@cloudbase/js-sdk 2.31.0 → 2.32.0

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/CHANGELOG.md CHANGED
@@ -1,151 +1,27 @@
1
1
  # 更新日志
2
2
 
3
- ## [3.5.0] 2026-06-23
4
- - [Added] Storage 模块新增 Neo 环境对象存储能力,`app.storage.from(bucketId)` 返回全新对象存储客户端(上传/下载/删除/移动/复制/签名 URL 等)
5
- - [Added] `app.storage` 新增 Bucket 管理 API:`listBuckets` / `getBucket` / `createBucket` / `updateBucket` / `deleteBucket`
6
- - [Added] Auth 模块新增 `AuthErrorCode` 数字错误码枚举及 `AuthError.errorCode`、`retryAfter` 属性
7
- - [Added] `AuthErrorCategory` 新增 `RATE_LIMITED`、`CAPTCHA_REQUIRED`、`CAPTCHA_INVALID`、`MFA_REQUIRED`、`PRECONDITION_FAILED`、`VERIFICATION_FAILED` 分类
8
- - [Changed] `app.storage.from()` 无参仍返回 `ClassicStorageFileApi`(行为不变);传入 `bucketId` 返回 Neo 对象存储客户端
9
- - [Deprecated] 传统顶层云存储 API(`uploadFile` / `downloadFile` / `deleteFile` 等)标记为废弃,推荐改用 `app.storage.from(bucketId)` 新 API
10
- - [Fixed] Auth `updateUser` 中 `verifyOtp` 校验失败时正确返回错误;仅在实际修改时触发 `USER_UPDATED` 事件
11
- - [Fixed] 验证码发送补充 `target: 'USER'` 参数;修复 abort 监听器泄漏、容错解析非 JSON 响应体
3
+ ## [2.32.0] 2026-07-28
4
+ - [Changed] Node 入口不再于模块加载时自动注册 adapter-node,避免打包器解析 Node 专属依赖导致的构建报错
12
5
 
13
- ## [3.4.8] 2026-06-16
14
- - [Fixed] 修复 `getUser` 和 `getSession` 在无凭证或 `accessKey` 模式下返回 `user` 统一返回 `null`
6
+ ## [2.31.0] 2026-07-02
7
+ - [Added] AI 生图新增图片模型参数校验及标准错误类
8
+ - [Added] AI 生图支持新模型 HY-Image-v3.0-I2I-ToB-v1.0.1
9
+ - [Added] 补充类型说明
15
10
 
16
- ## [3.4.7] 2026-06-16
17
- - [Fixed] Auth 模块 `verifyOtp` `token` 参数兼容 `number` 和 `string` 类型
11
+ ## [2.30.0] 2026-06-29
12
+ - [Changed] AI 生图默认采用 ar 新路径,老模型走 images/generations
18
13
 
19
- ## [3.4.6] 2026-06-12
20
- - [Refactor] 重构 Node.js adapter 层,整合微信云开发相关请求逻辑(callWxOpenApi / callWxPayApi / callCompatibleWxOpenApi / wxCallContainerApi)
21
- - [Fixed] 修复微信云开发 form-data 请求返回值格式与旧版不一致的问题,正确返回 Buffer 类型响应
22
- - [Changed] request 模块新增 responseType: 'buffer' 支持,兼容二进制响应场景
14
+ ## [2.29.0] 2026-06-23
15
+ - [Added] auth 相关接口更新,返回值对齐 supabase
16
+ - [Changed] updateUser 支持不传 target
17
+ - [Changed] 优化错误捕获逻辑
23
18
 
24
- ## [3.4.5] 2026-06-10
25
- - [Fixed] 服务端 body stream 时设置 duplex: 'half'
19
+ ## [2.28.6] 2026-05-19
20
+ - [Changed] 更新 fetch auth 处理逻辑
21
+ - [Added] 更新类型说明
26
22
 
27
- ## [3.4.4] 2026-06-10
28
- - [Fixed] 服务端增加 `bson` 依赖
29
-
30
- ## [3.4.3] 2026-06-10
31
- - [Fixed] 修复 Node.js 环境下调用 downloadFile 报 `window is not defined` 的问题
32
-
33
- ## [3.4.2] 2026-06-10
34
- - [Fixed] 修复 bundledDependencies 子包版本号导致 yarn install 时从 registry 查找失败的问题
35
-
36
- ## [3.4.1] 2026-06-10
37
- - [Fixed] 修复 database 模块文档查询相关问题
38
-
39
- ## [3.4.0] 2026-06-09
40
- - [Changed] 移除 analytics 模块,不再随主包发布
41
- - [Changed] 子模块随主包一起发布,不再单独进行模块独立版本更新
42
- - [Added] 支持 sub-path exports 按需引入(如 `@cloudbase/js-sdk/auth`)
43
-
44
- ## [3.3.13] 2026-05-29
45
- - [Fixed] 修复云函数相关问题
46
-
47
- ## [3.3.12] 2026-05-28
48
- - [Fixed] 适配 v1/user/me 接口返回字段变化,hasPassword 改用 password === 'SET' 判断
49
-
50
- ## [3.3.11] 2026-05-26
51
- - [Fixed] 修复 _getCredentials 中 credentials 为空时访问 scope 属性报错的问题
52
-
53
- ## [3.3.10] 2026-05-19
54
- - [Changed] fetch 请求支持 withCredentials 参数控制是否携带鉴权信息
55
-
56
- ## [3.3.9] 2026-05-08
57
- - [Changed] endPointMode 默认值更新为 GATEWAY
58
-
59
- ## [3.3.8] 2026-05-07
60
- - [Added] getUser 支持从 providers 中匹配当前小程序 appId 对应的 open_id
61
-
62
- ## [3.3.7] 2026-05-06
63
- - [Fixed] getUser 返回用户信息支持 open_id 字段
64
-
65
- ## [3.3.6] 2026-04-30
66
- - [Added] 文档型数据库支持批量新增数据
67
-
68
- ## [3.3.5] 2026-04-29
69
- - [Added] 添加类型定义
70
-
71
- ## [3.3.4] 2026-04-21
72
- - [Added] database where条件支持事务
73
-
74
- ## [3.3.3] 2026-04-17
75
- - [Fixed] signUp 修复 phone_number 为空时格式化报错的问题
76
-
77
- ## [3.3.2] 2026-04-13
78
- - [Changed] getUser/getCurrentUser 支持 isRefresh 参数控制是否发请求获取最新用户信息,默认每次请求最新数据
79
-
80
- ## [3.3.1] 2026-04-13
81
- - [Added] getUser 支持读缓存和读接口数据可选
82
-
83
- ## [3.3.0] 2026-04-08
84
- - [Added] database 支持 http api
85
-
86
- ## [3.2.2] 2026-04-02
87
- - [Added] signInWithOtp 支持 emailRedirectTo
88
-
89
- ## [3.2.1] 2026-03-24
90
- - [Added] 增加帮助信息
91
-
92
- ## [3.2.0] 2026-03-23
93
- - [Added] 小程序手机号授权支持服务商类型小程序
94
-
95
- ## [3.1.12] 2026-03-16
96
- - [Fixed] node 模式下请求参数增加 envName
97
-
98
- ## [3.1.11] 2026-03-16
99
- - [Fixed] node 模式下 v3 签名兼容 headers 为空场景
100
-
101
- ## [3.1.9] 2026-03-13
102
- - [Added] 增强类型声明以及错误提示
103
-
104
- ## [3.1.8] 2026-03-12
105
- - [Fixed] 增加 storage 类型定义
106
-
107
- ## [3.1.7] 2026-03-12
108
- - [Fixed] getVerification 增加 phone_number 参数格式化
109
-
110
- ## [3.1.6] 2026-03-12
111
- - [Added] signInWithOtp 增加可选参数 options.shouldCreateUser 控制是否自动注册用户
112
-
113
- ## [3.1.5] 2026-03-11
114
- - [Changed] 完善 database 类型定义
115
- - [Added] 异常时增加 requestId 返回
116
-
117
- ## [3.1.4] 2026-03-11
118
- - [Fixed] verifyOAuth 返回预设重定向地址
119
-
120
- ## [3.1.3] 2026-03-10
121
- - [Fixed] verifyOAuth 兼容 hash 地址
122
-
123
- ## [3.1.2] 2026-03-06
124
- - [Fixed] 修复 HBuilderX 找不到 SourceMap 问题
125
-
126
- ## [3.1.1] 2026-03-03
127
- - [Changed] 更新微信小程序端adapter
128
-
129
- ## [3.1.0] 2026-03-03
130
- - [Fixed] 兼容多端
131
-
132
- ## [3.0.6] 2026-03-03
133
- - [Fixed] 修复 Node.js 端签名问题
134
-
135
- ## [3.0.5] 2026-03-01
136
- - [Added] Node.js 端支持 SecretId 和 SecretKey
137
-
138
- ## [3.0.4] 2026-02-27
139
- - [Added] 支持 Node.js 端
140
-
141
- ## [3.0.3] 2026-02-26
142
- - [Fixed] 修复用户信息nickName获取问题
143
-
144
- ## [3.0.2] 2026-02-12
145
- - [Fixed] 修复用户信息role获取问题
146
-
147
- ## [3.0.0] 2026-02-10
148
- - [Changed] endPointMode 默认启用 GATEWAY 模式
23
+ ## [2.28.5] 2026-05-07
24
+ - [Changed] getUser 返回的 user 信息过滤 open_id 字段
149
25
 
150
26
  ## [2.28.4] 2026-05-06
151
27
  - [Fixed] getUser 返回用户信息支持 open_id 字段
@@ -1,2 +1,2 @@
1
- import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as n from"@cloudbase/adapter-wx_mp";var o={d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};o.d(r,{Z:()=>Mt});var i="@cloudbase/js-sdk";function a(){return i}var s="https:",c={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};const u=(l={AbstractSDKRequest:()=>t.AbstractSDKRequest,AbstractStorage:()=>t.AbstractStorage,StorageType:()=>t.StorageType},p={},o.d(p,l),p);var l,p;function f(t){return"[object FormData]"===Object.prototype.toString.call(t)}function d(t,e,n){void 0===n&&(n={});var o=/\?/.test(e),r="";return Object.keys(n).forEach((function(t){""===r?!o&&(e+="?"):r+="&",r+="".concat(t,"=").concat(encodeURIComponent(n[t]))})),/^http(s)?:\/\//.test(e+=r)?e:"".concat(t).concat(e)}function h(t,e){console.warn("[".concat(a(),"][").concat(t,"]:").concat(e))}function v(t){var e={},n=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(n){t=n[1];var o=n[2];o&&(e=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var n=t.split("="),o=n[0],r=n[1];o=decodeURIComponent(o),r=decodeURIComponent(r),o&&(e[o]?Array.isArray(e[o])?e[o].push(r):e[o]=[e[o],r]:e[o]=r)})),e}(o))}var r=e.token,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(e,["token"]);return/^data:/.test(t)&&!r?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:r?{state:i.state,token:r,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}var y,g,b=(y=function(t,e){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},y(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}y(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),m=function(){return m=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},m.apply(this,arguments)},w=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))},O=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},A=function(t){function e(e){var n=t.call(this)||this,o=e.timeout,r=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=o||0,n.timeoutMsg=r||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return b(e,t),e.prototype.get=function(t){return this.request(m(m({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(m(m({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(m(m({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,o=t.name,r=t.method,i=t.headers,a=void 0===i?{}:i,s={post:"post",put:"put"}[null==r?void 0:r.toLowerCase()]||"put",c=new FormData;return"post"===s?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",o),c.append("file",n),this.request(m(m({},t),{data:c,method:s}),this.restrictedMethods.includes("upload"))):this.request(m(m({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return w(this,void 0,Promise,(function(){var e,n,o,r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(m(m({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),o=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(r=document.createElement("a")).href=n,r.setAttribute("download",o),r.style.display="none",document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return w(this,void 0,Promise,(function(){var n,o,r,i,a,s,c,u,l,p,f,d,h,v=this;return O(this,(function(y){switch(y.label){case 0:return n=new AbortController,o=t.url,r=t.enableAbort,i=void 0!==r&&r,a=t.stream,s=void 0!==a&&a,c=t.signal,u=t.timeout,l=t.shouldThrowOnError,p=void 0===l||l,f=null!=u?u:this.timeout,c&&(c.aborted&&n.abort(),c.addEventListener("abort",(function(){return n.abort()}))),d=null,i&&f&&(d=setTimeout((function(){console.warn(v.timeoutMsg),n.abort(new Error(v.timeoutMsg))}),f)),[4,fetch(o,m(m({},t),{signal:n.signal})).then((function(t){return w(v,void 0,void 0,(function(){var e,n,o;return O(this,(function(r){switch(r.label){case 0:return clearTimeout(d),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return o=(n=Promise).reject,[4,t.json()];case 2:e=o.apply(n,[r.sent()]),r.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){return clearTimeout(d),Promise.reject(t)}))];case 1:return h=y.sent(),[2,{data:s?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.headers,response:h}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var o=String(t.method).toLowerCase()||"get";return new Promise((function(r){var i=t.url,a=t.headers,c=void 0===a?{}:a,u=t.data,l=t.responseType,p=t.withCredentials,h=t.body,v=t.onUploadProgress,y=d(s,i,"get"===o?u:{}),g=new XMLHttpRequest;g.open(o,y),l&&(g.responseType=l);var b,m,w=t.signal;w&&(w.aborted?g.abort():w.addEventListener("abort",(function(){return g.abort()}),{once:!0})),Object.keys(c).forEach((function(t){g.setRequestHeader(t,c[t])})),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),o=e.shift().toLowerCase(),r=e.join(": ");n[o]=r})),t.header=n,t.statusCode=g.status;try{t.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===l?g.response:g.responseText}clearTimeout(b),r(t)}},e&&n.timeout&&(b=setTimeout((function(){console.warn(n.timeoutMsg),g.abort()}),n.timeout)),m=f(u)?u:"application/x-www-form-urlencoded"===c["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")}(u):h||(u?JSON.stringify(u):void 0),p&&(g.withCredentials=!0),g.send(m)}))},e}(u.AbstractSDKRequest),I=function(){return I=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},I.apply(this,arguments)};!function(t){t.WEB="web",t.WX_MP="wx_mp"}(g||(g={}));var E=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),P=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))},S=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},_=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return E(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(u.AbstractStorage),C=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,o=void 0===n?{}:n,r=t.keys,i=void 0===r?{}:r;this.platformInfo=o,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(h(c.INVALID_PARAMS,"localStorage is not supported on current platform"),new _(e.root));case"none":return new _(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var o={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(o))}catch(t){throw new Error(JSON.stringify({code:c.OPERATION_FAIL,msg:"[".concat(a(),"][").concat(c.OPERATION_FAIL,"]setStore failed"),info:t}))}}else h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return P(this,void 0,void 0,(function(){var o;return S(this,(function(r){switch(r.label){case 0:if(!this.storage)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),o={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(o))];case 2:return r.sent(),[3,4];case 3:return r.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var o=this.storage.getItem(t);return o&&o.indexOf(e)>=0?JSON.parse(o).content:""}h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return P(this,void 0,void 0,(function(){var o;return S(this,(function(r){switch(r.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(o=r.sent())&&o.indexOf(e)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return P(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),j=function(t,e){this.data=e||null,this.name=t},R=function(t){function e(e,n){var o=t.call(this,"error",{error:e,data:n})||this;return o.error=e,o}return x(e,t),e}(j),k=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var o=n[t].indexOf(e);-1!==o&&n[t].splice(o,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof R)return console.error(t.error),this;var n="string"==typeof t?new j(t,e||{}):t,o=n.name;if(this.listens(o)){n.target=this;for(var r=0,i=this.listeners[o]?function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}([],this.listeners[o],!0):[];r<i.length;r++)i[r].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new k;var T=new k,N="lang_change";"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const D=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});D.default;var L=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))},U=c,M={};function q(t,e){var n=e.name,o=e.namespace,r=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(M[n]||o&&t[o])throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(s){if(!r||"function"!=typeof r)throw new Error(JSON.stringify({code:U.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));r.call(t)}if(M[n]=e,o?t.prototype[o]=r:W(t.prototype,r),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var l=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=L(L([],t.prototype.events[n].events,!0),u,!0):t.prototype.events[n]={bus:c,events:u},t.prototype.fire=function(t,e){l(t,e);for(var n=0,o=Object.keys(this.events);n<o.length;n++){var r=o[n],i=this.events[r],a=i.bus;if(i.events.includes(t)){a.fire(t,e);break}}}}}function W(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n=0,o=Object.keys(e);n<o.length;n++){var r=o[n];Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=W(t[r],e[r]))}return t}const V=(t=>{var e={};return o.d(e,t),e})({WxMpWebSocket:()=>n.WxMpWebSocket,WxRequest:()=>n.WxRequest,default:()=>n.default,parseQueryString:()=>n.parseQueryString,wxMpStorage:()=>n.wxMpStorage});var B=function(){return B=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},B.apply(this,arguments)},H={},F=function(){return F=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},F.apply(this,arguments)},K=C,J={},X={};function G(t){var e=t.env,n=t.platformInfo,o={userInfoKey:"".concat("user_info","_").concat(e)};J[e]=J[e]||new K(F(F({},t),{keys:o,platformInfo:n})),X[e]=X[e]||new K(F(F({},t),{keys:o,platformInfo:n,persistence:"local"}))}function Y(t){return X[t]}var Q=function(){return Q=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},Q.apply(this,arguments)},$="",z="@cloudbase/js-sdk";function Z(){return $}var tt,et=[],nt=["env","endPointKey","region"],ot="https:";function rt(t){return et.find((function(e){return nt.filter((function(e){return null!=t[e]})).every((function(n){return e[n]===t[n]}))}))}function it(t){var e,n;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var o,r=rt(t);r?(null!=t.baseUrl&&(r.baseUrl=t.baseUrl),null!=t.protocol&&(r.protocol=t.protocol)):et.push(Q(Q({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:ot})),"CLOUD_API"===t.endPointKey&&(o=null!==(n=t.protocol)&&void 0!==n?n:ot,s=o)}function at(t,e,n){return rt({env:t,endPointKey:e,region:n})}function st(t,e){void 0===e&&(e="CLOUD_API");var n=at(t,e||"CLOUD_API"),o=n.protocol,r=n.baseUrl;return"".concat(o).concat(r).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(tt||(tt={}));var ct=function(){return ct=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},ct.apply(this,arguments)},ut=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))},lt=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},pt=c,ft=f,dt=d,ht=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function vt(t,e,n){var o=t[e];t[e]=function(e){var r={},i={};n.forEach((function(n){var o=n.call(t,e),a=o.data,s=o.headers;Object.assign(r,a),Object.assign(i,s)}));var a=e.data;return a&&(ft(a)?Object.keys(r).forEach((function(t){a.append(t,r[t])})):e.data=ct(ct({},a),r)),e.headers=ct(ct({},e.headers||{}),i),o.call(t,e)}}function yt(){var t=Math.random().toString(16).slice(2);return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z()),"x-seqid":t}}}var gt,bt,mt=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var n={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:t.auth};this.reqClass=new H.adapter.reqClass(n),this.throwWhenRequestFail=t.throw||!1,this.localCache=Y(this.config.env),"GATEWAY"!==this.config.endPointMode&&(vt(this.reqClass,"post",[yt]),vt(this.reqClass,"upload",[yt]),vt(this.reqClass,"download",[yt])),T.on(N,(function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n}))}return t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),ut(this,void 0,void 0,(function(){var e,n,o;return lt(this,(function(r){switch(r.label){case 0:if(null!=t)return[2,t];if(!(e=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=e.oauthInstance,o=n.oauth2client,[4,this.getOauthAccessTokenV2(o)];case 1:return[2,r.sent().accessToken]}}))}))},t.prototype.getDefaultHeaders=function(){var t,e,n;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,t["X-SDK-Version"]="@cloudbase/js-sdk/".concat(Z()),t},t.prototype.post=function(t,e){return ut(this,void 0,Promise,(function(){return lt(this,(function(n){switch(n.label){case 0:return[4,this.reqClass.post(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}}))}))},t.prototype.upload=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),st(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return ut(this,void 0,Promise,(function(){var e,n;return lt(this,(function(o){switch(o.label){case 0:return[4,t.getAccessToken()];case 1:return e=o.sent(),[4,t.getCredentials()];case 2:return n=o.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n,o){var r,i;return ut(this,void 0,Promise,(function(){var a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O,A,I,E,P,S,_,C;return lt(this,(function(x){switch(x.label){case 0:if(x.trys.push([0,4,,5]),a="x-tcb-trace_".concat(this.config.env),s="application/x-www-form-urlencoded",c=ct({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==ht.indexOf(t))return[3,2];if(!(u=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return l=u.oauthInstance,p=l.oauth2client,f=c,[4,this.getOauthAccessTokenV2(p)];case 1:f.access_token=x.sent().accessToken,x.label=2;case 2:return"storage.uploadFile"===t?(d=new FormData,Object.keys(d).forEach((function(t){Object.prototype.hasOwnProperty.call(d,t)&&void 0!==d[t]&&d.append(t,c[t])})),s="multipart/form-data"):(s="application/json;charset=UTF-8",d={},Object.keys(c).forEach((function(t){void 0!==c[t]&&(d[t]=c[t])}))),h={headers:ct(ct({"content-type":s},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(v=this.localCache.getStore(a))&&(h.headers["X-TCB-Trace"]=v),y=void 0!==(null==n?void 0:n.parse)?n.parse:e.parse,g=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:e.inQuery,b=void 0!==(null==n?void 0:n.search)?n.search:e.search,m=ct(ct({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),g&&(m=ct(ct({},g),m)),w=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",O=at(this.config.env,w),A=O.baseUrl,I=O.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(E=at(this.config.env,"CLOUD_API"),A="".concat(E.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),P=void 0,P=n.pathname?dt(I,"".concat(null===(r=st(this.config.env,w))||void 0===r?void 0:r.replace(/^https?:/,""),"/").concat(n.pathname),m):dt(I,A,m),b&&(P+=b),[4,this.post(ct({url:P,data:d},h),o)];case 3:if(S=x.sent(),(_=null===(i=S.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(a,_),200!==Number(S.status)&&200!==Number(S.statusCode)||!S.data)throw new Error("network request error");return[2,S];case 4:C=x.sent();try{C.requestId=C.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw C;case 5:return[2]}}))}))},t.prototype.fetch=function(t){var e,n,o,r,i,a,s,c;return ut(this,void 0,Promise,(function(){var u,l,p,f,d,h,v,y,g=this;return lt(this,(function(b){switch(b.label){case 0:u=t.token,l=t.headers,p=void 0===l?{}:l,f=t.withCredentials,d=void 0===f||f,h=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(t,["token","headers","withCredentials"]),v=function(){return ut(g,void 0,void 0,(function(){var t,e,n,o;return lt(this,(function(r){switch(r.label){case 0:return t={},d?(e=t,n="Bearer ".concat,[4,this.getAccessToken(u)]):[3,2];case 1:e.Authorization=n.apply("Bearer ",[r.sent()]),r.label=2;case 2:return o=ct({headers:ct(ct(ct({"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z())},t),this.getDefaultHeaders()),p),withCredentials:d},h),[2,this.reqClass.fetch(o)]}}))}))},b.label=1;case 1:return b.trys.push([1,3,,6]),[4,v()];case 2:return[2,b.sent()];case 3:y=b.sent();try{y.requestId=y.requestId||p["x-request-id"]||p["X-Request-Id"]||""}catch(t){}if("ACCESS_TOKEN_EXPIRED"!==(null==y?void 0:y.code))return[3,5];if("function"!=typeof(null===(r=null===(o=null===(n=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===o?void 0:o.authApi)||void 0===r?void 0:r.refreshTokenForce))throw y;return[4,null===(c=null===(s=null===(a=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===a?void 0:a.oauthInstance)||void 0===s?void 0:s.authApi)||void 0===c?void 0:c.refreshTokenForce()];case 4:return b.sent(),[2,v()];case 5:throw y;case 6:return[2]}}))}))},t.prototype.send=function(t,e,n,o){return void 0===e&&(e={}),void 0===n&&(n={}),ut(this,void 0,Promise,(function(){var r;return lt(this,(function(i){switch(i.label){case 0:return[4,this.request(t,e,ct(ct({},n),{onUploadProgress:e.onUploadProgress}),o)];case 1:if((r=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:pt.OPERATION_FAIL,msg:"[".concat(r.data.code,"] ").concat(r.data.message)}));return[2,r.data]}}))}))},t.prototype.gateWay=function(t,e){var n;return ut(this,void 0,void 0,(function(){var o,r,i,a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O;return lt(this,(function(A){switch(A.label){case 0:if(o=t.url,r=t.name,i=t.data,a=t.path,s=void 0===a?"":a,c=t.method,u=t.header,l=void 0===u?{}:u,!(r&&s||o))throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{p=i?JSON.stringify(i):""}catch(t){throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(I=(new Date).getTime(),E=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0,f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random();return I>0?(e=(I+e)%16|0,I=Math.floor(I/16)):(e=(E+e)%16|0,E=Math.floor(E/16)),("x"===t?e:7&e|8).toString(16)})),d=at(this.config.env,"GATEWAY"),h=d.baseUrl,v=d.protocol,y="".concat(v).concat(h).concat(o||"/".concat(s,"/").concat(r)),g=["GET","HEAD"].includes(null===(n=null==c?void 0:c.toUpperCase)||void 0===n?void 0:n.call(c)))try{b={};try{b=JSON.parse(i)}catch(t){b=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(b).map((function(t){return"".concat(t,"=").concat(b[t])})).join("&"))}catch(t){}return[4,this.fetch(ct(ct({method:c||"POST",headers:ct({"Content-Type":"application/json; charset=utf-8","X-Request-Id":f},l)},g?{}:{body:p}),{url:y,customReqOpts:e}))];case 1:return m=A.sent(),w=[ct({requestId:f},m)],O={},[4,m.data];case 2:return[2,ct.apply(void 0,w.concat([(O.data=A.sent(),O)]))]}var I,E}))}))},t}(),wt={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(bt||(bt={}));var Ot=((gt={})[bt.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code",错误信息:"error message",未实现:"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs",请求超时:"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},gt),At=function(t,e){var n;return(null===(n=Ot[e])||void 0===n?void 0:n[t])||t},It=function(t,e){var n,o,r=function(t){return"lang_".concat(t.clientId||t.env)}(e),i=(t.adapter||{}).localStorage,a=e.lang||(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||bt.ZH;return null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,a),new Proxy({t:function(t){return At(t,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(t,e){var n;return"lang"===e&&(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||t[e]},set:function(t,e,n){var o;return"lang"===e&&n!==t[e]&&(t[e]=n,t.t=function(t){return At(t,n)},null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,n),T.fire(N,{i18n:t})),t[e]=n,!0}})},Et=function(){return Et=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},Et.apply(this,arguments)},Pt=function(t,e,n,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a},St=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},_t=function(){return{adapter:I({},{type:"default",root:window,reqClass:A,wsClass:WebSocket,localStorage}),runtime:g.WEB}},Ct=c,xt="https://support.qq.com/products/148793",jt=h,Rt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},kt={timeout:15e3,persistence:"local"},Tt=6e5,Nt={},Dt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=Z()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return H},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,J[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return Y(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,wt[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,r;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"CLOUD_API",H.adapter||this.useDefaultAdapter(),!(e=this.dealNodeAdapterConfig(e)).env)throw new Error(JSON.stringify({code:Ct.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var i={timeout:e.timeout||15e3,timeoutMsg:"[".concat(z,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s"),auth:e.auth};this.requestClient=new H.adapter.reqClass(i),this.cloudbaseConfig=Et(Et(Et({},kt),e),{i18n:It(H,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var a=this.cloudbaseConfig,s=a.env,c=a.persistence,u=a.debug,l=a.timeout,p=a.oauthClient,f=a.i18n;G({env:s,persistence:c,debug:u,platformInfo:this.platform}),function(t,e){it({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(s,e.region||""),function(t,e,n){var o="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(o="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),it({endPointKey:"GATEWAY",env:t,baseUrl:o,protocol:e})}(s,ot,e.intl);var d=new t(this.cloudbaseConfig);return function(t){wt[t.env]=new mt(ct(ct({},t),{throw:!0}))}({env:s,region:e.region||"",timeout:l,oauthClient:p,_fromApp:d,i18n:f,endPointMode:e.endPointMode,auth:e.auth}),d.requestClient=this.requestClient,null===(n=null==this?void 0:this.fire)||void 0===n||n.call(this,"cloudbase_init",d),this.try2InitAuth(d),(null===(o=H.adapter)||void 0===o?void 0:o.nodeTool)&&(null===(r=H.adapter)||void 0===r||r.nodeTool(d,this.cloudbaseConfig)),d},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,G({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){Nt[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,o=void 0,i=function(){var n;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,(function(o){switch(o.label){case 0:if(!(n=Nt[t]))throw new Error(JSON.stringify({code:Ct.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,o.sent()]}}))},new((r=void 0)||(r=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function s(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((i=i.apply(n,o||[])).next())}));var n,o,r,i},t.prototype.useAdapters=function(t,e){var n=function(t,e){for(var n,o=0,r=(n=t,"[object Array]"===Object.prototype.toString.call(n)?t:[t]);o<r.length;o++){var i=r[o],a=i.isMatch,s=i.genAdapter,c=i.runtime;if(a())return{adapter:I({isMatch:a},s(e)),runtime:c}}}(t,e)||{},o=n.adapter,r=n.runtime;o&&(H.adapter=o),r&&(H.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,o=e.target;if(Object.prototype.hasOwnProperty.call(t,o))throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"target:".concat(o," is not exist")}));var r=t.prototype[o];if("function"!=typeof r)throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"target:".concat(o," is not a function which is the only type supports hook")}));t.prototype[o]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,L([this],t,!1)),r.call.apply(r,L([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){q(t,e)},t.prototype.registerVersion=function(t){!function(t){$=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){z=t,function(t){i=t}(t)}(t)},t.prototype.isInitialized=function(t){return void 0===t&&(t=this.cloudbaseConfig),["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some((function(e){return t.env.toLowerCase()===e.toLowerCase()}))&&jt(Ct.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(t.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==t?void 0:t.env)},t.prototype.registerEndPoint=function(t,e){it({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){it({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.getEndPointWithKey=function(t){var e=at(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return v(t)},t.prototype.useDefaultAdapter=function(){var t=_t.bind(this)(),e=t.adapter,n=t.runtime;H.adapter=e,H.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>Tt:return jt(Ct.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Tt;case t<100:return jt(Ct.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},t.prototype.try2InitAuth=function(t){try{t.auth()}catch(t){console.log("try2InitAuth error:",t)}},t.prototype.dealNodeAdapterConfig=function(t){return t},Pt([Rt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),St("design:type",Function),St("design:paramtypes",[Object]),St("design:returntype",t)],t.prototype,"init",null),Pt([Rt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),St("design:type",Function),St("design:paramtypes",[String,Object]),St("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),Lt=new Dt;Lt.useAdapters((V.WxRequest.prototype.upload=function(t){var e=this,n=this;return new Promise((function(o){var r=t.url,i=t.file,a=t.data,s=t.headers,c=wx.getFileSystemManager(),u=wx.request({url:r,method:t.method,header:B({"content-type":" "},s),data:c.readFileSync(i),timeout:e._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&(null==a?void 0:a.success_action_status)&&(e.statusCode=parseInt(a.success_action_status,10)),o(e)},fail:function(t){o(t)},complete:function(t){if((null==t?void 0:t.errMsg)&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},V.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:V.WxRequest,wsClass:V.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(e){var n=t.EventBus,o={},r=e;console.log("openURIWithCallback",e);var i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){r=i[1],console.log("openURIWithCallback url",r);var a=i[2];a&&(o=(0,V.parseQueryString)(a))}console.log("openURIWithCallback queryObj",o);var s=o.token,c=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(o,["token"]);return/^data:/.test(r)&&!s?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(e)}):s?new Promise((function(t){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",B(B({},c),{token:s,url:r})),n.$once("RESOLVE_CAPTCHA_DATA",(function(e){t(e)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:V.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},V.default));const Ut=Lt;Ut.registerVersion("2.30.0");try{window.cloudbase=Ut}catch(t){}const Mt=Ut;var qt=r.Z;export{qt as default};
1
+ import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as n from"@cloudbase/adapter-wx_mp";var o={d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};o.d(r,{Z:()=>Mt});var i="@cloudbase/js-sdk";function a(){return i}var s="https:",c={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};const u=(l={AbstractSDKRequest:()=>t.AbstractSDKRequest,AbstractStorage:()=>t.AbstractStorage,StorageType:()=>t.StorageType},p={},o.d(p,l),p);var l,p;function f(t){return"[object FormData]"===Object.prototype.toString.call(t)}function d(t,e,n){void 0===n&&(n={});var o=/\?/.test(e),r="";return Object.keys(n).forEach((function(t){""===r?!o&&(e+="?"):r+="&",r+="".concat(t,"=").concat(encodeURIComponent(n[t]))})),/^http(s)?:\/\//.test(e+=r)?e:"".concat(t).concat(e)}function h(t,e){console.warn("[".concat(a(),"][").concat(t,"]:").concat(e))}function v(t){var e={},n=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(n){t=n[1];var o=n[2];o&&(e=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var n=t.split("="),o=n[0],r=n[1];o=decodeURIComponent(o),r=decodeURIComponent(r),o&&(e[o]?Array.isArray(e[o])?e[o].push(r):e[o]=[e[o],r]:e[o]=r)})),e}(o))}var r=e.token,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(e,["token"]);return/^data:/.test(t)&&!r?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:r?{state:i.state,token:r,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}var y,g,b=(y=function(t,e){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},y(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}y(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),m=function(){return m=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},m.apply(this,arguments)},w=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))},O=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},A=function(t){function e(e){var n=t.call(this)||this,o=e.timeout,r=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=o||0,n.timeoutMsg=r||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return b(e,t),e.prototype.get=function(t){return this.request(m(m({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(m(m({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(m(m({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,o=t.name,r=t.method,i=t.headers,a=void 0===i?{}:i,s={post:"post",put:"put"}[null==r?void 0:r.toLowerCase()]||"put",c=new FormData;return"post"===s?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",o),c.append("file",n),this.request(m(m({},t),{data:c,method:s}),this.restrictedMethods.includes("upload"))):this.request(m(m({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return w(this,void 0,Promise,(function(){var e,n,o,r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(m(m({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),o=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(r=document.createElement("a")).href=n,r.setAttribute("download",o),r.style.display="none",document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return w(this,void 0,Promise,(function(){var n,o,r,i,a,s,c,u,l,p,f,d,h,v=this;return O(this,(function(y){switch(y.label){case 0:return n=new AbortController,o=t.url,r=t.enableAbort,i=void 0!==r&&r,a=t.stream,s=void 0!==a&&a,c=t.signal,u=t.timeout,l=t.shouldThrowOnError,p=void 0===l||l,f=null!=u?u:this.timeout,c&&(c.aborted&&n.abort(),c.addEventListener("abort",(function(){return n.abort()}))),d=null,i&&f&&(d=setTimeout((function(){console.warn(v.timeoutMsg),n.abort(new Error(v.timeoutMsg))}),f)),[4,fetch(o,m(m({},t),{signal:n.signal})).then((function(t){return w(v,void 0,void 0,(function(){var e,n,o;return O(this,(function(r){switch(r.label){case 0:return clearTimeout(d),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return o=(n=Promise).reject,[4,t.json()];case 2:e=o.apply(n,[r.sent()]),r.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){return clearTimeout(d),Promise.reject(t)}))];case 1:return h=y.sent(),[2,{data:s?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.headers,response:h}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var o=String(t.method).toLowerCase()||"get";return new Promise((function(r){var i=t.url,a=t.headers,c=void 0===a?{}:a,u=t.data,l=t.responseType,p=t.withCredentials,h=t.body,v=t.onUploadProgress,y=d(s,i,"get"===o?u:{}),g=new XMLHttpRequest;g.open(o,y),l&&(g.responseType=l);var b,m,w=t.signal;w&&(w.aborted?g.abort():w.addEventListener("abort",(function(){return g.abort()}),{once:!0})),Object.keys(c).forEach((function(t){g.setRequestHeader(t,c[t])})),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),o=e.shift().toLowerCase(),r=e.join(": ");n[o]=r})),t.header=n,t.statusCode=g.status;try{t.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===l?g.response:g.responseText}clearTimeout(b),r(t)}},e&&n.timeout&&(b=setTimeout((function(){console.warn(n.timeoutMsg),g.abort()}),n.timeout)),m=f(u)?u:"application/x-www-form-urlencoded"===c["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")}(u):h||(u?JSON.stringify(u):void 0),p&&(g.withCredentials=!0),g.send(m)}))},e}(u.AbstractSDKRequest),I=function(){return I=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},I.apply(this,arguments)};!function(t){t.WEB="web",t.WX_MP="wx_mp"}(g||(g={}));var E=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),P=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))},S=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},_=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return E(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(u.AbstractStorage),C=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,o=void 0===n?{}:n,r=t.keys,i=void 0===r?{}:r;this.platformInfo=o,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(h(c.INVALID_PARAMS,"localStorage is not supported on current platform"),new _(e.root));case"none":return new _(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var o={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(o))}catch(t){throw new Error(JSON.stringify({code:c.OPERATION_FAIL,msg:"[".concat(a(),"][").concat(c.OPERATION_FAIL,"]setStore failed"),info:t}))}}else h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return P(this,void 0,void 0,(function(){var o;return S(this,(function(r){switch(r.label){case 0:if(!this.storage)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),o={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(o))];case 2:return r.sent(),[3,4];case 3:return r.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var o=this.storage.getItem(t);return o&&o.indexOf(e)>=0?JSON.parse(o).content:""}h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return P(this,void 0,void 0,(function(){var o;return S(this,(function(r){switch(r.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(o=r.sent())&&o.indexOf(e)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return P(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),j=function(t,e){this.data=e||null,this.name=t},R=function(t){function e(e,n){var o=t.call(this,"error",{error:e,data:n})||this;return o.error=e,o}return x(e,t),e}(j),k=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var o=n[t].indexOf(e);-1!==o&&n[t].splice(o,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof R)return console.error(t.error),this;var n="string"==typeof t?new j(t,e||{}):t,o=n.name;if(this.listens(o)){n.target=this;for(var r=0,i=this.listeners[o]?function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}([],this.listeners[o],!0):[];r<i.length;r++)i[r].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new k;var T=new k,N="lang_change";"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const D=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});D.default;var L=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))},U=c,M={};function q(t,e){var n=e.name,o=e.namespace,r=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(M[n]||o&&t[o])throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(s){if(!r||"function"!=typeof r)throw new Error(JSON.stringify({code:U.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));r.call(t)}if(M[n]=e,o?t.prototype[o]=r:W(t.prototype,r),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var l=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=L(L([],t.prototype.events[n].events,!0),u,!0):t.prototype.events[n]={bus:c,events:u},t.prototype.fire=function(t,e){l(t,e);for(var n=0,o=Object.keys(this.events);n<o.length;n++){var r=o[n],i=this.events[r],a=i.bus;if(i.events.includes(t)){a.fire(t,e);break}}}}}function W(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n=0,o=Object.keys(e);n<o.length;n++){var r=o[n];Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=W(t[r],e[r]))}return t}const V=(t=>{var e={};return o.d(e,t),e})({WxMpWebSocket:()=>n.WxMpWebSocket,WxRequest:()=>n.WxRequest,default:()=>n.default,parseQueryString:()=>n.parseQueryString,wxMpStorage:()=>n.wxMpStorage});var B=function(){return B=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},B.apply(this,arguments)},H={},F=function(){return F=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},F.apply(this,arguments)},K=C,J={},X={};function G(t){var e=t.env,n=t.platformInfo,o={userInfoKey:"".concat("user_info","_").concat(e)};J[e]=J[e]||new K(F(F({},t),{keys:o,platformInfo:n})),X[e]=X[e]||new K(F(F({},t),{keys:o,platformInfo:n,persistence:"local"}))}function Y(t){return X[t]}var Q=function(){return Q=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},Q.apply(this,arguments)},$="",z="@cloudbase/js-sdk";function Z(){return $}var tt,et=[],nt=["env","endPointKey","region"],ot="https:";function rt(t){return et.find((function(e){return nt.filter((function(e){return null!=t[e]})).every((function(n){return e[n]===t[n]}))}))}function it(t){var e,n;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var o,r=rt(t);r?(null!=t.baseUrl&&(r.baseUrl=t.baseUrl),null!=t.protocol&&(r.protocol=t.protocol)):et.push(Q(Q({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:ot})),"CLOUD_API"===t.endPointKey&&(o=null!==(n=t.protocol)&&void 0!==n?n:ot,s=o)}function at(t,e,n){return rt({env:t,endPointKey:e,region:n})}function st(t,e){void 0===e&&(e="CLOUD_API");var n=at(t,e||"CLOUD_API"),o=n.protocol,r=n.baseUrl;return"".concat(o).concat(r).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(tt||(tt={}));var ct=function(){return ct=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},ct.apply(this,arguments)},ut=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((o=o.apply(t,e||[])).next())}))},lt=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},pt=c,ft=f,dt=d,ht=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function vt(t,e,n){var o=t[e];t[e]=function(e){var r={},i={};n.forEach((function(n){var o=n.call(t,e),a=o.data,s=o.headers;Object.assign(r,a),Object.assign(i,s)}));var a=e.data;return a&&(ft(a)?Object.keys(r).forEach((function(t){a.append(t,r[t])})):e.data=ct(ct({},a),r)),e.headers=ct(ct({},e.headers||{}),i),o.call(t,e)}}function yt(){var t=Math.random().toString(16).slice(2);return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z()),"x-seqid":t}}}var gt,bt,mt=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var n={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:t.auth};this.reqClass=new H.adapter.reqClass(n),this.throwWhenRequestFail=t.throw||!1,this.localCache=Y(this.config.env),"GATEWAY"!==this.config.endPointMode&&(vt(this.reqClass,"post",[yt]),vt(this.reqClass,"upload",[yt]),vt(this.reqClass,"download",[yt])),T.on(N,(function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n}))}return t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),ut(this,void 0,void 0,(function(){var e,n,o;return lt(this,(function(r){switch(r.label){case 0:if(null!=t)return[2,t];if(!(e=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=e.oauthInstance,o=n.oauth2client,[4,this.getOauthAccessTokenV2(o)];case 1:return[2,r.sent().accessToken]}}))}))},t.prototype.getDefaultHeaders=function(){var t,e,n;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,t["X-SDK-Version"]="@cloudbase/js-sdk/".concat(Z()),t},t.prototype.post=function(t,e){return ut(this,void 0,Promise,(function(){return lt(this,(function(n){switch(n.label){case 0:return[4,this.reqClass.post(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}}))}))},t.prototype.upload=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),st(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return ut(this,void 0,Promise,(function(){var e,n;return lt(this,(function(o){switch(o.label){case 0:return[4,t.getAccessToken()];case 1:return e=o.sent(),[4,t.getCredentials()];case 2:return n=o.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n,o){var r,i;return ut(this,void 0,Promise,(function(){var a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O,A,I,E,P,S,_,C;return lt(this,(function(x){switch(x.label){case 0:if(x.trys.push([0,4,,5]),a="x-tcb-trace_".concat(this.config.env),s="application/x-www-form-urlencoded",c=ct({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==ht.indexOf(t))return[3,2];if(!(u=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return l=u.oauthInstance,p=l.oauth2client,f=c,[4,this.getOauthAccessTokenV2(p)];case 1:f.access_token=x.sent().accessToken,x.label=2;case 2:return"storage.uploadFile"===t?(d=new FormData,Object.keys(d).forEach((function(t){Object.prototype.hasOwnProperty.call(d,t)&&void 0!==d[t]&&d.append(t,c[t])})),s="multipart/form-data"):(s="application/json;charset=UTF-8",d={},Object.keys(c).forEach((function(t){void 0!==c[t]&&(d[t]=c[t])}))),h={headers:ct(ct({"content-type":s},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(v=this.localCache.getStore(a))&&(h.headers["X-TCB-Trace"]=v),y=void 0!==(null==n?void 0:n.parse)?n.parse:e.parse,g=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:e.inQuery,b=void 0!==(null==n?void 0:n.search)?n.search:e.search,m=ct(ct({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),g&&(m=ct(ct({},g),m)),w=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",O=at(this.config.env,w),A=O.baseUrl,I=O.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(E=at(this.config.env,"CLOUD_API"),A="".concat(E.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),P=void 0,P=n.pathname?dt(I,"".concat(null===(r=st(this.config.env,w))||void 0===r?void 0:r.replace(/^https?:/,""),"/").concat(n.pathname),m):dt(I,A,m),b&&(P+=b),[4,this.post(ct({url:P,data:d},h),o)];case 3:if(S=x.sent(),(_=null===(i=S.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(a,_),200!==Number(S.status)&&200!==Number(S.statusCode)||!S.data)throw new Error("network request error");return[2,S];case 4:C=x.sent();try{C.requestId=C.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw C;case 5:return[2]}}))}))},t.prototype.fetch=function(t){var e,n,o,r,i,a,s,c;return ut(this,void 0,Promise,(function(){var u,l,p,f,d,h,v,y,g=this;return lt(this,(function(b){switch(b.label){case 0:u=t.token,l=t.headers,p=void 0===l?{}:l,f=t.withCredentials,d=void 0===f||f,h=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(t,["token","headers","withCredentials"]),v=function(){return ut(g,void 0,void 0,(function(){var t,e,n,o;return lt(this,(function(r){switch(r.label){case 0:return t={},d?(e=t,n="Bearer ".concat,[4,this.getAccessToken(u)]):[3,2];case 1:e.Authorization=n.apply("Bearer ",[r.sent()]),r.label=2;case 2:return o=ct({headers:ct(ct(ct({"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z())},t),this.getDefaultHeaders()),p),withCredentials:d},h),[2,this.reqClass.fetch(o)]}}))}))},b.label=1;case 1:return b.trys.push([1,3,,6]),[4,v()];case 2:return[2,b.sent()];case 3:y=b.sent();try{y.requestId=y.requestId||p["x-request-id"]||p["X-Request-Id"]||""}catch(t){}if("ACCESS_TOKEN_EXPIRED"!==(null==y?void 0:y.code))return[3,5];if("function"!=typeof(null===(r=null===(o=null===(n=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===o?void 0:o.authApi)||void 0===r?void 0:r.refreshTokenForce))throw y;return[4,null===(c=null===(s=null===(a=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===a?void 0:a.oauthInstance)||void 0===s?void 0:s.authApi)||void 0===c?void 0:c.refreshTokenForce()];case 4:return b.sent(),[2,v()];case 5:throw y;case 6:return[2]}}))}))},t.prototype.send=function(t,e,n,o){return void 0===e&&(e={}),void 0===n&&(n={}),ut(this,void 0,Promise,(function(){var r;return lt(this,(function(i){switch(i.label){case 0:return[4,this.request(t,e,ct(ct({},n),{onUploadProgress:e.onUploadProgress}),o)];case 1:if((r=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:pt.OPERATION_FAIL,msg:"[".concat(r.data.code,"] ").concat(r.data.message)}));return[2,r.data]}}))}))},t.prototype.gateWay=function(t,e){var n;return ut(this,void 0,void 0,(function(){var o,r,i,a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O;return lt(this,(function(A){switch(A.label){case 0:if(o=t.url,r=t.name,i=t.data,a=t.path,s=void 0===a?"":a,c=t.method,u=t.header,l=void 0===u?{}:u,!(r&&s||o))throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{p=i?JSON.stringify(i):""}catch(t){throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(I=(new Date).getTime(),E=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0,f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random();return I>0?(e=(I+e)%16|0,I=Math.floor(I/16)):(e=(E+e)%16|0,E=Math.floor(E/16)),("x"===t?e:7&e|8).toString(16)})),d=at(this.config.env,"GATEWAY"),h=d.baseUrl,v=d.protocol,y="".concat(v).concat(h).concat(o||"/".concat(s,"/").concat(r)),g=["GET","HEAD"].includes(null===(n=null==c?void 0:c.toUpperCase)||void 0===n?void 0:n.call(c)))try{b={};try{b=JSON.parse(i)}catch(t){b=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(b).map((function(t){return"".concat(t,"=").concat(b[t])})).join("&"))}catch(t){}return[4,this.fetch(ct(ct({method:c||"POST",headers:ct({"Content-Type":"application/json; charset=utf-8","X-Request-Id":f},l)},g?{}:{body:p}),{url:y,customReqOpts:e}))];case 1:return m=A.sent(),w=[ct({requestId:f},m)],O={},[4,m.data];case 2:return[2,ct.apply(void 0,w.concat([(O.data=A.sent(),O)]))]}var I,E}))}))},t}(),wt={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(bt||(bt={}));var Ot=((gt={})[bt.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code",错误信息:"error message",未实现:"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs",请求超时:"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},gt),At=function(t,e){var n;return(null===(n=Ot[e])||void 0===n?void 0:n[t])||t},It=function(t,e){var n,o,r=function(t){return"lang_".concat(t.clientId||t.env)}(e),i=(t.adapter||{}).localStorage,a=e.lang||(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||bt.ZH;return null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,a),new Proxy({t:function(t){return At(t,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(t,e){var n;return"lang"===e&&(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||t[e]},set:function(t,e,n){var o;return"lang"===e&&n!==t[e]&&(t[e]=n,t.t=function(t){return At(t,n)},null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,n),T.fire(N,{i18n:t})),t[e]=n,!0}})},Et=function(){return Et=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},Et.apply(this,arguments)},Pt=function(t,e,n,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a},St=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},_t=function(){return{adapter:I({},{type:"default",root:window,reqClass:A,wsClass:WebSocket,localStorage}),runtime:g.WEB}},Ct=c,xt="https://support.qq.com/products/148793",jt=h,Rt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},kt={timeout:15e3,persistence:"local"},Tt=6e5,Nt={},Dt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=Z()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return H},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,J[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return Y(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,wt[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,r;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"CLOUD_API",H.adapter||this.useDefaultAdapter(),!(e=this.dealNodeAdapterConfig(e)).env)throw new Error(JSON.stringify({code:Ct.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var i={timeout:e.timeout||15e3,timeoutMsg:"[".concat(z,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s"),auth:e.auth};this.requestClient=new H.adapter.reqClass(i),this.cloudbaseConfig=Et(Et(Et({},kt),e),{i18n:It(H,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var a=this.cloudbaseConfig,s=a.env,c=a.persistence,u=a.debug,l=a.timeout,p=a.oauthClient,f=a.i18n;G({env:s,persistence:c,debug:u,platformInfo:this.platform}),function(t,e){it({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(s,e.region||""),function(t,e,n){var o="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(o="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),it({endPointKey:"GATEWAY",env:t,baseUrl:o,protocol:e})}(s,ot,e.intl);var d=new t(this.cloudbaseConfig);return function(t){wt[t.env]=new mt(ct(ct({},t),{throw:!0}))}({env:s,region:e.region||"",timeout:l,oauthClient:p,_fromApp:d,i18n:f,endPointMode:e.endPointMode,auth:e.auth}),d.requestClient=this.requestClient,null===(n=null==this?void 0:this.fire)||void 0===n||n.call(this,"cloudbase_init",d),this.try2InitAuth(d),(null===(o=H.adapter)||void 0===o?void 0:o.nodeTool)&&(null===(r=H.adapter)||void 0===r||r.nodeTool(d,this.cloudbaseConfig)),d},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,G({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){Nt[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,o=void 0,i=function(){var n;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,(function(o){switch(o.label){case 0:if(!(n=Nt[t]))throw new Error(JSON.stringify({code:Ct.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,o.sent()]}}))},new((r=void 0)||(r=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function s(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((i=i.apply(n,o||[])).next())}));var n,o,r,i},t.prototype.useAdapters=function(t,e){var n=function(t,e){for(var n,o=0,r=(n=t,"[object Array]"===Object.prototype.toString.call(n)?t:[t]);o<r.length;o++){var i=r[o],a=i.isMatch,s=i.genAdapter,c=i.runtime;if(a())return{adapter:I({isMatch:a},s(e)),runtime:c}}}(t,e)||{},o=n.adapter,r=n.runtime;o&&(H.adapter=o),r&&(H.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,o=e.target;if(Object.prototype.hasOwnProperty.call(t,o))throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"target:".concat(o," is not exist")}));var r=t.prototype[o];if("function"!=typeof r)throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"target:".concat(o," is not a function which is the only type supports hook")}));t.prototype[o]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,L([this],t,!1)),r.call.apply(r,L([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){q(t,e)},t.prototype.registerVersion=function(t){!function(t){$=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){z=t,function(t){i=t}(t)}(t)},t.prototype.isInitialized=function(t){return void 0===t&&(t=this.cloudbaseConfig),["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some((function(e){return t.env.toLowerCase()===e.toLowerCase()}))&&jt(Ct.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(t.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==t?void 0:t.env)},t.prototype.registerEndPoint=function(t,e){it({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){it({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.getEndPointWithKey=function(t){var e=at(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return v(t)},t.prototype.useDefaultAdapter=function(){var t=_t.bind(this)(),e=t.adapter,n=t.runtime;H.adapter=e,H.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>Tt:return jt(Ct.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Tt;case t<100:return jt(Ct.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},t.prototype.try2InitAuth=function(t){try{t.auth()}catch(t){console.log("try2InitAuth error:",t)}},t.prototype.dealNodeAdapterConfig=function(t){return t},Pt([Rt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),St("design:type",Function),St("design:paramtypes",[Object]),St("design:returntype",t)],t.prototype,"init",null),Pt([Rt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),St("design:type",Function),St("design:paramtypes",[String,Object]),St("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),Lt=new Dt;Lt.useAdapters((V.WxRequest.prototype.upload=function(t){var e=this,n=this;return new Promise((function(o){var r=t.url,i=t.file,a=t.data,s=t.headers,c=wx.getFileSystemManager(),u=wx.request({url:r,method:t.method,header:B({"content-type":" "},s),data:c.readFileSync(i),timeout:e._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&(null==a?void 0:a.success_action_status)&&(e.statusCode=parseInt(a.success_action_status,10)),o(e)},fail:function(t){o(t)},complete:function(t){if((null==t?void 0:t.errMsg)&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},V.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:V.WxRequest,wsClass:V.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(e){var n=t.EventBus,o={},r=e;console.log("openURIWithCallback",e);var i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){r=i[1],console.log("openURIWithCallback url",r);var a=i[2];a&&(o=(0,V.parseQueryString)(a))}console.log("openURIWithCallback queryObj",o);var s=o.token,c=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(o,["token"]);return/^data:/.test(r)&&!s?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(e)}):s?new Promise((function(t){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",B(B({},c),{token:s,url:r})),n.$once("RESOLVE_CAPTCHA_DATA",(function(e){t(e)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:V.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},V.default));const Ut=Lt;Ut.registerVersion("2.31.0");try{window.cloudbase=Ut}catch(t){}const Mt=Ut;var qt=r.Z;export{qt as default};
2
2
  //# sourceMappingURL=index.esm.js.map