@visulima/email 4.1.0 → 4.2.1

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 (76) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +17 -0
  3. package/dist/crypto/index.d.ts +2 -2
  4. package/dist/deliverability/index.d.ts +1 -1
  5. package/dist/inbound/index.d.ts +1 -1
  6. package/dist/index.d.ts +5 -5
  7. package/dist/index.js +1 -1
  8. package/dist/middleware/index.d.ts +4 -4
  9. package/dist/packem_chunks/index.js +1 -1
  10. package/dist/packem_shared/{DraftMailMessage-B0gwf8n_.js → DraftMailMessage-zkKTOxQ8.js} +1 -1
  11. package/dist/packem_shared/Mail-DtpXUSIl.js +1 -0
  12. package/dist/packem_shared/MailMessage-Aw0vVAh-.js +1 -0
  13. package/dist/packem_shared/{createTestEmail-DWimjf0F.js → createTestEmail-B2Fz-Ifb.js} +1 -1
  14. package/dist/packem_shared/{mail.d-BdyyyQO5.d.ts → mail.d-2u-30lWz.d.ts} +12 -4
  15. package/dist/packem_shared/{provider.d-Cx5YQJdP.d.ts → provider.d-BLLbEuQ8.d.ts} +1 -1
  16. package/dist/packem_shared/resendProvider-BaIZCvph.js +1 -0
  17. package/dist/packem_shared/{tracer.d-sb5yrt_n.d.ts → tracer.d-B103E-TW.d.ts} +84 -32
  18. package/dist/packem_shared/{types.d-Cb5fls_X.d.ts → types.d-A1Eea-p_.d.ts} +1 -1
  19. package/dist/packem_shared/{types.d-kHO4kX9q.d.ts → types.d-B5iH_mgb.d.ts} +1 -1
  20. package/dist/packem_shared/{types.d-GKqPNk0I.d.ts → types.d-Chhzb-48.d.ts} +1 -1
  21. package/dist/packem_shared/{types.d-B9295M4_.d.ts → types.d-CyiC9uRC.d.ts} +10 -0
  22. package/dist/packem_shared/{types.d-C5geVKes.d.ts → types.d-V_yuAOrx.d.ts} +1 -1
  23. package/dist/providers/ahasend/index.d.ts +3 -3
  24. package/dist/providers/autosend/index.d.ts +3 -3
  25. package/dist/providers/aws-ses/index.d.ts +3 -3
  26. package/dist/providers/azure/index.d.ts +3 -3
  27. package/dist/providers/brevo/index.d.ts +3 -3
  28. package/dist/providers/cloudflare-email/index.d.ts +4 -4
  29. package/dist/providers/failover/index.d.ts +3 -3
  30. package/dist/providers/file/index.d.ts +3 -3
  31. package/dist/providers/http/index.d.ts +3 -3
  32. package/dist/providers/infobip/index.d.ts +3 -3
  33. package/dist/providers/loops/index.d.ts +3 -3
  34. package/dist/providers/mailchannels/index.d.ts +3 -3
  35. package/dist/providers/mailcrab/index.d.ts +3 -3
  36. package/dist/providers/mailersend/index.d.ts +3 -3
  37. package/dist/providers/mailgun/index.d.ts +3 -3
  38. package/dist/providers/mailjet/index.d.ts +3 -3
  39. package/dist/providers/mailomat/index.d.ts +3 -3
  40. package/dist/providers/mailpace/index.d.ts +3 -3
  41. package/dist/providers/mailtrap/index.d.ts +3 -3
  42. package/dist/providers/mandrill/index.d.ts +3 -3
  43. package/dist/providers/mock/index.d.ts +5 -5
  44. package/dist/providers/netcore/index.d.ts +3 -3
  45. package/dist/providers/nodemailer/index.d.ts +3 -3
  46. package/dist/providers/opentelemetry/index.d.ts +3 -3
  47. package/dist/providers/outlook365/index.d.ts +3 -3
  48. package/dist/providers/plunk/index.d.ts +3 -3
  49. package/dist/providers/postal/index.d.ts +3 -3
  50. package/dist/providers/postmark/index.d.ts +3 -3
  51. package/dist/providers/resend/index.d.ts +3 -3
  52. package/dist/providers/resend/index.js +1 -1
  53. package/dist/providers/roundrobin/index.d.ts +3 -3
  54. package/dist/providers/scaleway/index.d.ts +3 -3
  55. package/dist/providers/sendgrid/index.d.ts +3 -3
  56. package/dist/providers/smtp/index.d.ts +4 -4
  57. package/dist/providers/sparkpost/index.d.ts +3 -3
  58. package/dist/providers/sweego/index.d.ts +3 -3
  59. package/dist/providers/zeptomail/index.d.ts +3 -3
  60. package/dist/queue/bullmq-queue.d.ts +2 -2
  61. package/dist/queue/index.d.ts +2 -2
  62. package/dist/queue/pg-boss-queue.d.ts +2 -2
  63. package/dist/queue/sqs-queue.d.ts +2 -2
  64. package/dist/queue/unstorage-queue.d.ts +2 -2
  65. package/dist/test/index.d.ts +6 -6
  66. package/dist/test/index.js +1 -1
  67. package/dist/utils/format-email-address.d.ts +1 -1
  68. package/dist/utils/parse-address.d.ts +1 -1
  69. package/dist/utils/parse-eml.d.ts +1 -1
  70. package/dist/utils/result.d.ts +1 -1
  71. package/dist/utils/validation/check-feature-support.d.ts +1 -1
  72. package/dist/utils/validation/check-feature-support.js +1 -1
  73. package/package.json +5 -5
  74. package/dist/packem_shared/Mail-0cxS6jre.js +0 -1
  75. package/dist/packem_shared/MailMessage-DmmaNHHc.js +0 -1
  76. package/dist/packem_shared/resendProvider-DC7Op5Gr.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## @visulima/email [4.2.1](https://github.com/visulima/visulima/compare/@visulima/email@4.2.0...@visulima/email@4.2.1) (2026-11-11)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/error:** upgraded to 6.1.1
7
+ * **@visulima/fs:** upgraded to 7.0.1
8
+ * **@react-email/render:** ^2.1.0 → ^2.2.0
9
+ * **html-to-text:** ^10.0.0 → ^10.0.1
10
+ * **ical-generator:** 11.1.0 → 11.1.3
11
+ * **mime:** ^4.1.0 → ^4.1.2
12
+
13
+ ## @visulima/email [4.2.0](https://github.com/visulima/visulima/compare/@visulima/email@4.1.0...@visulima/email@4.2.0) (2026-10-23)
14
+
15
+ ### Features
16
+
17
+ * **email:** add idempotency key for resend ([#982](https://github.com/visulima/visulima/issues/982)) ([53cfa4d](https://github.com/visulima/visulima/commit/53cfa4da67ee38dfdcaf6cd92f518b09adfeaf19))
18
+
1
19
  ## @visulima/email [4.1.0](https://github.com/visulima/visulima/compare/@visulima/email@4.0.0...@visulima/email@4.1.0) (2026-10-23)
2
20
 
3
21
  ### Features
package/README.md CHANGED
@@ -154,6 +154,23 @@ import { checkFeatureSupport } from "@visulima/email";
154
154
  const { supported, violations } = checkFeatureSupport(message, provider.features);
155
155
  ```
156
156
 
157
+ ### Idempotency Keys
158
+
159
+ Pass an `idempotencyKey` to tell the provider that a repeated send is the same message, so it is not delivered twice. The key is set on the message builder or on `EmailOptions`:
160
+
161
+ ```ts
162
+ await mail.send(
163
+ new MailMessage()
164
+ .from("orders@example.com")
165
+ .to("user@example.com")
166
+ .subject("Order confirmed")
167
+ .text("Thanks for your order")
168
+ .idempotencyKey(`order-${orderId}-confirmation`),
169
+ );
170
+ ```
171
+
172
+ The key is sent as an `Idempotency-Key` HTTP header and never appears in the message headers or the MIME body. Only providers that declare `features.idempotency` (currently Resend) use it; other providers ignore the key. Keys must be 1–256 visible ASCII characters. Resend keeps a key for 24 hours and requires a retry to carry the same payload; a retry with a different payload is rejected, and a retry after 24 hours can deliver the email again. The key is therefore protection against accidental double sends within that window, not a permanent guarantee. `sendBatch` does not apply a batch-level key to each recipient, because that would make every recipient look like a repeat of the first.
173
+
157
174
  ### Creating Draft Emails
158
175
 
159
176
  You can create draft emails in EML (RFC 822) format without sending them. The `draft()` method returns the email as an EML string with an `X-Unsent: 1` header automatically added:
@@ -1,6 +1,6 @@
1
1
  import { KeyObject } from 'node:crypto';
2
- import { D as DkimOptions, S as SmimeEncryptOptions, E as EmailEncrypter, a as SmimeSignOptions, b as EmailSigner } from "../packem_shared/types.d-Cb5fls_X.js";
3
- import { E as EmailOptions } from "../packem_shared/types.d-B9295M4_.js";
2
+ import { D as DkimOptions, S as SmimeEncryptOptions, E as EmailEncrypter, a as SmimeSignOptions, b as EmailSigner } from "../packem_shared/types.d-A1Eea-p_.js";
3
+ import { E as EmailOptions } from "../packem_shared/types.d-CyiC9uRC.js";
4
4
  import 'node:buffer';
5
5
  /**
6
6
  * The signature algorithm for the ARC headers. RSA per RFC 8617, Ed25519 per RFC 8463.
@@ -1,4 +1,4 @@
1
- import { c as EmailAddress } from "../packem_shared/types.d-B9295M4_.js";
1
+ import { c as EmailAddress } from "../packem_shared/types.d-CyiC9uRC.js";
2
2
  import { S as SuppressionReason, a as SuppressionEntry, b as SuppressionStore } from "../packem_shared/types.d-BzoHR9nB.js";
3
3
  import 'node:buffer';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { M as MaybePromise } from "../packem_shared/types.d-B9295M4_.js";
1
+ import { M as MaybePromise } from "../packem_shared/types.d-CyiC9uRC.js";
2
2
  import 'node:buffer';
3
3
  /**
4
4
  * A parsed address from an inbound message.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-BdyyyQO5.js";
2
- export type { M as Middleware, S as SendFunction } from "./packem_shared/types.d-GKqPNk0I.js";
3
- export { type a as Provider, type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-Cx5YQJdP.js";
1
+ export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-2u-30lWz.js";
2
+ export type { M as Middleware, S as SendFunction } from "./packem_shared/types.d-Chhzb-48.js";
3
+ export { type a as Provider, type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-BLLbEuQ8.js";
4
4
  export type { T as TemplateRenderer } from "./packem_shared/types.d-I-KeZ5w2.js";
5
- export type { A as Attachment, B as BaseConfig, C as CalendarEventOptions, c as EmailAddress, e as EmailHeaders, E as EmailOptions, a as EmailResult, d as EmailTag, F as FeatureFlags, I as ImmutableHeaders, M as MaybePromise, P as Priority, b as Receipt, R as Result } from "./packem_shared/types.d-B9295M4_.js";
5
+ export type { A as Attachment, B as BaseConfig, C as CalendarEventOptions, c as EmailAddress, e as EmailHeaders, E as EmailOptions, a as EmailResult, d as EmailTag, F as FeatureFlags, I as ImmutableHeaders, M as MaybePromise, P as Priority, b as Receipt, R as Result } from "./packem_shared/types.d-CyiC9uRC.js";
6
6
  export { default as parseEml } from "./utils/parse-eml.js";
7
7
  export { type OkResult, isErr, isOk, mapOk, tryAsync, unwrap, unwrapOr } from "./utils/result.js";
8
8
  export { type FeatureSupportResult, type FeatureViolation, default as checkFeatureSupport } from "./utils/validation/check-feature-support.js";
9
9
  import 'ical-generator';
10
10
  import 'node:buffer';
11
- import "./packem_shared/types.d-Cb5fls_X.js";
11
+ import "./packem_shared/types.d-A1Eea-p_.js";
12
12
  interface ErrorProperties {
13
13
  cause?: unknown;
14
14
  hint?: ErrorHint;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-BRz3Qjyz.js";import{default as p}from"./packem_shared/DraftMailMessage-B0gwf8n_.js";import{default as m}from"./packem_shared/EmailError-SXEFQEyA.js";import{default as l}from"./packem_shared/RequiredOptionError-C2wWqmiE.js";import{Mail as u,createMail as x}from"./packem_shared/Mail-0cxS6jre.js";import{default as M}from"./packem_shared/MailMessage-DmmaNHHc.js";import{defineProvider as E}from"./packem_shared/defineProvider-C9q-7iwt.js";import{default as g}from"./utils/parse-eml.js";import{isErr as y,isOk as w,mapOk as A,tryAsync as F,unwrap as h,unwrapOr as q}from"./utils/result.js";import{default as B}from"./utils/validation/check-feature-support.js";export{p as DraftMailMessage,m as EmailError,u as Mail,M as MailMessage,l as RequiredOptionError,B as checkFeatureSupport,x as createMail,E as defineProvider,a as detectMimeType,t as generateContentId,y as isErr,w as isOk,A as mapOk,g as parseEml,o as readFileAsBuffer,F as tryAsync,h as unwrap,q as unwrapOr};
1
+ import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-BRz3Qjyz.js";import{default as p}from"./packem_shared/DraftMailMessage-zkKTOxQ8.js";import{default as m}from"./packem_shared/EmailError-SXEFQEyA.js";import{default as l}from"./packem_shared/RequiredOptionError-C2wWqmiE.js";import{Mail as u,createMail as x}from"./packem_shared/Mail-DtpXUSIl.js";import{default as M}from"./packem_shared/MailMessage-Aw0vVAh-.js";import{defineProvider as E}from"./packem_shared/defineProvider-C9q-7iwt.js";import{default as g}from"./utils/parse-eml.js";import{isErr as y,isOk as w,mapOk as A,tryAsync as F,unwrap as h,unwrapOr as q}from"./utils/result.js";import{default as B}from"./utils/validation/check-feature-support.js";export{p as DraftMailMessage,m as EmailError,u as Mail,M as MailMessage,l as RequiredOptionError,B as checkFeatureSupport,x as createMail,E as defineProvider,a as detectMimeType,t as generateContentId,y as isErr,w as isOk,A as mapOk,g as parseEml,o as readFileAsBuffer,F as tryAsync,h as unwrap,q as unwrapOr};
@@ -1,9 +1,9 @@
1
- import { M as Middleware } from "../packem_shared/types.d-GKqPNk0I.js";
2
- export { type S as SendFunction, c as composeMiddleware } from "../packem_shared/types.d-GKqPNk0I.js";
3
- import { E as EmailOptions, M as MaybePromise, a as EmailResult, R as Result, c as EmailAddress } from "../packem_shared/types.d-B9295M4_.js";
1
+ import { M as Middleware } from "../packem_shared/types.d-Chhzb-48.js";
2
+ export { type S as SendFunction, c as composeMiddleware } from "../packem_shared/types.d-Chhzb-48.js";
3
+ import { E as EmailOptions, M as MaybePromise, a as EmailResult, R as Result, c as EmailAddress } from "../packem_shared/types.d-CyiC9uRC.js";
4
4
  import { d as EventBus } from "../packem_shared/event-bus.d-BNQA-FZE.js";
5
5
  import { b as SuppressionStore } from "../packem_shared/types.d-BzoHR9nB.js";
6
- import { T as Tracer } from "../packem_shared/tracer.d-sb5yrt_n.js";
6
+ import { T as Tracer } from "../packem_shared/tracer.d-B103E-TW.js";
7
7
  import 'node:buffer';
8
8
  /**
9
9
  * The state of a {@link circuitBreakerMiddleware}.
@@ -1,4 +1,4 @@
1
- import{createRequire as wn}from"node:module";let Sn;const xn=t=>(Sn??=wn(import.meta.url))(t),Ct=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,En=t=>{if(typeof Ct<"u"&&Ct.versions&&Ct.versions.node){const[e,s]=Ct.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ct.getBuiltinModule(t)}return xn(t)},{createRequire:H}=En("node:module"),we=0,Os=4,ba=2,va=1,Ns=Symbol("findUpStop"),An=/^[A-Z]:\//i,Et=(t="")=>t&&t.replaceAll("\\","/").replace(An,e=>e.toUpperCase()),_n=/^[/\\]{2}/,Tn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,ze=/^[A-Z]:$/i,Rn=/[^/](\.[^./]+)$/,kn=/^[/\\]|^[a-z]:[/\\]/i,Cn=/\/$/,On=()=>{if(typeof process.cwd=="function")try{const t=process.cwd();if(typeof t=="string")return Et(t)}catch{}return"/"},Ls=(t,e)=>{let s="",n=0,o=-1,r=0,i;for(let c=0;c<=t.length;++c){if(c<t.length)i=t[c];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===c-1||r===1))if(r===2){if(s.length<2||n!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const u=s.lastIndexOf("/");u===-1?(s="",n=0):(s=s.slice(0,u),n=s.length-1-s.lastIndexOf("/")),o=c,r=0;continue}else if(s.length>0){s="",n=0,o=c,r=0;continue}}e&&(s+=s.length>0?"/..":"..",n=2)}else s.length>0?s+=`/${t.slice(o+1,c)}`:s=t.slice(o+1,c),n=c-o-1;o=c,r=0}else i==="."&&r!==-1?++r:r=-1}return s},St=t=>Tn.test(t),Tt=function(t){if(t.length===0)return".";t=Et(t);const e=_n.exec(t),s=St(t),n=t.at(-1)==="/";return t=Ls(t,!s),t.length===0?s?"/":n?"./":".":(n&&(t+="/"),ze.test(t)&&(t+="/"),e?s?`//${t}`:`//./${t}`:s&&!St(t)?`/${t}`:t)},Se=(...t)=>{let e="";for(const s of t)if(s)if(e.length>0){const n=e.at(-1)==="/",o=s[0]==="/";n&&o?e+=s.slice(1):e+=n||o?s:`/${s}`}else e+=s;return Tt(e)},tt=function(...t){t=t.map(n=>Et(n));let e="",s=!1;for(let n=t.length-1;n>=-1&&!s;n--){const o=n>=0?t[n]:On();!o||o.length===0||(e=`${o}/${e}`,s=St(o))}return e=Ls(e,!s),ze.test(e)?`${e}/`:s&&!St(e)?`/${e}`:e.length>0?e:"."},ht=function(t){return Et(t)},Nn=function(t){return Rn.exec(Et(t))?.[1]??""},V=t=>{const e=Et(t).replace(Cn,""),s=e.lastIndexOf("/");if(s===-1)return St(t)?"/":".";const n=e.slice(0,s);return ze.test(n)?`${n}/`:n||(St(t)?"/":".")},le=(t,e)=>{const s=Et(t),n=s.slice(s.lastIndexOf("/")+1);if(e&&n.endsWith(e)){if(e===s)return"";const o=n.slice(0,-e.length);if(o.length>0)return o}return n},Ds=function(t){const e=kn.exec(t)?.[0]?.replaceAll("\\","/")??"",s=le(t),n=Nn(s);return{base:s,dir:V(t),ext:n,name:s.slice(0,s.length-n.length),root:e}};let Ln;const Dn=t=>(Ln??=H(import.meta.url))(t),Ot=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Fn=t=>{if(typeof Ot<"u"&&Ot.versions&&Ot.versions.node){const[e,s]=Ot.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ot.getBuiltinModule(t)}return Dn(t)},{fileURLToPath:Hn}=Fn("node:url");function In(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ve,Ye;function Bn(){return Ye||(Ye=1,Ve=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Ve}var Mn=Bn();const Pn=In(Mn);new Set(Pn);const F=t=>Et(t instanceof URL?Hn(t):t);let xt=class extends Error{constructor(e){super(`EEXIST: ${e}`)}get code(){return"EEXIST"}set code(e){throw new Error("Cannot overwrite code EEXIST")}get name(){return"AlreadyExistsError"}set name(e){throw new Error("Cannot overwrite name of AlreadyExistsError")}};const P=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")};let jn;const Gn=t=>(jn??=H(import.meta.url))(t),Nt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Un=t=>{if(typeof Nt<"u"&&Nt.versions&&Nt.versions.node){const[e,s]=Nt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Nt.getBuiltinModule(t)}return Gn(t)},{cp:qn}=Un("node:fs/promises"),Sa=async(t,e,s={})=>{P(t),P(e);const{dereference:n=!1,errorOnExist:o=!0,filter:r,overwrite:i=!0,preserveTimestamps:c=!1,recursive:u=!0,verbatimSymlinks:y=!1}=s,l=F(t),h=F(e);try{await qn(l,h,{dereference:n,errorOnExist:o,filter:r,force:i,preserveTimestamps:c,recursive:u,verbatimSymlinks:y})}catch($){throw $?.code==="ERR_FS_CP_EEXIST"?new xt(`destination already exists, copy '${h}'`):$}};let zn;const Wn=t=>(zn??=H(import.meta.url))(t),Lt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xn=t=>{if(typeof Lt<"u"&&Lt.versions&&Lt.versions.node){const[e,s]=Lt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Lt.getBuiltinModule(t)}return Wn(t)},{cpSync:Kn}=Xn("node:fs"),xa=(t,e,s={})=>{P(t),P(e);const{dereference:n=!1,errorOnExist:o=!0,filter:r,overwrite:i=!0,preserveTimestamps:c=!1,recursive:u=!0,verbatimSymlinks:y=!1}=s,l=F(t),h=F(e);try{Kn(l,h,{dereference:n,errorOnExist:o,filter:r,force:i,preserveTimestamps:c,recursive:u,verbatimSymlinks:y})}catch($){throw $?.code==="ERR_FS_CP_EEXIST"?new xt(`destination already exists, copy '${h}'`):$}},dt=t=>{if(t.isFile())return"file";if(t.isDirectory())return"dir";if(t.isSymbolicLink())return"symlink"};let Qn;const Vn=t=>(Qn??=H(import.meta.url))(t),Dt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Yn=t=>{if(typeof Dt<"u"&&Dt.versions&&Dt.versions.node){const[e,s]=Dt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Dt.getBuiltinModule(t)}return Vn(t)},{lstat:Ze,mkdir:Zn}=Yn("node:fs/promises"),We=async t=>{P(t);try{const e=await Ze(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await Zn(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const s=await Ze(t);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(s))}'`,{cause:e})}};let Jn;const tr=t=>(Jn??=H(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,er=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,s]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ft.getBuiltinModule(t)}return tr(t)},{lstatSync:Je,mkdirSync:sr}=er("node:fs"),Xe=t=>{P(t);try{const e=Je(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{sr(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const s=Je(t);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(s))}'`,{cause:e})}};let nr;const rr=t=>(nr??=H(import.meta.url))(t),Ht=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,or=t=>{if(typeof Ht<"u"&&Ht.versions&&Ht.versions.node){const[e,s]=Ht.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ht.getBuiltinModule(t)}return rr(t)},{lstat:ir,writeFile:cr}=or("node:fs/promises"),Ea=async t=>{P(t);try{const e=await ir(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(dt(e))}'`)}catch(e){if(e.code==="ENOENT"){await We(V(F(t))),await cr(t,new Uint8Array);return}throw e}};let ur;const ar=t=>(ur??=H(import.meta.url))(t),It=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,lr=t=>{if(typeof It<"u"&&It.versions&&It.versions.node){const[e,s]=It.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return It.getBuiltinModule(t)}return ar(t)},{lstatSync:pr,writeFileSync:fr}=lr("node:fs"),Aa=t=>{P(t);try{const e=pr(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(dt(e))}'`)}catch(e){if(e.code==="ENOENT"){Xe(V(F(t))),fr(t,new Uint8Array);return}throw e}},xe=(t,e)=>e.ino!==0n&&e.dev!==0n&&e.ino===t.ino&&e.dev===t.dev;let hr;const dr=t=>(hr??=H(import.meta.url))(t),Bt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,gr=t=>{if(typeof Bt<"u"&&Bt.versions&&Bt.versions.node){const[e,s]=Bt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Bt.getBuiltinModule(t)}return dr(t)},{lstat:ts,link:yr}=gr("node:fs/promises"),_a=async(t,e)=>{P(t),P(e),t=ht(F(t)),e=ht(F(e));let s;try{s=await ts(e,{bigint:!0})}catch{}let n;try{n=await ts(t,{bigint:!0})}catch(o){const r=o;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&xe(n,s)||(await We(V(e)),await yr(t,e))};let mr;const $r=t=>(mr??=H(import.meta.url))(t),Mt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,br=t=>{if(typeof Mt<"u"&&Mt.versions&&Mt.versions.node){const[e,s]=Mt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Mt.getBuiltinModule(t)}return $r(t)},{lstatSync:es,linkSync:vr}=br("node:fs"),Ta=(t,e)=>{P(t),P(e),t=ht(F(t)),e=ht(F(e));let s;try{s=es(e,{bigint:!0})}catch{}let n;try{n=es(t,{bigint:!0})}catch(o){const r=o;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&xe(n,s)||(Xe(V(e)),vr(t,e))},Fs=(t,e)=>typeof t!="string"?t:t.startsWith("./")?tt(t):typeof e=="string"?tt(V(e),t):new URL(t,e);let wr;const Sr=t=>(wr??=H(import.meta.url))(t),Pt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xr=t=>{if(typeof Pt<"u"&&Pt.versions&&Pt.versions.node){const[e,s]=Pt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Pt.getBuiltinModule(t)}return Sr(t)},{lstat:ke,stat:ss,symlink:Er,readlink:Ar}=xr("node:fs/promises"),_r=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),Ra=async(t,e,s)=>{P(t),P(e);const n=Fs(t,e);e=ht(F(e));try{if((await ke(e)).isSymbolicLink()){const[c,u]=await Promise.all([ss(n,{bigint:!0}),ss(e,{bigint:!0})]);if(xe(c,u))return}}catch{}const o=await ke(n),r=dt(o);await We(V(e));let i=s??"file";s||(_r?i="junction":i=r==="dir"?"dir":"file");try{await Er(ht(F(n)),e,i)}catch(c){if(c.code!=="EEXIST")throw c;const u=await ke(e);if(!u.isSymbolicLink())throw new xt(`A ${String(dt(u))} already exists at the path: ${e}`);const y=await Ar(e),l=ht(tt(y));if(l!==n)throw new xt(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}};let Tr;const Rr=t=>(Tr??=H(import.meta.url))(t),jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,kr=t=>{if(typeof jt<"u"&&jt.versions&&jt.versions.node){const[e,s]=jt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return jt.getBuiltinModule(t)}return Rr(t)},{lstatSync:Ce,statSync:ns,symlinkSync:Cr,readlinkSync:Or}=kr("node:fs"),Nr=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),ka=(t,e,s)=>{P(t),P(e);const n=Fs(t,e);e=ht(F(e));try{if(Ce(e).isSymbolicLink()&&xe(ns(n,{bigint:!0}),ns(e,{bigint:!0})))return}catch{}const o=Ce(n),r=dt(o);Xe(V(e));let i=s??"file";s||(Nr?i="junction":i=r==="dir"?"dir":"file");try{Cr(ht(F(n)),e,i)}catch(c){if(c.code!=="EEXIST")throw c;const u=Ce(e);if(!u.isSymbolicLink())throw new xt(`A ${String(dt(u))} already exists at the path: ${e}`);const y=Or(e),l=ht(tt(y));if(l!==n)throw new xt(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}},Lr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{platform:Dr}=Lr,Hs=/\r?\n/g,Is=`
1
+ import{createRequire as wn}from"node:module";let Sn;const xn=t=>(Sn??=wn(import.meta.url))(t),Ct=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,En=t=>{if(typeof Ct<"u"&&Ct.versions&&Ct.versions.node){const[e,s]=Ct.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ct.getBuiltinModule(t)}return xn(t)},{createRequire:H}=En("node:module"),we=0,Os=4,ba=2,va=1,Ns=Symbol("findUpStop"),An=/^[A-Z]:\//i,Et=(t="")=>t&&t.replaceAll("\\","/").replace(An,e=>e.toUpperCase()),_n=/^[/\\]{2}/,Tn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,ze=/^[A-Z]:$/i,Rn=/[^/](\.[^./]+)$/,kn=/^[/\\]|^[a-z]:[/\\]/i,Cn=/\/$/,On=()=>{if(typeof process.cwd=="function")try{const t=process.cwd();if(typeof t=="string")return Et(t)}catch{}return"/"},Ls=(t,e)=>{let s="",n=0,o=-1,r=0,i;for(let c=0;c<=t.length;++c){if(c<t.length)i=t[c];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===c-1||r===1))if(r===2){if(s.length<2||n!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const u=s.lastIndexOf("/");u===-1?(s="",n=0):(s=s.slice(0,u),n=s.length-1-s.lastIndexOf("/")),o=c,r=0;continue}else if(s.length>0){s="",n=0,o=c,r=0;continue}}e&&(s+=s.length>0?"/..":"..",n=2)}else s.length>0?s+=`/${t.slice(o+1,c)}`:s=t.slice(o+1,c),n=c-o-1;o=c,r=0}else i==="."&&r!==-1?++r:r=-1}return s},St=t=>Tn.test(t),Tt=function(t){if(t.length===0)return".";t=Et(t);const e=_n.exec(t),s=St(t),n=t.at(-1)==="/";return t=Ls(t,!s),t.length===0?s?"/":n?"./":".":(n&&(t+="/"),ze.test(t)&&(t+="/"),e?s?`//${t}`:`//./${t}`:s&&!St(t)?`/${t}`:t)},Se=(...t)=>{let e="";for(const s of t)if(s)if(e.length>0){const n=e.at(-1)==="/",o=s[0]==="/";n&&o?e+=s.slice(1):e+=n||o?s:`/${s}`}else e+=s;return Tt(e)},tt=function(...t){t=t.map(n=>Et(n));let e="",s=!1;for(let n=t.length-1;n>=-1&&!s;n--){const o=n>=0?t[n]:On();!o||o.length===0||(e=`${o}/${e}`,s=St(o))}return e=Ls(e,!s),ze.test(e)?`${e}/`:s&&!St(e)?`/${e}`:e.length>0?e:"."},ht=function(t){return Et(t)},Nn=function(t){return Rn.exec(Et(t))?.[1]??""},V=t=>{const e=Et(t).replace(Cn,""),s=e.lastIndexOf("/");if(s===-1)return St(t)?"/":".";const n=e.slice(0,s);return ze.test(n)?`${n}/`:n||(St(t)?"/":".")},le=(t,e)=>{const s=Et(t),n=s.slice(s.lastIndexOf("/")+1);if(e&&n.endsWith(e)){if(e===s)return"";const o=n.slice(0,-e.length);if(o.length>0)return o}return n},Ds=function(t){const e=kn.exec(t)?.[0]?.replaceAll("\\","/")??"",s=le(t),n=Nn(s);return{base:s,dir:V(t),ext:n,name:s.slice(0,s.length-n.length),root:e}};let Ln;const Dn=t=>(Ln??=H(import.meta.url))(t),Ot=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Fn=t=>{if(typeof Ot<"u"&&Ot.versions&&Ot.versions.node){const[e,s]=Ot.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ot.getBuiltinModule(t)}return Dn(t)},{fileURLToPath:Hn}=Fn("node:url");function In(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ve,Ye;function Bn(){return Ye||(Ye=1,Ve=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","dds","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","dylib","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","msi","msp","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","p12","pages","pbm","pcx","pdb","pdf","pea","pfx","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","sqlite","sqlite3","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wasm","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Ve}var Mn=Bn();const Pn=In(Mn);new Set(Pn);const F=t=>Et(t instanceof URL?Hn(t):t);let xt=class extends Error{constructor(e){super(`EEXIST: ${e}`)}get code(){return"EEXIST"}set code(e){throw new Error("Cannot overwrite code EEXIST")}get name(){return"AlreadyExistsError"}set name(e){throw new Error("Cannot overwrite name of AlreadyExistsError")}};const P=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")};let jn;const Gn=t=>(jn??=H(import.meta.url))(t),Nt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Un=t=>{if(typeof Nt<"u"&&Nt.versions&&Nt.versions.node){const[e,s]=Nt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Nt.getBuiltinModule(t)}return Gn(t)},{cp:qn}=Un("node:fs/promises"),Sa=async(t,e,s={})=>{P(t),P(e);const{dereference:n=!1,errorOnExist:o=!0,filter:r,overwrite:i=!0,preserveTimestamps:c=!1,recursive:u=!0,verbatimSymlinks:y=!1}=s,l=F(t),h=F(e);try{await qn(l,h,{dereference:n,errorOnExist:o,filter:r,force:i,preserveTimestamps:c,recursive:u,verbatimSymlinks:y})}catch($){throw $?.code==="ERR_FS_CP_EEXIST"?new xt(`destination already exists, copy '${h}'`):$}};let zn;const Wn=t=>(zn??=H(import.meta.url))(t),Lt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xn=t=>{if(typeof Lt<"u"&&Lt.versions&&Lt.versions.node){const[e,s]=Lt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Lt.getBuiltinModule(t)}return Wn(t)},{cpSync:Kn}=Xn("node:fs"),xa=(t,e,s={})=>{P(t),P(e);const{dereference:n=!1,errorOnExist:o=!0,filter:r,overwrite:i=!0,preserveTimestamps:c=!1,recursive:u=!0,verbatimSymlinks:y=!1}=s,l=F(t),h=F(e);try{Kn(l,h,{dereference:n,errorOnExist:o,filter:r,force:i,preserveTimestamps:c,recursive:u,verbatimSymlinks:y})}catch($){throw $?.code==="ERR_FS_CP_EEXIST"?new xt(`destination already exists, copy '${h}'`):$}},dt=t=>{if(t.isFile())return"file";if(t.isDirectory())return"dir";if(t.isSymbolicLink())return"symlink"};let Qn;const Vn=t=>(Qn??=H(import.meta.url))(t),Dt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Yn=t=>{if(typeof Dt<"u"&&Dt.versions&&Dt.versions.node){const[e,s]=Dt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Dt.getBuiltinModule(t)}return Vn(t)},{lstat:Ze,mkdir:Zn}=Yn("node:fs/promises"),We=async t=>{P(t);try{const e=await Ze(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await Zn(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const s=await Ze(t);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(s))}'`,{cause:e})}};let Jn;const tr=t=>(Jn??=H(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,er=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,s]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ft.getBuiltinModule(t)}return tr(t)},{lstatSync:Je,mkdirSync:sr}=er("node:fs"),Xe=t=>{P(t);try{const e=Je(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{sr(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const s=Je(t);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(dt(s))}'`,{cause:e})}};let nr;const rr=t=>(nr??=H(import.meta.url))(t),Ht=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,or=t=>{if(typeof Ht<"u"&&Ht.versions&&Ht.versions.node){const[e,s]=Ht.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ht.getBuiltinModule(t)}return rr(t)},{lstat:ir,writeFile:cr}=or("node:fs/promises"),Ea=async t=>{P(t);try{const e=await ir(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(dt(e))}'`)}catch(e){if(e.code==="ENOENT"){await We(V(F(t))),await cr(t,new Uint8Array);return}throw e}};let ur;const ar=t=>(ur??=H(import.meta.url))(t),It=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,lr=t=>{if(typeof It<"u"&&It.versions&&It.versions.node){const[e,s]=It.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return It.getBuiltinModule(t)}return ar(t)},{lstatSync:pr,writeFileSync:fr}=lr("node:fs"),Aa=t=>{P(t);try{const e=pr(t);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(dt(e))}'`)}catch(e){if(e.code==="ENOENT"){Xe(V(F(t))),fr(t,new Uint8Array);return}throw e}},xe=(t,e)=>e.ino!==0n&&e.dev!==0n&&e.ino===t.ino&&e.dev===t.dev;let hr;const dr=t=>(hr??=H(import.meta.url))(t),Bt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,gr=t=>{if(typeof Bt<"u"&&Bt.versions&&Bt.versions.node){const[e,s]=Bt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Bt.getBuiltinModule(t)}return dr(t)},{lstat:ts,link:yr}=gr("node:fs/promises"),_a=async(t,e)=>{P(t),P(e),t=ht(F(t)),e=ht(F(e));let s;try{s=await ts(e,{bigint:!0})}catch{}let n;try{n=await ts(t,{bigint:!0})}catch(o){const r=o;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&xe(n,s)||(await We(V(e)),await yr(t,e))};let mr;const $r=t=>(mr??=H(import.meta.url))(t),Mt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,br=t=>{if(typeof Mt<"u"&&Mt.versions&&Mt.versions.node){const[e,s]=Mt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Mt.getBuiltinModule(t)}return $r(t)},{lstatSync:es,linkSync:vr}=br("node:fs"),Ta=(t,e)=>{P(t),P(e),t=ht(F(t)),e=ht(F(e));let s;try{s=es(e,{bigint:!0})}catch{}let n;try{n=es(t,{bigint:!0})}catch(o){const r=o;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&xe(n,s)||(Xe(V(e)),vr(t,e))},Fs=(t,e)=>typeof t!="string"?t:t.startsWith("./")?tt(t):typeof e=="string"?tt(V(e),t):new URL(t,e);let wr;const Sr=t=>(wr??=H(import.meta.url))(t),Pt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xr=t=>{if(typeof Pt<"u"&&Pt.versions&&Pt.versions.node){const[e,s]=Pt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Pt.getBuiltinModule(t)}return Sr(t)},{lstat:ke,stat:ss,symlink:Er,readlink:Ar}=xr("node:fs/promises"),_r=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),Ra=async(t,e,s)=>{P(t),P(e);const n=Fs(t,e);e=ht(F(e));try{if((await ke(e)).isSymbolicLink()){const[c,u]=await Promise.all([ss(n,{bigint:!0}),ss(e,{bigint:!0})]);if(xe(c,u))return}}catch{}const o=await ke(n),r=dt(o);await We(V(e));let i=s??"file";s||(_r?i="junction":i=r==="dir"?"dir":"file");try{await Er(ht(F(n)),e,i)}catch(c){if(c.code!=="EEXIST")throw c;const u=await ke(e);if(!u.isSymbolicLink())throw new xt(`A ${String(dt(u))} already exists at the path: ${e}`);const y=await Ar(e),l=ht(tt(y));if(l!==n)throw new xt(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}};let Tr;const Rr=t=>(Tr??=H(import.meta.url))(t),jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,kr=t=>{if(typeof jt<"u"&&jt.versions&&jt.versions.node){const[e,s]=jt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return jt.getBuiltinModule(t)}return Rr(t)},{lstatSync:Ce,statSync:ns,symlinkSync:Cr,readlinkSync:Or}=kr("node:fs"),Nr=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),ka=(t,e,s)=>{P(t),P(e);const n=Fs(t,e);e=ht(F(e));try{if(Ce(e).isSymbolicLink()&&xe(ns(n,{bigint:!0}),ns(e,{bigint:!0})))return}catch{}const o=Ce(n),r=dt(o);Xe(V(e));let i=s??"file";s||(Nr?i="junction":i=r==="dir"?"dir":"file");try{Cr(ht(F(n)),e,i)}catch(c){if(c.code!=="EEXIST")throw c;const u=Ce(e);if(!u.isSymbolicLink())throw new xt(`A ${String(dt(u))} already exists at the path: ${e}`);const y=Or(e),l=ht(tt(y));if(l!==n)throw new xt(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}},Lr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{platform:Dr}=Lr,Hs=/\r?\n/g,Is=`
2
2
  `,Ge=`\r
3
3
  `,Ca=Dr==="win32"?Ge:Is,Oa=t=>{const e=t.match(Hs);if(!e||e.length===0)return null;const s=e.filter(o=>o===Ge).length,n=e.length-s;return s>n?Ge:Is},Na=(t,e)=>t.replaceAll(Hs,e);let me=class extends Error{root;constructor(e,s){super(`${e instanceof Error?e.message:String(e)} for path "${s}"`),this.cause=e,this.root=s}get name(){return"WalkError"}set name(e){throw new Error("Cannot overwrite name of WalkError")}};const Fr=t=>{const e=[],s=new Set;let n=0;for(const c of t){if(c==="{")e.push(n);else if(c==="}"){const u=e.pop();u!==void 0&&(s.add(u),s.add(n))}n+=1}let o=0,r=0,i="";for(const c of t)c==="{"?s.has(r)?(i+="(",o+=1):i+=String.raw`\{`:c==="}"?s.has(r)?(i+=")",o-=1):i+=String.raw`\}`:c===","&&o>0?i+="|":i+=c,r+=1;return i},$e=t=>{const e=t.replace(/[$()+\\^]/g,String.raw`\$&`).replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`),s=Fr(e).replace(/\[!(.*?)\]/g,"[^$1]");try{return new RegExp(`^${s}$`)}catch(n){throw new Error(`Invalid glob pattern: ${t}`,{cause:n})}};let Hr=class{name;path;#t;constructor(e,s,n){this.#t=e,this.name=s,this.path=n}isDirectory(){return this.#t.isDirectory()}isFile(){return this.#t.isFile()}isSymbolicLink(){return this.#t.isSymbolicLink()}};const kt=(t,e,s)=>new Hr(t,e,s),wt=(t,e,s,n)=>{if(Array.isArray(e)&&e.length>0&&!e.some(r=>t.endsWith(r)))return!1;const o=t.includes("\\")?t.replaceAll("\\","/"):t;return s&&!s.some(r=>r.test(o))?!1:!n?.some(r=>r.test(o))};let Ir;const Br=t=>(Ir??=H(import.meta.url))(t),Gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mr=t=>{if(typeof Gt<"u"&&Gt.versions&&Gt.versions.node){const[e,s]=Gt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Gt.getBuiltinModule(t)}return Br(t)},{readdir:Pr,realpath:jr,stat:Bs}=Mr("node:fs/promises"),Gr=async t=>{const e=Tt(t),s=le(e),n=await Bs(e);return kt(n,s,e)};async function*Ms(t,e={}){const{extensions:s,followSymlinks:n=!1,includeDirs:o=!0,includeFiles:r=!0,includeSymlinks:i=!0,match:c,maxDepth:u=Number.POSITIVE_INFINITY,skip:y}=e;if(P(t),u<0)return;const l=e.visited??new Set,h=c?c.map(g=>typeof g=="string"?$e(g):g):void 0,$=y?y.map(g=>typeof g=="string"?$e(g):g):void 0;if(t=tt(F(t)),o&&wt(t,s,h,$)&&(yield await Gr(t)),!(u<1||!wt(t,void 0,void 0,$)))try{const g=await Pr(t,{withFileTypes:!0});for(const b of g){let E=Se(t,b.name),R=b,{name:C}=b,D=b.isDirectory(),m=b.isFile();if(b.isSymbolicLink())if(n){const v=Tt(await jr(E));if(l.has(v))continue;E=v;const a=await Bs(v);D=a.isDirectory(),m=a.isFile(),R=a,C=le(v)}else if(i&&wt(E,s,h,$)){yield kt(b,b.name,E);continue}else continue;D?(n&&l.add(E),yield*Ms(E,{extensions:s,followSymlinks:n,includeDirs:o,includeFiles:r,includeSymlinks:i,match:h,maxDepth:u-1,skip:$,visited:l})):m&&r&&wt(E,s,h,$)&&(yield kt(R,C,E))}}catch(g){throw g instanceof me?g:new me(g,t)}}const Fa=async(t,e={})=>{Array.isArray(e.extensions)||(e.extensions=["js","mjs","cjs","ts"]);const s=[];for await(const n of Ms(t,e))s.push(n.path);return s};let Ur;const qr=t=>(Ur??=H(import.meta.url))(t),Ut=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zr=t=>{if(typeof Ut<"u"&&Ut.versions&&Ut.versions.node){const[e,s]=Ut.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Ut.getBuiltinModule(t)}return qr(t)},{readdirSync:Wr,realpathSync:Xr,statSync:Ps}=zr("node:fs"),Kr=t=>{const e=Tt(t),s=Ps(e);return kt(s,le(e),e)};function*js(t,e={}){const{extensions:s,followSymlinks:n=!1,includeDirs:o=!0,includeFiles:r=!0,includeSymlinks:i=!0,match:c,maxDepth:u=Number.POSITIVE_INFINITY,skip:y}=e;if(P(t),u<0)return;const l=e.visited??new Set,h=c?c.map(g=>typeof g=="string"?$e(g):g):void 0,$=y?y.map(g=>typeof g=="string"?$e(g):g):void 0;if(t=tt(F(t)),o&&wt(t,s,h,$)&&(yield Kr(t)),!(u<1||!wt(t,void 0,void 0,$)))try{const g=Wr(t,{withFileTypes:!0});for(const b of g){let E=Se(t,b.name),R=b,{name:C}=b,D=b.isDirectory(),m=b.isFile();if(b.isSymbolicLink())if(n){const v=Tt(Xr(E));if(l.has(v))continue;E=v;const a=Ps(v);D=a.isDirectory(),m=a.isFile(),R=a,C=le(v)}else if(i&&wt(E,s,h,$)){yield kt(b,b.name,Tt(E));continue}else continue;D?(n&&l.add(E),yield*js(E,{extensions:s,followSymlinks:n,includeDirs:o,includeFiles:r,includeSymlinks:i,match:h,maxDepth:u-1,skip:$,visited:l})):m&&r&&wt(E,s,h,$)&&(yield kt(R,C,Tt(E)))}}catch(g){throw g instanceof me?g:new me(g,t)}}const Ha=(t,e={})=>{Array.isArray(e.extensions)||(e.extensions=["js","mjs","cjs","ts"]);const s=[];for(const n of js(t,e))s.push(n.path);return s};let Qr;const Vr=t=>(Qr??=H(import.meta.url))(t),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Yr=t=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[e,s]=qt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return qt.getBuiltinModule(t)}return Vr(t)},{stat:Zr,lstat:Jr}=Yr("node:fs/promises"),Ia=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const s=e.cwd?F(e.cwd):process.cwd();let n=tt(s);const{root:o}=Ds(n),r=F(e.stopAt??o),i=tt(n,r),c=e.type??"file",u=async function(l){return typeof t=="function"?[await t(l)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};e.allowSymlinks??=!0;const y=e.allowSymlinks?Zr:Jr;for(;n;){const l=await u(n);for(let h of l){if(h===Ns)return;if(h===void 0)continue;Buffer.isBuffer(h)?h=h.toString():h instanceof URL&&(h=F(h));const $=St(h)?h:tt(n,h);try{const g=await y($);if(c==="file"&&g.isFile()||c==="directory"&&g.isDirectory())return $}catch{}}if(n===i||n===o)break;n=V(n)}};let to;const eo=t=>(to??=H(import.meta.url))(t),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,so=t=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[e,s]=zt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return zt.getBuiltinModule(t)}return eo(t)},{statSync:no,lstatSync:ro}=so("node:fs"),Ba=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const s=e.cwd?F(e.cwd):process.cwd();let n=tt(s);const{root:o}=Ds(n),r=F(e.stopAt??o),i=tt(n,r),c=e.type??"file",u=function(l){return typeof t=="function"?[t(l)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};e.allowSymlinks??=!0;const y=e.allowSymlinks?no:ro;for(;n;){for(let l of u(n)){if(l===Ns)return;if(l===void 0)continue;Buffer.isBuffer(l)?l=l.toString():l instanceof URL&&(l=F(l));const h=St(l)?l:tt(n,l);try{const $=y(h);if(c==="file"&&$.isFile()||c==="directory"&&$.isDirectory())return h}catch{}}if(n===i||n===o)break;n=V(n)}};function Ke(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rs={},Oe,os;function Ee(){if(os)return Oe;os=1;const t="\\\\/",e=`[^${t}]`,s=0,n=Symbol("unignore"),o="\\.",r="\\+",i="\\?",c="\\/",u="(?=.)",y="[^/]",l=`(?:${c}|$)`,h=`(?:^|${c})`,$=`${o}{1,2}${l}`,g=`(?!${o})`,b=`(?!${h}${$})`,E=`(?!${o}{0,1}${l})`,R=`(?!${$})`,C=`[^.${c}]`,D=`${y}*?`,m={DOT_LITERAL:o,PLUS_LITERAL:r,QMARK_LITERAL:i,SLASH_LITERAL:c,ONE_CHAR:u,QMARK:y,END_ANCHOR:l,DOTS_SLASH:$,NO_DOT:g,NO_DOTS:b,NO_DOT_SLASH:E,NO_DOTS_SLASH:R,QMARK_NO_DOT:C,STAR:D,START_ANCHOR:h,SEP:"/"},v={...m,SLASH_LITERAL:`[${t}]`,QMARK:e,STAR:`${e}*?`,DOTS_SLASH:`${o}{1,2}(?:[${t}]|$)`,NO_DOT:`(?!${o})`,NO_DOTS:`(?!(?:^|[${t}])${o}{1,2}(?:[${t}]|$))`,NO_DOT_SLASH:`(?!${o}{0,1}(?:[${t}]|$))`,NO_DOTS_SLASH:`(?!${o}{1,2}(?:[${t}]|$))`,QMARK_NO_DOT:`[^.${t}]`,START_ANCHOR:`(?:^|[${t}])`,END_ANCHOR:`(?:[${t}]|$)`,SEP:"\\"},a={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return Oe={DEFAULT_MAX_EXTGLOB_RECURSION:s,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:a,UNIGNORE:n,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(A){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${A.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(A){return A===!0?v:m}},Oe}var is;function Ae(){return is||(is=1,(function(t){const{REGEX_BACKSLASH:e,REGEX_REMOVE_BACKSLASH:s,REGEX_SPECIAL_CHARS:n,REGEX_SPECIAL_CHARS_GLOBAL:o}=Ee();t.isObject=r=>r!==null&&typeof r=="object"&&!Array.isArray(r),t.hasRegexChars=r=>n.test(r),t.isRegexChar=r=>r.length===1&&t.hasRegexChars(r),t.escapeRegex=r=>r.replace(o,"\\$1"),t.toPosixSlashes=r=>r.replace(e,"/"),t.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){const r=navigator.platform.toLowerCase();return r==="win32"||r==="windows"}return process.platform?process.platform==="win32":!1},t.removeBackslashes=r=>r.replace(s,i=>i==="\\"?"":i),t.escapeLast=(r,i,c)=>{const u=r.lastIndexOf(i,c);return u===-1?r:r[u-1]==="\\"?t.escapeLast(r,i,u-1):`${r.slice(0,u)}\\${r.slice(u)}`},t.removePrefix=(r,i={})=>{let c=r;return c.startsWith("./")&&(c=c.slice(2),i.prefix="./"),c},t.wrapOutput=(r,i={},c={})=>{const u=c.contains?"":"^",y=c.contains?"":"$";let l=`${u}(?:${r})${y}`;return i.negated===!0&&(l=`(?:^(?!${l}).*$)`),l},t.basename=(r,{windows:i}={})=>{const c=r.split(i?/[\\/]/:"/"),u=c[c.length-1];return u===""?c[c.length-2]:u}})(rs)),rs}var Ne,cs;function oo(){if(cs)return Ne;cs=1;const t=Ae(),{CHAR_ASTERISK:e,CHAR_AT:s,CHAR_BACKWARD_SLASH:n,CHAR_COMMA:o,CHAR_DOT:r,CHAR_EXCLAMATION_MARK:i,CHAR_FORWARD_SLASH:c,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:y,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_PLUS:h,CHAR_QUESTION_MARK:$,CHAR_RIGHT_CURLY_BRACE:g,CHAR_RIGHT_PARENTHESES:b,CHAR_RIGHT_SQUARE_BRACKET:E}=Ee(),R=D=>D===c||D===n,C=D=>{D.isPrefix!==!0&&(D.depth=D.isGlobstar?1/0:1)};return Ne=(D,m)=>{const v=m||{},a=D.length-1,A=v.parts===!0||v.scanToEnd===!0,O=[],_=[],T=[];let x=D,B=-1,U=0,nt=0,gt=!1,rt=!1,K=!1,ot=!1,mt=!1,ut=!1,it=!1,W=!1,at=!1,Z=!1,$t=0,J,k,M={value:"",depth:0,isGlob:!1};const Y=()=>B>=a,d=()=>x.charCodeAt(B+1),q=()=>(J=k,x.charCodeAt(++B));for(;B<a;){k=q();let et;if(k===n){it=M.backslashes=!0,k=q(),k===u&&(ut=!0);continue}if(ut===!0||k===u){for($t++;Y()!==!0&&(k=q());){if(k===n){it=M.backslashes=!0,q();continue}if(k===u){$t++;continue}if(ut!==!0&&k===r&&(k=q())===r){if(gt=M.isBrace=!0,K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(ut!==!0&&k===o){if(gt=M.isBrace=!0,K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(k===g&&($t--,$t===0)){ut=!1,gt=M.isBrace=!0,Z=!0;break}}if(A===!0)continue;break}if(k===c){if(O.push(B),_.push(M),M={value:"",depth:0,isGlob:!1},Z===!0)continue;if(J===r&&B===U+1){U+=2;continue}nt=B+1;continue}if(v.noext!==!0&&(k===h||k===s||k===e||k===$||k===i)&&d()===y){if(K=M.isGlob=!0,ot=M.isExtglob=!0,Z=!0,k===i&&B===U&&(at=!0),A===!0){for(;Y()!==!0&&(k=q());){if(k===n){it=M.backslashes=!0,k=q();continue}if(k===b){K=M.isGlob=!0,Z=!0;break}}continue}break}if(k===e){if(J===e&&(mt=M.isGlobstar=!0),K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(k===$){if(K=M.isGlob=!0,Z=!0,A===!0)continue;break}if(k===l){for(;Y()!==!0&&(et=q());){if(et===n){it=M.backslashes=!0,q();continue}if(et===E){rt=M.isBracket=!0,K=M.isGlob=!0,Z=!0;break}}if(A===!0)continue;break}if(v.nonegate!==!0&&k===i&&B===U){W=M.negated=!0,U++;continue}if(v.noparen!==!0&&k===y){if(K=M.isGlob=!0,A===!0){for(;Y()!==!0&&(k=q());){if(k===y){it=M.backslashes=!0,k=q();continue}if(k===b){Z=!0;break}}continue}break}if(K===!0){if(Z=!0,A===!0)continue;break}}v.noext===!0&&(ot=!1,K=!1);let G=x,bt="",p="";U>0&&(bt=x.slice(0,U),x=x.slice(U),nt-=U),G&&K===!0&&nt>0?(G=x.slice(0,nt),p=x.slice(nt)):K===!0?(G="",p=x):G=x,G&&G!==""&&G!=="/"&&G!==x&&R(G.charCodeAt(G.length-1))&&(G=G.slice(0,-1)),v.unescape===!0&&(p&&(p=t.removeBackslashes(p)),G&&it===!0&&(G=t.removeBackslashes(G)));const f={prefix:bt,input:D,start:U,base:G,glob:p,isBrace:gt,isBracket:rt,isGlob:K,isExtglob:ot,isGlobstar:mt,negated:W,negatedExtglob:at};if(v.tokens===!0&&(f.maxDepth=0,R(k)||_.push(M),f.tokens=_),v.parts===!0||v.tokens===!0){let et;for(let I=0;I<O.length;I++){const ct=et?et+1:U,lt=O[I],st=D.slice(ct,lt);v.tokens&&(I===0&&U!==0?(_[I].isPrefix=!0,_[I].value=bt):_[I].value=st,C(_[I]),f.maxDepth+=_[I].depth),(I!==0||st!=="")&&T.push(st),et=lt}if(et&&et+1<D.length){const I=D.slice(et+1);T.push(I),v.tokens&&(_[_.length-1].value=I,C(_[_.length-1]),f.maxDepth+=_[_.length-1].depth)}f.slashes=O,f.parts=T}return f},Ne}var Le,us;function io(){if(us)return Le;us=1;const t=Ee(),e=Ae(),{MAX_LENGTH:s,POSIX_REGEX_SOURCE:n,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:r,REPLACEMENTS:i}=t,c=(m,v)=>{if(typeof v.expandRange=="function")return v.expandRange(...m,v);m.sort();const a=`[${m.join("-")}]`;try{new RegExp(a)}catch{return m.map(A=>e.escapeRegex(A)).join("..")}return a},u=(m,v)=>`Missing ${m}: "${v}" - use "\\\\${v}" to match literal characters`,y=m=>{const v=[];let a=0,A=0,O=0,_="",T=!1;for(const x of m){if(T===!0){_+=x,T=!1;continue}if(x==="\\"){_+=x,T=!0;continue}if(x==='"'){O=O===1?0:1,_+=x;continue}if(O===0){if(x==="[")a++;else if(x==="]"&&a>0)a--;else if(a===0){if(x==="(")A++;else if(x===")"&&A>0)A--;else if(x==="|"&&A===0){v.push(_),_="";continue}}}_+=x}return v.push(_),v},l=m=>{let v=!1;for(const a of m){if(v===!0){v=!1;continue}if(a==="\\"){v=!0;continue}if(/[?*+@!()[\]{}]/.test(a))return!1}return!0},h=m=>{let v=m.trim(),a=!0;for(;a===!0;)a=!1,/^@\([^\\()[\]{}|]+\)$/.test(v)&&(v=v.slice(2,-1),a=!0);if(l(v))return v.replace(/\\(.)/g,"$1")},$=m=>{const v=m.map(h).filter(Boolean);for(let a=0;a<v.length;a++)for(let A=a+1;A<v.length;A++){const O=v[a],_=v[A],T=O[0];if(!(!T||O!==T.repeat(O.length)||_!==T.repeat(_.length))&&(O===_||O.startsWith(_)||_.startsWith(O)))return!0}return!1},g=(m,v=!0)=>{if(m[0]!=="+"&&m[0]!=="*"||m[1]!=="(")return;let a=0,A=0,O=0,_=!1;for(let T=1;T<m.length;T++){const x=m[T];if(_===!0){_=!1;continue}if(x==="\\"){_=!0;continue}if(x==='"'){O=O===1?0:1;continue}if(O!==1){if(x==="["){a++;continue}if(x==="]"&&a>0){a--;continue}if(!(a>0)){if(x==="("){A++;continue}if(x===")"&&(A--,A===0))return v===!0&&T!==m.length-1?void 0:{type:m[0],body:m.slice(2,T),end:T}}}}},b=m=>`${m.length===1?e.escapeRegex(m[0]):`[${m.map(v=>e.escapeRegex(v)).join("")}]`}*`,E=m=>{let v=0;const a=[];for(;v<m.length;){const A=g(m.slice(v),!1);if(!A||A.type!=="*")return;const O=y(A.body).map(T=>T.trim());if(O.length!==1)return;const _=h(O[0]);if(!_||_.length!==1)return;a.push(_),v+=A.end+1}if(!(a.length<1))return a},R=m=>{let v=0,a=m.trim(),A=g(a);for(;A;)v++,a=A.body.trim(),A=g(a);return v},C=(m,v)=>{if(v.maxExtglobRecursion===!1)return{risky:!1};const a=typeof v.maxExtglobRecursion=="number"?v.maxExtglobRecursion:t.DEFAULT_MAX_EXTGLOB_RECURSION,A=y(m).map(x=>x.trim());if(A.length>1&&(A.some(x=>x==="")||A.some(x=>/^[*?]+$/.test(x))||$(A)))return{risky:!0};const O=[];let _=!1,T=!0;for(const x of A){const B=E(x);if(B){_=!0,O.push(...B);continue}const U=h(x);if(U&&U.length===1){O.push(U);continue}if(T=!1,R(x)>a)return{risky:!0}}return _?T?{risky:!0,safeOutput:b([...new Set(O)])}:{risky:!0}:{risky:!1}},D=(m,v)=>{if(typeof m!="string")throw new TypeError("Expected a string");m=i[m]||m;const a={...v},A=typeof a.maxLength=="number"?Math.min(s,a.maxLength):s;let O=m.length;if(O>A)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${A}`);const _={type:"bos",value:"",output:a.prepend||""},T=[_],x=a.capture?"":"?:",B=t.globChars(a.windows),U=t.extglobChars(B),{DOT_LITERAL:nt,PLUS_LITERAL:gt,SLASH_LITERAL:rt,ONE_CHAR:K,DOTS_SLASH:ot,NO_DOT:mt,NO_DOT_SLASH:ut,NO_DOTS_SLASH:it,QMARK:W,QMARK_NO_DOT:at,STAR:Z,START_ANCHOR:$t}=B,J=S=>`(${x}(?:(?!${$t}${S.dot?ot:nt}).)*?)`,k=a.dot?"":mt,M=a.dot?W:at;let Y=a.bash===!0?J(a):Z;a.capture&&(Y=`(${Y})`),typeof a.noext=="boolean"&&(a.noextglob=a.noext);const d={input:m,index:-1,start:0,dot:a.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:T};m=e.removePrefix(m,d),O=m.length;const q=[],G=[],bt=[];let p=_,f;const et=()=>d.index===O-1,I=d.peek=(S=1)=>m[d.index+S],ct=d.advance=()=>m[++d.index]||"",lt=()=>m.slice(d.index+1),st=(S="",z=0)=>{d.consumed+=S,d.index+=z},de=S=>{d.output+=S.output!=null?S.output:S.value,st(S.value)},bn=()=>{let S=1;for(;I()==="!"&&(I(2)!=="("||I(3)==="?");)ct(),d.start++,S++;return S%2===0?!1:(d.negated=!0,d.start++,!0)},ge=S=>{d[S]++,bt.push(S)},vt=S=>{d[S]--,bt.pop()},N=S=>{if(p.type==="globstar"){const z=d.braces>0&&(S.type==="comma"||S.type==="brace"),w=S.extglob===!0||q.length&&(S.type==="pipe"||S.type==="paren");S.type!=="slash"&&S.type!=="paren"&&!z&&!w&&(d.output=d.output.slice(0,-p.output.length),p.type="star",p.value="*",p.output=Y,d.output+=p.output)}if(q.length&&S.type!=="paren"&&(q[q.length-1].inner+=S.value),(S.value||S.output)&&de(S),p&&p.type==="text"&&S.type==="text"){p.output=(p.output||p.value)+S.value,p.value+=S.value;return}S.prev=p,T.push(S),p=S},ye=(S,z)=>{const w={...U[z],conditions:1,inner:""};w.prev=p,w.parens=d.parens,w.output=d.output,w.startIndex=d.index,w.tokensIndex=T.length;const L=(a.capture?"(":"")+w.open;ge("parens"),N({type:S,value:z,output:d.output?"":K}),N({type:"paren",extglob:!0,value:ct(),output:L}),q.push(w)},vn=S=>{const z=m.slice(S.startIndex,d.index+1),w=m.slice(S.startIndex+2,d.index),L=C(w,a);if((S.type==="plus"||S.type==="star")&&L.risky){const j=L.safeOutput?(S.output?"":K)+(a.capture?`(${L.safeOutput})`:L.safeOutput):void 0,pt=T[S.tokensIndex];pt.type="text",pt.value=z,pt.output=j||e.escapeRegex(z);for(let ft=S.tokensIndex+1;ft<T.length;ft++)T[ft].value="",T[ft].output="",delete T[ft].suffix;d.output=S.output+pt.output,d.backtrack=!0,N({type:"paren",extglob:!0,value:f,output:""}),vt("parens");return}let X=S.close+(a.capture?")":""),Q;if(S.type==="negate"){let j=Y;if(S.inner&&S.inner.length>1&&S.inner.includes("/")&&(j=J(a)),(j!==Y||et()||/^\)+$/.test(lt()))&&(X=S.close=`)$))${j}`),S.inner.includes("*")&&(Q=lt())&&/^\.[^\\/.]+$/.test(Q)){const pt=D(Q,{...v,fastpaths:!1}).output;X=S.close=`)${pt})${j})`}S.prev.type==="bos"&&(d.negatedExtglob=!0)}N({type:"paren",extglob:!0,value:f,output:X}),vt("parens")};if(a.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(m)){let S=!1,z=m.replace(r,(w,L,X,Q,j,pt)=>Q==="\\"?(S=!0,w):Q==="?"?L?L+Q+(j?W.repeat(j.length):""):pt===0?M+(j?W.repeat(j.length):""):W.repeat(X.length):Q==="."?nt.repeat(X.length):Q==="*"?L?L+Q+(j?Y:""):Y:L?w:`\\${w}`);return S===!0&&(a.unescape===!0?z=z.replace(/\\/g,""):z=z.replace(/\\+/g,w=>w.length%2===0?"\\\\":w?"\\":"")),z===m&&a.contains===!0?(d.output=m,d):(d.output=e.wrapOutput(z,d,v),d)}for(;!et();){if(f=ct(),f==="\0")continue;if(f==="\\"){const w=I();if(w==="/"&&a.bash!==!0||w==="."||w===";")continue;if(!w){f+="\\",N({type:"text",value:f});continue}const L=/^\\+/.exec(lt());let X=0;if(L&&L[0].length>2&&(X=L[0].length,d.index+=X,X%2!==0&&(f+="\\")),a.unescape===!0?f=ct():f+=ct(),d.brackets===0){N({type:"text",value:f});continue}}if(d.brackets>0&&(f!=="]"||p.value==="["||p.value==="[^")){if(a.posix!==!1&&f===":"){const w=p.value.slice(1);if(w.includes("[")&&(p.posix=!0,w.includes(":"))){const L=p.value.lastIndexOf("["),X=p.value.slice(0,L),Q=p.value.slice(L+2),j=n[Q];if(j){p.value=X+j,d.backtrack=!0,ct(),!_.output&&T.indexOf(p)===1&&(_.output=K);continue}}}(f==="["&&I()!==":"||f==="-"&&I()==="]")&&(f=`\\${f}`),f==="]"&&(p.value==="["||p.value==="[^")&&(f=`\\${f}`),a.posix===!0&&f==="!"&&p.value==="["&&(f="^"),p.value+=f,de({value:f});continue}if(d.quotes===1&&f!=='"'){f=e.escapeRegex(f),p.value+=f,de({value:f});continue}if(f==='"'){d.quotes=d.quotes===1?0:1,a.keepQuotes===!0&&N({type:"text",value:f});continue}if(f==="("){ge("parens"),N({type:"paren",value:f});continue}if(f===")"){if(d.parens===0&&a.strictBrackets===!0)throw new SyntaxError(u("opening","("));const w=q[q.length-1];if(w&&d.parens===w.parens+1){vn(q.pop());continue}N({type:"paren",value:f,output:d.parens?")":"\\)"}),vt("parens");continue}if(f==="["){if(a.nobracket===!0||!lt().includes("]")){if(a.nobracket!==!0&&a.strictBrackets===!0)throw new SyntaxError(u("closing","]"));f=`\\${f}`}else ge("brackets");N({type:"bracket",value:f});continue}if(f==="]"){if(a.nobracket===!0||p&&p.type==="bracket"&&p.value.length===1){N({type:"text",value:f,output:`\\${f}`});continue}if(d.brackets===0){if(a.strictBrackets===!0)throw new SyntaxError(u("opening","["));N({type:"text",value:f,output:`\\${f}`});continue}vt("brackets");const w=p.value.slice(1);if(p.posix!==!0&&w[0]==="^"&&!w.includes("/")&&(f=`/${f}`),p.value+=f,de({value:f}),a.literalBrackets===!1||e.hasRegexChars(w))continue;const L=e.escapeRegex(p.value);if(d.output=d.output.slice(0,-p.value.length),a.literalBrackets===!0){d.output+=L,p.value=L;continue}p.value=`(${x}${L}|${p.value})`,d.output+=p.value;continue}if(f==="{"&&a.nobrace!==!0){ge("braces");const w={type:"brace",value:f,output:"(",outputIndex:d.output.length,tokensIndex:d.tokens.length};G.push(w),N(w);continue}if(f==="}"){const w=G[G.length-1];if(a.nobrace===!0||!w){N({type:"text",value:f,output:f});continue}let L=")";if(w.dots===!0){const X=T.slice(),Q=[];for(let j=X.length-1;j>=0&&(T.pop(),X[j].type!=="brace");j--)X[j].type!=="dots"&&Q.unshift(X[j].value);L=c(Q,a),d.backtrack=!0}if(w.comma!==!0&&w.dots!==!0){const X=d.output.slice(0,w.outputIndex),Q=d.tokens.slice(w.tokensIndex);w.value=w.output="\\{",f=L="\\}",d.output=X;for(const j of Q)d.output+=j.output||j.value}N({type:"brace",value:f,output:L}),vt("braces"),G.pop();continue}if(f==="|"){q.length>0&&q[q.length-1].conditions++,N({type:"text",value:f});continue}if(f===","){let w=f;const L=G[G.length-1];L&&bt[bt.length-1]==="braces"&&(L.comma=!0,w="|"),N({type:"comma",value:f,output:w});continue}if(f==="/"){if(p.type==="dot"&&d.index===d.start+1){d.start=d.index+1,d.consumed="",d.output="",T.pop(),p=_;continue}N({type:"slash",value:f,output:rt});continue}if(f==="."){if(d.braces>0&&p.type==="dot"){p.value==="."&&(p.output=nt);const w=G[G.length-1];p.type="dots",p.output+=f,p.value+=f,w.dots=!0;continue}if(d.braces+d.parens===0&&p.type!=="bos"&&p.type!=="slash"){N({type:"text",value:f,output:nt});continue}N({type:"dot",value:f,output:nt});continue}if(f==="?"){if(!(p&&p.value==="(")&&a.noextglob!==!0&&I()==="("&&I(2)!=="?"){ye("qmark",f);continue}if(p&&p.type==="paren"){const w=I();let L=f;(p.value==="("&&!/[!=<:]/.test(w)||w==="<"&&!/<([!=]|\w+>)/.test(lt()))&&(L=`\\${f}`),N({type:"text",value:f,output:L});continue}if(a.dot!==!0&&(p.type==="slash"||p.type==="bos")){N({type:"qmark",value:f,output:at});continue}N({type:"qmark",value:f,output:W});continue}if(f==="!"){if(a.noextglob!==!0&&I()==="("&&(I(2)!=="?"||!/[!=<:]/.test(I(3)))){ye("negate",f);continue}if(a.nonegate!==!0&&d.index===0){bn();continue}}if(f==="+"){if(a.noextglob!==!0&&I()==="("&&I(2)!=="?"){ye("plus",f);continue}if(p&&p.value==="("||a.regex===!1){N({type:"plus",value:f,output:gt});continue}if(p&&(p.type==="bracket"||p.type==="paren"||p.type==="brace")||d.parens>0){N({type:"plus",value:f});continue}N({type:"plus",value:gt});continue}if(f==="@"){if(a.noextglob!==!0&&I()==="("&&I(2)!=="?"){N({type:"at",extglob:!0,value:f,output:""});continue}N({type:"text",value:f});continue}if(f!=="*"){(f==="$"||f==="^")&&(f=`\\${f}`);const w=o.exec(lt());w&&(f+=w[0],d.index+=w[0].length),N({type:"text",value:f});continue}if(p&&(p.type==="globstar"||p.star===!0)){p.type="star",p.star=!0,p.value+=f,p.output=Y,d.backtrack=!0,d.globstar=!0,st(f);continue}let S=lt();if(a.noextglob!==!0&&/^\([^?]/.test(S)){ye("star",f);continue}if(p.type==="star"){if(a.noglobstar===!0){st(f);continue}const w=p.prev,L=w.prev,X=w.type==="slash"||w.type==="bos",Q=L&&(L.type==="star"||L.type==="globstar");if(a.bash===!0&&(!X||S[0]&&S[0]!=="/")){N({type:"star",value:f,output:""});continue}const j=d.braces>0&&(w.type==="comma"||w.type==="brace"),pt=q.length&&(w.type==="pipe"||w.type==="paren");if(!X&&w.type!=="paren"&&!j&&!pt){N({type:"star",value:f,output:""});continue}for(;S.slice(0,3)==="/**";){const ft=m[d.index+4];if(ft&&ft!=="/")break;S=S.slice(3),st("/**",3)}if(w.type==="bos"&&et()){p.type="globstar",p.value+=f,p.output=J(a),d.output=p.output,d.globstar=!0,st(f);continue}if(w.type==="slash"&&w.prev.type!=="bos"&&!Q&&et()){d.output=d.output.slice(0,-(w.output+p.output).length),w.output=`(?:${w.output}`,p.type="globstar",p.output=J(a)+(a.strictSlashes?")":"|$)"),p.value+=f,d.globstar=!0,d.output+=w.output+p.output,st(f);continue}if(w.type==="slash"&&w.prev.type!=="bos"&&S[0]==="/"){const ft=S[1]!==void 0?"|$":"";d.output=d.output.slice(0,-(w.output+p.output).length),w.output=`(?:${w.output}`,p.type="globstar",p.output=`${J(a)}${rt}|${rt}${ft})`,p.value+=f,d.output+=w.output+p.output,d.globstar=!0,st(f+ct()),N({type:"slash",value:"/",output:""});continue}if(w.type==="bos"&&S[0]==="/"){p.type="globstar",p.value+=f,p.output=`(?:^|${rt}|${J(a)}${rt})`,d.output=p.output,d.globstar=!0,st(f+ct()),N({type:"slash",value:"/",output:""});continue}if(j&&S[0]==="/"){p.type="globstar",p.value+=f,p.output=`(?:^|${rt}|${J(a)}${rt})`,d.output+=p.output,d.globstar=!0,st(f+ct()),N({type:"slash",value:"/",output:""});continue}d.output=d.output.slice(0,-p.output.length),p.type="globstar",p.output=J(a),p.value+=f,d.output+=p.output,d.globstar=!0,st(f);continue}const z={type:"star",value:f,output:Y};if(a.bash===!0){z.output=".*?",(p.type==="bos"||p.type==="slash")&&(z.output=k+z.output),N(z);continue}if(p&&(p.type==="bracket"||p.type==="paren")&&a.regex===!0){z.output=f,N(z);continue}(d.index===d.start||p.type==="slash"||p.type==="dot")&&(p.type==="dot"?(d.output+=ut,p.output+=ut):a.dot===!0?(d.output+=it,p.output+=it):(d.output+=k,p.output+=k),I()!=="*"&&(d.output+=K,p.output+=K)),N(z)}for(;d.brackets>0;){if(a.strictBrackets===!0)throw new SyntaxError(u("closing","]"));d.output=e.escapeLast(d.output,"["),vt("brackets")}for(;d.parens>0;){if(a.strictBrackets===!0)throw new SyntaxError(u("closing",")"));d.output=e.escapeLast(d.output,"("),vt("parens")}for(;d.braces>0;){if(a.strictBrackets===!0)throw new SyntaxError(u("closing","}"));d.output=e.escapeLast(d.output,"{"),vt("braces")}if(a.strictSlashes!==!0&&(p.type==="star"||p.type==="bracket")&&N({type:"maybe_slash",value:"",output:`${rt}?`}),d.backtrack===!0){d.output="";for(const S of d.tokens)d.output+=S.output!=null?S.output:S.value,S.suffix&&(d.output+=S.suffix)}return d};return D.fastpaths=(m,v)=>{const a={...v},A=typeof a.maxLength=="number"?Math.min(s,a.maxLength):s,O=m.length;if(O>A)throw new SyntaxError(`Input length: ${O}, exceeds maximum allowed length: ${A}`);m=i[m]||m;const{DOT_LITERAL:_,SLASH_LITERAL:T,ONE_CHAR:x,DOTS_SLASH:B,NO_DOT:U,NO_DOTS:nt,NO_DOTS_SLASH:gt,STAR:rt,START_ANCHOR:K}=t.globChars(a.windows),ot=a.dot?nt:U,mt=a.dot?gt:U,ut=a.capture?"":"?:",it={negated:!1,prefix:""};let W=a.bash===!0?".*?":rt;a.capture&&(W=`(${W})`);const at=k=>k.noglobstar===!0?W:`(${ut}(?:(?!${K}${k.dot?B:_}).)*?)`,Z=k=>{switch(k){case"*":return`${ot}${x}${W}`;case".*":return`${_}${x}${W}`;case"*.*":return`${ot}${W}${_}${x}${W}`;case"*/*":return`${ot}${W}${T}${x}${mt}${W}`;case"**":return ot+at(a);case"**/*":return`(?:${ot}${at(a)}${T})?${mt}${x}${W}`;case"**/*.*":return`(?:${ot}${at(a)}${T})?${mt}${W}${_}${x}${W}`;case"**/.*":return`(?:${ot}${at(a)}${T})?${_}${x}${W}`;default:{const M=/^(.*?)\.(\w+)$/.exec(k);if(!M)return;const Y=Z(M[1]);return Y?Y+_+M[2]:void 0}}},$t=e.removePrefix(m,it);let J=Z($t);return J&&a.strictSlashes!==!0&&(J+=`${T}?`),J},Le=D,Le}var De,as;function co(){if(as)return De;as=1;const t=oo(),e=io(),s=Ae(),n=Ee(),o=i=>i&&typeof i=="object"&&!Array.isArray(i),r=(i,c,u=!1)=>{if(Array.isArray(i)){const R=i.map(C=>r(C,c,u));return C=>{for(const D of R){const m=D(C);if(m)return m}return!1}}const y=o(i)&&i.tokens&&i.input;if(i===""||typeof i!="string"&&!y)throw new TypeError("Expected pattern to be a non-empty string");const l=c||{},h=l.windows,$=y?r.compileRe(i,c):r.makeRe(i,c,!1,!0),g=$.state;delete $.state;let b=()=>!1;if(l.ignore){const R={...c,ignore:null,onMatch:null,onResult:null};b=r(l.ignore,R,u)}const E=(R,C=!1)=>{const{isMatch:D,match:m,output:v}=r.test(R,$,c,{glob:i,posix:h}),a={glob:i,state:g,regex:$,posix:h,input:R,output:v,match:m,isMatch:D};if(typeof l.onResult=="function"&&l.onResult(a),D===!1)return a.isMatch=!1,C?a:!1;t:if(b(R)){if(typeof l.onIgnore=="function"&&l.onIgnore(a)===n.UNIGNORE){a.isMatch=!0;break t}return a.isMatch=!1,C?a:!1}return typeof l.onMatch=="function"&&l.onMatch(a),C?a:!0};return u&&(E.state=g),E};return r.test=(i,c,u,{glob:y,posix:l}={})=>{if(typeof i!="string")throw new TypeError("Expected input to be a string");if(i==="")return{isMatch:!1,output:""};const h=u||{},$=h.format||(l?s.toPosixSlashes:null);let g=i===y,b=g&&$?$(i):i;return g===!1&&(b=$?$(i):i,g=b===y),(g===!1||h.capture===!0)&&(h.matchBase===!0||h.basename===!0?g=r.matchBase(i,c,u,l):g=c.exec(b)),{isMatch:!!g,match:g,output:b}},r.matchBase=(i,c,u,y=u&&u.windows)=>(c instanceof RegExp?c:r.makeRe(c,u)).test(s.basename(i,{windows:y})),r.isMatch=(i,c,u)=>r(c,u)(i),r.parse=(i,c)=>Array.isArray(i)?i.map(u=>r.parse(u,c)):e(i,{...c,fastpaths:!1}),r.scan=(i,c)=>t(i,c),r.compileRe=(i,c,u=!1,y=!1)=>{if(u===!0)return i.output;const l=c||{},h=l.contains?"":"^",$=l.contains?"":"$";let g=`${h}(?:${i.output})${$}`;i&&i.negated===!0&&(g=`^(?!${g}).*$`);const b=r.toRegex(g,c);return y===!0&&(b.state=i),b},r.makeRe=(i,c={},u=!1,y=!1)=>{if(!i||typeof i!="string")throw new TypeError("Expected a non-empty string");let l={negated:!1,fastpaths:!0};return c.fastpaths!==!1&&(i[0]==="."||i[0]==="*")&&(l.output=e.fastpaths(i,c)),l.output||(l=e(i,c)),r.compileRe(l,c,u,y)},r.toRegex=(i,c)=>{try{const u=c||{};return new RegExp(i,u.flags||(u.nocase?"i":""))}catch(u){if(c&&c.debug===!0)throw u;return/$^/}},r.constants=n,De=r,De}var Fe,ls;function uo(){if(ls)return Fe;ls=1;const t=co(),e=Ae();function s(n,o,r=!1){return o&&(o.windows===null||o.windows===void 0)&&(o={...o,windows:e.isWindows()}),t(n,o,r)}return Object.assign(s,t),Fe=s,Fe}var ao=uo();const yt=Ke(ao);let lo;const po=t=>(lo??=H(import.meta.url))(t),Wt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=t=>{if(typeof Wt<"u"&&Wt.versions&&Wt.versions.node){const[e,s]=Wt.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return Wt.getBuiltinModule(t)}return po(t)},ps=pe("fs"),fo={...ps,default:ps},{statSync:ho,stat:go,realpathSync:yo,realpath:mo,readdirSync:$o,readdir:bo}=pe("fs"),{sep:Gs,basename:vo,dirname:Ue,resolve:Us,normalize:wo,relative:So,posix:_t,isAbsolute:xo}=pe("path"),{fileURLToPath:Eo}=pe("url"),{createRequire:Ao}=pe("module");var fs=Ao(import.meta.url);function _o(t){let e=wo(t);return e.length>1&&e[e.length-1]===Gs&&(e=e.substring(0,e.length-1)),e}const To=/[\\/]/g;function qs(t,e){return t.replace(To,e)}const Ro=/^[a-z]:[\\/]$/i;function ko(t){return t==="/"||Ro.test(t)}function He(t,e){const{resolvePaths:s,normalizePath:n,pathSeparator:o}=e,r=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(s&&(t=Us(t)),(n||r)&&(t=_o(t)),t===".")return"";const i=t[t.length-1]!==o;return qs(i?t+o:t,o)}function zs(t,e){return e+t}function Co(t,e){return function(s,n){return n.startsWith(t)?n.slice(t.length)+s:qs(So(t,n),e.pathSeparator)+e.pathSeparator+s}}function Oo(t){return t}function No(t,e,s){return e+t+s}function Lo(t,e){const{relativePaths:s,includeBasePath:n}=e;return s&&t?Co(t,e):n?zs:Oo}function Do(t){return function(e,s){s.push(e.substring(t.length)||".")}}function Fo(t){return function(e,s,n){const o=e.substring(t.length)||".";n.every(r=>r(o,!0))&&s.push(o)}}const Ho=(t,e)=>{e.push(t||".")},Io=(t,e,s)=>{const n=t||".";s.every(o=>o(n,!0))&&e.push(n)},Bo=()=>{};function Mo(t,e){const{includeDirs:s,filters:n,relativePaths:o}=e;return s?o?n&&n.length?Fo(t):Do(t):n&&n.length?Io:Ho:Bo}const Po=(t,e,s,n)=>{n.every(o=>o(t,!1))&&s.files++},jo=(t,e,s,n)=>{n.every(o=>o(t,!1))&&e.push(t)},Go=(t,e,s,n)=>{s.files++},Uo=(t,e)=>{e.push(t)},qo=()=>{};function zo(t){const{excludeFiles:e,filters:s,onlyCounts:n}=t;return e?qo:s&&s.length?n?Po:jo:n?Go:Uo}const Wo=t=>t,Xo=()=>[""].slice(0,0);function Ko(t){return t.group?Xo:Wo}const Qo=(t,e,s)=>{t.push({directory:e,files:s,dir:e})},Vo=()=>{};function Yo(t){return t.group?Qo:Vo}const Zo=function(t,e,s){const{queue:n,fs:o,options:{suppressErrors:r}}=e;n.enqueue(),o.realpath(t,(i,c)=>{if(i)return n.dequeue(r?null:i,e);o.stat(c,(u,y)=>{if(u)return n.dequeue(r?null:u,e);if(y.isDirectory()&&Ws(t,c,e))return n.dequeue(null,e);s(y,c),n.dequeue(null,e)})})},Jo=function(t,e,s){const{queue:n,fs:o,options:{suppressErrors:r}}=e;n.enqueue();try{const i=o.realpathSync(t),c=o.statSync(i);if(c.isDirectory()&&Ws(t,i,e))return;s(c,i)}catch(i){if(!r)throw i}};function ti(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?Jo:Zo}function Ws(t,e,s){if(s.options.useRealPaths)return ei(e,s);let n=Ue(t),o=1;for(;n!==s.root&&o<2;){const r=s.symlinks.get(n);r&&(r===e||r.startsWith(e)||e.startsWith(r))?o++:n=Ue(n)}return s.symlinks.set(t,e),o>1}function ei(t,e){return e.visited.includes(t+e.options.pathSeparator)}const si=t=>t.counts,ni=t=>t.groups,ri=t=>t.paths,oi=t=>t.paths.slice(0,t.options.maxFiles),ii=(t,e,s)=>(_e(e,s,t.counts,t.options.suppressErrors),null),ci=(t,e,s)=>(_e(e,s,t.paths,t.options.suppressErrors),null),ui=(t,e,s)=>(_e(e,s,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),ai=(t,e,s)=>(_e(e,s,t.groups,t.options.suppressErrors),null);function _e(t,e,s,n){e(t&&!n?t:null,s)}function li(t,e){const{onlyCounts:s,group:n,maxFiles:o}=t;return s?e?si:ii:n?e?ni:ai:o?e?oi:ui:e?ri:ci}const Xs={withFileTypes:!0},pi=(t,e,s,n,o)=>{if(t.queue.enqueue(),n<0)return t.queue.dequeue(null,t);const{fs:r}=t;t.visited.push(e),t.counts.directories++,r.readdir(e||".",Xs,(i,c=[])=>{o(c,s,n),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},fi=(t,e,s,n,o)=>{const{fs:r}=t;if(n<0)return;t.visited.push(e),t.counts.directories++;let i=[];try{i=r.readdirSync(e||".",Xs)}catch(c){if(!t.options.suppressErrors)throw c}o(i,s,n)};function hi(t){return t?fi:pi}var di=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},gi=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},yi=class{aborted=!1;abort(){this.aborted=!0}},Ks=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,s,n){this.isSynchronous=!n,this.callbackInvoker=li(s,this.isSynchronous),this.root=He(e,s),this.state={root:ko(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new gi,options:s,queue:new di((o,r)=>this.callbackInvoker(r,o,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new yi,fs:s.fs||fo},this.joinPath=Lo(this.root,s),this.pushDirectory=Mo(this.root,s),this.pushFile=zo(s),this.getArray=Ko(s),this.groupFiles=Yo(s),this.resolveSymlink=ti(s,this.isSynchronous),this.walkDirectory=hi(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,s,n)=>{const{paths:o,options:{filters:r,resolveSymlinks:i,excludeSymlinks:c,exclude:u,maxFiles:y,signal:l,useRealPaths:h,pathSeparator:$},controller:g}=this.state;if(g.aborted||l&&l.aborted||y&&o.length>y)return;const b=this.getArray(this.state.paths);for(let E=0;E<e.length;++E){const R=e[E];if(R.isFile()||R.isSymbolicLink()&&!i&&!c){const C=this.joinPath(R.name,s);this.pushFile(C,b,this.state.counts,r)}else if(R.isDirectory()){let C=No(R.name,s,this.state.options.pathSeparator);if(u&&u(R.name,C))continue;this.pushDirectory(C,o,r),this.walkDirectory(this.state,C,C,n-1,this.walk)}else if(this.resolveSymlink&&R.isSymbolicLink()){let C=zs(R.name,s);this.resolveSymlink(C,this.state,(D,m)=>{if(D.isDirectory()){if(m=He(m,this.state.options),u&&u(R.name,h?m:C+$))return;this.walkDirectory(this.state,m,h?m:C+$,n-1,this.walk)}else{m=h?m:C;const v=vo(m),a=He(Ue(m),this.state.options);m=this.joinPath(v,a),this.pushFile(m,b,this.state.counts,r)}})}}this.groupFiles(this.state.groups,s,b)}};function mi(t,e){return new Promise((s,n)=>{Qs(t,e,(o,r)=>{if(o)return n(o);s(r)})})}function Qs(t,e,s){new Ks(t,e,s).start()}function $i(t,e){return new Ks(t,e).start()}var hs=class{constructor(e,s){this.root=e,this.options=s}withPromise(){return mi(this.root,this.options)}withCallback(e){Qs(this.root,this.options,e)}sync(){return $i(this.root,this.options)}};let Vs=null;try{fs.resolve("picomatch"),Vs=fs("picomatch")}catch{}var bi=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:Gs,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new hs(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new hs(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){const s=this.globFunction||Vs;if(!s)throw new Error("Please specify a glob function to use glob matching.");var n=this.globCache[t.join("\0")];return n||(n=s(t,...e),this.globCache[t.join("\0")]=n),this.options.filters.push(o=>n(o)),this}};const vi=Array.isArray,Ys=/\\/g,wi=/^[A-Za-z]:$/,Zs=process.platform==="win32",Si=/^(\/?\.\.)+$/;function ds(t,e={}){const s=t.length,n=Array(s),o=Array(s);let r,i;for(r=0;r<s;r++){const c=Js(t[r]);n[r]=c;const u=c.length,y=Array(u);for(i=0;i<u;i++)y[i]=yt(c[i],e);o[r]=y}return c=>{const u=c.split("/");if(u[0]===".."&&Si.test(c))return!0;for(r=0;r<s;r++){const y=n[r],l=o[r],h=u.length,$=Math.min(h,y.length);for(i=0;i<$;){const g=y[i];if(g.includes("/"))return!0;if(!l[i](u[i]))break;if(!e.noglobstar&&g==="**")return!0;i++}if(i===h)return!0}return!1}}const xi=/^[A-Z]:\/$/i,Ei=Zs?t=>xi.test(t):t=>t==="/";function gs(t,e,s){if(t===e||e.startsWith(`${t}/`)){if(s){const o=t.length+ +!Ei(t);return(r,i)=>r.slice(o,i?-1:void 0)||"."}const n=e.slice(t.length+1);return n?(o,r)=>{if(o===".")return n;const i=`${n}/${o}`;return r?i.slice(0,-1):i}:(o,r)=>r&&o!=="."?o.slice(0,-1):o}return s?n=>_t.relative(t,n)||".":n=>_t.relative(t,`${e}/${n}`)||"."}function Ai(t,e){if(e.startsWith(`${t}/`)){const s=e.slice(t.length+1);return n=>`${s}/${n}`}return s=>{const n=_t.relative(t,`${e}/${s}`);return s[s.length-1]==="/"&&n!==""?`${n}/`:n||"."}}function ys(t){return t.replace(wi,e=>`${e}/`)}const _i={parts:!0};function Js(t){var e;const s=yt.scan(t,_i);return!((e=s.parts)===null||e===void 0)&&e.length?s.parts:[t]}const Ti=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Ri=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,ki=t=>t.replace(Ti,"\\$&"),Ci=t=>t.replace(Ri,"\\$&"),Oi=Zs?Ci:ki;function Ni(t,e){const s=yt.scan(t);return s.isGlob||s.negated}function ue(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function tn(t){return typeof t=="string"?[t]:t??[]}const Li=/^(\/?\.\.)+/,Di=/\\(?=[()[\]{}!*+?@|])/g;function Ie(t,e,s,n){var o;const r=e.cwd;let i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1));const c=i.lastIndexOf("/"),u=(c===-1?i:i.slice(c+1)).startsWith("!(");i[i.length-1]!=="*"&&!u&&e.expandDirectories&&(i+="/**");const y=Oi(r);i=xo(i.replace(Di,""))?_t.relative(y,i):_t.normalize(i);const l=(o=Li.exec(i))===null||o===void 0?void 0:o[0],h=Js(i);if(l){const g=(l.length+1)/3;let b=0;const E=y.split("/");for(;b<g&&h[b+g]===E[E.length+b-g];)i=i.slice(0,(g-b-1)*3)+i.slice((g-b)*3+h[b+g].length+1)||".",b++;const R=_t.join(r,l.slice(b*3));R[0]!=="."&&s.root.length>R.length&&(s.root=ys(R),s.depthOffset=-g+b)}if(!n&&s.depthOffset>=0){var $;($=s.commonPath)!==null&&$!==void 0||(s.commonPath=h);const g=[],b=Math.min(s.commonPath.length,h.length);for(let E=0;E<b;E++){const R=h[E];if(R==="**"&&!h[E+1]){g.pop();break}if(E===h.length-1||R!==s.commonPath[E]||Ni(R))break;g.push(R)}s.depthOffset=g.length,s.commonPath=g,s.root=ys(g.length>0?_t.join(r,...g):r)}return i}function Fi(t,e,s){const n=[],o=[],r=[];for(const i of t.ignore)i&&(i[0]!=="!"||i[1]==="("?o.push(Ie(i,t,s,!0)):r.push(i.slice(1)));for(const i of e)i&&(i[0]!=="!"||i[1]==="("?n.push(Ie(i,t,s,!1)):(i[1]!=="!"||i[2]==="(")&&o.push(Ie(i.slice(1),t,s,!0)));return{match:n,ignore:o,unignore:r}}function Hi(t,e){const s=t.cwd,n={root:s,depthOffset:0},o=Fi(t,e,n);t.debug&&ue("internal processing patterns:",o);const{absolute:r,caseSensitiveMatch:i,debug:c,dot:u,followSymbolicLinks:y,onlyDirectories:l}=t,h=n.root.replace(Ys,""),$={dot:u,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},g=o.unignore.length>0,b=g?yt(o.unignore,$):void 0,E=g?ds(o.unignore,$):void 0,R=yt(o.match,{...$,ignore:o.ignore,onIgnore:b?T=>b(T.output)&&yt.constants.UNIGNORE:void 0}),C=yt(o.ignore,$),D=ds(o.match,$),m=gs(s,h,r),v=r?m:gs(s,h,!0),a=o.match.length>0&&o.match.every(T=>T==="**"||T==="**/*"),A=o.ignore.length>0||g||!a?(T,x)=>{const B=v(x,!0);return B==="."||E&&E(B)?!1:!D(B)||C(B)}:void 0;let O;t.deep!==void 0&&(O=Math.round(t.deep-n.depthOffset));const _=new bi({filters:[c?(T,x)=>{const B=m(T,x),U=R(B);return U&&ue(`matched ${B}`),U}:(T,x)=>{const B=m(T,x);return R(B)}],exclude:c&&A?(T,x)=>{const B=A(T,x);return ue(`${B?"skipped":"crawling"} ${x}`),B}:A,fs:t.fs,pathSeparator:"/",relativePaths:!r,resolvePaths:r,includeBasePath:r,resolveSymlinks:y,excludeSymlinks:!y,excludeFiles:l,includeDirs:l||!t.onlyFiles,maxDepth:O,signal:t.signal}).crawl(h);return t.debug&&ue("internal properties:",{...n,root:h}),[_,s!==h&&!r&&Ai(s,h)]}function en(t,e){if(e)for(let s=t.length-1;s>=0;s--)t[s]=e(t[s]);return t}const ms={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Ii(t){const e=Object.assign({},t);for(const s in ms)e[s]===void 0&&Object.assign(e,{[s]:ms[s]});return e.cwd=(e.cwd instanceof URL?Eo(e.cwd):Us(e.cwd||process.cwd())).replace(Ys,"/"),e.ignore=tn(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||bo,readdirSync:e.fs.readdirSync||$o,realpath:e.fs.realpath||mo,realpathSync:e.fs.realpathSync||yo,stat:e.fs.stat||go,statSync:e.fs.statSync||ho}),e.debug&&ue("globbing with options:",e),e}function sn(t,e={}){var s;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");const n=vi(t)||typeof t=="string",o=tn((s=n?t:t.patterns)!==null&&s!==void 0?s:"**/*"),r=Ii(n?e:t);return o.length>0?Hi(r,o):[]}async function Bi(t,e){const[s,n]=sn(t,e);return s?en(await s.withPromise(),n):[]}function Mi(t,e){const[s,n]=sn(t,e);return s?en(s.sync(),n):[]}const ja=async(t,e)=>await Bi(t,e),Ga=(t,e)=>Mi(t,e);var Be,$s;function Pi(){if($s)return Be;$s=1;/*!
4
4
  * is-extglob <https://github.com/jonschlinkert/is-extglob>
@@ -1 +1 @@
1
- import e from"./MailMessage-DmmaNHHc.js";class t extends e{constructor(){super(),this.header("X-Unsent","1")}}export{t as default};
1
+ import e from"./MailMessage-Aw0vVAh-.js";class t extends e{constructor(){super(),this.header("X-Unsent","1")}}export{t as default};
@@ -0,0 +1 @@
1
+ import f from"./DraftMailMessage-zkKTOxQ8.js";import v from"./EmailError-SXEFQEyA.js";import u from"./MailMessage-Aw0vVAh-.js";import{composeMiddleware as w}from"./composeMiddleware-B3RCDFsy.js";import{b as C}from"./build-mime-message-D45WdgfP.js";import{c as M}from"./create-logger-CazqtXcL.js";import{h as d}from"./headers-to-record-ZOZ7Dubo.js";import T from"../utils/validation/check-feature-support.js";const S=(a,e,r)=>{e.success&&e.data?a&&a.info("Email sent successfully",{messageId:e.data.messageId,provider:e.data.provider}):a&&a.error("Email send failed",{error:e.error,provider:r})},E=async(a,e,r)=>{const t={...a,to:e.to};return delete t.idempotencyKey,e.cc&&(t.cc=e.cc),e.bcc&&(t.bcc=e.bcc),e.replyTo&&(t.replyTo=e.replyTo),e.headers&&(t.headers={...d(a.headers??{}),...d(e.headers)}),t.subject=e.subject??a.subject,r&&e.data&&(t.subject=await r(t.subject,e.data),a.html!==void 0&&(t.html=await r(a.html,e.data)),a.text!==void 0&&(t.text=await r(a.text,e.data))),t};class h{static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;middlewares=[];composedSend;mountedProviders=new Map;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=M("Mail",e),this}use(e){return this.middlewares.push(e),this.composedSend=void 0,this}mount(e,r){return this.mountedProviders.set(e,r),this}setFrom(e){return this.globalConfig??={},this.globalConfig.from=e,this.logger&&this.logger.debug("Default from address updated",{from:e.email}),this}setReplyTo(e){return this.globalConfig??={},this.globalConfig.replyTo=e,this.logger&&this.logger.debug("Default reply-to address updated",{replyTo:e.email}),this}setHeaders(e){if(this.globalConfig??={},this.globalConfig.headers=e,this.logger){const r=d(e);this.logger.debug("Default headers updated",{count:Object.keys(r).length,headers:Object.keys(r)})}return this}async draft(e){let r=e instanceof u||e instanceof f?await this.buildDraftFromMessage(e):await this.buildDraftFromOptions(e);r=this.applyGlobalConfig(r);const t=r.headers?d(r.headers):{};r.headers={...t,"X-Unsent":"1"};const s=await C(r,{includeBcc:!0});return this.logger&&this.logger.debug("Draft created successfully in EML format",{from:r.from.email,size:s.length,subject:r.subject,to:Array.isArray(r.to)?r.to.length:1}),s}async send(e){if(e instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");let r;if(e instanceof u)this.logger&&this.logger.debug("Sending MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),r=await e.build();else{const o=e;this.logger&&this.logger.debug("Sending email with options",{subject:o.subject,to:Array.isArray(o.to)?o.to.length:1}),r=o}r=this.applyGlobalConfig(r);const t=this.assertFeatureSupport(r,this.resolveProvider(r));if(t)return{error:t,success:!1};const s=await this.dispatch(r);return S(this.logger,s,this.provider.name??"unknown"),s}sendMany(e,r){const t=Math.max(1,Math.floor(r?.concurrency??1));return t===1?this.sendManySerial(e,r?.signal):this.sendManyConcurrent(e,t,r?.signal)}sendBatch(e,r,t){const s=async function*(){const o=e instanceof u?await e.build():e;for(const i of r)yield await E(o,i,t?.render)};return this.sendMany(s(),{concurrency:t?.concurrency,signal:t?.signal})}async sendOneToReceipt(e){const r=this.provider.name;try{const t=await this.send(e);return t.success&&t.data?{messageId:t.data.messageId,provider:t.data.provider??r,response:t.data.response,successful:!0,timestamp:t.data.timestamp}:{errorMessages:h.extractErrorMessages(t.error),provider:r,successful:!1}}catch(t){return{errorMessages:h.extractErrorMessages(t),provider:r,successful:!1}}}async*sendManySerial(e,r){const t=this.provider.name;let s=0,o=0,i=0;this.logger&&this.logger.debug("Starting batch email send",{provider:t});for await(const l of e){if(l instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");if(r?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:i,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;const n=await this.sendOneToReceipt(l);n.successful?o+=1:i+=1,yield n}this.logger&&this.logger.debug("Batch email send completed",{failureCount:i,processedCount:s,provider:t,successCount:o})}async*sendManyConcurrent(e,r,t){const s=this.provider.name;this.logger&&this.logger.debug("Starting concurrent batch email send",{concurrency:r,provider:s});const o=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator](),i=new Map;let l=0,n=!1,p=!1;const m=async()=>{for(;!n&&!p&&i.size<r;){const g=await o.next();if(g.done){n=!0;break}const c=g.value;if(c instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");const b=l;l+=1,i.set(b,this.sendOneToReceipt(c).then(y=>({id:b,receipt:y})))}};for(await m();i.size>0;){if(t?.aborted){p=!0,yield{errorMessages:["Send operation was aborted"],provider:s,successful:!1};return}const{id:g,receipt:c}=await Promise.race(i.values());i.delete(g),yield c,await m()}this.logger&&this.logger.debug("Concurrent batch email send completed",{processedCount:l,provider:s})}async dispatch(e){return this.middlewares.length===0?await this.resolveProvider(e).sendEmail(e):(this.composedSend??=w(this.middlewares,r=>Promise.resolve(this.resolveProvider(r).sendEmail(r))),await this.composedSend(e))}resolveProvider(e){return e.stream!==void 0?this.mountedProviders.get(e.stream)??this.provider:this.provider}assertFeatureSupport(e,r){if(this.featureCheck==="off")return;const{supported:t,violations:s}=T(e,r.features);if(t)return;const o=r.name??"unknown",i=s.map(n=>n.field),l=s.map(n=>n.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:i,provider:o});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:i,provider:o}),new v(o,`Provider does not support the following message fields: ${i.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:l})}async buildDraftFromMessage(e){return this.logger&&this.logger.debug("Creating draft from MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),this.applyGlobalConfigToMessage(e),await e.build()}async buildDraftFromOptions(e){return this.logger&&this.logger.debug("Creating draft from email options",{subject:e.subject,to:Array.isArray(e.to)?e.to.length:1}),e}applyGlobalConfigToMessage(e){const r=this.globalConfig?.from;r&&!e.getFrom()&&e.from(r);const t=this.globalConfig?.replyTo;if(t&&!e.getReplyTo()&&e.replyTo(t),this.globalConfig?.headers){const s=d(this.globalConfig.headers);Object.entries(s).forEach(([o,i])=>{e.header(o,i)})}}applyGlobalConfig(e){if(!this.globalConfig)return e;const r={...e};if(!r.from&&this.globalConfig.from&&(r.from=this.globalConfig.from,this.logger&&this.logger.debug("Applied global from address",{from:this.globalConfig.from.email})),!r.replyTo&&this.globalConfig.replyTo&&(r.replyTo=this.globalConfig.replyTo,this.logger&&this.logger.debug("Applied global reply-to address",{replyTo:this.globalConfig.replyTo.email})),this.globalConfig.headers){const t=d(this.globalConfig.headers),s=r.headers?d(r.headers):{};r.headers={...t,...s},this.logger&&this.logger.debug("Merged global headers",{globalCount:Object.keys(t).length,messageCount:Object.keys(s).length})}return r}}const O=(a,e)=>new h(a,e);export{h as Mail,O as createMail};
@@ -0,0 +1 @@
1
+ import{createRequire as y}from"node:module";import{readFileAsBuffer as c,detectMimeType as d,generateContentId as u}from"./detectMimeType-BRz3Qjyz.js";import{c as T}from"./create-logger-CazqtXcL.js";import{h as l}from"./headers-to-record-ZOZ7Dubo.js";let p;const A=n=>(p??=y(import.meta.url))(n),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=n=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,e]=o.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return o.getBuiltinModule(n)}return A(n)},{basename:g}=f("node:path"),{fileURLToPath:b}=f("node:url"),m=async()=>(await import("../template-engines/html-to-text.js")).default,x=async()=>(await import("ical-generator")).default,a=n=>Array.isArray(n)?n.map(t=>typeof t=="string"?{email:t}:t):typeof n=="string"?[{email:n}]:[n];class D{fromAddress;toAddresses=[];ccAddresses=[];bccAddresses=[];subjectText="";textContent;textCharset="utf8";autoTextEnabled=!0;htmlContent;htmlCharset="utf8";dateValue;returnPathAddress;senderAddress;headers={};attachments=[];replyToAddress;priorityValue;tagsValue=[];idempotencyKeyValue;signer;encrypter;logger;icalEventData;icalEventBuilder;from(t){return this.fromAddress=typeof t=="string"?{email:t}:t,this}to(t){return this.toAddresses.length=0,this.toAddresses.push(...a(t)),this}cc(t){return this.ccAddresses.length=0,this.ccAddresses.push(...a(t)),this}bcc(t){return this.bccAddresses.length=0,this.bccAddresses.push(...a(t)),this}subject(t){return this.subjectText=t,this}text(t,e="utf8"){return this.textContent=t,this.textCharset=e,this}html(t,e="utf8"){return this.htmlContent=t,this.htmlCharset=e,this}header(t,e){return this.headers[t]=e,this}setHeaders(t){const e=l(t);return Object.assign(this.headers,e),this}async attachFromPath(t,e){try{const s=await c(t),i=e?.filename??(g(t)||"attachment"),r=e?.contentType??d(i);this.attachments.push({cid:e?.cid,content:s,contentDisposition:e?.contentDisposition??"attachment",contentType:r,encoding:e?.encoding,filename:i,headers:e?.headers}),this.logger&&this.logger.debug(`Attachment added from path: ${t}`,{contentType:r,filename:i})}catch(s){throw this.logger&&this.logger.error(`Failed to attach file from path: ${t}`,s),s}return this}attachData(t,e){const s=e.contentType??d(e.filename);return this.attachments.push({cid:e.cid,content:t,contentDisposition:e.contentDisposition??"attachment",contentType:s,encoding:e.encoding,filename:e.filename,headers:e.headers}),this.logger&&this.logger.debug("Attachment added from data",{contentType:s,filename:e.filename}),this}async embedFromPath(t,e){try{const s=await c(t),i=e?.filename??(g(t)||"inline"),r=e?.contentType??d(i),h=u(i);return this.attachments.push({cid:h,content:s,contentDisposition:"inline",contentType:r,filename:i}),this.logger&&this.logger.debug(`Inline attachment embedded from path: ${t}`,{cid:h,contentType:r,filename:i}),h}catch(s){throw this.logger&&this.logger.error(`Failed to embed file from path: ${t}`,s),s}}embedData(t,e,s){const i=s?.contentType??d(e),r=u(e);return this.attachments.push({cid:r,content:t,contentDisposition:"inline",contentType:i,filename:e}),this.logger&&this.logger.debug("Inline attachment embedded from data",{cid:r,contentType:i,filename:e}),r}replyTo(t){return this.replyToAddress=typeof t=="string"?{email:t}:t,this}date(t){return this.dateValue=typeof t=="string"?new Date(t):t,this.logger&&this.logger.debug("Date header set",{date:this.dateValue.toISOString()}),this}returnPath(t){return this.returnPathAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Return-path address set",{returnPath:this.returnPathAddress.email}),this}sender(t){return this.senderAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Sender address set",{sender:this.senderAddress.email}),this}addTo(t){return this.toAddresses.push(...a(t)),this}addCc(t){return this.ccAddresses.push(...a(t)),this}addBcc(t){return this.bccAddresses.push(...a(t)),this}addReplyTo(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const s=e[0];this.replyToAddress=typeof s=="string"?{email:s}:s}return this}addFrom(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const s=e[0];this.fromAddress=typeof s=="string"?{email:s}:s}return this}priority(t){return this.priorityValue=t,this}tags(t){return this.tagsValue=Array.isArray(t)?t:[t],this}idempotencyKey(t){return this.idempotencyKeyValue=t,this}sign(t){return this.signer=t,this.logger&&this.logger.debug("Email signer configured"),this}encrypt(t){return this.encrypter=t,this.logger&&this.logger.debug("Email encrypter configured"),this}setLogger(t){return this.logger=T("MailMessage",t),this}icalEvent(t,e){return typeof t=="function"?(this.icalEventBuilder={build:t,options:e},this.icalEventData=void 0):(this.icalEventBuilder=void 0,this.icalEventData={content:t,...e}),this.logger&&this.logger.debug("Calendar event attached",{method:e?.method}),this}icalEventFromFile(t,e){const s=typeof t=="string"?t:b(t);return this.icalEventData={path:s,...e},this.logger&&this.logger.debug(`Calendar event attached from file: ${s}`,{method:e?.method}),this}icalEventFromUrl(t,e){return this.icalEventData={href:t,...e},this.logger&&this.logger.debug(`Calendar event attached from URL: ${t}`,{method:e?.method}),this}async view(t,e,s,i){try{const r=i?.autoText!==!1;this.autoTextEnabled=r,this.logger&&this.logger.debug("Rendering template",{autoText:r});const h=await t(e,s,i);this.html(h),r&&h&&await this.tryAutoGenerateText(h),this.logger&&this.logger.debug("Template rendered successfully")}catch(r){throw this.logger&&this.logger.error("Failed to render template",r),new Error(`Failed to render template: ${r.message}`)}return this}async viewText(t,e,s,i){try{this.logger&&this.logger.debug("Rendering text template");const r=await t(e,s,i);if(typeof r=="string")this.text(r),this.logger&&this.logger.debug("Text template rendered successfully");else throw new TypeError("Text renderer must return a string")}catch(r){throw this.logger&&this.logger.error("Failed to render text template",r),new Error(`Failed to render text template: ${r.message}`)}return this}async build(){if(this.logger&&this.logger.debug("Building email message"),this.fromAddress||this.throwAndLogError("From address is required","Build failed: from address is required"),this.toAddresses.length===0&&this.throwAndLogError("At least one recipient is required","Build failed: at least one recipient is required"),this.subjectText||this.throwAndLogError("Subject is required","Build failed: subject is required"),this.htmlContent&&!this.textContent&&this.autoTextEnabled)try{const e=await m();this.textContent=e(this.htmlContent),this.logger&&this.logger.debug("Auto-generated text content from HTML")}catch{this.logger&&this.logger.debug("Failed to convert HTML to text; proceeding without text content.")}!this.textContent&&!this.htmlContent&&this.throwAndLogError("Either text or html content is required","Build failed: either text or html content is required");let t={from:this.fromAddress,html:this.htmlContent,subject:this.subjectText,text:this.textContent,to:this.toAddresses.length===1?this.toAddresses[0]:this.toAddresses};if(this.ccAddresses.length>0&&(t.cc=this.ccAddresses.length===1?this.ccAddresses[0]:this.ccAddresses),this.bccAddresses.length>0&&(t.bcc=this.bccAddresses.length===1?this.bccAddresses[0]:this.bccAddresses),Object.keys(this.headers).length>0&&(t.headers=this.headers),this.attachments.length>0&&(t.attachments=this.attachments,this.logger&&this.logger.debug(`Email includes ${this.attachments.length} attachment(s)`)),this.replyToAddress&&(t.replyTo=this.replyToAddress),this.priorityValue&&(t.priority=this.priorityValue),this.tagsValue.length>0&&(t.tags=this.tagsValue),this.idempotencyKeyValue!==void 0&&(t.idempotencyKey=this.idempotencyKeyValue),this.icalEventBuilder){const s=(await x())();this.icalEventBuilder.build(s),this.icalEventData={content:s.toString(),...this.icalEventBuilder.options}}return this.icalEventData&&(t.icalEvent=this.icalEventData,this.logger&&this.logger.debug("Email includes calendar event")),this.dateValue&&(t.headers={...l(t.headers??{}),Date:this.dateValue.toUTCString()}),this.returnPathAddress&&(t.headers={...l(t.headers??{}),"Return-Path":this.returnPathAddress.email}),this.senderAddress&&(t.headers={...l(t.headers??{}),Sender:this.senderAddress.email}),this.signer&&(this.logger&&this.logger.debug("Signing email message"),t=await this.signer.sign(t),this.logger&&this.logger.debug("Email message signed successfully")),this.encrypter&&(this.logger&&this.logger.debug("Encrypting email message"),t=await this.encrypter.encrypt(t),this.logger&&this.logger.debug("Email message encrypted successfully")),this.logger&&this.logger.debug("Email message built successfully",{bcc:this.bccAddresses.length,cc:this.ccAddresses.length,hasHtml:!!this.htmlContent,hasText:!!this.textContent,to:this.toAddresses.length}),t}getSubject(){return this.subjectText}getFrom(){return this.fromAddress}getTo(){return[...this.toAddresses]}getCc(){return[...this.ccAddresses]}getBcc(){return[...this.bccAddresses]}getReplyTo(){return this.replyToAddress}getSender(){return this.senderAddress}getReturnPath(){return this.returnPathAddress}getDate(){return this.dateValue}getPriority(){return this.priorityValue}getTextBody(){return this.textContent}getTextCharset(){return this.textCharset}getHtmlBody(){return this.htmlContent}getHtmlCharset(){return this.htmlCharset}getAttachments(){return[...this.attachments]}async tryAutoGenerateText(t){try{const s=(await m())(t);s&&!this.textContent&&this.text(s),this.logger&&this.logger.debug("Auto-generated text content from HTML template")}catch(e){this.logger&&this.logger.warn("Failed to auto-generate text from HTML template",e)}}throwAndLogError(t,e){const s=new Error(t);throw this.logger&&this.logger.error(e??t),s}}export{D as default};
@@ -1 +1 @@
1
- import{createMail as d}from"./Mail-0cxS6jre.js";import w from"./mockProvider-DVtl5Jjy.js";const l=(t,o,e,n)=>{const r=Date.now()+e;return new Promise((i,s)=>{const a=()=>{const c=t.find(m=>o(m));if(c){i(c);return}if(Date.now()>=r){s(new Error("waitFor timed out before a matching message was captured"));return}setTimeout(a,n)};a()})},h=()=>{const t=w(),o=d(t),e=t.getInstance?.();if(!e)throw new Error("mockProvider() did not expose getInstance(); cannot create a test harness");return{mail:o,reset:()=>{e.length=0},sent:()=>e,waitFor:(n,r={})=>l(e,n,r.timeout??1e3,r.interval??10)}};export{h as createTestEmail};
1
+ import{createMail as d}from"./Mail-DtpXUSIl.js";import w from"./mockProvider-DVtl5Jjy.js";const l=(t,o,e,n)=>{const r=Date.now()+e;return new Promise((i,s)=>{const a=()=>{const c=t.find(m=>o(m));if(c){i(c);return}if(Date.now()>=r){s(new Error("waitFor timed out before a matching message was captured"));return}setTimeout(a,n)};a()})},h=()=>{const t=w(),o=d(t),e=t.getInstance?.();if(!e)throw new Error("mockProvider() did not expose getInstance(); cannot create a test harness");return{mail:o,reset:()=>{e.length=0},sent:()=>e,waitFor:(n,r={})=>l(e,n,r.timeout??1e3,r.interval??10)}};export{h as createTestEmail};
@@ -1,10 +1,10 @@
1
1
  import { ICalCalendar } from 'ical-generator';
2
2
  import { Buffer as Buffer$1 } from 'node:buffer';
3
3
  import { T as TemplateRenderer } from "./types.d-I-KeZ5w2.js";
4
- import { c as EmailAddress, e as EmailHeaders, P as Priority, C as CalendarEventOptions, E as EmailOptions, A as Attachment, M as MaybePromise, a as EmailResult, R as Result, b as Receipt } from "./types.d-B9295M4_.js";
5
- import { b as EmailSigner, E as EmailEncrypter } from "./types.d-Cb5fls_X.js";
6
- import { M as Middleware } from "./types.d-GKqPNk0I.js";
7
- import { a as Provider } from "./provider.d-Cx5YQJdP.js";
4
+ import { c as EmailAddress, e as EmailHeaders, P as Priority, C as CalendarEventOptions, E as EmailOptions, A as Attachment, M as MaybePromise, a as EmailResult, R as Result, b as Receipt } from "./types.d-CyiC9uRC.js";
5
+ import { b as EmailSigner, E as EmailEncrypter } from "./types.d-A1Eea-p_.js";
6
+ import { M as Middleware } from "./types.d-Chhzb-48.js";
7
+ import { a as Provider } from "./provider.d-BLLbEuQ8.js";
8
8
  /**
9
9
  * Detects MIME type from filename using mime package.
10
10
  * Falls back to application/octet-stream if not found.
@@ -91,6 +91,7 @@ declare class MailMessage {
91
91
  private replyToAddress?;
92
92
  private priorityValue?;
93
93
  private tagsValue;
94
+ private idempotencyKeyValue?;
94
95
  private signer?;
95
96
  private encrypter?;
96
97
  private logger?;
@@ -276,6 +277,13 @@ declare class MailMessage {
276
277
  * @returns This instance for method chaining.
277
278
  */
278
279
  tags(tags: string | string[]): this;
280
+ /**
281
+ * Sets an idempotency key so the provider can drop a repeated send of the same message.
282
+ * Honoured only by providers that declare `features.idempotency`.
283
+ * @param key The caller-chosen key, unique per logical message.
284
+ * @returns This instance for method chaining.
285
+ */
286
+ idempotencyKey(key: string): this;
279
287
  /**
280
288
  * Signs the email message with an S/MIME signer.
281
289
  *
@@ -1,4 +1,4 @@
1
- import { E as EmailOptions, F as FeatureFlags, R as Result, M as MaybePromise, a as EmailResult } from "./types.d-B9295M4_.js";
1
+ import { E as EmailOptions, F as FeatureFlags, R as Result, M as MaybePromise, a as EmailResult } from "./types.d-CyiC9uRC.js";
2
2
  /**
3
3
  * Standard provider interface for email services.
4
4
  */
@@ -0,0 +1 @@
1
+ import d from"./EmailError-SXEFQEyA.js";import I from"./RequiredOptionError-C2wWqmiE.js";import{g as A}from"./generate-message-id-C5AM6DFE.js";import{h as w}from"./headers-to-record-ZOZ7Dubo.js";import{m as y}from"./make-request-mszP240P.js";import{r as g}from"./retry-ByPJFAtq.js";import{v as T}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{c as C,P as K,h as b}from"./provider-base-G22b4a87.js";import{e as $,g as v,d as E}from"./address-formatter-w36S9ZYj.js";import{p as R}from"./attachment-processor-AB1m-n9T.js";const s="resend",j="https://api.resend.com",S=3e4,_=3,k=/^[\u0021-\u007E]{1,256}$/,D=o=>{const r=[],c=/^[\w-]+$/;return c.test(o.name)||r.push(`Tag name '${o.name}' must only contain ASCII letters, numbers, underscores, or dashes`),o.name.length>256&&r.push(`Tag name '${o.name}' exceeds maximum length of 256 characters`),c.test(o.value)||r.push(`Tag value '${o.value}' for tag '${o.name}' must only contain ASCII letters, numbers, underscores, or dashes`),r},Y=P((o={})=>{if(!o.apiKey)throw new I(s,"apiKey");const r={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??j,logger:o.logger,retries:o.retries??_,timeout:o.timeout??S},c=new K,n=C(s,o.logger);return{endpoint:r.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,idempotency:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(s,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const t={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const a=await g(async()=>y(`${r.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:r.timeout}),r.retries);return a.success?(n.debug("Email details retrieved successfully"),{data:a.data?.body,success:!0}):(n.debug("API request failed when retrieving email",a.error),{error:new d(s,`Failed to retrieve email: ${a.error instanceof Error?a.error.message:"Unknown error"}`,{cause:a.error}),success:!1})}catch(t){return{error:b(s,"retrieve email",t,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(s,"Resend API not available or invalid API key");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{if(r.apiKey&&r.apiKey.startsWith("re_"))return n.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Checking Resend API availability");const t=await y(`${r.endpoint}/domains`,{headers:e,method:"GET",timeout:r.timeout});return t.data&&typeof t.data=="object"&&"body"in t.data&&t.data.body&&typeof t.data.body=="object"&&"name"in t.data.body&&t.data.body.name==="restricted_api_key"?(n.debug("API key is valid but restricted to only sending emails"),!0):(n.debug("Resend API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300))}catch(e){return n.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const t=T(e);if(t.length>0)return{error:new d(s,`Invalid email options: ${t.join(", ")}`),success:!1};if(e.idempotencyKey!==void 0&&(typeof e.idempotencyKey!="string"||!k.test(e.idempotencyKey)))return{error:new d(s,"Invalid idempotency key: must be 1-256 visible ASCII characters"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const a={from:v(e.from),headers:e.headers?w(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:$(e.to)};if(e.cc&&(a.cc=E(e.cc)),e.bcc&&(a.bcc=E(e.bcc)),e.replyTo&&(a.reply_to=v(e.replyTo)),e.templateId&&(a.template=e.templateId,e.templateData&&(a.data=e.templateData)),e.scheduledAt&&(a.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const i=[];if(e.tags.forEach(l=>{const p=D(l);p.length>0&&i.push(...p)}),i.length>0)return{error:new d(s,`Invalid email tags: ${i.join(", ")}`),success:!1};a.tags=e.tags.map(l=>({name:l.name,value:l.value}))}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async i=>({content:await R(i,s),content_type:i.contentType,filename:i.filename,...i.path&&{path:i.path}})))),n.debug("Sending email via Resend API",{subject:a.subject,to:a.to});const f={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};e.idempotencyKey!==void 0&&(f["Idempotency-Key"]=e.idempotencyKey);const u=await g(async()=>y(`${r.endpoint}/emails`,{headers:f,method:"POST",timeout:r.timeout},JSON.stringify(a)),r.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new d(s,"Failed to send email"),success:!1};const m=u.data,h=m?.body&&typeof m.body=="object"&&m.body.id?m.body.id:A();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:s,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:b(s,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Y as default};