@cloudbase/js-sdk 2.28.8 → 2.29.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.
Files changed (330) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/ai/dist/index.esm.js +2 -3
  3. package/ai/dist/index.esm.js.map +1 -0
  4. package/ai/dist/index.js +2 -21
  5. package/ai/dist/index.js.map +1 -0
  6. package/apis/dist/index.esm.js +2 -3
  7. package/apis/dist/index.esm.js.map +1 -0
  8. package/apis/dist/index.js +2 -21
  9. package/apis/dist/index.js.map +1 -0
  10. package/app/dist/index.esm.js +2 -11
  11. package/app/dist/index.esm.js.map +1 -0
  12. package/app/dist/index.js +2 -18
  13. package/app/dist/index.js.map +1 -0
  14. package/auth/dist/index.d.ts +2 -2
  15. package/auth/dist/index.esm.js +3 -8
  16. package/auth/dist/index.esm.js.LICENSE.txt +12 -0
  17. package/auth/dist/index.esm.js.map +1 -0
  18. package/auth/dist/index.js +3 -13
  19. package/auth/dist/index.js.LICENSE.txt +12 -0
  20. package/auth/dist/index.js.map +1 -0
  21. package/cloudrun/dist/index.esm.js +2 -3
  22. package/cloudrun/dist/index.esm.js.map +1 -0
  23. package/cloudrun/dist/index.js +2 -21
  24. package/cloudrun/dist/index.js.map +1 -0
  25. package/container/dist/index.d.ts +2 -2
  26. package/container/dist/index.esm.js +2 -8
  27. package/container/dist/index.esm.js.map +1 -0
  28. package/container/dist/index.js +2 -13
  29. package/container/dist/index.js.map +1 -0
  30. package/database/dist/commonjs/aggregate.d.ts +29 -0
  31. package/database/dist/commonjs/aggregate.js +156 -0
  32. package/database/dist/commonjs/collection.d.ts +9 -0
  33. package/database/dist/commonjs/collection.js +49 -0
  34. package/database/dist/commonjs/command.d.ts +175 -0
  35. package/database/dist/commonjs/command.js +299 -0
  36. package/database/dist/commonjs/commands/logic.d.ts +24 -0
  37. package/database/dist/commonjs/commands/logic.js +89 -0
  38. package/database/dist/commonjs/commands/query.d.ts +68 -0
  39. package/database/dist/commonjs/commands/query.js +160 -0
  40. package/database/dist/commonjs/commands/update.d.ts +29 -0
  41. package/database/dist/commonjs/commands/update.js +51 -0
  42. package/database/dist/commonjs/config/app.config.d.ts +6 -0
  43. package/database/dist/commonjs/config/app.config.js +7 -0
  44. package/database/dist/commonjs/config/error.config.d.ts +3 -0
  45. package/database/dist/commonjs/config/error.config.js +16 -0
  46. package/database/dist/commonjs/const/code.d.ts +30 -0
  47. package/database/dist/commonjs/const/code.js +33 -0
  48. package/database/dist/commonjs/constant.d.ts +51 -0
  49. package/database/dist/commonjs/constant.js +75 -0
  50. package/database/dist/commonjs/document.d.ts +11 -0
  51. package/database/dist/commonjs/document.js +260 -0
  52. package/database/dist/commonjs/geo/index.d.ts +6 -0
  53. package/database/dist/commonjs/geo/index.js +22 -0
  54. package/database/dist/commonjs/geo/interface.d.ts +24 -0
  55. package/database/dist/commonjs/geo/interface.js +2 -0
  56. package/database/dist/commonjs/geo/lineString.d.ts +19 -0
  57. package/database/dist/commonjs/geo/lineString.js +86 -0
  58. package/database/dist/commonjs/geo/multiLineString.d.ts +18 -0
  59. package/database/dist/commonjs/geo/multiLineString.js +95 -0
  60. package/database/dist/commonjs/geo/multiPoint.d.ts +18 -0
  61. package/database/dist/commonjs/geo/multiPoint.js +79 -0
  62. package/database/dist/commonjs/geo/multiPolygon.d.ts +18 -0
  63. package/database/dist/commonjs/geo/multiPolygon.js +122 -0
  64. package/database/dist/commonjs/geo/point.d.ts +19 -0
  65. package/database/dist/commonjs/geo/point.js +50 -0
  66. package/database/dist/commonjs/geo/polygon.d.ts +19 -0
  67. package/database/dist/commonjs/geo/polygon.js +109 -0
  68. package/database/dist/commonjs/helper/symbol.d.ts +14 -0
  69. package/database/dist/commonjs/helper/symbol.js +31 -0
  70. package/database/dist/commonjs/index.d.ts +40 -0
  71. package/database/dist/commonjs/index.js +61 -0
  72. package/database/dist/commonjs/lib/util.d.ts +1 -0
  73. package/database/dist/commonjs/lib/util.js +26 -0
  74. package/database/dist/commonjs/operator-map.d.ts +4 -0
  75. package/database/dist/commonjs/operator-map.js +24 -0
  76. package/database/dist/commonjs/query.d.ts +22 -0
  77. package/database/dist/commonjs/query.js +252 -0
  78. package/database/dist/commonjs/regexp/index.d.ts +14 -0
  79. package/database/dist/commonjs/regexp/index.js +33 -0
  80. package/database/dist/commonjs/serializer/common.d.ts +11 -0
  81. package/database/dist/commonjs/serializer/common.js +127 -0
  82. package/database/dist/commonjs/serializer/datatype.d.ts +7 -0
  83. package/database/dist/commonjs/serializer/datatype.js +132 -0
  84. package/database/dist/commonjs/serializer/query.d.ts +7 -0
  85. package/database/dist/commonjs/serializer/query.js +232 -0
  86. package/database/dist/commonjs/serializer/update.d.ts +15 -0
  87. package/database/dist/commonjs/serializer/update.js +142 -0
  88. package/database/dist/commonjs/serverDate/index.d.ts +13 -0
  89. package/database/dist/commonjs/serverDate/index.js +30 -0
  90. package/database/dist/commonjs/transaction/collection.d.ts +7 -0
  91. package/database/dist/commonjs/transaction/collection.js +49 -0
  92. package/database/dist/commonjs/transaction/document.d.ts +27 -0
  93. package/database/dist/commonjs/transaction/document.js +205 -0
  94. package/database/dist/commonjs/transaction/index.d.ts +30 -0
  95. package/database/dist/commonjs/transaction/index.js +215 -0
  96. package/database/dist/commonjs/transaction/query.d.ts +43 -0
  97. package/database/dist/commonjs/transaction/query.js +261 -0
  98. package/database/dist/commonjs/typings/index.d.ts +40 -0
  99. package/database/dist/commonjs/typings/index.js +2 -0
  100. package/database/dist/commonjs/typings/realtime.d.ts +219 -0
  101. package/database/dist/commonjs/typings/realtime.js +2 -0
  102. package/database/dist/commonjs/util.d.ts +9 -0
  103. package/database/dist/commonjs/util.js +145 -0
  104. package/database/dist/commonjs/utils/error.d.ts +38 -0
  105. package/database/dist/commonjs/utils/error.js +91 -0
  106. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  107. package/database/dist/commonjs/utils/msg.js +0 -0
  108. package/database/dist/commonjs/utils/symbol.d.ts +8 -0
  109. package/database/dist/commonjs/utils/symbol.js +58 -0
  110. package/database/dist/commonjs/utils/type.d.ts +13 -0
  111. package/database/dist/commonjs/utils/type.js +34 -0
  112. package/database/dist/commonjs/utils/utils.d.ts +4 -0
  113. package/database/dist/commonjs/utils/utils.js +39 -0
  114. package/database/dist/commonjs/validate.d.ts +1 -0
  115. package/database/dist/commonjs/validate.js +60 -0
  116. package/database/dist/esm/aggregate.d.ts +29 -0
  117. package/database/dist/esm/aggregate.js +154 -0
  118. package/database/dist/esm/collection.d.ts +9 -0
  119. package/database/dist/esm/collection.js +46 -0
  120. package/database/dist/esm/command.d.ts +175 -0
  121. package/database/dist/esm/command.js +296 -0
  122. package/database/dist/esm/commands/logic.d.ts +24 -0
  123. package/database/dist/esm/commands/logic.js +84 -0
  124. package/database/dist/esm/commands/query.d.ts +68 -0
  125. package/database/dist/esm/commands/query.js +154 -0
  126. package/database/dist/esm/commands/update.d.ts +29 -0
  127. package/database/dist/esm/commands/update.js +46 -0
  128. package/database/dist/esm/config/app.config.d.ts +6 -0
  129. package/database/dist/esm/config/app.config.js +5 -0
  130. package/database/dist/esm/config/error.config.d.ts +3 -0
  131. package/database/dist/esm/config/error.config.js +13 -0
  132. package/database/dist/esm/const/code.d.ts +30 -0
  133. package/database/dist/esm/const/code.js +30 -0
  134. package/database/dist/esm/constant.d.ts +51 -0
  135. package/database/dist/esm/constant.js +65 -0
  136. package/database/dist/esm/document.d.ts +11 -0
  137. package/database/dist/esm/document.js +257 -0
  138. package/database/dist/esm/geo/index.d.ts +6 -0
  139. package/database/dist/esm/geo/index.js +6 -0
  140. package/database/dist/esm/geo/interface.d.ts +24 -0
  141. package/database/dist/esm/geo/interface.js +1 -0
  142. package/database/dist/esm/geo/lineString.d.ts +19 -0
  143. package/database/dist/esm/geo/lineString.js +83 -0
  144. package/database/dist/esm/geo/multiLineString.d.ts +18 -0
  145. package/database/dist/esm/geo/multiLineString.js +92 -0
  146. package/database/dist/esm/geo/multiPoint.d.ts +18 -0
  147. package/database/dist/esm/geo/multiPoint.js +76 -0
  148. package/database/dist/esm/geo/multiPolygon.d.ts +18 -0
  149. package/database/dist/esm/geo/multiPolygon.js +119 -0
  150. package/database/dist/esm/geo/point.d.ts +19 -0
  151. package/database/dist/esm/geo/point.js +47 -0
  152. package/database/dist/esm/geo/polygon.d.ts +19 -0
  153. package/database/dist/esm/geo/polygon.js +106 -0
  154. package/database/dist/esm/helper/symbol.d.ts +14 -0
  155. package/database/dist/esm/helper/symbol.js +14 -0
  156. package/database/dist/esm/index.d.ts +40 -0
  157. package/database/dist/esm/index.js +55 -0
  158. package/database/dist/esm/lib/util.d.ts +1 -0
  159. package/database/dist/esm/lib/util.js +22 -0
  160. package/database/dist/esm/operator-map.d.ts +4 -0
  161. package/database/dist/esm/operator-map.js +20 -0
  162. package/database/dist/esm/query.d.ts +22 -0
  163. package/database/dist/esm/query.js +249 -0
  164. package/database/dist/esm/regexp/index.d.ts +14 -0
  165. package/database/dist/esm/regexp/index.js +29 -0
  166. package/database/dist/esm/serializer/common.d.ts +11 -0
  167. package/database/dist/esm/serializer/common.js +118 -0
  168. package/database/dist/esm/serializer/datatype.d.ts +7 -0
  169. package/database/dist/esm/serializer/datatype.js +127 -0
  170. package/database/dist/esm/serializer/query.d.ts +7 -0
  171. package/database/dist/esm/serializer/query.js +229 -0
  172. package/database/dist/esm/serializer/update.d.ts +15 -0
  173. package/database/dist/esm/serializer/update.js +139 -0
  174. package/database/dist/esm/serverDate/index.d.ts +13 -0
  175. package/database/dist/esm/serverDate/index.js +26 -0
  176. package/database/dist/esm/transaction/collection.d.ts +7 -0
  177. package/database/dist/esm/transaction/collection.js +46 -0
  178. package/database/dist/esm/transaction/document.d.ts +27 -0
  179. package/database/dist/esm/transaction/document.js +202 -0
  180. package/database/dist/esm/transaction/index.d.ts +30 -0
  181. package/database/dist/esm/transaction/index.js +210 -0
  182. package/database/dist/esm/transaction/query.d.ts +43 -0
  183. package/database/dist/esm/transaction/query.js +258 -0
  184. package/database/dist/esm/typings/index.d.ts +40 -0
  185. package/database/dist/esm/typings/index.js +1 -0
  186. package/database/dist/esm/typings/realtime.d.ts +219 -0
  187. package/database/dist/esm/typings/realtime.js +1 -0
  188. package/database/dist/esm/util.d.ts +9 -0
  189. package/database/dist/esm/util.js +142 -0
  190. package/database/dist/esm/utils/error.d.ts +38 -0
  191. package/database/dist/esm/utils/error.js +84 -0
  192. package/database/dist/esm/utils/msg.d.ts +0 -0
  193. package/database/dist/esm/utils/msg.js +0 -0
  194. package/database/dist/esm/utils/symbol.d.ts +8 -0
  195. package/database/dist/esm/utils/symbol.js +55 -0
  196. package/database/dist/esm/utils/type.d.ts +13 -0
  197. package/database/dist/esm/utils/type.js +20 -0
  198. package/database/dist/esm/utils/utils.d.ts +4 -0
  199. package/database/dist/esm/utils/utils.js +33 -0
  200. package/database/dist/esm/validate.d.ts +1 -0
  201. package/database/dist/esm/validate.js +57 -0
  202. package/database/package.json +34 -4
  203. package/dist/index.cjs.js +3 -40
  204. package/dist/index.cjs.js.LICENSE.txt +12 -0
  205. package/dist/index.cjs.js.map +1 -0
  206. package/dist/index.d.ts +9 -0
  207. package/dist/index.esm.js +3 -35
  208. package/dist/index.esm.js.LICENSE.txt +12 -0
  209. package/dist/index.esm.js.map +1 -0
  210. package/functions/dist/index.d.ts +2 -2
  211. package/functions/dist/index.esm.js +2 -8
  212. package/functions/dist/index.esm.js.map +1 -0
  213. package/functions/dist/index.js +2 -13
  214. package/functions/dist/index.js.map +1 -0
  215. package/index.d.ts +654 -45
  216. package/miniprogram_dist/ai.js +1 -1
  217. package/miniprogram_dist/apis.js +1 -1
  218. package/miniprogram_dist/app.js +1 -1
  219. package/miniprogram_dist/auth.js +1 -1
  220. package/miniprogram_dist/cloudrun.js +1 -1
  221. package/miniprogram_dist/container.js +1 -1
  222. package/miniprogram_dist/database.js +1 -1
  223. package/miniprogram_dist/functions.js +1 -1
  224. package/miniprogram_dist/index.js +1 -1
  225. package/miniprogram_dist/model.js +1 -1
  226. package/miniprogram_dist/mysql.js +1 -1
  227. package/miniprogram_dist/oauth.js +2 -1
  228. package/miniprogram_dist/realtime.js +1 -1
  229. package/miniprogram_dist/storage.js +1 -1
  230. package/model/dist/index.esm.js +2 -3
  231. package/model/dist/index.esm.js.map +1 -0
  232. package/model/dist/index.js +2 -21
  233. package/model/dist/index.js.map +1 -0
  234. package/mysql/dist/index.esm.js +2 -3
  235. package/mysql/dist/index.esm.js.map +1 -0
  236. package/mysql/dist/index.js +2 -21
  237. package/mysql/dist/index.js.map +1 -0
  238. package/oauth/dist/index.esm.js +3 -3
  239. package/oauth/dist/index.esm.js.LICENSE.txt +12 -0
  240. package/oauth/dist/index.esm.js.map +1 -0
  241. package/oauth/dist/index.js +3 -21
  242. package/oauth/dist/index.js.LICENSE.txt +12 -0
  243. package/oauth/dist/index.js.map +1 -0
  244. package/package.json +113 -20
  245. package/realtime/dist/index.d.ts +2 -2
  246. package/realtime/dist/index.esm.js +2 -8
  247. package/realtime/dist/index.esm.js.map +1 -0
  248. package/realtime/dist/index.js +2 -13
  249. package/realtime/dist/index.js.map +1 -0
  250. package/storage/dist/index.d.ts +2 -2
  251. package/storage/dist/index.esm.js +2 -4
  252. package/storage/dist/index.esm.js.map +1 -0
  253. package/storage/dist/index.js +2 -9
  254. package/storage/dist/index.js.map +1 -0
  255. package/types/analytics.d.ts +51 -0
  256. package/types/auth.d.ts +99 -0
  257. package/types/cache.d.ts +26 -0
  258. package/types/cloudrun.d.ts +9 -0
  259. package/types/component.d.ts +17 -0
  260. package/types/container.d.ts +93 -0
  261. package/types/database.d.ts +31 -0
  262. package/types/events.d.ts +13 -0
  263. package/types/functions.d.ts +40 -0
  264. package/types/index.d.ts +211 -0
  265. package/types/package.json +43 -0
  266. package/types/realtime.d.ts +350 -0
  267. package/types/request.d.ts +30 -0
  268. package/types/storage.d.ts +126 -0
  269. package/utilities/dist/cjs/adapters/index.d.ts +45 -0
  270. package/utilities/dist/cjs/adapters/index.js +68 -0
  271. package/utilities/dist/cjs/adapters/platforms/web.d.ts +20 -0
  272. package/utilities/dist/cjs/adapters/platforms/web.js +286 -0
  273. package/utilities/dist/cjs/constants/common.d.ts +6 -0
  274. package/utilities/dist/cjs/constants/common.js +24 -0
  275. package/utilities/dist/cjs/constants/errors.d.ts +8 -0
  276. package/utilities/dist/cjs/constants/errors.js +12 -0
  277. package/utilities/dist/cjs/constants/index.d.ts +3 -0
  278. package/utilities/dist/cjs/constants/index.js +21 -0
  279. package/utilities/dist/cjs/helpers/decorators.d.ts +11 -0
  280. package/utilities/dist/cjs/helpers/decorators.js +238 -0
  281. package/utilities/dist/cjs/helpers/index.d.ts +1 -0
  282. package/utilities/dist/cjs/helpers/index.js +18 -0
  283. package/utilities/dist/cjs/index.d.ts +13 -0
  284. package/utilities/dist/cjs/index.js +51 -0
  285. package/utilities/dist/cjs/libs/abortController.d.ts +9 -0
  286. package/utilities/dist/cjs/libs/abortController.js +25 -0
  287. package/utilities/dist/cjs/libs/cache.d.ts +17 -0
  288. package/utilities/dist/cjs/libs/cache.js +261 -0
  289. package/utilities/dist/cjs/libs/events.d.ts +27 -0
  290. package/utilities/dist/cjs/libs/events.js +108 -0
  291. package/utilities/dist/cjs/libs/langEvent.d.ts +3 -0
  292. package/utilities/dist/cjs/libs/langEvent.js +7 -0
  293. package/utilities/dist/cjs/libs/util.d.ts +49 -0
  294. package/utilities/dist/cjs/libs/util.js +282 -0
  295. package/utilities/dist/esm/adapters/index.d.ts +45 -0
  296. package/utilities/dist/esm/adapters/index.js +40 -0
  297. package/utilities/dist/esm/adapters/platforms/web.d.ts +20 -0
  298. package/utilities/dist/esm/adapters/platforms/web.js +282 -0
  299. package/utilities/dist/esm/constants/common.d.ts +6 -0
  300. package/utilities/dist/esm/constants/common.js +17 -0
  301. package/utilities/dist/esm/constants/errors.d.ts +8 -0
  302. package/utilities/dist/esm/constants/errors.js +9 -0
  303. package/utilities/dist/esm/constants/index.d.ts +3 -0
  304. package/utilities/dist/esm/constants/index.js +4 -0
  305. package/utilities/dist/esm/helpers/decorators.d.ts +11 -0
  306. package/utilities/dist/esm/helpers/decorators.js +234 -0
  307. package/utilities/dist/esm/helpers/index.d.ts +1 -0
  308. package/utilities/dist/esm/helpers/index.js +2 -0
  309. package/utilities/dist/esm/index.d.ts +13 -0
  310. package/utilities/dist/esm/index.js +14 -0
  311. package/utilities/dist/esm/libs/abortController.d.ts +9 -0
  312. package/utilities/dist/esm/libs/abortController.js +23 -0
  313. package/utilities/dist/esm/libs/cache.d.ts +17 -0
  314. package/utilities/dist/esm/libs/cache.js +258 -0
  315. package/utilities/dist/esm/libs/events.d.ts +27 -0
  316. package/utilities/dist/esm/libs/events.js +102 -0
  317. package/utilities/dist/esm/libs/langEvent.d.ts +3 -0
  318. package/utilities/dist/esm/libs/langEvent.js +4 -0
  319. package/utilities/dist/esm/libs/util.d.ts +49 -0
  320. package/utilities/dist/esm/libs/util.js +254 -0
  321. package/utilities/dist/miniprogram/index.js +1 -0
  322. package/utilities/package.json +26 -0
  323. package/analytics/dist/index.d.ts +0 -2
  324. package/analytics/dist/index.esm.js +0 -4
  325. package/analytics/dist/index.js +0 -9
  326. package/analytics/package.json +0 -6
  327. package/database/dist/index.d.ts +0 -3
  328. package/database/dist/index.esm.js +0 -503
  329. package/database/dist/index.js +0 -509
  330. package/miniprogram_dist/analytics.js +0 -1
@@ -1,2 +1,2 @@
1
- import cloudbase from '../../index';
2
- export declare const registerStorage: (app: typeof cloudbase) => void;
1
+ import { ICloudbase } from '@cloudbase/types';
2
+ export declare const registerStorage: (app: ICloudbase) => void;
@@ -1,4 +1,2 @@
1
- import { registerStorage as registerStorageOrigin } from '@cloudbase/storage';
2
- export var registerStorage = registerStorageOrigin;
3
-
4
- //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxlQUFlLElBQUkscUJBQXFCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUc5RSxNQUFNLENBQUMsSUFBTSxlQUFlLEdBQUcscUJBQXdELENBQUMiLCJmaWxlIjoiaW5kZXguZXNtLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgcmVnaXN0ZXJTdG9yYWdlIGFzIHJlZ2lzdGVyU3RvcmFnZU9yaWdpbiB9IGZyb20gJ0BjbG91ZGJhc2Uvc3RvcmFnZSc7XG5pbXBvcnQgY2xvdWRiYXNlIGZyb20gJy4uLy4uL2luZGV4JztcblxuZXhwb3J0IGNvbnN0IHJlZ2lzdGVyU3RvcmFnZSA9IHJlZ2lzdGVyU3RvcmFnZU9yaWdpbiBhcyAoYXBwOiB0eXBlb2YgY2xvdWRiYXNlKSA9PiB2b2lkOyJdfQ==
1
+ import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";var n={388:t=>{t.exports={}}},r={};function o(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return n[t](i,i.exports,o),i.exports}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.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};(()=>{o.d(i,{v:()=>qt});var n,r=(n=function(t,e){return n=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])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),a=function(t){function e(e){var n=t.call(this,e)||this;return n.__isStorageError=!0,n.name="StorageError",n}return r(e,t),e}(Error);function s(t){return"object"==typeof t&&null!==t&&"__isStorageError"in t}var c,u=function(t){function e(e,n,r){var o=t.call(this,e)||this;return o.name="StorageApiError",o.status=n,o.statusCode=r,o}return r(e,t),e.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}},e}(a);function l(){return globalThis.Buffer}function d(t){var e=l();return e?e.from(t).toString("base64"):btoa(t)}function h(t){return t.split("/").map((function(t){return encodeURIComponent(t)})).join("/")}r((function(t,e){var n=c.call(this,t)||this;return n.name="StorageUnknownError",n.originalError=e,n}),c=a);var f=function(){return f=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},f.apply(this,arguments)},p=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},y=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},v="/v1/storages";function m(t,e){return p(this,void 0,Promise,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t()];case 1:return[2,{data:r.sent(),error:null}];case 2:if(n=r.sent(),e)throw n;return s(n)?[2,{data:null,error:n}]:[2,{data:null,error:new a((null==n?void 0:n.message)||String(n))}];case 3:return[2]}}))}))}var b=function(){function t(t){this.ctx=t}return Object.defineProperty(t.prototype,"request",{get:function(){return this.ctx.request},enumerable:!1,configurable:!0}),t.prototype.gatewayOrigin=function(){return this.request.getBaseEndPoint("GATEWAY")},t.prototype.buildUrl=function(t,e){var n="".concat(this.gatewayOrigin()).concat(v).concat(t),r=function(t){if(!t)return"";var e=[];return Object.keys(t).forEach((function(n){var r=t[n];null!=r&&e.push("".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(String(r))))})),e.join("&")}(e);return r&&(n+=(n.includes("?")?"&":"?")+r),n},t.prototype.toFullUrl=function(t){return t?/^https?:\/\//.test(t)||t.startsWith("//")?t:"".concat(this.gatewayOrigin()).concat(v).concat(t.startsWith("/")?"":"/").concat(t):t},t.prototype.send=function(t){return p(this,void 0,Promise,(function(){var e,n,r,o,i,a;return y(this,(function(s){switch(s.label){case 0:return e=this.buildUrl(t.path,t.query),n=t.method.toUpperCase(),r=["GET","HEAD"].includes(n),o=f({},t.headers||{}),r||(void 0!==t.rawBody?i=t.rawBody:void 0!==t.json&&(o["Content-Type"]=o["Content-Type"]||"application/json",i=JSON.stringify(t.json))),[4,this.request.fetch(f(f(f(f({url:e,method:n,headers:o},void 0!==i?{body:i}:{}),{withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1}),t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:return a=s.sent(),[2,this.unwrap(a,e)]}}))}))},t.prototype.download=function(t){var e,n;return p(this,void 0,Promise,(function(){var r,o,i,a;return y(this,(function(s){switch(s.label){case 0:return r=this.buildUrl(t.path,t.query),[4,this.request.fetch(f(f({url:r,method:"GET",headers:f({},t.headers||{}),stream:!0,withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1},t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:if(o=s.sent(),null===(e=t.signal)||void 0===e?void 0:e.aborted)throw new u("The download was aborted",0,"STORAGE_PG_ABORTED");if(304===(i=Number(null!==(n=null==o?void 0:o.statusCode)&&void 0!==n?n:200)))throw new u("Not Modified",i,"STORAGE_PG_NOT_MODIFIED");if(i>=400)throw new u("Download failed with status ".concat(i),i,"STORAGE_PG_REQUEST_FAIL");if(!(a=null==o?void 0:o.response))throw new u("Underlying adapter did not expose the raw Response",i,"STORAGE_PG_NO_RESPONSE");return[2,{response:a,status:i,header:null==o?void 0:o.header}]}}))}))},t.prototype.unwrap=function(t,e){var n,r;return p(this,void 0,Promise,(function(){var o,i,a,s;return y(this,(function(c){switch(c.label){case 0:o=Number(null!==(r=null!==(n=null==t?void 0:t.statusCode)&&void 0!==n?n:null==t?void 0:t.status)&&void 0!==r?r:200),i=null==t?void 0:t.data,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,i];case 2:return i=c.sent(),[3,4];case 3:return c.sent(),i=void 0,[3,4];case 4:if(o>=200&&o<300)return[2,i];throw a=(null==i?void 0:i.code)||(null==i?void 0:i.error)||"STORAGE_PG_REQUEST_FAIL",s=(null==i?void 0:i.message)||"Storage request failed with status ".concat(o,": ").concat(e),new u(s,o,a)}}))}))},t}(),g=function(){return g=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},g.apply(this,arguments)},w=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},O=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};function I(t){return s(t)?t:new a((null==t?void 0:t.message)||String(t))}function P(t){var e={};return void 0!==(null==t?void 0:t.download)&&(e.download=!0===t.download?"":t.download),void 0!==(null==t?void 0:t.cacheNonce)&&(e.cacheNonce=String(t.cacheNonce)),{headers:{},query:e}}var S=function(){function t(t){this.ctx=t}return t.prototype.then=function(t,e){return this.execute().then(t,e)},t.prototype.execute=function(){var t,e;return w(this,void 0,Promise,(function(){var n,r,o,i,a;return O(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),n=P(this.ctx.options),r=n.headers,o=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat(h(this.ctx.cleanName)),headers:g(g({},this.ctx.headers),r),query:o,signal:null===(t=this.ctx.parameters)||void 0===t?void 0:t.signal,cache:null===(e=this.ctx.parameters)||void 0===e?void 0:e.cache})];case 1:if(!(i=s.sent().response).body)throw new u("Response body is empty",i.status,"STORAGE_PG_EMPTY_BODY");return[2,{data:i.body,error:null}];case 2:if(a=s.sent(),this.ctx.shouldThrowOnError)throw a;return[2,{data:null,error:I(a)}];case 3:return[2]}}))}))},t}(),E=function(){function t(t){this.ctx=t}return t.prototype.asStream=function(){return new S(this.ctx)},t.prototype.then=function(t,e){return this.execute().then(t,e)},t.prototype.execute=function(){var t,e;return w(this,void 0,Promise,(function(){var n,r,o,i,a,s;return O(this,(function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),n=P(this.ctx.options),r=n.headers,o=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat(h(this.ctx.cleanName)),headers:g(g({},this.ctx.headers),r),query:o,signal:null===(t=this.ctx.parameters)||void 0===t?void 0:t.signal,cache:null===(e=this.ctx.parameters)||void 0===e?void 0:e.cache})];case 1:return i=c.sent().response,s={},[4,i.blob()];case 2:return[2,(s.data=c.sent(),s.error=null,s)];case 3:if(a=c.sent(),this.ctx.shouldThrowOnError)throw a;return[2,{data:null,error:I(a)}];case 4:return[2]}}))}))},t}(),_=function(){return _=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},_.apply(this,arguments)},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},F=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},L="3600",j=function(){function t(t,e,n){void 0===n&&(n=!1),this.headers={},this.http=t,this.bucketId=e,this.shouldThrowOnError=n}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.setHeader=function(t,e){var n;if("string"!=typeof t||""===t.trim())throw new a("setHeader requires a non-empty header name");if(/[\r\n]/.test(t)||"string"==typeof e&&/[\r\n]/.test(e))throw new a("setHeader does not allow CR/LF characters in header name or value");return this.headers=_(_({},this.headers),((n={})[t]=String(e),n)),this},t.prototype.upload=function(t,e,n){return T(this,void 0,Promise,(function(){return F(this,(function(r){return[2,this.uploadOrUpdate("POST",t,e,n)]}))}))},t.prototype.update=function(t,e,n){return T(this,void 0,Promise,(function(){return F(this,(function(r){return[2,this.uploadOrUpdate("PUT",t,e,n)]}))}))},t.prototype.download=function(t,e,n){return new E({http:this.http,bucketId:this.bucketId,cleanName:this.cleanPath(t),options:e,parameters:n,headers:this.headers,shouldThrowOnError:this.shouldThrowOnError})},t.prototype.list=function(t,e,n){return T(this,void 0,Promise,(function(){var r=this;return F(this,(function(o){return[2,m((function(){return T(r,void 0,void 0,(function(){var r;return F(this,(function(o){return r={prefix:t||""},void 0!==(null==e?void 0:e.limit)&&(r.limit=e.limit),void 0!==(null==e?void 0:e.cursor)&&(r.cursor=e.cursor),void 0!==(null==e?void 0:e.withDelimiter)&&(r.with_delimiter=e.withDelimiter),void 0!==(null==e?void 0:e.sortBy)&&(r.sortBy=e.sortBy),[2,this.send({method:"POST",path:"/object/list/".concat(this.bucketId),json:r,signal:null==n?void 0:n.signal,cache:null==n?void 0:n.cache})]}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.remove=function(t){return T(this,void 0,Promise,(function(){var e=this;return F(this,(function(n){return[2,m((function(){return T(e,void 0,void 0,(function(){var e,n,r,o,i,a=this;return F(this,(function(s){switch(s.label){case 0:e=t.map((function(t){return a.cleanPath(t)})),n=[],r=0,s.label=1;case 1:return r<e.length?(o=e.slice(r,r+100),[4,this.send({method:"DELETE",path:"/object/".concat(this.bucketId),json:{prefixes:o}})]):[3,4];case 2:i=s.sent(),Array.isArray(i)&&n.push.apply(n,i),s.label=3;case 3:return r+=100,[3,1];case 4:return[2,n]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.copy=function(t,e,n){return T(this,void 0,Promise,(function(){var r=this;return F(this,(function(o){return[2,m((function(){return T(r,void 0,void 0,(function(){var r;return F(this,(function(o){switch(o.label){case 0:return r=this.buildCopyMoveHeaders(n),[4,this.send({method:"POST",path:"/object/copy",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(t),destinationKey:this.cleanPath(e),destinationBucket:null==n?void 0:n.destinationBucket,copyMetadata:null==n?void 0:n.copyMetadata,metadata:null==n?void 0:n.metadata},headers:r})];case 1:return[2,{path:o.sent().Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.move=function(t,e,n){return T(this,void 0,Promise,(function(){var r=this;return F(this,(function(o){return[2,m((function(){return T(r,void 0,void 0,(function(){return F(this,(function(r){switch(r.label){case 0:return[4,this.send({method:"POST",path:"/object/move",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(t),destinationKey:this.cleanPath(e),destinationBucket:null==n?void 0:n.destinationBucket}})];case 1:return[2,{message:r.sent().message||"Successfully moved"}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.info=function(t){return T(this,void 0,Promise,(function(){var e=this;return F(this,(function(n){return[2,m((function(){return T(e,void 0,void 0,(function(){var e,n;return F(this,(function(r){switch(r.label){case 0:return e=this.cleanPath(t),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(e))})];case 1:return[2,{id:(n=r.sent()).id,name:n.name,version:n.version,bucketId:n.bucket_id,size:n.size,contentType:n.content_type,cacheControl:n.cache_control,etag:n.etag,metadata:n.metadata,lastModified:n.last_modified,createdAt:n.created_at}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.exists=function(t){return T(this,void 0,Promise,(function(){var e,n,r;return F(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.cleanPath(t),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(e))})];case 1:return o.sent(),[2,{data:!0,error:null}];case 2:if(n=o.sent(),void 0!==(r=null==n?void 0:n.status)&&[400,404].includes(Number(r)))return[2,{data:!1,error:null}];if(this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof a?n:new a((null==n?void 0:n.message)||String(n))}];case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(t,e,n){return T(this,void 0,Promise,(function(){var r=this;return F(this,(function(o){return[2,m((function(){return T(r,void 0,void 0,(function(){var r,o,i;return F(this,(function(a){switch(a.label){case 0:return r=this.cleanPath(t),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId,"/").concat(this.encodePath(r)),json:{expiresIn:e}})];case 1:return o=a.sent(),i=o.fullSignedURL||this.http.toFullUrl(o.signedURL||""),[2,{fullSignedURL:this.appendUrlOptions(i,n)}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.createSignedUrls=function(t,e,n){return T(this,void 0,Promise,(function(){var r=this;return F(this,(function(o){return[2,m((function(){return T(r,void 0,void 0,(function(){var r,o,i,a,s=this;return F(this,(function(c){switch(c.label){case 0:r=t.map((function(t){return s.cleanPath(t)})),o=[],i=0,c.label=1;case 1:return i<r.length?(a=r.slice(i,i+500),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId),json:{expiresIn:e,paths:a}})]):[3,4];case 2:c.sent().forEach((function(t){var e,r=t.fullSignedURL||(t.signedURL?s.http.toFullUrl(t.signedURL):null);o.push({path:t.path,fullSignedURL:r?s.appendUrlOptions(r,n):null,error:null!==(e=t.error)&&void 0!==e?e:null})})),c.label=3;case 3:return i+=500,[3,1];case 4:return[2,o]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.createSignedUploadUrl=function(t,e){return T(this,void 0,Promise,(function(){var n=this;return F(this,(function(r){return[2,m((function(){return T(n,void 0,void 0,(function(){var n,r,o;return F(this,(function(i){switch(i.label){case 0:return n=this.cleanPath(t),r={},(null==e?void 0:e.upsert)&&(r["x-upsert"]="true"),[4,this.send({method:"POST",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(n)),headers:r})];case 1:return[2,{fullSignedURL:(o=i.sent()).fullURL||this.http.toFullUrl(o.url||""),path:n,token:o.token}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.uploadToSignedUrl=function(t,e,n,r){return T(this,void 0,Promise,(function(){var o=this;return F(this,(function(i){return[2,m((function(){return T(o,void 0,void 0,(function(){var o,i,a,s,c;return F(this,(function(u){switch(u.label){case 0:return o=this.cleanPath(t),i=this.buildUploadBody(n,r),a=i.body,s=i.headers,[4,this.send({method:"PUT",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(o)),query:{token:e},rawBody:a,headers:s,withCredentials:!1})];case 1:return c=u.sent(),[2,{path:o,fullPath:c.Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.getPublicUrl=function(t,e){var n=this.cleanPath(t),r=this.http.buildUrl("/object/public/".concat(this.bucketId,"/").concat(this.encodePath(n)));return{data:{publicUrl:this.appendUrlOptions(r,e)}}},t.prototype.send=function(t){return this.http.send(_(_({},t),{headers:_(_({},this.headers),t.headers||{})}))},t.prototype.uploadOrUpdate=function(t,e,n,r){return T(this,void 0,Promise,(function(){var o=this;return F(this,(function(i){return[2,m((function(){return T(o,void 0,void 0,(function(){var o,i,a,s,c;return F(this,(function(u){switch(u.label){case 0:return o=this.cleanPath(e),i=this.buildUploadBody(n,r),a=i.body,s=i.headers,"POST"===t&&(s["x-upsert"]=String(Boolean(null==r?void 0:r.upsert))),[4,this.send({method:t,path:"/object/".concat(this.bucketId,"/").concat(this.encodePath(o)),rawBody:a,headers:s})];case 1:return[2,{id:(c=u.sent()).Id,path:o,fullPath:c.Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.cleanPath=function(t){var e=t.replace(/^\/+|\/+$/g,"").replace(/\/+/g,"/");if(e.split("/").some((function(t){return".."===t})))throw new a('invalid path: ".." segment is not allowed');return e},t.prototype.encodePath=function(t){return h(t)},t.prototype.buildUploadBody=function(t,e){var n,r,o,i,a,s=_({},(null==e?void 0:e.headers)||{}),c=t,u="undefined"!=typeof FormData&&t instanceof FormData;if("undefined"!=typeof Blob&&t instanceof Blob||u){var l=void 0,d={};if(u){var h=this.extractFromFormData(t);l=h.file,d=h.fields}else l=t;var f=null!==(r=null!==(n=null==e?void 0:e.cacheControl)&&void 0!==n?n:d.cacheControl)&&void 0!==r?r:L,p=null!==(o=null==e?void 0:e.contentType)&&void 0!==o?o:d.contentType,y=void 0!==(null==e?void 0:e.metadata)?JSON.stringify(e.metadata):d.metadata,v=new FormData;void 0!==f&&v.append("cacheControl",String(f)),void 0!==p&&v.append("contentType",p),void 0!==y&&v.append("metadata",y),v.append("",l),c=v}else c=t,f=null!==(i=null==e?void 0:e.cacheControl)&&void 0!==i?i:L,p=null!==(a=null==e?void 0:e.contentType)&&void 0!==a?a:"text/plain;charset=UTF-8",s["cache-control"]="max-age=".concat(f),p&&(s["content-type"]=p),(null==e?void 0:e.metadata)&&(s["x-metadata"]=this.toBase64(JSON.stringify(e.metadata)));return{body:c,headers:s}},t.prototype.extractFromFormData=function(t){var e,n={},r=0,o=[];if(t.forEach((function(t,i){if("undefined"!=typeof Blob&&t instanceof Blob)return e=t,void(r+=1);"cacheControl"!==i&&"contentType"!==i&&"metadata"!==i?o.push(i):n[i]=String(t)})),o.length>0&&console.warn("Ignored unsupported FormData field(s): [".concat(o.join(", "),"]. Only file, cacheControl, contentType and metadata are supported")),0===r||!e)throw new a("FormData must contain a file");if(r>1)throw new a("FormData must contain exactly one file");return{file:e,fields:n}},t.prototype.buildCopyMoveHeaders=function(t){var e={};return(null==t?void 0:t.upsert)&&(e["x-upsert"]="true"),!1===(null==t?void 0:t.copyMetadata)&&(null==t?void 0:t.metadata)&&(e["x-metadata"]=this.toBase64(JSON.stringify(t.metadata))),e},t.prototype.appendUrlOptions=function(t,e){var n=[];if(void 0!==(null==e?void 0:e.download)){var r=!0===e.download?"":String(e.download);n.push("download=".concat(encodeURIComponent(r)))}if(void 0!==(null==e?void 0:e.cacheNonce)&&n.push("cacheNonce=".concat(encodeURIComponent(String(e.cacheNonce)))),0===n.length)return t;var o=t.includes("?")?"&":"?";return"".concat(t).concat(o).concat(n.join("&"))},t.prototype.toBase64=function(t){return d(t)},t}(),x=/[\x00-\x20\x7f/\\?#%]/;function U(t,e){if("string"!=typeof t||0===t.length)throw new a("[storage.".concat(e,"] bucketId is required"));if(t.length>256)throw new a("[storage.".concat(e,"] invalid bucketId: length must be 1-").concat(256));var n=x.exec(t);if(n){var r="[storage.".concat(e,'] invalid bucketId "').concat(t,'": ')+"contains forbidden character ".concat(JSON.stringify(n[0]),"; ")+'must not contain whitespace, control chars, "/", "\\", "?", "#" or "%"';throw new a(r)}}var R=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},C=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},A=function(){function t(t,e){void 0===e&&(e=!1),this.http=new b(t),this.shouldThrowOnError=e}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.listBuckets=function(t){return R(this,void 0,Promise,(function(){var e=this;return C(this,(function(n){return[2,m((function(){var n={};return void 0!==(null==t?void 0:t.limit)&&(n.limit=t.limit),void 0!==(null==t?void 0:t.offset)&&(n.offset=t.offset),(null==t?void 0:t.sortColumn)&&(n.sortColumn=t.sortColumn),(null==t?void 0:t.sortOrder)&&(n.sortOrder=t.sortOrder),(null==t?void 0:t.search)&&(n.search=t.search),e.http.send({method:"GET",path:"/bucket/",query:n})}),this.shouldThrowOnError)]}))}))},t.prototype.getBucket=function(t){return R(this,void 0,Promise,(function(){var e=this;return C(this,(function(n){return[2,m((function(){return U(t,"getBucket"),e.http.send({method:"GET",path:"/bucket/".concat(t)})}),this.shouldThrowOnError)]}))}))},t.prototype.createBucket=function(t,e){return R(this,void 0,Promise,(function(){var n=this;return C(this,(function(r){return[2,m((function(){var r;return U(t,"createBucket"),n.http.send({method:"POST",path:"/bucket/",json:{id:t,name:t,public:null!==(r=null==e?void 0:e.public)&&void 0!==r&&r,type:null==e?void 0:e.type,file_size_limit:null==e?void 0:e.fileSizeLimit,allowed_mime_types:null==e?void 0:e.allowedMimeTypes}})}),this.shouldThrowOnError)]}))}))},t.prototype.updateBucket=function(t,e){return R(this,void 0,Promise,(function(){var n=this;return C(this,(function(r){return[2,m((function(){return U(t,"updateBucket"),n.http.send({method:"PUT",path:"/bucket/".concat(t),json:{public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes}})}),this.shouldThrowOnError)]}))}))},t.prototype.deleteBucket=function(t){return R(this,void 0,Promise,(function(){var e=this;return C(this,(function(n){return[2,m((function(){return U(t,"deleteBucket"),e.http.send({method:"DELETE",path:"/bucket/".concat(t)})}),this.shouldThrowOnError)]}))}))},t}(),k="@cloudbase/js-sdk";function N(){return k}var D={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 q=(B={AbstractSDKRequest:()=>t.AbstractSDKRequest,AbstractStorage:()=>t.AbstractStorage},M={},o.d(M,B),M);var B,M;function G(t){return"string"==typeof t}function z(t,e){console.warn("[".concat(N(),"][").concat(t,"]:").concat(e))}var W,J=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 r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),V=function(){return V=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},V.apply(this,arguments)},H=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},K=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=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,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}J(e,t),e.prototype.get=function(t){return this.request(V(V({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(V(V({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(V(V({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,i=t.headers,a=void 0===i?{}:i,s={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===s?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",r),c.append("file",n),this.request(V(V({},t),{data:c,method:s}),this.restrictedMethods.includes("upload"))):this.request(V(V({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return H(this,void 0,Promise,(function(){var e,n,r,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(V(V({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[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 H(this,void 0,Promise,(function(){var n,r,o,i,a,s,c,u,l,d,h,f,p,y=this;return K(this,(function(v){switch(v.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,i=void 0!==o&&o,a=t.stream,s=void 0!==a&&a,c=t.signal,u=t.timeout,l=t.shouldThrowOnError,d=void 0===l||l,h=null!=u?u:this.timeout,c&&(c.aborted&&n.abort(),c.addEventListener("abort",(function(){return n.abort()}))),f=null,i&&h&&(f=setTimeout((function(){console.warn(y.timeoutMsg),n.abort(new Error(y.timeoutMsg))}),h)),[4,fetch(r,V(V({},t),{signal:n.signal})).then((function(t){return H(y,void 0,void 0,(function(){var e,n,r;return K(this,(function(o){switch(o.label){case 0:return clearTimeout(f),d?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){return clearTimeout(f),Promise.reject(t)}))];case 1:return p=v.sent(),[2,{data:s?p.body:(null===(e=p.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers,response:p}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i=t.url,a=t.headers,s=void 0===a?{}:a,c=t.data,u=t.responseType,l=t.withCredentials,d=t.body,h=t.onUploadProgress,f=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}("https:",i,"get"===r?c:{}),p=new XMLHttpRequest;p.open(r,f),u&&(p.responseType=u);var y,v,m,b=t.signal;b&&(b.aborted?p.abort():b.addEventListener("abort",(function(){return p.abort()}),{once:!0})),Object.keys(s).forEach((function(t){p.setRequestHeader(t,s[t])})),h&&p.upload.addEventListener("progress",h),p.onreadystatechange=function(){var t={};if(4===p.readyState){var e=p.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=p.status;try{t.data="blob"===u?p.response:JSON.parse(p.responseText)}catch(e){t.data="blob"===u?p.response:p.responseText}clearTimeout(y),o(t)}},e&&n.timeout&&(y=setTimeout((function(){console.warn(n.timeoutMsg),p.abort()}),n.timeout)),m=c,v="[object FormData]"===Object.prototype.toString.call(m)?c:"application/x-www-form-urlencoded"===s["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("&")}(c):d||(c?JSON.stringify(c):void 0),l&&(p.withCredentials=!0),p.send(v)}))}}(q.AbstractSDKRequest),function(t){t.WEB="web",t.WX_MP="wx_mp"}(W||(W={}));var Y=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 r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Q=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},X=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=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 Y(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}(q.AbstractStorage);!function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(z(D.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)}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 r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:D.OPERATION_FAIL,msg:"[".concat(N(),"][").concat(D.OPERATION_FAIL,"]setStore failed"),info:t}))}}else z(D.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return Q(this,void 0,void 0,(function(){var r;return X(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.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 r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}z(D.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return Q(this,void 0,void 0,(function(){var r;return X(this,(function(o){switch(o.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(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):z(D.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return Q(this,void 0,void 0,(function(){return X(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))}}();var Z=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 r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),tt=function(t,e){this.data=e||null,this.name=t},et=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return Z(e,t),e}(tt),nt=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 r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof et)return console.error(t.error),this;var n=G(t)?new tt(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,i=this.listeners[r]?function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],this.listeners[r],!0):[];o<i.length;o++)i[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new nt,new nt,"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const rt=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});rt.default;var ot,it=o(388),at=function(){return at=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},at.apply(this,arguments)},st=function(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a},ct=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},ut=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},lt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};!function(t){t.put="put",t.post="post"}(ot||(ot={}));var dt=N,ht=D,ft="https://support.qq.com/products/148793",pt=function(t){return"[object Array]"===Object.prototype.toString.call(t)},yt=G,vt=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},mt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},bt="storage",gt=function(t,e,n){return ut(void 0,void 0,void 0,(function(){var r,o,i;return lt(this,(function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-upload-info",data:[at({objectId:e.path},e.signedHeader?{signedHeader:e.signedHeader}:{})]},n)];case 1:return r=a.sent(),o=(null===(i=r.data)||void 0===i?void 0:i[0])||{},[2,at(at({},r),{data:at(at({},o.code?at({},o):{}),{authorization:o.authorization,token:o.token,url:o.uploadUrl,fileId:o.cloudObjectId,cosFileId:o.cloudObjectMeta,download_url:o.downloadUrl})})]}}))}))},wt=function(t,e,n){return ut(void 0,void 0,void 0,(function(){var r,o;return lt(this,(function(i){switch(i.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-download-info",data:e.convertedFileList.map((function(t){return{cloudObjectId:t.fileid}}))},n)];case 1:return r=i.sent(),[2,at(at({},r),{data:{download_list:null===(o=r.data)||void 0===o?void 0:o.map((function(t){return{code:t.code||"SUCCESS",message:t.message,fileid:t.cloudObjectId,download_url:t.downloadUrl,fileID:t.cloudObjectId,tempFileURL:t.downloadUrl}}))}})]}}))}))},Ot=function(t,e,n){return ut(void 0,void 0,void 0,(function(){var r,o;return lt(this,(function(i){switch(i.label){case 0:return[4,t.gateWay({path:"storages",name:"delete-objects",data:e.fileList.map((function(t){return{cloudObjectId:t}}))},n)];case 1:return r=i.sent(),[2,at(at({},r),{data:{delete_list:null===(o=r.data)||void 0===o?void 0:o.map((function(t){return{code:t.code||"SUCCESS",fileID:t.cloudObjectId,message:t.message}}))}})]}}))}))},It=function(t,e,n){return ut(void 0,void 0,void 0,(function(){var r,o;return lt(this,(function(i){switch(i.label){case 0:return[4,t.gateWay({path:"storages",name:"copy-objects",data:e.convertedFileList.map((function(t){return{srcPath:t.src_path,dstPath:t.dst_path,overwrite:t.overwrite,removeOriginal:t.remove_original}}))},n)];case 1:return r=i.sent(),[2,at(at({},r),{data:{copy_list:null===(o=r.data)||void 0===o?void 0:o.map((function(t){return{code:t.code||"SUCCESS",fileID:t.cloudObjectId,message:t.message}}))}})]}}))}))},Pt={txt:"text/plain",json:"application/json",html:"text/html",htm:"text/html",css:"text/css",js:"application/javascript",csv:"text/csv",xml:"application/xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",pdf:"application/pdf",zip:"application/zip",gz:"application/gzip",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav"};function St(t,e){if("undefined"!=typeof Blob&&t instanceof Blob&&t.type)return t.type;var n=/\.([a-zA-Z0-9]+)$/.exec(e||""),r=n?n[1].toLowerCase():"";return Pt[r]||"application/octet-stream"}function Et(t,e){var n=e.toLowerCase();return Object.keys(t).some((function(t){return t.toLowerCase()===n}))}function _t(t){return Object.keys(t).reduce((function(e,n){var r;return at(at({},e),((r={})[n]=[t[n]],r))}),{})}var Tt=function(){function t(t){this.context=t}var e,n,r,o,i,a,s,c,u,d,h,f,p,y,v,m;return Object.defineProperty(t.prototype,"config",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.request},enumerable:!1,configurable:!0}),t.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},t.prototype.uploadFile=function(t,e){return ut(this,void 0,Promise,(function(){var n,r,o,i,a,s,c,u,d,h,f,p,y,v,m,b,g,w,O,I,P,S,E,_,T,F,L,j,x,U,R;return lt(this,(function(C){switch(C.label){case 0:if(n=t.cloudPath,r=t.filePath,o=t.onUploadProgress,x=t.method,i=void 0===x?"put":x,U=t.headers,a=void 0===U?{}:U,s=t.fileContent,!yt(n)||!r&&!s)throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".uploadFile] invalid params")}));return c={put:ot.put,post:ot.post}[i.toLocaleLowerCase()]||ot.put,u=this.isGateWay(),d=at({},a),h=Object.keys(a).reduce((function(t,e){return"content-length"!==e.toLowerCase()&&(t[e]=a[e]),t}),{}),c===ot.put&&u&&(Et(d,"content-length")||"number"==typeof(f=function(t,e){var n=null!=t?t:e;if(null!==n){if("undefined"!=typeof Blob&&n instanceof Blob)return n.size;if("undefined"!=typeof ArrayBuffer){if(n instanceof ArrayBuffer)return n.byteLength;if("function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(n))return n.byteLength}if("string"==typeof n){if("undefined"!=typeof Blob)return new Blob([n]).size;var r=(o=n,null===(i=l())||void 0===i?void 0:i.byteLength(o));return"number"==typeof r?r:n.length}var o,i;return"object"==typeof n&&"number"==typeof n.size?n.size:void 0}}(r,s))&&(d["content-length"]=String(f)),Et(d,"content-type")||(d["content-type"]=St(r,n)),Et(h,"content-type")||(h["content-type"]=St(r,n))),[4,this.getUploadMetadata({cloudPath:n,method:c,headers:c!==ot.put||u?void 0:h,signedHeader:c===ot.put&&u?_t(d):void 0,customReqOpts:t.customReqOpts})];case 1:return p=C.sent(),y=p.data,v=p.requestId,(null==(m=y)?void 0:m.code)||!(null==m?void 0:m.url)?(b=(null==m?void 0:m.code)||ht.OPERATION_FAIL,g=(null==m?void 0:m.message)||"get upload info failed",[2,vt(e,new Error("[".concat(dt(),"][").concat(b,"][").concat(bt,"]:").concat(g)))]):(w=y.url,O=y.authorization,I=y.token,P=y.fileId,S=y.cosFileId,E=y.download_url,T=at(at({},_={url:w,file:r,name:n,onUploadProgress:o,fileContent:s,fileId:P,requestId:v}),{method:ot.put,headers:at(at({},h),{authorization:O,"x-cos-meta-fileid":S,"x-cos-security-token":I})}),F=at(at({},_),{method:ot.post,data:{key:n,signature:O,"x-cos-meta-fileid":S,success_action_status:"201","x-cos-security-token":I}}),(R={})[ot.put]={params:T,isSuccess:function(t){return t>=200&&t<300}},R[ot.post]={params:F,isSuccess:function(t){return 201===t}},L=R,[4,this.request.upload(L[c].params)]);case 2:return j=C.sent(),L[c].isSuccess(j.statusCode)?[2,vt(e,null,{fileID:P,download_url:E,requestId:v})]:[2,vt(e,new Error("[".concat(dt(),"][").concat(ht.OPERATION_FAIL,"][").concat(bt,"]:").concat(j.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return ut(this,void 0,Promise,(function(){var n,r,o,i,a,s,c,u,l,d;return lt(this,(function(h){switch(h.label){case 0:if(n=t.cloudPath,r=t.method,o=t.headers,i=t.signedHeader,!yt(n))throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".getUploadMetadata] invalid cloudPath")}));a=this.request,s="storage.getUploadMetadata",h.label=1;case 1:return h.trys.push([1,6,,7]),c=void 0,u={path:n},l=this.isGateWay(),r&&(u.method=r),r===ot.put&&(l&&i?u.signedHeader=i:!l&&o&&(u.headers=o)),l?[4,gt(a,u,t.customReqOpts)]:[3,3];case 2:return c=h.sent(),[3,5];case 3:return[4,a.send(s,u,t.customReqOpts)];case 4:c=h.sent(),h.label=5;case 5:return[2,vt(e,null,c)];case 6:return d=h.sent(),[2,vt(e,d)];case 7:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return ut(this,void 0,Promise,(function(){var n,r,o,i,a,s,c,u;return lt(this,(function(l){switch(l.label){case 0:if(!(n=t.fileList)||!pt(n)||0===n.length)throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".deleteFile] fileList must not be empty")}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!yt(i))throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".deleteFile] fileID must be string")}));return a="storage.batchDeleteFile",s=this.request,c={},this.isGateWay()?[4,Ot(s,{fileList:n},t.customReqOpts)]:[3,2];case 1:return c=l.sent(),[3,4];case 2:return[4,s.send(a,{fileid_list:n},t.customReqOpts)];case 3:c=l.sent(),l.label=4;case 4:return c.code?[2,vt(e,null,c)]:(u={fileList:c.data.delete_list,requestId:c.requestId},[2,vt(e,null,u)])}}))}))},t.prototype.getTempFileURL=function(t,e){return ut(this,void 0,Promise,(function(){var n,r,o,i,a,s,c,u;return lt(this,(function(l){switch(l.label){case 0:if(!(n=t.fileList)||!pt(n)||0===n.length)throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".getTempFileURL] fileList must not be empty")}));for(r=[],o=0,i=n;o<i.length;o++)if(a=i[o],d=a,"[object Object]"===Object.prototype.toString.call(d)){if(!Object.prototype.hasOwnProperty.call(a,"fileID"))throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".getTempFileURL] file info must include fileID")}));r.push({fileid:a.fileID,max_age:a.maxAge||7200})}else{if(!yt(a))throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".getTempFileURL] invalid fileList")}));r.push({fileid:a})}return s="storage.batchGetDownloadUrl",c=this.request,u={},this.isGateWay()?[4,wt(c,{convertedFileList:r},t.customReqOpts)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,c.send(s,{file_list:r},t.customReqOpts)];case 3:u=l.sent(),l.label=4;case 4:return u.code?[2,vt(e,null,u)]:[2,vt(e,null,{fileList:u.data.download_list,requestId:u.requestId})]}var d}))}))},t.prototype.downloadFile=function(t,e){return ut(this,void 0,Promise,(function(){var n,r,o,i,a,s;return lt(this,(function(c){switch(c.label){case 0:if(n=t.fileID,!yt(n))throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}],customReqOpts:t.customReqOpts})];case 1:return r=c.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,vt(e,o)]:(i=this.request,a=encodeURI(o.download_url),[4,i.download({url:a,tempFilePath:t.tempFilePath})]);case 2:return s=c.sent(),[2,vt(e,null,s)]}}))}))},t.prototype.copyFile=function(t,e){return ut(this,void 0,Promise,(function(){var n,r,o,i,a,s,c,u,l;return lt(this,(function(d){switch(d.label){case 0:if(!(n=t.fileList)||!pt(n)||0===n.length)throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".copyFile] fileList must not be empty")}));for(r=[],o=0,i=n;o<i.length;o++){if(a=i[o],s=a.srcPath,c=a.dstPath,!s||!c||"string"!=typeof s||"string"!=typeof c)throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".copyFile] srcPath and dstPath may not be empty")}));if(s===c)throw new Error(JSON.stringify({code:ht.INVALID_PARAMS,msg:"[".concat(bt,".copyFile] srcPath and dstPath can not be the same")}));r.push({src_path:s,dst_path:c,overwrite:a.overwrite,remove_original:a.removeOriginal})}return u=this.request,l={},this.isGateWay()?[4,It(u,{convertedFileList:r},t.customReqOpts)]:[3,2];case 1:return l=d.sent(),[3,4];case 2:return[4,u.send("storage.batchCopyFile",{file_list:r},t.customReqOpts)];case 3:l=d.sent(),d.label=4;case 4:return l.code?[2,vt(e,null,l)]:[2,vt(e,null,{fileList:l.data.copy_list,requestId:l.requestId})]}}))}))},t.prototype.getFileInfo=function(t){var e;return ut(this,void 0,Promise,(function(){var n,r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,this.getTempFileURL(t)];case 1:return(null==(n=o.sent())?void 0:n.fileList)&&(null===(e=null==n?void 0:n.fileList)||void 0===e?void 0:e.length)>0?[4,Promise.all(n.fileList.map((function(t){return ut(r,void 0,void 0,(function(){var e,n,r,o,i,a,s;return lt(this,(function(c){switch(c.label){case 0:if("SUCCESS"!==t.code)return[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,message:t.message}];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.request.fetch({url:t.tempFileURL,method:"HEAD"})];case 2:return e=c.sent(),n=e.header,"undefined"!=typeof Headers&&n instanceof Headers&&(r={},n.forEach((function(t,e){r[e]=t})),n=r),o=parseInt(n["content-length"])||0,i=n["content-type"]||"",[400,404].includes(Number(e.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:t.fileID,tempFileURL:t.tempFileURL,message:"file not found"}]:[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,cloudId:t.fileID,fileName:t.fileID.split("/").pop(),contentType:i,mime:i.split(";")[0].trim(),size:o,etag:n.etag||"",lastModified:n["last-modified"]||"",cacheControl:n["cache-control"]||""}];case 3:return a=c.sent(),s="object"==typeof a&&null!==a&&"message"in a?String(a.message):void 0,[2,{code:"FETCH_FILE_INFO_ERROR",fileID:t.fileID,tempFileURL:t.tempFileURL,message:s}];case 4:return[2]}}))}))})))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:n.requestId}];case 3:return[2,{fileList:[],requestId:n.requestId}]}}))}))},st([mt({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ft)]}),ct("design:type",Function),ct("design:paramtypes",[Object,"function"==typeof(e="undefined"!=typeof Function&&Function)?e:Object]),ct("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],t.prototype,"uploadFile",null),st([mt({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ft)]}),ct("design:type",Function),ct("design:paramtypes",[Object,"function"==typeof(r="undefined"!=typeof Function&&Function)?r:Object]),ct("design:returntype","function"==typeof(o="undefined"!=typeof Promise&&Promise)?o:Object)],t.prototype,"getUploadMetadata",null),st([mt({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ft)]}),ct("design:type",Function),ct("design:paramtypes",["function"==typeof(i=void 0!==it.ICloudbaseDeleteFileParams&&it.ICloudbaseDeleteFileParams)?i:Object,"function"==typeof(a="undefined"!=typeof Function&&Function)?a:Object]),ct("design:returntype","function"==typeof(s="undefined"!=typeof Promise&&Promise)?s:Object)],t.prototype,"deleteFile",null),st([mt({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ft)]}),ct("design:type",Function),ct("design:paramtypes",["function"==typeof(c=void 0!==it.ICloudbaseGetTempFileURLParams&&it.ICloudbaseGetTempFileURLParams)?c:Object,"function"==typeof(u="undefined"!=typeof Function&&Function)?u:Object]),ct("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"getTempFileURL",null),st([mt({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ft)]}),ct("design:type",Function),ct("design:paramtypes",["function"==typeof(h=void 0!==it.ICloudbaseDownloadFileParams&&it.ICloudbaseDownloadFileParams)?h:Object,"function"==typeof(f="undefined"!=typeof Function&&Function)?f:Object]),ct("design:returntype","function"==typeof(p="undefined"!=typeof Promise&&Promise)?p:Object)],t.prototype,"downloadFile",null),st([mt({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ft)]}),ct("design:type",Function),ct("design:paramtypes",["function"==typeof(y=void 0!==it.ICloudbaseCopyFileParams&&it.ICloudbaseCopyFileParams)?y:Object,"function"==typeof(v="undefined"!=typeof Function&&Function)?v:Object]),ct("design:returntype","function"==typeof(m="undefined"!=typeof Promise&&Promise)?m:Object)],t.prototype,"copyFile",null),t}(),Ft=function(){return Ft=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ft.apply(this,arguments)},Lt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},jt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},xt=D,Ut=function(){function t(t,e){void 0===e&&(e=!1),this.shouldThrowOnError=!1,this.bucketId="",this.context=t,this.shouldThrowOnError=e,this.storage=new Tt(t)}return Object.defineProperty(t.prototype,"config",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.request},enumerable:!1,configurable:!0}),t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.upload=function(t,e,n){return Lt(this,void 0,Promise,(function(){var r,o,i,a,c,u,l,d,h;return jt(this,(function(f){switch(f.label){case 0:r=Ft({upsert:!0},n),o=r.cacheControl,i=r.contentType,a=r.metadata,f.label=1;case 1:return f.trys.push([1,3,,4]),c=this.getCloudPath(t),u={cloudPath:c,filePath:e},(o||i||a)&&(l={},o&&(l["cache-control"]=o),i&&(l["content-type"]=i),a&&(l["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(a))),u.headers=l),[4,this.storage.uploadFile(u)];case 2:if(!(d=f.sent()).fileID)throw new Error(JSON.stringify({code:xt.OPERATION_FAIL,msg:"[".concat(bt,".update] no fileID returned")}));return[2,{data:{id:d.fileID,path:t,fullPath:t},error:null}];case 3:if(h=f.sent(),this.shouldThrowOnError)throw h;if(s(h))return[2,{data:null,error:h}];throw h;case 4:return[2]}}))}))},t.prototype.uploadToSignedUrl=function(t,e,n,r){return Lt(this,void 0,Promise,(function(){return jt(this,(function(e){return[2,this.upload(t,n,r)]}))}))},t.prototype.createSignedUploadUrl=function(t){return Lt(this,void 0,Promise,(function(){var e,n,r;return jt(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.getCloudPath(t),[4,this.storage.getUploadMetadata({cloudPath:e})];case 1:return[2,{data:{signedUrl:(n=o.sent().data).url,token:n.token,path:t,authorization:n.authorization,id:n.fileId,cosFileId:n.cosFileId,downloadUrl:n.download_url},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;return[2,{data:null,error:r instanceof a?r:new a(r.message)}];case 3:return[2]}}))}))},t.prototype.update=function(t,e,n){return Lt(this,void 0,Promise,(function(){return jt(this,(function(r){return[2,this.upload(t,e,Ft(Ft({},n),{upsert:!0}))]}))}))},t.prototype.move=function(t,e){return Lt(this,void 0,Promise,(function(){var n,r;return jt(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(t),dstPath:this.getCloudPath(e),overwrite:!0,removeOriginal:!0}]})];case 1:if((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a(n.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(t," to ").concat(e)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if(s(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.copy=function(t,e){return Lt(this,void 0,Promise,(function(){var n,r;return jt(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(t),dstPath:this.getCloudPath(e),overwrite:!0,removeOriginal:!1}]})];case 1:if((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a(n.fileList[0].message||"Copy failed");return[2,{data:{path:this.getCloudPath(e)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if(s(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(t,e,n){return Lt(this,void 0,Promise,(function(){var r,o,i,c,u,l,d;return jt(this,(function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),r=this.normalizeCloudId(t),[4,this.storage.getTempFileURL({fileList:[{fileID:r,maxAge:e}]})];case 1:if("SUCCESS"!==(o=h.sent()).fileList[0].code)throw new a("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return i=o.fileList[0].download_url,c=[],void 0!==(null==n?void 0:n.download)&&("string"==typeof n.download?c.push("download=".concat(encodeURIComponent(n.download))):!0===n.download&&c.push("download=true")),(null==n?void 0:n.transform)&&(u=this.transformOptsToQueryString(n.transform))&&c.push(u),c.length>0&&(l=i.includes("?")?"&":"?",i="".concat(i).concat(l).concat(c.join("&"))),[2,{data:{signedUrl:i},error:null}];case 2:if(d=h.sent(),this.shouldThrowOnError)throw d;if(s(d))return[2,{data:null,error:d}];throw d;case 3:return[2]}}))}))},t.prototype.createSignedUrls=function(t,e){return Lt(this,void 0,Promise,(function(){var n,r,o=this;return jt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=t.map((function(t){return{fileID:o.normalizeCloudId(t),maxAge:e}})),[4,this.storage.getTempFileURL({fileList:n})];case 1:return[2,{data:i.sent().fileList.map((function(e,n){return{path:t[n],signedUrl:e.tempFileURL||"",error:"SUCCESS"===e.code?null:e.message}})),error:null}];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if(s(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.download=function(t,e){return Lt(this,void 0,Promise,(function(){var n,r,o=this;return jt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r={},[4,Lt(o,void 0,void 0,(function(){var n,r,o,i;return jt(this,(function(s){switch(s.label){case 0:return[4,this.createSignedUrl(t,600,{transform:e})];case 1:if((n=s.sent()).error)throw n.error;return r=encodeURI(null===(i=n.data)||void 0===i?void 0:i.signedUrl),[4,this.request.reqClass.get({url:r,headers:{},responseType:"blob"})];case 2:if(!(o=s.sent().data))throw new a("Download failed: no file content");return[2,new Blob([o])]}}))}))];case 1:return[2,(r.data=i.sent(),r.error=null,r)];case 2:if(n=i.sent(),this.shouldThrowOnError)throw n;if(s(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.info=function(t){return Lt(this,void 0,Promise,(function(){var e,n,r,o,i,s,c,u;return jt(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),e=t.startsWith("cloud://"),n=e?this.extractPathFromFileId(t):t,r=e?this.extractBucketFromFileId(t):this.bucketId,[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(o=l.sent(),"SUCCESS"!==(i=o.fileList[0]).code)throw new a(i.message);return s=(new Date).toISOString(),c=(i.lastModified?new Date(i.lastModified):new Date).toISOString(),[2,{data:{id:i.fileID,version:"1",name:n,bucketId:r,updatedAt:c,createdAt:c,lastAccessedAt:s,size:i.size,cacheControl:i.cacheControl,contentType:i.contentType,etag:i.etag,lastModified:c,metadata:{}},error:null}];case 2:if(u=l.sent(),this.shouldThrowOnError)throw u;return[2,{data:null,error:u instanceof a?u:new a(u.message)}];case 3:return[2]}}))}))},t.prototype.exists=function(t){return Lt(this,void 0,Promise,(function(){var e,n,r;return jt(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(e=o.sent(),"FILE_NOT_FOUND"===(n=e.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==n.code)throw new a(n.message);return[2,{data:!0,error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if(s(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.getPublicUrl=function(t,e){return Lt(this,void 0,Promise,(function(){var n;return jt(this,(function(r){switch(r.label){case 0:return[4,this.createSignedUrl(t,600,e)];case 1:return(n=r.sent()).data?[2,{data:{publicUrl:n.data.signedUrl}}]:[2,{data:null,error:n.error}]}}))}))},t.prototype.remove=function(t){return Lt(this,void 0,Promise,(function(){var e,n,r,o,i,c,u,l,d,h,f=this;return jt(this,(function(p){switch(p.label){case 0:for(p.trys.push([0,3,,4]),e=10,n=[],r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return[4,Promise.all(n.map((function(t){return Promise.all(t.map((function(t){return f.info(t)})))})))];case 1:return o=p.sent(),i=new Map,o.forEach((function(n,r){n.forEach((function(n,o){n.data&&i.set(t[r*e+o],n.data)}))})),c=t.map((function(t){return f.normalizeCloudId(t)})),[4,this.storage.deleteFile({fileList:c})];case 2:if(u=p.sent(),(l=u.fileList.filter((function(t){return"SUCCESS"!==t.code}))).length>0)throw new a("Delete failed for ".concat(l.length," file(s)"));return d=(new Date).toISOString(),[2,{data:t.map((function(t){var e=i.get(t);return{name:null==e?void 0:e.name,id:null==e?void 0:e.id,bucket_id:null==e?void 0:e.bucketId,owner:void 0,updated_at:(null==e?void 0:e.updatedAt)||d,created_at:null==e?void 0:e.createdAt,last_accessed_at:(null==e?void 0:e.lastAccessedAt)||d,metadata:(null==e?void 0:e.metadata)||{},buckets:{id:null==e?void 0:e.bucketId,name:null==e?void 0:e.bucketId,owner:void 0,public:!1,created_at:"",updated_at:d}}})),error:null}];case 3:if(h=p.sent(),this.shouldThrowOnError)throw h;if(s(h))return[2,{data:null,error:h}];throw h;case 4:return[2]}}))}))},t.prototype.list=function(){return Lt(this,void 0,void 0,(function(){return jt(this,(function(t){throw new a("Not implemented")}))}))},t.prototype.getCloudPath=function(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},t.prototype.normalizeCloudId=function(t){var e;if(/^cloud:\/\//.test(t))return t;var n=this.getCloudPath(t);if(!this.bucketId)throw new a("bucketId is not set");var r=(null===(e=this.config)||void 0===e?void 0:e.env)||"";return r?"cloud://".concat(r,".").concat(this.bucketId,"/").concat(n):void 0},t.prototype.toBase64=function(t){return d(t)},t.prototype.transformOptsToQueryString=function(t){var e=["imageMogr2"];if(t.width||t.height){var n=t.width||"",r=t.height||"";"fill"===t.resize?e.push("thumbnail/".concat(n,"x").concat(r,"!")):"contain"===t.resize?e.push("thumbnail/".concat(n,"x").concat(r)):e.push("thumbnail/".concat(n,"x").concat(r,"^"))}if(t.format&&"origin"!==t.format&&e.push("format/".concat(t.format)),void 0!==t.quality){var o=Math.max(1,Math.min(100,t.quality));e.push("quality/".concat(o))}return e.join("/")},t.prototype.extractPathFromFileId=function(t){var e=t.replace(/^cloud:\/\//,"").split("/");return e.length<2?t:e.slice(1).join("/")},t.prototype.extractBucketFromFileId=function(t){var e=t.replace(/^cloud:\/\//,"").split("/");if(e.length<1)return"";var n=e[0],r=n.indexOf(".");return-1===r?n:n.substring(r+1)},t}(),Rt=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 r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ct=new Tt,At={name:bt,entity:{uploadFile:Ct.uploadFile,deleteFile:Ct.deleteFile,getTempFileURL:Ct.getTempFileURL,downloadFile:Ct.downloadFile,getUploadMetadata:Ct.getUploadMetadata,copyFile:Ct.copyFile,getFileInfo:Ct.getFileInfo,isGateWay:Ct.isGateWay}},kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Rt(e,t),e.prototype.from=function(t){return t?(U(t,"from"),new j(this.http,t,this.shouldThrowOnError)):new Ut(this.http.ctx,this.shouldThrowOnError)},e}(A),Nt={name:"".concat(bt,"/supabase"),IIFE:!0,entity:function(){var t=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(t.has(this))return t.get(this);var e=this,n=new Proxy({},{get:function(t,n){return"config"===n?e.config:"request"===n?e.request:void 0}}),r=new kt(n);return t.set(this,r),r},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(At),cloudbase.registerComponent(Nt)}catch(t){}function Dt(t){try{t.registerComponent(At),t.registerComponent(Nt)}catch(t){console.warn(t)}}try{window.registerStorage=Dt}catch(t){}var qt=Dt})();var a=i.v;export{a as registerStorage};
2
+ //# sourceMappingURL=index.esm.js.map