@donotdev/functions 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +1 -1
  2. package/lib/chunks/chunk-522YXGDA.js +23 -0
  3. package/lib/chunks/chunk-522YXGDA.js.map +7 -0
  4. package/lib/chunks/chunk-7ODXXXES.js +151 -0
  5. package/lib/chunks/chunk-7ODXXXES.js.map +7 -0
  6. package/lib/chunks/chunk-CP3NNKO5.js +22 -0
  7. package/lib/chunks/chunk-CP3NNKO5.js.map +7 -0
  8. package/lib/chunks/{chunk-2A4FPYNB.js → chunk-CVYSXC27.js} +2 -2
  9. package/lib/chunks/chunk-CVYSXC27.js.map +7 -0
  10. package/lib/chunks/{chunk-PJCJ5H2O.js → chunk-HZM5X5A7.js} +2 -2
  11. package/lib/chunks/chunk-ICNQCRLV.js +22 -0
  12. package/lib/chunks/chunk-ICNQCRLV.js.map +7 -0
  13. package/lib/chunks/chunk-OAZ2JYSD.js +22 -0
  14. package/lib/chunks/chunk-OAZ2JYSD.js.map +7 -0
  15. package/lib/chunks/chunk-OKRR7ST5.js +22 -0
  16. package/lib/chunks/chunk-OKRR7ST5.js.map +7 -0
  17. package/lib/chunks/chunk-PDBNKSBQ.js +22 -0
  18. package/lib/chunks/chunk-PDBNKSBQ.js.map +7 -0
  19. package/lib/chunks/chunk-TJPJXJEK.js +22 -0
  20. package/lib/chunks/{chunk-OZX5ZG44.js.map → chunk-TJPJXJEK.js.map} +1 -1
  21. package/lib/chunks/chunk-W6W4L44F.js +22 -0
  22. package/lib/chunks/chunk-W6W4L44F.js.map +7 -0
  23. package/lib/chunks/{monitoring-UIDJS2KA.js → monitoring-UCBNPPW2.js} +2 -2
  24. package/lib/chunks/{rateLimiter-WNWHI3B4.js → rateLimiter-XKECWM33.js} +2 -2
  25. package/lib/chunks/{server-RYGEBS2B.js → server-24XGDDO3.js} +2 -2
  26. package/lib/firebase/auth/removeCustomClaims.d.ts +1 -1
  27. package/lib/firebase/crud/aggregate.d.ts +1 -1
  28. package/lib/firebase/crud/create.d.ts +22 -1
  29. package/lib/firebase/crud/update.d.ts +27 -3
  30. package/lib/firebase/index.js +1 -1
  31. package/lib/firebase/index.js.map +3 -3
  32. package/lib/shared/billing/checkoutValidation.d.ts +1 -1
  33. package/lib/shared/billing/createCheckout.d.ts +1 -1
  34. package/lib/shared/billing/helpers/subscriptionManagement.d.ts +2 -2
  35. package/lib/shared/billing/helpers/updateUserSubscription.d.ts +2 -8
  36. package/lib/shared/billing/index.d.ts +2 -0
  37. package/lib/shared/billing/orderWebhook.d.ts +29 -2
  38. package/lib/shared/billing/stripePinned.d.ts +43 -0
  39. package/lib/shared/billing/verifyOrderCheckout.d.ts +53 -0
  40. package/lib/shared/crud/bulkCore.d.ts +38 -10
  41. package/lib/shared/crud/index.d.ts +1 -0
  42. package/lib/shared/crud/written.d.ts +21 -0
  43. package/lib/shared/denoEnv.d.ts +25 -0
  44. package/lib/shared/github.d.ts +0 -8
  45. package/lib/shared/index.d.ts +0 -1
  46. package/lib/shared/index.js +1 -1
  47. package/lib/shared/logger.d.ts +14 -14
  48. package/lib/shared/utils/external/subscription.d.ts +0 -8
  49. package/lib/shared/utils.d.ts +13 -10
  50. package/lib/supabase/auth/deleteAccount.d.ts +34 -2
  51. package/lib/supabase/crud/bulk.d.ts +7 -0
  52. package/lib/supabase/crud/create.d.ts +5 -9
  53. package/lib/supabase/crud/entityStore.d.ts +67 -14
  54. package/lib/supabase/crud/update.d.ts +7 -10
  55. package/lib/supabase/index.d.ts +5 -0
  56. package/lib/supabase/index.js +1 -1
  57. package/lib/supabase/index.js.map +4 -4
  58. package/lib/vercel/api/crud/create.d.ts +6 -1
  59. package/lib/vercel/api/crud/update.d.ts +8 -1
  60. package/lib/vercel/api/index.js +1 -1
  61. package/lib/vercel/api/index.js.map +3 -3
  62. package/package.json +9 -9
  63. package/src/firebase/auth/getCustomClaims.ts +2 -0
  64. package/src/firebase/auth/getUserAuthStatus.ts +2 -0
  65. package/src/firebase/auth/removeCustomClaims.ts +33 -1
  66. package/src/firebase/auth/setCustomClaims.ts +6 -0
  67. package/src/firebase/baseFunction.ts +5 -2
  68. package/src/firebase/billing/changePlan.ts +6 -5
  69. package/src/firebase/billing/createCustomerPortal.ts +6 -4
  70. package/src/firebase/billing/refreshSubscriptionStatus.ts +7 -5
  71. package/src/firebase/billing/webhookHandler.ts +4 -4
  72. package/src/firebase/crud/__tests__/bulk.test.ts +50 -1
  73. package/src/firebase/crud/__tests__/create.test.ts +64 -0
  74. package/src/firebase/crud/__tests__/update.test.ts +97 -0
  75. package/src/firebase/crud/aggregate.ts +37 -19
  76. package/src/firebase/crud/bulk.ts +30 -10
  77. package/src/firebase/crud/create.ts +40 -26
  78. package/src/firebase/crud/delete.ts +6 -1
  79. package/src/firebase/crud/get.ts +12 -14
  80. package/src/firebase/crud/list.ts +23 -12
  81. package/src/firebase/crud/update.ts +49 -25
  82. package/src/firebase/helpers/githubAccessHelper.ts +3 -0
  83. package/src/firebase/helpers/githubTeamAccessHelper.ts +1 -0
  84. package/src/firebase/oauth/exchangeToken.ts +4 -0
  85. package/src/firebase/oauth/getConnections.ts +1 -1
  86. package/src/firebase/oauth/githubAccess.ts +3 -0
  87. package/src/firebase/oauth/refreshToken.ts +1 -0
  88. package/src/firebase/registerCrudFunctions.ts +1 -0
  89. package/src/firebase/scheduled/checkExpiredSubscriptions.ts +4 -1
  90. package/src/shared/__tests__/bulkCore.test.ts +191 -0
  91. package/src/shared/__tests__/removeCustomClaims.test.ts +117 -0
  92. package/src/shared/__tests__/setCustomClaims.test.ts +103 -0
  93. package/src/shared/__tests__/utils.test.ts +0 -30
  94. package/src/shared/ai/classifyAIError.ts +18 -10
  95. package/src/shared/ai/createAIRoute.ts +2 -1
  96. package/src/shared/ai/resolveModelTier.ts +2 -1
  97. package/src/shared/billing/__tests__/createCheckout.test.ts +94 -0
  98. package/src/shared/billing/__tests__/firestoreIdempotency.emulator.test.ts +1 -1
  99. package/src/shared/billing/__tests__/updateUserSubscription.test.ts +139 -0
  100. package/src/shared/billing/__tests__/verifyOrderCheckout.exports.test.ts +47 -0
  101. package/src/shared/billing/__tests__/verifyOrderCheckout.supabase.integration.test.ts +107 -0
  102. package/src/shared/billing/__tests__/verifyOrderCheckout.test.ts +233 -0
  103. package/src/shared/billing/__tests__/webhookHandler.test.ts +108 -0
  104. package/src/shared/billing/checkoutValidation.ts +19 -2
  105. package/src/shared/billing/createCheckout.ts +56 -11
  106. package/src/shared/billing/helpers/subscriptionManagement.ts +14 -10
  107. package/src/shared/billing/helpers/updateUserSubscription.ts +10 -14
  108. package/src/shared/billing/index.ts +2 -0
  109. package/src/shared/billing/orderWebhook.ts +69 -1
  110. package/src/shared/billing/stripeClient.ts +2 -1
  111. package/src/shared/billing/stripePinned.ts +71 -0
  112. package/src/shared/billing/tierWebhookEvents.ts +3 -2
  113. package/src/shared/billing/verifyOrderCheckout.ts +142 -0
  114. package/src/shared/billing/webhookHandler.ts +5 -1
  115. package/src/shared/crud/bulkCore.ts +112 -82
  116. package/src/shared/crud/index.ts +1 -0
  117. package/src/shared/crud/written.ts +56 -0
  118. package/src/shared/denoEnv.ts +29 -0
  119. package/src/shared/email/createEmailRoute.ts +2 -2
  120. package/src/shared/errorHandling.ts +8 -8
  121. package/src/shared/firebase.ts +26 -9
  122. package/src/shared/github.ts +15 -5
  123. package/src/shared/index.d.ts +0 -9
  124. package/src/shared/index.ts +0 -1
  125. package/src/shared/logger.ts +37 -38
  126. package/src/shared/utils/external/date.ts +4 -4
  127. package/src/shared/utils/external/subscription.ts +2 -89
  128. package/src/shared/utils/firebaseHelpers.ts +2 -0
  129. package/src/shared/utils/internal/idempotency.ts +3 -0
  130. package/src/shared/utils/internal/monitoring.ts +6 -5
  131. package/src/shared/utils/internal/validation.ts +2 -0
  132. package/src/shared/utils/schemaValidation.ts +1 -0
  133. package/src/shared/utils/validation.ts +10 -20
  134. package/src/shared/utils.ts +4 -42
  135. package/src/supabase/__tests__/aggregate.test.ts +132 -0
  136. package/src/supabase/__tests__/bulk.test.ts +60 -2
  137. package/src/supabase/__tests__/create.test.ts +86 -0
  138. package/src/supabase/__tests__/entityStore.test.ts +91 -25
  139. package/src/supabase/__tests__/update.test.ts +107 -0
  140. package/src/supabase/auth/__tests__/deleteAccount.test.ts +102 -0
  141. package/src/supabase/auth/deleteAccount.ts +72 -5
  142. package/src/supabase/auth/removeCustomClaims.ts +7 -2
  143. package/src/supabase/auth/setCustomClaims.ts +4 -2
  144. package/src/supabase/billing/refreshSubscriptionStatus.ts +6 -5
  145. package/src/supabase/crud/aggregate.ts +85 -72
  146. package/src/supabase/crud/bulk.ts +50 -0
  147. package/src/supabase/crud/create.ts +27 -33
  148. package/src/supabase/crud/delete.ts +2 -1
  149. package/src/supabase/crud/entityStore.ts +107 -18
  150. package/src/supabase/crud/get.ts +5 -13
  151. package/src/supabase/crud/list.ts +28 -21
  152. package/src/supabase/crud/update.ts +29 -24
  153. package/src/supabase/edgeFunction.ts +2 -1
  154. package/src/supabase/email/createEmailFunction.ts +2 -1
  155. package/src/supabase/index.ts +8 -0
  156. package/src/supabase/oauth/exchangeToken.ts +1 -0
  157. package/src/supabase/oauth/getConnections.ts +1 -1
  158. package/src/supabase/oauth/refreshToken.ts +1 -0
  159. package/src/supabase/registerCrudFunctions.ts +1 -0
  160. package/src/supabase/utils/idempotency.ts +1 -1
  161. package/src/supabase/utils/monitoring.ts +1 -0
  162. package/src/vercel/__tests__/bulk.test.ts +16 -8
  163. package/src/vercel/api/billing/change-plan.ts +6 -5
  164. package/src/vercel/api/billing/refresh-subscription-status.ts +3 -1
  165. package/src/vercel/api/crud/bulk.ts +34 -6
  166. package/src/vercel/api/crud/create.ts +22 -21
  167. package/src/vercel/api/crud/delete.ts +5 -2
  168. package/src/vercel/api/crud/get.ts +10 -8
  169. package/src/vercel/api/crud/list.ts +10 -8
  170. package/src/vercel/api/crud/update.ts +25 -20
  171. package/src/vercel/api/oauth/check-github-access.ts +1 -0
  172. package/src/vercel/api/oauth/exchange-token.ts +5 -2
  173. package/src/vercel/api/oauth/grant-github-access.ts +1 -0
  174. package/src/vercel/api/oauth/revoke-github-access.ts +1 -0
  175. package/src/vercel/baseFunction.ts +5 -1
  176. package/lib/chunks/chunk-2A4FPYNB.js.map +0 -7
  177. package/lib/chunks/chunk-2IFFIUFV.js +0 -23
  178. package/lib/chunks/chunk-2IFFIUFV.js.map +0 -7
  179. package/lib/chunks/chunk-FQSQGOBN.js +0 -22
  180. package/lib/chunks/chunk-FQSQGOBN.js.map +0 -7
  181. package/lib/chunks/chunk-G4FO76EA.js +0 -22
  182. package/lib/chunks/chunk-G4FO76EA.js.map +0 -7
  183. package/lib/chunks/chunk-LSM5Y2E5.js +0 -22
  184. package/lib/chunks/chunk-LSM5Y2E5.js.map +0 -7
  185. package/lib/chunks/chunk-M4JV2JCF.js +0 -22
  186. package/lib/chunks/chunk-M4JV2JCF.js.map +0 -7
  187. package/lib/chunks/chunk-OZX5ZG44.js +0 -22
  188. package/lib/chunks/chunk-PWAGW4R6.js +0 -22
  189. package/lib/chunks/chunk-PWAGW4R6.js.map +0 -7
  190. package/lib/chunks/chunk-UYI56E6Q.js +0 -151
  191. package/lib/chunks/chunk-UYI56E6Q.js.map +0 -7
  192. package/lib/chunks/chunk-ZVHC2CAV.js +0 -22
  193. package/lib/chunks/chunk-ZVHC2CAV.js.map +0 -7
  194. package/lib/shared/schema.d.ts +0 -56
  195. package/lib/shared/utils/functionWrapper.d.ts +0 -36
  196. package/src/shared/__tests__/schema.test.ts +0 -219
  197. package/src/shared/schema.ts +0 -192
  198. package/src/shared/utils/__tests__/functionWrapper.test.ts +0 -122
  199. package/src/shared/utils/functionWrapper.ts +0 -73
  200. /package/lib/chunks/{chunk-PJCJ5H2O.js.map → chunk-HZM5X5A7.js.map} +0 -0
  201. /package/lib/chunks/{monitoring-UIDJS2KA.js.map → monitoring-UCBNPPW2.js.map} +0 -0
  202. /package/lib/chunks/{rateLimiter-WNWHI3B4.js.map → rateLimiter-XKECWM33.js.map} +0 -0
  203. /package/lib/chunks/{server-RYGEBS2B.js.map → server-24XGDDO3.js.map} +0 -0
@@ -1,22 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath } from 'node:url';
3
- import { dirname } from 'node:path';
4
- import { Buffer } from 'node:buffer';
5
- import process from 'node:process';
6
-
7
- const require = __createRequire(import.meta.url);
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
-
11
- if (typeof globalThis !== 'undefined') {
12
- globalThis.require = require;
13
- globalThis.__filename = __filename;
14
- globalThis.__dirname = __dirname;
15
- globalThis.Buffer = Buffer;
16
- globalThis.process = process;
17
- if (typeof global === 'undefined') {
18
- globalThis.global = globalThis;
19
- }
20
- }
21
- import{a as i}from"./chunk-AYY7UXNI.js";var ue={ALREADY_EXISTS:"already-exists",CANCELLED:"cancelled",DEADLINE_EXCEEDED:"deadline-exceeded",DELETE_ACCOUNT_REQUIRES_SERVER:"DELETE_ACCOUNT_REQUIRES_SERVER",INTERNAL:"internal",INVALID_ARGUMENT:"invalid-argument",NOT_FOUND:"not-found",PERMISSION_DENIED:"permission-denied",RATE_LIMIT_EXCEEDED:"rate-limit-exceeded",TIMEOUT:"timeout",UNAUTHENTICATED:"unauthenticated",UNAVAILABLE:"unavailable",UNIMPLEMENTED:"unimplemented",UNKNOWN:"unknown",VALIDATION_FAILED:"validation-failed"};var ge={INTERNAL_ERROR:"INTERNAL_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",PERMISSION_DENIED:"PERMISSION_DENIED",NOT_FOUND:"NOT_FOUND",ALREADY_EXISTS:"ALREADY_EXISTS",NETWORK_ERROR:"NETWORK_ERROR"},Re={[ue.PERMISSION_DENIED]:{type:ge.PERMISSION_DENIED,message:"You do not have permission to perform this action"},[ue.NOT_FOUND]:{type:ge.NOT_FOUND,message:"The requested resource was not found"},[ue.ALREADY_EXISTS]:{type:ge.ALREADY_EXISTS,message:"The resource already exists"},[ue.INVALID_ARGUMENT]:{type:ge.VALIDATION_ERROR,message:"Invalid argument provided"}};var O=class e extends Error{static{i(this,"DoNotDevError")}code;details;source;originalError;context;displayable;userMessageProvided;constructor(t,n=ue.INTERNAL,o){super(t),Object.setPrototypeOf(this,e.prototype),this.code=n,this.details=o?.details,this.source=o?.source,this.originalError=o?.originalError,this.context=o?.context,this.displayable=o?.displayable??!0,this.userMessageProvided=o?.userMessageProvided,this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(){return`${this.name} [${this.code}]: ${this.message}`}toJSON(){return{name:this.name,code:this.code,message:this.message,details:this.details,source:this.source,originalError:this.originalError,context:this.context,displayable:this.displayable,userMessageProvided:this.userMessageProvided}}};var q={ANTHROPIC:"anthropic",OPENAI:"openai",GOOGLE:"google"},ve={USER:"user",ASSISTANT:"assistant",SYSTEM:"system"},$n={[q.ANTHROPIC]:{default:"claude-sonnet-4-6",models:["claude-sonnet-4-6","claude-sonnet-4-20250514","claude-haiku-4-5-20251001","claude-opus-4-6","claude-opus-4-20250514"]},[q.OPENAI]:{default:"gpt-4o",models:["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","o3-mini"]},[q.GOOGLE]:{default:"gemini-2.0-flash",models:["gemini-2.0-flash","gemini-2.5-pro","gemini-2.5-flash"]}};var Gn={FAST:{id:"fast",defaultModel:"claude-haiku-4-5-20251001"},STANDARD:{id:"standard",defaultModel:"claude-sonnet-4-6"},PREMIUM:{id:"premium",defaultModel:"claude-opus-4-6"}},Hn=4,Wn={"claude-sonnet-4-6":{promptPer1M:3,completionPer1M:15,currency:"usd"},"claude-haiku-4-5-20251001":{promptPer1M:.8,completionPer1M:4,currency:"usd"},"claude-opus-4-6":{promptPer1M:15,completionPer1M:75,currency:"usd"},"claude-sonnet-4-20250514":{promptPer1M:3,completionPer1M:15,currency:"usd"},"claude-opus-4-20250514":{promptPer1M:15,completionPer1M:75,currency:"usd"},"gpt-4o":{promptPer1M:2.5,completionPer1M:10,currency:"usd"},"gpt-4o-mini":{promptPer1M:.15,completionPer1M:.6,currency:"usd"},"gpt-4.1":{promptPer1M:2,completionPer1M:8,currency:"usd"},"gpt-4.1-mini":{promptPer1M:.4,completionPer1M:1.6,currency:"usd"},"o3-mini":{promptPer1M:1.1,completionPer1M:4.4,currency:"usd"},"gemini-2.0-flash":{promptPer1M:.1,completionPer1M:.4,currency:"usd"},"gemini-2.5-pro":{promptPer1M:1.25,completionPer1M:10,currency:"usd"},"gemini-2.5-flash":{promptPer1M:.15,completionPer1M:.6,currency:"usd"}};var he,Tt={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Ce(e){return!e&&!he?Tt:{lang:e?.lang??he?.lang,message:e?.message,abortEarly:e?.abortEarly??he?.abortEarly,abortPipeEarly:e?.abortPipeEarly??he?.abortPipeEarly}}i(Ce,"getGlobalConfig");var It;function Rt(e){return It?.get(e)}i(Rt,"getGlobalMessage");var Ct;function wt(e){return Ct?.get(e)}i(wt,"getSchemaMessage");var Ot;function Pt(e,t){return Ot?.get(e)?.get(t)}i(Pt,"getSpecificMessage");function Y(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}i(Y,"_stringify");function x(e,t,n,o,c){let a=c&&"input"in c?c.input:n.value,u=c?.expected??e.expects??null,g=c?.received??Y(a),f={kind:e.kind,type:e.type,input:a,expected:u,received:g,message:`Invalid ${t}: ${u?`Expected ${u} but r`:"R"}eceived ${g}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:o.lang,abortEarly:o.abortEarly,abortPipeEarly:o.abortPipeEarly},h=e.kind==="schema",d=c?.message??e.message??Pt(e.reference,f.lang)??(h?wt(f.lang):null)??o.message??Rt(f.lang);d!==void 0&&(f.message=typeof d=="function"?d(f):d),h&&(n.typed=!1),n.issues?n.issues.push(f):n.issues=[f]}i(x,"_addIssue");function Dt(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}i(Dt,"_isSameValueZero");function Ye(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}i(Ye,"_isValidObjectKey");function we(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}i(we,"_joinExpects");function R(e){return e["~standard"]={version:1,vendor:"valibot",validate:i(t=>e["~run"]({value:t},Ce()),"validate")},e}i(R,"_standardSchema");var be=class extends Error{static{i(this,"ValiError")}constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function zn(e){return e instanceof be}i(zn,"isValiError");var _t=/^[\w+-]+(?:\.[\w+-]+)*@[\da-zA-Z]+(?:[.-][\da-zA-Z]+)*\.[a-zA-Z]{2,}$/u,Yn=new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$","u");var Nt=/^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;function le(e,t){return{kind:"validation",type:"check",reference:le,async:!1,expects:null,requirement:e,message:t,"~run"(n,o){return n.typed&&!this.requirement(n.value)&&x(this,"input",n,o),n}}}i(le,"check");function L(e){return{kind:"validation",type:"email",reference:L,expects:null,async:!1,requirement:_t,message:e,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&x(this,"email",t,n),t}}}i(L,"email");function te(e){return{kind:"validation",type:"integer",reference:te,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&x(this,"integer",t,n),t}}}i(te,"integer");function j(e){return{kind:"validation",type:"iso_timestamp",reference:j,async:!1,expects:null,requirement:Nt,message:e,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&x(this,"timestamp",t,n),t}}}i(j,"isoTimestamp");function ne(e,t){return{kind:"validation",type:"length",reference:ne,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(n,o){return n.typed&&n.value.length!==this.requirement&&x(this,"length",n,o,{received:`${n.value.length}`}),n}}}i(ne,"length");function V(e,t){return{kind:"validation",type:"max_length",reference:V,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(n,o){return n.typed&&n.value.length>this.requirement&&x(this,"length",n,o,{received:`${n.value.length}`}),n}}}i(V,"maxLength");function B(e,t){return{kind:"validation",type:"max_value",reference:B,async:!1,expects:`<=${e instanceof Date?e.toJSON():Y(e)}`,requirement:e,message:t,"~run"(n,o){return n.typed&&!(n.value<=this.requirement)&&x(this,"value",n,o,{received:n.value instanceof Date?n.value.toJSON():Y(n.value)}),n}}}i(B,"maxValue");function m(e,t){return{kind:"validation",type:"min_length",reference:m,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,o){return n.typed&&n.value.length<this.requirement&&x(this,"length",n,o,{received:`${n.value.length}`}),n}}}i(m,"minLength");function _(e,t){return{kind:"validation",type:"min_value",reference:_,async:!1,expects:`>=${e instanceof Date?e.toJSON():Y(e)}`,requirement:e,message:t,"~run"(n,o){return n.typed&&!(n.value>=this.requirement)&&x(this,"value",n,o,{received:n.value instanceof Date?n.value.toJSON():Y(n.value)}),n}}}i(_,"minValue");function Oe(e){return{kind:"transformation",type:"raw_transform",reference:Oe,async:!1,"~run"(t,n){let o=e({dataset:t,config:n,addIssue:i(c=>x(this,c?.label??"input",t,n,c),"addIssue"),NEVER:null});return t.issues?t.typed=!1:t.value=o,t}}}i(Oe,"rawTransform");function re(e,t){return{kind:"validation",type:"regex",reference:re,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(n,o){return n.typed&&!this.requirement.test(n.value)&&x(this,"format",n,o),n}}}i(re,"regex");function Ft(e){return{kind:"transformation",type:"transform",reference:Ft,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}i(Ft,"transform");function N(e){return{kind:"validation",type:"url",reference:N,async:!1,expects:null,requirement(t){try{return URL.canParse?URL.canParse(t):(new URL(t),!0)}catch{return!1}},message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&x(this,"URL",t,n),t}}}i(N,"url");var Ut={abortEarly:!0};function Xe(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}i(Xe,"getFallback");function ce(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}i(ce,"getDefault");function X(){return R({kind:"schema",type:"any",reference:X,expects:"any",async:!1,"~run"(e){return e.typed=!0,e}})}i(X,"any");function v(e,t){return R({kind:"schema",type:"array",reference:v,expects:"Array",async:!1,item:e,message:t,"~run"(n,o){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let a=0;a<c.length;a++){let u=c[a],g=this.item["~run"]({value:u},o);if(g.issues){let f={type:"array",origin:"value",input:c,key:a,value:u};for(let h of g.issues)h.path?h.path.unshift(f):h.path=[f],n.issues?.push(h);if(n.issues||(n.issues=g.issues),o.abortEarly){n.typed=!1;break}}g.typed||(n.typed=!1),n.value.push(g.value)}}else x(this,"type",n,o);return n}})}i(v,"array");function S(e){return R({kind:"schema",type:"boolean",reference:S,expects:"boolean",async:!1,message:e,"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:x(this,"type",t,n),t}})}i(S,"boolean");function Pe(e,t){return R({kind:"schema",type:"custom",reference:Pe,expects:"unknown",async:!1,check:e,message:t,"~run"(n,o){return this.check(n.value)?n.typed=!0:x(this,"type",n,o),n}})}i(Pe,"custom");function De(e){return R({kind:"schema",type:"lazy",reference:De,expects:"unknown",async:!1,getter:e,"~run"(t,n){return this.getter(t.value)["~run"](t,n)}})}i(De,"lazy");function F(e,t){return R({kind:"schema",type:"literal",reference:F,expects:Y(e),async:!1,literal:e,message:t,"~run"(n,o){return Dt(n.value,this.literal)?n.typed=!0:x(this,"type",n,o),n}})}i(F,"literal");function _e(e,t){return R({kind:"schema",type:"loose_object",reference:_e,expects:"Object",async:!1,entries:e,message:t,"~run"(n,o){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let a in this.entries){let u=this.entries[a];if(a in c||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){let g=a in c?c[a]:ce(u),f=u["~run"]({value:g},o);if(f.issues){let h={type:"object",origin:"value",input:c,key:a,value:g};for(let d of f.issues)d.path?d.path.unshift(h):d.path=[h],n.issues?.push(d);if(n.issues||(n.issues=f.issues),o.abortEarly){n.typed=!1;break}}f.typed||(n.typed=!1),n.value[a]=f.value}else if(u.fallback!==void 0)n.value[a]=Xe(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(x(this,"key",n,o,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:c,key:a,value:c[a]}]}),o.abortEarly))break}if(!n.issues||!o.abortEarly)for(let a in c)Ye(c,a)&&!Object.prototype.hasOwnProperty.call(this.entries,a)&&(n.value[a]=c[a])}else x(this,"type",n,o);return n}})}i(_e,"looseObject");function Ne(e){return R({kind:"schema",type:"never",reference:Ne,expects:"never",async:!1,message:e,"~run"(t,n){return x(this,"type",t,n),t}})}i(Ne,"never");function P(e,t){return R({kind:"schema",type:"nullable",reference:P,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(n,o){return n.value===null&&(this.default!==void 0&&(n.value=ce(this,n,o)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,o)}})}i(P,"nullable");function U(e,t){return R({kind:"schema",type:"nullish",reference:U,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,"~run"(n,o){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=ce(this,n,o)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,o)}})}i(U,"nullish");function A(e){return R({kind:"schema",type:"number",reference:A,expects:"number",async:!1,message:e,"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:x(this,"type",t,n),t}})}i(A,"number");function p(e,t){return R({kind:"schema",type:"object",reference:p,expects:"Object",async:!1,entries:e,message:t,"~run"(n,o){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let a in this.entries){let u=this.entries[a];if(a in c||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){let g=a in c?c[a]:ce(u),f=u["~run"]({value:g},o);if(f.issues){let h={type:"object",origin:"value",input:c,key:a,value:g};for(let d of f.issues)d.path?d.path.unshift(h):d.path=[h],n.issues?.push(d);if(n.issues||(n.issues=f.issues),o.abortEarly){n.typed=!1;break}}f.typed||(n.typed=!1),n.value[a]=f.value}else if(u.fallback!==void 0)n.value[a]=Xe(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(x(this,"key",n,o,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:c,key:a,value:c[a]}]}),o.abortEarly))break}}else x(this,"type",n,o);return n}})}i(p,"object");function s(e,t){return R({kind:"schema",type:"optional",reference:s,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(n,o){return n.value===void 0&&(this.default!==void 0&&(n.value=ce(this,n,o)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,o)}})}i(s,"optional");function b(e,t){return R({kind:"schema",type:"picklist",reference:b,expects:we(e.map(Y),"|"),async:!1,options:e,message:t,"~run"(n,o){return this.options.includes(n.value)?n.typed=!0:x(this,"type",n,o),n}})}i(b,"picklist");function E(e,t,n){return R({kind:"schema",type:"record",reference:E,expects:"Object",async:!1,key:e,value:t,message:n,"~run"(o,c){let a=o.value;if(a&&typeof a=="object"){o.typed=!0,o.value={};for(let u in a)if(Ye(a,u)){let g=a[u],f=this.key["~run"]({value:u},c);if(f.issues){let d={type:"object",origin:"key",input:a,key:u,value:g};for(let C of f.issues)C.path=[d],o.issues?.push(C);if(o.issues||(o.issues=f.issues),c.abortEarly){o.typed=!1;break}}let h=this.value["~run"]({value:g},c);if(h.issues){let d={type:"object",origin:"value",input:a,key:u,value:g};for(let C of h.issues)C.path?C.path.unshift(d):C.path=[d],o.issues?.push(C);if(o.issues||(o.issues=h.issues),c.abortEarly){o.typed=!1;break}}(!f.typed||!h.typed)&&(o.typed=!1),f.typed&&(o.value[f.value]=h.value)}}else x(this,"type",o,c);return o}})}i(E,"record");function r(e){return R({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,n){return typeof t.value=="string"?t.typed=!0:x(this,"type",t,n),t}})}i(r,"string");function Mt(e,t){return R({kind:"schema",type:"tuple",reference:Mt,expects:"Array",async:!1,items:e,message:t,"~run"(n,o){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let a=0;a<this.items.length;a++){let u=c[a],g=this.items[a]["~run"]({value:u},o);if(g.issues){let f={type:"array",origin:"value",input:c,key:a,value:u};for(let h of g.issues)h.path?h.path.unshift(f):h.path=[f],n.issues?.push(h);if(n.issues||(n.issues=g.issues),o.abortEarly){n.typed=!1;break}}g.typed||(n.typed=!1),n.value.push(g.value)}}else x(this,"type",n,o);return n}})}i(Mt,"tuple");function ze(e){let t;if(e)for(let n of e)if(t)for(let o of n.issues)t.push(o);else t=n.issues;return t}i(ze,"_subIssues");function Z(e,t){return R({kind:"schema",type:"union",reference:Z,expects:we(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,"~run"(n,o){let c,a,u;for(let g of this.options){let f=g["~run"]({value:n.value},o);if(f.typed)if(f.issues)a?a.push(f):a=[f];else{c=f;break}else u?u.push(f):u=[f]}if(c)return c;if(a){if(a.length===1)return a[0];x(this,"type",n,o,{issues:ze(a)}),n.typed=!0}else{if(u?.length===1)return u[0];x(this,"type",n,o,{issues:ze(u)})}return n}})}i(Z,"union");function D(){return R({kind:"schema",type:"unknown",reference:D,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}i(D,"unknown");function pe(e,t,n){return R({kind:"schema",type:"variant",reference:pe,expects:"Object",async:!1,key:e,options:t,message:n,"~run"(o,c){let a=o.value;if(a&&typeof a=="object"){let u,g=0,f=this.key,h=[],d=i((C,w)=>{for(let $ of C.options){if($.type==="variant")d($,new Set(w).add($.key));else{let ye=!0,ee=0;for(let k of w){let I=$.entries[k];if(k in a?I["~run"]({typed:!1,value:a[k]},Ut).issues:I.type!=="exact_optional"&&I.type!=="optional"&&I.type!=="nullish"){ye=!1,f!==k&&(g<ee||g===ee&&k in a&&!(f in a))&&(g=ee,f=k,h=[]),f===k&&h.push($.entries[k].expects);break}ee++}if(ye){let k=$["~run"]({value:a},c);(!u||!u.typed&&k.typed)&&(u=k)}}if(u&&!u.issues)break}},"parseOptions");if(d(this,new Set([this.key])),u)return u;x(this,"type",o,c,{input:a[f],expected:we(h,"|"),path:[{type:"object",origin:"value",input:a,key:f,value:a[f]}]})}else x(this,"type",o,c);return o}})}i(pe,"variant");function Ze(e,t,n){let o=e["~run"]({value:t},Ce(n));if(o.issues)throw new be(o.issues);return o.value}i(Ze,"parse");function l(...e){return R({...e[0],pipe:e,"~run"(t,n){for(let o of e)if(o.kind!=="metadata"){if(t.issues&&(o.kind==="schema"||o.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=o["~run"](t,n))}return t}})}i(l,"pipe");function H(e,t,n){let o=e["~run"]({value:t},Ce(n));return{typed:o.typed,success:!o.issues,output:o.value,issues:o.issues}}i(H,"safeParse");var Je=p({role:b([ve.USER,ve.ASSISTANT,ve.SYSTEM]),content:l(r(),m(1)),id:s(r()),createdAt:s(r())}),Fe=De(()=>p({type:b(["string","number","boolean","array","object"]),description:s(r()),enum:s(v(r())),items:s(Fe),properties:s(E(r(),Fe)),required:s(v(r()))})),Lt=p({description:l(r(),m(1)),parameters:p({type:F("object"),properties:E(r(),Fe),required:s(v(r()))})}),Bt=p({id:r(),name:r(),args:E(r(),D())}),qt=p({messages:l(v(Je),m(1)),provider:s(b([q.ANTHROPIC,q.OPENAI,q.GOOGLE])),model:s(r()),maxTokens:s(l(A(),te(),_(1))),temperature:s(l(A(),_(0),B(2))),systemPrompt:s(r()),stream:s(S()),tools:s(E(r(),Lt))}),jt=p({promptTokens:A(),completionTokens:A(),totalTokens:A()}),Qn=p({message:Je,usage:s(jt),finishReason:s(r()),toolCalls:s(v(Bt))}),er=p({provider:b([q.ANTHROPIC,q.OPENAI,q.GOOGLE]),model:s(r()),maxTokens:s(l(A(),te(),_(1))),temperature:s(l(A(),_(0),B(2))),systemPrompt:s(r())});function tr(e){return H(qt,e)}i(tr,"validateAIChatRequest");var W={GUEST:"guest",USER:"user",ADMIN:"admin",SUPER:"super"};var Qe={FREE:"free",PRO:"pro",PREMIUM:"premium"};var et={BASIC_ACCESS:"basic_access",ADVANCED_FEATURES:"advanced_features",API_ACCESS:"api_access",PRIORITY_SUPPORT:"priority_support"};var tt={READ_PUBLIC:"read_public",READ_OWN_DATA:"read_own_data",WRITE_OWN_DATA:"write_own_data",READ_ALL_DATA:"read_all_data",MANAGE_USERS:"manage_users"};var de={ACTIVE:"active",CANCELED:"canceled",INCOMPLETE:"incomplete",INCOMPLETE_EXPIRED:"incomplete_expired",PAST_DUE:"past_due",TRIALING:"trialing",UNPAID:"unpaid"};var Ue={PAYMENT:"payment",SUBSCRIPTION:"subscription"};var cr={tier:"free",subscriptionId:null,customerId:"",status:"active",subscriptionEnd:null,cancelAtPeriodEnd:!1,updatedAt:new Date().toISOString(),isDefault:!0};var nt=100,Vt=p({productId:l(r(),m(1),V(200)),quantity:l(A(),te(),_(1),B(1e4))}),mr=l(p({billingConfigKey:s(l(r(),m(1))),lineItems:s(l(v(Vt),m(1,"At least one line item is required"),V(nt,`At most ${nt} line items`))),successUrl:l(r(),N()),cancelUrl:l(r(),N()),customerEmail:s(l(r(),L())),metadata:s(E(r(),r())),allowPromotionCodes:s(S()),userId:s(r()),productId:s(r()),priceId:s(r()),currency:s(l(r(),ne(3,"Currency must be 3-letter ISO code"))),userEmail:s(l(r(),L())),mode:s(b([Ue.PAYMENT,Ue.SUBSCRIPTION]))}),Oe(({dataset:e,addIssue:t,NEVER:n})=>{let o=e.value,c=o.billingConfigKey||o.metadata?.billingConfigKey;return c?{...o,billingConfigKey:c,lineItems:o.lineItems??[{productId:c,quantity:1}]}:(t({message:"billingConfigKey is required"}),n)})),yr=p({sessionId:r(),sessionUrl:P(l(r(),N()))}),gr=p({userId:r(),tier:r(),status:b(Object.values(de)),subscriptionId:P(r()),customerId:r(),subscriptionEnd:P(l(r(),j())),cancelAtPeriodEnd:S(),updatedAt:l(r(),j())}),vr=p({tier:r(),subscriptionId:P(r()),customerId:r(),status:b(Object.values(de)),subscriptionEnd:P(l(r(),j())),cancelAtPeriodEnd:S(),updatedAt:l(r(),j()),isDefault:s(S())}),hr=p({id:r(),type:r(),data:p({object:X()}),created:l(r(),j())}),br=_e({userId:s(r()),firebaseUid:s(r()),productType:s(r())});var $t=p({type:F("StripePayment"),name:l(r(),m(1,"Product name is required")),description:s(r()),price:r(),currency:s(l(r(),ne(3,"Currency must be 3-letter ISO code")),"EUR"),priceId:s(l(r(),m(1,"Stripe price ID is required"))),tier:l(r(),m(1,"Tier is required")),duration:l(r(),m(1,"Duration is required")),allowPromotionCodes:s(S()),metadata:s(E(r(),r()))}),Gt=p({type:F("StripeSubscription"),name:l(r(),m(1,"Product name is required")),description:s(r()),price:r(),currency:s(l(r(),ne(3,"Currency must be 3-letter ISO code")),"EUR"),priceId:l(r(),m(1,"Stripe price ID is required")),tier:l(r(),m(1,"Tier is required")),duration:b(["1month","3months","6months","1year","2years","lifetime"]),allowPromotionCodes:s(S()),metadata:s(E(r(),r()))}),Ht=pe("type",[$t,Gt]),Er=E(r(),Ht),xr=E(r(),p({name:r(),price:r(),currency:r(),description:s(r()),features:s(v(r())),priceId:s(r()),allowPromotionCodes:s(S())})),rt={name:r(),price:A(),currency:r(),priceId:s(r()),tier:r(),duration:r(),description:s(r()),metadata:s(E(r(),r())),allowPromotionCodes:s(S())},Wt=pe("mode",[p({mode:F("manual"),taxRateIds:l(v(l(r(),m(1))),m(1))}),p({mode:F("automatic")})]),it=5,Kt=p({allowedCountries:l(v(l(r(),re(/^[A-Z]{2}$/,"allowedCountries: uppercase ISO 3166-1 alpha-2 code expected (e.g. FR)"))),m(1)),shippingRateIds:s(l(v(l(r(),m(1))),V(it,`shippingRateIds: at most ${it} (Stripe limit)`)))}),zt=p({type:F("StripeOrder"),name:r(),currency:l(r(),ne(3)),description:s(r()),metadata:s(E(r(),r())),allowPromotionCodes:s(S()),tax:Wt,taxIdCollection:b(["disabled","optional","required"]),billingAddressCollection:b(["auto","required"]),shipping:s(Kt),customerCreation:b(["always","if_required"]),invoiceCreation:S(),paymentMethodConfiguration:s(l(r(),m(1)))}),Yt=E(r(),pe("type",[p({type:F("StripePayment"),...rt}),p({type:F("StripeSubscription"),...rt}),zt]));function Sr(e){return Ze(Yt,e)}i(Sr,"validateStripeBackConfig");var Pr=p({id:r(),email:s(P(l(r(),L()))),displayName:s(P(r())),photoURL:s(P(l(r(),N()))),emailVerified:s(S()),lastLoginAt:s(r()),providerData:s(v(p({providerId:r(),uid:r(),email:s(P(l(r(),L()))),displayName:s(P(r())),photoURL:s(P(l(r(),N()))),phoneNumber:s(P(r()))}))),role:s(b(Object.values(W))),customClaims:s(E(r(),X()))}),Xt=p({userId:r(),tier:b(Object.values(Qe)),status:b(Object.values(de)),isActive:s(S()),features:s(v(r())),subscriptionId:P(r()),customerId:r(),subscriptionEnd:P(l(r(),j())),cancelAtPeriodEnd:S(),updatedAt:l(r(),j())}),Dr=p({role:s(b(Object.values(W))),subscription:s(Xt),features:s(v(b(Object.values(et)))),permissions:s(v(b(Object.values(tt)))),githubAccess:s(p({username:s(r()),teamAccess:s(v(r())),repoAccess:s(v(r()))}))});var Me={TRUE:!0,FALSE:!1,USER:"user",ADMIN:"admin",SUPER:"super",CREATE_ONLY:"create-only",GENERATED:"generated",COMPUTED:"computed"};var J={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">=",IN:"in",NOT_IN:"not-in",ARRAY_CONTAINS:"array-contains",ARRAY_CONTAINS_ANY:"array-contains-any"};var Hr={EQ:J.EQ,NEQ:J.NEQ,LT:J.LT,LTE:J.LTE,GT:J.GT,GTE:J.GTE};var ot=class extends Error{static{i(this,"BulkCollisionError")}collidingIds;where;constructor(t,n){super(`BulkCollisionError: ${t.length} id(s) appear in both "${n.replace("-",'" and "')}" \u2014 ${t.join(", ")}`),this.name="BulkCollisionError",this.collidingIds=t,this.where=n}};var Qr=p({collection:l(r(),m(1,"Collection name is required")),data:E(r(),D()),idempotencyKey:s(r())}),ei=p({collection:l(r(),m(1,"Collection name is required")),id:l(r(),m(1,"Entity ID is required"))}),ti=p({collection:l(r(),m(1,"Collection name is required")),id:l(r(),m(1,"Entity ID is required")),data:E(r(),D()),merge:s(S(),!1)}),ni=p({collection:l(r(),m(1,"Collection name is required")),id:l(r(),m(1,"Entity ID is required"))}),ri=p({collection:l(r(),m(1,"Collection name is required")),limit:s(l(A(),_(1),B(1e3)),1e3),offset:s(l(A(),_(0)),0),orderBy:s(r()),orderDirection:s(b(["asc","desc"]),"desc"),where:s(v(p({field:r(),operator:b(["==","!=","<","<=",">",">=","array-contains","in","not-in"]),value:D()})))});var Jt=p({templateId:l(r(),m(1)),to:l(r(),L()),data:E(r(),D()),locale:s(l(r(),m(2),V(5)),"fr"),from:s(r()),replyTo:s(r())}),yi=p({success:S(),messageId:s(r()),error:s(r())});function gi(e){return H(Jt,e)}i(gi,"validateSendEmailRequest");var st=["pull","push","admin","maintain","triage"];var Le=p({owner:l(r(),m(1,"Repository owner is required")),repo:l(r(),m(1,"Repository name is required"))}),Qt=b([...st]),to=p({userId:l(r(),m(1,"User ID is required")),githubUsername:l(r(),m(1,"GitHub username is required")),repoConfig:Le,permission:s(Qt,"push"),customClaims:s(E(r(),X()))}),no=p({userId:l(r(),m(1,"User ID is required")),githubUsername:l(r(),m(1,"GitHub username is required")),repoConfig:Le}),ro=p({userId:l(r(),m(1,"User ID is required")),githubUsername:l(r(),m(1,"GitHub username is required")),repoConfig:Le}),io=p({provider:r(),purpose:b(["authentication","api-access"]),code:l(r(),m(1,"Authorization code is required")),redirectUri:l(r(),N("Valid redirect URI is required")),codeVerifier:s(r()),state:s(r()),instance:s(l(r(),N()))}),oo=p({provider:r(),refreshToken:l(r(),m(1,"Refresh token is required")),redirectUri:l(r(),N("Valid redirect URI is required"))}),so=p({provider:r()}),ao=p({userId:l(r(),m(1,"User ID is required"))});var at=p({name:r(),color:r(),icon:r(),customParameters:s(E(r(),r())),button:p({backgroundColor:r(),textColor:r(),borderColor:r(),hoverBackgroundColor:r(),focusOutlineColor:r(),fontWeight:s(r(),"500"),textKey:s(r())})}),en=p({...at.entries,type:b(["auth","both"]),scopes:s(v(r())),firebaseProviderId:s(r())}),Ee=Z([F(""),l(r(),N())]),tn=p({authUrl:Ee,tokenUrl:Ee,profileUrl:Ee,revokeUrl:s(Ee)}),nn=p({authentication:s(v(r())),"api-access":v(r())}),rn=s(p({pkce:s(S(),!1),codeChallengeMethod:s(b(["S256","plain"]),"S256")})),on=p({...at.entries,type:b(["oauth","both"]),scopes:nn,endpoints:tn,capabilities:rn});var yo={google:{name:"Google",color:"#4285F4",icon:"google",type:"both",scopes:{authentication:["openid","profile","email"],"api-access":["https://www.googleapis.com/auth/drive.readonly","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/calendar.readonly","https://www.googleapis.com/auth/gmail.readonly"]},endpoints:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",profileUrl:"https://www.googleapis.com/oauth2/v3/userinfo",revokeUrl:"https://oauth2.googleapis.com/revoke"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},github:{name:"GitHub",color:"#24292E",icon:"github",type:"both",scopes:{authentication:["read:user","user:email"],"api-access":["repo","user","read:org","gist","notifications"]},endpoints:{authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",profileUrl:"https://api.github.com/user",revokeUrl:"https://api.github.com/applications/CLIENT_ID/token"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},discord:{name:"Discord",color:"#5865F2",icon:"discord",type:"both",scopes:{authentication:["identify","email"],"api-access":["guilds","guilds.members.read","bot","messages.read"]},endpoints:{authUrl:"https://discord.com/api/oauth2/authorize",tokenUrl:"https://discord.com/api/oauth2/token",profileUrl:"https://discord.com/api/users/@me",revokeUrl:"https://discord.com/api/oauth2/token/revoke"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},spotify:{name:"Spotify",color:"#1DB954",icon:"spotify",type:"both",scopes:{authentication:["user-read-email","user-read-private"],"api-access":["user-read-playback-state","user-modify-playback-state","user-read-currently-playing","playlist-read-private","playlist-modify-public","user-library-read"]},endpoints:{authUrl:"https://accounts.spotify.com/authorize",tokenUrl:"https://accounts.spotify.com/api/token",profileUrl:"https://api.spotify.com/v1/me",revokeUrl:"https://accounts.spotify.com/api/token"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},twitch:{name:"Twitch",color:"#9146FF",icon:"twitch",type:"both",scopes:{authentication:["user:read:email"],"api-access":["channel:read:subscriptions","bits:read","channel:manage:broadcast","channel:read:stream_key","user:read:follows"]},endpoints:{authUrl:"https://id.twitch.tv/oauth2/authorize",tokenUrl:"https://id.twitch.tv/oauth2/token",profileUrl:"https://api.twitch.tv/helix/users",revokeUrl:"https://id.twitch.tv/oauth2/revoke"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},reddit:{name:"Reddit",color:"#FF4500",icon:"reddit",type:"both",scopes:{authentication:["identity"],"api-access":["read","submit","vote","mysubreddits","subscribe"]},endpoints:{authUrl:"https://www.reddit.com/api/v1/authorize",tokenUrl:"https://www.reddit.com/api/v1/access_token",profileUrl:"https://oauth.reddit.com/api/v1/me",revokeUrl:"https://www.reddit.com/api/v1/revoke_token"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},linkedin:{name:"LinkedIn",color:"#0077B5",icon:"linkedin",type:"oauth",scopes:{"api-access":["r_liteprofile","r_emailaddress","w_member_social","r_organization_social"]},endpoints:{authUrl:"https://www.linkedin.com/oauth/v2/authorization",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",profileUrl:"https://api.linkedin.com/v2/me",revokeUrl:"https://www.linkedin.com/oauth/v2/revoke"},capabilities:{pkce:!1},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},slack:{name:"Slack",color:"#E01E5A",icon:"slack",type:"oauth",scopes:{"api-access":["channels:read","chat:write","users:read","files:read","im:read"]},endpoints:{authUrl:"https://slack.com/oauth/v2/authorize",tokenUrl:"https://slack.com/api/oauth.v2.access",profileUrl:"https://slack.com/api/users.identity",revokeUrl:"https://slack.com/api/auth.revoke"},capabilities:{pkce:!1},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},notion:{name:"Notion",color:"#000000",icon:"notion",type:"oauth",scopes:{"api-access":["read","write"]},endpoints:{authUrl:"https://api.notion.com/v1/oauth/authorize",tokenUrl:"https://api.notion.com/v1/oauth/token",profileUrl:"https://api.notion.com/v1/users/me",revokeUrl:"https://api.notion.com/v1/oauth/revoke"},capabilities:{pkce:!1},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},medium:{name:"Medium",color:"#000000",icon:"medium",type:"oauth",scopes:{"api-access":["basicProfile","publishPost","listPublications"]},endpoints:{authUrl:"https://medium.com/m/oauth/authorize",tokenUrl:"https://medium.com/v1/tokens",profileUrl:"https://medium.com/v1/me",revokeUrl:"https://medium.com/v1/tokens/revoke"},capabilities:{pkce:!1},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},twitter:{name:"X",color:"#000000",icon:"twitter",type:"oauth",scopes:{"api-access":["tweet.read","users.read","follows.read","tweet.write","like.write"]},endpoints:{authUrl:"https://twitter.com/i/oauth2/authorize",tokenUrl:"https://api.twitter.com/2/oauth2/token",profileUrl:"https://api.twitter.com/2/users/me",revokeUrl:"https://api.twitter.com/2/oauth2/revoke"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},mastodon:{name:"Mastodon",color:"#6364FF",icon:"mastodon",type:"oauth",scopes:{"api-access":["read","write","follow","push"]},endpoints:{authUrl:"",tokenUrl:"",profileUrl:"",revokeUrl:""},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},youtube:{name:"YouTube",color:"#FF0000",icon:"youtube",type:"oauth",scopes:{"api-access":["https://www.googleapis.com/auth/youtube.readonly","https://www.googleapis.com/auth/youtube.upload","https://www.googleapis.com/auth/youtube.force-ssl"]},endpoints:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",profileUrl:"https://www.googleapis.com/youtube/v3/channels",revokeUrl:"https://oauth2.googleapis.com/revoke"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}},supabase:{name:"Supabase",color:"#3ECF8E",icon:"supabase",type:"oauth",scopes:{"api-access":["auth:read","auth:write","database:read","database:write","domains:read","domains:write","edge_functions:read","edge_functions:write","environment:read","environment:write","organizations:read","projects:read","projects:write","rest:read","rest:write","secrets:read","secrets:write","storage:read"]},endpoints:{authUrl:"https://api.supabase.com/v1/oauth/authorize",tokenUrl:"https://api.supabase.com/v1/oauth/token",profileUrl:"",revokeUrl:""},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#F1F3F5",textColor:"#11181C",borderColor:"#E6E8EB",hoverBackgroundColor:"#E6E8EB",focusOutlineColor:"#3ECF8E",fontWeight:"500"}},vercel:{name:"Vercel",color:"#000000",icon:"vercel",type:"oauth",scopes:{authentication:["openid","email","profile","offline_access"],"api-access":["project","project-env-vars","deployment","team","user"]},endpoints:{authUrl:"https://vercel.com/oauth/authorize",tokenUrl:"https://api.vercel.com/login/oauth/token",profileUrl:"https://api.vercel.com/login/oauth/userinfo",revokeUrl:"https://api.vercel.com/login/oauth/token/revoke"},capabilities:{pkce:!0,codeChallengeMethod:"S256"},button:{backgroundColor:"#ffffff",textColor:"#000000",borderColor:"#d1d5db",hoverBackgroundColor:"#f9fafb",focusOutlineColor:"#3b82f6",fontWeight:"500"}}},go=E(r(),en),vo=E(r(),on);var ut={NECESSARY:"necessary",FUNCTIONAL:"functional",ANALYTICS:"analytics",MARKETING:"marketing"};var Co={auth:{requiresConsent:null},oauth:{requiresConsent:null},billing:{requiresConsent:null},analytics:{requiresConsent:ut.ANALYTICS},marketing:{requiresConsent:ut.MARKETING}};function lt(e){return e instanceof Error&&"source"in e&&typeof e.source=="string"?e.source:typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("auth/")?"auth":typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("oauth/")?"oauth":typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&["permission-denied","unavailable","not-found","already-exists","unauthenticated","invalid-argument","failed-precondition","resource-exhausted"].includes(e.code)?"firebase":typeof e=="object"&&e!==null&&"issues"in e&&Array.isArray(e.issues)&&"name"in e&&e.name==="ValiError"?"validation":e instanceof Error&&e.name==="EntityHookError"?"entity":typeof e=="object"&&e!==null&&("response"in e||"status"in e||"statusText"in e)?"api":typeof e=="object"&&e!==null&&"componentStack"in e?"ui":"unknown"}i(lt,"detectErrorSource");function G(e){return(t,n)=>{if(t instanceof O)return t;if(typeof t!="object"||t===null){let g=typeof t=="string"?t:e.defaultErrorMessage;return new O(n||g,e.defaultErrorCode,{details:{originalError:t},source:e.errorSource})}let o;e.extractErrorCode?o=e.extractErrorCode(t):"code"in t&&typeof t.code=="string"&&(o=t.code);let c=e.defaultErrorCode;o&&e.errorCodeMapping&&o in e.errorCodeMapping&&(c=e.errorCodeMapping[o]);let a;e.extractErrorMessage?a=e.extractErrorMessage(t):("message"in t&&typeof t.message=="string"||t instanceof Error)&&(a=t.message),o&&e.friendlyMessageMapping&&o in e.friendlyMessageMapping&&(a=e.friendlyMessageMapping[o]),a||(a=e.defaultErrorMessage);let u;return e.processMetadata?u=e.processMetadata(t):(u={originalError:t},o&&(u.originalCode=o)),"originalError"in u||(u.originalError=t),new O(n||a,c,{details:u,source:e.errorSource})}}i(G,"createErrorHandler");var xe={"permission-denied":"permission-denied",unavailable:"unavailable","not-found":"not-found","already-exists":"already-exists",unauthenticated:"unauthenticated","invalid-argument":"invalid-argument","failed-precondition":"invalid-argument","resource-exhausted":"rate-limit-exceeded","deadline-exceeded":"timeout",cancelled:"cancelled","not-implemented":"unimplemented"};var ie={"already-exists":"The resource already exists.",cancelled:"The operation was cancelled.","deadline-exceeded":"The operation timed out.",DELETE_ACCOUNT_REQUIRES_SERVER:"Account deletion requires a server endpoint. Configure a callable provider or deploy a delete-account Edge Function.",internal:"An internal error occurred.","invalid-argument":"Invalid argument provided.","not-found":"The requested resource was not found.","permission-denied":"You do not have permission to perform this action.","rate-limit-exceeded":"Too many requests. Please try again later.",timeout:"The operation timed out.",unauthenticated:"Authentication is required for this action.",unavailable:"The service is currently unavailable.",unimplemented:"This feature is not implemented.",unknown:"An unknown error occurred.","validation-failed":"Validation failed."},sn={400:"invalid-argument",401:"unauthenticated",403:"permission-denied",404:"not-found",409:"already-exists",422:"validation-failed",429:"rate-limit-exceeded",500:"internal",501:"unimplemented",502:"unavailable",503:"unavailable",504:"timeout"},Be={INTERNAL_ERROR:"internal",VALIDATION_ERROR:"validation-failed",PERMISSION_DENIED:"permission-denied",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",NETWORK_ERROR:"unavailable"},K={auth:{errorSource:"auth",defaultErrorCode:"unknown",defaultErrorMessage:"An authentication error occurred",errorCodeMapping:{"auth/user-not-found":"not-found","auth/wrong-password":"invalid-argument","auth/email-already-in-use":"already-exists","auth/weak-password":"validation-failed","auth/invalid-email":"validation-failed","auth/account-exists-with-different-credential":"already-exists","auth/credential-already-in-use":"already-exists","auth/requires-recent-login":"unauthenticated","auth/user-disabled":"permission-denied","auth/too-many-requests":"rate-limit-exceeded","auth/network-request-failed":"unavailable","auth/popup-blocked":"unavailable","auth/popup-closed-by-user":"invalid-argument","auth/cancelled-popup-request":"invalid-argument","auth/operation-not-allowed":"unimplemented","auth/invalid-credential":"invalid-argument","auth/invalid-verification-code":"invalid-argument","auth/captcha-check-failed":"validation-failed","auth/invalid-phone-number":"validation-failed","auth/missing-phone-number":"invalid-argument","auth/quota-exceeded":"rate-limit-exceeded","auth/timeout":"unavailable","auth/web-storage-unsupported":"unavailable","auth/unauthorized-domain":"permission-denied","auth/internal-error":"internal","auth/invalid-action-code":"invalid-argument","auth/invalid-continue-uri":"invalid-argument","auth/missing-continue-uri":"invalid-argument","auth/missing-ios-bundle-id":"invalid-argument","auth/missing-android-pkg-name":"invalid-argument","auth/unauthorized-continue-uri":"permission-denied","auth/invalid-dynamic-link-domain":"invalid-argument","auth/invalid-tenant-id":"invalid-argument","auth/tenant-id-mismatch":"invalid-argument","auth/provider-already-linked":"already-exists","auth/invalid-persistence-type":"invalid-argument","auth/unsupported-persistence-type":"unimplemented","auth/invalid-provider":"invalid-argument","auth/invalid-client-id":"invalid-argument","oauth/unauthorized-app":"permission-denied","auth/provider-not-enabled":"unimplemented","auth/unknown-provider":"invalid-argument","auth/missing-provider":"invalid-argument","auth/no-user-signed-in":"unauthenticated",DELETE_ACCOUNT_REQUIRES_SERVER:"DELETE_ACCOUNT_REQUIRES_SERVER",...xe},friendlyMessageMapping:{"auth/user-not-found":"No account found with this email address.","auth/wrong-password":"Incorrect password. Please try again.","auth/email-already-in-use":"An account with this email already exists.","auth/weak-password":"Password is too weak. It should be at least 6 characters.","auth/invalid-email":"Please enter a valid email address.","auth/account-exists-with-different-credential":"An account already exists with the same email but different sign-in method.","auth/credential-already-in-use":"This credential is already associated with a different user account.","auth/requires-recent-login":"This operation requires you to sign in again for security reasons.","auth/user-disabled":"This account has been disabled.","auth/too-many-requests":"Too many sign-in attempts. Please try again later.","auth/network-request-failed":"Network connection error. Please check your internet connection.","auth/popup-blocked":"Sign-in popup was blocked. Please allow popups for this site.","auth/popup-closed-by-user":"Sign-in popup was closed before completion.","auth/operation-not-allowed":"This sign-in method is not enabled for this project.","auth/internal-error":"An internal authentication error occurred. Please try again.","auth/invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","auth/invalid-continue-uri":"The continue URL provided is invalid.","auth/missing-continue-uri":"A continue URL must be provided in the request.","auth/missing-ios-bundle-id":"An iOS Bundle ID must be provided in the request.","auth/missing-android-pkg-name":"An Android package name must be provided in the request.","auth/unauthorized-continue-uri":"The domain of the continue URL is not allowlisted.","auth/invalid-dynamic-link-domain":"The provided dynamic link domain is not authorized.","auth/invalid-tenant-id":"The provided tenant ID is invalid.","auth/tenant-id-mismatch":"The tenant ID of the provider does not match the tenant ID of the current user.","auth/provider-already-linked":"This authentication provider is already linked to the account.","auth/invalid-persistence-type":"The specified persistence type is invalid.","auth/unsupported-persistence-type":"The current environment does not support the specified persistence type.","auth/invalid-provider":"The specified authentication provider is invalid.","auth/invalid-client-id":"The authentication client ID provided is invalid.","oauth/unauthorized-app":"This application is not authorized to use OAuth with the provided client ID.","auth/provider-not-enabled":"This authentication provider is not enabled.","auth/unknown-provider":"Unknown authentication provider.","auth/missing-provider":"No authentication provider specified in the request.","auth/no-user-signed-in":"No user is currently signed in."}},oauth:{errorSource:"oauth",defaultErrorCode:"unknown",defaultErrorMessage:"An OAuth error occurred",errorCodeMapping:{"oauth/invalid-request":"invalid-argument","oauth/invalid-client":"invalid-argument","oauth/invalid-grant":"invalid-argument","oauth/unauthorized-client":"permission-denied","oauth/unsupported-grant-type":"unimplemented","oauth/invalid-scope":"invalid-argument","oauth/insufficient-scope":"permission-denied","oauth/invalid-token":"unauthenticated","oauth/expired-token":"unauthenticated","oauth/redirect-uri-mismatch":"invalid-argument","oauth/access-denied":"permission-denied","oauth/server-error":"unavailable","oauth/temporarily-unavailable":"unavailable","oauth/state-mismatch":"invalid-argument","oauth/invalid-callback":"invalid-argument","oauth/client-secret-mismatch":"permission-denied","oauth/unauthorized-scope":"permission-denied","oauth/rate-limit-exceeded":"rate-limit-exceeded","oauth/token-expired":"unauthenticated","oauth/missing-token":"invalid-argument","oauth/invalid-code":"invalid-argument","oauth/invalid-redirect":"invalid-argument","oauth/provider-error":"unavailable","oauth/invalid-response":"unavailable","oauth/unauthorized-access":"permission-denied",...xe},friendlyMessageMapping:{"oauth/invalid-request":"The OAuth request was invalid or missing parameters.","oauth/invalid-client":"Client authentication failed.","oauth/invalid-grant":"The provided authorization grant is invalid.","oauth/unauthorized-client":"The client is not authorized to use this grant type.","oauth/unsupported-grant-type":"The requested grant type is not supported.","oauth/invalid-scope":"The requested scope is invalid or unknown.","oauth/insufficient-scope":"The token does not have the required scope for this resource.","oauth/invalid-token":"The access token is invalid.","oauth/expired-token":"The access token has expired.","oauth/redirect-uri-mismatch":"The redirect URI does not match the registered URI.","oauth/access-denied":"The resource owner denied the request.","oauth/server-error":"The authorization server encountered an unexpected error.","oauth/temporarily-unavailable":"The authorization server is temporarily unavailable.","oauth/state-mismatch":"Invalid state parameter. This could be a security issue.","oauth/invalid-callback":"The callback URL is invalid or not registered.","oauth/client-secret-mismatch":"The client secret does not match the registered secret.","oauth/unauthorized-scope":"The requested scope is not authorized for this client.","oauth/rate-limit-exceeded":"Too many requests. Please try again later.","oauth/token-expired":"The OAuth token has expired and needs to be refreshed.","oauth/missing-token":"No OAuth token was provided in the request.","oauth/invalid-code":"The authorization code is invalid or expired.","oauth/invalid-redirect":"The redirect URL is invalid or does not match the registered redirect URL.","oauth/provider-error":"The OAuth provider returned an error.","oauth/invalid-response":"The response from the OAuth provider was invalid.","oauth/unauthorized-access":"Unauthorized access to OAuth resources."}},api:{errorSource:"api",defaultErrorCode:"unknown",defaultErrorMessage:"API request failed",errorCodeMapping:Object.fromEntries(Object.entries(sn).map(([e,t])=>[e,t])),friendlyMessageMapping:{},extractErrorCode:i(e=>{if(typeof e!="object"||e===null)return;let t;return"response"in e&&e.response&&"status"in e.response?t=e.response.status:"status"in e&&typeof e.status=="number"&&(t=e.status),t?.toString()},"extractErrorCode"),processMetadata:i(e=>{let t={originalError:e};return typeof e!="object"||e===null||("response"in e&&e.response?("status"in e.response&&(t.statusCode=e.response.status),"data"in e.response&&(t.responseData=e.response.data)):"status"in e&&(t.statusCode=e.status)),t},"processMetadata")},firebase:{errorSource:"firebase",defaultErrorCode:"unknown",defaultErrorMessage:"A Firebase error occurred",errorCodeMapping:xe,friendlyMessageMapping:{}},ui:{errorSource:"ui",defaultErrorCode:"internal",defaultErrorMessage:ie.internal,errorCodeMapping:{},friendlyMessageMapping:{},processMetadata:i(e=>{let t={originalError:e};return typeof e=="object"&&e!==null&&"componentStack"in e&&(t.componentStack=e.componentStack),t},"processMetadata")},validation:{errorSource:"validation",defaultErrorCode:"validation-failed",defaultErrorMessage:ie["validation-failed"],errorCodeMapping:{},friendlyMessageMapping:{}},entity:{errorSource:"entity",defaultErrorCode:"unknown",defaultErrorMessage:"An entity operation error occurred",errorCodeMapping:{},friendlyMessageMapping:{}},unknown:{errorSource:"unknown",defaultErrorCode:"unknown",defaultErrorMessage:ie.unknown,errorCodeMapping:{TypeError:"invalid-argument",ReferenceError:"internal",RangeError:"invalid-argument"},friendlyMessageMapping:{},extractErrorCode:i(e=>{if(e instanceof Error)return e.name},"extractErrorCode")}},an=i(e=>e instanceof be?new O(ie["validation-failed"],"validation-failed",{details:{validationErrors:e.issues.map(t=>({path:t.path.join("."),message:t.message})),originalError:e},source:"validation"}):G(K.validation)(e),"handleValidationError"),un=i(e=>{if(e instanceof Error&&"type"in e&&typeof e.type=="string"&&e.type in Be){let t=e,n=Be[t.type]||"unknown";return new O(t.message||ie[n],n,{details:{originalError:e},source:"entity"})}if(typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&Re[e.code]){let t=e,n=Re[t.code];if(n){let o=Be[n.type]||"unknown";return new O(n.message||ie[o],o,{details:{originalCode:t.code,originalError:e},source:"entity"})}}return G(K.entity)(e)},"handleEntityError"),ct={auth:G(K.auth),oauth:G(K.oauth),api:G(K.api),firebase:G(K.firebase),ui:G(K.ui),validation:an,entity:un,unknown:G(K.unknown)};function Se(e,t,n){return e instanceof O?e:(ct[t]||ct.unknown)(e,n)}i(Se,"mapToDoNotDevError");function pt(e,t,n={}){let o=globalThis.Sentry;o&&o.withScope(c=>{c.setTag("errorSource",t),c.setTag("errorCode",e.code),e.details&&Object.entries(e.details).forEach(([a,u])=>{if(typeof u!="function"&&a!=="originalError")try{c.setExtra(a,u)}catch{c.setExtra(a,`[${typeof u}]`)}}),Object.entries(n).forEach(([a,u])=>{if(typeof u!="function")try{c.setExtra(`context.${a}`,u)}catch{c.setExtra(`context.${a}`,`[${typeof u}]`)}}),(e.details?.userId||n.userId)&&c.setUser({id:e.details?.userId||n.userId,email:e.details?.userEmail||n.userEmail}),o.captureException(e)})}i(pt,"captureErrorToSentry");function ln(){return typeof import.meta<"u"&&import.meta.env&&(import.meta.env.DEV===!0||import.meta.env.MODE&&import.meta.env.MODE!=="production")?!0:typeof process<"u"&&process.env?"production".toLowerCase()!=="production":!1}i(ln,"isDev");function ke(e,t){let n=typeof t=="string"?{userMessage:t}:t||{},{userMessage:o,context:c={},log:a=!0,reportToSentry:u=!0,showNotification:g=!1,severity:f="error"}=n,h=lt(e),d=e instanceof O?e:Se(e,h,o);if(o&&!d.userMessageProvided&&(d.message.includes("Error")||d.message.includes("Failed")||d.message.length<10?d=new O(o,d.code,{details:{...d.details,originalMessage:d.message},source:h,userMessageProvided:!0}):d=new O(d.message,d.code,{details:{...d.details,userMessage:o},source:h,userMessageProvided:!0})),a){let C=ln()||typeof window<"u"&&window.__DNDEV_DEBUG,w={code:d.code,message:d.message,source:h};switch(f){case"warning":console.warn(`[DoNotDev] ${d.code}: ${d.message}`,C?{...w,details:d.details}:w);break;case"info":console.info(`[DoNotDev] ${d.code}: ${d.message}`,C?{...w,details:d.details}:w);break;case"success":console.log(`[DoNotDev] ${d.code}: ${d.message}`,C?{...w,details:d.details}:w);break;default:console.error(`[DoNotDev] ${d.code}: ${d.message}`,C?{...w,details:d.details,stack:d.stack}:w)}}return u&&pt(d,h,c),g&&typeof window<"u"&&console.warn("[handleError] showNotification requires client-side toast setup"),d}i(ke,"handleError");function Ds(e,t,n,o){let c=o?` ${JSON.stringify(o)}`:"",a=`${t}.${n}(${c})`,u=Se(e,"auth",`${a}: ${cn(e)}`);return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&u.code==="unknown"&&e.code!=="unknown"?new O(u.message,u.code,{details:{...u.details,originalCode:e.code},source:u.source}):u}i(Ds,"wrapAuthError");function cn(e){return e instanceof Error?e.message:typeof e=="string"?e:String(e)}i(cn,"getErrorMessage");var dt={[W.GUEST]:0,[W.USER]:1,[W.ADMIN]:2,[W.SUPER]:3};function qe(e,t){if(!e)return!1;let n=dt[e]??-1,o=dt[t]??1/0;return n>=o}i(qe,"hasRoleAccess");var je="__DNDEV_SINGLETONS__";function pn(){if(typeof globalThis<"u"){let e=globalThis;return e[je]||(e[je]=new Map),e[je]}return new Map}i(pn,"getSingletonRegistry");function ft(e,t){let n=pn();return n.has(e)||n.set(e,t()),n.get(e)}i(ft,"getGlobalSingleton");function Ls(e,...t){let n=null,o=!1;return i(function(){if(n!==null)return n;if(o)throw new Error("Circular dependency detected in singleton initialization");o=!0;try{return typeof e=="function"&&e.prototype?n=new e(...t):n=e(),n}finally{o=!1}},"getInstance")}i(Ls,"createSingleton");function mt(){return ft("providers",()=>({providers:null}))}i(mt,"getProviderState");function Vs(e){let{providers:t}=mt();if(!t)throw new Error(`[dndev] Provider "${e}" not available. Call configureProviders() at app startup.`);let n=t[e];if(!n)throw new Error(`[dndev] Provider "${e}" not configured. Pass it to configureProviders().`);return n}i(Vs,"getProvider");function $s(e){return!!mt().providers?.[e]}i($s,"hasProvider");function dn(e){return typeof e=="object"&&e!==null&&"visibility"in e&&typeof e.visibility=="string"}i(dn,"hasVisibility");function fn(e){if(dn(e))return e.visibility}i(fn,"getFieldVisibility");function mn(e,t){let n=e??"guest";return n==="hidden"?!1:n==="technical"?qe(t,"admin"):n==="owner"?!1:qe(t,n)}i(mn,"isFieldVisible");function yn(e,t,n){for(let o of n.ownerFields)if(e[o]===t)return!0;return!1}i(yn,"isOwnerVisible");function yt(e,t,n){let o=e;if(!o||typeof o!="object"||!o.entries)return console.warn("getVisibleFields expects a Valibot object schema (v.object)."),[];let c=o.entries,a=[],{documentData:u,uid:g,ownership:f}=n??{},h=f&&g!=null&&u&&yn(u,g,f);for(let[d,C]of Object.entries(c)){let w=fn(C);if(w==="owner"){h&&a.push(d);continue}mn(w,t)&&a.push(d)}return a}i(yt,"getVisibleFields");function Xs(e,t,n,o){if(!e)return{};let c=o?.uid!=null&&o?.ownership!=null?{documentData:o.documentData??e,uid:o.uid,ownership:o.ownership}:void 0,a=yt(t,n,c),u={};for(let g of a)Object.prototype.hasOwnProperty.call(e,g)&&(u[g]=e[g]);return u}i(Xs,"filterVisibleFields");function Ve(e){let t=e.listCardFields;if(t){if(Array.isArray(t))return t;let n=t,o=[...n.title??[],...n.subtitle??[],...n.content??[],...n.footer??[]];return[...new Set(o)]}return e.listFields&&e.listFields.length>0?e.listFields:e.fields?Object.keys(e.fields):[]}i(Ve,"getListCardFieldNames");var gn=new Set(["http:","https:","mailto:","tel:","blob:"]);function ta(e){if(!e||typeof e!="string")return"";let t=e.trim();if(/^[/.?#]/.test(t))return t;try{let n=new URL(t);if(gn.has(n.protocol))return t}catch{return t}return""}i(ta,"sanitizeHref");var gt=[{value:"draft",label:"crud:status.draft"},{value:"available",label:"crud:status.available"},{value:"deleted",label:"crud:status.deleted"}],ia="available",oa=["draft","deleted"],$e=["id","createdAt","updatedAt","createdById","updatedById"],sa=[...$e,"status"];var Ae={status:{name:"status",type:"select",visibility:"admin",label:"crud:fields.status",editable:"admin",validation:{required:!0,options:[...gt]}},id:{name:"id",type:"text",visibility:"hidden",label:"crud:fields.id",validation:{required:!0}},createdAt:{name:"createdAt",type:"timestamp",visibility:"technical",label:"crud:fields.createdAt",validation:{}},updatedAt:{name:"updatedAt",type:"timestamp",visibility:"technical",label:"crud:fields.updatedAt",validation:{}},createdById:{name:"createdById",type:"reference",visibility:"technical",label:"crud:fields.createdById",validation:{}},updatedById:{name:"updatedById",type:"reference",visibility:"technical",label:"crud:fields.updatedById",validation:{}}};function Te(e,t){let n=new Date(e),o=n.getDate();return n.setMonth(n.getMonth()+t),n.getDate()!==o&&n.setDate(0),n}i(Te,"addMonths");function vt(e,t){let n=new Date(e),o=n.getDate();return n.setFullYear(n.getFullYear()+t),n.getDate()!==o&&n.setDate(0),n}i(vt,"addYears");function wu(e,t=new Date){if(e==="lifetime")return"2099-12-31T23:59:59.000Z";let n;return e==="1month"?n=Te(t,1):e==="3months"?n=Te(t,3):e==="6months"?n=Te(t,6):e==="1year"?n=vt(t,1):e==="2years"?n=vt(t,2):n=Te(t,1),n.toISOString()}i(wu,"calculateSubscriptionEndDate");var St=new Map;function y(e,t){St.set(e,t)}i(y,"registerSchemaGenerator");function T(e,t){return t?e:U(e)}i(T,"applyRequired");var Ie=i(e=>{let t=[];e.validation?.minLength!==void 0&&t.push(m(e.validation.minLength,`Must be at least ${e.validation.minLength} characters`)),e.validation?.maxLength!==void 0&&t.push(V(e.validation.maxLength,`Must be at most ${e.validation.maxLength} characters`)),e.validation?.pattern&&t.push(re(new RegExp(e.validation.pattern),"Invalid format"));let n=t.length>0?l(r(),...t):r();return T(n,e.validation?.required)},"textSchema"),hn=i(e=>{let t=l(r(),L("Invalid email address"));return T(t,e.validation?.required)},"emailSchema"),bn=i(e=>{let t=e.validation?.minLength!==void 0?l(r(),m(e.validation.minLength,`Must be at least ${e.validation.minLength} characters`)):r();return T(t,e.validation?.required)},"passwordSchema"),En=i(e=>{let t=l(r(),N("Invalid URL"));return T(t,e.validation?.required)},"urlSchema"),oe=i(e=>{let t=[];e.validation?.min!==void 0&&t.push(_(e.validation.min,`Must be at least ${e.validation.min}`)),e.validation?.max!==void 0&&t.push(B(e.validation.max,`Must be at most ${e.validation.max}`));let n=t.length>0?l(A(),...t):A();return T(n,e.validation?.required)},"numberSchema"),ht=i(e=>{let t=S();return T(t,e.validation?.required)},"booleanSchema"),se=i(e=>{let t=l(r(),le(n=>!isNaN(new Date(n).getTime()),"Invalid date format"));return T(t,e.validation?.required)},"dateSchema"),kt=p({url:r(),filename:r(),size:A(),mimeType:U(r()),uploadedAt:U(r())}),bt=i(e=>{let t=P(kt);return T(t,e.validation?.required)},"fileSchema"),Et=i(e=>{let t=v(kt);return T(t,e.validation?.required)},"filesSchema"),At=p({fullUrl:r(),thumbUrl:r()}),xn=i(e=>{let t=Z([r(),At]);return T(t,e.validation?.required)},"pictureSchema"),Sn=i(e=>{let t=v(Z([r(),At]));return T(t,e.validation?.required)},"picturesSchema"),kn=i(e=>{let t=p({lat:A(),lng:A()});return T(t,e.validation?.required)},"geopointSchema"),An=i(e=>{let t=p({formatted_address:r(),latitude:A(),longitude:A(),street_number:U(r()),route:U(r()),locality:U(r()),administrative_area_level_1:U(r()),administrative_area_level_2:U(r()),country:U(r()),postal_code:U(r())});return T(t,e.validation?.required)},"addressSchema"),Tn=i(e=>{let t=E(r(),D());return T(t,e.validation?.required)},"mapSchema"),In=i(e=>{let t=v(D());return T(t,e.validation?.required)},"arraySchema"),Ge=i(e=>{let t=e.validation?.options;if(Array.isArray(t)&&t.length>0){let o=t.map(a=>a.value),c=b(o);return T(c,e.validation?.required)}let n=Z([r(),A()]);return T(n,e.validation?.required)},"selectSchema"),Rn=i(e=>{let t=e.validation?.options;if(Array.isArray(t)&&t.length>0){let o=t.map(a=>a.value),c=v(b(o));return T(c,e.validation?.required)}let n=v(r());return T(n,e.validation?.required)},"multiselectSchema"),Cn=i(e=>{let t=l(r(),m(1,"Invalid ID format"));return T(t,e.validation?.required)},"referenceSchema"),He=i(e=>{let t=r();return T(t,e.validation?.required)},"stringSchema"),wn=i(e=>{let t=r();return T(t,e.validation?.required)},"telSchema"),On=i(e=>{let t=e.validation?.minLength??15,n=e.validation?.maxLength??34,o=e.validation?.pattern??"^[A-Z]{2}[0-9]{2}[A-Z0-9]{4,34}$",c=[];if(t!==void 0&&c.push(m(t,`IBAN must be at least ${t} characters`)),n!==void 0&&c.push(V(n,`IBAN must not exceed ${n} characters`)),o){let u=typeof o=="string"?new RegExp(o):o;c.push(re(u,"Invalid IBAN format"))}let a=c.length>0?l(r(),...c):r();return T(a,e.validation?.required)},"ibanSchema"),xt=i(()=>Ne(),"neverSchema"),Pn=i(e=>{let t=e.options?.fieldSpecific;if(t?.checkedValue&&t?.uncheckedValue){let o=[t.checkedValue,t.uncheckedValue],c=b(o);return T(c,e.validation?.required)}let n=S();return T(n,e.validation?.required)},"switchSchema"),Dn=i(e=>Pe(n=>e.validation?.required?typeof n=="object"&&n!==null?n.gdprConsent===!0:!1:n===!1||n===null||n===void 0?!0:typeof n=="object"&&n!==null?n.gdprConsent===!0:!1,"GDPR consent must be given"),"gdprConsentSchema"),_n=i(e=>{let t=p({amount:A(),currency:s(r()),vatIncluded:s(S()),discountPercent:s(l(A(),_(0),B(100)))});return T(t,e.validation?.required)},"priceSchema");function Nn(){y("text",Ie),y("textarea",Ie),y("richtext",Ie),y("color",Ie),y("email",hn),y("password",bn),y("url",En),y("tel",wn),y("iban",On),y("number",oe),y("currency",oe),y("price",_n),y("range",oe),y("year",oe),y("rating",oe),y("duration",oe),y("boolean",ht),y("checkbox",ht),y("gdprConsent",Dn),y("date",se),y("datetime-local",se),y("time",se),y("week",se),y("month",se),y("timestamp",se),y("file",bt),y("files",Et),y("document",bt),y("documents",Et),y("image",xn),y("images",Sn),y("geopoint",kn),y("address",An),y("map",Tn),y("array",In),y("select",Ge),y("multiselect",Rn),y("radio",Ge),y("combobox",Ge),y("switch",Pn),y("reference",Cn),y("hidden",He),y("avatar",He),y("badge",He),y("submit",xt),y("reset",xt)}i(Nn,"registerBuiltinSchemas");Nn();function fe(e){if(e.validation?.schema){let o=e.validation.schema;return T(o,e.validation?.required)}let t=St.get(e.type);if(t){let o=t(e);if(o!==null)return o}let n=D();return T(n,e.validation?.required)}i(fe,"getSchemaType");function We(e,t){return!!(t.visibility==="hidden"||t.editable===Me.GENERATED||$e.includes(e))}i(We,"isWriteExcluded");function me(e,t){return Object.assign(e,{visibility:t})}i(me,"withVisibility");function Q(e,t){let n=e;return n.metadata={collection:t.collection,entity:t.name,...t.uniqueKeys&&{uniqueKeys:t.uniqueKeys}},n}i(Q,"withMetadata");function Fn(e){let t=fe(e);return me(t,e.visibility)}i(Fn,"createFieldSchema");function Ke(e){let t=fe({...e,validation:{...e.validation,required:!1}});return me(t,e.visibility)}i(Ke,"createOptionalFieldSchema");function Wu(e){let t=e.fields,n={};for(let[k,I]of Object.entries(t))I.visibility!=="hidden"&&(n[k]=Ke(I));let o=Q(p(n),e),c={};for(let[k,I]of Object.entries(t))We(k,I)||(c[k]=Fn(I));let a=Q(p(c),e),u={};for(let[k,I]of Object.entries(t))if(!We(k,I))if(k==="status"){let z=F("draft");u[k]=me(z,I.visibility)}else u[k]=Ke(I);let g=Q(p(u),e),f={};for(let[k,I]of Object.entries(t))We(k,I)||(f[k]=Ke(I));f.id=me(fe(Ae.id),"technical");let h=Q(p(f),e),d;if(e.listFields&&e.listFields.length>0){let k=["id","status"],I=[...new Set([...k,...e.listFields])];d={};for(let z of I){let ae=n[z];ae&&(d[z]=ae)}}else d=n;let C=Q(p(d),e),w,$=Ve(e);if($.length>0){let k=["id","status"],I=[...new Set([...k,...$])];w={};for(let z of I){let ae=n[z];ae&&(w[z]=ae)}}else w=n;let ye=Q(p(w),e),ee=Q(p({id:me(fe(Ae.id),"technical")}),e);return{create:a,draft:g,update:h,get:o,list:C,listCard:ye,delete:ee}}i(Wu,"createSchemas");var Un=E(r(),D()),Mn=p({id:r(),patch:E(r(),D())}),Ln=r(),Yu=p({inserts:s(v(Un)),updates:s(v(Mn)),deletes:s(v(Ln))}),Xu=p({insertedIds:v(r()),updatedIds:v(r()),deletedIds:v(r())});function Zu(e){let t=new Set((e.updates??[]).map(u=>u.id)),n=e.deletes??[],o=[];for(let u of n)t.has(u)&&o.push(u);if(o.length>0)return{collisions:o,where:"updates-deletes"};let c=e.inserts??[],a=[];for(let u of c)typeof u.id=="string"&&t.has(u.id)&&a.push(u.id);return a.length>0?{collisions:a,where:"inserts-updates"}:{collisions:[],where:null}}i(Zu,"detectBulkCollisions");var Nl=l(r(),le(e=>e.startsWith("/proxy/")||e.startsWith("data:image/"),"Image URL must be box-proxied (/proxy/...) or an inline data:image URI.")),Bn=b(["ephemeral","session","persistent"]),qn=p({title:s(r()),pinnable:s(S()),preferredHeight:s(l(A(),_(0)))}),Fl=p({id:l(r(),m(1)),kind:l(r(),m(1)),lifetime:s(Bn,"ephemeral"),metadata:s(qn),payload:D()}),Ul=p({widgetId:l(r(),m(1)),action:l(r(),m(1)),payload:D()});export{$n as a,Gn as b,Hn as c,Wn as d,zn as e,ne as f,B as g,m as h,_ as i,re as j,Ft as k,N as l,X as m,v as n,S as o,Pe as p,A as q,p as r,s,b as t,E as u,r as v,Mt as w,Z as x,D as y,Ze as z,l as A,H as B,qt as C,tr as D,Qe as E,de as F,mr as G,Sr as H,ot as I,Jt as J,gi as K,O as L,to as M,no as N,ro as O,io as P,yo as Q,ke as R,Ds as S,qe as T,Ls as U,Vs as V,$s as W,Xs as X,Ve as Y,ta as Z,wu as _,ia as $,oa as aa,Wu as ba,Yu as ca,Xu as da,Zu as ea};
22
- //# sourceMappingURL=chunk-G4FO76EA.js.map