@kyro-cms/core 0.12.47 → 0.12.49

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 (172) hide show
  1. package/README.md +21 -0
  2. package/dist/api-handler-graphql.cjs +1 -1
  3. package/dist/api-handler-graphql.js +1 -1
  4. package/dist/api-handler-trpc.cjs +1 -1
  5. package/dist/api-handler-trpc.js +1 -1
  6. package/dist/api-handler.cjs +1 -1
  7. package/dist/api-handler.js +1 -1
  8. package/dist/auth-session-DHVGXHOH.cjs +1 -0
  9. package/dist/auth-session-O7IIH7EP.js +1 -0
  10. package/dist/bcryptjs-ZEEHSMAG.js +2 -0
  11. package/dist/{better-sqlite3-42Q3FG3E.js → better-sqlite3-B34RIU4C.js} +1 -1
  12. package/dist/bootstrap-4FK3LPPH.js +1 -0
  13. package/dist/bootstrap-F4SDJLPK.cjs +1 -0
  14. package/dist/{bowser-FI5JQGKZ.js → bowser-SB3ZUPO4.js} +1 -1
  15. package/dist/chokidar-5RVQZVHP.cjs +5 -0
  16. package/dist/chokidar-BOYGRT4Q.js +6 -0
  17. package/dist/{chunk-DS5DE5BU.js → chunk-24L3UEJJ.js} +1 -1
  18. package/dist/{chunk-HT44I66C.js → chunk-2HA6EKXX.js} +1 -1
  19. package/dist/{chunk-7AQSH3KR.js → chunk-3NSZZCOJ.js} +1 -1
  20. package/dist/{chunk-VIUU4D5I.js → chunk-47CXBWMA.js} +1 -1
  21. package/dist/{chunk-6MSS5X77.js → chunk-5M3FKE2V.js} +1 -1
  22. package/dist/chunk-63BSQ3FK.cjs +1 -0
  23. package/dist/chunk-6TPICJ2L.js +7 -0
  24. package/dist/{chunk-K7YNEKVE.js → chunk-7FXEXHK6.js} +1 -1
  25. package/dist/{chunk-WSP7PSXC.js → chunk-7MNDQU6K.js} +1 -1
  26. package/dist/{chunk-7V67ONUD.js → chunk-7N7U2ERH.js} +1 -1
  27. package/dist/{chunk-BPMA2ECA.js → chunk-7NH7H3WA.js} +1 -1
  28. package/dist/{chunk-ZJE3VAAW.js → chunk-BU6O3TP7.js} +3 -3
  29. package/dist/{chunk-W46LZ4MY.js → chunk-C7QCZX7X.js} +1 -1
  30. package/dist/chunk-CFZVJTXW.cjs +264 -0
  31. package/dist/{chunk-2WFTETFB.js → chunk-CIVA6SKW.js} +1 -1
  32. package/dist/chunk-EFGOYI57.js +265 -0
  33. package/dist/{chunk-2BUODBE2.js → chunk-EML5FDUU.js} +1 -1
  34. package/dist/{chunk-66BJXVFJ.js → chunk-FLMUMPDE.js} +1 -1
  35. package/dist/{chunk-QYI3GOHF.cjs → chunk-HKNQVI76.cjs} +1 -1
  36. package/dist/{chunk-IP6JUEH3.js → chunk-HRAY65XH.js} +1 -1
  37. package/dist/{chunk-KH7LM52S.js → chunk-IKGVPXMK.js} +1 -1
  38. package/dist/{chunk-XSRISWOY.js → chunk-JR6IOJO7.js} +2 -2
  39. package/dist/{chunk-XOACKBG7.js → chunk-JRUQ5ABB.js} +2 -2
  40. package/dist/{chunk-OMWQVPV7.js → chunk-JV4HJBXW.js} +1 -1
  41. package/dist/{chunk-X54XZACS.cjs → chunk-KZHXYXSH.cjs} +2 -2
  42. package/dist/{chunk-UD6ZPO7T.js → chunk-L2QXP26Q.js} +1 -1
  43. package/dist/{chunk-ORG67NXX.js → chunk-L3Q64RUX.js} +1 -1
  44. package/dist/chunk-LELK3TYX.js +3 -0
  45. package/dist/chunk-LGYBTBWE.js +2 -0
  46. package/dist/{chunk-7I6URA6F.js → chunk-LVBHOZZF.js} +1 -1
  47. package/dist/{chunk-R3NEPC4I.js → chunk-LWM4WABU.js} +1 -1
  48. package/dist/{chunk-TR3ZS3T3.js → chunk-M75VGFCI.js} +1 -1
  49. package/dist/chunk-MCIZG4A3.cjs +1 -0
  50. package/dist/{chunk-VBPAAQEF.js → chunk-N5POANYV.js} +1 -1
  51. package/dist/chunk-O4YE57OS.cjs +6 -0
  52. package/dist/{chunk-A73AVVFR.js → chunk-OBYAIJVU.js} +1 -1
  53. package/dist/chunk-OLRCZ6E3.js +2 -0
  54. package/dist/{chunk-WGESLAWV.js → chunk-OXGJOYEO.js} +1 -1
  55. package/dist/{chunk-CGPAS4U5.js → chunk-P6JITOFF.js} +1 -1
  56. package/dist/{chunk-JUJZOG6P.js → chunk-PA4ZZREG.js} +1 -1
  57. package/dist/{chunk-45TJAB5X.js → chunk-PENOCINR.js} +3 -3
  58. package/dist/{chunk-MZOWPV4D.js → chunk-PRMILS4Y.js} +1 -1
  59. package/dist/chunk-QDBGBDCT.js +2 -0
  60. package/dist/{chunk-XBH4YMC7.js → chunk-R25WLKX4.js} +1 -1
  61. package/dist/{chunk-J6U5LWZ7.js → chunk-RPRGGGIW.js} +3 -3
  62. package/dist/{chunk-E27KEZPT.js → chunk-RTHJ6SS5.js} +1 -1
  63. package/dist/{chunk-MCZ3YZ2L.js → chunk-SLMIYECU.js} +1 -1
  64. package/dist/{chunk-IPXOY4RI.js → chunk-SQBTIMWF.js} +1 -1
  65. package/dist/{chunk-VJ2WMKPK.js → chunk-SZT6BLUR.js} +1 -1
  66. package/dist/{chunk-6KRR7YHA.js → chunk-TBHNE4VV.js} +1 -1
  67. package/dist/{chunk-OSAVAYJZ.js → chunk-TYQYKKWJ.js} +1 -1
  68. package/dist/{chunk-ICVQWR2A.js → chunk-U6KFONKM.js} +1 -1
  69. package/dist/chunk-UT7RGIYS.js +2 -0
  70. package/dist/{chunk-PBOZJOKN.js → chunk-UWHWSWDE.js} +1 -1
  71. package/dist/chunk-VVVCCB6R.js +2 -0
  72. package/dist/{chunk-MY42EWZP.js → chunk-W45TLOOT.js} +1 -1
  73. package/dist/{chunk-R4N352LI.cjs → chunk-WC7H45ZG.cjs} +3 -3
  74. package/dist/chunk-WJBQ2NBD.cjs +1 -0
  75. package/dist/{chunk-ATBH763U.js → chunk-WPM6LFCY.js} +1 -1
  76. package/dist/chunk-XBQ6HV3T.cjs +114 -0
  77. package/dist/{chunk-C2PXMVR5.js → chunk-Y2YAKDEQ.js} +1 -1
  78. package/dist/chunk-YENNL5HG.js +2 -0
  79. package/dist/{chunk-SYEP5QLG.js → chunk-YUUXFD73.js} +1 -1
  80. package/dist/{chunk-NWCREF47.js → chunk-YZEMLLD2.js} +1 -1
  81. package/dist/chunk-ZKHTFR5S.cjs +2 -0
  82. package/dist/{chunk-7T35572E.js → chunk-ZMG7Z3KF.js} +1 -1
  83. package/dist/{chunk-HLAEJB5R.js → chunk-ZRIBWDYJ.js} +1 -1
  84. package/dist/chunk-ZWDBPEXL.js +115 -0
  85. package/dist/cli/index.cjs +1 -1
  86. package/dist/cli/index.js +2 -2
  87. package/dist/client.js +1 -1
  88. package/dist/{d1-VPH75GI2.js → d1-HPB6B253.js} +1 -1
  89. package/dist/{dist-es-6TQTDPE7.js → dist-es-64F22JL2.js} +2 -2
  90. package/dist/{dist-es-XZBHIIKY.js → dist-es-F2ZR55UK.js} +2 -2
  91. package/dist/dist-es-IPSSZNFP.js +1 -0
  92. package/dist/{dist-es-SJ76GYCI.js → dist-es-M2F7M27Y.js} +1 -1
  93. package/dist/{dist-es-U4ZB3ZDA.js → dist-es-M66JKZF5.js} +1 -1
  94. package/dist/{dist-es-MNIQZC4U.js → dist-es-OKLLRYI3.js} +2 -2
  95. package/dist/{dist-es-TX4DBXEW.js → dist-es-SVHZDVUF.js} +2 -2
  96. package/dist/{dist-es-EMUQ6ZNZ.js → dist-es-WFI55HKT.js} +1 -1
  97. package/dist/drizzle/index.cjs +1 -1
  98. package/dist/drizzle/index.d.cts +1 -0
  99. package/dist/drizzle/index.d.ts +1 -0
  100. package/dist/drizzle/index.js +1 -1
  101. package/dist/drizzle-orm-XRTSOQJS.js +1 -0
  102. package/dist/event-streams-7NAWZW2I.js +1 -0
  103. package/dist/fields/index.js +1 -1
  104. package/dist/fs-KWBRQ6T6.js +1 -0
  105. package/dist/fs-ZQYOJOIO.cjs +1 -0
  106. package/dist/graphql/index.js +1 -1
  107. package/dist/index.cjs +9 -9
  108. package/dist/index.js +10 -10
  109. package/dist/integration.js +1 -1
  110. package/dist/{jsonwebtoken-S7BG2YWK.js → jsonwebtoken-OD67R5JS.js} +3 -3
  111. package/dist/{lib-IYW32OER.js → lib-XXYYUPMW.js} +3 -3
  112. package/dist/{loadSso-YTG2GQGW.js → loadSso-UQR6545M.js} +1 -1
  113. package/dist/local-3V3XEQUY.js +1 -0
  114. package/dist/media-E762GEHL.js +1 -0
  115. package/dist/mongo-auth-adapter-QDXVHREJ.js +1 -0
  116. package/dist/{mongo-auth-adapter-7K64Y2QM.cjs → mongo-auth-adapter-W3HLB7OR.cjs} +1 -1
  117. package/dist/mongodb/index.cjs +1 -1
  118. package/dist/mongodb/index.js +1 -1
  119. package/dist/{nodemailer-AXROO37D.js → nodemailer-NITB45SS.js} +3 -3
  120. package/dist/postgres-auth-adapter-SK3N3OSS.js +1 -0
  121. package/dist/postgres-auth-adapter-ZO6HK5AK.cjs +1 -0
  122. package/dist/postgres-js-3Y54EXVQ.cjs +1 -1
  123. package/dist/postgres-js-4CI7FMYS.js +1 -0
  124. package/dist/redis-adapter-QPCTMF55.js +1 -0
  125. package/dist/rest/index.cjs +1 -1
  126. package/dist/rest/index.js +1 -1
  127. package/dist/schema-YFMSJK2P.js +2 -0
  128. package/dist/{signin-KZBIAHGS.js → signin-N3T2KF5Q.js} +1 -1
  129. package/dist/sqlite-adapter-4TPNROJK.js +1 -0
  130. package/dist/src-QBADSZV4.js +1 -0
  131. package/dist/{sso-oidc-SX5OIQGG.js → sso-oidc-UB7G4END.js} +1 -1
  132. package/dist/{sts-HVGDJYIF.js → sts-WAA6I22C.js} +1 -1
  133. package/dist/templates/index.js +1 -1
  134. package/dist/trpc/index.js +1 -1
  135. package/dist/ws/index.js +1 -1
  136. package/package.json +2 -2
  137. package/dist/bcryptjs-AZA6WEN2.js +0 -2
  138. package/dist/bootstrap-7CI3NVSY.js +0 -1
  139. package/dist/bootstrap-DOOM2CNQ.cjs +0 -1
  140. package/dist/chokidar-24HVS6XD.cjs +0 -5
  141. package/dist/chokidar-43DT7CVN.js +0 -6
  142. package/dist/chunk-5DWYVUQR.cjs +0 -1
  143. package/dist/chunk-6QWLXJ7L.js +0 -2
  144. package/dist/chunk-B3GDQ7UI.cjs +0 -114
  145. package/dist/chunk-BLH2MRK4.js +0 -2
  146. package/dist/chunk-EOOZDOL7.js +0 -3
  147. package/dist/chunk-F3MCWKOW.cjs +0 -1
  148. package/dist/chunk-FYPEL7XW.js +0 -270
  149. package/dist/chunk-MPGROUMH.js +0 -2
  150. package/dist/chunk-PL5AIE6F.js +0 -2
  151. package/dist/chunk-QDHP5E4P.cjs +0 -2
  152. package/dist/chunk-QN5ULXBX.cjs +0 -269
  153. package/dist/chunk-R4LXRAMX.js +0 -2
  154. package/dist/chunk-SVYUTQVE.js +0 -115
  155. package/dist/chunk-UB5TJHQR.js +0 -2
  156. package/dist/chunk-XPPVX4GQ.cjs +0 -1
  157. package/dist/dist-es-6SVFVYN3.js +0 -1
  158. package/dist/drizzle-orm-7YTX5NTT.js +0 -1
  159. package/dist/event-streams-25YJ2Z6R.js +0 -1
  160. package/dist/fs-DGKZLRM6.cjs +0 -1
  161. package/dist/fs-YZJ5FM6J.js +0 -2
  162. package/dist/local-VDCSEMC2.js +0 -1
  163. package/dist/media-HK2IZMUZ.js +0 -1
  164. package/dist/mongo-auth-adapter-BUKINEZL.js +0 -1
  165. package/dist/postgres-auth-adapter-2M4RNEY3.cjs +0 -1
  166. package/dist/postgres-auth-adapter-MKSHIJDL.js +0 -1
  167. package/dist/postgres-js-INQPBHJP.js +0 -1
  168. package/dist/redis-adapter-SXOXLHNH.js +0 -1
  169. package/dist/schema-XC5ISGNR.js +0 -2
  170. package/dist/sqlite-adapter-DV7ZX2EJ.js +0 -1
  171. package/dist/src-GZRZ4VAO.js +0 -1
  172. /package/dist/{chunk-P7XYIKL6.cjs → chunk-YUER4JU3.cjs} +0 -0
@@ -1,2 +1,2 @@
1
- import {createRequire}from'module';import {J,c,d}from'./chunk-7AQSH3KR.js';import {g as g$1}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
1
+ import {J,c,d}from'./chunk-3NSZZCOJ.js';import {g as g$1}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  g$1();g$1();function a(r){return J`count(${r||J.raw("*")})`.mapWith(Number)}function s(r){return J`count(distinct ${r})`.mapWith(Number)}function x(r){return J`avg(${r})`.mapWith(String)}function y(r){return J`avg(distinct ${r})`.mapWith(String)}function g(r){return J`sum(${r})`.mapWith(String)}function A(r){return J`sum(distinct ${r})`.mapWith(String)}function h(r){return J`max(${r})`.mapWith(c(r,d)?r:String)}function D(r){return J`min(${r})`.mapWith(c(r,d)?r:String)}g$1();function o(r){return JSON.stringify(r)}function q(r,t){return Array.isArray(t)?J`${r} <-> ${o(t)}`:J`${r} <-> ${t}`}function N(r,t){return Array.isArray(t)?J`${r} <+> ${o(t)}`:J`${r} <+> ${t}`}function b(r,t){return Array.isArray(t)?J`${r} <#> ${o(t)}`:J`${r} <#> ${t}`}function j(r,t){return Array.isArray(t)?J`${r} <=> ${o(t)}`:J`${r} <=> ${t}`}function w(r,t){return Array.isArray(t)?J`${r} <~> ${o(t)}`:J`${r} <~> ${t}`}function C(r,t){return Array.isArray(t)?J`${r} <%> ${o(t)}`:J`${r} <%> ${t}`}export{a,s as b,x as c,y as d,g as e,A as f,h as g,D as h,q as i,N as j,b as k,j as l,w as m,C as n};
@@ -1,2 +1,2 @@
1
- import {createRequire}from'module';import {a,c,A,h}from'./chunk-7AQSH3KR.js';import {g}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
1
+ import {a,c,A,h}from'./chunk-3NSZZCOJ.js';import {g}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  g();var f=class{constructor(e,n){this.unique=e,this.name=n;}static[a]="PgIndexBuilderOn";on(...e){return new u(e.map(n=>{if(c(n,A))return n;n=n;let r=new h(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=JSON.parse(JSON.stringify(n.defaultConfig)),r}),this.unique,false,this.name)}onOnly(...e){return new u(e.map(n=>{if(c(n,A))return n;n=n;let r=new h(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=n.defaultConfig,r}),this.unique,true,this.name)}using(e,...n){return new u(n.map(r=>{if(c(r,A))return r;r=r;let a=new h(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),a}),this.unique,true,this.name,e)}},u=class{static[a]="PgIndexBuilder";config;constructor(e,n,r,a,g="btree"){this.config={name:a,columns:e,unique:n,only:r,method:g};}concurrently(){return this.config.concurrently=true,this}with(e){return this.config.with=e,this}where(e){return this.config.where=e,this}build(e){return new m(this.config,e)}},m=class{static[a]="PgIndex";config;constructor(e,n){this.config={...e,table:n};}};function p(o){return new f(false,o)}function y(o){return new f(true,o)}export{p as a,y as b};
@@ -1 +1 @@
1
- 'use strict';var chunkP7XYIKL6_cjs=require('./chunk-P7XYIKL6.cjs'),chunkBHR7OAU4_cjs=require('./chunk-BHR7OAU4.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();async function g(t){let{adminEmail:e,adminPassword:r,adminRole:a="super_admin",tenantId:n,emailConfig:o,sendWelcomeEmail:c=false}=t,s=t.authAdapter||new chunkBHR7OAU4_cjs.a({path:t.authDbPath||"./data/auth.db"});try{await s.connect?.();}catch{return {success:false,error:"Failed to connect to auth storage"}}let u=new chunkP7XYIKL6_cjs.l().validate(r);if(!u.valid)return await s.disconnect?.(),{success:false,error:`Invalid password: ${u.errors.join(", ")}`};if(await s.findUserByEmail(e))return await s.disconnect?.(),{success:false,error:"Admin user already exists"};try{let i=await s.createUser({name:"Super Admin",email:e,password:r,role:a||"admin",tenantId:n});if(await s.updateUser?.(i.id,{emailVerified:!0}),c&&o){let l=new chunkP7XYIKL6_cjs.k(o),A=l.getTemplates().welcome(e.split("@")[0]);await l.send({to:e,...A});}return await s.disconnect?.(),{success:!0,user:i}}catch(i){return await s.disconnect?.(),{success:false,error:i instanceof Error?i.message:"Failed to create admin user"}}}async function U(t,e){return !await t.findUserByEmail(e)}function w(t){let e=t.KYRO_ADMIN_EMAIL,r=t.KYRO_ADMIN_PASSWORD;return !e||!r?null:{authDbPath:t.KYRO_AUTH_DB_PATH||"./data/auth.db",adminEmail:e,adminPassword:r,adminRole:t.KYRO_ADMIN_ROLE||"super_admin",tenantId:t.KYRO_ADMIN_TENANT_ID,emailConfig:t.SMTP_HOST?{provider:"smtp",smtp:{host:t.SMTP_HOST,port:parseInt(t.SMTP_PORT||"587",10),secure:t.SMTP_SECURE==="true",auth:{user:t.SMTP_USER||"",pass:t.SMTP_PASS||""}},from:t.SMTP_FROM||"noreply@example.com",fromName:t.SMTP_FROM_NAME}:void 0,sendWelcomeEmail:t.KYRO_ADMIN_SEND_WELCOME==="true"}}function h(){return w(process.env)}async function E(){try{let{env:t}=await import('cloudflare:workers');if(t){let e=w(t);if(e)return e}}catch{}return null}async function M(t){let e=h()||await E();if(!e)return null;t&&(e.authAdapter=t);try{if(await e.authAdapter?.connect?.(),await e.authAdapter?.findUserByEmail(e.adminEmail))return await e.authAdapter?.disconnect?.(),{success:!1,error:"Admin user already exists"}}catch{}let r=await g(e);return r.success||console.error(`Bootstrap failed: ${r.error}`),r}async function x(t,e=3,r=2e3){let a="";for(let n=0;n<e;n++){let o=await g(t);if(o.success||(a=o.error||"Unknown error",a.includes("already exists")))return o;n<e-1&&await new Promise(c=>setTimeout(c,r));}return {success:false,error:`Failed after ${e} retries: ${a}`}}exports.a=g;exports.b=U;exports.c=w;exports.d=h;exports.e=M;exports.f=x;
1
+ 'use strict';var chunkYUER4JU3_cjs=require('./chunk-YUER4JU3.cjs'),chunkBHR7OAU4_cjs=require('./chunk-BHR7OAU4.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();async function g(t){let{adminEmail:e,adminPassword:r,adminRole:a="super_admin",tenantId:n,emailConfig:o,sendWelcomeEmail:c=false}=t,s=t.authAdapter||new chunkBHR7OAU4_cjs.a({path:t.authDbPath||"./data/auth.db"});try{await s.connect?.();}catch{return {success:false,error:"Failed to connect to auth storage"}}let u=new chunkYUER4JU3_cjs.l().validate(r);if(!u.valid)return await s.disconnect?.(),{success:false,error:`Invalid password: ${u.errors.join(", ")}`};if(await s.findUserByEmail(e))return await s.disconnect?.(),{success:false,error:"Admin user already exists"};try{let i=await s.createUser({name:"Super Admin",email:e,password:r,role:a||"admin",tenantId:n});if(await s.updateUser?.(i.id,{emailVerified:!0}),c&&o){let l=new chunkYUER4JU3_cjs.k(o),A=l.getTemplates().welcome(e.split("@")[0]);await l.send({to:e,...A});}return await s.disconnect?.(),{success:!0,user:i}}catch(i){return await s.disconnect?.(),{success:false,error:i instanceof Error?i.message:"Failed to create admin user"}}}async function U(t,e){return !await t.findUserByEmail(e)}function w(t){let e=t.KYRO_ADMIN_EMAIL,r=t.KYRO_ADMIN_PASSWORD;return !e||!r?null:{authDbPath:t.KYRO_AUTH_DB_PATH||"./data/auth.db",adminEmail:e,adminPassword:r,adminRole:t.KYRO_ADMIN_ROLE||"super_admin",tenantId:t.KYRO_ADMIN_TENANT_ID,emailConfig:t.SMTP_HOST?{provider:"smtp",smtp:{host:t.SMTP_HOST,port:parseInt(t.SMTP_PORT||"587",10),secure:t.SMTP_SECURE==="true",auth:{user:t.SMTP_USER||"",pass:t.SMTP_PASS||""}},from:t.SMTP_FROM||"noreply@example.com",fromName:t.SMTP_FROM_NAME}:void 0,sendWelcomeEmail:t.KYRO_ADMIN_SEND_WELCOME==="true"}}function h(){return w(process.env)}async function E(){try{let{env:t}=await import('cloudflare:workers');if(t){let e=w(t);if(e)return e}}catch{}return null}async function M(t){let e=h()||await E();if(!e)return null;t&&(e.authAdapter=t);try{if(await e.authAdapter?.connect?.(),await e.authAdapter?.findUserByEmail(e.adminEmail))return await e.authAdapter?.disconnect?.(),{success:!1,error:"Admin user already exists"}}catch{}let r=await g(e);return r.success||console.error(`Bootstrap failed: ${r.error}`),r}async function x(t,e=3,r=2e3){let a="";for(let n=0;n<e;n++){let o=await g(t);if(o.success||(a=o.error||"Unknown error",a.includes("already exists")))return o;n<e-1&&await new Promise(c=>setTimeout(c,r));}return {success:false,error:`Failed after ${e} retries: ${a}`}}exports.a=g;exports.b=U;exports.c=w;exports.d=h;exports.e=M;exports.f=x;
@@ -1,3 +1,3 @@
1
- import {createRequire}from'module';import {a,t,l,c,d,A,J,H as H$1,D,y,K as K$1,N,z,w,qa}from'./chunk-7AQSH3KR.js';import {g}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
1
+ import {a,t,l,c,d,A,J,H as H$1,D,y,K as K$1,N,z,w,qa}from'./chunk-3NSZZCOJ.js';import {g}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  g();var S=class{constructor(r){this.table=r;}static[a]="ColumnAliasProxyHandler";get(r,t){return t==="table"?this.table:r[t]}},C=class{constructor(r,t){this.alias=r,this.replaceOriginalName=t;}static[a]="TableAliasProxyHandler";get(r,t$1){if(t$1===t.Symbol.IsAlias)return true;if(t$1===t.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t$1===t.Symbol.OriginalName)return this.alias;if(t$1===l)return {...r[l],name:this.alias,isAlias:true};if(t$1===t.Symbol.Columns){let o=r[t.Symbol.Columns];if(!o)return o;let a={};return Object.keys(o).map(l=>{a[l]=new Proxy(o[l],new S(new Proxy(r,this)));}),a}let i=r[t$1];return c(i,d)?new Proxy(i,new S(new Proxy(r,this))):i}},j=class{constructor(r){this.alias=r;}static[a]="RelationTableAliasProxyHandler";get(r,t){return t==="sourceTable"?Ne(r.sourceTable,this.alias):r[t]}};function Ne(e,r){return new Proxy(e,new C(r,false))}function ke(e,r){return new Proxy(e,new j(r))}function ge(e,r){return new Proxy(e,new S(new Proxy(e.table,new C(r,false))))}function Te(e,r){return new A.Aliased(H(e.sql,r),e.fieldAlias)}function H(e,r){return J.join(e.queryChunks.map(t=>c(t,d)?ge(t,r):c(t,A)?H(t,r):c(t,A.Aliased)?Te(t,r):t))}g();var M=class{static[a]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(r){return this.then(void 0,r)}finally(r){return this.then(t=>(r?.(),t),t=>{throw r?.(),t})}then(r,t){return this.execute().then(r,t)}};g();var q=class extends Error{static[a]="DrizzleError";constructor({message:r,cause:t}){super(r),this.name="DrizzleError",this.cause=t;}},U=class e extends Error{constructor(r,t,i){super(`Failed query: ${r}
3
3
  params: ${t}`),this.query=r,this.params=t,this.cause=i,Error.captureStackTrace(this,e),i&&(this.cause=i);}},W=class extends q{static[a]="TransactionRollbackError";constructor(){super({message:"Rollback"});}};g();function m(e,r){return D(r)&&!y(e)&&!c(e,H$1)&&!c(e,K$1)&&!c(e,d)&&!c(e,t)&&!c(e,N)?new H$1(e,r):e}var G=(e,r)=>J`${e} = ${m(r,e)}`,X=(e,r)=>J`${e} <> ${m(r,e)}`;function Y(...e){let r=e.filter(t=>t!==void 0);if(r.length!==0)return r.length===1?new A(r):new A([new z("("),J.join(r,new z(" and ")),new z(")")])}function Z(...e){let r=e.filter(t=>t!==void 0);if(r.length!==0)return r.length===1?new A(r):new A([new z("("),J.join(r,new z(" or ")),new z(")")])}function _(e){return J`not ${e}`}var v=(e,r)=>J`${e} > ${m(r,e)}`,ee=(e,r)=>J`${e} >= ${m(r,e)}`,re=(e,r)=>J`${e} < ${m(r,e)}`,te=(e,r)=>J`${e} <= ${m(r,e)}`;function ne(e,r){return Array.isArray(r)?r.length===0?J`false`:J`${e} in ${r.map(t=>m(t,e))}`:J`${e} in ${m(r,e)}`}function ie(e,r){return Array.isArray(r)?r.length===0?J`true`:J`${e} not in ${r.map(t=>m(t,e))}`:J`${e} not in ${m(r,e)}`}function oe(e){return J`${e} is null`}function se(e){return J`${e} is not null`}function ae(e){return J`exists ${e}`}function le(e){return J`not exists ${e}`}function ce(e,r,t){return J`${e} between ${m(r,e)} and ${m(t,e)}`}function ue(e,r,t){return J`${e} not between ${m(r,e)} and ${m(t,e)}`}function fe(e,r){return J`${e} like ${r}`}function me(e,r){return J`${e} not like ${r}`}function he(e,r){return J`${e} ilike ${r}`}function ye(e,r){return J`${e} not ilike ${r}`}function ze(e,r){if(Array.isArray(r)){if(r.length===0)throw new Error("arrayContains requires at least one value");let t=J`${m(r,e)}`;return J`${e} @> ${t}`}return J`${e} @> ${m(r,e)}`}function He(e,r){if(Array.isArray(r)){if(r.length===0)throw new Error("arrayContained requires at least one value");let t=J`${m(r,e)}`;return J`${e} <@ ${t}`}return J`${e} <@ ${m(r,e)}`}function Me(e,r){if(Array.isArray(r)){if(r.length===0)throw new Error("arrayOverlaps requires at least one value");let t=J`${m(r,e)}`;return J`${e} && ${t}`}return J`${e} && ${m(r,e)}`}g();function de(e){return J`${e} asc`}function be(e){return J`${e} desc`}g();g();var O=class{static[a]="PgPrimaryKeyBuilder";columns;name;constructor(r,t){this.columns=r,this.name=t;}build(r){return new R(r,this.columns,this.name)}},R=class{constructor(r,t,i){this.table=r,this.columns=t,this.name=i;}static[a]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[qa.Symbol.Name]}_${this.columns.map(r=>r.name).join("_")}_pk`}};var E=class{constructor(r,t$1,i){this.sourceTable=r,this.referencedTable=t$1,this.relationName=i,this.referencedTableName=t$1[t.Symbol.Name];}static[a]="Relation";referencedTableName;fieldName},K=class{constructor(r,t){this.table=r,this.config=t;}static[a]="Relations"},T=class e extends E{constructor(r,t,i,o){super(r,t,i?.relationName),this.config=i,this.isNullable=o;}static[a]="One";withFieldName(r){let t=new e(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=r,t}},I=class e extends E{constructor(r,t,i){super(r,t,i?.relationName),this.config=i;}static[a]="Many";withFieldName(r){let t=new e(this.sourceTable,this.referencedTable,this.config);return t.fieldName=r,t}};function ar(){return {and:Y,between:ce,eq:G,exists:ae,gt:v,gte:ee,ilike:he,inArray:ne,isNull:oe,isNotNull:se,like:fe,lt:re,lte:te,ne:X,not:_,notBetween:ue,notExists:le,notLike:me,notIlike:ye,notInArray:ie,or:Z,sql:J}}function lr(){return {sql:J,asc:de,desc:be}}function cr(e,r){Object.keys(e).length===1&&"default"in e&&!c(e.default,t)&&(e=e.default);let t$1={},i={},o={};for(let[a,l]of Object.entries(e))if(c(l,t)){let s=w(l),d=i[s];t$1[s]=a,o[a]={tsName:a,dbName:l[t.Symbol.Name],schema:l[t.Symbol.Schema],columns:l[t.Symbol.Columns],relations:d?.relations??{},primaryKey:d?.primaryKey??[]};for(let h of Object.values(l[t.Symbol.Columns]))h.primary&&o[a].primaryKey.push(h);let b=l[t.Symbol.ExtraConfigBuilder]?.(l[t.Symbol.ExtraConfigColumns]);if(b)for(let h of Object.values(b))c(h,O)&&o[a].primaryKey.push(...h.columns);}else if(c(l,K)){let s=w(l.table),d=t$1[s],b=l.config(r(l.table)),h;for(let[A,L]of Object.entries(b))if(d){let B=o[d];B.relations[A]=L;}else s in i||(i[s]={relations:{},primaryKey:h}),i[s].relations[A]=L;}return {tables:o,tableNamesMap:t$1}}function ur(e,r){return new K(e,t=>Object.fromEntries(Object.entries(r(t)).map(([i,o])=>[i,o.withFieldName(i)])))}function xe(e){return function(t,i){return new T(e,t,i,i?.fields.reduce((o,a)=>o&&a.notNull,true)??false)}}function Se(e){return function(t,i){return new I(e,t,i)}}function fr(e,r,t$1){if(c(t$1,T)&&t$1.config)return {fields:t$1.config.fields,references:t$1.config.references};let i=r[w(t$1.referencedTable)];if(!i)throw new Error(`Table "${t$1.referencedTable[t.Symbol.Name]}" not found in schema`);let o=e[i];if(!o)throw new Error(`Table "${i}" not found in schema`);let a=t$1.sourceTable,l=r[w(a)];if(!l)throw new Error(`Table "${a[t.Symbol.Name]}" not found in schema`);let s=[];for(let d of Object.values(o.relations))(t$1.relationName&&t$1!==d&&d.relationName===t$1.relationName||!t$1.relationName&&d.referencedTable===t$1.sourceTable)&&s.push(d);if(s.length>1)throw t$1.relationName?new Error(`There are multiple relations with name "${t$1.relationName}" in table "${i}"`):new Error(`There are multiple relations between "${i}" and "${t$1.sourceTable[t.Symbol.Name]}". Please specify relation name`);if(s[0]&&c(s[0],T)&&s[0].config)return {fields:s[0].config.references,references:s[0].config.fields};throw new Error(`There is not enough information to infer relation "${l}.${t$1.fieldName}"`)}function mr(e){return {one:xe(e),many:Se(e)}}function we(e,r,t,i,o=a=>a){let a={};for(let[l,s]of i.entries())if(s.isJson){let d=r.relations[s.tsKey],b=t[l],h=typeof b=="string"?JSON.parse(b):b;a[s.tsKey]=c(d,T)?h&&we(e,e[s.relationTableTsKey],h,s.selection,o):h.map(A=>we(e,e[s.relationTableTsKey],A,s.selection,o));}else {let d$1=o(t[l]),b=s.field,h;c(b,d)?h=b:c(b,A)?h=b.decoder:h=b.sql.decoder,a[s.tsKey]=d$1===null?null:h.mapFromDriverValue(d$1);}return a}g();var Q=class{static[a]="ConsoleLogWriter";write(r){console.log(r);}},$e=class{static[a]="DefaultLogger";writer;constructor(r){this.writer=r?.writer??new Q;}logQuery(r,t){let i=t.map(a=>{try{return JSON.stringify(a)}catch{return String(a)}}),o=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${r}${o}`);}},pe=class{static[a]="NoopLogger";logQuery(){}};export{$e as $,ae as A,le as B,ce as C,ue as D,fe as E,me as F,he as G,ye as H,ze as I,He as J,Me as K,de as L,be as M,E as N,K as O,T as P,I as Q,ar as R,lr as S,cr as T,ur as U,xe as V,Se as W,fr as X,mr as Y,we as Z,Q as _,S as a,pe as aa,C as b,j as c,Ne as d,ke as e,ge as f,Te as g,H as h,M as i,q as j,U as k,W as l,m,G as n,X as o,Y as p,Z as q,_ as r,v as s,ee as t,re as u,te as v,ne as w,ie as x,oe as y,se as z};
@@ -1,3 +1,3 @@
1
- import {createRequire}from'module';import {b,a}from'./chunk-SYEP5QLG.js';import {g as g$1}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
1
+ import {b,a}from'./chunk-YUUXFD73.js';import {g as g$1}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  g$1();g$1();g$1();var l="X-Amz-S3session-Token",m=l.toLowerCase(),g=class extends a{async signWithCredentials(e,i,r){let t=v(i);e.headers[m]=i.sessionToken;let a=this;return w(a,t),a.signRequest(e,r??{})}async presignWithCredentials(e,i,r){let t=v(i);return delete e.headers[m],e.headers[l]=i.sessionToken,e.query=e.query??{},e.query[l]=i.sessionToken,w(this,t),this.presign(e,r)}};function v(n){return {accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,expiration:n.expiration}}function w(n,e){let i=n.credentialProvider;n.credentialProvider=()=>(n.credentialProvider=i,Promise.resolve(e));}var p=class{sigv4aSigner;sigv4Signer;signerOptions;static sigv4aDependency(){return typeof b.SignatureV4a=="function"?"js":"none"}constructor(e){this.sigv4Signer=new g(e),this.signerOptions=e;}async sign(e,i={}){return i.signingRegion==="*"?this.getSigv4aSigner().sign(e,i):this.sigv4Signer.sign(e,i)}async signWithCredentials(e,i,r={}){if(r.signingRegion==="*"){this.getSigv4aSigner();throw new Error(`signWithCredentials with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`)}return this.sigv4Signer.signWithCredentials(e,i,r)}async presign(e,i={}){if(i.signingRegion==="*"){this.getSigv4aSigner();throw new Error(`presign with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`)}return this.sigv4Signer.presign(e,i)}async presignWithCredentials(e,i,r={}){if(r.signingRegion==="*")throw new Error("Method presignWithCredentials is not supported for [signingRegion=*].");return this.sigv4Signer.presignWithCredentials(e,i,r)}getSigv4aSigner(){if(!this.sigv4aSigner){let i=b.SignatureV4a;if(this.signerOptions.runtime==="node"){if(!i)throw new Error("Neither CRT nor JS SigV4a implementation is available. Please load either @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt");if(i&&typeof i=="function")this.sigv4aSigner=new i({...this.signerOptions});else throw new Error("Available SigV4a implementation is not a valid constructor. Please ensure you've properly imported @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a.For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt")}else {if(!i||typeof i!="function")throw new Error("JS SigV4a implementation is not available or not a valid constructor. Please check whether you have installed the @aws-sdk/signature-v4a package explicitly. The CRT implementation is not available for browsers. You must also register the package by calling [require('@aws-sdk/signature-v4a');] or an ESM equivalent such as [import '@aws-sdk/signature-v4a';]. For more information please go to https://github.com/aws/aws-sdk-js-v3#using-javascript-non-crt-implementation-of-sigv4a");this.sigv4aSigner=new i({...this.signerOptions});}}return this.sigv4aSigner}};g$1();
3
3
  export{p as a};
@@ -1,4 +1,4 @@
1
- import {createRequire}from'module';import {a as a$3}from'./chunk-R3NEPC4I.js';import {a as a$2}from'./chunk-IPXOY4RI.js';import {a as a$4,i as i$1}from'./chunk-JUJZOG6P.js';import {r as r$1,p as p$1,n as n$1,c as c$2,q as q$1,o as o$1,J as J$1,b as b$3,a as a$5,F as F$2,D as D$1,C as C$2,e as e$3,H as H$2,x as x$1,d as d$4,y as y$2,k as k$1,f as f$4,A as A$1,j as j$1,z as z$2,u as u$1,v as v$1,w as w$1,g as g$5,E as E$1,B as B$1,t as t$1,s as s$1,m as m$1,i as i$2,l as l$1,h as h$1}from'./chunk-7T35572E.js';import {wa as wa$1,a as a$1,ua as ua$1,Aa as Aa$1,ra as ra$1,Da as Da$1,Na as Na$1,qa as qa$1,ka as ka$1,za as za$1,i,Ga as Ga$1,Ea as Ea$1,f as f$1,Ma as Ma$1,Qa as Qa$1,Ra,Sa as Sa$1,Oa as Oa$1,Ta as Ta$1,Ua as Ua$1,b as b$1,ya as ya$1,la as la$1,Pa as Pa$1,sa as sa$1,va as va$1,La as La$1,ma as ma$1,Fa as Fa$1,k,Ja as Ja$1,Ia as Ia$1,ha as ha$1,t,s,u,r,Ca as Ca$1,ja as ja$1,d as d$1,j,Ha as Ha$1,Ka as Ka$1,Ba as Ba$1,h,w,pa as pa$1,ga as ga$1,Va as Va$1,oa as oa$1,na as na$1,xa as xa$1,ta as ta$1,m,I,G as G$1,L,D,v,O,Y,C as C$1,x,R,P,fa as fa$1,X,ea as ea$1,c as c$1,Z,K,y as y$1,_,E,H as H$1,W,ba as ba$1,Q as Q$1,U,T,e,N as N$1,S,ia as ia$1,g as g$1,V,M as M$1,$,B,aa as aa$1,da as da$1,A,z as z$1,J,F as F$1,n,q,Wa as Wa$1,o,l,p,ca as ca$1,Xa as Xa$1,Ya as Ya$1,$a as $a$1,qb}from'./chunk-FYPEL7XW.js';import {o as o$2,f as f$2,g as g$3}from'./chunk-NWCREF47.js';import {d as d$2,e as e$2,f as f$3,g as g$4}from'./chunk-E27KEZPT.js';import {b as b$2,d as d$3}from'./chunk-6MSS5X77.js';import {c as c$3}from'./chunk-ZJE3VAAW.js';import {g as g$2}from'./chunk-VIUU4D5I.js';import {c,g,b,d,a,f,e as e$1}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
1
+ import {a as a$3}from'./chunk-LWM4WABU.js';import {a as a$2}from'./chunk-SQBTIMWF.js';import {a as a$4,i as i$1}from'./chunk-PA4ZZREG.js';import {r as r$1,p as p$1,n as n$1,c as c$2,q as q$1,o as o$1,J as J$1,b as b$3,a as a$5,F as F$2,D as D$1,C as C$2,e as e$3,H as H$2,x as x$1,d as d$4,y as y$2,k as k$1,f as f$4,A as A$1,j as j$1,z as z$2,u as u$1,v as v$1,w as w$1,g as g$5,E as E$1,B as B$1,t as t$1,s as s$1,m as m$1,i as i$2,l as l$1,h as h$1}from'./chunk-ZMG7Z3KF.js';import {wa as wa$1,a as a$1,ua as ua$1,Aa as Aa$1,ra as ra$1,Da as Da$1,Na as Na$1,qa as qa$1,ka as ka$1,za as za$1,i,Ga as Ga$1,Ea as Ea$1,f as f$1,Ma as Ma$1,Qa as Qa$1,Ra,Sa as Sa$1,Oa as Oa$1,Ta as Ta$1,Ua as Ua$1,b as b$1,ya as ya$1,la as la$1,Pa as Pa$1,sa as sa$1,va as va$1,La as La$1,ma as ma$1,Fa as Fa$1,k,Ja as Ja$1,Ia as Ia$1,ha as ha$1,t,s,u,r,Ca as Ca$1,ja as ja$1,d as d$1,j,Ha as Ha$1,Ka as Ka$1,Ba as Ba$1,h,w,pa as pa$1,ga as ga$1,Va as Va$1,oa as oa$1,na as na$1,xa as xa$1,ta as ta$1,m,I,G as G$1,L,D,v,O,Y,C as C$1,x,R,P,fa as fa$1,X,ea as ea$1,c as c$1,Z,K,y as y$1,_,E,H as H$1,W,ba as ba$1,Q as Q$1,U,T,e,N as N$1,S,ia as ia$1,g as g$1,V,M as M$1,$,B,aa as aa$1,da as da$1,A,z as z$1,J,F as F$1,n,q,Wa as Wa$1,o,l,p,ca as ca$1,Xa as Xa$1,Ya as Ya$1,$a as $a$1,ib}from'./chunk-EFGOYI57.js';import {o as o$2,f as f$2,g as g$3}from'./chunk-YZEMLLD2.js';import {d as d$2,e as e$2,f as f$3,g as g$4}from'./chunk-RTHJ6SS5.js';import {b as b$2,d as d$3}from'./chunk-5M3FKE2V.js';import {c as c$3}from'./chunk-BU6O3TP7.js';import {g as g$2}from'./chunk-47CXBWMA.js';import {c,g,b,d,a,f,e as e$1}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  var ms=c((fw,Ra)=>{g();function Rp(){return Object.keys(globalThis).some(t=>t.startsWith("__NEXT"))}Ra.exports=function(){return !!(globalThis.Deno||globalThis.Bun||Rp())};});function Aa(t,e){return (e?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(t)}function _s(t,e=false){let r=[],n=0;for(;n<t.length;){let s=t[n],i=F(function(o){if(!e)throw new TypeError(o);r.push({type:"INVALID_CHAR",index:n,value:t[n++]});},"ErrorOrInvalid");if(s==="*"){r.push({type:"ASTERISK",index:n,value:t[n++]});continue}if(s==="+"||s==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:t[n++]});continue}if(s==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:t[n++]});continue}if(s==="{"){r.push({type:"OPEN",index:n,value:t[n++]});continue}if(s==="}"){r.push({type:"CLOSE",index:n,value:t[n++]});continue}if(s===":"){let o="",a=n+1;for(;a<t.length;){let c=t.substr(a,1);if(a===n+1&&Lp.test(c)||a!==n+1&&Op.test(c)){o+=t[a++];continue}break}if(!o){i(`Missing parameter name at ${n}`);continue}r.push({type:"NAME",index:n,value:o}),n=a;continue}if(s==="("){let o=1,a="",c=n+1,l=false;if(t[c]==="?"){i(`Pattern cannot start with "?" at ${c}`);continue}for(;c<t.length;){if(!Aa(t[c],false)){i(`Invalid character '${t[c]}' at ${c}.`),l=true;break}if(t[c]==="\\"){a+=t[c++]+t[c++];continue}if(t[c]===")"){if(o--,o===0){c++;break}}else if(t[c]==="("&&(o++,t[c+1]!=="?")){i(`Capturing groups are not allowed at ${c}`),l=true;break}a+=t[c++];}if(l)continue;if(o){i(`Unbalanced pattern at ${n}`);continue}if(!a){i(`Missing pattern at ${n}`);continue}r.push({type:"REGEX",index:n,value:a}),n=c;continue}r.push({type:"CHAR",index:n,value:t[n++]});}return r.push({type:"END",index:n,value:""}),r}function ws(t,e={}){let r=_s(t);e.delimiter??="/#?",e.prefixes??="./";let n=`[^${me(e.delimiter)}]+?`,s=[],i=0,o=0,c=new Set,l=F(P=>{if(o<r.length&&r[o].type===P)return r[o++].value},"tryConsume"),u=F(()=>l("OTHER_MODIFIER")??l("ASTERISK"),"tryConsumeModifier"),h=F(P=>{let k=l(P);if(k!==void 0)return k;let{type:S,index:v}=r[o];throw new TypeError(`Unexpected ${S} at ${v}, expected ${P}`)},"mustConsume"),d=F(()=>{let P="",k;for(;k=l("CHAR")??l("ESCAPED_CHAR");)P+=k;return P},"consumeText"),p=F(P=>P,"DefaultEncodePart"),_=e.encodePart||p,E="",A=F(P=>{E+=P;},"appendToPendingFixedValue"),R=F(()=>{E.length&&(s.push(new wt(3,"","",_(E),"",3)),E="");},"maybeAddPartFromPendingFixedValue"),j=F((P,k,S,v,O)=>{let g=3;switch(O){case "?":g=1;break;case "*":g=0;break;case "+":g=2;break}if(!k&&!S&&g===3){A(P);return}if(R(),!k&&!S){if(!P)return;s.push(new wt(3,"","",_(P),"",g));return}let x;S?S==="*"?x=ys:x=S:x=n;let w=2;x===n?(w=1,x=""):x===ys&&(w=0,x="");let T;if(k?T=k:S&&(T=i++),c.has(T))throw new TypeError(`Duplicate name '${T}'.`);c.add(T),s.push(new wt(w,T,_(P),x,_(v),g));},"addPart");for(;o<r.length;){let P=l("CHAR"),k=l("NAME"),S=l("REGEX");if(!k&&!S&&(S=l("ASTERISK")),k||S){let O=P??"";e.prefixes.indexOf(O)===-1&&(A(O),O=""),R();let g=u();j(O,k,S,"",g);continue}let v=P??l("ESCAPED_CHAR");if(v){A(v);continue}if(l("OPEN")){let O=d(),g=l("NAME"),x=l("REGEX");!g&&!x&&(x=l("ASTERISK"));let w=d();h("CLOSE");let T=u();j(O,g,x,w,T);continue}R(),h("END");}return s}function me(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function gs(t){return t&&t.ignoreCase?"ui":"u"}function La(t,e,r){return Ss(ws(t,r),e,r)}function tt(t){switch(t){case 0:return "*";case 1:return "?";case 2:return "+";case 3:return ""}}function Ss(t,e,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=false,r.strict??=false,r.end??=true,r.start??=true,r.endsWith="";let n=r.start?"^":"";for(let a of t){if(a.type===3){a.modifier===3?n+=me(a.value):n+=`(?:${me(a.value)})${tt(a.modifier)}`;continue}e&&e.push(a.name);let c=`[^${me(r.delimiter)}]+?`,l=a.value;if(a.type===1?l=c:a.type===0&&(l=ys),!a.prefix.length&&!a.suffix.length){a.modifier===3||a.modifier===1?n+=`(${l})${tt(a.modifier)}`:n+=`((?:${l})${tt(a.modifier)})`;continue}if(a.modifier===3||a.modifier===1){n+=`(?:${me(a.prefix)}(${l})${me(a.suffix)})`,n+=tt(a.modifier);continue}n+=`(?:${me(a.prefix)}`,n+=`((?:${l})(?:`,n+=me(a.suffix),n+=me(a.prefix),n+=`(?:${l}))*)${me(a.suffix)})`,a.modifier===0&&(n+="?");}let s=`[${me(r.endsWith)}]|$`,i=`[${me(r.delimiter)}]`;if(r.end)return r.strict||(n+=`${i}?`),r.endsWith.length?n+=`(?=${s})`:n+="$",new RegExp(n,gs(r));r.strict||(n+=`(?:${i}(?=${s}))?`);let o=false;if(t.length){let a=t[t.length-1];a.type===3&&a.modifier===3&&(o=r.delimiter.indexOf(a)>-1);}return o||(n+=`(?=${i}|${s})`),new RegExp(n,gs(r))}function Oa(t,e){return t.length?t[0]==="/"?true:!e||t.length<2?false:(t[0]=="\\"||t[0]=="{")&&t[1]=="/":false}function Es(t,e){return t.startsWith(e)?t.substring(e.length,t.length):t}function Fa(t,e){return t.endsWith(e)?t.substr(0,t.length-e.length):t}function Ps(t){return !t||t.length<2?false:t[0]==="["||(t[0]==="\\"||t[0]==="{")&&t[1]==="["}function vs(t){if(!t)return true;for(let e of Ia)if(t.test(e))return true;return false}function Da(t,e){if(t=Es(t,"#"),e||t==="")return t;let r=new URL("https://example.com");return r.hash=t,r.hash?r.hash.substring(1,r.hash.length):""}function ja(t,e){if(t=Es(t,"?"),e||t==="")return t;let r=new URL("https://example.com");return r.search=t,r.search?r.search.substring(1,r.search.length):""}function qa(t,e){return e||t===""?t:Ps(t)?Cs(t):ks(t)}function Ua(t,e){if(e||t==="")return t;let r=new URL("https://example.com");return r.password=t,r.password}function Ma(t,e){if(e||t==="")return t;let r=new URL("https://example.com");return r.username=t,r.username}function Ba(t,e,r){if(r||t==="")return t;if(e&&!Ia.includes(e))return new URL(`${e}:${t}`).pathname;let n=t[0]=="/";return t=new URL(n?t:"/-"+t,"https://example.com").pathname,n||(t=t.substring(2,t.length)),t}function $a(t,e,r){return Ts(e)===t&&(t=""),r||t===""?t:Rs(t)}function Na(t,e){return t=Fa(t,":"),e||t===""?t:Ar(t)}function Ts(t){switch(t){case "ws":case "http":return "80";case "wws":case "https":return "443";case "ftp":return "21";default:return ""}}function Ar(t){if(t==="")return t;if(/^[-+.A-Za-z0-9]*$/.test(t))return t.toLowerCase();throw new TypeError(`Invalid protocol '${t}'.`)}function Ga(t){if(t==="")return t;let e=new URL("https://example.com");return e.username=t,e.username}function Ha(t){if(t==="")return t;let e=new URL("https://example.com");return e.password=t,e.password}function ks(t){if(t==="")return t;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(t))throw new TypeError(`Invalid hostname '${t}'`);let e=new URL("https://example.com");return e.hostname=t,e.hostname}function Cs(t){if(t==="")return t;if(/[^0-9a-fA-F[\]:]/g.test(t))throw new TypeError(`Invalid IPv6 hostname '${t}'`);return t.toLowerCase()}function Rs(t){if(t===""||/^[0-9]*$/.test(t)&&parseInt(t)<=65535)return t;throw new TypeError(`Invalid port '${t}'.`)}function za(t){if(t==="")return t;let e=new URL("https://example.com");return e.pathname=t[0]!=="/"?"/-"+t:t,t[0]!=="/"?e.pathname.substring(2,e.pathname.length):e.pathname}function Va(t){return t===""?t:new URL(`data:${t}`).pathname}function Wa(t){if(t==="")return t;let e=new URL("https://example.com");return e.search=t,e.search.substring(1,e.search.length)}function Ka(t){if(t==="")return t;let e=new URL("https://example.com");return e.hash=t,e.hash.substring(1,e.hash.length)}function xs(t,e){if(typeof t!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(t,e);return {protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function Te(t,e){return e?_t(t):t}function xt(t,e,r){let n;if(typeof e.baseURL=="string")try{n=new URL(e.baseURL),e.protocol===void 0&&(t.protocol=Te(n.protocol.substring(0,n.protocol.length-1),r)),!r&&e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.username===void 0&&(t.username=Te(n.username,r)),!r&&e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.username===void 0&&e.password===void 0&&(t.password=Te(n.password,r)),e.protocol===void 0&&e.hostname===void 0&&(t.hostname=Te(n.hostname,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&(t.port=Te(n.port,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&(t.pathname=Te(n.pathname,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&e.search===void 0&&(t.search=Te(n.search.substring(1,n.search.length),r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&e.search===void 0&&e.hash===void 0&&(t.hash=Te(n.hash.substring(1,n.hash.length),r));}catch{throw new TypeError(`invalid baseURL '${e.baseURL}'.`)}if(typeof e.protocol=="string"&&(t.protocol=Na(e.protocol,r)),typeof e.username=="string"&&(t.username=Ma(e.username,r)),typeof e.password=="string"&&(t.password=Ua(e.password,r)),typeof e.hostname=="string"&&(t.hostname=qa(e.hostname,r)),typeof e.port=="string"&&(t.port=$a(e.port,t.protocol,r)),typeof e.pathname=="string"){if(t.pathname=e.pathname,n&&!Oa(t.pathname,r)){let s=n.pathname.lastIndexOf("/");s>=0&&(t.pathname=Te(n.pathname.substring(0,s+1),r)+t.pathname);}t.pathname=Ba(t.pathname,t.protocol,r);}return typeof e.search=="string"&&(t.search=ja(e.search,r)),typeof e.hash=="string"&&(t.hash=Da(e.hash,r)),t}function _t(t){return t.replace(/([+*?:{}()\\])/g,"\\$1")}function Za(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function Ja(t,e){e.delimiter??="/#?",e.prefixes??="./",e.sensitive??=false,e.strict??=false,e.end??=true,e.start??=true,e.endsWith="";let r=".*",n=`[^${Za(e.delimiter)}]+?`,s=/[$_\u200C\u200D\p{ID_Continue}]/u,i="";for(let o=0;o<t.length;++o){let a=t[o];if(a.type===3){if(a.modifier===3){i+=_t(a.value);continue}i+=`{${_t(a.value)}}${tt(a.modifier)}`;continue}let c=a.hasCustomName(),l=!!a.suffix.length||!!a.prefix.length&&(a.prefix.length!==1||!e.prefixes.includes(a.prefix)),u=o>0?t[o-1]:null,h=o<t.length-1?t[o+1]:null;if(!l&&c&&a.type===1&&a.modifier===3&&h&&!h.prefix.length&&!h.suffix.length)if(h.type===3){let d=h.value.length>0?h.value[0]:"";l=s.test(d);}else l=!h.hasCustomName();if(!l&&!a.prefix.length&&u&&u.type===3){let d=u.value[u.value.length-1];l=e.prefixes.includes(d);}l&&(i+="{"),i+=_t(a.prefix),c&&(i+=`:${a.name}`),a.type===2?i+=`(${a.value})`:a.type===1?c||(i+=`(${n})`):a.type===0&&(!c&&(!u||u.type===3||u.modifier!==3||l||a.prefix!=="")?i+="*":i+=`(${r})`),a.type===1&&c&&a.suffix.length&&s.test(a.suffix[0])&&(i+="\\"),i+=_t(a.suffix),l&&(i+="}"),a.modifier!==3&&(i+=tt(a.modifier));}return i}var Ap,F,wt,Lp,Op,ys,He,Fp,Ip,Ia,Qa,bs,Ge,Lr,Ya=b(()=>{g();Ap=Object.defineProperty,F=(t,e)=>Ap(t,"name",{value:e,configurable:true}),wt=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(t,e,r,n,s,i){this.type=t,this.name=e,this.prefix=r,this.value=n,this.suffix=s,this.modifier=i;}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};F(wt,"Part");Lp=/[$_\p{ID_Start}]/u,Op=/[$_\u200C\u200D\p{ID_Continue}]/u,ys=".*";F(Aa,"isASCII");F(_s,"lexer");F(ws,"parse");F(me,"escapeString");F(gs,"flags");F(La,"stringToRegexp");F(tt,"modifierToString");F(Ss,"partsToRegexp");He={delimiter:"",prefixes:"",sensitive:true,strict:true},Fp={delimiter:".",prefixes:"",sensitive:true,strict:true},Ip={delimiter:"/",prefixes:"/",sensitive:true,strict:true};F(Oa,"isAbsolutePathname");F(Es,"maybeStripPrefix");F(Fa,"maybeStripSuffix");F(Ps,"treatAsIPv6Hostname");Ia=["ftp","file","http","https","ws","wss"];F(vs,"isSpecialScheme");F(Da,"canonicalizeHash");F(ja,"canonicalizeSearch");F(qa,"canonicalizeHostname");F(Ua,"canonicalizePassword");F(Ma,"canonicalizeUsername");F(Ba,"canonicalizePathname");F($a,"canonicalizePort");F(Na,"canonicalizeProtocol");F(Ts,"defaultPortForProtocol");F(Ar,"protocolEncodeCallback");F(Ga,"usernameEncodeCallback");F(Ha,"passwordEncodeCallback");F(ks,"hostnameEncodeCallback");F(Cs,"ipv6HostnameEncodeCallback");F(Rs,"portEncodeCallback");F(za,"standardURLPathnameEncodeCallback");F(Va,"pathURLPathnameEncodeCallback");F(Wa,"searchEncodeCallback");F(Ka,"hashEncodeCallback");Qa=class{#o;#r=[];#n={};#t=0;#p=1;#w=0;#s=0;#y=0;#l=0;#i=false;constructor(t){this.#o=t;}get result(){return this.#n}parse(){for(this.#r=_s(this.#o,true);this.#t<this.#r.length;this.#t+=this.#p){if(this.#p=1,this.#r[this.#t].type==="END"){if(this.#s===0){this.#b(),this.#T()?this.#e(9,1):this.#d()?this.#e(8,1):this.#e(7,0);continue}else if(this.#s===2){this.#f(5);continue}this.#e(10,0);break}if(this.#y>0)if(this.#k())this.#y-=1;else continue;if(this.#L()){this.#y+=1;continue}switch(this.#s){case 0:this.#h()&&this.#f(1);break;case 1:if(this.#h()){this.#O();let t=7,e=1;this.#E()?(t=2,e=3):this.#i&&(t=2),this.#e(t,e);}break;case 2:this.#g()?this.#f(3):(this.#v()||this.#d()||this.#T())&&this.#f(5);break;case 3:this.#x()?this.#e(4,1):this.#g()&&this.#e(5,1);break;case 4:this.#g()&&this.#e(5,1);break;case 5:this.#F()?this.#l+=1:this.#_()&&(this.#l-=1),this.#P()&&!this.#l?this.#e(6,1):this.#v()?this.#e(7,0):this.#d()?this.#e(8,1):this.#T()&&this.#e(9,1);break;case 6:this.#v()?this.#e(7,0):this.#d()?this.#e(8,1):this.#T()&&this.#e(9,1);break;case 7:this.#d()?this.#e(8,1):this.#T()&&this.#e(9,1);break;case 8:this.#T()&&this.#e(9,1);break;}}this.#n.hostname!==void 0&&this.#n.port===void 0&&(this.#n.port="");}#e(t,e){switch(this.#s){case 0:break;case 1:this.#n.protocol=this.#S();break;case 2:break;case 3:this.#n.username=this.#S();break;case 4:this.#n.password=this.#S();break;case 5:this.#n.hostname=this.#S();break;case 6:this.#n.port=this.#S();break;case 7:this.#n.pathname=this.#S();break;case 8:this.#n.search=this.#S();break;case 9:this.#n.hash=this.#S();break;}this.#s!==0&&t!==10&&([1,2,3,4].includes(this.#s)&&[6,7,8,9].includes(t)&&(this.#n.hostname??=""),[1,2,3,4,5,6].includes(this.#s)&&[8,9].includes(t)&&(this.#n.pathname??=this.#i?"/":""),[1,2,3,4,5,6,7].includes(this.#s)&&t===9&&(this.#n.search??="")),this.#m(t,e);}#m(t,e){this.#s=t,this.#w=this.#t+e,this.#t+=e,this.#p=0;}#b(){this.#t=this.#w,this.#p=0;}#f(t){this.#b(),this.#s=t;}#u(t){return t<0&&(t=this.#r.length-t),t<this.#r.length?this.#r[t]:this.#r[this.#r.length-1]}#c(t,e){let r=this.#u(t);return r.value===e&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#h(){return this.#c(this.#t,":")}#E(){return this.#c(this.#t+1,"/")&&this.#c(this.#t+2,"/")}#g(){return this.#c(this.#t,"@")}#x(){return this.#c(this.#t,":")}#P(){return this.#c(this.#t,":")}#v(){return this.#c(this.#t,"/")}#d(){if(this.#c(this.#t,"?"))return true;if(this.#r[this.#t].value!=="?")return false;let t=this.#u(this.#t-1);return t.type!=="NAME"&&t.type!=="REGEX"&&t.type!=="CLOSE"&&t.type!=="ASTERISK"}#T(){return this.#c(this.#t,"#")}#L(){return this.#r[this.#t].type=="OPEN"}#k(){return this.#r[this.#t].type=="CLOSE"}#F(){return this.#c(this.#t,"[")}#_(){return this.#c(this.#t,"]")}#S(){let t=this.#r[this.#t],e=this.#u(this.#w).index;return this.#o.substring(e,t.index)}#O(){let t={};Object.assign(t,He),t.encodePart=Ar;let e=La(this.#S(),void 0,t);this.#i=vs(e);}};F(Qa,"Parser");bs=["protocol","username","password","hostname","port","pathname","search","hash"],Ge="*";F(xs,"extractValues");F(Te,"processBaseURLString");F(xt,"applyInit");F(_t,"escapePatternString");F(Za,"escapeRegexpString");F(Ja,"partsToPattern");Lr=class{#o;#r={};#n={};#t={};#p={};#w=false;constructor(t={},e,r){try{let n;if(typeof e=="string"?n=e:r=e,typeof t=="string"){let a=new Qa(t);if(a.parse(),t=a.result,n===void 0&&typeof t.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");t.baseURL=n;}else {if(!t||typeof t!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let s={ignoreCase:r.ignoreCase===!0},i={pathname:Ge,protocol:Ge,username:Ge,password:Ge,hostname:Ge,port:Ge,search:Ge,hash:Ge};this.#o=xt(i,t,!0),Ts(this.#o.protocol)===this.#o.port&&(this.#o.port="");let o;for(o of bs){if(!(o in this.#o))continue;let a={},c=this.#o[o];switch(this.#n[o]=[],o){case "protocol":Object.assign(a,He),a.encodePart=Ar;break;case "username":Object.assign(a,He),a.encodePart=Ga;break;case "password":Object.assign(a,He),a.encodePart=Ha;break;case "hostname":Object.assign(a,Fp),Ps(c)?a.encodePart=Cs:a.encodePart=ks;break;case "port":Object.assign(a,He),a.encodePart=Rs;break;case "pathname":vs(this.#r.protocol)?(Object.assign(a,Ip,s),a.encodePart=za):(Object.assign(a,He,s),a.encodePart=Va);break;case "search":Object.assign(a,He,s),a.encodePart=Wa;break;case "hash":Object.assign(a,He,s),a.encodePart=Ka;break}try{this.#p[o]=ws(c,a),this.#r[o]=Ss(this.#p[o],this.#n[o],a),this.#t[o]=Ja(this.#p[o],a),this.#w=this.#w||this.#p[o].some(l=>l.type===2);}catch{throw new TypeError(`invalid ${o} pattern '${this.#o[o]}'.`)}}}catch(n){throw new TypeError(`Failed to construct 'URLPattern': ${n.message}`)}}get[Symbol.toStringTag](){return "URLPattern"}test(t={},e){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return false;try{typeof t=="object"?r=xt(r,t,!1):r=xt(r,xs(t,e),!1);}catch{return false}let n;for(n of bs)if(!this.#r[n].exec(r[n]))return false;return true}exec(t={},e){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return;try{typeof t=="object"?r=xt(r,t,!1):r=xt(r,xs(t,e),!1);}catch{return null}let n={};e?n.inputs=[t,e]:n.inputs=[t];let s;for(s of bs){let i=this.#r[s].exec(r[s]);if(!i)return null;let o={};for(let[a,c]of this.#n[s].entries())if(typeof c=="string"||typeof c=="number"){let l=i[a+1];o[c]=l;}n[s]={input:r[s]??"",groups:o};}return n}static compareComponent(t,e,r){let n=F((a,c)=>{for(let l of ["type","modifier","prefix","value","suffix"]){if(a[l]<c[l])return -1;if(a[l]!==c[l])return 1}return 0},"comparePart"),s=new wt(3,"","","","",3),i=new wt(0,"","","","",3),o=F((a,c)=>{let l=0;for(;l<Math.min(a.length,c.length);++l){let u=n(a[l],c[l]);if(u)return u}return a.length===c.length?0:n(a[l]??s,c[l]??s)},"comparePartList");return !e.#t[t]&&!r.#t[t]?0:e.#t[t]&&!r.#t[t]?o(e.#p[t],[i]):!e.#t[t]&&r.#t[t]?o([i],r.#p[t]):o(e.#p[t],r.#p[t])}get protocol(){return this.#t.protocol}get username(){return this.#t.username}get password(){return this.#t.password}get hostname(){return this.#t.hostname}get port(){return this.#t.port}get pathname(){return this.#t.pathname}get search(){return this.#t.search}get hash(){return this.#t.hash}get hasRegExpGroups(){return this.#w}};F(Lr,"URLPattern");});var Xa={};d(Xa,{URLPattern:()=>Lr});var el=b(()=>{g();Ya();globalThis.URLPattern||(globalThis.URLPattern=Lr);});var Ve=c(de=>{g();Object.defineProperty(de,"__esModule",{value:true});de.isPromise=Or;de.isActualPromise=rl;de.handleMaybePromise=ze;de.fakePromise=ke;de.createDeferredPromise=Dp;de.iterateAsync=nl;de.iterateAsyncVoid=nl;de.fakeRejectPromise=rt;de.mapMaybePromise=jp;de.mapAsyncIterator=qp;de.promiseLikeFinally=sl;de.unfakePromise=il;var Fr=Symbol.for("@whatwg-node/promise-helpers/FakePromise");function Or(t){return t?.then!=null}function rl(t){let e=t;return e&&e.then&&e.catch&&e.finally}function ze(t,e,r,n){let s=ke().then(t).then(e,r);return n&&(s=s.finally(n)),il(s)}function ke(t){return t&&rl(t)?t:Or(t)?{then:(e,r)=>ke(t.then(e,r)),catch:e=>ke(t.then(r=>r,e)),finally:e=>ke(e?sl(t,e):t),[Symbol.toStringTag]:"Promise"}:{then(e){if(e)try{return ke(e(t))}catch(r){return rt(r)}return this},catch(){return this},finally(e){if(e)try{return ke(e()).then(()=>t,()=>t)}catch(r){return rt(r)}return this},[Symbol.toStringTag]:"Promise",__fakePromiseValue:t,[Fr]:"resolved"}}function Dp(){if(Promise.withResolvers)return Promise.withResolvers();let t,e;return {promise:new Promise(function(s,i){t=s,e=i;}),get resolve(){return t},get reject(){return e}}}function nl(t,e,r){if(t?.length===0)return;let n=t[Symbol.iterator](),s=0;function i(){let{done:o,value:a}=n.next();if(o)return;let c=false;function l(){c=true;}return ze(function(){return e(a,l,s++)},function(h){if(h&&r?.push(h),!c)return i()})}return i()}function rt(t){return {then(e,r){if(r)try{return ke(r(t))}catch(n){return rt(n)}return this},catch(e){if(e)try{return ke(e(t))}catch(r){return rt(r)}return this},finally(e){if(e)try{e();}catch(r){return rt(r)}return this},__fakeRejectError:t,[Symbol.toStringTag]:"Promise",[Fr]:"rejected"}}function jp(t,e,r){return ze(()=>t,e,r)}function qp(t,e,r,n){Symbol.asyncIterator in t&&(t=t[Symbol.asyncIterator]());let s,i,o;if(n){let l;o=u=>(l||=ze(n,()=>u,()=>u),l);}typeof t.return=="function"&&(s=t.return,i=l=>{let u=()=>{throw l};return s.call(t).then(u,u)});function a(l){return l.done?o?o(l):l:ze(()=>l.value,u=>ze(()=>e(u),tl,i))}let c;if(r){let l,u=r;c=h=>(l||=ze(()=>h,d=>ze(()=>u(d),tl,i)),l);}return {next(){return t.next().then(a,c)},return(){let l=s?s.call(t).then(a,c):ke({value:void 0,done:true});return o?l.then(o):l},throw(l){return typeof t.throw=="function"?t.throw(l).then(a,c):i?i(l):rt(l)},[Symbol.asyncIterator](){return this}}}function tl(t){return {value:t,done:false}}function Up(t){return t?.[Fr]==="resolved"}function Mp(t){return t?.[Fr]==="rejected"}function sl(t,e){return "finally"in t?t.finally(e):t.then(r=>{let n=e();return Or(n)?n.then(()=>r):r},r=>{let n=e();if(Or(n))return n.then(()=>{throw r});throw r})}function il(t){if(Up(t))return t.__fakePromiseValue;if(Mp(t))throw t.__fakeRejectError;return t}});var As=c((Sw,ol)=>{g();var{EventEmitter:Bp}=a("events"),{inherits:$p}=a("util");function nt(t){if(typeof t=="string"&&(t=Buffer.from(t)),!Buffer.isBuffer(t))throw new TypeError("The needle has to be a String or a Buffer.");let e=t.length,r=e-1;if(e===0)throw new Error("The needle cannot be an empty String/Buffer.");if(e>256)throw new Error("The needle cannot have a length bigger than 256.");this.maxMatches=1/0,this.matches=0,this._occ=new Uint8Array(256).fill(e),this._lookbehind_size=0,this._needle=t,this._bufpos=0,this._lookbehind=Buffer.alloc(r);for(var n=0;n<r;++n)this._occ[t[n]]=r-n;}$p(nt,Bp);nt.prototype.reset=function(){this._lookbehind_size=0,this.matches=0,this._bufpos=0;};nt.prototype.push=function(t,e){Buffer.isBuffer(t)||(t=Buffer.from(t,"binary"));let r=t.length;this._bufpos=e||0;let n;for(;n!==r&&this.matches<this.maxMatches;)n=this._sbmh_feed(t);return n};nt.prototype._sbmh_feed=function(t){let e=t.length,r=this._needle,n=r.length,s=n-1,i=r[s],o=-this._lookbehind_size,a;if(o<0){for(;o<0&&o<=e-n;){if(a=t[o+s],a===i&&this._sbmh_memcmp(t,o,s))return this._lookbehind_size=0,++this.matches,this.emit("info",true),this._bufpos=o+n;o+=this._occ[a];}for(;o<0&&!this._sbmh_memcmp(t,o,e-o);)++o;if(o>=0)this.emit("info",false,this._lookbehind,0,this._lookbehind_size),this._lookbehind_size=0;else {let c=this._lookbehind_size+o;return c>0&&this.emit("info",false,this._lookbehind,0,c),this._lookbehind_size-=c,this._lookbehind.copy(this._lookbehind,0,c,this._lookbehind_size),t.copy(this._lookbehind,this._lookbehind_size),this._lookbehind_size+=e,this._bufpos=e,e}}if(o=t.indexOf(r,o+this._bufpos),o!==-1)return ++this.matches,o===0?this.emit("info",true):this.emit("info",true,t,this._bufpos,o),this._bufpos=o+n;for(o=e-s,o<0&&(o=0);o!==e&&(t[o]!==r[0]||Buffer.compare(t.subarray(o+1,e),r.subarray(1,e-o))!==0);)++o;return o!==e&&(t.copy(this._lookbehind,0,o,e),this._lookbehind_size=e-o),o!==0&&this.emit("info",false,t,this._bufpos,o),this._bufpos=e,e};nt.prototype._sbmh_lookup_char=function(t,e){return e<0?this._lookbehind[this._lookbehind_size+e]:t[e]};nt.prototype._sbmh_memcmp=function(t,e,r){for(var n=0;n<r;++n)if(this._sbmh_lookup_char(t,e+n)!==this._needle[n])return false;return true};ol.exports=nt;});var cl=c((Pw,ll)=>{g();var Np=a("util").inherits,al=a("stream").Readable;function Ls(t){al.call(this,t);}Np(Ls,al);Ls.prototype._read=function(t){};ll.exports=Ls;});var Ir=c((Tw,ul)=>{g();ul.exports=function(e,r,n){if(!e||e[r]===void 0||e[r]===null)return n;if(typeof e[r]!="number"||isNaN(e[r]))throw new TypeError("Limit "+r+" is not a valid number");return e[r]};});var pl=c((Cw,dl)=>{g();var hl=a("events").EventEmitter,Gp=a("util").inherits,fl=Ir(),Hp=As(),zp=Buffer.from(`\r
3
3
  \r
4
4
  `),Vp=/\r\n/g,Wp=/^([^:]+):[ \t]?([\x00-\xFF]+)?$/;function St(t){hl.call(this),t=t||{};let e=this;this.nread=0,this.maxed=false,this.npairs=0,this.maxHeaderPairs=fl(t,"maxHeaderPairs",2e3),this.maxHeaderSize=fl(t,"maxHeaderSize",80*1024),this.buffer="",this.header={},this.finished=false,this.ss=new Hp(zp),this.ss.on("info",function(r,n,s,i){n&&!e.maxed&&(e.nread+i-s>=e.maxHeaderSize?(i=e.maxHeaderSize-e.nread+s,e.nread=e.maxHeaderSize,e.maxed=true):e.nread+=i-s,e.buffer+=n.toString("binary",s,i)),r&&e._finish();});}Gp(St,hl);St.prototype.push=function(t){let e=this.ss.push(t);if(this.finished)return e};St.prototype.reset=function(){this.finished=false,this.buffer="",this.header={},this.ss.reset();};St.prototype._finish=function(){this.buffer&&this._parseHeader(),this.ss.matches=this.ss.maxMatches;let t=this.header;this.header={},this.buffer="",this.finished=true,this.nread=this.npairs=0,this.maxed=false,this.emit("header",t);};St.prototype._parseHeader=function(){if(this.npairs===this.maxHeaderPairs)return;let t=this.buffer.split(Vp),e=t.length,r,n;for(var s=0;s<e;++s){if(t[s].length===0)continue;if((t[s][0]===" "||t[s][0]===" ")&&n){this.header[n][this.header[n].length-1]+=t[s];continue}let i=t[s].indexOf(":");if(i===-1||i===0)return;if(r=Wp.exec(t[s]),n=r[1].toLowerCase(),this.header[n]=this.header[n]||[],this.header[n].push(r[2]||""),++this.npairs===this.maxHeaderPairs)break}};dl.exports=St;});var Fs=c((Aw,bl)=>{g();var Os=a("stream").Writable,Kp=a("util").inherits,Qp=As(),ml=cl(),Zp=pl(),Jp=45,Yp=Buffer.from("-"),Xp=Buffer.from(`\r
@@ -53,5 +53,5 @@ const yoga = createYoga({
53
53
  graphqlEndpoint: '__REQUEST_PATH__',
54
54
  })
55
55
  </code>
56
- </pre></section></main></body></html>`;var Xy=function(e){return new e.fetchAPI.Response(tf.replace(/__GRAPHIQL_LINK__/g,e.graphqlEndpoint).replace(/__REQUEST_PATH__/g,e.url.pathname),{status:200,statusText:"OK",headers:{"Content-Type":"text/html"}})};function rf(t){let e=t.landingPageRenderer||Xy;return {onRequest({request:r,fetchAPI:n,endResponse:s,url:i}){let o=t.getGraphQLEndpoint();if(!r.url.endsWith(o)&&!r.url.endsWith(`${o}/`)&&i.pathname!==o&&i.pathname!==`${o}/`&&!t.getGraphQLEndpointURLPattern().test(i)){if(t.showLandingPage===true&&r.method==="GET"&&r.headers?.get("accept")?.includes("text/html")){let a=e({request:r,fetchAPI:n,url:i,graphqlEndpoint:o,get urlPattern(){return t.getGraphQLEndpointURLPattern()}});if(G(a))return a.then(s);s(a);return}s(new n.Response("",{status:404,statusText:"Not Found"}));}}}}g();function En({request:t,result:e,fetchAPI:r,onResultProcessHooks:n,serverContext:s}){let i,o=[],a="*/*";return C(()=>Q(n,c=>c({request:t,acceptableMediaTypes:o,result:e,setResult(l){e=l;},resultProcessor:i,setResultProcessor(l,u){i=l,a=u;},serverContext:s})),()=>i?i(e,r,a):new r.Response(null,{status:406,statusText:"Not Acceptable",headers:{accept:o.join("; charset=utf-8, ")}}))}function nf({params:t,enveloped:e}){let r=e.parse(t.query),n=e.validate(e.schema,r);return n.length>0?{errors:n}:C(()=>e.contextFactory(),s=>{let i={schema:e.schema,document:r,contextValue:s,variableValues:t.variables,operationName:t.operationName};return (F$2(r,t.operationName)?.operation==="subscription"?e.subscribe:e.execute)(i)})}g();function sf(t){return t?.status&&t?.headers}g();function of(t){return Ae(t)?t.toJSON():t instanceof Error?{message:t.message,stack:t.stack,cause:t.cause}:t}var af=(t,e,r=globalThis.process?.env?.NODE_ENV==="development")=>{if(xn(t))return t;let n={code:"INTERNAL_SERVER_ERROR",unexpected:true},s={extensions:n};return Ae(t)?(s.nodes=t.nodes,s.source=t.source,s.positions=t.positions,s.path=t.path,s.coordinate=gn(t),r&&t.originalError&&(n.originalError=of(t.originalError)),t.extensions?.http&&(n.http=t.extensions.http)):r&&(n.originalError=of(t)),M(e,s)};var Hi=class{getEnveloped;logger;fetchAPI;plugins;instrumentation;onRequestParseHooks;onParamsHooks;onExecutionResultHooks;onResultProcessHooks;maskedErrorsOpts;id;_graphqlEndpoint;_graphqlEndpointURLPattern;version="5.21.2";constructor(e){if(this.id=e?.id??"yoga",this.fetchAPI={...eg},e?.fetchAPI)for(let a in e.fetchAPI)e.fetchAPI[a]&&(this.fetchAPI[a]=e.fetchAPI[a]);let r=e?.logging==null?true:e.logging;this.logger=typeof r=="boolean"?r===true?xr():xr("silent"):typeof r=="string"?xr(r):r;let n=typeof e?.maskedErrors=="object"&&e.maskedErrors.maskError||af,s=new WeakSet;this.maskedErrorsOpts=e?.maskedErrors===false?null:{errorMessage:"Unexpected error.",...typeof e?.maskedErrors=="object"?e.maskedErrors:{},maskError:(a,c)=>{if(s.has(a))return a;let l=n(a,c,this.maskedErrorsOpts?.isDev);return l!==a&&this.logger.error(a),s.add(l),l}};let i=this.maskedErrorsOpts==null?null:this.maskedErrorsOpts,o=0;e?.batching&&(typeof e.batching=="boolean"?o=10:o=e.batching.limit??10),this.graphqlEndpoint=e?.graphqlEndpoint||"/graphql",this.plugins=[ia({parse:e$3,validate:D$1,execute:Rr,subscribe:Rr,specifiedRules:C$2}),!!e?.schema&&qo(e.schema),e?.allowedHeaders?.request!=null&&_u(e.allowedHeaders.request),e?.context!=null&&sa(a=>e?.context?typeof e.context=="function"?e.context(a):e.context:{}),Bu({id:this.id,logger:this.logger,endpoint:e?.healthCheckEndpoint}),e?.cors!==false&&bu(e?.cors),e?.graphiql!==false&&jo({getGraphQLEndpoint:()=>this._graphqlEndpoint,getGraphQLEndpointURLPattern:()=>this.getUrlPatternForGraphQLEndpoint(),options:e?.graphiql,render:e?.renderGraphiQL,logger:this.logger}),Dt({match:vu,parse:Tu}),Dt({match:Lu,parse:Ou}),e?.multipart!==false&&Dt({match:Fu,parse:Iu}),Dt({match:Ru,parse:Au}),Dt({match:ku,parse:Cu}),ef(),...e?.plugins??[],e?.parserAndValidationCache!==false&&zu(!e?.parserAndValidationCache||e?.parserAndValidationCache===true?{}:e?.parserAndValidationCache),Uu(o),Du(e?.extraParamNames),rf({getGraphQLEndpoint:()=>this.graphqlEndpoint,getGraphQLEndpointURLPattern:()=>this.getUrlPatternForGraphQLEndpoint(),showLandingPage:e?.landingPage!==false,landingPageRenderer:typeof e?.landingPage=="function"?e.landingPage:void 0}),ju(),Mu(),i!==null&&{onSubscribe(){return {onSubscribeError({error:a}){if(Bi(a))throw a}}}},i!==null&&na(i),e?.allowedHeaders?.response!=null&&xu(e.allowedHeaders.response),qu()],this.getEnveloped=ta({plugins:this.plugins}),this.plugins=this.getEnveloped._plugins,this.onRequestParseHooks=[],this.onParamsHooks=[],this.onExecutionResultHooks=[],this.onResultProcessHooks=[];for(let a of this.plugins)a&&(a.onYogaInit&&a.onYogaInit({yoga:this}),a.onRequestParse&&this.onRequestParseHooks.push(a.onRequestParse),a.onParams&&this.onParamsHooks.push(a.onParams),a.onExecutionResult&&this.onExecutionResultHooks.push(a.onExecutionResult),a.onResultProcess&&this.onResultProcessHooks.push(a.onResultProcess),a.instrumentation&&(this.instrumentation=this.instrumentation?gt(this.instrumentation,a.instrumentation):a.instrumentation));}get graphqlEndpoint(){return this._graphqlEndpoint}set graphqlEndpoint(e){this._graphqlEndpoint=e,this._graphqlEndpointURLPattern=void 0;}getUrlPatternForGraphQLEndpoint(){return this._graphqlEndpointURLPattern??=new this.fetchAPI.URLPattern({pathname:this._graphqlEndpoint}),this._graphqlEndpointURLPattern}handleParams=({request:e,context:r,params:n})=>{let s=r.request===e?{params:n}:{request:e,params:n};Object.assign(r,s);let i=this.getEnveloped(r);return this.logger.debug("Processing GraphQL Parameters"),C(()=>C(()=>nf({params:n,enveloped:i}),o=>(this.logger.debug("Processing GraphQL Parameters done."),o),o=>({errors:Lt(o,this.maskedErrorsOpts,this.logger)})),o=>(ce(o)&&(o=Fe(o,a=>a,a=>{if(a.name==="AbortError")throw this.logger.debug("Request aborted"),a;return {errors:Lt(a,this.maskedErrorsOpts,this.logger)}})),o))};getResultForParams=({params:e,request:r},n)=>{let s,i=this.handleParams;return C(()=>Q(this.onParamsHooks,o=>o({params:e,request:r,setParams(a){e=a;},paramsHandler:i,setParamsHandler(a){i=a;},setResult(a){s=a;},fetchAPI:this.fetchAPI,context:n})),()=>C(()=>s||i({request:r,params:e,context:n}),o=>C(()=>Q(this.onExecutionResultHooks,a=>a({result:o,setResult(c){o=c;},request:r,context:n})),()=>o)))};parseRequest=(e,r)=>{let n=new Proxy({},{get:(a,c,l)=>(n=new this.fetchAPI.URL(e.url,"http://localhost"),Reflect.get(n,c,n))}),s,i,o=[];return C(()=>Q(this.onRequestParseHooks,(a,c)=>C(()=>a({request:e,url:n,requestParser:s,serverContext:r,setRequestParser(l){s=l;},endResponse(l){i=l,c();},fetchAPI:this.fetchAPI}),l=>l?.onRequestParseDone),o),()=>i?{response:i}:(this.logger.debug("Parsing request to extract GraphQL parameters"),s?C(()=>s(e),a=>{if(sf(a))return {response:a};let c=a;return C(()=>Q(o,l=>l({requestParserResult:c,setRequestParserResult(u){c=u;}})),()=>({requestParserResult:c}))}):{response:new this.fetchAPI.Response(null,{status:415,statusText:"Unsupported Media Type"})}))};handle=(e,r)=>{let n=this.instrumentation&&et({request:e}),s=this.instrumentation?.requestParse?n.asyncFn(this.instrumentation?.requestParse,this.parseRequest):this.parseRequest;return Bt(N().then(()=>s(e,r)).then(({response:i,requestParserResult:o})=>{if(i)return i;let a=this.instrumentation?.operation?(c,l)=>et({context:l,request:c.request}).asyncFn(this.instrumentation?.operation,this.getResultForParams)(c,l):this.getResultForParams;return C(()=>Array.isArray(o)?Promise.all(o.map(c=>N().then(()=>a({params:c,request:e},Object.create(r))).catch(l=>({errors:Lt(l,this.maskedErrorsOpts,this.logger)})))):a({params:o,request:e},r),c=>(this.instrumentation?.resultProcess?n.asyncFn(this.instrumentation.resultProcess,En):En)({request:e,result:c,fetchAPI:this.fetchAPI,onResultProcessHooks:this.onResultProcessHooks,serverContext:r}))}).catch(i=>{let a={errors:Lt(i,this.maskedErrorsOpts,this.logger)};return En({request:e,result:a,fetchAPI:this.fetchAPI,onResultProcessHooks:this.onResultProcessHooks,serverContext:r})}))}};function lf(t){let e=new Hi(t);return mu(e,{fetchAPI:e.fetchAPI,plugins:e.plugins,disposeOnProcessTerminate:t.disposeOnProcessTerminate})}g();var tg={aws:{type:"aws",configKey:"s3",displayName:"S3 Compatible (AWS, Backblaze, Wasabi, etc.)",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"endpoint",type:"text",label:"Endpoint URL",admin:{placeholder:"https://s3.custom.com"}},{name:"cdnUrl",type:"text",label:"CDN URL",admin:{placeholder:"https://cdn.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}]},r2:{type:"r2",configKey:"r2",displayName:"Cloudflare R2",configFields:[{name:"accountId",type:"text",label:"Account ID",required:true,admin:{placeholder:"Your Cloudflare Account ID"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"publicDevUrl",type:"text",label:"Public Dev URL ID",admin:{placeholder:"pub-xxxxxxxxxxxxxxxx",description:"Enter ONLY the ID (e.g., pub-b8d8c4cc8bcf4d868ddd95efc1b305aa). Do NOT include https:// or the full URL. Found in R2 Dashboard \u2192 Public Dev URL."}},{name:"cdnUrl",type:"text",label:"Custom CDN URL",admin:{placeholder:"https://assets.example.com (optional)"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads (optional)",description:"Optional prefix for all object keys. Do not use '/' as prefix."}}]},gcs:{type:"gcs",configKey:"gcs",displayName:"Google Cloud Storage",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"projectId",type:"text",label:"Project ID"},{name:"clientEmail",type:"text",label:"Client Email"},{name:"privateKey",type:"password",label:"Private Key"},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},digitalocean:{type:"digitalocean",configKey:"digitalocean",displayName:"DigitalOcean Spaces",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"nyc3"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},backblaze:{type:"backblaze",configKey:"backblaze",displayName:"Backblaze B2",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"accountId",type:"text",label:"Account ID"},{name:"applicationKeyId",type:"text",label:"Application Key ID",required:true},{name:"applicationKey",type:"password",label:"Application Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},wasabi:{type:"wasabi",configKey:"wasabi",displayName:"Wasabi",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]}};function rg(t,e){switch(t){case "r2":return e?.endpoint||`https://${e?.accountId||""}.r2.cloudflarestorage.com`;case "digitalocean":return e?.endpoint||`https://${e?.region||"nyc3"}.digitaloceanspaces.com`;case "backblaze":return e?.endpoint||"https://s3.backblazeb2.com";case "wasabi":return e?.endpoint||`https://s3.${e?.region||"us-east-1"}.wasabisys.com`;default:return e?.endpoint}}function cf(t,e){return {provider:t,bucket:e?.bucket||"",region:e?.region||"us-east-1",accessKeyId:e?.accessKeyId||e?.clientEmail||e?.applicationKeyId||"",secretAccessKey:e?.secretAccessKey||e?.privateKey||e?.applicationKey||"",endpoint:rg(t,e),cdnUrl:e?.cdnUrl,prefix:e?.prefix,accountId:e?.accountId,publicDevUrl:e?.publicDevUrl}}function ng(t,e,r){let n=r[e.configKey]||{};return cf(t,n)}function sg(t,e,r){let n=r?.[e.configKey]||r;return cf(t,n)}var zi=class extends xe{constructor(){super("@kyro-cms/storage-s3"),this.version="1.0.0",this.description="S3-compatible storage (AWS R2 GCS DigitalOcean Backblaze Wasabi)";}async init(e){let r=e.registry?.storageProviders;if(!r)return;let n=this.name;for(let s of Object.values(tg))r.register({type:s.type,displayName:s.displayName,pluginName:n,configKey:s.configKey,configFields:s.configFields,extractConfig:i=>ng(s.type,s,i),extractRawConfig:i=>sg(s.type,s,i),factory:i=>Xa$1(i)});}},uf=new zi;g();var Vi=class extends xe{constructor(){super("@kyro-cms/storage-cloudinary"),this.version="1.0.0",this.description="Cloudinary image and video storage";}async init(e){let r=e.registry?.storageProviders;r&&r.register({type:"cloudinary",displayName:"Cloudinary",pluginName:this.name,configKey:"cloudinary",configFields:[{name:"cloudName",type:"text",label:"Cloud Name",required:true},{name:"apiKey",type:"text",label:"API Key",required:true},{name:"apiSecret",type:"password",label:"API Secret",required:true},{name:"folder",type:"text",label:"Folder",admin:{placeholder:"Optional folder path"}},{name:"uploadPreset",type:"text",label:"Upload Preset (optional)",admin:{placeholder:"Leave empty for signed uploads",description:"If not set, uploads will be signed with API Secret"}}],extractConfig:n=>({cloudName:n.cloudinary?.cloudName||"",apiKey:n.cloudinary?.apiKey||"",apiSecret:n.cloudinary?.apiSecret||"",folder:n.cloudinary?.folder,uploadPreset:n.cloudinary?.uploadPreset}),extractRawConfig:n=>{let s=n?.cloudinary||n;return {cloudName:s?.cloudName||"",apiKey:s?.apiKey||"",apiSecret:s?.apiSecret||"",folder:s?.folder,uploadPreset:s?.uploadPreset}},factory:n=>Ya$1(n)});}},ff=new Vi;var ig=[uf,ff];function ut(t,e,r){let n=e.split(".");if(n.length===0)return false;let s=n[0],i=n.slice(1).join(".");for(let o of t){if(o.name===s)if(i){if(o.fields&&Array.isArray(o.fields))return ut(o.fields,i,r);if(o.type==="tabs"&&o.tabs&&Array.isArray(o.tabs)){for(let c of o.tabs)if(c.fields&&Array.isArray(c.fields)&&ut(c.fields,i,r))return true;return false}if(o.type==="blocks"&&o.blocks&&Array.isArray(o.blocks)){let c=i.split(".")[0],l=i.split(".").slice(1).join(".");if(!l)return false;for(let u of o.blocks)if(u.slug===c&&u.fields&&Array.isArray(u.fields))return ut(u.fields,l,r);return false}return o.type==="array"&&o.fields&&Array.isArray(o.fields)?ut(o.fields,i,r):false}else return Object.assign(o,r),true;if(!o.name||o.type==="tabs"||o.type==="row"||o.type==="collapsible"){if(o.fields&&Array.isArray(o.fields)&&ut(o.fields,e,r))return true;if(o.type==="tabs"&&o.tabs&&Array.isArray(o.tabs)){for(let c of o.tabs)if(c.fields&&Array.isArray(c.fields)&&ut(c.fields,e,r))return true}}}return i?false:(t.push({name:s,...r}),true)}function og(t,e){if(e)for(let r of t){let n=e[r.slug];if(n){let{fields:s,...i}=n;if(r.admin={...r.admin,...i},s&&r.fields&&Array.isArray(r.fields))for(let[o,a]of Object.entries(s))ut(r.fields,o,a);}}}var Wi=class{registry;db;pubsub;webhookService;settings;pluginManager;wsServer;config;constructor(e){this.config=e,this.registry=Wn(),this.db=e.adapter||e.db,this.pubsub=new b$2(this.registry),this.webhookService=o$2(this.db),this.pluginManager=new br;for(let r of ig)this.pluginManager.register(r),this.registry.addPlugin(r);if(e.plugins)for(let r of e.plugins)this.pluginManager.register(r),this.registry.addPlugin(r);e.collections&&e.admin?.collectionOverrides&&og(e.collections,e.admin.collectionOverrides),e.collections&&this.registry.addCollections(e.collections),e.globals&&this.registry.addGlobals(e.globals);}async init(){await this.pluginManager.executeHook("beforeInit",{kyro:this}),await this.registry.init(this),await this.pluginManager.executeHook("afterInit",{kyro:this}),this.registry.addGlobalPostInit(a$3);let e={slug:"plugin-settings",admin:{hidden:true},fields:[{name:"states",type:"json"}]};if(this.registry.addGlobalPostInit(e),!this.db)throw new Error("Database adapter is null \u2014 failed to load at startup. Check the server console for the exact error.");let r={slug:d$2,fields:[{name:"userId",type:"text",required:true},{name:"name",type:"text",required:true},{name:"key",type:"text",required:true},{name:"keyPrefix",type:"text",required:true},{name:"permissions",type:"json"},{name:"lastUsedAt",type:"date"},{name:"expiresAt",type:"date"}]},n={slug:f$2,fields:[{name:"name",type:"text",required:true},{name:"url",type:"text",required:true},{name:"events",type:"json",required:true},{name:"collections",type:"json"},{name:"status",type:"text",required:true},{name:"secret",type:"text"},{name:"headers",type:"json"},{name:"action",type:"text"},{name:"config",type:"json"},{name:"lastTriggered",type:"date"},{name:"lastError",type:"text"}]},s={slug:g$3,fields:[{name:"webhookId",type:"text",required:true},{name:"event",type:"text",required:true},{name:"payload",type:"json",required:true},{name:"attempt",type:"number",required:true},{name:"status",type:"text",required:true},{name:"responseStatus",type:"number"},{name:"responseBody",type:"text"},{name:"error",type:"text"},{name:"duration",type:"number"},{name:"deliveredAt",type:"date"},{name:"nextRetryAt",type:"date"}]},i=this.registry.getGlobals();if(this.db instanceof c$3&&this.db.dialect==="postgres"){let o=this.db,a=d$2.replace(/-/g,"_");o.schema&&!o.schema[a]&&(o.schema[a]=g$2);}await this.db.init([...this.registry.getCollections(),r,n,s],i),await this.loadPluginState(),this.pubsub.autoRegisterHooks();}async loadSettings(){if(this.settings)return this.settings;try{let e=await this.db.findOne({collection:"_globals_access-settings",where:{},draft:!0});e&&(this.settings={access:e});}catch{}return this.settings||{}}async loadPluginState(){let e=this.registry.storageProviders,r=e.getAllPluginNames(),n={};try{let s=await this.db.findOne({collection:"_globals_plugin-settings",where:{},draft:!0});s&&s.states&&(n=s.states);}catch{}for(let s of r)n[s]!==void 0&&e.setPluginEnabled(s,n[s]);}async getREST(e){let r=typeof this.config.auth=="object"?this.config.auth:null,n=r?.secret,s=r?.checkSession!==false;return qb({registry:this.registry,db:this.db,authSecret:n,authAdapter:this.config.authAdapter,checkSession:s,...e,cors:this.config.cors,webhookService:this.webhookService,settings:this.settings})}getGraphQL(e){let r=J$1({registry:this.registry,db:this.db,settings:this.settings});return {fetch:lf({schema:r,context:async({request:s})=>{let i=f$3(s),o,a;if(i&&this.db){let l=await e$2(i,this.db);l.user&&(o=l.user,a=g$4(l));}let c=e?.tenantId;return {db:this.db,registry:this.registry,user:o,req:s,tenantId:c,apiKey:a,relationLoader:new H$2({db:this.db,tenantId:c,user:o})}},graphiql:this.config.graphQL?.disablePlayground!==true,plugins:[]}).fetch,schema:r}}getTRPC(e){return {fetch:async(r,n)=>{let i=new URL(r.url).pathname.replace(/^\/api\/trpc\//,""),[o,...a]=i.split("."),c=a.join(".");if(c=c.replace(/\.(query|mutate|subscribe)$/,""),!o||!c)return new Response(JSON.stringify({error:{message:"Invalid tRPC path",code:-32600,data:{code:"BAD_REQUEST",httpStatus:400}}}),{status:400,headers:{"Content-Type":"application/json"}});let l=await a$4({db:this.db,registry:this.registry,req:r,user:e?.user,tenantId:e?.tenantId,settings:this.settings}),h=i$1(l)[o];if(!h)return new Response(JSON.stringify({error:{message:`Collection '${o}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});let d=h[c];if(typeof d!="function")return new Response(JSON.stringify({error:{message:`Procedure '${c}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});try{let p={};if(r.method==="POST"||r.method==="PATCH")p=await r.json().catch(()=>({}));else {let A=new URL(r.url).searchParams.get("input");if(A)try{p=JSON.parse(decodeURIComponent(A));}catch{}}let _=p?.["0"]??p,E=await d({..._,collection:o});return new Response(JSON.stringify({result:{data:E}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(p){let _=p.message||"Internal error",E=_.includes("not found")?404:_.includes("denied")||_.includes("authentication required")?403:_.includes("conflict")?409:500,A=E===404?-32601:E===403?-32001:E===409?-32002:-32603;return new Response(JSON.stringify({error:{message:_,code:A,data:{code:"INTERNAL_SERVER_ERROR",httpStatus:E}}}),{status:E,headers:{"Content-Type":"application/json"}})}},router:null}}getWS(){return this.wsServer}async startWebSocket(e){let r=this.settings?.access?.apiAccess;if(r?.wsEnabled===false)return null;let n=async o=>{let a=await e$2(o,this.db);if(!a.valid)throw new Error(a.error||"Invalid API key");if(!a.user)throw new Error("API key has no associated user");return a.user},s=e?.port||8080,i=globalThis;if(i.__KYRO_WS_SERVER__)try{await i.__KYRO_WS_SERVER__.close();}catch{}return this.wsServer=d$3({pubsub:this.pubsub,port:s,requireAuth:e?.requireAuth??r?.requireAuth,verifyToken:e?.verifyToken||n}),i.__KYRO_WS_SERVER__=this.wsServer,this.wsServer}async shutdown(){await this.pluginManager.executeHook("beforeServerStop",{kyro:this}),this.wsServer&&await this.wsServer.close(),await this.db.disconnect(),await this.pluginManager.executeHook("afterServerStop",{kyro:this});}};function Rv(t){return new Wi(t)}g();var hf={debug:0,info:1,warn:2,error:3,none:4},Ki=class{level;constructor(){let e=typeof process<"u"?process.env?.KYRO_LOG_LEVEL:void 0;this.level=e||"info";}setLevel(e){this.level=e;}getLevel(){return this.level}shouldLog(e){return hf[e]>=hf[this.level]}debug(...e){this.shouldLog("debug")&&console.debug("[Kyro DEBUG]",...e);}info(...e){this.shouldLog("info")&&console.log("[Kyro]",...e);}warn(...e){this.shouldLog("warn")&&console.warn("[Kyro WARN]",...e);}error(...e){this.shouldLog("error")&&console.error("[Kyro ERROR]",...e);}},Mv=new Ki;
56
+ </pre></section></main></body></html>`;var Xy=function(e){return new e.fetchAPI.Response(tf.replace(/__GRAPHIQL_LINK__/g,e.graphqlEndpoint).replace(/__REQUEST_PATH__/g,e.url.pathname),{status:200,statusText:"OK",headers:{"Content-Type":"text/html"}})};function rf(t){let e=t.landingPageRenderer||Xy;return {onRequest({request:r,fetchAPI:n,endResponse:s,url:i}){let o=t.getGraphQLEndpoint();if(!r.url.endsWith(o)&&!r.url.endsWith(`${o}/`)&&i.pathname!==o&&i.pathname!==`${o}/`&&!t.getGraphQLEndpointURLPattern().test(i)){if(t.showLandingPage===true&&r.method==="GET"&&r.headers?.get("accept")?.includes("text/html")){let a=e({request:r,fetchAPI:n,url:i,graphqlEndpoint:o,get urlPattern(){return t.getGraphQLEndpointURLPattern()}});if(G(a))return a.then(s);s(a);return}s(new n.Response("",{status:404,statusText:"Not Found"}));}}}}g();function En({request:t,result:e,fetchAPI:r,onResultProcessHooks:n,serverContext:s}){let i,o=[],a="*/*";return C(()=>Q(n,c=>c({request:t,acceptableMediaTypes:o,result:e,setResult(l){e=l;},resultProcessor:i,setResultProcessor(l,u){i=l,a=u;},serverContext:s})),()=>i?i(e,r,a):new r.Response(null,{status:406,statusText:"Not Acceptable",headers:{accept:o.join("; charset=utf-8, ")}}))}function nf({params:t,enveloped:e}){let r=e.parse(t.query),n=e.validate(e.schema,r);return n.length>0?{errors:n}:C(()=>e.contextFactory(),s=>{let i={schema:e.schema,document:r,contextValue:s,variableValues:t.variables,operationName:t.operationName};return (F$2(r,t.operationName)?.operation==="subscription"?e.subscribe:e.execute)(i)})}g();function sf(t){return t?.status&&t?.headers}g();function of(t){return Ae(t)?t.toJSON():t instanceof Error?{message:t.message,stack:t.stack,cause:t.cause}:t}var af=(t,e,r=globalThis.process?.env?.NODE_ENV==="development")=>{if(xn(t))return t;let n={code:"INTERNAL_SERVER_ERROR",unexpected:true},s={extensions:n};return Ae(t)?(s.nodes=t.nodes,s.source=t.source,s.positions=t.positions,s.path=t.path,s.coordinate=gn(t),r&&t.originalError&&(n.originalError=of(t.originalError)),t.extensions?.http&&(n.http=t.extensions.http)):r&&(n.originalError=of(t)),M(e,s)};var Hi=class{getEnveloped;logger;fetchAPI;plugins;instrumentation;onRequestParseHooks;onParamsHooks;onExecutionResultHooks;onResultProcessHooks;maskedErrorsOpts;id;_graphqlEndpoint;_graphqlEndpointURLPattern;version="5.21.2";constructor(e){if(this.id=e?.id??"yoga",this.fetchAPI={...eg},e?.fetchAPI)for(let a in e.fetchAPI)e.fetchAPI[a]&&(this.fetchAPI[a]=e.fetchAPI[a]);let r=e?.logging==null?true:e.logging;this.logger=typeof r=="boolean"?r===true?xr():xr("silent"):typeof r=="string"?xr(r):r;let n=typeof e?.maskedErrors=="object"&&e.maskedErrors.maskError||af,s=new WeakSet;this.maskedErrorsOpts=e?.maskedErrors===false?null:{errorMessage:"Unexpected error.",...typeof e?.maskedErrors=="object"?e.maskedErrors:{},maskError:(a,c)=>{if(s.has(a))return a;let l=n(a,c,this.maskedErrorsOpts?.isDev);return l!==a&&this.logger.error(a),s.add(l),l}};let i=this.maskedErrorsOpts==null?null:this.maskedErrorsOpts,o=0;e?.batching&&(typeof e.batching=="boolean"?o=10:o=e.batching.limit??10),this.graphqlEndpoint=e?.graphqlEndpoint||"/graphql",this.plugins=[ia({parse:e$3,validate:D$1,execute:Rr,subscribe:Rr,specifiedRules:C$2}),!!e?.schema&&qo(e.schema),e?.allowedHeaders?.request!=null&&_u(e.allowedHeaders.request),e?.context!=null&&sa(a=>e?.context?typeof e.context=="function"?e.context(a):e.context:{}),Bu({id:this.id,logger:this.logger,endpoint:e?.healthCheckEndpoint}),e?.cors!==false&&bu(e?.cors),e?.graphiql!==false&&jo({getGraphQLEndpoint:()=>this._graphqlEndpoint,getGraphQLEndpointURLPattern:()=>this.getUrlPatternForGraphQLEndpoint(),options:e?.graphiql,render:e?.renderGraphiQL,logger:this.logger}),Dt({match:vu,parse:Tu}),Dt({match:Lu,parse:Ou}),e?.multipart!==false&&Dt({match:Fu,parse:Iu}),Dt({match:Ru,parse:Au}),Dt({match:ku,parse:Cu}),ef(),...e?.plugins??[],e?.parserAndValidationCache!==false&&zu(!e?.parserAndValidationCache||e?.parserAndValidationCache===true?{}:e?.parserAndValidationCache),Uu(o),Du(e?.extraParamNames),rf({getGraphQLEndpoint:()=>this.graphqlEndpoint,getGraphQLEndpointURLPattern:()=>this.getUrlPatternForGraphQLEndpoint(),showLandingPage:e?.landingPage!==false,landingPageRenderer:typeof e?.landingPage=="function"?e.landingPage:void 0}),ju(),Mu(),i!==null&&{onSubscribe(){return {onSubscribeError({error:a}){if(Bi(a))throw a}}}},i!==null&&na(i),e?.allowedHeaders?.response!=null&&xu(e.allowedHeaders.response),qu()],this.getEnveloped=ta({plugins:this.plugins}),this.plugins=this.getEnveloped._plugins,this.onRequestParseHooks=[],this.onParamsHooks=[],this.onExecutionResultHooks=[],this.onResultProcessHooks=[];for(let a of this.plugins)a&&(a.onYogaInit&&a.onYogaInit({yoga:this}),a.onRequestParse&&this.onRequestParseHooks.push(a.onRequestParse),a.onParams&&this.onParamsHooks.push(a.onParams),a.onExecutionResult&&this.onExecutionResultHooks.push(a.onExecutionResult),a.onResultProcess&&this.onResultProcessHooks.push(a.onResultProcess),a.instrumentation&&(this.instrumentation=this.instrumentation?gt(this.instrumentation,a.instrumentation):a.instrumentation));}get graphqlEndpoint(){return this._graphqlEndpoint}set graphqlEndpoint(e){this._graphqlEndpoint=e,this._graphqlEndpointURLPattern=void 0;}getUrlPatternForGraphQLEndpoint(){return this._graphqlEndpointURLPattern??=new this.fetchAPI.URLPattern({pathname:this._graphqlEndpoint}),this._graphqlEndpointURLPattern}handleParams=({request:e,context:r,params:n})=>{let s=r.request===e?{params:n}:{request:e,params:n};Object.assign(r,s);let i=this.getEnveloped(r);return this.logger.debug("Processing GraphQL Parameters"),C(()=>C(()=>nf({params:n,enveloped:i}),o=>(this.logger.debug("Processing GraphQL Parameters done."),o),o=>({errors:Lt(o,this.maskedErrorsOpts,this.logger)})),o=>(ce(o)&&(o=Fe(o,a=>a,a=>{if(a.name==="AbortError")throw this.logger.debug("Request aborted"),a;return {errors:Lt(a,this.maskedErrorsOpts,this.logger)}})),o))};getResultForParams=({params:e,request:r},n)=>{let s,i=this.handleParams;return C(()=>Q(this.onParamsHooks,o=>o({params:e,request:r,setParams(a){e=a;},paramsHandler:i,setParamsHandler(a){i=a;},setResult(a){s=a;},fetchAPI:this.fetchAPI,context:n})),()=>C(()=>s||i({request:r,params:e,context:n}),o=>C(()=>Q(this.onExecutionResultHooks,a=>a({result:o,setResult(c){o=c;},request:r,context:n})),()=>o)))};parseRequest=(e,r)=>{let n=new Proxy({},{get:(a,c,l)=>(n=new this.fetchAPI.URL(e.url,"http://localhost"),Reflect.get(n,c,n))}),s,i,o=[];return C(()=>Q(this.onRequestParseHooks,(a,c)=>C(()=>a({request:e,url:n,requestParser:s,serverContext:r,setRequestParser(l){s=l;},endResponse(l){i=l,c();},fetchAPI:this.fetchAPI}),l=>l?.onRequestParseDone),o),()=>i?{response:i}:(this.logger.debug("Parsing request to extract GraphQL parameters"),s?C(()=>s(e),a=>{if(sf(a))return {response:a};let c=a;return C(()=>Q(o,l=>l({requestParserResult:c,setRequestParserResult(u){c=u;}})),()=>({requestParserResult:c}))}):{response:new this.fetchAPI.Response(null,{status:415,statusText:"Unsupported Media Type"})}))};handle=(e,r)=>{let n=this.instrumentation&&et({request:e}),s=this.instrumentation?.requestParse?n.asyncFn(this.instrumentation?.requestParse,this.parseRequest):this.parseRequest;return Bt(N().then(()=>s(e,r)).then(({response:i,requestParserResult:o})=>{if(i)return i;let a=this.instrumentation?.operation?(c,l)=>et({context:l,request:c.request}).asyncFn(this.instrumentation?.operation,this.getResultForParams)(c,l):this.getResultForParams;return C(()=>Array.isArray(o)?Promise.all(o.map(c=>N().then(()=>a({params:c,request:e},Object.create(r))).catch(l=>({errors:Lt(l,this.maskedErrorsOpts,this.logger)})))):a({params:o,request:e},r),c=>(this.instrumentation?.resultProcess?n.asyncFn(this.instrumentation.resultProcess,En):En)({request:e,result:c,fetchAPI:this.fetchAPI,onResultProcessHooks:this.onResultProcessHooks,serverContext:r}))}).catch(i=>{let a={errors:Lt(i,this.maskedErrorsOpts,this.logger)};return En({request:e,result:a,fetchAPI:this.fetchAPI,onResultProcessHooks:this.onResultProcessHooks,serverContext:r})}))}};function lf(t){let e=new Hi(t);return mu(e,{fetchAPI:e.fetchAPI,plugins:e.plugins,disposeOnProcessTerminate:t.disposeOnProcessTerminate})}g();var tg={aws:{type:"aws",configKey:"s3",displayName:"S3 Compatible (AWS, Backblaze, Wasabi, etc.)",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"endpoint",type:"text",label:"Endpoint URL",admin:{placeholder:"https://s3.custom.com"}},{name:"cdnUrl",type:"text",label:"CDN URL",admin:{placeholder:"https://cdn.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}]},r2:{type:"r2",configKey:"r2",displayName:"Cloudflare R2",configFields:[{name:"accountId",type:"text",label:"Account ID",required:true,admin:{placeholder:"Your Cloudflare Account ID"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"publicDevUrl",type:"text",label:"Public Dev URL ID",admin:{placeholder:"pub-xxxxxxxxxxxxxxxx",description:"Enter ONLY the ID (e.g., pub-b8d8c4cc8bcf4d868ddd95efc1b305aa). Do NOT include https:// or the full URL. Found in R2 Dashboard \u2192 Public Dev URL."}},{name:"cdnUrl",type:"text",label:"Custom CDN URL",admin:{placeholder:"https://assets.example.com (optional)"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads (optional)",description:"Optional prefix for all object keys. Do not use '/' as prefix."}}]},gcs:{type:"gcs",configKey:"gcs",displayName:"Google Cloud Storage",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"projectId",type:"text",label:"Project ID"},{name:"clientEmail",type:"text",label:"Client Email"},{name:"privateKey",type:"password",label:"Private Key"},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},digitalocean:{type:"digitalocean",configKey:"digitalocean",displayName:"DigitalOcean Spaces",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"nyc3"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},backblaze:{type:"backblaze",configKey:"backblaze",displayName:"Backblaze B2",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"accountId",type:"text",label:"Account ID"},{name:"applicationKeyId",type:"text",label:"Application Key ID",required:true},{name:"applicationKey",type:"password",label:"Application Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},wasabi:{type:"wasabi",configKey:"wasabi",displayName:"Wasabi",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]}};function rg(t,e){switch(t){case "r2":return e?.endpoint||`https://${e?.accountId||""}.r2.cloudflarestorage.com`;case "digitalocean":return e?.endpoint||`https://${e?.region||"nyc3"}.digitaloceanspaces.com`;case "backblaze":return e?.endpoint||"https://s3.backblazeb2.com";case "wasabi":return e?.endpoint||`https://s3.${e?.region||"us-east-1"}.wasabisys.com`;default:return e?.endpoint}}function cf(t,e){return {provider:t,bucket:e?.bucket||"",region:e?.region||"us-east-1",accessKeyId:e?.accessKeyId||e?.clientEmail||e?.applicationKeyId||"",secretAccessKey:e?.secretAccessKey||e?.privateKey||e?.applicationKey||"",endpoint:rg(t,e),cdnUrl:e?.cdnUrl,prefix:e?.prefix,accountId:e?.accountId,publicDevUrl:e?.publicDevUrl}}function ng(t,e,r){let n=r[e.configKey]||{};return cf(t,n)}function sg(t,e,r){let n=r?.[e.configKey]||r;return cf(t,n)}var zi=class extends xe{constructor(){super("@kyro-cms/storage-s3"),this.version="1.0.0",this.description="S3-compatible storage (AWS R2 GCS DigitalOcean Backblaze Wasabi)";}async init(e){let r=e.registry?.storageProviders;if(!r)return;let n=this.name;for(let s of Object.values(tg))r.register({type:s.type,displayName:s.displayName,pluginName:n,configKey:s.configKey,configFields:s.configFields,extractConfig:i=>ng(s.type,s,i),extractRawConfig:i=>sg(s.type,s,i),factory:i=>Xa$1(i)});}},uf=new zi;g();var Vi=class extends xe{constructor(){super("@kyro-cms/storage-cloudinary"),this.version="1.0.0",this.description="Cloudinary image and video storage";}async init(e){let r=e.registry?.storageProviders;r&&r.register({type:"cloudinary",displayName:"Cloudinary",pluginName:this.name,configKey:"cloudinary",configFields:[{name:"cloudName",type:"text",label:"Cloud Name",required:true},{name:"apiKey",type:"text",label:"API Key",required:true},{name:"apiSecret",type:"password",label:"API Secret",required:true},{name:"folder",type:"text",label:"Folder",admin:{placeholder:"Optional folder path"}},{name:"uploadPreset",type:"text",label:"Upload Preset (optional)",admin:{placeholder:"Leave empty for signed uploads",description:"If not set, uploads will be signed with API Secret"}}],extractConfig:n=>({cloudName:n.cloudinary?.cloudName||"",apiKey:n.cloudinary?.apiKey||"",apiSecret:n.cloudinary?.apiSecret||"",folder:n.cloudinary?.folder,uploadPreset:n.cloudinary?.uploadPreset}),extractRawConfig:n=>{let s=n?.cloudinary||n;return {cloudName:s?.cloudName||"",apiKey:s?.apiKey||"",apiSecret:s?.apiSecret||"",folder:s?.folder,uploadPreset:s?.uploadPreset}},factory:n=>Ya$1(n)});}},ff=new Vi;var ig=[uf,ff];function ut(t,e,r){let n=e.split(".");if(n.length===0)return false;let s=n[0],i=n.slice(1).join(".");for(let o of t){if(o.name===s)if(i){if(o.fields&&Array.isArray(o.fields))return ut(o.fields,i,r);if(o.type==="tabs"&&o.tabs&&Array.isArray(o.tabs)){for(let c of o.tabs)if(c.fields&&Array.isArray(c.fields)&&ut(c.fields,i,r))return true;return false}if(o.type==="blocks"&&o.blocks&&Array.isArray(o.blocks)){let c=i.split(".")[0],l=i.split(".").slice(1).join(".");if(!l)return false;for(let u of o.blocks)if(u.slug===c&&u.fields&&Array.isArray(u.fields))return ut(u.fields,l,r);return false}return o.type==="array"&&o.fields&&Array.isArray(o.fields)?ut(o.fields,i,r):false}else return Object.assign(o,r),true;if(!o.name||o.type==="tabs"||o.type==="row"||o.type==="collapsible"){if(o.fields&&Array.isArray(o.fields)&&ut(o.fields,e,r))return true;if(o.type==="tabs"&&o.tabs&&Array.isArray(o.tabs)){for(let c of o.tabs)if(c.fields&&Array.isArray(c.fields)&&ut(c.fields,e,r))return true}}}return i?false:(t.push({name:s,...r}),true)}function og(t,e){if(e)for(let r of t){let n=e[r.slug];if(n){let{fields:s,...i}=n;if(r.admin={...r.admin,...i},s&&r.fields&&Array.isArray(r.fields))for(let[o,a]of Object.entries(s))ut(r.fields,o,a);}}}var Wi=class{registry;db;pubsub;webhookService;settings;pluginManager;wsServer;config;constructor(e){this.config=e,this.registry=Wn(),this.db=e.adapter||e.db,this.pubsub=new b$2(this.registry),this.webhookService=o$2(this.db),this.pluginManager=new br;for(let r of ig)this.pluginManager.register(r),this.registry.addPlugin(r);if(e.plugins)for(let r of e.plugins)this.pluginManager.register(r),this.registry.addPlugin(r);e.collections&&e.admin?.collectionOverrides&&og(e.collections,e.admin.collectionOverrides),e.collections&&this.registry.addCollections(e.collections),e.globals&&this.registry.addGlobals(e.globals);}async init(){await this.pluginManager.executeHook("beforeInit",{kyro:this}),await this.registry.init(this),await this.pluginManager.executeHook("afterInit",{kyro:this}),this.registry.addGlobalPostInit(a$3);let e={slug:"plugin-settings",admin:{hidden:true},fields:[{name:"states",type:"json"}]};if(this.registry.addGlobalPostInit(e),!this.db)throw new Error("Database adapter is null \u2014 failed to load at startup. Check the server console for the exact error.");let r={slug:d$2,fields:[{name:"userId",type:"text",required:true},{name:"name",type:"text",required:true},{name:"key",type:"text",required:true},{name:"keyPrefix",type:"text",required:true},{name:"permissions",type:"json"},{name:"lastUsedAt",type:"date"},{name:"expiresAt",type:"date"}]},n={slug:f$2,fields:[{name:"name",type:"text",required:true},{name:"url",type:"text",required:true},{name:"events",type:"json",required:true},{name:"collections",type:"json"},{name:"status",type:"text",required:true},{name:"secret",type:"text"},{name:"headers",type:"json"},{name:"action",type:"text"},{name:"config",type:"json"},{name:"lastTriggered",type:"date"},{name:"lastError",type:"text"}]},s={slug:g$3,fields:[{name:"webhookId",type:"text",required:true},{name:"event",type:"text",required:true},{name:"payload",type:"json",required:true},{name:"attempt",type:"number",required:true},{name:"status",type:"text",required:true},{name:"responseStatus",type:"number"},{name:"responseBody",type:"text"},{name:"error",type:"text"},{name:"duration",type:"number"},{name:"deliveredAt",type:"date"},{name:"nextRetryAt",type:"date"}]},i=this.registry.getGlobals();if(this.db instanceof c$3&&this.db.dialect==="postgres"){let o=this.db,a=d$2.replace(/-/g,"_");o.schema&&!o.schema[a]&&(o.schema[a]=g$2);}await this.db.init([...this.registry.getCollections(),r,n,s],i),await this.loadPluginState(),this.pubsub.autoRegisterHooks();}async loadSettings(){if(this.settings)return this.settings;try{let e=await this.db.findOne({collection:"_globals_access-settings",where:{},draft:!0});e&&(this.settings={access:e});}catch{}return this.settings||{}}async loadPluginState(){let e=this.registry.storageProviders,r=e.getAllPluginNames(),n={};try{let s=await this.db.findOne({collection:"_globals_plugin-settings",where:{},draft:!0});s&&s.states&&(n=s.states);}catch{}for(let s of r)n[s]!==void 0&&e.setPluginEnabled(s,n[s]);}async getREST(e){let r=typeof this.config.auth=="object"?this.config.auth:null,n=r?.secret,s=r?.checkSession!==false;return ib({registry:this.registry,db:this.db,authSecret:n,authAdapter:this.config.authAdapter,checkSession:s,...e,cors:this.config.cors,webhookService:this.webhookService,settings:this.settings})}getGraphQL(e){let r=J$1({registry:this.registry,db:this.db,settings:this.settings});return {fetch:lf({schema:r,context:async({request:s})=>{let i=f$3(s),o,a;if(i&&this.db){let l=await e$2(i,this.db);l.user&&(o=l.user,a=g$4(l));}let c=e?.tenantId;return {db:this.db,registry:this.registry,user:o,req:s,tenantId:c,apiKey:a,relationLoader:new H$2({db:this.db,tenantId:c,user:o})}},graphiql:this.config.graphQL?.disablePlayground!==true,plugins:[]}).fetch,schema:r}}getTRPC(e){return {fetch:async(r,n)=>{let i=new URL(r.url).pathname.replace(/^\/api\/trpc\//,""),[o,...a]=i.split("."),c=a.join(".");if(c=c.replace(/\.(query|mutate|subscribe)$/,""),!o||!c)return new Response(JSON.stringify({error:{message:"Invalid tRPC path",code:-32600,data:{code:"BAD_REQUEST",httpStatus:400}}}),{status:400,headers:{"Content-Type":"application/json"}});let l=await a$4({db:this.db,registry:this.registry,req:r,user:e?.user,tenantId:e?.tenantId,settings:this.settings}),h=i$1(l)[o];if(!h)return new Response(JSON.stringify({error:{message:`Collection '${o}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});let d=h[c];if(typeof d!="function")return new Response(JSON.stringify({error:{message:`Procedure '${c}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});try{let p={};if(r.method==="POST"||r.method==="PATCH")p=await r.json().catch(()=>({}));else {let A=new URL(r.url).searchParams.get("input");if(A)try{p=JSON.parse(decodeURIComponent(A));}catch{}}let _=p?.["0"]??p,E=await d({..._,collection:o});return new Response(JSON.stringify({result:{data:E}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(p){let _=p.message||"Internal error",E=_.includes("not found")?404:_.includes("denied")||_.includes("authentication required")?403:_.includes("conflict")?409:500,A=E===404?-32601:E===403?-32001:E===409?-32002:-32603;return new Response(JSON.stringify({error:{message:_,code:A,data:{code:"INTERNAL_SERVER_ERROR",httpStatus:E}}}),{status:E,headers:{"Content-Type":"application/json"}})}},router:null}}getWS(){return this.wsServer}async startWebSocket(e){let r=this.settings?.access?.apiAccess;if(r?.wsEnabled===false)return null;let n=async o=>{let a=await e$2(o,this.db);if(!a.valid)throw new Error(a.error||"Invalid API key");if(!a.user)throw new Error("API key has no associated user");return a.user},s=e?.port||8080,i=globalThis;if(i.__KYRO_WS_SERVER__)try{await i.__KYRO_WS_SERVER__.close();}catch{}return this.wsServer=d$3({pubsub:this.pubsub,port:s,requireAuth:e?.requireAuth??r?.requireAuth,verifyToken:e?.verifyToken||n}),i.__KYRO_WS_SERVER__=this.wsServer,this.wsServer}async shutdown(){await this.pluginManager.executeHook("beforeServerStop",{kyro:this}),this.wsServer&&await this.wsServer.close(),await this.db.disconnect(),await this.pluginManager.executeHook("afterServerStop",{kyro:this});}};function Rv(t){return new Wi(t)}g();var hf={debug:0,info:1,warn:2,error:3,none:4},Ki=class{level;constructor(){let e=typeof process<"u"?process.env?.KYRO_LOG_LEVEL:void 0;this.level=e||"info";}setLevel(e){this.level=e;}getLevel(){return this.level}shouldLog(e){return hf[e]>=hf[this.level]}debug(...e){this.shouldLog("debug")&&console.debug("[Kyro DEBUG]",...e);}info(...e){this.shouldLog("info")&&console.log("[Kyro]",...e);}warn(...e){this.shouldLog("warn")&&console.warn("[Kyro WARN]",...e);}error(...e){this.shouldLog("error")&&console.error("[Kyro ERROR]",...e);}},Mv=new Ki;
57
57
  export{Rv as A,Ki as B,Mv as C,Hn as a,zn as b,Vn as c,Je as d,wo as e,y as f,ae as g,Po as h,vo as i,To as j,ko as k,Co as l,qt as m,Ld as n,Od as o,Wn as p,xe as q,br as r,Kn as s,Qn as t,Zn as u,Jn as v,Yn as w,Cg as x,og as y,Wi as z};
@@ -1,4 +1,4 @@
1
- import {createRequire}from'module';import {B as B$1,A as A$1,p,q as q$1,b,m,o,n,k as k$1,r,e,c,D as D$1,d,f,l}from'./chunk-OSAVAYJZ.js';import {g}from'./chunk-C2PXMVR5.js';import {join,sep}from'path';import {homedir}from'os';import {readFile}from'fs/promises';import {createHash}from'crypto';createRequire(import.meta.url);
1
+ import {B as B$1,A as A$1,p,q as q$1,b,m,o,n,k as k$1,r,e,c,D as D$1,d,f,l}from'./chunk-TYQYKKWJ.js';import {g}from'./chunk-Y2YAKDEQ.js';import {join,sep}from'path';import {homedir}from'os';import {readFile}from'fs/promises';import {createHash}from'crypto';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  g();var te;(function(r){r.MD5="md5",r.CRC32="crc32",r.CRC32C="crc32c",r.SHA1="sha1",r.SHA256="sha256";})(te||(te={}));g();g();var re="__smithy_context";g();g();var ye;(function(r){r.HTTP="http",r.HTTPS="https";})(ye||(ye={}));g();var _;(function(r){r.PROFILE="profile",r.SSO_SESSION="sso-session",r.SERVICES="services";})(_||(_={}));g();var H=r=>r[re]||(r[re]={});g();var Lt=r=>{if(typeof r=="function")return r;let e=Promise.resolve(r);return ()=>e};g();g();function qe(r){let e={};if(r=r.replace(/^\?/,""),r)for(let t of r.split("&")){let[o,s=null]=t.split("=");o=decodeURIComponent(o),s&&(s=decodeURIComponent(s)),o in e?Array.isArray(e[o])?e[o].push(s):e[o]=[e[o],s]:e[o]=s;}return e}var M=r=>{if(typeof r=="string")return M(new URL(r));let{hostname:e,pathname:t,port:o,protocol:s,search:n}=r,a;return n&&(a=qe(n)),{hostname:e,port:o?parseInt(o):void 0,protocol:s,path:t,query:a}};g();g();var N=class r{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||"GET",this.hostname=e.hostname||"localhost",this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)!==":"?`${e.protocol}:`:e.protocol:"https:",this.path=e.path?e.path.charAt(0)!=="/"?`/${e.path}`:e.path:"/",this.username=e.username,this.password=e.password,this.fragment=e.fragment;}static clone(e){let t=new r({...e,headers:{...e.headers}});return t.query&&(t.query=zt(t.query)),t}static isInstance(e){if(!e)return false;let t=e;return "method"in t&&"protocol"in t&&"hostname"in t&&"path"in t&&typeof t.query=="object"&&typeof t.headers=="object"}clone(){return r.clone(this)}};function zt(r){return Object.keys(r).reduce((e,t)=>{let o=r[t];return {...e,[t]:Array.isArray(o)?[...o]:o}},{})}g();var v=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body;}static isInstance(e){if(!e)return false;let t=e;return typeof t.statusCode=="number"&&typeof t.headers=="object"}};g();var Ht=new RegExp("^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$"),oe=(r,e=false)=>{if(!e)return Ht.test(r);let t=r.split(".");for(let o of t)if(!oe(o))return false;return true};g();function xe(r){return /^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(r)}g();var Te=r=>{if(typeof r=="object"){if("url"in r){let e=M(r.url);if(r.headers){e.headers={};for(let t in r.headers)e.headers[t.toLowerCase()]=r.headers[t].join(", ");}return e}return r}return M(r)};g();g();g();var se=(r,e,t,o,s)=>({name:e,namespace:r,traits:t,input:o,output:s});var Qe=r=>(e,t)=>async o=>{let{response:s}=await e(o),{operationSchema:n}=H(t),[,a,h,f,l,g]=n??[];try{let d=await r.protocol.deserializeResponse(se(a,h,f,l,g),{...r,...t},s);return {response:s,output:d}}catch(d){if(Object.defineProperty(d,"$response",{value:s,enumerable:false,writable:false,configurable:false}),!("$metadata"in d)){let E="Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.";try{d.message+=`
3
- `+E;}catch{!t.logger||t.logger?.constructor?.name==="NoOpLogger"?console.warn(E):t.logger?.warn?.(E);}typeof d.$responseBodyText<"u"&&d.$response&&(d.$response.body=d.$responseBodyText);try{if(v.isInstance(s)){let{headers:y={},statusCode:u}=s,p=Object.entries(y);d.$metadata={httpStatusCode:u,requestId:be(/^x-[\w-]+-request-?id$/,p),extendedRequestId:be(/^x-[\w-]+-id-2$/,p),cfId:be(/^x-[\w-]+-cf-id$/,p)};}}catch{}}throw d}},be=(r,e)=>(e.find(([t])=>t.match(r))||[void 0,void 0])[1];g();var Xe=r=>(e,t)=>async o=>{let{operationSchema:s}=H(t),[,n,a,h,f,l]=s??[],g=t.endpointV2?async()=>Te(t.endpointV2):r.endpoint,d=await r.protocol.serializeRequest(se(n,a,h,f,l),o.input,{...r,...t,endpoint:g});return e({...o,request:d})};var Je={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:true},Ye={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:true};function Ut(r){return {applyToStack:e=>{e.add(Xe(r),Ye),e.add(Qe(r),Je),r.protocol.setSerdeContext(r);}}}g();var U=class r{namespace;schemas;exceptions;static registries=new Map;constructor(e,t=new Map,o=new Map){this.namespace=e,this.schemas=t,this.exceptions=o;}static for(e){return r.registries.has(e)||r.registries.set(e,new r(e)),r.registries.get(e)}copyFrom(e){let{schemas:t,exceptions:o}=this;for(let[s,n]of e.schemas)t.has(s)||t.set(s,n);for(let[s,n]of e.exceptions)o.has(s)||o.set(s,n);}register(e,t){let o=this.normalizeShapeId(e);for(let s of [this,r.for(o.split("#")[0])])s.schemas.set(o,t);}getSchema(e){let t=this.normalizeShapeId(e);if(!this.schemas.has(t)){if(!e.includes("#")){let o="#"+e,s=[];for(let[n,a]of this.schemas.entries())n.endsWith(o)&&s.push(a);if(s.length===1)return s[0]}throw new Error(`@smithy/core/schema - schema not found for ${t}`)}return this.schemas.get(t)}registerError(e,t){let o=e,s=o[1];for(let n of [this,r.for(s)])n.schemas.set(s+"#"+o[2],o),n.exceptions.set(o,t);}getErrorCtor(e){let t=e;return this.exceptions.has(t)?this.exceptions.get(t):r.for(t[1]).exceptions.get(t)}getBaseException(){for(let e of this.exceptions.keys())if(Array.isArray(e)){let[,t,o]=e,s=t+"#"+o;if(s.startsWith("smithy.ts.sdk.synthetic.")&&s.endsWith("ServiceException"))return e}}find(e){for(let t of this.schemas.values())if(e(t))return t}clear(){this.schemas.clear(),this.exceptions.clear();}normalizeShapeId(e){return e.includes("#")?e:this.namespace+"#"+e}};g();g();var k=r=>typeof r=="function"?r():r;g();g();var ie=[];function w(r){if(typeof r=="object")return r;if(r=r|0,ie[r])return ie[r];let e={},t=0;for(let o of ["httpLabel","idempotent","idempotencyToken","sensitive","httpPayload","httpResponseCode","httpQueryParams"])(r>>t++&1)===1&&(e[o]=1);return ie[r]=e}var $={it:Symbol.for("@smithy/nor-struct-it"),ns:Symbol.for("@smithy/ns")},ne=[],ae={},x=class r{ref;memberName;static symbol=Symbol.for("@smithy/nor");symbol=r.symbol;name;schema;_isMemberSchema;traits;memberTraits;normalizedTraits;constructor(e,t){this.ref=e,this.memberName=t;let o=[],s=e,n=e;for(this._isMemberSchema=false;Ne(s);)o.push(s[1]),s=s[0],n=k(s),this._isMemberSchema=true;if(o.length>0){this.memberTraits={};for(let a=o.length-1;a>=0;--a){let h=o[a];Object.assign(this.memberTraits,w(h));}}else this.memberTraits=0;if(n instanceof r){let a=this.memberTraits;Object.assign(this,n),this.memberTraits=Object.assign({},a,n.getMemberTraits(),this.getMemberTraits()),this.normalizedTraits=void 0,this.memberName=t??n.memberName;return}if(this.schema=k(n),Ze(this.schema)?(this.name=`${this.schema[1]}#${this.schema[2]}`,this.traits=this.schema[3]):(this.name=this.memberName??String(n),this.traits=0),this._isMemberSchema&&!t)throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`)}static[Symbol.hasInstance](e){let t=this.prototype.isPrototypeOf(e);return !t&&typeof e=="object"&&e!==null?e.symbol===this.symbol:t}static of(e){let t=typeof e=="function"||typeof e=="object"&&e!==null;if(typeof e=="number"){if(ne[e])return ne[e]}else if(typeof e=="string"){if(ae[e])return ae[e]}else if(t&&e[$.ns])return e[$.ns];let o=k(e);if(o instanceof r)return o;if(Ne(o)){let[n,a]=o;if(n instanceof r)return Object.assign(n.getMergedTraits(),w(a)),n;throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(e,null,2)}.`)}let s=new r(o);return t?e[$.ns]=s:typeof o=="string"?ae[o]=s:typeof o=="number"?ne[o]=s:s}getSchema(){let e=this.schema;return Array.isArray(e)&&e[0]===0?e[4]:e}getName(e=false){let{name:t}=this;return !e&&t&&t.includes("#")?t.split("#")[1]:t||void 0}getMemberName(){return this.memberName}isMemberSchema(){return this._isMemberSchema}isListSchema(){let e=this.getSchema();return typeof e=="number"?e>=64&&e<128:e[0]===1}isMapSchema(){let e=this.getSchema();return typeof e=="number"?e>=128&&e<=255:e[0]===2}isStructSchema(){let e=this.getSchema();if(typeof e!="object")return false;let t=e[0];return t===3||t===-3||t===4}isUnionSchema(){let e=this.getSchema();return typeof e!="object"?false:e[0]===4}isBlobSchema(){let e=this.getSchema();return e===21||e===42}isTimestampSchema(){let e=this.getSchema();return typeof e=="number"&&e>=4&&e<=7}isUnitSchema(){return this.getSchema()==="unit"}isDocumentSchema(){return this.getSchema()===15}isStringSchema(){return this.getSchema()===0}isBooleanSchema(){return this.getSchema()===2}isNumericSchema(){return this.getSchema()===1}isBigIntegerSchema(){return this.getSchema()===17}isBigDecimalSchema(){return this.getSchema()===19}isStreaming(){let{streaming:e}=this.getMergedTraits();return !!e||this.getSchema()===42}isIdempotencyToken(){return !!this.getMergedTraits().idempotencyToken}getMergedTraits(){return this.normalizedTraits??(this.normalizedTraits={...this.getOwnTraits(),...this.getMemberTraits()})}getMemberTraits(){return w(this.memberTraits)}getOwnTraits(){return w(this.traits)}getKeySchema(){let[e,t]=[this.isDocumentSchema(),this.isMapSchema()];if(!e&&!t)throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);let o=this.getSchema(),s=e?15:o[4]??0;return V([s,0],"key")}getValueSchema(){let e=this.getSchema(),[t,o,s]=[this.isDocumentSchema(),this.isMapSchema(),this.isListSchema()],n=typeof e=="number"?63&e:e&&typeof e=="object"&&(o||s)?e[3+e[0]]:t?15:void 0;if(n!=null)return V([n,0],o?"value":"member");throw new Error(`@smithy/core/schema - ${this.getName(true)} has no value member.`)}getMemberSchema(e){let t=this.getSchema();if(this.isStructSchema()&&t[4].includes(e)){let o=t[4].indexOf(e),s=t[5][o];return V(Ne(s)?s:[s,0],e)}if(this.isDocumentSchema())return V([15,0],e);throw new Error(`@smithy/core/schema - ${this.getName(true)} has no member=${e}.`)}getMemberSchemas(){let e={};try{for(let[t,o]of this.structIterator())e[t]=o;}catch{}return e}getEventStreamMember(){if(this.isStructSchema()){for(let[e,t]of this.structIterator())if(t.isStreaming()&&t.isStructSchema())return e}return ""}*structIterator(){if(this.isUnitSchema())return;if(!this.isStructSchema())throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");let e=this.getSchema(),t=e[4].length,o=e[$.it];if(o&&t===o.length){yield*o;return}o=Array(t);for(let s=0;s<t;++s){let n=e[4][s],a=V([e[5][s],0],n);yield o[s]=[n,a];}e[$.it]=o;}};function V(r,e){if(r instanceof x)return Object.assign(r,{memberName:e,_isMemberSchema:true});let t=x;return new t(r,e)}var Ne=r=>Array.isArray(r)&&r.length===2,Ze=r=>Array.isArray(r)&&r.length>=5;g();var I=class r extends Error{name="ProviderError";tryNextLink;constructor(e,t=true){let o,s=true;typeof t=="boolean"?(o=void 0,s=t):t!=null&&typeof t=="object"&&(o=t.logger,s=t.tryNextLink??true),super(e),this.tryNextLink=s,Object.setPrototypeOf(this,r.prototype),o?.debug?.(`@smithy/property-provider ${s?"->":"(!)"} ${e}`);}static from(e,t=true){return Object.assign(new this(e.message,t),e)}};g();var P=class r extends I{name="CredentialsProviderError";constructor(e,t=true){super(e,t),Object.setPrototypeOf(this,r.prototype);}};g();var et="AWS_PROFILE",tt="default",Ce=r=>r.profile||process.env[et]||tt;g();g();g();var _e={},Vt=()=>process&&process.geteuid?`${process.geteuid()}`:"DEFAULT",F=()=>{let{HOME:r,USERPROFILE:e,HOMEPATH:t,HOMEDRIVE:o=`C:${sep}`}=process.env;if(r)return r;if(e)return e;if(t)return `${o}${t}`;let s=Vt();return _e[s]||(_e[s]=homedir()),_e[s]};var Gt="AWS_CONFIG_FILE",ce=()=>process.env[Gt]||join(F(),".aws","config");g();g();g();var rt=r=>Object.entries(r).filter(([e])=>{let t=e.indexOf(".");return t===-1?false:Object.values(_).includes(e.substring(0,t))}).reduce((e,[t,o])=>{let s=t.indexOf("."),n=t.substring(0,s)===_.PROFILE?t.substring(s+1):t;return e[n]=o,e},{...r.default&&{default:r.default}});g();var Wt="AWS_SHARED_CREDENTIALS_FILE",ot=()=>process.env[Wt]||join(F(),".aws","credentials");g();var Kt=/^([\w-]+)\s(["'])?([\w-@+.%:/]+)\2$/,qt=["__proto__","profile __proto__"],G=r=>{let e={},t,o;for(let s of r.split(/\r?\n/)){let n=s.split(/(^|\s)[;#]/)[0].trim();if(n[0]==="["&&n[n.length-1]==="]"){t=void 0,o=void 0;let h=n.substring(1,n.length-1),f=Kt.exec(h);if(f){let[,l,,g]=f;Object.values(_).includes(l)&&(t=[l,g].join("."));}else t=h;if(qt.includes(h))throw new Error(`Found invalid profile name "${h}"`)}else if(t){let h=n.indexOf("=");if(![0,-1].includes(h)){let[f,l]=[n.substring(0,h).trim(),n.substring(h+1).trim()];if(l==="")o=f;else {o&&s.trimStart()===s&&(o=void 0),e[t]=e[t]||{};let g=o?[o,f].join("."):f;e[t][g]=l;}}}}return e};g();var we={},B={},L=(r,e)=>B[r]!==void 0?B[r]:((!we[r]||e?.ignoreCache)&&(we[r]=readFile(r,"utf8")),we[r]);var it=()=>({}),me=async(r={})=>{let{filepath:e=ot(),configFilepath:t=ce()}=r,o=F(),s="~/",n=e;e.startsWith(s)&&(n=join(o,e.slice(2)));let a=t;t.startsWith(s)&&(a=join(o,t.slice(2)));let h=await Promise.all([L(a,{ignoreCache:r.ignoreCache}).then(G).then(rt).catch(it),L(n,{ignoreCache:r.ignoreCache}).then(G).catch(it)]);return {configFile:h[0],credentialsFile:h[1]}};var nt=r=>Object.entries(r).filter(([e])=>e.startsWith(_.SSO_SESSION+".")).reduce((e,[t,o])=>({...e,[t.substring(t.indexOf(".")+1)]:o}),{});var Xt=()=>({}),Jt=async(r={})=>L(r.configFilepath??ce()).then(G).then(nt).catch(Xt);g();g();var at=(...r)=>{let e={};for(let t of r)for(let[o,s]of Object.entries(t))e[o]!==void 0?Object.assign(e[o],s):e[o]=s;return e};var Yt=async r=>{let e=await me(r);return at(e.configFile,e.credentialsFile)};g();g();g();var Oe=r=>{let t=createHash("sha1").update(r).digest("hex");return join(F(),".aws","sso","cache",`${t}.json`)};var W={},rr=async r=>{if(W[r])return W[r];let e=Oe(r),t=await readFile(e,"utf8");return JSON.parse(t)};var or={getFileRecord(){return B},interceptFile(r,e){B[r]=Promise.resolve(e);},getTokenRecord(){return W},interceptToken(r,e){W[r]=e;}};g();g();var Ie=(...r)=>async()=>{if(r.length===0)throw new I("No providers in chain");let e;for(let t of r)try{return await t()}catch(o){if(e=o,o?.tryNextLink)continue;throw o}throw e};g();var fe=(r,e,t)=>{let o,s,n,a=false,h=async()=>{s||(s=r());try{o=await s,n=!0,a=!1;}finally{s=void 0;}return o};return e===void 0?async f=>((!n||f?.forceRefresh)&&(o=await h()),o):async f=>((!n||f?.forceRefresh)&&(o=await h()),a?o:t&&!t(o)?(a=true,o):(e(o)&&await h(),o))};g();g();function he(r){try{let e=new Set(Array.from(r.match(/([A-Z_]){3,}/g)??[]));return e.delete("CONFIG"),e.delete("CONFIG_PREFIX_SEPARATOR"),e.delete("ENV"),[...e].join(", ")}catch{return r}}var ct=(r,e)=>async()=>{try{let t=r(process.env,e);if(t===void 0)throw new Error;return t}catch(t){throw new P(t.message||`Not found in ENV: ${he(r.toString())}`,{logger:e?.logger})}};g();var mt=(r,{preferredFile:e="config",...t}={})=>async()=>{let o=Ce(t),{configFile:s,credentialsFile:n}=await me(t),a=n[o]||{},h=s[o]||{},f=e==="config"?{...a,...h}:{...h,...a};try{let g=r(f,e==="config"?s:n);if(g===void 0)throw new Error;return g}catch(l){throw new P(l.message||`Not found in config files w/ profile [${o}]: ${he(r.toString())}`,{logger:t.logger})}};g();g();var ft=r=>()=>Promise.resolve(r);var sr=r=>typeof r=="function",ht=r=>sr(r)?async()=>await r():ft(r);var le=({environmentVariableSelector:r,configFileSelector:e,default:t},o={})=>{let{signingName:s,logger:n}=o;return fe(Ie(ct(r,{signingName:s,logger:n}),mt(e,o),ht(t)))};g();g();var lt=new Set,pt=(r,e=oe)=>{if(!lt.has(r)&&!e(r))if(r==="*")console.warn('@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.');else throw new Error(`Region not accepted: region="${r}" is not a valid hostname component.`);else lt.add(r);};g();g();var pe=r=>typeof r=="string"&&(r.startsWith("fips-")||r.endsWith("-fips"));var dt=r=>pe(r)?["fips-aws-global","aws-fips"].includes(r)?"us-east-1":r.replace(/fips-(dkr-|prod-)?|-fips/,""):r;var ir=r=>{let{region:e,useFipsEndpoint:t}=r;if(!e)throw new Error("Region is missing");return Object.assign(r,{region:async()=>{let o=typeof e=="function"?await e():e,s=dt(o);return pt(s),s},useFipsEndpoint:async()=>{let o=typeof e=="string"?e:await e();return pe(o)?true:typeof t!="function"?Promise.resolve(!!t):t()}})};g();g();var Ae=class r extends I{name="TokenProviderError";constructor(e,t=true){super(e,t),Object.setPrototypeOf(this,r.prototype);}};g();var R=(r,e,t)=>{if(e in r){if(r[e]==="true")return true;if(r[e]==="false")return false;throw new Error(`Cannot load ${t} "${e}". Expected "true" or "false", got ${r[e]}.`)}};g();var A;(function(r){r.ENV="env",r.CONFIG="shared config entry";})(A||(A={}));g();var ut="AWS_USE_DUALSTACK_ENDPOINT",gt="use_dualstack_endpoint";var nr={environmentVariableSelector:r=>R(r,ut,A.ENV),configFileSelector:r=>R(r,gt,A.CONFIG),default:false};g();var St="AWS_USE_FIPS_ENDPOINT",Et="use_fips_endpoint";var ar={environmentVariableSelector:r=>R(r,St,A.ENV),configFileSelector:r=>R(r,Et,A.CONFIG),default:false};g();g();g();var yt="AWS_EXECUTION_ENV",De="AWS_REGION",ve="AWS_DEFAULT_REGION",xt="AWS_EC2_METADATA_DISABLED",Tt=["in-region","cross-region","mobile","standard","legacy"],bt="/latest/meta-data/placement/region",Nt="/latest/api/token",Ct="x-aws-ec2-metadata-token",_t="x-aws-ec2-metadata-token-ttl-seconds";var wt=1e3,cr=6e4,At=0,de=async()=>{if(!process.env[xt]&&!(Date.now()<At))try{let r=mr(),e=(await It({...r,path:Nt,method:"PUT",headers:{[_t]:"21600"}})).toString();return (await It({...r,path:bt,method:"GET",headers:{[Ct]:e}})).toString().trim()||Ot()}catch{return Ot()}},Ot=()=>{At=Date.now()+cr;},mr=()=>{let r=process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;if(r){let e=new URL(r);return {hostname:e.hostname.replace(/^\[(.+)]$/,"$1"),port:e.port?Number(e.port):void 0}}return process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE==="IPv6"?{hostname:"fd00:ec2::254"}:{hostname:"169.254.169.254"}},It=async r=>{let{request:e}=await import('http');return new Promise((t,o)=>{let s=e({hostname:r.hostname,port:r.port,path:r.path,method:r.method,headers:r.headers,timeout:wt,signal:AbortSignal.timeout(wt)});s.on("error",n=>{o(n),s.destroy();}),s.on("timeout",()=>{o(new Error("TimeoutError from instance metadata service")),s.destroy();}),s.on("response",n=>{let{statusCode:a=400}=n;if(a<200||a>=300){o(Object.assign(new Error("Error response received from instance metadata service"),{statusCode:a})),s.destroy();return}let h=[];n.on("data",f=>h.push(f)),n.on("end",()=>{t(Buffer.concat(h)),s.destroy();});}),s.end();})};var Dt="AWS_REGION",vt="region",Fe={environmentVariableSelector:r=>r[Dt],configFileSelector:r=>r[vt],default:async()=>{let r=await de();if(r)return r;throw new Error("Region is missing")}},fr={preferredFile:"credentials"};g();g();var hr="AWS_DEFAULTS_MODE",lr="defaults_mode",Ft={environmentVariableSelector:r=>r[hr],configFileSelector:r=>r[lr],default:"legacy"};var pr=({region:r=le(Fe),defaultsMode:e=le(Ft)}={})=>fe(async()=>{let t=typeof e=="function"?await e():e;switch(t?.toLowerCase()){case "auto":return dr(r);case "in-region":case "cross-region":case "mobile":case "standard":case "legacy":return Promise.resolve(t?.toLocaleLowerCase());case void 0:return Promise.resolve("legacy");default:throw new Error(`Invalid parameter for "defaultsMode", expect ${Tt.join(", ")}, got ${t}`)}}),dr=async r=>{if(r){let e=typeof r=="function"?await r():r,t=await ur();return t?e===t?"in-region":"cross-region":"standard"}return "standard"},ur=async()=>process.env[yt]&&(process.env[De]||process.env[ve])?process.env[De]??process.env[ve]:de();g();var Pt="content-length";function Rt(r){return e=>async t=>{let o=t.request;if(N.isInstance(o)){let{body:s,headers:n}=o;if(s&&Object.keys(n).map(a=>a.toLowerCase()).indexOf(Pt)===-1)try{let a=r(s);o.headers={...o.headers,[Pt]:String(a)};}catch{}}return e({...t,request:o})}}var Mt={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:true},gr=r=>({applyToStack:e=>{e.add(Rt(r.bodyLengthChecker),Mt);}});g();g();var D=async(r=new Uint8Array,e)=>{if(r instanceof Uint8Array)return B$1.mutate(r);if(!r)return B$1.mutate(new Uint8Array);let t=e.streamCollector(r);return B$1.mutate(await t)};g();function ue(r){return encodeURIComponent(r).replace(/[!'()*]/g,function(e){return "%"+e.charCodeAt(0).toString(16).toUpperCase()})}g();g();g();var O=class{serdeContext;setSerdeContext(e){this.serdeContext=e;}};var z=class extends O{options;compositeErrorRegistry;constructor(e){super(),this.options=e,this.compositeErrorRegistry=U.for(e.defaultNamespace);for(let t of e.errorTypeRegistries??[])this.compositeErrorRegistry.copyFrom(t);}getRequestType(){return N}getResponseType(){return v}setSerdeContext(e){this.serdeContext=e,this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e),this.getPayloadCodec()&&this.getPayloadCodec().setSerdeContext(e);}updateServiceEndpoint(e,t){if("url"in t){e.protocol=t.url.protocol,e.hostname=t.url.hostname,e.port=t.url.port?Number(t.url.port):void 0,e.path=t.url.pathname,e.fragment=t.url.hash||void 0,e.username=t.url.username||void 0,e.password=t.url.password||void 0,e.query||(e.query={});for(let[o,s]of t.url.searchParams.entries())e.query[o]=s;if(t.headers)for(let o in t.headers)e.headers[o]=t.headers[o].join(", ");return e}else {if(e.protocol=t.protocol,e.hostname=t.hostname,e.port=t.port?Number(t.port):void 0,e.path=t.path,e.query={...t.query},t.headers)for(let o in t.headers)e.headers[o]=t.headers[o];return e}}setHostPrefix(e,t,o){if(this.serdeContext?.disableHostPrefix)return;let s=x.of(t.input),n=w(t.traits??{});if(n.endpoint){let a=n.endpoint?.[0];if(typeof a=="string"){for(let[h,f]of s.structIterator()){if(!f.getMergedTraits().hostLabel)continue;let l=o[h];if(typeof l!="string")throw new Error(`@smithy/core/schema - ${h} in input must be a string as hostLabel.`);a=a.replace(`{${h}}`,l);}if(e.hostname=a+e.hostname,!xe(e.hostname))throw new Error(`[${e.hostname}] is not a valid hostname.`)}}}deserializeMetadata(e){return {httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}}async serializeEventStream({eventStream:e,requestSchema:t,initialRequest:o}){return (await this.loadEventStreamCapability()).serializeEventStream({eventStream:e,requestSchema:t,initialRequest:o})}async deserializeEventStream({response:e,responseSchema:t,initialResponseContainer:o}){return (await this.loadEventStreamCapability()).deserializeEventStream({response:e,responseSchema:t,initialResponseContainer:o})}async loadEventStreamCapability(){let{EventStreamSerde:e,eventStreamSerdeProvider:t}=await import('./event-streams-25YJ2Z6R.js'),o=this.resolveEventStreamMarshaller(t);return new e({marshaller:o,serializer:this.serializer,deserializer:this.deserializer,serdeContext:this.serdeContext,defaultContentType:this.getDefaultContentType()})}resolveEventStreamMarshaller(e){let t=this.serdeContext;return t.eventStreamMarshaller?t.eventStreamMarshaller:e(this.serdeContext)}getDefaultContentType(){throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`)}async deserializeHttpMessage(e,t,o,s,n){return []}getEventStreamMarshaller(){let e=this.serdeContext;if(!e.eventStreamMarshaller)throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");return e.eventStreamMarshaller}};var Pe=class extends z{async serializeRequest(e,t,o){let s=t&&typeof t=="object"?t:{},n=this.serializer,a={},h={},f=await o.endpoint(),l=x.of(e?.input),g=[],d=[],E=false,y,u=new N({protocol:"",hostname:"",port:void 0,path:"",fragment:void 0,query:a,headers:h,body:void 0});if(f){this.updateServiceEndpoint(u,f),this.setHostPrefix(u,e,s);let p=w(e.traits);if(p.http){u.method=p.http[0];let[S,T]=p.http[1].split("?");u.path=="/"?u.path=S:u.path+=S;let b=new URLSearchParams(T??"");for(let[C,X]of b)a[C]=X;}}for(let[p,S]of l.structIterator()){let T=S.getMergedTraits()??{},b=s[p];if(b==null&&!S.isIdempotencyToken()){if(T.httpLabel&&(u.path.includes(`{${p}+}`)||u.path.includes(`{${p}}`)))throw new Error(`No value provided for input HTTP label: ${p}.`);continue}if(T.httpPayload)S.isStreaming()?S.isStructSchema()?s[p]&&(y=await this.serializeEventStream({eventStream:s[p],requestSchema:l})):y=b:(n.write(S,b),y=n.flush());else if(T.httpLabel){n.write(S,b);let C=n.flush();u.path.includes(`{${p}+}`)?u.path=u.path.replace(`{${p}+}`,C.split("/").map(ue).join("/")):u.path.includes(`{${p}}`)&&(u.path=u.path.replace(`{${p}}`,ue(C)));}else if(T.httpHeader)n.write(S,b),h[T.httpHeader.toLowerCase()]=String(n.flush());else if(typeof T.httpPrefixHeaders=="string")for(let C in b){let X=b[C],ze=T.httpPrefixHeaders+C;n.write([S.getValueSchema(),{httpHeader:ze}],X),h[ze.toLowerCase()]=n.flush();}else T.httpQuery||T.httpQueryParams?this.serializeQuery(S,b,a):(E=true,g.push(p),d.push(S));}if(E&&s){let[p,S]=(l.getName(true)??"#Unknown").split("#"),T=l.getSchema()[6],b=[3,p,S,l.getMergedTraits(),g,d,void 0];T?b[6]=T:b.pop(),n.write(b,s),y=n.flush();}return u.headers=h,u.query=a,u.body=y,u}serializeQuery(e,t,o){let s=this.serializer,n=e.getMergedTraits();if(n.httpQueryParams){for(let a in t)if(!(a in o)){let h=t[a],f=e.getValueSchema();Object.assign(f.getMergedTraits(),{...n,httpQuery:a,httpQueryParams:void 0}),this.serializeQuery(f,h,o);}return}if(e.isListSchema()){let a=!!e.getMergedTraits().sparse,h=[];for(let f of t){s.write([e.getValueSchema(),n],f);let l=s.flush();(a||l!==void 0)&&h.push(l);}o[n.httpQuery]=h;}else s.write([e,n],t),o[n.httpQuery]=s.flush();}async deserializeResponse(e,t,o){let s=this.deserializer,n=x.of(e.output),a={};if(o.statusCode>=300){let f=await D(o.body,t);throw f.byteLength>0&&Object.assign(a,await s.read(15,f)),await this.handleError(e,t,o,a,this.deserializeMetadata(o)),new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.")}for(let f in o.headers){let l=o.headers[f];delete o.headers[f],o.headers[f.toLowerCase()]=l;}let h=await this.deserializeHttpMessage(n,t,o,a);if(h.length){let f=await D(o.body,t);if(f.byteLength>0){let l=await s.read(n,f);for(let g of h)l[g]!=null&&(a[g]=l[g]);}}else h.discardResponseBody&&await D(o.body,t);return a.$metadata=this.deserializeMetadata(o),a}async deserializeHttpMessage(e,t,o,s,n){let a;s instanceof Set?a=n:a=s;let h=true,f=this.deserializer,l=x.of(e),g=[];for(let[d,E]of l.structIterator()){let y=E.getMemberTraits();if(y.httpPayload){if(h=false,E.isStreaming())E.isStructSchema()?a[d]=await this.deserializeEventStream({response:o,responseSchema:l}):a[d]=A$1(o.body);else if(o.body){let p=await D(o.body,t);p.byteLength>0&&(a[d]=await f.read(E,p));}}else if(y.httpHeader){let u=String(y.httpHeader).toLowerCase(),p$1=o.headers[u];if(p$1!=null)if(E.isListSchema()){let S=E.getValueSchema();S.getMergedTraits().httpHeader=u;let T;S.isTimestampSchema()&&S.getSchema()===4?T=p(p$1,",",2):T=q$1(p$1);let b=[];for(let C of T)b.push(await f.read(S,C.trim()));a[d]=b;}else a[d]=await f.read(E,p$1);}else if(y.httpPrefixHeaders!==void 0){a[d]={};for(let u in o.headers)if(u.startsWith(y.httpPrefixHeaders)){let p=o.headers[u],S=E.getValueSchema();S.getMergedTraits().httpHeader=u,a[d][u.slice(y.httpPrefixHeaders.length)]=await f.read(S,p);}}else y.httpResponseCode?a[d]=o.statusCode:g.push(d);}return g.discardResponseBody=h,g}};g();var Re=class extends z{async serializeRequest(e,t,o){let s=this.serializer,n={},a={},h=await o.endpoint(),f=x.of(e?.input),l=f.getSchema(),g,d=t&&typeof t=="object"?t:{},E=new N({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:n,headers:a,body:void 0});if(h&&(this.updateServiceEndpoint(E,h),this.setHostPrefix(E,e,d)),d){let y=f.getEventStreamMember();if(y){if(d[y]){let u={};for(let[p,S]of f.structIterator())p!==y&&d[p]&&(s.write(S,d[p]),u[p]=s.flush());g=await this.serializeEventStream({eventStream:d[y],requestSchema:f,initialRequest:u});}}else s.write(l,d),g=s.flush();}return E.headers=Object.assign(E.headers,a),E.query=n,E.body=g,E.method="POST",E}async deserializeResponse(e,t,o){let s=this.deserializer,n=x.of(e.output),a={};if(o.statusCode>=300){let f=await D(o.body,t);throw f.byteLength>0&&Object.assign(a,await s.read(15,f)),await this.handleError(e,t,o,a,this.deserializeMetadata(o)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(let f in o.headers){let l=o.headers[f];delete o.headers[f],o.headers[f.toLowerCase()]=l;}let h=n.getEventStreamMember();if(h)a[h]=await this.deserializeEventStream({response:o,responseSchema:n,initialResponseContainer:a});else {let f=await D(o.body,t);f.byteLength>0&&Object.assign(a,await s.read(n,f));}return a.$metadata=this.deserializeMetadata(o),a}};g();g();function K(r,e){if(e.timestampFormat.useTrait&&r.isTimestampSchema()&&(r.getSchema()===5||r.getSchema()===6||r.getSchema()===7))return r.getSchema();let{httpLabel:t,httpPrefixHeaders:o,httpHeader:s,httpQuery:n}=r.getMergedTraits();return (e.httpBindings?typeof o=="string"||s?6:n||t?5:void 0:void 0)??e.timestampFormat.default}var q=class extends O{settings;constructor(e){super(),this.settings=e;}read(e,t){let o$1=x.of(e);if(o$1.isListSchema())return q$1(t).map(s=>this.read(o$1.getValueSchema(),s));if(o$1.isBlobSchema())return (this.serdeContext?.base64Decoder??b)(t);if(o$1.isTimestampSchema())switch(K(o$1,this.settings)){case 5:return n(t);case 6:return o(t);case 7:return m(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(o$1.isStringSchema()){let s=o$1.getMergedTraits().mediaType,n=t;if(s)return o$1.getMergedTraits().httpHeader&&(n=this.base64ToUtf8(n)),(s==="application/json"||s.endsWith("+json"))&&(n=k$1.from(n)),n}return o$1.isNumericSchema()?Number(t):o$1.isBigIntegerSchema()?BigInt(t):o$1.isBigDecimalSchema()?new r(t,"bigDecimal"):o$1.isBooleanSchema()?String(t).toLowerCase()==="true":t}base64ToUtf8(e$1){return (this.serdeContext?.utf8Encoder??e)((this.serdeContext?.base64Decoder??b)(e$1))}};g();var Me=class extends O{codecDeserializer;stringDeserializer;constructor(e,t){super(),this.codecDeserializer=e,this.stringDeserializer=new q(t);}setSerdeContext(e){this.stringDeserializer.setSerdeContext(e),this.codecDeserializer.setSerdeContext(e),this.serdeContext=e;}read(e$1,t){let o=x.of(e$1),s=o.getMergedTraits(),n=this.serdeContext?.utf8Encoder??e;if(s.httpHeader||s.httpResponseCode)return this.stringDeserializer.read(o,n(t));if(s.httpPayload){if(o.isBlobSchema()){let a=this.serdeContext?.utf8Decoder??c;return typeof t=="string"?a(t):t}else if(o.isStringSchema())return "byteLength"in t?n(t):t}return this.codecDeserializer.read(o,t)}};g();g();var ge=class extends O{settings;stringBuffer="";constructor(e){super(),this.settings=e;}write(e,t){let o=x.of(e);switch(typeof t){case "object":if(t===null){this.stringBuffer="null";return}if(o.isTimestampSchema()){if(!(t instanceof Date))throw new Error(`@smithy/core/protocols - received non-Date value ${t} when schema expected Date in ${o.getName(true)}`);switch(K(o,this.settings)){case 5:this.stringBuffer=t.toISOString().replace(".000Z","Z");break;case 6:this.stringBuffer=f(t);break;case 7:this.stringBuffer=String(t.getTime()/1e3);break;default:console.warn("Missing timestamp format, using epoch seconds",t),this.stringBuffer=String(t.getTime()/1e3);}return}if(o.isBlobSchema()&&"byteLength"in t){this.stringBuffer=(this.serdeContext?.base64Encoder??d)(t);return}if(o.isListSchema()&&Array.isArray(t)){let a="";for(let h of t){this.write([o.getValueSchema(),o.getMergedTraits()],h);let f=this.flush(),l$1=o.getValueSchema().isTimestampSchema()?f:l(f);a!==""&&(a+=", "),a+=l$1;}this.stringBuffer=a;return}this.stringBuffer=JSON.stringify(t,null,2);break;case "string":let s=o.getMergedTraits().mediaType,n=t;if(s&&((s==="application/json"||s.endsWith("+json"))&&(n=k$1.from(n)),o.getMergedTraits().httpHeader)){this.stringBuffer=(this.serdeContext?.base64Encoder??d)(n.toString());return}this.stringBuffer=t;break;default:o.isIdempotencyToken()?this.stringBuffer=D$1():this.stringBuffer=String(t);}}flush(){let e=this.stringBuffer;return this.stringBuffer="",e}};var Le=class{codecSerializer;stringSerializer;buffer;constructor(e,t,o=new ge(t)){this.codecSerializer=e,this.stringSerializer=o;}setSerdeContext(e){this.codecSerializer.setSerdeContext(e),this.stringSerializer.setSerdeContext(e);}write(e,t){let o=x.of(e),s=o.getMergedTraits();if(s.httpHeader||s.httpLabel||s.httpQuery){this.stringSerializer.write(o,t),this.buffer=this.stringSerializer.flush();return}return this.codecSerializer.write(o,t)}flush(){if(this.buffer!==void 0){let e=this.buffer;return this.buffer=void 0,e}return this.codecSerializer.flush()}};g();var Sr=r=>({setHttpHandler(e){r.httpHandler=e;},httpHandler(){return r.httpHandler},updateHttpClientConfig(e,t){r.httpHandler?.updateHttpClientConfig(e,t);},httpHandlerConfigs(){return r.httpHandler.httpHandlerConfigs()}}),Er=r=>({httpHandler:r.httpHandler()});g();var Q=r=>encodeURIComponent(r).replace(/[!'()*]/g,yr),yr=r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`;g();function xr(r){let e=[];for(let t of Object.keys(r).sort()){let o=r[t];if(t=Q(t),Array.isArray(o))for(let s=0,n=o.length;s<n;s++)e.push(`${t}=${Q(o[s])}`);else {let s=t;(o||typeof o=="string")&&(s+=`=${Q(o)}`),e.push(s);}}return e.join("&")}
3
+ `+E;}catch{!t.logger||t.logger?.constructor?.name==="NoOpLogger"?console.warn(E):t.logger?.warn?.(E);}typeof d.$responseBodyText<"u"&&d.$response&&(d.$response.body=d.$responseBodyText);try{if(v.isInstance(s)){let{headers:y={},statusCode:u}=s,p=Object.entries(y);d.$metadata={httpStatusCode:u,requestId:be(/^x-[\w-]+-request-?id$/,p),extendedRequestId:be(/^x-[\w-]+-id-2$/,p),cfId:be(/^x-[\w-]+-cf-id$/,p)};}}catch{}}throw d}},be=(r,e)=>(e.find(([t])=>t.match(r))||[void 0,void 0])[1];g();var Xe=r=>(e,t)=>async o=>{let{operationSchema:s}=H(t),[,n,a,h,f,l]=s??[],g=t.endpointV2?async()=>Te(t.endpointV2):r.endpoint,d=await r.protocol.serializeRequest(se(n,a,h,f,l),o.input,{...r,...t,endpoint:g});return e({...o,request:d})};var Je={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:true},Ye={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:true};function Ut(r){return {applyToStack:e=>{e.add(Xe(r),Ye),e.add(Qe(r),Je),r.protocol.setSerdeContext(r);}}}g();var U=class r{namespace;schemas;exceptions;static registries=new Map;constructor(e,t=new Map,o=new Map){this.namespace=e,this.schemas=t,this.exceptions=o;}static for(e){return r.registries.has(e)||r.registries.set(e,new r(e)),r.registries.get(e)}copyFrom(e){let{schemas:t,exceptions:o}=this;for(let[s,n]of e.schemas)t.has(s)||t.set(s,n);for(let[s,n]of e.exceptions)o.has(s)||o.set(s,n);}register(e,t){let o=this.normalizeShapeId(e);for(let s of [this,r.for(o.split("#")[0])])s.schemas.set(o,t);}getSchema(e){let t=this.normalizeShapeId(e);if(!this.schemas.has(t)){if(!e.includes("#")){let o="#"+e,s=[];for(let[n,a]of this.schemas.entries())n.endsWith(o)&&s.push(a);if(s.length===1)return s[0]}throw new Error(`@smithy/core/schema - schema not found for ${t}`)}return this.schemas.get(t)}registerError(e,t){let o=e,s=o[1];for(let n of [this,r.for(s)])n.schemas.set(s+"#"+o[2],o),n.exceptions.set(o,t);}getErrorCtor(e){let t=e;return this.exceptions.has(t)?this.exceptions.get(t):r.for(t[1]).exceptions.get(t)}getBaseException(){for(let e of this.exceptions.keys())if(Array.isArray(e)){let[,t,o]=e,s=t+"#"+o;if(s.startsWith("smithy.ts.sdk.synthetic.")&&s.endsWith("ServiceException"))return e}}find(e){for(let t of this.schemas.values())if(e(t))return t}clear(){this.schemas.clear(),this.exceptions.clear();}normalizeShapeId(e){return e.includes("#")?e:this.namespace+"#"+e}};g();g();var k=r=>typeof r=="function"?r():r;g();g();var ie=[];function w(r){if(typeof r=="object")return r;if(r=r|0,ie[r])return ie[r];let e={},t=0;for(let o of ["httpLabel","idempotent","idempotencyToken","sensitive","httpPayload","httpResponseCode","httpQueryParams"])(r>>t++&1)===1&&(e[o]=1);return ie[r]=e}var $={it:Symbol.for("@smithy/nor-struct-it"),ns:Symbol.for("@smithy/ns")},ne=[],ae={},x=class r{ref;memberName;static symbol=Symbol.for("@smithy/nor");symbol=r.symbol;name;schema;_isMemberSchema;traits;memberTraits;normalizedTraits;constructor(e,t){this.ref=e,this.memberName=t;let o=[],s=e,n=e;for(this._isMemberSchema=false;Ne(s);)o.push(s[1]),s=s[0],n=k(s),this._isMemberSchema=true;if(o.length>0){this.memberTraits={};for(let a=o.length-1;a>=0;--a){let h=o[a];Object.assign(this.memberTraits,w(h));}}else this.memberTraits=0;if(n instanceof r){let a=this.memberTraits;Object.assign(this,n),this.memberTraits=Object.assign({},a,n.getMemberTraits(),this.getMemberTraits()),this.normalizedTraits=void 0,this.memberName=t??n.memberName;return}if(this.schema=k(n),Ze(this.schema)?(this.name=`${this.schema[1]}#${this.schema[2]}`,this.traits=this.schema[3]):(this.name=this.memberName??String(n),this.traits=0),this._isMemberSchema&&!t)throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`)}static[Symbol.hasInstance](e){let t=this.prototype.isPrototypeOf(e);return !t&&typeof e=="object"&&e!==null?e.symbol===this.symbol:t}static of(e){let t=typeof e=="function"||typeof e=="object"&&e!==null;if(typeof e=="number"){if(ne[e])return ne[e]}else if(typeof e=="string"){if(ae[e])return ae[e]}else if(t&&e[$.ns])return e[$.ns];let o=k(e);if(o instanceof r)return o;if(Ne(o)){let[n,a]=o;if(n instanceof r)return Object.assign(n.getMergedTraits(),w(a)),n;throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(e,null,2)}.`)}let s=new r(o);return t?e[$.ns]=s:typeof o=="string"?ae[o]=s:typeof o=="number"?ne[o]=s:s}getSchema(){let e=this.schema;return Array.isArray(e)&&e[0]===0?e[4]:e}getName(e=false){let{name:t}=this;return !e&&t&&t.includes("#")?t.split("#")[1]:t||void 0}getMemberName(){return this.memberName}isMemberSchema(){return this._isMemberSchema}isListSchema(){let e=this.getSchema();return typeof e=="number"?e>=64&&e<128:e[0]===1}isMapSchema(){let e=this.getSchema();return typeof e=="number"?e>=128&&e<=255:e[0]===2}isStructSchema(){let e=this.getSchema();if(typeof e!="object")return false;let t=e[0];return t===3||t===-3||t===4}isUnionSchema(){let e=this.getSchema();return typeof e!="object"?false:e[0]===4}isBlobSchema(){let e=this.getSchema();return e===21||e===42}isTimestampSchema(){let e=this.getSchema();return typeof e=="number"&&e>=4&&e<=7}isUnitSchema(){return this.getSchema()==="unit"}isDocumentSchema(){return this.getSchema()===15}isStringSchema(){return this.getSchema()===0}isBooleanSchema(){return this.getSchema()===2}isNumericSchema(){return this.getSchema()===1}isBigIntegerSchema(){return this.getSchema()===17}isBigDecimalSchema(){return this.getSchema()===19}isStreaming(){let{streaming:e}=this.getMergedTraits();return !!e||this.getSchema()===42}isIdempotencyToken(){return !!this.getMergedTraits().idempotencyToken}getMergedTraits(){return this.normalizedTraits??(this.normalizedTraits={...this.getOwnTraits(),...this.getMemberTraits()})}getMemberTraits(){return w(this.memberTraits)}getOwnTraits(){return w(this.traits)}getKeySchema(){let[e,t]=[this.isDocumentSchema(),this.isMapSchema()];if(!e&&!t)throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);let o=this.getSchema(),s=e?15:o[4]??0;return V([s,0],"key")}getValueSchema(){let e=this.getSchema(),[t,o,s]=[this.isDocumentSchema(),this.isMapSchema(),this.isListSchema()],n=typeof e=="number"?63&e:e&&typeof e=="object"&&(o||s)?e[3+e[0]]:t?15:void 0;if(n!=null)return V([n,0],o?"value":"member");throw new Error(`@smithy/core/schema - ${this.getName(true)} has no value member.`)}getMemberSchema(e){let t=this.getSchema();if(this.isStructSchema()&&t[4].includes(e)){let o=t[4].indexOf(e),s=t[5][o];return V(Ne(s)?s:[s,0],e)}if(this.isDocumentSchema())return V([15,0],e);throw new Error(`@smithy/core/schema - ${this.getName(true)} has no member=${e}.`)}getMemberSchemas(){let e={};try{for(let[t,o]of this.structIterator())e[t]=o;}catch{}return e}getEventStreamMember(){if(this.isStructSchema()){for(let[e,t]of this.structIterator())if(t.isStreaming()&&t.isStructSchema())return e}return ""}*structIterator(){if(this.isUnitSchema())return;if(!this.isStructSchema())throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");let e=this.getSchema(),t=e[4].length,o=e[$.it];if(o&&t===o.length){yield*o;return}o=Array(t);for(let s=0;s<t;++s){let n=e[4][s],a=V([e[5][s],0],n);yield o[s]=[n,a];}e[$.it]=o;}};function V(r,e){if(r instanceof x)return Object.assign(r,{memberName:e,_isMemberSchema:true});let t=x;return new t(r,e)}var Ne=r=>Array.isArray(r)&&r.length===2,Ze=r=>Array.isArray(r)&&r.length>=5;g();var I=class r extends Error{name="ProviderError";tryNextLink;constructor(e,t=true){let o,s=true;typeof t=="boolean"?(o=void 0,s=t):t!=null&&typeof t=="object"&&(o=t.logger,s=t.tryNextLink??true),super(e),this.tryNextLink=s,Object.setPrototypeOf(this,r.prototype),o?.debug?.(`@smithy/property-provider ${s?"->":"(!)"} ${e}`);}static from(e,t=true){return Object.assign(new this(e.message,t),e)}};g();var P=class r extends I{name="CredentialsProviderError";constructor(e,t=true){super(e,t),Object.setPrototypeOf(this,r.prototype);}};g();var et="AWS_PROFILE",tt="default",Ce=r=>r.profile||process.env[et]||tt;g();g();g();var _e={},Vt=()=>process&&process.geteuid?`${process.geteuid()}`:"DEFAULT",F=()=>{let{HOME:r,USERPROFILE:e,HOMEPATH:t,HOMEDRIVE:o=`C:${sep}`}=process.env;if(r)return r;if(e)return e;if(t)return `${o}${t}`;let s=Vt();return _e[s]||(_e[s]=homedir()),_e[s]};var Gt="AWS_CONFIG_FILE",ce=()=>process.env[Gt]||join(F(),".aws","config");g();g();g();var rt=r=>Object.entries(r).filter(([e])=>{let t=e.indexOf(".");return t===-1?false:Object.values(_).includes(e.substring(0,t))}).reduce((e,[t,o])=>{let s=t.indexOf("."),n=t.substring(0,s)===_.PROFILE?t.substring(s+1):t;return e[n]=o,e},{...r.default&&{default:r.default}});g();var Wt="AWS_SHARED_CREDENTIALS_FILE",ot=()=>process.env[Wt]||join(F(),".aws","credentials");g();var Kt=/^([\w-]+)\s(["'])?([\w-@+.%:/]+)\2$/,qt=["__proto__","profile __proto__"],G=r=>{let e={},t,o;for(let s of r.split(/\r?\n/)){let n=s.split(/(^|\s)[;#]/)[0].trim();if(n[0]==="["&&n[n.length-1]==="]"){t=void 0,o=void 0;let h=n.substring(1,n.length-1),f=Kt.exec(h);if(f){let[,l,,g]=f;Object.values(_).includes(l)&&(t=[l,g].join("."));}else t=h;if(qt.includes(h))throw new Error(`Found invalid profile name "${h}"`)}else if(t){let h=n.indexOf("=");if(![0,-1].includes(h)){let[f,l]=[n.substring(0,h).trim(),n.substring(h+1).trim()];if(l==="")o=f;else {o&&s.trimStart()===s&&(o=void 0),e[t]=e[t]||{};let g=o?[o,f].join("."):f;e[t][g]=l;}}}}return e};g();var we={},B={},L=(r,e)=>B[r]!==void 0?B[r]:((!we[r]||e?.ignoreCache)&&(we[r]=readFile(r,"utf8")),we[r]);var it=()=>({}),me=async(r={})=>{let{filepath:e=ot(),configFilepath:t=ce()}=r,o=F(),s="~/",n=e;e.startsWith(s)&&(n=join(o,e.slice(2)));let a=t;t.startsWith(s)&&(a=join(o,t.slice(2)));let h=await Promise.all([L(a,{ignoreCache:r.ignoreCache}).then(G).then(rt).catch(it),L(n,{ignoreCache:r.ignoreCache}).then(G).catch(it)]);return {configFile:h[0],credentialsFile:h[1]}};var nt=r=>Object.entries(r).filter(([e])=>e.startsWith(_.SSO_SESSION+".")).reduce((e,[t,o])=>({...e,[t.substring(t.indexOf(".")+1)]:o}),{});var Xt=()=>({}),Jt=async(r={})=>L(r.configFilepath??ce()).then(G).then(nt).catch(Xt);g();g();var at=(...r)=>{let e={};for(let t of r)for(let[o,s]of Object.entries(t))e[o]!==void 0?Object.assign(e[o],s):e[o]=s;return e};var Yt=async r=>{let e=await me(r);return at(e.configFile,e.credentialsFile)};g();g();g();var Oe=r=>{let t=createHash("sha1").update(r).digest("hex");return join(F(),".aws","sso","cache",`${t}.json`)};var W={},rr=async r=>{if(W[r])return W[r];let e=Oe(r),t=await readFile(e,"utf8");return JSON.parse(t)};var or={getFileRecord(){return B},interceptFile(r,e){B[r]=Promise.resolve(e);},getTokenRecord(){return W},interceptToken(r,e){W[r]=e;}};g();g();var Ie=(...r)=>async()=>{if(r.length===0)throw new I("No providers in chain");let e;for(let t of r)try{return await t()}catch(o){if(e=o,o?.tryNextLink)continue;throw o}throw e};g();var fe=(r,e,t)=>{let o,s,n,a=false,h=async()=>{s||(s=r());try{o=await s,n=!0,a=!1;}finally{s=void 0;}return o};return e===void 0?async f=>((!n||f?.forceRefresh)&&(o=await h()),o):async f=>((!n||f?.forceRefresh)&&(o=await h()),a?o:t&&!t(o)?(a=true,o):(e(o)&&await h(),o))};g();g();function he(r){try{let e=new Set(Array.from(r.match(/([A-Z_]){3,}/g)??[]));return e.delete("CONFIG"),e.delete("CONFIG_PREFIX_SEPARATOR"),e.delete("ENV"),[...e].join(", ")}catch{return r}}var ct=(r,e)=>async()=>{try{let t=r(process.env,e);if(t===void 0)throw new Error;return t}catch(t){throw new P(t.message||`Not found in ENV: ${he(r.toString())}`,{logger:e?.logger})}};g();var mt=(r,{preferredFile:e="config",...t}={})=>async()=>{let o=Ce(t),{configFile:s,credentialsFile:n}=await me(t),a=n[o]||{},h=s[o]||{},f=e==="config"?{...a,...h}:{...h,...a};try{let g=r(f,e==="config"?s:n);if(g===void 0)throw new Error;return g}catch(l){throw new P(l.message||`Not found in config files w/ profile [${o}]: ${he(r.toString())}`,{logger:t.logger})}};g();g();var ft=r=>()=>Promise.resolve(r);var sr=r=>typeof r=="function",ht=r=>sr(r)?async()=>await r():ft(r);var le=({environmentVariableSelector:r,configFileSelector:e,default:t},o={})=>{let{signingName:s,logger:n}=o;return fe(Ie(ct(r,{signingName:s,logger:n}),mt(e,o),ht(t)))};g();g();var lt=new Set,pt=(r,e=oe)=>{if(!lt.has(r)&&!e(r))if(r==="*")console.warn('@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.');else throw new Error(`Region not accepted: region="${r}" is not a valid hostname component.`);else lt.add(r);};g();g();var pe=r=>typeof r=="string"&&(r.startsWith("fips-")||r.endsWith("-fips"));var dt=r=>pe(r)?["fips-aws-global","aws-fips"].includes(r)?"us-east-1":r.replace(/fips-(dkr-|prod-)?|-fips/,""):r;var ir=r=>{let{region:e,useFipsEndpoint:t}=r;if(!e)throw new Error("Region is missing");return Object.assign(r,{region:async()=>{let o=typeof e=="function"?await e():e,s=dt(o);return pt(s),s},useFipsEndpoint:async()=>{let o=typeof e=="string"?e:await e();return pe(o)?true:typeof t!="function"?Promise.resolve(!!t):t()}})};g();g();var Ae=class r extends I{name="TokenProviderError";constructor(e,t=true){super(e,t),Object.setPrototypeOf(this,r.prototype);}};g();var R=(r,e,t)=>{if(e in r){if(r[e]==="true")return true;if(r[e]==="false")return false;throw new Error(`Cannot load ${t} "${e}". Expected "true" or "false", got ${r[e]}.`)}};g();var A;(function(r){r.ENV="env",r.CONFIG="shared config entry";})(A||(A={}));g();var ut="AWS_USE_DUALSTACK_ENDPOINT",gt="use_dualstack_endpoint";var nr={environmentVariableSelector:r=>R(r,ut,A.ENV),configFileSelector:r=>R(r,gt,A.CONFIG),default:false};g();var St="AWS_USE_FIPS_ENDPOINT",Et="use_fips_endpoint";var ar={environmentVariableSelector:r=>R(r,St,A.ENV),configFileSelector:r=>R(r,Et,A.CONFIG),default:false};g();g();g();var yt="AWS_EXECUTION_ENV",De="AWS_REGION",ve="AWS_DEFAULT_REGION",xt="AWS_EC2_METADATA_DISABLED",Tt=["in-region","cross-region","mobile","standard","legacy"],bt="/latest/meta-data/placement/region",Nt="/latest/api/token",Ct="x-aws-ec2-metadata-token",_t="x-aws-ec2-metadata-token-ttl-seconds";var wt=1e3,cr=6e4,At=0,de=async()=>{if(!process.env[xt]&&!(Date.now()<At))try{let r=mr(),e=(await It({...r,path:Nt,method:"PUT",headers:{[_t]:"21600"}})).toString();return (await It({...r,path:bt,method:"GET",headers:{[Ct]:e}})).toString().trim()||Ot()}catch{return Ot()}},Ot=()=>{At=Date.now()+cr;},mr=()=>{let r=process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;if(r){let e=new URL(r);return {hostname:e.hostname.replace(/^\[(.+)]$/,"$1"),port:e.port?Number(e.port):void 0}}return process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE==="IPv6"?{hostname:"fd00:ec2::254"}:{hostname:"169.254.169.254"}},It=async r=>{let{request:e}=await import('http');return new Promise((t,o)=>{let s=e({hostname:r.hostname,port:r.port,path:r.path,method:r.method,headers:r.headers,timeout:wt,signal:AbortSignal.timeout(wt)});s.on("error",n=>{o(n),s.destroy();}),s.on("timeout",()=>{o(new Error("TimeoutError from instance metadata service")),s.destroy();}),s.on("response",n=>{let{statusCode:a=400}=n;if(a<200||a>=300){o(Object.assign(new Error("Error response received from instance metadata service"),{statusCode:a})),s.destroy();return}let h=[];n.on("data",f=>h.push(f)),n.on("end",()=>{t(Buffer.concat(h)),s.destroy();});}),s.end();})};var Dt="AWS_REGION",vt="region",Fe={environmentVariableSelector:r=>r[Dt],configFileSelector:r=>r[vt],default:async()=>{let r=await de();if(r)return r;throw new Error("Region is missing")}},fr={preferredFile:"credentials"};g();g();var hr="AWS_DEFAULTS_MODE",lr="defaults_mode",Ft={environmentVariableSelector:r=>r[hr],configFileSelector:r=>r[lr],default:"legacy"};var pr=({region:r=le(Fe),defaultsMode:e=le(Ft)}={})=>fe(async()=>{let t=typeof e=="function"?await e():e;switch(t?.toLowerCase()){case "auto":return dr(r);case "in-region":case "cross-region":case "mobile":case "standard":case "legacy":return Promise.resolve(t?.toLocaleLowerCase());case void 0:return Promise.resolve("legacy");default:throw new Error(`Invalid parameter for "defaultsMode", expect ${Tt.join(", ")}, got ${t}`)}}),dr=async r=>{if(r){let e=typeof r=="function"?await r():r,t=await ur();return t?e===t?"in-region":"cross-region":"standard"}return "standard"},ur=async()=>process.env[yt]&&(process.env[De]||process.env[ve])?process.env[De]??process.env[ve]:de();g();var Pt="content-length";function Rt(r){return e=>async t=>{let o=t.request;if(N.isInstance(o)){let{body:s,headers:n}=o;if(s&&Object.keys(n).map(a=>a.toLowerCase()).indexOf(Pt)===-1)try{let a=r(s);o.headers={...o.headers,[Pt]:String(a)};}catch{}}return e({...t,request:o})}}var Mt={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:true},gr=r=>({applyToStack:e=>{e.add(Rt(r.bodyLengthChecker),Mt);}});g();g();var D=async(r=new Uint8Array,e)=>{if(r instanceof Uint8Array)return B$1.mutate(r);if(!r)return B$1.mutate(new Uint8Array);let t=e.streamCollector(r);return B$1.mutate(await t)};g();function ue(r){return encodeURIComponent(r).replace(/[!'()*]/g,function(e){return "%"+e.charCodeAt(0).toString(16).toUpperCase()})}g();g();g();var O=class{serdeContext;setSerdeContext(e){this.serdeContext=e;}};var z=class extends O{options;compositeErrorRegistry;constructor(e){super(),this.options=e,this.compositeErrorRegistry=U.for(e.defaultNamespace);for(let t of e.errorTypeRegistries??[])this.compositeErrorRegistry.copyFrom(t);}getRequestType(){return N}getResponseType(){return v}setSerdeContext(e){this.serdeContext=e,this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e),this.getPayloadCodec()&&this.getPayloadCodec().setSerdeContext(e);}updateServiceEndpoint(e,t){if("url"in t){e.protocol=t.url.protocol,e.hostname=t.url.hostname,e.port=t.url.port?Number(t.url.port):void 0,e.path=t.url.pathname,e.fragment=t.url.hash||void 0,e.username=t.url.username||void 0,e.password=t.url.password||void 0,e.query||(e.query={});for(let[o,s]of t.url.searchParams.entries())e.query[o]=s;if(t.headers)for(let o in t.headers)e.headers[o]=t.headers[o].join(", ");return e}else {if(e.protocol=t.protocol,e.hostname=t.hostname,e.port=t.port?Number(t.port):void 0,e.path=t.path,e.query={...t.query},t.headers)for(let o in t.headers)e.headers[o]=t.headers[o];return e}}setHostPrefix(e,t,o){if(this.serdeContext?.disableHostPrefix)return;let s=x.of(t.input),n=w(t.traits??{});if(n.endpoint){let a=n.endpoint?.[0];if(typeof a=="string"){for(let[h,f]of s.structIterator()){if(!f.getMergedTraits().hostLabel)continue;let l=o[h];if(typeof l!="string")throw new Error(`@smithy/core/schema - ${h} in input must be a string as hostLabel.`);a=a.replace(`{${h}}`,l);}if(e.hostname=a+e.hostname,!xe(e.hostname))throw new Error(`[${e.hostname}] is not a valid hostname.`)}}}deserializeMetadata(e){return {httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}}async serializeEventStream({eventStream:e,requestSchema:t,initialRequest:o}){return (await this.loadEventStreamCapability()).serializeEventStream({eventStream:e,requestSchema:t,initialRequest:o})}async deserializeEventStream({response:e,responseSchema:t,initialResponseContainer:o}){return (await this.loadEventStreamCapability()).deserializeEventStream({response:e,responseSchema:t,initialResponseContainer:o})}async loadEventStreamCapability(){let{EventStreamSerde:e,eventStreamSerdeProvider:t}=await import('./event-streams-7NAWZW2I.js'),o=this.resolveEventStreamMarshaller(t);return new e({marshaller:o,serializer:this.serializer,deserializer:this.deserializer,serdeContext:this.serdeContext,defaultContentType:this.getDefaultContentType()})}resolveEventStreamMarshaller(e){let t=this.serdeContext;return t.eventStreamMarshaller?t.eventStreamMarshaller:e(this.serdeContext)}getDefaultContentType(){throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`)}async deserializeHttpMessage(e,t,o,s,n){return []}getEventStreamMarshaller(){let e=this.serdeContext;if(!e.eventStreamMarshaller)throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");return e.eventStreamMarshaller}};var Pe=class extends z{async serializeRequest(e,t,o){let s=t&&typeof t=="object"?t:{},n=this.serializer,a={},h={},f=await o.endpoint(),l=x.of(e?.input),g=[],d=[],E=false,y,u=new N({protocol:"",hostname:"",port:void 0,path:"",fragment:void 0,query:a,headers:h,body:void 0});if(f){this.updateServiceEndpoint(u,f),this.setHostPrefix(u,e,s);let p=w(e.traits);if(p.http){u.method=p.http[0];let[S,T]=p.http[1].split("?");u.path=="/"?u.path=S:u.path+=S;let b=new URLSearchParams(T??"");for(let[C,X]of b)a[C]=X;}}for(let[p,S]of l.structIterator()){let T=S.getMergedTraits()??{},b=s[p];if(b==null&&!S.isIdempotencyToken()){if(T.httpLabel&&(u.path.includes(`{${p}+}`)||u.path.includes(`{${p}}`)))throw new Error(`No value provided for input HTTP label: ${p}.`);continue}if(T.httpPayload)S.isStreaming()?S.isStructSchema()?s[p]&&(y=await this.serializeEventStream({eventStream:s[p],requestSchema:l})):y=b:(n.write(S,b),y=n.flush());else if(T.httpLabel){n.write(S,b);let C=n.flush();u.path.includes(`{${p}+}`)?u.path=u.path.replace(`{${p}+}`,C.split("/").map(ue).join("/")):u.path.includes(`{${p}}`)&&(u.path=u.path.replace(`{${p}}`,ue(C)));}else if(T.httpHeader)n.write(S,b),h[T.httpHeader.toLowerCase()]=String(n.flush());else if(typeof T.httpPrefixHeaders=="string")for(let C in b){let X=b[C],ze=T.httpPrefixHeaders+C;n.write([S.getValueSchema(),{httpHeader:ze}],X),h[ze.toLowerCase()]=n.flush();}else T.httpQuery||T.httpQueryParams?this.serializeQuery(S,b,a):(E=true,g.push(p),d.push(S));}if(E&&s){let[p,S]=(l.getName(true)??"#Unknown").split("#"),T=l.getSchema()[6],b=[3,p,S,l.getMergedTraits(),g,d,void 0];T?b[6]=T:b.pop(),n.write(b,s),y=n.flush();}return u.headers=h,u.query=a,u.body=y,u}serializeQuery(e,t,o){let s=this.serializer,n=e.getMergedTraits();if(n.httpQueryParams){for(let a in t)if(!(a in o)){let h=t[a],f=e.getValueSchema();Object.assign(f.getMergedTraits(),{...n,httpQuery:a,httpQueryParams:void 0}),this.serializeQuery(f,h,o);}return}if(e.isListSchema()){let a=!!e.getMergedTraits().sparse,h=[];for(let f of t){s.write([e.getValueSchema(),n],f);let l=s.flush();(a||l!==void 0)&&h.push(l);}o[n.httpQuery]=h;}else s.write([e,n],t),o[n.httpQuery]=s.flush();}async deserializeResponse(e,t,o){let s=this.deserializer,n=x.of(e.output),a={};if(o.statusCode>=300){let f=await D(o.body,t);throw f.byteLength>0&&Object.assign(a,await s.read(15,f)),await this.handleError(e,t,o,a,this.deserializeMetadata(o)),new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.")}for(let f in o.headers){let l=o.headers[f];delete o.headers[f],o.headers[f.toLowerCase()]=l;}let h=await this.deserializeHttpMessage(n,t,o,a);if(h.length){let f=await D(o.body,t);if(f.byteLength>0){let l=await s.read(n,f);for(let g of h)l[g]!=null&&(a[g]=l[g]);}}else h.discardResponseBody&&await D(o.body,t);return a.$metadata=this.deserializeMetadata(o),a}async deserializeHttpMessage(e,t,o,s,n){let a;s instanceof Set?a=n:a=s;let h=true,f=this.deserializer,l=x.of(e),g=[];for(let[d,E]of l.structIterator()){let y=E.getMemberTraits();if(y.httpPayload){if(h=false,E.isStreaming())E.isStructSchema()?a[d]=await this.deserializeEventStream({response:o,responseSchema:l}):a[d]=A$1(o.body);else if(o.body){let p=await D(o.body,t);p.byteLength>0&&(a[d]=await f.read(E,p));}}else if(y.httpHeader){let u=String(y.httpHeader).toLowerCase(),p$1=o.headers[u];if(p$1!=null)if(E.isListSchema()){let S=E.getValueSchema();S.getMergedTraits().httpHeader=u;let T;S.isTimestampSchema()&&S.getSchema()===4?T=p(p$1,",",2):T=q$1(p$1);let b=[];for(let C of T)b.push(await f.read(S,C.trim()));a[d]=b;}else a[d]=await f.read(E,p$1);}else if(y.httpPrefixHeaders!==void 0){a[d]={};for(let u in o.headers)if(u.startsWith(y.httpPrefixHeaders)){let p=o.headers[u],S=E.getValueSchema();S.getMergedTraits().httpHeader=u,a[d][u.slice(y.httpPrefixHeaders.length)]=await f.read(S,p);}}else y.httpResponseCode?a[d]=o.statusCode:g.push(d);}return g.discardResponseBody=h,g}};g();var Re=class extends z{async serializeRequest(e,t,o){let s=this.serializer,n={},a={},h=await o.endpoint(),f=x.of(e?.input),l=f.getSchema(),g,d=t&&typeof t=="object"?t:{},E=new N({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:n,headers:a,body:void 0});if(h&&(this.updateServiceEndpoint(E,h),this.setHostPrefix(E,e,d)),d){let y=f.getEventStreamMember();if(y){if(d[y]){let u={};for(let[p,S]of f.structIterator())p!==y&&d[p]&&(s.write(S,d[p]),u[p]=s.flush());g=await this.serializeEventStream({eventStream:d[y],requestSchema:f,initialRequest:u});}}else s.write(l,d),g=s.flush();}return E.headers=Object.assign(E.headers,a),E.query=n,E.body=g,E.method="POST",E}async deserializeResponse(e,t,o){let s=this.deserializer,n=x.of(e.output),a={};if(o.statusCode>=300){let f=await D(o.body,t);throw f.byteLength>0&&Object.assign(a,await s.read(15,f)),await this.handleError(e,t,o,a,this.deserializeMetadata(o)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(let f in o.headers){let l=o.headers[f];delete o.headers[f],o.headers[f.toLowerCase()]=l;}let h=n.getEventStreamMember();if(h)a[h]=await this.deserializeEventStream({response:o,responseSchema:n,initialResponseContainer:a});else {let f=await D(o.body,t);f.byteLength>0&&Object.assign(a,await s.read(n,f));}return a.$metadata=this.deserializeMetadata(o),a}};g();g();function K(r,e){if(e.timestampFormat.useTrait&&r.isTimestampSchema()&&(r.getSchema()===5||r.getSchema()===6||r.getSchema()===7))return r.getSchema();let{httpLabel:t,httpPrefixHeaders:o,httpHeader:s,httpQuery:n}=r.getMergedTraits();return (e.httpBindings?typeof o=="string"||s?6:n||t?5:void 0:void 0)??e.timestampFormat.default}var q=class extends O{settings;constructor(e){super(),this.settings=e;}read(e,t){let o$1=x.of(e);if(o$1.isListSchema())return q$1(t).map(s=>this.read(o$1.getValueSchema(),s));if(o$1.isBlobSchema())return (this.serdeContext?.base64Decoder??b)(t);if(o$1.isTimestampSchema())switch(K(o$1,this.settings)){case 5:return n(t);case 6:return o(t);case 7:return m(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(o$1.isStringSchema()){let s=o$1.getMergedTraits().mediaType,n=t;if(s)return o$1.getMergedTraits().httpHeader&&(n=this.base64ToUtf8(n)),(s==="application/json"||s.endsWith("+json"))&&(n=k$1.from(n)),n}return o$1.isNumericSchema()?Number(t):o$1.isBigIntegerSchema()?BigInt(t):o$1.isBigDecimalSchema()?new r(t,"bigDecimal"):o$1.isBooleanSchema()?String(t).toLowerCase()==="true":t}base64ToUtf8(e$1){return (this.serdeContext?.utf8Encoder??e)((this.serdeContext?.base64Decoder??b)(e$1))}};g();var Me=class extends O{codecDeserializer;stringDeserializer;constructor(e,t){super(),this.codecDeserializer=e,this.stringDeserializer=new q(t);}setSerdeContext(e){this.stringDeserializer.setSerdeContext(e),this.codecDeserializer.setSerdeContext(e),this.serdeContext=e;}read(e$1,t){let o=x.of(e$1),s=o.getMergedTraits(),n=this.serdeContext?.utf8Encoder??e;if(s.httpHeader||s.httpResponseCode)return this.stringDeserializer.read(o,n(t));if(s.httpPayload){if(o.isBlobSchema()){let a=this.serdeContext?.utf8Decoder??c;return typeof t=="string"?a(t):t}else if(o.isStringSchema())return "byteLength"in t?n(t):t}return this.codecDeserializer.read(o,t)}};g();g();var ge=class extends O{settings;stringBuffer="";constructor(e){super(),this.settings=e;}write(e,t){let o=x.of(e);switch(typeof t){case "object":if(t===null){this.stringBuffer="null";return}if(o.isTimestampSchema()){if(!(t instanceof Date))throw new Error(`@smithy/core/protocols - received non-Date value ${t} when schema expected Date in ${o.getName(true)}`);switch(K(o,this.settings)){case 5:this.stringBuffer=t.toISOString().replace(".000Z","Z");break;case 6:this.stringBuffer=f(t);break;case 7:this.stringBuffer=String(t.getTime()/1e3);break;default:console.warn("Missing timestamp format, using epoch seconds",t),this.stringBuffer=String(t.getTime()/1e3);}return}if(o.isBlobSchema()&&"byteLength"in t){this.stringBuffer=(this.serdeContext?.base64Encoder??d)(t);return}if(o.isListSchema()&&Array.isArray(t)){let a="";for(let h of t){this.write([o.getValueSchema(),o.getMergedTraits()],h);let f=this.flush(),l$1=o.getValueSchema().isTimestampSchema()?f:l(f);a!==""&&(a+=", "),a+=l$1;}this.stringBuffer=a;return}this.stringBuffer=JSON.stringify(t,null,2);break;case "string":let s=o.getMergedTraits().mediaType,n=t;if(s&&((s==="application/json"||s.endsWith("+json"))&&(n=k$1.from(n)),o.getMergedTraits().httpHeader)){this.stringBuffer=(this.serdeContext?.base64Encoder??d)(n.toString());return}this.stringBuffer=t;break;default:o.isIdempotencyToken()?this.stringBuffer=D$1():this.stringBuffer=String(t);}}flush(){let e=this.stringBuffer;return this.stringBuffer="",e}};var Le=class{codecSerializer;stringSerializer;buffer;constructor(e,t,o=new ge(t)){this.codecSerializer=e,this.stringSerializer=o;}setSerdeContext(e){this.codecSerializer.setSerdeContext(e),this.stringSerializer.setSerdeContext(e);}write(e,t){let o=x.of(e),s=o.getMergedTraits();if(s.httpHeader||s.httpLabel||s.httpQuery){this.stringSerializer.write(o,t),this.buffer=this.stringSerializer.flush();return}return this.codecSerializer.write(o,t)}flush(){if(this.buffer!==void 0){let e=this.buffer;return this.buffer=void 0,e}return this.codecSerializer.flush()}};g();var Sr=r=>({setHttpHandler(e){r.httpHandler=e;},httpHandler(){return r.httpHandler},updateHttpClientConfig(e,t){r.httpHandler?.updateHttpClientConfig(e,t);},httpHandlerConfigs(){return r.httpHandler.httpHandlerConfigs()}}),Er=r=>({httpHandler:r.httpHandler()});g();var Q=r=>encodeURIComponent(r).replace(/[!'()*]/g,yr),yr=r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`;g();function xr(r){let e=[];for(let t of Object.keys(r).sort()){let o=r[t];if(t=Q(t),Array.isArray(o))for(let s=0,n=o.length;s<n;s++)e.push(`${t}=${Q(o[s])}`);else {let s=t;(o||typeof o=="string")&&(s+=`=${Q(o)}`),e.push(s);}}return e.join("&")}
4
4
  export{Yt as A,or as B,le as C,nr as D,ar as E,Fe as F,fr as G,ir as H,pr as I,D as J,ue as K,Pe as L,Re as M,K as N,q as O,Me as P,Le as Q,Sr as R,Er as S,gr as T,Q as U,xr as V,ye as a,te as b,re as c,H as d,N as e,v as f,oe as g,Lt as h,M as i,Te as j,k,Ut as l,x as m,U as n,I as o,P as p,Ae as q,Ie as r,R as s,A as t,et as u,Ce as v,Oe as w,rr as x,L as y,Jt as z};
@@ -1,4 +1,4 @@
1
- import {createRequire}from'module';import {b}from'./chunk-VBPAAQEF.js';import {f,R as R$1,h,g as g$1,S as S$1,X as X$1,p,n,P,j,Q,d as d$1}from'./chunk-IP6JUEH3.js';import {t,a,Y,N,J as J$1,c,A,d,R,v,i,l,H as H$1,w,e,f as f$1,_}from'./chunk-7AQSH3KR.js';import {g}from'./chunk-C2PXMVR5.js';createRequire(import.meta.url);
1
+ import {b}from'./chunk-N5POANYV.js';import {f,R as R$1,h,g as g$1,S as S$1,X as X$1,p,n,P,j,Q,d as d$1}from'./chunk-HRAY65XH.js';import {t,a,Y,N,J as J$1,c,A,d,R,v,i,l,H as H$1,w,e,f as f$1,_}from'./chunk-3NSZZCOJ.js';import {g}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
2
  g();g();g();var X=class{static[a]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:n,columns:s,foreignColumns:o}=e();return {name:n,columns:s,foreignTable:o[0].table,foreignColumns:o}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete);}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new re(e,this)}},re=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete;}static[a]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),s=t.map(r=>r.name),o=n.map(r=>r.name),u=[this.table[f$1],...s,n[0].table[f$1],...o];return e??`${u.join("_")}_fk`}};g();function ue(a,e){return `${a[f$1]}_${e.join("_")}_unique`}var q=class extends e{static[a]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=true,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:s})=>((o,u)=>{let r=new X(()=>{let c=o();return {columns:[e],foreignColumns:[c]}});return u.onUpdate&&r.onUpdate(u.onUpdate),u.onDelete&&r.onDelete(u.onDelete),r.build(t)})(n,s))}},S=class extends d{constructor(e,t){t.uniqueName||(t.uniqueName=ue(e,[t.name])),super(e,t),this.table=e;}static[a]="SQLiteColumn"};var k=class extends q{static[a]="SQLiteBaseIntegerBuilder";constructor(e,t,n){super(e,t,n),this.config.autoIncrement=false;}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=true),this.config.hasDefault=true,super.primaryKey()}},J=class extends S{static[a]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return "integer"}},ae=class extends k{static[a]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger");}build(e){return new le(e,this.config)}},le=class extends J{static[a]="SQLiteInteger"},me=class extends k{static[a]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t;}defaultNow(){return this.default(J$1`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new ce(e,this.config)}},ce=class extends J{static[a]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return this.config.mode==="timestamp"?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode==="timestamp"?Math.floor(t/1e3):t}},fe=class extends k{static[a]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t;}build(e){return new de(e,this.config)}},de=class extends J{static[a]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}};function Ge(a,e){let{name:t,config:n}=Y(a,e);return n?.mode==="timestamp"||n?.mode==="timestamp_ms"?new me(t,n.mode):n?.mode==="boolean"?new fe(t,n.mode):new ae(t)}g();var pe=class extends q{static[a]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric");}build(e){return new he(e,this.config)}},he=class extends S{static[a]="SQLiteNumeric";mapFromDriverValue(e){return typeof e=="string"?e:String(e)}getSQLType(){return "numeric"}},ge=class extends q{static[a]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber");}build(e){return new ye(e,this.config)}},ye=class extends S{static[a]="SQLiteNumericNumber";mapFromDriverValue(e){return typeof e=="number"?e:Number(e)}mapToDriverValue=String;getSQLType(){return "numeric"}},be=class extends q{static[a]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt");}build(e){return new Se(e,this.config)}},Se=class extends S{static[a]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return "numeric"}};function He(a,e){let{name:t,config:n}=Y(a,e),s=n?.mode;return s==="number"?new ge(t):s==="bigint"?new be(t):new pe(t)}g();var $e=class extends q{static[a]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length;}build(e){return new Te(e,this.config)}},Te=class extends S{static[a]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t);}getSQLType(){return `text${this.config.length?`(${this.config.length})`:""}`}},Ce=class extends q{static[a]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson");}build(e){return new we(e,this.config)}},we=class extends S{static[a]="SQLiteTextJson";getSQLType(){return "text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function Ze(a,e={}){let{name:t,config:n}=Y(a,e);return n.mode==="json"?new Ce(t):new $e(t,n)}g();g();g();var Le=class extends q{static[a]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt");}build(e){return new qe(e,this.config)}},qe=class extends S{static[a]="SQLiteBigInt";getSQLType(){return "blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(_.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},xe=class extends q{static[a]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson");}build(e){return new Qe(e,this.config)}},Qe=class extends S{static[a]="SQLiteBlobJson";getSQLType(){return "blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(_.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},Be=class extends q{static[a]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer");}build(e){return new Ne(e,this.config)}},Ne=class extends S{static[a]="SQLiteBlobBuffer";mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return "blob"}};function et(a,e){let{name:t,config:n}=Y(a,e);return n?.mode==="json"?new xe(t):n?.mode==="bigint"?new Le(t):new Be(t)}g();var Oe=class extends q{static[a]="SQLiteCustomColumnBuilder";constructor(e,t,n){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=n;}build(e){return new ve(e,this.config)}},ve=class extends S{static[a]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver;}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom=="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo=="function"?this.mapTo(e):e}};function tt(a){return (e,t)=>{let{name:n,config:s}=Y(e,t);return new Oe(n,s,a)}}g();var _e=class extends q{static[a]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal");}build(e){return new De(e,this.config)}},De=class extends S{static[a]="SQLiteReal";getSQLType(){return "real"}};function it(a){return new _e(a??"")}function nt(){return {blob:et,customType:tt,integer:Ge,numeric:He,real:it,text:Ze}}var Ke=Symbol.for("drizzle:SQLiteInlineForeignKeys"),F=class extends t{static[a]="SQLiteTable";static Symbol=Object.assign({},t.Symbol,{InlineForeignKeys:Ke});[t.Symbol.Columns];[Ke]=[];[t.Symbol.ExtraConfigBuilder]=void 0};function lt(a,e,t$1,n,s=a){let o=new F(a,n,s),u=typeof e=="function"?e(nt()):e,r=Object.fromEntries(Object.entries(u).map(([f,p])=>{let $=p;$.setName(f);let x=$.build(o);return o[Ke].push(...$.buildForeignKeys(x,o)),[f,x]})),c=Object.assign(o,r);return c[t.Symbol.Columns]=r,c[t.Symbol.ExtraConfigColumns]=r,t$1&&(c[F.Symbol.ExtraConfigBuilder]=t$1),c}var fi=(a,e,t)=>lt(a,e,t);g();g();var G=class extends N{static[a]="SQLiteViewBase"};var H=class{static[a]="SQLiteDialect";casing;constructor(e){this.casing=new b(e?.casing);}escapeName(e){return `"${e}"`}escapeParam(e){return "?"}escapeString(e){return `'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[J$1`with `];for(let[n,s]of e.entries())t.push(J$1`${J$1.identifier(s._.alias)} as (${s._.sql})`),n<e.length-1&&t.push(J$1`, `);return t.push(J$1` `),J$1.join(t)}buildDeleteQuery({table:e,where:t,returning:n,withList:s,limit:o,orderBy:u}){let r=this.buildWithCTE(s),c=n?J$1` returning ${this.buildSelection(n,{isSingleTable:true})}`:void 0,f=t?J$1` where ${t}`:void 0,p=this.buildOrderBy(u),$=this.buildLimit(o);return J$1`${r}delete from ${e}${f}${c}${p}${$}`}buildUpdateSet(e,t$1){let n=e[t.Symbol.Columns],s=Object.keys(n).filter(u=>t$1[u]!==void 0||n[u]?.onUpdateFn!==void 0),o=s.length;return J$1.join(s.flatMap((u,r)=>{let c=n[u],f=t$1[u]??J$1.param(c.onUpdateFn(),c),p=J$1`${J$1.identifier(this.casing.getColumnCasing(c))} = ${f}`;return r<o-1?[p,J$1.raw(", ")]:[p]}))}buildUpdateQuery({table:e,set:t,where:n,returning:s,withList:o,joins:u,from:r,limit:c,orderBy:f}){let p=this.buildWithCTE(o),$=this.buildUpdateSet(e,t),x=r&&J$1.join([J$1.raw(" from "),this.buildFromTable(r)]),Q=this.buildJoins(u),w=s?J$1` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,b=n?J$1` where ${n}`:void 0,T=this.buildOrderBy(f),C=this.buildLimit(c);return J$1`${p}update ${e} set ${$}${x}${Q}${b}${w}${T}${C}`}buildSelection(e,{isSingleTable:t$1=false}={}){let n=e.length,s=e.flatMap(({field:o},u)=>{let r=[];if(c(o,A.Aliased)&&o.isSelectionField)r.push(J$1.identifier(o.fieldAlias));else if(c(o,A.Aliased)||c(o,A)){let c$1=c(o,A.Aliased)?o.sql:o;t$1?r.push(new A(c$1.queryChunks.map(f=>c(f,d)?J$1.identifier(this.casing.getColumnCasing(f)):f))):r.push(c$1),c(o,A.Aliased)&&r.push(J$1` as ${J$1.identifier(o.fieldAlias)}`);}else if(c(o,d)){let c=o.table[t.Symbol.Name];o.columnType==="SQLiteNumericBigInt"?t$1?r.push(J$1`cast(${J$1.identifier(this.casing.getColumnCasing(o))} as text)`):r.push(J$1`cast(${J$1.identifier(c)}.${J$1.identifier(this.casing.getColumnCasing(o))} as text)`):t$1?r.push(J$1.identifier(this.casing.getColumnCasing(o))):r.push(J$1`${J$1.identifier(c)}.${J$1.identifier(this.casing.getColumnCasing(o))}`);}return u<n-1&&r.push(J$1`, `),r});return J$1.join(s)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[n,s]of e.entries()){n===0&&t.push(J$1` `);let o=s.table,u=s.on?J$1` on ${s.on}`:void 0;if(c(o,F)){let r=o[F.Symbol.Name],c=o[F.Symbol.Schema],f=o[F.Symbol.OriginalName],p=r===f?void 0:s.alias;t.push(J$1`${J$1.raw(s.joinType)} join ${c?J$1`${J$1.identifier(c)}.`:void 0}${J$1.identifier(f)}${p&&J$1` ${J$1.identifier(p)}`}${u}`);}else t.push(J$1`${J$1.raw(s.joinType)} join ${o}${u}`);n<e.length-1&&t.push(J$1` `);}return J$1.join(t)}buildLimit(e){return typeof e=="object"||typeof e=="number"&&e>=0?J$1` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[n,s]of e.entries())t.push(s),n<e.length-1&&t.push(J$1`, `);return t.length>0?J$1` order by ${J$1.join(t)}`:void 0}buildFromTable(e){return c(e,t)&&e[t.Symbol.IsAlias]?J$1`${J$1`${J$1.identifier(e[t.Symbol.Schema]??"")}.`.if(e[t.Symbol.Schema])}${J$1.identifier(e[t.Symbol.OriginalName])} ${J$1.identifier(e[t.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t$1,fieldsFlat:n,where:s,having:o,table:u,joins:r,orderBy:c$1,groupBy:f,limit:p,offset:$,distinct:x,setOperators:Q}){let w=n??R(t$1);for(let K of w)if(c(K.field,d)&&v(K.field.table)!==(c(u,i)?u._.alias:c(u,G)?u[l].name:c(u,A)?void 0:v(u))&&!(j=>r?.some(({alias:Y})=>Y===(j[t.Symbol.IsAlias]?v(j):j[t.Symbol.BaseName])))(K.field.table)){let j=v(K.field.table);throw new Error(`Your "${K.path.join("->")}" field references a column "${j}"."${K.field.name}", but the table "${j}" is not part of the query! Did you forget to join it?`)}let b=!r||r.length===0,T=this.buildWithCTE(e),C=x?J$1` distinct`:void 0,O=this.buildSelection(w,{isSingleTable:b}),B=this.buildFromTable(u),h=this.buildJoins(r),V=s?J$1` where ${s}`:void 0,v$1=o?J$1` having ${o}`:void 0,m=[];if(f)for(let[K,j]of f.entries())m.push(j),K<f.length-1&&m.push(J$1`, `);let g=m.length>0?J$1` group by ${J$1.join(m)}`:void 0,R$1=this.buildOrderBy(c$1),P=this.buildLimit(p),Z=$?J$1` offset ${$}`:void 0,A$1=J$1`${T}select${C} ${O} from ${B}${h}${V}${g}${v$1}${R$1}${P}${Z}`;return Q.length>0?this.buildSetOperations(A$1,Q):A$1}buildSetOperations(e,t){let[n,...s]=t;if(!n)throw new Error("Cannot pass undefined values to any set operator");return s.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:s,limit:o,orderBy:u,offset:r}}){let c$1=J$1`${e.getSQL()} `,f=J$1`${s.getSQL()}`,p;if(u&&u.length>0){let w=[];for(let b of u)if(c(b,S))w.push(J$1.identifier(b.name));else if(c(b,A)){for(let T=0;T<b.queryChunks.length;T++){let C=b.queryChunks[T];c(C,S)&&(b.queryChunks[T]=J$1.identifier(this.casing.getColumnCasing(C)));}w.push(J$1`${b}`);}else w.push(J$1`${b}`);p=J$1` order by ${J$1.join(w,J$1`, `)}`;}let $=typeof o=="object"||typeof o=="number"&&o>=0?J$1` limit ${o}`:void 0,x=J$1.raw(`${t} ${n?"all ":""}`),Q=r?J$1` offset ${r}`:void 0;return J$1`${c$1}${x}${f}${p}${$}${Q}`}buildInsertQuery({table:e,values:t$1,onConflict:n,returning:s,withList:o,select:u}){let r=[],c$1=e[t.Symbol.Columns],f=Object.entries(c$1).filter(([b,T])=>!T.shouldDisableInsert()),p=f.map(([,b])=>J$1.identifier(this.casing.getColumnCasing(b)));if(u){let b=t$1;c(b,A)?r.push(b):r.push(b.getSQL());}else {let b=t$1;r.push(J$1.raw("values "));for(let[T,C]of b.entries()){let O=[];for(let[B,h]of f){let V=C[B];if(V===void 0||c(V,H$1)&&V.value===void 0){let v;if(h.default!==null&&h.default!==void 0)v=c(h.default,A)?h.default:J$1.param(h.default,h);else if(h.defaultFn!==void 0){let m=h.defaultFn();v=c(m,A)?m:J$1.param(m,h);}else if(!h.default&&h.onUpdateFn!==void 0){let m=h.onUpdateFn();v=c(m,A)?m:J$1.param(m,h);}else v=J$1`null`;O.push(v);}else O.push(V);}r.push(O),T<b.length-1&&r.push(J$1`, `);}}let $=this.buildWithCTE(o),x=J$1.join(r),Q=s?J$1` returning ${this.buildSelection(s,{isSingleTable:true})}`:void 0,w=n?.length?J$1.join(n):void 0;return J$1`${$}insert into ${e} ${p} ${x}${w}${Q}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:n$1,table:s,tableConfig:o,queryConfig:u,tableAlias:r,nestedQueryRelation:c$1,joinOn:f$1}){let p$1=[],$,x,Q$1=[],w$1,b=[];if(u===true)p$1=Object.entries(o.columns).map(([O,B])=>({dbKey:B.name,tsKey:O,field:f(B,r),relationTableTsKey:void 0,isJson:false,selection:[]}));else {let C=Object.fromEntries(Object.entries(o.columns).map(([m,g])=>[m,f(g,r)]));if(u.where){let m=typeof u.where=="function"?u.where(C,R$1()):u.where;w$1=m&&h(m,r);}let O=[],B=[];if(u.columns){let m=false;for(let[g,R]of Object.entries(u.columns))R!==void 0&&g in o.columns&&(!m&&R===true&&(m=true),B.push(g));B.length>0&&(B=m?B.filter(g=>u.columns?.[g]===true):Object.keys(o.columns).filter(g=>!B.includes(g)));}else B=Object.keys(o.columns);for(let m of B){let g=o.columns[m];O.push({tsKey:m,value:g});}let h$1=[];u.with&&(h$1=Object.entries(u.with).filter(m=>!!m[1]).map(([m,g])=>({tsKey:m,queryConfig:g,relation:o.relations[m]})));let V;if(u.extras){V=typeof u.extras=="function"?u.extras(C,{sql:J$1}):u.extras;for(let[m,g]of Object.entries(V))O.push({tsKey:m,value:g$1(g,r)});}for(let{tsKey:m,value:g}of O)p$1.push({dbKey:c(g,A.Aliased)?g.fieldAlias:o.columns[m].name,tsKey:m,field:c(g,d)?f(g,r):g,relationTableTsKey:void 0,isJson:false,selection:[]});let v=typeof u.orderBy=="function"?u.orderBy(C,S$1()):u.orderBy??[];Array.isArray(v)||(v=[v]),Q$1=v.map(m=>c(m,d)?f(m,r):h(m,r)),$=u.limit,x=u.offset;for(let{tsKey:m,queryConfig:g,relation:R}of h$1){let P$1=X$1(t,n$1,R),Z=w(R.referencedTable),A=n$1[Z],K=`${r}_${m}`,j=p(...P$1.fields.map((ut,at)=>n(f(P$1.references[at],K),f(ut,r)))),Y=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:n$1,table:e[A],tableConfig:t[A],queryConfig:c(R,P)?g===true?{limit:1}:{...g,limit:1}:g,tableAlias:K,joinOn:j,nestedQueryRelation:R}),st=J$1`(${Y.sql})`.as(m);p$1.push({dbKey:m,tsKey:m,field:st,relationTableTsKey:A,isJson:true,selection:Y.selection});}}if(p$1.length===0)throw new j({message:`No fields selected for table "${o.tsName}" ("${r}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let T;if(w$1=p(f$1,w$1),c$1){let C=J$1`json_array(${J$1.join(p$1.map(({field:h})=>c(h,S)?J$1.identifier(this.casing.getColumnCasing(h)):c(h,A.Aliased)?h.sql:h),J$1`, `)})`;c(c$1,Q)&&(C=J$1`coalesce(json_group_array(${C}), json_array())`);let O=[{dbKey:"data",tsKey:"data",field:C.as("data"),isJson:true,relationTableTsKey:o.tsName,selection:p$1}];$!==void 0||x!==void 0||Q$1.length>0?(T=this.buildSelectQuery({table:d$1(s,r),fields:{},fieldsFlat:[{path:[],field:J$1.raw("*")}],where:w$1,limit:$,offset:x,orderBy:Q$1,setOperators:[]}),w$1=void 0,$=void 0,x=void 0,Q$1=void 0):T=d$1(s,r),T=this.buildSelectQuery({table:c(T,F)?T:new i(T,{},r),fields:{},fieldsFlat:O.map(({field:h})=>({path:[],field:c(h,d)?f(h,r):h})),joins:b,where:w$1,limit:$,offset:x,orderBy:Q$1,setOperators:[]});}else T=this.buildSelectQuery({table:d$1(s,r),fields:{},fieldsFlat:p$1.map(({field:C})=>({path:[],field:c(C,d)?f(C,r):C})),joins:b,where:w$1,limit:$,offset:x,orderBy:Q$1,setOperators:[]});return {tableTsKey:o.tsName,sql:T,selection:p$1}}},rt=class extends H{static[a]="SQLiteSyncDialect";migrate(e,t,n){let s=n===void 0||typeof n=="string"?"__drizzle_migrations":n.migrationsTable??"__drizzle_migrations",o=J$1`
3
3
  CREATE TABLE IF NOT EXISTS ${J$1.identifier(s)} (
4
4
  id SERIAL PRIMARY KEY,