├── .gitignore ├── assets ├── demo.mp4 └── demo.webm ├── file-and-email-delivery ├── package.json ├── index.js └── dist │ └── index.js ├── .github └── FUNDING.yml ├── download_url.html ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | */node_modules 2 | */*/node_modules 3 | package-lock.json 4 | .DS_Store 5 | *.zip -------------------------------------------------------------------------------- /assets/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mneveroff/stripe-link-file-delivery/HEAD/assets/demo.mp4 -------------------------------------------------------------------------------- /assets/demo.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mneveroff/stripe-link-file-delivery/HEAD/assets/demo.webm -------------------------------------------------------------------------------- /file-and-email-delivery/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "https": "^1.0.0", 5 | "stripe": "^14.20.0", 6 | "url": "^0.11.3" 7 | }, 8 | "devDependencies": { 9 | "esbuild": "^0.20.1" 10 | }, 11 | "scripts": { 12 | "build": "esbuild ./index.js --bundle --platform=node --external:@aws-sdk/s3-request-presigner --external:@aws-sdk/client-s3 --minify --outfile=./dist/index.js" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: MNeverOff 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username 14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 15 | -------------------------------------------------------------------------------- /download_url.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Mike Neverov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /file-and-email-delivery/index.js: -------------------------------------------------------------------------------- 1 | import HTTPS from 'https'; 2 | import URL from 'url'; 3 | import Stripe from 'stripe'; 4 | import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"; 5 | import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; 6 | 7 | // Specifying the IAM User with S3 access to generate long-lived Signed URLs 8 | const s3Client = new S3Client({ 9 | region: process.env.S3_REGION, 10 | credentials: { 11 | accessKeyId: process.env.S3_ACCESS_KEY_ID, 12 | secretAccessKey: process.env.S3_SECRET_ACCESS_KEY 13 | } 14 | }); 15 | 16 | async function request(url, data, headers, blocking) { 17 | return new Promise((resolve, reject) => { 18 | const options = { 19 | ...URL.parse(url), 20 | method: 'POST', 21 | headers: { 22 | ...headers, 23 | 'Content-Length': data.length 24 | } 25 | }; 26 | 27 | if (blocking) { 28 | let req = HTTPS.request(options, function (res) { 29 | let body = '' 30 | res.on('data', (chunk) => { body += chunk }) 31 | res.on('end', () => { resolve(body) }) 32 | }) 33 | req.write(data) 34 | req.end() 35 | } else { 36 | let req = HTTPS.request(options) 37 | req.write(data) 38 | req.end(null, null, () => { 39 | /* Request has been fully sent */ 40 | resolve(req) 41 | }); 42 | } 43 | }); 44 | } 45 | 46 | export const handler = async (event) => { 47 | const stripe = new Stripe(event.stageVariables.stripe_secret_api_key); 48 | 49 | if (!event.queryStringParameters) { 50 | return { 51 | statusCode: 400, 52 | body: 'Bad Request: No query parameters supplied.' 53 | }; 54 | } 55 | else if (!event.queryStringParameters.session_id) { 56 | return { 57 | statusCode: 400, 58 | body: 'Bad Request: Missing session_id query parameter.' 59 | }; 60 | } 61 | 62 | const session_id = event.queryStringParameters.session_id; 63 | let session; 64 | let chargeSucceeded = false; 65 | 66 | // A crude way to check if the charge has succeeded, retrying 20 times with a 250ms delay - so giving it 5 seconds to succeed 67 | // TODO: Improve. Add a redirect to "payment exception" page with contact for support. 68 | for (let i = 0; i < 20; i++) { 69 | try { 70 | session = await stripe.checkout.sessions.retrieve(session_id); 71 | if (session.payment_status === 'paid') { 72 | chargeSucceeded = true; 73 | console.log(`Charge succeeded for session id ${session_id} after ${i+1} attempts. Environment: ${event.stageVariables.environment}.`); 74 | break; 75 | } 76 | } catch (error) { 77 | console.error(`Failed to retrieve session: ${error.message} after ${i+1} attempts. Environment: ${event.stageVariables.environment}.`); 78 | return { 79 | statusCode: 400, 80 | body: `Payment exception. Contact ${process.env.support_email}.\nError Details: Failed to retrieve session: ${error.message} after ${i+1} attempts. Environment: ${event.stageVariables.environment}.` 81 | }; 82 | } 83 | await new Promise(resolve => setTimeout(resolve, 250)); 84 | } 85 | 86 | if (chargeSucceeded) { 87 | let recipientEmail = session?.customer_details?.email; 88 | 89 | if (!recipientEmail) { 90 | recipientEmail = process.env.fallback_email; 91 | } 92 | 93 | const command = new GetObjectCommand({ 94 | Bucket: process.env.bucket_name, 95 | Key: process.env.object_key 96 | }); 97 | 98 | const presignedUrl = await getSignedUrl(s3Client, command, { expiresIn: parseInt(process.env.link_expiration, 10) }); 99 | const redirectUrl = `${process.env.redirect_host}${encodeURIComponent(presignedUrl)}${process.env.utm_parameters}`; 100 | 101 | const emailBody = { 102 | templateId: parseInt(process.env.brevo_template_id, 10), 103 | to: [{ email: recipientEmail }], 104 | params: { download_url: redirectUrl } 105 | }; 106 | 107 | const url = 'https://api.sendinblue.com/v3/smtp/email'; 108 | const data = JSON.stringify(emailBody); 109 | const headers = { 110 | 'Content-Type': 'application/json', 111 | 'Accept': 'application/json', 112 | 'api-key': process.env.brevo_api_key 113 | }; 114 | 115 | if (process.env.email_mode === "ensure-delivery") { 116 | try { 117 | await request(url, data, headers, true); 118 | console.log(`Email was sent for session id ${session_id}.`); 119 | } catch (err) { 120 | console.log(`Failed to send email for session id ${session_id}.`, err); 121 | } 122 | } else { 123 | await request(url, data, headers, false) 124 | .then(() => { 125 | console.log(`Email request was sent for session id ${session_id}.`); 126 | }).catch(err => { 127 | console.log(`Failed to send email for session id ${session_id}.`, err); 128 | }); 129 | } 130 | 131 | console.log(`Redirecting to ${redirectUrl} in environment ${event.stageVariables.environment}.`); 132 | 133 | return { 134 | statusCode: 302, 135 | headers: { 136 | Location: redirectUrl 137 | }, 138 | body: '' 139 | }; 140 | } else { 141 | console.log(`Charge did not succeed for session id ${session_id}. Environment: ${event.stageVariables.environment}.`); 142 | return { 143 | statusCode: 400, 144 | body: `Payment exception. Contact ${process.env.support_email}.\nError Details: Charge did not succeed for session id ${session_id}. Environment: ${event.stageVariables.environment}.` 145 | }; 146 | } 147 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Cover Image](assets/cover.svg) 2 | 3 | This is a simple serverless application that uses AWS Lambda, Stripe and Brevo to deliver files to customers after they have made a payment via your Stripe Payment Link. 4 | 5 | Because KoFi and Gumroad may be nice, but why not manage your own payment links and have a straight-forward user experience? 6 | 7 | ## Demo 8 | 9 | [Expand to see the demo of the finished solution](https://github.com/MNeverOff/stripe-link-file-delivery/assets/3989091/b717a3f7-35aa-4f29-b1bd-4ae63b7ab526) 10 | 11 | 12 | ## In-depth guide 13 | 14 | You can read a detailed guide on setting this up in [my blog](https://neveroff.dev/blog/stripe-payment-link-file-download-with-email/). 15 | 16 | ### Why not Zapier? 17 | 18 | Owning your infrastructure aside, Zapier has [improved away](https://community.zapier.com/how-do-i-3/how-do-i-connect-both-a-stripe-live-account-and-test-account-16313?postid=133299&ref=neveroff.dev#post133299) an ability to use Stripe Test Mode in their integration in 2023 and still hasn't brought it back, which seems entirely counterintuitive. 19 | 20 | And whilst there are other options to achieve this with Zapier, I'd have much less control over execution, speed or overall experience and my faith in them maintaining that weorkaround option isn't great following their decision on the direct integration. I talk more about this in my [blog post](https://neveroff.dev/blog/stripe-payment-link-file-download-with-email/#what-about-zapier). 21 | 22 | ## Getting started without the guide 23 | 24 | 1. Check out the repository into a local folder, open the terminal at the root folder. 25 | 2. Do `cd file-and-email-delivery && npm install && npm run build && cd dist && zip -r ../../file-and-email-delivery.zip .`. This set of commands will install npm modules, build the code and tree-shake it via webpack, generate a dist folder with a single .js file and .zip it for upload to AWS. 26 | 3. Create a new IAM role with the S3 `GetObject` permission for your object and bucket, generate an Access Key pair. 27 | 4. Create a new Lambda function, call it `file-and-email-delivery`, upload the .zip file you've just 1reated. Set Lambda Configuration to 1,769 MB Memory or whatever's the latest value that gives you a full 1vCPU accoridng to [the manual](https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-memory-console). 28 | 5. Configure the API Gateway to point to the Lambda functions and supply the Stage Varibles as per the `index.js` files in both 1ile and email delivery folders, see Variables below. It's worth it to create two Stages - `prod` and `test` to be able to use 1tripe Test mode separately. 29 | 6. Configure the Environment Variables as per the `index.js` or the Variables reference below. 30 | 7. Configure the Stripe Payment Link to point to the API Gateway URL for the `file-and-email-delivery` Lambda. 31 | 8. Configure Brevo and your Static Site, get the Brevo Tempalte ID, API Key, insert the script to initiate the download from [download_url.html](/download_url.html), insert the Stripe Payment Link URL or Button embed. 32 | 9. Use the Stripe Test mode to ensure that your customer path is working as expected and an email is sent out with the file download link. 33 | 10. Replace the URL on your Static Website to point to the Live Stripe Payment Link. 34 | 35 | ## Variables 36 | 37 | ### Environment Variables 38 | 39 | Provide thtese under Lambda -> Configuration -> Environment Variables: 40 | 41 | | Label | Note | 42 | | -------- | --- | 43 | | S3_ACCESS_KEY_ID | The IAM user Access Key | 44 | | S3_SECRET_ACCESS_KEY | The IAM user Access Secret Key | 45 | | S3_REGION | The region of your S3 bucket. `eu-west-2` in this guide | 46 | | bucket_name | The name of S3 bucket with the file, `file-delivery` in our case | 47 | | object_key | The file's object key, `file.zip` | 48 | | redirect_host | The url of our confirmation page | 49 | | brevo_api_key | The API Key from Brevo which we'll set up later, leave it as `TBD` | 50 | | brevo_template_id | The ID of the template in Brevo, by default it's `1` | 51 | | link_expiration | The number of seconds the file will be acessible via the link. Cannot exceed 7 days, which is `604800` seconds | 52 | | fallback_email | An email to send message to in case customer haven't provided their email during checkout | 53 | | support_email | A parameter to show customers if payment confirmation failed to contact | 54 | | email_mode | Whether the code should await email server response and log it. Unless the value is `ensure-delivery` it will be sent but the answer won't be awaited and logged | 55 | | utm_parameters | Optional UTM parameters to add after the redirect url. Enter `&none` by default | 56 | 57 | ### Stage Variables 58 | 59 | Provide thtese under API Gateway -> Stage -> Stage Variables: 60 | 61 | | Label | Note | 62 | | -------- | --- | 63 | | environment | Text to identify the environment in logs | 64 | | stripe_secret_api_key | The Secret Key from Stripe Developer dashboard | 65 | 66 | ## Full Flow Diagram 67 | 68 | ![Flow Diagram](assets/flow.svg) 69 | 70 | This diagram roughly outlines the flow of the application. The customer clicks the Stripe Payment Link, is redirected to the API Gateway, which triggers the Lambda function. 71 | 72 | The Lambda function checks the payment status with Stripe, if it's successful, it sends an email with the download link and redirects the customer to the confirmation page. If the payment is not successful, it redirects the customer to the support email. 73 | 74 | ## Separate Lambdas 75 | 76 | Previous versions of this project have a separate lambdas approach, where one would handle a webhook from Stripe and send an email and another would handle the HTTP redirect from the Stripe Payment Link. 77 | 78 | I have abandoned it in favor of unified approach, and whilst it doesen't separate the concerns very well, the overlap in code and functionality felt too great to maintain them separately, not to mention the hassle and price increase added with two sets of API Gateways and two Lambdas. 79 | 80 | ## Performance 81 | 82 | When configured with 1 vCPU (currently 1,769 MB) the cold start is ~450ms and execution is ~300ms, **achieving sub-750ms processing**. 83 | 84 | Warm execution goes down to ~200ms. 85 | 86 | These figures assume `email_mode` is not set to `ensure-delivery`. If it is then both cold and warm execution times rises by about 100-150ms. 87 | 88 | ### Potential improvements 89 | 90 | 1. It's possible to use a language different from JS (Go?) that would have faster execution times or better init times. JS is not the fastest, but with tree-shaking it gets sub 750ms which is commendable. 91 | 2. It's further possible to add better handling to email failure, potentially by sending an email to the `support_email` with a report on the failure. 92 | 93 | ## Contributing 94 | 95 | I'm open to contribution and suggestions, feel free to open an issue or a pull request. 96 | 97 | I would be especially grateful for suggestions on how to speed up the Lambda to sub-750ms execution time, keeping in mind the currently presented outlined improvements. 98 | 99 | ## License 100 | 101 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 102 | -------------------------------------------------------------------------------- /file-and-email-delivery/dist/index.js: -------------------------------------------------------------------------------- 1 | var Za=Object.create;var ft=Object.defineProperty;var el=Object.getOwnPropertyDescriptor;var tl=Object.getOwnPropertyNames;var rl=Object.getPrototypeOf,ol=Object.prototype.hasOwnProperty;var T=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),mr=(t,e)=>{for(var r in e)ft(t,r,{get:e[r],enumerable:!0})},fo=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of tl(e))!ol.call(t,s)&&s!==r&&ft(t,s,{get:()=>e[s],enumerable:!(o=el(e,s))||o.enumerable});return t};var se=(t,e,r)=>(r=t!=null?Za(rl(t)):{},fo(e||!t||!t.__esModule?ft(r,"default",{value:t,enumerable:!0}):r,t)),nl=t=>fo(ft({},"__esModule",{value:!0}),t);var To=T((pp,go)=>{"use strict";go.exports=Error});var So=T((dp,_o)=>{"use strict";_o.exports=EvalError});var xo=T((hp,Eo)=>{"use strict";Eo.exports=RangeError});var Oo=T((fp,bo)=>{"use strict";bo.exports=ReferenceError});var _r=T((mp,wo)=>{"use strict";wo.exports=SyntaxError});var Pe=T((yp,Ro)=>{"use strict";Ro.exports=TypeError});var Co=T((vp,Ao)=>{"use strict";Ao.exports=URIError});var Mo=T((Pp,Io)=>{"use strict";Io.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),o=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(o)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==s||a.enumerable!==!0)return!1}return!0}});var ko=T((gp,Do)=>{"use strict";var Go=typeof Symbol<"u"&&Symbol,al=Mo();Do.exports=function(){return typeof Go!="function"||typeof Symbol!="function"||typeof Go("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:al()}});var No=T((Tp,qo)=>{"use strict";var Sr={__proto__:null,foo:{}},ll=Object;qo.exports=function(){return{__proto__:Sr}.foo===Sr.foo&&!(Sr instanceof ll)}});var $o=T((_p,Uo)=>{"use strict";var ul="Function.prototype.bind called on incompatible ",cl=Object.prototype.toString,pl=Math.max,dl="[object Function]",Fo=function(e,r){for(var o=[],s=0;s{"use strict";var ml=$o();Lo.exports=Function.prototype.bind||ml});var Bo=T((Ep,Ho)=>{"use strict";var yl=Function.prototype.call,vl=Object.prototype.hasOwnProperty,Pl=bt();Ho.exports=Pl.call(yl,vl)});var le=T((xp,jo)=>{"use strict";var g,gl=To(),Tl=So(),_l=xo(),Sl=Oo(),Se=_r(),_e=Pe(),El=Co(),Ko=Function,Er=function(t){try{return Ko('"use strict"; return ('+t+").constructor;")()}catch{}},ie=Object.getOwnPropertyDescriptor;if(ie)try{ie({},"")}catch{ie=null}var xr=function(){throw new _e},xl=ie?function(){try{return arguments.callee,xr}catch{try{return ie(arguments,"callee").get}catch{return xr}}}():xr,ge=ko()(),bl=No()(),C=Object.getPrototypeOf||(bl?function(t){return t.__proto__}:null),Te={},Ol=typeof Uint8Array>"u"||!C?g:C(Uint8Array),ae={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?g:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?g:ArrayBuffer,"%ArrayIteratorPrototype%":ge&&C?C([][Symbol.iterator]()):g,"%AsyncFromSyncIteratorPrototype%":g,"%AsyncFunction%":Te,"%AsyncGenerator%":Te,"%AsyncGeneratorFunction%":Te,"%AsyncIteratorPrototype%":Te,"%Atomics%":typeof Atomics>"u"?g:Atomics,"%BigInt%":typeof BigInt>"u"?g:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?g:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?g:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?g:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":gl,"%eval%":eval,"%EvalError%":Tl,"%Float32Array%":typeof Float32Array>"u"?g:Float32Array,"%Float64Array%":typeof Float64Array>"u"?g:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?g:FinalizationRegistry,"%Function%":Ko,"%GeneratorFunction%":Te,"%Int8Array%":typeof Int8Array>"u"?g:Int8Array,"%Int16Array%":typeof Int16Array>"u"?g:Int16Array,"%Int32Array%":typeof Int32Array>"u"?g:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ge&&C?C(C([][Symbol.iterator]())):g,"%JSON%":typeof JSON=="object"?JSON:g,"%Map%":typeof Map>"u"?g:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ge||!C?g:C(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?g:Promise,"%Proxy%":typeof Proxy>"u"?g:Proxy,"%RangeError%":_l,"%ReferenceError%":Sl,"%Reflect%":typeof Reflect>"u"?g:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?g:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ge||!C?g:C(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?g:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ge&&C?C(""[Symbol.iterator]()):g,"%Symbol%":ge?Symbol:g,"%SyntaxError%":Se,"%ThrowTypeError%":xl,"%TypedArray%":Ol,"%TypeError%":_e,"%Uint8Array%":typeof Uint8Array>"u"?g:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?g:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?g:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?g:Uint32Array,"%URIError%":El,"%WeakMap%":typeof WeakMap>"u"?g:WeakMap,"%WeakRef%":typeof WeakRef>"u"?g:WeakRef,"%WeakSet%":typeof WeakSet>"u"?g:WeakSet};if(C)try{null.error}catch(t){Wo=C(C(t)),ae["%Error.prototype%"]=Wo}var Wo,wl=function t(e){var r;if(e==="%AsyncFunction%")r=Er("async function () {}");else if(e==="%GeneratorFunction%")r=Er("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Er("async function* () {}");else if(e==="%AsyncGenerator%"){var o=t("%AsyncGeneratorFunction%");o&&(r=o.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&C&&(r=C(s.prototype))}return ae[e]=r,r},zo={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},$e=bt(),Ot=Bo(),Rl=$e.call(Function.call,Array.prototype.concat),Al=$e.call(Function.apply,Array.prototype.splice),Vo=$e.call(Function.call,String.prototype.replace),wt=$e.call(Function.call,String.prototype.slice),Cl=$e.call(Function.call,RegExp.prototype.exec),Il=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ml=/\\(\\)?/g,Gl=function(e){var r=wt(e,0,1),o=wt(e,-1);if(r==="%"&&o!=="%")throw new Se("invalid intrinsic syntax, expected closing `%`");if(o==="%"&&r!=="%")throw new Se("invalid intrinsic syntax, expected opening `%`");var s=[];return Vo(e,Il,function(i,a,u,c){s[s.length]=u?Vo(c,Ml,"$1"):a||i}),s},Dl=function(e,r){var o=e,s;if(Ot(zo,o)&&(s=zo[o],o="%"+s[0]+"%"),Ot(ae,o)){var i=ae[o];if(i===Te&&(i=wl(o)),typeof i>"u"&&!r)throw new _e("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:o,value:i}}throw new Se("intrinsic "+e+" does not exist!")};jo.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new _e("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new _e('"allowMissing" argument must be a boolean');if(Cl(/^%?[^%]*%?$/,e)===null)throw new Se("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var o=Gl(e),s=o.length>0?o[0]:"",i=Dl("%"+s+"%",r),a=i.name,u=i.value,c=!1,l=i.alias;l&&(s=l[0],Al(o,Rl([0,1],l)));for(var p=1,h=!0;p=o.length){var y=ie(u,d);h=!!y,h&&"get"in y&&!("originalValue"in y.get)?u=y.get:u=u[d]}else h=Ot(u,d),u=u[d];h&&!c&&(ae[a]=u)}}return u}});var At=T((bp,Qo)=>{"use strict";var kl=le(),Rt=kl("%Object.defineProperty%",!0)||!1;if(Rt)try{Rt({},"a",{value:1})}catch{Rt=!1}Qo.exports=Rt});var br=T((Op,Jo)=>{"use strict";var ql=le(),Ct=ql("%Object.getOwnPropertyDescriptor%",!0);if(Ct)try{Ct([],"length")}catch{Ct=null}Jo.exports=Ct});var en=T((wp,Zo)=>{"use strict";var Yo=At(),Nl=_r(),Ee=Pe(),Xo=br();Zo.exports=function(e,r,o){if(!e||typeof e!="object"&&typeof e!="function")throw new Ee("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Ee("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ee("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ee("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ee("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ee("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,c=!!Xo&&Xo(e,r);if(Yo)Yo(e,r,{configurable:a===null&&c?c.configurable:!a,enumerable:s===null&&c?c.enumerable:!s,value:o,writable:i===null&&c?c.writable:!i});else if(u||!s&&!i&&!a)e[r]=o;else throw new Nl("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var on=T((Rp,rn)=>{"use strict";var Or=At(),tn=function(){return!!Or};tn.hasArrayLengthDefineBug=function(){if(!Or)return null;try{return Or([],"length",{value:1}).length!==1}catch{return!0}};rn.exports=tn});var un=T((Ap,ln)=>{"use strict";var Fl=le(),nn=en(),Ul=on()(),sn=br(),an=Pe(),$l=Fl("%Math.floor%");ln.exports=function(e,r){if(typeof e!="function")throw new an("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||$l(r)!==r)throw new an("`length` must be a positive 32-bit integer");var o=arguments.length>2&&!!arguments[2],s=!0,i=!0;if("length"in e&&sn){var a=sn(e,"length");a&&!a.configurable&&(s=!1),a&&!a.writable&&(i=!1)}return(s||i||!o)&&(Ul?nn(e,"length",r,!0,!0):nn(e,"length",r)),e}});var mn=T((Cp,It)=>{"use strict";var wr=bt(),Mt=le(),Ll=un(),Hl=Pe(),dn=Mt("%Function.prototype.apply%"),hn=Mt("%Function.prototype.call%"),fn=Mt("%Reflect.apply%",!0)||wr.call(hn,dn),cn=At(),Bl=Mt("%Math.max%");It.exports=function(e){if(typeof e!="function")throw new Hl("a function is required");var r=fn(wr,hn,arguments);return Ll(r,1+Bl(0,e.length-(arguments.length-1)),!0)};var pn=function(){return fn(wr,dn,arguments)};cn?cn(It.exports,"apply",{value:pn}):It.exports.apply=pn});var gn=T((Ip,Pn)=>{"use strict";var yn=le(),vn=mn(),Wl=vn(yn("String.prototype.indexOf"));Pn.exports=function(e,r){var o=yn(e,!!r);return typeof o=="function"&&Wl(e,".prototype.")>-1?vn(o):o}});var _n=T((Mp,Tn)=>{Tn.exports=require("util").inspect});var Ln=T((Gp,$n)=>{var Nr=typeof Map=="function"&&Map.prototype,Rr=Object.getOwnPropertyDescriptor&&Nr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Dt=Nr&&Rr&&typeof Rr.get=="function"?Rr.get:null,Sn=Nr&&Map.prototype.forEach,Fr=typeof Set=="function"&&Set.prototype,Ar=Object.getOwnPropertyDescriptor&&Fr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,kt=Fr&&Ar&&typeof Ar.get=="function"?Ar.get:null,En=Fr&&Set.prototype.forEach,zl=typeof WeakMap=="function"&&WeakMap.prototype,He=zl?WeakMap.prototype.has:null,Vl=typeof WeakSet=="function"&&WeakSet.prototype,Be=Vl?WeakSet.prototype.has:null,Kl=typeof WeakRef=="function"&&WeakRef.prototype,xn=Kl?WeakRef.prototype.deref:null,jl=Boolean.prototype.valueOf,Ql=Object.prototype.toString,Jl=Function.prototype.toString,Yl=String.prototype.match,Ur=String.prototype.slice,X=String.prototype.replace,Xl=String.prototype.toUpperCase,bn=String.prototype.toLowerCase,Dn=RegExp.prototype.test,On=Array.prototype.concat,L=Array.prototype.join,Zl=Array.prototype.slice,wn=Math.floor,Mr=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Cr=Object.getOwnPropertySymbols,Gr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,xe=typeof Symbol=="function"&&typeof Symbol.iterator=="object",G=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===xe||!0)?Symbol.toStringTag:null,kn=Object.prototype.propertyIsEnumerable,Rn=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function An(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Dn.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var o=t<0?-wn(-t):wn(t);if(o!==t){var s=String(o),i=Ur.call(e,s.length+1);return X.call(s,r,"$&_")+"."+X.call(X.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return X.call(e,r,"$&_")}var Dr=_n(),Cn=Dr.custom,In=Nn(Cn)?Cn:null;$n.exports=function t(e,r,o,s){var i=r||{};if(Y(i,"quoteStyle")&&i.quoteStyle!=="single"&&i.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Y(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=Y(i,"customInspect")?i.customInspect:!0;if(typeof a!="boolean"&&a!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Y(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Y(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var u=i.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Un(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return u?An(e,c):c}if(typeof e=="bigint"){var l=String(e)+"n";return u?An(e,l):l}var p=typeof i.depth>"u"?5:i.depth;if(typeof o>"u"&&(o=0),o>=p&&p>0&&typeof e=="object")return kr(e)?"[Array]":"[Object]";var h=vu(i,o);if(typeof s>"u")s=[];else if(Fn(s,e)>=0)return"[Circular]";function d(N,K,j){if(K&&(s=Zl.call(s),s.push(K)),j){var qe={depth:i.depth};return Y(i,"quoteStyle")&&(qe.quoteStyle=i.quoteStyle),t(N,qe,o+1,s)}return t(N,i,o+1,s)}if(typeof e=="function"&&!Mn(e)){var f=lu(e),m=Gt(e,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(m.length>0?" { "+L.call(m,", ")+" }":"")}if(Nn(e)){var y=xe?X.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Gr.call(e);return typeof e=="object"&&!xe?Le(y):y}if(fu(e)){for(var P="<"+bn.call(String(e.nodeName)),_=e.attributes||[],E=0;E<_.length;E++)P+=" "+_[E].name+"="+qn(eu(_[E].value),"double",i);return P+=">",e.childNodes&&e.childNodes.length&&(P+="..."),P+="",P}if(kr(e)){if(e.length===0)return"[]";var v=Gt(e,d);return h&&!yu(v)?"["+qr(v,h)+"]":"[ "+L.call(v,", ")+" ]"}if(ru(e)){var b=Gt(e,d);return!("cause"in Error.prototype)&&"cause"in e&&!kn.call(e,"cause")?"{ ["+String(e)+"] "+L.call(On.call("[cause]: "+d(e.cause),b),", ")+" }":b.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+L.call(b,", ")+" }"}if(typeof e=="object"&&a){if(In&&typeof e[In]=="function"&&Dr)return Dr(e,{depth:p-o});if(a!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(uu(e)){var q=[];return Sn&&Sn.call(e,function(N,K){q.push(d(K,e,!0)+" => "+d(N,e))}),Gn("Map",Dt.call(e),q,h)}if(du(e)){var D=[];return En&&En.call(e,function(N){D.push(d(N,e))}),Gn("Set",kt.call(e),D,h)}if(cu(e))return Ir("WeakMap");if(hu(e))return Ir("WeakSet");if(pu(e))return Ir("WeakRef");if(nu(e))return Le(d(Number(e)));if(iu(e))return Le(d(Mr.call(e)));if(su(e))return Le(jl.call(e));if(ou(e))return Le(d(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(e===global)return"{ [object globalThis] }";if(!tu(e)&&!Mn(e)){var R=Gt(e,d),$=Rn?Rn(e)===Object.prototype:e instanceof Object||e.constructor===Object,ne=e instanceof Object?"":"null prototype",V=!$&&G&&Object(e)===e&&G in e?Ur.call(Z(e),8,-1):ne?"Object":"",ht=$||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",he=ht+(V||ne?"["+L.call(On.call([],V||[],ne||[]),": ")+"] ":"");return R.length===0?he+"{}":h?he+"{"+qr(R,h)+"}":he+"{ "+L.call(R,", ")+" }"}return String(e)};function qn(t,e,r){var o=(r.quoteStyle||e)==="double"?'"':"'";return o+t+o}function eu(t){return X.call(String(t),/"/g,""")}function kr(t){return Z(t)==="[object Array]"&&(!G||!(typeof t=="object"&&G in t))}function tu(t){return Z(t)==="[object Date]"&&(!G||!(typeof t=="object"&&G in t))}function Mn(t){return Z(t)==="[object RegExp]"&&(!G||!(typeof t=="object"&&G in t))}function ru(t){return Z(t)==="[object Error]"&&(!G||!(typeof t=="object"&&G in t))}function ou(t){return Z(t)==="[object String]"&&(!G||!(typeof t=="object"&&G in t))}function nu(t){return Z(t)==="[object Number]"&&(!G||!(typeof t=="object"&&G in t))}function su(t){return Z(t)==="[object Boolean]"&&(!G||!(typeof t=="object"&&G in t))}function Nn(t){if(xe)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!Gr)return!1;try{return Gr.call(t),!0}catch{}return!1}function iu(t){if(!t||typeof t!="object"||!Mr)return!1;try{return Mr.call(t),!0}catch{}return!1}var au=Object.prototype.hasOwnProperty||function(t){return t in this};function Y(t,e){return au.call(t,e)}function Z(t){return Ql.call(t)}function lu(t){if(t.name)return t.name;var e=Yl.call(Jl.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function Fn(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,o=t.length;re.maxStringLength){var r=t.length-e.maxStringLength,o="... "+r+" more character"+(r>1?"s":"");return Un(Ur.call(t,0,e.maxStringLength),e)+o}var s=X.call(X.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,mu);return qn(s,"single",e)}function mu(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+Xl.call(e.toString(16))}function Le(t){return"Object("+t+")"}function Ir(t){return t+" { ? }"}function Gn(t,e,r,o){var s=o?qr(r,o):L.call(r,", ");return t+" ("+e+") {"+s+"}"}function yu(t){for(var e=0;e=0)return!1;return!0}function vu(t,e){var r;if(t.indent===" ")r=" ";else if(typeof t.indent=="number"&&t.indent>0)r=L.call(Array(t.indent+1)," ");else return null;return{base:r,prev:L.call(Array(e+1),r)}}function qr(t,e){if(t.length===0)return"";var r=` 3 | `+e.prev+e.base;return r+L.call(t,","+r)+` 4 | `+e.prev}function Gt(t,e){var r=kr(t),o=[];if(r){o.length=t.length;for(var s=0;s{"use strict";var Hn=le(),be=gn(),Pu=Ln(),gu=Pe(),qt=Hn("%WeakMap%",!0),Nt=Hn("%Map%",!0),Tu=be("WeakMap.prototype.get",!0),_u=be("WeakMap.prototype.set",!0),Su=be("WeakMap.prototype.has",!0),Eu=be("Map.prototype.get",!0),xu=be("Map.prototype.set",!0),bu=be("Map.prototype.has",!0),$r=function(t,e){for(var r=t,o;(o=r.next)!==null;r=o)if(o.key===e)return r.next=o.next,o.next=t.next,t.next=o,o},Ou=function(t,e){var r=$r(t,e);return r&&r.value},wu=function(t,e,r){var o=$r(t,e);o?o.value=r:t.next={key:e,next:t.next,value:r}},Ru=function(t,e){return!!$r(t,e)};Bn.exports=function(){var e,r,o,s={assert:function(i){if(!s.has(i))throw new gu("Side channel does not contain "+Pu(i))},get:function(i){if(qt&&i&&(typeof i=="object"||typeof i=="function")){if(e)return Tu(e,i)}else if(Nt){if(r)return Eu(r,i)}else if(o)return Ou(o,i)},has:function(i){if(qt&&i&&(typeof i=="object"||typeof i=="function")){if(e)return Su(e,i)}else if(Nt){if(r)return bu(r,i)}else if(o)return Ru(o,i);return!1},set:function(i,a){qt&&i&&(typeof i=="object"||typeof i=="function")?(e||(e=new qt),_u(e,i,a)):Nt?(r||(r=new Nt),xu(r,i,a)):(o||(o={key:{},next:null}),wu(o,i,a))}};return s}});var Ft=T((kp,zn)=>{"use strict";var Au=String.prototype.replace,Cu=/%20/g,Lr={RFC1738:"RFC1738",RFC3986:"RFC3986"};zn.exports={default:Lr.RFC3986,formatters:{RFC1738:function(t){return Au.call(t,Cu,"+")},RFC3986:function(t){return String(t)}},RFC1738:Lr.RFC1738,RFC3986:Lr.RFC3986}});var Br=T((qp,Kn)=>{"use strict";var Iu=Ft(),Hr=Object.prototype.hasOwnProperty,ue=Array.isArray,H=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),Mu=function(e){for(;e.length>1;){var r=e.pop(),o=r.obj[r.prop];if(ue(o)){for(var s=[],i=0;i=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||i===Iu.RFC1738&&(l===40||l===41)){u+=a.charAt(c);continue}if(l<128){u=u+H[l];continue}if(l<2048){u=u+(H[192|l>>6]+H[128|l&63]);continue}if(l<55296||l>=57344){u=u+(H[224|l>>12]+H[128|l>>6&63]+H[128|l&63]);continue}c+=1,l=65536+((l&1023)<<10|a.charCodeAt(c)&1023),u+=H[240|l>>18]+H[128|l>>12&63]+H[128|l>>6&63]+H[128|l&63]}return u},Nu=function(e){for(var r=[{obj:{o:e},prop:"o"}],o=[],s=0;s{"use strict";var Qn=Wn(),Ut=Br(),We=Ft(),Hu=Object.prototype.hasOwnProperty,Jn={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,r){return e+"["+r+"]"},repeat:function(e){return e}},B=Array.isArray,Bu=Array.prototype.push,Yn=function(t,e){Bu.apply(t,B(e)?e:[e])},Wu=Date.prototype.toISOString,jn=We.default,A={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Ut.encode,encodeValuesOnly:!1,format:jn,formatter:We.formatters[jn],indices:!1,serializeDate:function(e){return Wu.call(e)},skipNulls:!1,strictNullHandling:!1},zu=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Wr={},Vu=function t(e,r,o,s,i,a,u,c,l,p,h,d,f,m,y,P,_,E){for(var v=e,b=E,q=0,D=!1;(b=b.get(Wr))!==void 0&&!D;){var R=b.get(e);if(q+=1,typeof R<"u"){if(R===q)throw new RangeError("Cyclic object value");D=!0}typeof b.get(Wr)>"u"&&(q=0)}if(typeof p=="function"?v=p(r,v):v instanceof Date?v=f(v):o==="comma"&&B(v)&&(v=Ut.maybeMap(v,function(fr){return fr instanceof Date?f(fr):fr})),v===null){if(a)return l&&!P?l(r,A.encoder,_,"key",m):r;v=""}if(zu(v)||Ut.isBuffer(v)){if(l){var $=P?r:l(r,A.encoder,_,"key",m);return[y($)+"="+y(l(v,A.encoder,_,"value",m))]}return[y(r)+"="+y(String(v))]}var ne=[];if(typeof v>"u")return ne;var V;if(o==="comma"&&B(v))P&&l&&(v=Ut.maybeMap(v,l)),V=[{value:v.length>0?v.join(",")||null:void 0}];else if(B(p))V=p;else{var ht=Object.keys(v);V=h?ht.sort(h):ht}var he=c?r.replace(/\./g,"%2E"):r,N=s&&B(v)&&v.length===1?he+"[]":he;if(i&&B(v)&&v.length===0)return N+"[]";for(var K=0;K"u"?e.encodeDotInKeys===!0?!0:A.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:A.addQueryPrefix,allowDots:u,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:A.allowEmptyArrays,arrayFormat:a,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:A.charsetSentinel,commaRoundTrip:e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?A.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:A.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:A.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:A.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:A.encodeValuesOnly,filter:i,format:o,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:A.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:A.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:A.strictNullHandling}};Xn.exports=function(t,e){var r=t,o=Ku(e),s,i;typeof o.filter=="function"?(i=o.filter,r=i("",r)):B(o.filter)&&(i=o.filter,s=i);var a=[];if(typeof r!="object"||r===null)return"";var u=Jn[o.arrayFormat],c=u==="comma"&&o.commaRoundTrip;s||(s=Object.keys(r)),o.sort&&s.sort(o.sort);for(var l=Qn(),p=0;p0?f+d:""}});var rs=T((Fp,ts)=>{"use strict";var Oe=Br(),zr=Object.prototype.hasOwnProperty,ju=Array.isArray,w={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!0,decoder:Oe.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Qu=function(t){return t.replace(/&#(\d+);/g,function(e,r){return String.fromCharCode(parseInt(r,10))})},es=function(t,e){return t&&typeof t=="string"&&e.comma&&t.indexOf(",")>-1?t.split(","):t},Ju="utf8=%26%2310003%3B",Yu="utf8=%E2%9C%93",Xu=function(e,r){var o={__proto__:null},s=r.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=r.parameterLimit===1/0?void 0:r.parameterLimit,a=s.split(r.delimiter,i),u=-1,c,l=r.charset;if(r.charsetSentinel)for(c=0;c-1&&(m=ju(m)?[m]:m);var y=zr.call(o,f);y&&r.duplicates==="combine"?o[f]=Oe.combine(o[f],m):(!y||r.duplicates==="last")&&(o[f]=m)}return o},Zu=function(t,e,r,o){for(var s=o?e:es(e,r),i=t.length-1;i>=0;--i){var a,u=t[i];if(u==="[]"&&r.parseArrays)a=r.allowEmptyArrays&&s===""?[]:[].concat(s);else{a=r.plainObjects?Object.create(null):{};var c=u.charAt(0)==="["&&u.charAt(u.length-1)==="]"?u.slice(1,-1):u,l=r.decodeDotInKeys?c.replace(/%2E/g,"."):c,p=parseInt(l,10);!r.parseArrays&&l===""?a={0:s}:!isNaN(p)&&u!==l&&String(p)===l&&p>=0&&r.parseArrays&&p<=r.arrayLimit?(a=[],a[p]=s):l!=="__proto__"&&(a[l]=s)}s=a}return s},ec=function(e,r,o,s){if(e){var i=o.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/,u=/(\[[^[\]]*])/g,c=o.depth>0&&a.exec(i),l=c?i.slice(0,c.index):i,p=[];if(l){if(!o.plainObjects&&zr.call(Object.prototype,l)&&!o.allowPrototypes)return;p.push(l)}for(var h=0;o.depth>0&&(c=u.exec(i))!==null&&h"u"?w.charset:e.charset,o=typeof e.duplicates>"u"?w.duplicates:e.duplicates;if(o!=="combine"&&o!=="first"&&o!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof e.allowDots>"u"?e.decodeDotInKeys===!0?!0:w.allowDots:!!e.allowDots;return{allowDots:s,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:w.allowEmptyArrays,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:w.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:w.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:w.arrayLimit,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:w.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:w.comma,decodeDotInKeys:typeof e.decodeDotInKeys=="boolean"?e.decodeDotInKeys:w.decodeDotInKeys,decoder:typeof e.decoder=="function"?e.decoder:w.decoder,delimiter:typeof e.delimiter=="string"||Oe.isRegExp(e.delimiter)?e.delimiter:w.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:w.depth,duplicates:o,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:w.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:w.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:w.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:w.strictNullHandling}};ts.exports=function(t,e){var r=tc(e);if(t===""||t===null||typeof t>"u")return r.plainObjects?Object.create(null):{};for(var o=typeof t=="string"?Xu(t,r):t,s=r.plainObjects?Object.create(null):{},i=Object.keys(o),a=0;a{"use strict";var rc=Zn(),oc=rs(),nc=Ft();os.exports={formats:nc,parse:oc,stringify:rc}});var Jc={};mr(Jc,{handler:()=>Qc});module.exports=nl(Jc);var po=se(require("https"),1),Ja=se(require("url"),1);var we=se(require("crypto"),1),Kr=require("events");var mo=se(require("crypto"),1);var Q=class{computeHMACSignature(e,r){throw new Error("computeHMACSignature not implemented.")}computeHMACSignatureAsync(e,r){throw new Error("computeHMACSignatureAsync not implemented.")}},fe=class extends Error{};var mt=class extends Q{computeHMACSignature(e,r){return mo.createHmac("sha256",r).update(e,"utf8").digest("hex")}async computeHMACSignatureAsync(e,r){return await this.computeHMACSignature(e,r)}};var vr=se(require("http"),1),Pr=se(require("https"),1);var M=class t{getClientName(){throw new Error("getClientName not implemented.")}makeRequest(e,r,o,s,i,a,u,c){throw new Error("makeRequest not implemented.")}static makeTimeoutError(){let e=new TypeError(t.TIMEOUT_ERROR_CODE);return e.code=t.TIMEOUT_ERROR_CODE,e}};M.CONNECTION_CLOSED_ERROR_CODES=["ECONNRESET","EPIPE"];M.TIMEOUT_ERROR_CODE="ETIMEDOUT";var J=class{constructor(e,r){this._statusCode=e,this._headers=r}getStatusCode(){return this._statusCode}getHeaders(){return this._headers}getRawResponse(){throw new Error("getRawResponse not implemented.")}toStream(e){throw new Error("toStream not implemented.")}toJSON(){throw new Error("toJSON not implemented.")}};var yo=vr.default||vr,vo=Pr.default||Pr,sl=new yo.Agent({keepAlive:!0}),il=new vo.Agent({keepAlive:!0}),Ne=class extends M{constructor(e){super(),this._agent=e}getClientName(){return"node"}makeRequest(e,r,o,s,i,a,u,c){let l=u==="http",p=this._agent;return p||(p=l?sl:il),new Promise((d,f)=>{let m=(l?yo:vo).request({host:e,port:r,path:o,method:s,agent:p,headers:i,ciphers:"DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5"});m.setTimeout(c,()=>{m.destroy(M.makeTimeoutError())}),m.on("response",y=>{d(new yr(y))}),m.on("error",y=>{f(y)}),m.once("socket",y=>{y.connecting?y.once(l?"connect":"secureConnect",()=>{m.write(a),m.end()}):(m.write(a),m.end())})})}},yr=class extends J{constructor(e){super(e.statusCode,e.headers||{}),this._res=e}getRawResponse(){return this._res}toStream(e){return this._res.once("end",()=>e()),this._res}toJSON(){return new Promise((e,r)=>{let o="";this._res.setEncoding("utf8"),this._res.on("data",s=>{o+=s}),this._res.once("end",()=>{try{e(JSON.parse(o))}catch(s){r(s)}})})}};var yt=class t extends M{constructor(e){if(super(),!e){if(!globalThis.fetch)throw new Error("fetch() function not provided and is not defined in the global scope. You must provide a fetch implementation.");e=globalThis.fetch}globalThis.AbortController?this._fetchFn=t.makeFetchWithAbortTimeout(e):this._fetchFn=t.makeFetchWithRaceTimeout(e)}static makeFetchWithRaceTimeout(e){return(r,o,s)=>{let i,a=new Promise((c,l)=>{i=setTimeout(()=>{i=null,l(M.makeTimeoutError())},s)}),u=e(r,o);return Promise.race([u,a]).finally(()=>{i&&clearTimeout(i)})}}static makeFetchWithAbortTimeout(e){return async(r,o,s)=>{let i=new AbortController,a=setTimeout(()=>{a=null,i.abort(M.makeTimeoutError())},s);try{return await e(r,Object.assign(Object.assign({},o),{signal:i.signal}))}catch(u){throw u.name==="AbortError"?M.makeTimeoutError():u}finally{a&&clearTimeout(a)}}}getClientName(){return"fetch"}async makeRequest(e,r,o,s,i,a,u,c){let l=u==="http",p=new URL(o,`${l?"http":"https"}://${e}`);p.port=r;let h=s=="POST"||s=="PUT"||s=="PATCH",d=a||(h?"":void 0),f=await this._fetchFn(p.toString(),{method:s,headers:i,body:d},c);return new gr(f)}},gr=class t extends J{constructor(e){super(e.status,t._transformHeadersToObject(e.headers)),this._res=e}getRawResponse(){return this._res}toStream(e){return e(),this._res.body}toJSON(){return this._res.json()}static _transformHeadersToObject(e){let r={};for(let o of e){if(!Array.isArray(o)||o.length!=2)throw new Error("Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.");r[o[0]]=o[1]}return r}};var vt=class extends Q{constructor(e){super(),this.subtleCrypto=e||crypto.subtle}computeHMACSignature(e,r){throw new fe("SubtleCryptoProvider cannot be used in a synchronous context.")}async computeHMACSignatureAsync(e,r){let o=new TextEncoder,s=await this.subtleCrypto.importKey("raw",o.encode(r),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await this.subtleCrypto.sign("hmac",s,o.encode(e)),a=new Uint8Array(i),u=new Array(a.length);for(let c=0;c{let r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}secureCompare(e,r){if(e.length!==r.length)return!1;let o=e.length,s=0;for(let i=0;ime,StripeAuthenticationError:()=>ye,StripeCardError:()=>gt,StripeConnectionError:()=>Ue,StripeError:()=>O,StripeIdempotencyError:()=>_t,StripeInvalidGrantError:()=>St,StripeInvalidRequestError:()=>Tt,StripePermissionError:()=>Fe,StripeRateLimitError:()=>ve,StripeSignatureVerificationError:()=>F,StripeUnknownError:()=>Et,generate:()=>Po});var Po=t=>{switch(t.type){case"card_error":return new gt(t);case"invalid_request_error":return new Tt(t);case"api_error":return new me(t);case"authentication_error":return new ye(t);case"rate_limit_error":return new ve(t);case"idempotency_error":return new _t(t);case"invalid_grant":return new St(t);default:return new Et(t)}},O=class extends Error{constructor(e={}){super(e.message),this.type=this.constructor.name,this.raw=e,this.rawType=e.type,this.code=e.code,this.doc_url=e.doc_url,this.param=e.param,this.detail=e.detail,this.headers=e.headers,this.requestId=e.requestId,this.statusCode=e.statusCode,this.message=e.message,this.charge=e.charge,this.decline_code=e.decline_code,this.payment_intent=e.payment_intent,this.payment_method=e.payment_method,this.payment_method_type=e.payment_method_type,this.setup_intent=e.setup_intent,this.source=e.source}};O.generate=Po;var gt=class extends O{},Tt=class extends O{},me=class extends O{},ye=class extends O{},Fe=class extends O{},ve=class extends O{},Ue=class extends O{},F=class extends O{constructor(e,r,o={}){super(o),this.header=e,this.payload=r}},_t=class extends O{},St=class extends O{},Et=class extends O{};var ss=se(ns(),1),Vr=["apiKey","idempotencyKey","stripeAccount","apiVersion","maxNetworkRetries","timeout","host"];function is(t){return t&&typeof t=="object"&&Vr.some(e=>Object.prototype.hasOwnProperty.call(t,e))}function ee(t){return ss.stringify(t,{serializeDate:e=>Math.floor(e.getTime()/1e3).toString()}).replace(/%5B/g,"[").replace(/%5D/g,"]")}var $t=(()=>{let t={"\n":"\\n",'"':'\\"',"\u2028":"\\u2028","\u2029":"\\u2029"};return e=>{let r=e.replace(/["\n\r\u2028\u2029]/g,o=>t[o]);return o=>r.replace(/\{([\s\S]+?)\}/g,(s,i)=>encodeURIComponent(o[i]||""))}})();function as(t){let e=t.match(/\{\w+\}/g);return e?e.map(r=>r.replace(/[{}]/g,"")):[]}function Lt(t){if(!Array.isArray(t)||!t[0]||typeof t[0]!="object")return{};if(!is(t[0]))return t.shift();let e=Object.keys(t[0]),r=e.filter(o=>Vr.includes(o));return r.length>0&&r.length!==e.length&&Ve(`Options found in arguments (${r.join(", ")}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.`),{}}function ls(t){let e={auth:null,host:null,headers:{},settings:{}};if(t.length>0){let r=t[t.length-1];if(typeof r=="string")e.auth=t.pop();else if(is(r)){let o=Object.assign({},t.pop()),s=Object.keys(o).filter(i=>!Vr.includes(i));s.length&&Ve(`Invalid options found (${s.join(", ")}); ignoring.`),o.apiKey&&(e.auth=o.apiKey),o.idempotencyKey&&(e.headers["Idempotency-Key"]=o.idempotencyKey),o.stripeAccount&&(e.headers["Stripe-Account"]=o.stripeAccount),o.apiVersion&&(e.headers["Stripe-Version"]=o.apiVersion),Number.isInteger(o.maxNetworkRetries)&&(e.settings.maxNetworkRetries=o.maxNetworkRetries),Number.isInteger(o.timeout)&&(e.settings.timeout=o.timeout),o.host&&(e.host=o.host)}}return e}function us(t){let e=this,r=Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:function(...o){e.apply(this,o)};return Object.assign(r,e),r.prototype=Object.create(e.prototype),Object.assign(r.prototype,t),r}function Ht(t){if(typeof t!="object")throw new Error("Argument must be an object");return Object.keys(t).reduce((e,r)=>(t[r]!=null&&(e[r]=t[r]),e),{})}function cs(t){return t&&typeof t=="object"?Object.keys(t).reduce((e,r)=>(e[sc(r)]=t[r],e),{}):t}function sc(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()).join("-")}function ze(t,e){return e?t.then(r=>{setTimeout(()=>{e(null,r)},0)},r=>{setTimeout(()=>{e(r,null)},0)}):t}function ps(t){return t==="OAuth"?"oauth":t[0].toLowerCase()+t.substring(1)}function Ve(t){return typeof process.emitWarning!="function"?console.warn(`Stripe: ${t}`):process.emitWarning(t,"Stripe")}function ic(t){let e=typeof t;return(e==="function"||e==="object")&&!!t}function ds(t){let e={},r=(o,s)=>{Object.keys(o).forEach(i=>{let a=o[i],u=s?`${s}[${i}]`:i;if(ic(a)){if(!(a instanceof Uint8Array)&&!Object.prototype.hasOwnProperty.call(a,"data"))return r(a,u);e[u]=a}else e[u]=String(a)})};return r(t,null),e}function Bt(t,e,r){if(!Number.isInteger(e)){if(r!==void 0)return r;throw new Error(`${t} must be an integer`)}return e}function hs(){return typeof process>"u"?{}:{lang_version:process.version,platform:process.platform}}function fs(t){let e=t.reduce((s,i)=>s+i.length,0),r=new Uint8Array(e),o=0;return t.forEach(s=>{r.set(s,o),o+=s.length}),r}var ms=require("child_process"),jr=class extends O{},Wt=class extends Pt{constructor(){super(),this._exec=ms.exec,this._UNAME_CACHE=null}uuid4(){return we.randomUUID?we.randomUUID():super.uuid4()}getUname(){return this._UNAME_CACHE||(this._UNAME_CACHE=new Promise((e,r)=>{try{this._exec("uname -a",(o,s)=>{if(o)return e(null);e(s)})}catch{e(null)}})),this._UNAME_CACHE}secureCompare(e,r){if(!e||!r)throw new Error("secureCompare must receive two arguments");if(e.length!==r.length)return!1;if(we.timingSafeEqual){let o=new TextEncoder,s=o.encode(e),i=o.encode(r);return we.timingSafeEqual(s,i)}return super.secureCompare(e,r)}createEmitter(){return new Kr.EventEmitter}tryBufferData(e){if(!(e.file.data instanceof Kr.EventEmitter))return Promise.resolve(e);let r=[];return new Promise((o,s)=>{e.file.data.on("data",i=>{r.push(i)}).once("end",()=>{let i=Object.assign({},e);i.file.data=fs(r),o(i)}).on("error",i=>{s(new jr({message:"An error occurred while attempting to process the file for upload.",detail:i}))})})}createNodeHttpClient(e){return new Ne(e)}createDefaultHttpClient(){return new Ne}createNodeCryptoProvider(){return new mt}createDefaultCryptoProvider(){return this.createNodeCryptoProvider()}};var ys="2023-10-16";var dt={};mr(dt,{Account:()=>io,AccountLinks:()=>ki,AccountSessions:()=>qi,Accounts:()=>io,ApplePayDomains:()=>Ni,ApplicationFees:()=>Fi,Apps:()=>Cc,Balance:()=>Ui,BalanceTransactions:()=>Li,BillingPortal:()=>Ic,Charges:()=>Hi,Checkout:()=>Mc,Climate:()=>Gc,CountrySpecs:()=>Wi,Coupons:()=>zi,CreditNotes:()=>Vi,CustomerSessions:()=>Ki,Customers:()=>ji,Disputes:()=>Qi,EphemeralKeys:()=>Yi,Events:()=>Zi,ExchangeRates:()=>ta,FileLinks:()=>ra,Files:()=>na,FinancialConnections:()=>Dc,Identity:()=>kc,InvoiceItems:()=>sa,Invoices:()=>ia,Issuing:()=>qc,Mandates:()=>aa,OAuth:()=>ua,PaymentIntents:()=>ca,PaymentLinks:()=>pa,PaymentMethodConfigurations:()=>da,PaymentMethodDomains:()=>ha,PaymentMethods:()=>fa,Payouts:()=>ma,Plans:()=>ya,Prices:()=>va,Products:()=>Pa,PromotionCodes:()=>ga,Quotes:()=>Ta,Radar:()=>Nc,Refunds:()=>_a,Reporting:()=>Fc,Reviews:()=>Sa,SetupAttempts:()=>Ea,SetupIntents:()=>xa,ShippingRates:()=>ba,Sigma:()=>Uc,Sources:()=>Oa,SubscriptionItems:()=>wa,SubscriptionSchedules:()=>Ra,Subscriptions:()=>Aa,Tax:()=>$c,TaxCodes:()=>Ia,TaxIds:()=>Ma,TaxRates:()=>Ga,Terminal:()=>Lc,TestHelpers:()=>Hc,Tokens:()=>ka,Topups:()=>qa,Transfers:()=>Na,Treasury:()=>Bc,WebhookEndpoints:()=>Fa});function lc(t,e){for(let r in e){let o=r[0].toLowerCase()+r.substring(1),s=new e[r](t);this[o]=s}}function I(t,e){return function(r){return new lc(r,e)}}var zt=class{constructor(e,r,o,s){this.index=0,this.pagePromise=e,this.promiseCache={currentPromise:null},this.requestArgs=r,this.spec=o,this.stripeResource=s}async iterate(e){if(!(e&&e.data&&typeof e.data.length=="number"))throw Error("Unexpected: Stripe API response does not have a well-formed `data` array.");let r=gs(this.requestArgs);if(this.index{let r=await this._next();return this.promiseCache.currentPromise=null,r})();return this.promiseCache.currentPromise=e,e}},Qr=class extends zt{getNextPage(e){let r=gs(this.requestArgs),o=dc(e,r);return this.stripeResource._makeRequest(this.requestArgs,this.spec,{[r?"ending_before":"starting_after"]:o})}},Jr=class extends zt{getNextPage(e){if(!e.next_page)throw Error("Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true.");return this.stripeResource._makeRequest(this.requestArgs,this.spec,{page:e.next_page})}},Ps=(t,e,r,o)=>r.methodType==="search"?vs(new Jr(o,e,r,t)):r.methodType==="list"?vs(new Qr(o,e,r,t)):null,vs=t=>{let e=hc((...s)=>t.next(...s)),r=fc(e),o={autoPagingEach:e,autoPagingToArray:r,next:()=>t.next(),return:()=>({}),[uc()]:()=>o};return o};function uc(){return typeof Symbol<"u"&&Symbol.asyncIterator?Symbol.asyncIterator:"@@asyncIterator"}function cc(t){if(t.length<2)return null;let e=t[1];if(typeof e!="function")throw Error(`The second argument to autoPagingEach, if present, must be a callback function; received ${typeof e}`);return e}function pc(t){if(t.length===0)return;let e=t[0];if(typeof e!="function")throw Error(`The first argument to autoPagingEach, if present, must be a callback function; received ${typeof e}`);if(e.length===2)return e;if(e.length>2)throw Error(`The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${e}`);return function(o,s){let i=e(o);s(i)}}function dc(t,e){let r=e?0:t.data.length-1,o=t.data[r],s=o&&o.id;if(!s)throw Error("Unexpected: No `id` found on the last item while auto-paging a list.");return s}function hc(t){return function(){let r=[].slice.call(arguments),o=pc(r),s=cc(r);if(r.length>2)throw Error(`autoPagingEach takes up to two arguments; received ${r}`);let i=mc(t,o);return ze(i,s)}}function fc(t){return function(r,o){let s=r&&r.limit;if(!s)throw Error("You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.");if(s>1e4)throw Error("You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.");let i=new Promise((a,u)=>{let c=[];t(l=>{if(c.push(l),c.length>=s)return!1}).then(()=>{a(c)}).catch(u)});return ze(i,o)}}function mc(t,e){return new Promise((r,o)=>{function s(i){if(i.done){r();return}let a=i.value;return new Promise(u=>{e(a,u)}).then(u=>u===!1?s({done:!0,value:void 0}):t().then(s))}t().then(s).catch(o)})}function gs(t){let e=[].slice.call(t);return!!Lt(e).ending_before}function Ts(t){if(t.path!==void 0&&t.fullPath!==void 0)throw new Error(`Method spec specified both a 'path' (${t.path}) and a 'fullPath' (${t.fullPath}).`);return function(...e){let r=typeof e[e.length-1]=="function"&&e.pop();t.urlParams=as(t.fullPath||this.createResourcePathWithSymbols(t.path||""));let o=ze(this._makeRequest(e,t,{}),r);return Object.assign(o,Ps(this,e,t,o)),o}}n.extend=us;n.method=Ts;n.MAX_BUFFERED_REQUEST_METRICS=100;function n(t,e){if(this._stripe=t,e)throw new Error("Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.");this.basePath=$t(this.basePath||t.getApiField("basePath")),this.resourcePath=this.path,this.path=$t(this.path),this.initialize(...arguments)}n.prototype={_stripe:null,path:"",resourcePath:"",basePath:null,initialize(){},requestDataProcessor:null,validateRequest:null,createFullPath(t,e){let r=[this.basePath(e),this.path(e)];if(typeof t=="function"){let o=t(e);o&&r.push(o)}else r.push(t);return this._joinUrlParts(r)},createResourcePathWithSymbols(t){return t?`/${this._joinUrlParts([this.resourcePath,t])}`:`/${this.resourcePath}`},_joinUrlParts(t){return t.join("/").replace(/\/{2,}/g,"/")},_getRequestOpts(t,e,r){let o=(e.method||"GET").toUpperCase(),s=e.usage||[],i=e.urlParams||[],a=e.encode||(D=>D),u=!!e.fullPath,c=$t(u?e.fullPath:e.path||""),l=u?e.fullPath:this.createResourcePathWithSymbols(e.path),p=[].slice.call(t),h=i.reduce((D,R)=>{let $=p.shift();if(typeof $!="string")throw new Error(`Stripe: Argument "${R}" must be a string, but got: ${$} (on API request to \`${o} ${l}\`)`);return D[R]=$,D},{}),d=Lt(p),f=a(Object.assign({},d,r)),m=ls(p),y=m.host||e.host,P=!!e.streaming;if(p.filter(D=>D!=null).length)throw new Error(`Stripe: Unknown arguments (${p}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${o} \`${l}\`)`);let _=u?c(h):this.createFullPath(c,h),E=Object.assign(m.headers,e.headers);e.validator&&e.validator(f,{headers:E});let v=e.method==="GET"||e.method==="DELETE";return{requestMethod:o,requestPath:_,bodyData:v?{}:f,queryData:v?f:{},auth:m.auth,headers:E,host:y??null,streaming:P,settings:m.settings,usage:s}},_makeRequest(t,e,r){return new Promise((o,s)=>{var i;let a;try{a=this._getRequestOpts(t,e,r)}catch(d){s(d);return}function u(d,f){d?s(d):o(e.transformResponseData?e.transformResponseData(f):f)}let c=Object.keys(a.queryData).length===0,l=[a.requestPath,c?"":"?",ee(a.queryData)].join(""),{headers:p,settings:h}=a;this._stripe._requestSender._request(a.requestMethod,a.host,l,a.bodyData,a.auth,{headers:p,settings:h,streaming:a.streaming},a.usage,u,(i=this.requestDataProcessor)===null||i===void 0?void 0:i.bind(this))})}};var ce=n.method,_s=n.extend({retrieve:ce({method:"GET",fullPath:"/v1/financial_connections/accounts/{account}"}),list:ce({method:"GET",fullPath:"/v1/financial_connections/accounts",methodType:"list"}),disconnect:ce({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/disconnect"}),listOwners:ce({method:"GET",fullPath:"/v1/financial_connections/accounts/{account}/owners",methodType:"list"}),refresh:ce({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/refresh"}),subscribe:ce({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/subscribe"}),unsubscribe:ce({method:"POST",fullPath:"/v1/financial_connections/accounts/{account}/unsubscribe"})});var Ke=n.method,Ss=n.extend({create:Ke({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations"}),capture:Ke({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/capture"}),expire:Ke({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/expire"}),increment:Ke({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/increment"}),reverse:Ke({method:"POST",fullPath:"/v1/test_helpers/issuing/authorizations/{authorization}/reverse"})});var je=n.method,Es=n.extend({retrieve:je({method:"GET",fullPath:"/v1/issuing/authorizations/{authorization}"}),update:je({method:"POST",fullPath:"/v1/issuing/authorizations/{authorization}"}),list:je({method:"GET",fullPath:"/v1/issuing/authorizations",methodType:"list"}),approve:je({method:"POST",fullPath:"/v1/issuing/authorizations/{authorization}/approve"}),decline:je({method:"POST",fullPath:"/v1/issuing/authorizations/{authorization}/decline"})});var xs=n.method,bs=n.extend({create:xs({method:"POST",fullPath:"/v1/tax/calculations"}),listLineItems:xs({method:"GET",fullPath:"/v1/tax/calculations/{calculation}/line_items",methodType:"list"})});var Vt=n.method,Os=n.extend({create:Vt({method:"POST",fullPath:"/v1/issuing/cardholders"}),retrieve:Vt({method:"GET",fullPath:"/v1/issuing/cardholders/{cardholder}"}),update:Vt({method:"POST",fullPath:"/v1/issuing/cardholders/{cardholder}"}),list:Vt({method:"GET",fullPath:"/v1/issuing/cardholders",methodType:"list"})});var Kt=n.method,ws=n.extend({deliverCard:Kt({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/deliver"}),failCard:Kt({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/fail"}),returnCard:Kt({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/return"}),shipCard:Kt({method:"POST",fullPath:"/v1/test_helpers/issuing/cards/{card}/shipping/ship"})});var jt=n.method,Rs=n.extend({create:jt({method:"POST",fullPath:"/v1/issuing/cards"}),retrieve:jt({method:"GET",fullPath:"/v1/issuing/cards/{card}"}),update:jt({method:"POST",fullPath:"/v1/issuing/cards/{card}"}),list:jt({method:"GET",fullPath:"/v1/issuing/cards",methodType:"list"})});var Qt=n.method,As=n.extend({create:Qt({method:"POST",fullPath:"/v1/billing_portal/configurations"}),retrieve:Qt({method:"GET",fullPath:"/v1/billing_portal/configurations/{configuration}"}),update:Qt({method:"POST",fullPath:"/v1/billing_portal/configurations/{configuration}"}),list:Qt({method:"GET",fullPath:"/v1/billing_portal/configurations",methodType:"list"})});var Qe=n.method,Cs=n.extend({create:Qe({method:"POST",fullPath:"/v1/terminal/configurations"}),retrieve:Qe({method:"GET",fullPath:"/v1/terminal/configurations/{configuration}"}),update:Qe({method:"POST",fullPath:"/v1/terminal/configurations/{configuration}"}),list:Qe({method:"GET",fullPath:"/v1/terminal/configurations",methodType:"list"}),del:Qe({method:"DELETE",fullPath:"/v1/terminal/configurations/{configuration}"})});var yc=n.method,Is=n.extend({create:yc({method:"POST",fullPath:"/v1/terminal/connection_tokens"})});var Yr=n.method,Ms=n.extend({create:Yr({method:"POST",fullPath:"/v1/treasury/credit_reversals"}),retrieve:Yr({method:"GET",fullPath:"/v1/treasury/credit_reversals/{credit_reversal}"}),list:Yr({method:"GET",fullPath:"/v1/treasury/credit_reversals",methodType:"list"})});var vc=n.method,Gs=n.extend({fundCashBalance:vc({method:"POST",fullPath:"/v1/test_helpers/customers/{customer}/fund_cash_balance"})});var Xr=n.method,Ds=n.extend({create:Xr({method:"POST",fullPath:"/v1/treasury/debit_reversals"}),retrieve:Xr({method:"GET",fullPath:"/v1/treasury/debit_reversals/{debit_reversal}"}),list:Xr({method:"GET",fullPath:"/v1/treasury/debit_reversals",methodType:"list"})});var Je=n.method,ks=n.extend({create:Je({method:"POST",fullPath:"/v1/issuing/disputes"}),retrieve:Je({method:"GET",fullPath:"/v1/issuing/disputes/{dispute}"}),update:Je({method:"POST",fullPath:"/v1/issuing/disputes/{dispute}"}),list:Je({method:"GET",fullPath:"/v1/issuing/disputes",methodType:"list"}),submit:Je({method:"POST",fullPath:"/v1/issuing/disputes/{dispute}/submit"})});var qs=n.method,Ns=n.extend({retrieve:qs({method:"GET",fullPath:"/v1/radar/early_fraud_warnings/{early_fraud_warning}"}),list:qs({method:"GET",fullPath:"/v1/radar/early_fraud_warnings",methodType:"list"})});var Re=n.method,Fs=n.extend({create:Re({method:"POST",fullPath:"/v1/treasury/financial_accounts"}),retrieve:Re({method:"GET",fullPath:"/v1/treasury/financial_accounts/{financial_account}"}),update:Re({method:"POST",fullPath:"/v1/treasury/financial_accounts/{financial_account}"}),list:Re({method:"GET",fullPath:"/v1/treasury/financial_accounts",methodType:"list"}),retrieveFeatures:Re({method:"GET",fullPath:"/v1/treasury/financial_accounts/{financial_account}/features"}),updateFeatures:Re({method:"POST",fullPath:"/v1/treasury/financial_accounts/{financial_account}/features"})});var Zr=n.method,Us=n.extend({fail:Zr({method:"POST",fullPath:"/v1/test_helpers/treasury/inbound_transfers/{id}/fail"}),returnInboundTransfer:Zr({method:"POST",fullPath:"/v1/test_helpers/treasury/inbound_transfers/{id}/return"}),succeed:Zr({method:"POST",fullPath:"/v1/test_helpers/treasury/inbound_transfers/{id}/succeed"})});var Jt=n.method,$s=n.extend({create:Jt({method:"POST",fullPath:"/v1/treasury/inbound_transfers"}),retrieve:Jt({method:"GET",fullPath:"/v1/treasury/inbound_transfers/{id}"}),list:Jt({method:"GET",fullPath:"/v1/treasury/inbound_transfers",methodType:"list"}),cancel:Jt({method:"POST",fullPath:"/v1/treasury/inbound_transfers/{inbound_transfer}/cancel"})});var Ye=n.method,Ls=n.extend({create:Ye({method:"POST",fullPath:"/v1/terminal/locations"}),retrieve:Ye({method:"GET",fullPath:"/v1/terminal/locations/{location}"}),update:Ye({method:"POST",fullPath:"/v1/terminal/locations/{location}"}),list:Ye({method:"GET",fullPath:"/v1/terminal/locations",methodType:"list"}),del:Ye({method:"DELETE",fullPath:"/v1/terminal/locations/{location}"})});var Xe=n.method,Hs=n.extend({create:Xe({method:"POST",fullPath:"/v1/climate/orders"}),retrieve:Xe({method:"GET",fullPath:"/v1/climate/orders/{order}"}),update:Xe({method:"POST",fullPath:"/v1/climate/orders/{order}"}),list:Xe({method:"GET",fullPath:"/v1/climate/orders",methodType:"list"}),cancel:Xe({method:"POST",fullPath:"/v1/climate/orders/{order}/cancel"})});var eo=n.method,Bs=n.extend({fail:eo({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}/fail"}),post:eo({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}/post"}),returnOutboundPayment:eo({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_payments/{id}/return"})});var Yt=n.method,Ws=n.extend({create:Yt({method:"POST",fullPath:"/v1/treasury/outbound_payments"}),retrieve:Yt({method:"GET",fullPath:"/v1/treasury/outbound_payments/{id}"}),list:Yt({method:"GET",fullPath:"/v1/treasury/outbound_payments",methodType:"list"}),cancel:Yt({method:"POST",fullPath:"/v1/treasury/outbound_payments/{id}/cancel"})});var to=n.method,zs=n.extend({fail:to({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail"}),post:to({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post"}),returnOutboundTransfer:to({method:"POST",fullPath:"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return"})});var Xt=n.method,Vs=n.extend({create:Xt({method:"POST",fullPath:"/v1/treasury/outbound_transfers"}),retrieve:Xt({method:"GET",fullPath:"/v1/treasury/outbound_transfers/{outbound_transfer}"}),list:Xt({method:"GET",fullPath:"/v1/treasury/outbound_transfers",methodType:"list"}),cancel:Xt({method:"POST",fullPath:"/v1/treasury/outbound_transfers/{outbound_transfer}/cancel"})});var Ks=n.method,js=n.extend({retrieve:Ks({method:"GET",fullPath:"/v1/climate/products/{product}"}),list:Ks({method:"GET",fullPath:"/v1/climate/products",methodType:"list"})});var Pc=n.method,Qs=n.extend({presentPaymentMethod:Pc({method:"POST",fullPath:"/v1/test_helpers/terminal/readers/{reader}/present_payment_method"})});var W=n.method,Js=n.extend({create:W({method:"POST",fullPath:"/v1/terminal/readers"}),retrieve:W({method:"GET",fullPath:"/v1/terminal/readers/{reader}"}),update:W({method:"POST",fullPath:"/v1/terminal/readers/{reader}"}),list:W({method:"GET",fullPath:"/v1/terminal/readers",methodType:"list"}),del:W({method:"DELETE",fullPath:"/v1/terminal/readers/{reader}"}),cancelAction:W({method:"POST",fullPath:"/v1/terminal/readers/{reader}/cancel_action"}),processPaymentIntent:W({method:"POST",fullPath:"/v1/terminal/readers/{reader}/process_payment_intent"}),processSetupIntent:W({method:"POST",fullPath:"/v1/terminal/readers/{reader}/process_setup_intent"}),refundPayment:W({method:"POST",fullPath:"/v1/terminal/readers/{reader}/refund_payment"}),setReaderDisplay:W({method:"POST",fullPath:"/v1/terminal/readers/{reader}/set_reader_display"})});var gc=n.method,Ys=n.extend({create:gc({method:"POST",fullPath:"/v1/test_helpers/treasury/received_credits"})});var Xs=n.method,Zs=n.extend({retrieve:Xs({method:"GET",fullPath:"/v1/treasury/received_credits/{id}"}),list:Xs({method:"GET",fullPath:"/v1/treasury/received_credits",methodType:"list"})});var Tc=n.method,ei=n.extend({create:Tc({method:"POST",fullPath:"/v1/test_helpers/treasury/received_debits"})});var ti=n.method,ri=n.extend({retrieve:ti({method:"GET",fullPath:"/v1/treasury/received_debits/{id}"}),list:ti({method:"GET",fullPath:"/v1/treasury/received_debits",methodType:"list"})});var _c=n.method,oi=n.extend({expire:_c({method:"POST",fullPath:"/v1/test_helpers/refunds/{refund}/expire"})});var Zt=n.method,ni=n.extend({create:Zt({method:"POST",fullPath:"/v1/tax/registrations"}),retrieve:Zt({method:"GET",fullPath:"/v1/tax/registrations/{id}"}),update:Zt({method:"POST",fullPath:"/v1/tax/registrations/{id}"}),list:Zt({method:"GET",fullPath:"/v1/tax/registrations",methodType:"list"})});var ro=n.method,si=n.extend({create:ro({method:"POST",fullPath:"/v1/reporting/report_runs"}),retrieve:ro({method:"GET",fullPath:"/v1/reporting/report_runs/{report_run}"}),list:ro({method:"GET",fullPath:"/v1/reporting/report_runs",methodType:"list"})});var ii=n.method,ai=n.extend({retrieve:ii({method:"GET",fullPath:"/v1/reporting/report_types/{report_type}"}),list:ii({method:"GET",fullPath:"/v1/reporting/report_types",methodType:"list"})});var li=n.method,ui=n.extend({retrieve:li({method:"GET",fullPath:"/v1/sigma/scheduled_query_runs/{scheduled_query_run}"}),list:li({method:"GET",fullPath:"/v1/sigma/scheduled_query_runs",methodType:"list"})});var er=n.method,ci=n.extend({create:er({method:"POST",fullPath:"/v1/apps/secrets"}),list:er({method:"GET",fullPath:"/v1/apps/secrets",methodType:"list"}),deleteWhere:er({method:"POST",fullPath:"/v1/apps/secrets/delete"}),find:er({method:"GET",fullPath:"/v1/apps/secrets/find"})});var Sc=n.method,pi=n.extend({create:Sc({method:"POST",fullPath:"/v1/billing_portal/sessions"})});var Ze=n.method,di=n.extend({create:Ze({method:"POST",fullPath:"/v1/checkout/sessions"}),retrieve:Ze({method:"GET",fullPath:"/v1/checkout/sessions/{session}"}),list:Ze({method:"GET",fullPath:"/v1/checkout/sessions",methodType:"list"}),expire:Ze({method:"POST",fullPath:"/v1/checkout/sessions/{session}/expire"}),listLineItems:Ze({method:"GET",fullPath:"/v1/checkout/sessions/{session}/line_items",methodType:"list"})});var hi=n.method,fi=n.extend({create:hi({method:"POST",fullPath:"/v1/financial_connections/sessions"}),retrieve:hi({method:"GET",fullPath:"/v1/financial_connections/sessions/{session}"})});var mi=n.method,yi=n.extend({retrieve:mi({method:"GET",fullPath:"/v1/tax/settings"}),update:mi({method:"POST",fullPath:"/v1/tax/settings"})});var vi=n.method,Pi=n.extend({retrieve:vi({method:"GET",fullPath:"/v1/climate/suppliers/{supplier}"}),list:vi({method:"GET",fullPath:"/v1/climate/suppliers",methodType:"list"})});var et=n.method,gi=n.extend({create:et({method:"POST",fullPath:"/v1/test_helpers/test_clocks"}),retrieve:et({method:"GET",fullPath:"/v1/test_helpers/test_clocks/{test_clock}"}),list:et({method:"GET",fullPath:"/v1/test_helpers/test_clocks",methodType:"list"}),del:et({method:"DELETE",fullPath:"/v1/test_helpers/test_clocks/{test_clock}"}),advance:et({method:"POST",fullPath:"/v1/test_helpers/test_clocks/{test_clock}/advance"})});var oo=n.method,Ti=n.extend({retrieve:oo({method:"GET",fullPath:"/v1/issuing/tokens/{token}"}),update:oo({method:"POST",fullPath:"/v1/issuing/tokens/{token}"}),list:oo({method:"GET",fullPath:"/v1/issuing/tokens",methodType:"list"})});var _i=n.method,Si=n.extend({retrieve:_i({method:"GET",fullPath:"/v1/treasury/transaction_entries/{id}"}),list:_i({method:"GET",fullPath:"/v1/treasury/transaction_entries",methodType:"list"})});var no=n.method,Ei=n.extend({createForceCapture:no({method:"POST",fullPath:"/v1/test_helpers/issuing/transactions/create_force_capture"}),createUnlinkedRefund:no({method:"POST",fullPath:"/v1/test_helpers/issuing/transactions/create_unlinked_refund"}),refund:no({method:"POST",fullPath:"/v1/test_helpers/issuing/transactions/{transaction}/refund"})});var xi=n.method,bi=n.extend({retrieve:xi({method:"GET",fullPath:"/v1/financial_connections/transactions/{transaction}"}),list:xi({method:"GET",fullPath:"/v1/financial_connections/transactions",methodType:"list"})});var so=n.method,Oi=n.extend({retrieve:so({method:"GET",fullPath:"/v1/issuing/transactions/{transaction}"}),update:so({method:"POST",fullPath:"/v1/issuing/transactions/{transaction}"}),list:so({method:"GET",fullPath:"/v1/issuing/transactions",methodType:"list"})});var tr=n.method,wi=n.extend({retrieve:tr({method:"GET",fullPath:"/v1/tax/transactions/{transaction}"}),createFromCalculation:tr({method:"POST",fullPath:"/v1/tax/transactions/create_from_calculation"}),createReversal:tr({method:"POST",fullPath:"/v1/tax/transactions/create_reversal"}),listLineItems:tr({method:"GET",fullPath:"/v1/tax/transactions/{transaction}/line_items",methodType:"list"})});var Ri=n.method,Ai=n.extend({retrieve:Ri({method:"GET",fullPath:"/v1/treasury/transactions/{id}"}),list:Ri({method:"GET",fullPath:"/v1/treasury/transactions",methodType:"list"})});var rr=n.method,Ci=n.extend({create:rr({method:"POST",fullPath:"/v1/radar/value_list_items"}),retrieve:rr({method:"GET",fullPath:"/v1/radar/value_list_items/{item}"}),list:rr({method:"GET",fullPath:"/v1/radar/value_list_items",methodType:"list"}),del:rr({method:"DELETE",fullPath:"/v1/radar/value_list_items/{item}"})});var tt=n.method,Ii=n.extend({create:tt({method:"POST",fullPath:"/v1/radar/value_lists"}),retrieve:tt({method:"GET",fullPath:"/v1/radar/value_lists/{value_list}"}),update:tt({method:"POST",fullPath:"/v1/radar/value_lists/{value_list}"}),list:tt({method:"GET",fullPath:"/v1/radar/value_lists",methodType:"list"}),del:tt({method:"DELETE",fullPath:"/v1/radar/value_lists/{value_list}"})});var Mi=n.method,Gi=n.extend({retrieve:Mi({method:"GET",fullPath:"/v1/identity/verification_reports/{report}"}),list:Mi({method:"GET",fullPath:"/v1/identity/verification_reports",methodType:"list"})});var Ae=n.method,Di=n.extend({create:Ae({method:"POST",fullPath:"/v1/identity/verification_sessions"}),retrieve:Ae({method:"GET",fullPath:"/v1/identity/verification_sessions/{session}"}),update:Ae({method:"POST",fullPath:"/v1/identity/verification_sessions/{session}"}),list:Ae({method:"GET",fullPath:"/v1/identity/verification_sessions",methodType:"list"}),cancel:Ae({method:"POST",fullPath:"/v1/identity/verification_sessions/{session}/cancel"}),redact:Ae({method:"POST",fullPath:"/v1/identity/verification_sessions/{session}/redact"})});var x=n.method,io=n.extend({create:x({method:"POST",fullPath:"/v1/accounts"}),retrieve(t,...e){return typeof t=="string"?x({method:"GET",fullPath:"/v1/accounts/{id}"}).apply(this,[t,...e]):(t==null&&[].shift.apply([t,...e]),x({method:"GET",fullPath:"/v1/account"}).apply(this,[t,...e]))},update:x({method:"POST",fullPath:"/v1/accounts/{account}"}),list:x({method:"GET",fullPath:"/v1/accounts",methodType:"list"}),del:x({method:"DELETE",fullPath:"/v1/accounts/{account}"}),createExternalAccount:x({method:"POST",fullPath:"/v1/accounts/{account}/external_accounts"}),createLoginLink:x({method:"POST",fullPath:"/v1/accounts/{account}/login_links"}),createPerson:x({method:"POST",fullPath:"/v1/accounts/{account}/persons"}),deleteExternalAccount:x({method:"DELETE",fullPath:"/v1/accounts/{account}/external_accounts/{id}"}),deletePerson:x({method:"DELETE",fullPath:"/v1/accounts/{account}/persons/{person}"}),listCapabilities:x({method:"GET",fullPath:"/v1/accounts/{account}/capabilities",methodType:"list"}),listExternalAccounts:x({method:"GET",fullPath:"/v1/accounts/{account}/external_accounts",methodType:"list"}),listPersons:x({method:"GET",fullPath:"/v1/accounts/{account}/persons",methodType:"list"}),reject:x({method:"POST",fullPath:"/v1/accounts/{account}/reject"}),retrieveCurrent:x({method:"GET",fullPath:"/v1/account"}),retrieveCapability:x({method:"GET",fullPath:"/v1/accounts/{account}/capabilities/{capability}"}),retrieveExternalAccount:x({method:"GET",fullPath:"/v1/accounts/{account}/external_accounts/{id}"}),retrievePerson:x({method:"GET",fullPath:"/v1/accounts/{account}/persons/{person}"}),updateCapability:x({method:"POST",fullPath:"/v1/accounts/{account}/capabilities/{capability}"}),updateExternalAccount:x({method:"POST",fullPath:"/v1/accounts/{account}/external_accounts/{id}"}),updatePerson:x({method:"POST",fullPath:"/v1/accounts/{account}/persons/{person}"})});var Ec=n.method,ki=n.extend({create:Ec({method:"POST",fullPath:"/v1/account_links"})});var xc=n.method,qi=n.extend({create:xc({method:"POST",fullPath:"/v1/account_sessions"})});var or=n.method,Ni=n.extend({create:or({method:"POST",fullPath:"/v1/apple_pay/domains"}),retrieve:or({method:"GET",fullPath:"/v1/apple_pay/domains/{domain}"}),list:or({method:"GET",fullPath:"/v1/apple_pay/domains",methodType:"list"}),del:or({method:"DELETE",fullPath:"/v1/apple_pay/domains/{domain}"})});var Ce=n.method,Fi=n.extend({retrieve:Ce({method:"GET",fullPath:"/v1/application_fees/{id}"}),list:Ce({method:"GET",fullPath:"/v1/application_fees",methodType:"list"}),createRefund:Ce({method:"POST",fullPath:"/v1/application_fees/{id}/refunds"}),listRefunds:Ce({method:"GET",fullPath:"/v1/application_fees/{id}/refunds",methodType:"list"}),retrieveRefund:Ce({method:"GET",fullPath:"/v1/application_fees/{fee}/refunds/{id}"}),updateRefund:Ce({method:"POST",fullPath:"/v1/application_fees/{fee}/refunds/{id}"})});var bc=n.method,Ui=n.extend({retrieve:bc({method:"GET",fullPath:"/v1/balance"})});var $i=n.method,Li=n.extend({retrieve:$i({method:"GET",fullPath:"/v1/balance_transactions/{id}"}),list:$i({method:"GET",fullPath:"/v1/balance_transactions",methodType:"list"})});var Ie=n.method,Hi=n.extend({create:Ie({method:"POST",fullPath:"/v1/charges"}),retrieve:Ie({method:"GET",fullPath:"/v1/charges/{charge}"}),update:Ie({method:"POST",fullPath:"/v1/charges/{charge}"}),list:Ie({method:"GET",fullPath:"/v1/charges",methodType:"list"}),capture:Ie({method:"POST",fullPath:"/v1/charges/{charge}/capture"}),search:Ie({method:"GET",fullPath:"/v1/charges/search",methodType:"search"})});var Bi=n.method,Wi=n.extend({retrieve:Bi({method:"GET",fullPath:"/v1/country_specs/{country}"}),list:Bi({method:"GET",fullPath:"/v1/country_specs",methodType:"list"})});var rt=n.method,zi=n.extend({create:rt({method:"POST",fullPath:"/v1/coupons"}),retrieve:rt({method:"GET",fullPath:"/v1/coupons/{coupon}"}),update:rt({method:"POST",fullPath:"/v1/coupons/{coupon}"}),list:rt({method:"GET",fullPath:"/v1/coupons",methodType:"list"}),del:rt({method:"DELETE",fullPath:"/v1/coupons/{coupon}"})});var te=n.method,Vi=n.extend({create:te({method:"POST",fullPath:"/v1/credit_notes"}),retrieve:te({method:"GET",fullPath:"/v1/credit_notes/{id}"}),update:te({method:"POST",fullPath:"/v1/credit_notes/{id}"}),list:te({method:"GET",fullPath:"/v1/credit_notes",methodType:"list"}),listLineItems:te({method:"GET",fullPath:"/v1/credit_notes/{credit_note}/lines",methodType:"list"}),listPreviewLineItems:te({method:"GET",fullPath:"/v1/credit_notes/preview/lines",methodType:"list"}),preview:te({method:"GET",fullPath:"/v1/credit_notes/preview"}),voidCreditNote:te({method:"POST",fullPath:"/v1/credit_notes/{id}/void"})});var Oc=n.method,Ki=n.extend({create:Oc({method:"POST",fullPath:"/v1/customer_sessions"})});var S=n.method,ji=n.extend({create:S({method:"POST",fullPath:"/v1/customers"}),retrieve:S({method:"GET",fullPath:"/v1/customers/{customer}"}),update:S({method:"POST",fullPath:"/v1/customers/{customer}"}),list:S({method:"GET",fullPath:"/v1/customers",methodType:"list"}),del:S({method:"DELETE",fullPath:"/v1/customers/{customer}"}),createBalanceTransaction:S({method:"POST",fullPath:"/v1/customers/{customer}/balance_transactions"}),createFundingInstructions:S({method:"POST",fullPath:"/v1/customers/{customer}/funding_instructions"}),createSource:S({method:"POST",fullPath:"/v1/customers/{customer}/sources"}),createTaxId:S({method:"POST",fullPath:"/v1/customers/{customer}/tax_ids"}),deleteDiscount:S({method:"DELETE",fullPath:"/v1/customers/{customer}/discount"}),deleteSource:S({method:"DELETE",fullPath:"/v1/customers/{customer}/sources/{id}"}),deleteTaxId:S({method:"DELETE",fullPath:"/v1/customers/{customer}/tax_ids/{id}"}),listBalanceTransactions:S({method:"GET",fullPath:"/v1/customers/{customer}/balance_transactions",methodType:"list"}),listCashBalanceTransactions:S({method:"GET",fullPath:"/v1/customers/{customer}/cash_balance_transactions",methodType:"list"}),listPaymentMethods:S({method:"GET",fullPath:"/v1/customers/{customer}/payment_methods",methodType:"list"}),listSources:S({method:"GET",fullPath:"/v1/customers/{customer}/sources",methodType:"list"}),listTaxIds:S({method:"GET",fullPath:"/v1/customers/{customer}/tax_ids",methodType:"list"}),retrieveBalanceTransaction:S({method:"GET",fullPath:"/v1/customers/{customer}/balance_transactions/{transaction}"}),retrieveCashBalance:S({method:"GET",fullPath:"/v1/customers/{customer}/cash_balance"}),retrieveCashBalanceTransaction:S({method:"GET",fullPath:"/v1/customers/{customer}/cash_balance_transactions/{transaction}"}),retrievePaymentMethod:S({method:"GET",fullPath:"/v1/customers/{customer}/payment_methods/{payment_method}"}),retrieveSource:S({method:"GET",fullPath:"/v1/customers/{customer}/sources/{id}"}),retrieveTaxId:S({method:"GET",fullPath:"/v1/customers/{customer}/tax_ids/{id}"}),search:S({method:"GET",fullPath:"/v1/customers/search",methodType:"search"}),updateBalanceTransaction:S({method:"POST",fullPath:"/v1/customers/{customer}/balance_transactions/{transaction}"}),updateCashBalance:S({method:"POST",fullPath:"/v1/customers/{customer}/cash_balance"}),updateSource:S({method:"POST",fullPath:"/v1/customers/{customer}/sources/{id}"}),verifySource:S({method:"POST",fullPath:"/v1/customers/{customer}/sources/{id}/verify"})});var nr=n.method,Qi=n.extend({retrieve:nr({method:"GET",fullPath:"/v1/disputes/{dispute}"}),update:nr({method:"POST",fullPath:"/v1/disputes/{dispute}"}),list:nr({method:"GET",fullPath:"/v1/disputes",methodType:"list"}),close:nr({method:"POST",fullPath:"/v1/disputes/{dispute}/close"})});var Ji=n.method,Yi=n.extend({create:Ji({method:"POST",fullPath:"/v1/ephemeral_keys",validator:(t,e)=>{if(!e.headers||!e.headers["Stripe-Version"])throw new Error("Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node")}}),del:Ji({method:"DELETE",fullPath:"/v1/ephemeral_keys/{key}"})});var Xi=n.method,Zi=n.extend({retrieve:Xi({method:"GET",fullPath:"/v1/events/{id}"}),list:Xi({method:"GET",fullPath:"/v1/events",methodType:"list"})});var ea=n.method,ta=n.extend({retrieve:ea({method:"GET",fullPath:"/v1/exchange_rates/{rate_id}"}),list:ea({method:"GET",fullPath:"/v1/exchange_rates",methodType:"list"})});var sr=n.method,ra=n.extend({create:sr({method:"POST",fullPath:"/v1/file_links"}),retrieve:sr({method:"GET",fullPath:"/v1/file_links/{link}"}),update:sr({method:"POST",fullPath:"/v1/file_links/{link}"}),list:sr({method:"GET",fullPath:"/v1/file_links",methodType:"list"})});var wc=(t,e,r)=>{let o=(Math.round(Math.random()*1e16)+Math.round(Math.random()*1e16)).toString();r["Content-Type"]=`multipart/form-data; boundary=${o}`;let s=new TextEncoder,i=new Uint8Array(0),a=s.encode(`\r 5 | `);function u(p){let h=i,d=p instanceof Uint8Array?p:new Uint8Array(s.encode(p));i=new Uint8Array(h.length+d.length+2),i.set(h),i.set(d,h.length),i.set(a,i.length-2)}function c(p){return`"${p.replace(/"|"/g,"%22").replace(/\r\n|\r|\n/g," ")}"`}let l=ds(e);for(let p in l){let h=l[p];if(u(`--${o}`),Object.prototype.hasOwnProperty.call(h,"data")){let d=h;u(`Content-Disposition: form-data; name=${c(p)}; filename=${c(d.name||"blob")}`),u(`Content-Type: ${d.type||"application/octet-stream"}`),u(""),u(d.data)}else u(`Content-Disposition: form-data; name=${c(p)}`),u(""),u(h)}return u(`--${o}--`),i};function oa(t,e,r,o){if(e=e||{},t!=="POST")return o(null,ee(e));this._stripe._platformFunctions.tryBufferData(e).then(s=>{let i=wc(t,s,r);return o(null,i)}).catch(s=>o(s,null))}var ao=n.method,na=n.extend({create:ao({method:"POST",fullPath:"/v1/files",headers:{"Content-Type":"multipart/form-data"},host:"files.stripe.com"}),retrieve:ao({method:"GET",fullPath:"/v1/files/{file}"}),list:ao({method:"GET",fullPath:"/v1/files",methodType:"list"}),requestDataProcessor:oa});var ot=n.method,sa=n.extend({create:ot({method:"POST",fullPath:"/v1/invoiceitems"}),retrieve:ot({method:"GET",fullPath:"/v1/invoiceitems/{invoiceitem}"}),update:ot({method:"POST",fullPath:"/v1/invoiceitems/{invoiceitem}"}),list:ot({method:"GET",fullPath:"/v1/invoiceitems",methodType:"list"}),del:ot({method:"DELETE",fullPath:"/v1/invoiceitems/{invoiceitem}"})});var k=n.method,ia=n.extend({create:k({method:"POST",fullPath:"/v1/invoices"}),retrieve:k({method:"GET",fullPath:"/v1/invoices/{invoice}"}),update:k({method:"POST",fullPath:"/v1/invoices/{invoice}"}),list:k({method:"GET",fullPath:"/v1/invoices",methodType:"list"}),del:k({method:"DELETE",fullPath:"/v1/invoices/{invoice}"}),finalizeInvoice:k({method:"POST",fullPath:"/v1/invoices/{invoice}/finalize"}),listLineItems:k({method:"GET",fullPath:"/v1/invoices/{invoice}/lines",methodType:"list"}),listUpcomingLines:k({method:"GET",fullPath:"/v1/invoices/upcoming/lines",methodType:"list"}),markUncollectible:k({method:"POST",fullPath:"/v1/invoices/{invoice}/mark_uncollectible"}),pay:k({method:"POST",fullPath:"/v1/invoices/{invoice}/pay"}),retrieveUpcoming:k({method:"GET",fullPath:"/v1/invoices/upcoming"}),search:k({method:"GET",fullPath:"/v1/invoices/search",methodType:"search"}),sendInvoice:k({method:"POST",fullPath:"/v1/invoices/{invoice}/send"}),updateLineItem:k({method:"POST",fullPath:"/v1/invoices/{invoice}/lines/{line_item_id}"}),voidInvoice:k({method:"POST",fullPath:"/v1/invoices/{invoice}/void"})});var Rc=n.method,aa=n.extend({retrieve:Rc({method:"GET",fullPath:"/v1/mandates/{mandate}"})});var la=n.method,lo="connect.stripe.com",ua=n.extend({basePath:"/",authorizeUrl(t,e){t=t||{},e=e||{};let r="oauth/authorize";return e.express&&(r=`express/${r}`),t.response_type||(t.response_type="code"),t.client_id||(t.client_id=this._stripe.getClientId()),t.scope||(t.scope="read_write"),`https://${lo}/${r}?${ee(t)}`},token:la({method:"POST",path:"oauth/token",host:lo}),deauthorize(t,...e){return t.client_id||(t.client_id=this._stripe.getClientId()),la({method:"POST",path:"oauth/deauthorize",host:lo}).apply(this,[t,...e])}});var U=n.method,ca=n.extend({create:U({method:"POST",fullPath:"/v1/payment_intents"}),retrieve:U({method:"GET",fullPath:"/v1/payment_intents/{intent}"}),update:U({method:"POST",fullPath:"/v1/payment_intents/{intent}"}),list:U({method:"GET",fullPath:"/v1/payment_intents",methodType:"list"}),applyCustomerBalance:U({method:"POST",fullPath:"/v1/payment_intents/{intent}/apply_customer_balance"}),cancel:U({method:"POST",fullPath:"/v1/payment_intents/{intent}/cancel"}),capture:U({method:"POST",fullPath:"/v1/payment_intents/{intent}/capture"}),confirm:U({method:"POST",fullPath:"/v1/payment_intents/{intent}/confirm"}),incrementAuthorization:U({method:"POST",fullPath:"/v1/payment_intents/{intent}/increment_authorization"}),search:U({method:"GET",fullPath:"/v1/payment_intents/search",methodType:"search"}),verifyMicrodeposits:U({method:"POST",fullPath:"/v1/payment_intents/{intent}/verify_microdeposits"})});var nt=n.method,pa=n.extend({create:nt({method:"POST",fullPath:"/v1/payment_links"}),retrieve:nt({method:"GET",fullPath:"/v1/payment_links/{payment_link}"}),update:nt({method:"POST",fullPath:"/v1/payment_links/{payment_link}"}),list:nt({method:"GET",fullPath:"/v1/payment_links",methodType:"list"}),listLineItems:nt({method:"GET",fullPath:"/v1/payment_links/{payment_link}/line_items",methodType:"list"})});var ir=n.method,da=n.extend({create:ir({method:"POST",fullPath:"/v1/payment_method_configurations"}),retrieve:ir({method:"GET",fullPath:"/v1/payment_method_configurations/{configuration}"}),update:ir({method:"POST",fullPath:"/v1/payment_method_configurations/{configuration}"}),list:ir({method:"GET",fullPath:"/v1/payment_method_configurations",methodType:"list"})});var st=n.method,ha=n.extend({create:st({method:"POST",fullPath:"/v1/payment_method_domains"}),retrieve:st({method:"GET",fullPath:"/v1/payment_method_domains/{payment_method_domain}"}),update:st({method:"POST",fullPath:"/v1/payment_method_domains/{payment_method_domain}"}),list:st({method:"GET",fullPath:"/v1/payment_method_domains",methodType:"list"}),validate:st({method:"POST",fullPath:"/v1/payment_method_domains/{payment_method_domain}/validate"})});var Me=n.method,fa=n.extend({create:Me({method:"POST",fullPath:"/v1/payment_methods"}),retrieve:Me({method:"GET",fullPath:"/v1/payment_methods/{payment_method}"}),update:Me({method:"POST",fullPath:"/v1/payment_methods/{payment_method}"}),list:Me({method:"GET",fullPath:"/v1/payment_methods",methodType:"list"}),attach:Me({method:"POST",fullPath:"/v1/payment_methods/{payment_method}/attach"}),detach:Me({method:"POST",fullPath:"/v1/payment_methods/{payment_method}/detach"})});var Ge=n.method,ma=n.extend({create:Ge({method:"POST",fullPath:"/v1/payouts"}),retrieve:Ge({method:"GET",fullPath:"/v1/payouts/{payout}"}),update:Ge({method:"POST",fullPath:"/v1/payouts/{payout}"}),list:Ge({method:"GET",fullPath:"/v1/payouts",methodType:"list"}),cancel:Ge({method:"POST",fullPath:"/v1/payouts/{payout}/cancel"}),reverse:Ge({method:"POST",fullPath:"/v1/payouts/{payout}/reverse"})});var it=n.method,ya=n.extend({create:it({method:"POST",fullPath:"/v1/plans"}),retrieve:it({method:"GET",fullPath:"/v1/plans/{plan}"}),update:it({method:"POST",fullPath:"/v1/plans/{plan}"}),list:it({method:"GET",fullPath:"/v1/plans",methodType:"list"}),del:it({method:"DELETE",fullPath:"/v1/plans/{plan}"})});var at=n.method,va=n.extend({create:at({method:"POST",fullPath:"/v1/prices"}),retrieve:at({method:"GET",fullPath:"/v1/prices/{price}"}),update:at({method:"POST",fullPath:"/v1/prices/{price}"}),list:at({method:"GET",fullPath:"/v1/prices",methodType:"list"}),search:at({method:"GET",fullPath:"/v1/prices/search",methodType:"search"})});var De=n.method,Pa=n.extend({create:De({method:"POST",fullPath:"/v1/products"}),retrieve:De({method:"GET",fullPath:"/v1/products/{id}"}),update:De({method:"POST",fullPath:"/v1/products/{id}"}),list:De({method:"GET",fullPath:"/v1/products",methodType:"list"}),del:De({method:"DELETE",fullPath:"/v1/products/{id}"}),search:De({method:"GET",fullPath:"/v1/products/search",methodType:"search"})});var ar=n.method,ga=n.extend({create:ar({method:"POST",fullPath:"/v1/promotion_codes"}),retrieve:ar({method:"GET",fullPath:"/v1/promotion_codes/{promotion_code}"}),update:ar({method:"POST",fullPath:"/v1/promotion_codes/{promotion_code}"}),list:ar({method:"GET",fullPath:"/v1/promotion_codes",methodType:"list"})});var z=n.method,Ta=n.extend({create:z({method:"POST",fullPath:"/v1/quotes"}),retrieve:z({method:"GET",fullPath:"/v1/quotes/{quote}"}),update:z({method:"POST",fullPath:"/v1/quotes/{quote}"}),list:z({method:"GET",fullPath:"/v1/quotes",methodType:"list"}),accept:z({method:"POST",fullPath:"/v1/quotes/{quote}/accept"}),cancel:z({method:"POST",fullPath:"/v1/quotes/{quote}/cancel"}),finalizeQuote:z({method:"POST",fullPath:"/v1/quotes/{quote}/finalize"}),listComputedUpfrontLineItems:z({method:"GET",fullPath:"/v1/quotes/{quote}/computed_upfront_line_items",methodType:"list"}),listLineItems:z({method:"GET",fullPath:"/v1/quotes/{quote}/line_items",methodType:"list"}),pdf:z({method:"GET",fullPath:"/v1/quotes/{quote}/pdf",host:"files.stripe.com",streaming:!0})});var lt=n.method,_a=n.extend({create:lt({method:"POST",fullPath:"/v1/refunds"}),retrieve:lt({method:"GET",fullPath:"/v1/refunds/{refund}"}),update:lt({method:"POST",fullPath:"/v1/refunds/{refund}"}),list:lt({method:"GET",fullPath:"/v1/refunds",methodType:"list"}),cancel:lt({method:"POST",fullPath:"/v1/refunds/{refund}/cancel"})});var uo=n.method,Sa=n.extend({retrieve:uo({method:"GET",fullPath:"/v1/reviews/{review}"}),list:uo({method:"GET",fullPath:"/v1/reviews",methodType:"list"}),approve:uo({method:"POST",fullPath:"/v1/reviews/{review}/approve"})});var Ac=n.method,Ea=n.extend({list:Ac({method:"GET",fullPath:"/v1/setup_attempts",methodType:"list"})});var pe=n.method,xa=n.extend({create:pe({method:"POST",fullPath:"/v1/setup_intents"}),retrieve:pe({method:"GET",fullPath:"/v1/setup_intents/{intent}"}),update:pe({method:"POST",fullPath:"/v1/setup_intents/{intent}"}),list:pe({method:"GET",fullPath:"/v1/setup_intents",methodType:"list"}),cancel:pe({method:"POST",fullPath:"/v1/setup_intents/{intent}/cancel"}),confirm:pe({method:"POST",fullPath:"/v1/setup_intents/{intent}/confirm"}),verifyMicrodeposits:pe({method:"POST",fullPath:"/v1/setup_intents/{intent}/verify_microdeposits"})});var lr=n.method,ba=n.extend({create:lr({method:"POST",fullPath:"/v1/shipping_rates"}),retrieve:lr({method:"GET",fullPath:"/v1/shipping_rates/{shipping_rate_token}"}),update:lr({method:"POST",fullPath:"/v1/shipping_rates/{shipping_rate_token}"}),list:lr({method:"GET",fullPath:"/v1/shipping_rates",methodType:"list"})});var ut=n.method,Oa=n.extend({create:ut({method:"POST",fullPath:"/v1/sources"}),retrieve:ut({method:"GET",fullPath:"/v1/sources/{source}"}),update:ut({method:"POST",fullPath:"/v1/sources/{source}"}),listSourceTransactions:ut({method:"GET",fullPath:"/v1/sources/{source}/source_transactions",methodType:"list"}),verify:ut({method:"POST",fullPath:"/v1/sources/{source}/verify"})});var de=n.method,wa=n.extend({create:de({method:"POST",fullPath:"/v1/subscription_items"}),retrieve:de({method:"GET",fullPath:"/v1/subscription_items/{item}"}),update:de({method:"POST",fullPath:"/v1/subscription_items/{item}"}),list:de({method:"GET",fullPath:"/v1/subscription_items",methodType:"list"}),del:de({method:"DELETE",fullPath:"/v1/subscription_items/{item}"}),createUsageRecord:de({method:"POST",fullPath:"/v1/subscription_items/{subscription_item}/usage_records"}),listUsageRecordSummaries:de({method:"GET",fullPath:"/v1/subscription_items/{subscription_item}/usage_record_summaries",methodType:"list"})});var ke=n.method,Ra=n.extend({create:ke({method:"POST",fullPath:"/v1/subscription_schedules"}),retrieve:ke({method:"GET",fullPath:"/v1/subscription_schedules/{schedule}"}),update:ke({method:"POST",fullPath:"/v1/subscription_schedules/{schedule}"}),list:ke({method:"GET",fullPath:"/v1/subscription_schedules",methodType:"list"}),cancel:ke({method:"POST",fullPath:"/v1/subscription_schedules/{schedule}/cancel"}),release:ke({method:"POST",fullPath:"/v1/subscription_schedules/{schedule}/release"})});var re=n.method,Aa=n.extend({create:re({method:"POST",fullPath:"/v1/subscriptions"}),retrieve:re({method:"GET",fullPath:"/v1/subscriptions/{subscription_exposed_id}"}),update:re({method:"POST",fullPath:"/v1/subscriptions/{subscription_exposed_id}"}),list:re({method:"GET",fullPath:"/v1/subscriptions",methodType:"list"}),cancel:re({method:"DELETE",fullPath:"/v1/subscriptions/{subscription_exposed_id}"}),deleteDiscount:re({method:"DELETE",fullPath:"/v1/subscriptions/{subscription_exposed_id}/discount"}),resume:re({method:"POST",fullPath:"/v1/subscriptions/{subscription}/resume"}),search:re({method:"GET",fullPath:"/v1/subscriptions/search",methodType:"search"})});var Ca=n.method,Ia=n.extend({retrieve:Ca({method:"GET",fullPath:"/v1/tax_codes/{id}"}),list:Ca({method:"GET",fullPath:"/v1/tax_codes",methodType:"list"})});var ur=n.method,Ma=n.extend({create:ur({method:"POST",fullPath:"/v1/tax_ids"}),retrieve:ur({method:"GET",fullPath:"/v1/tax_ids/{id}"}),list:ur({method:"GET",fullPath:"/v1/tax_ids",methodType:"list"}),del:ur({method:"DELETE",fullPath:"/v1/tax_ids/{id}"})});var cr=n.method,Ga=n.extend({create:cr({method:"POST",fullPath:"/v1/tax_rates"}),retrieve:cr({method:"GET",fullPath:"/v1/tax_rates/{tax_rate}"}),update:cr({method:"POST",fullPath:"/v1/tax_rates/{tax_rate}"}),list:cr({method:"GET",fullPath:"/v1/tax_rates",methodType:"list"})});var Da=n.method,ka=n.extend({create:Da({method:"POST",fullPath:"/v1/tokens"}),retrieve:Da({method:"GET",fullPath:"/v1/tokens/{token}"})});var ct=n.method,qa=n.extend({create:ct({method:"POST",fullPath:"/v1/topups"}),retrieve:ct({method:"GET",fullPath:"/v1/topups/{topup}"}),update:ct({method:"POST",fullPath:"/v1/topups/{topup}"}),list:ct({method:"GET",fullPath:"/v1/topups",methodType:"list"}),cancel:ct({method:"POST",fullPath:"/v1/topups/{topup}/cancel"})});var oe=n.method,Na=n.extend({create:oe({method:"POST",fullPath:"/v1/transfers"}),retrieve:oe({method:"GET",fullPath:"/v1/transfers/{transfer}"}),update:oe({method:"POST",fullPath:"/v1/transfers/{transfer}"}),list:oe({method:"GET",fullPath:"/v1/transfers",methodType:"list"}),createReversal:oe({method:"POST",fullPath:"/v1/transfers/{id}/reversals"}),listReversals:oe({method:"GET",fullPath:"/v1/transfers/{id}/reversals",methodType:"list"}),retrieveReversal:oe({method:"GET",fullPath:"/v1/transfers/{transfer}/reversals/{id}"}),updateReversal:oe({method:"POST",fullPath:"/v1/transfers/{transfer}/reversals/{id}"})});var pt=n.method,Fa=n.extend({create:pt({method:"POST",fullPath:"/v1/webhook_endpoints"}),retrieve:pt({method:"GET",fullPath:"/v1/webhook_endpoints/{webhook_endpoint}"}),update:pt({method:"POST",fullPath:"/v1/webhook_endpoints/{webhook_endpoint}"}),list:pt({method:"GET",fullPath:"/v1/webhook_endpoints",methodType:"list"}),del:pt({method:"DELETE",fullPath:"/v1/webhook_endpoints/{webhook_endpoint}"})});var Cc=I("apps",{Secrets:ci}),Ic=I("billingPortal",{Configurations:As,Sessions:pi}),Mc=I("checkout",{Sessions:di}),Gc=I("climate",{Orders:Hs,Products:js,Suppliers:Pi}),Dc=I("financialConnections",{Accounts:_s,Sessions:fi,Transactions:bi}),kc=I("identity",{VerificationReports:Gi,VerificationSessions:Di}),qc=I("issuing",{Authorizations:Es,Cardholders:Os,Cards:Rs,Disputes:ks,Tokens:Ti,Transactions:Oi}),Nc=I("radar",{EarlyFraudWarnings:Ns,ValueListItems:Ci,ValueLists:Ii}),Fc=I("reporting",{ReportRuns:si,ReportTypes:ai}),Uc=I("sigma",{ScheduledQueryRuns:ui}),$c=I("tax",{Calculations:bs,Registrations:ni,Settings:yi,Transactions:wi}),Lc=I("terminal",{Configurations:Cs,ConnectionTokens:Is,Locations:Ls,Readers:Js}),Hc=I("testHelpers",{Customers:Gs,Refunds:oi,TestClocks:gi,Issuing:I("issuing",{Authorizations:Ss,Cards:ws,Transactions:Ei}),Terminal:I("terminal",{Readers:Qs}),Treasury:I("treasury",{InboundTransfers:Us,OutboundPayments:Bs,OutboundTransfers:zs,ReceivedCredits:Ys,ReceivedDebits:ei})}),Bc=I("treasury",{CreditReversals:Ms,DebitReversals:Ds,FinancialAccounts:Fs,InboundTransfers:$s,OutboundPayments:Ws,OutboundTransfers:Vs,ReceivedCredits:Zs,ReceivedDebits:ri,TransactionEntries:Si,Transactions:Ai});var Wc=60,pr=class t{constructor(e,r){this._stripe=e,this._maxBufferedRequestMetric=r}_addHeadersDirectlyToObject(e,r){e.requestId=r["request-id"],e.stripeAccount=e.stripeAccount||r["stripe-account"],e.apiVersion=e.apiVersion||r["stripe-version"],e.idempotencyKey=e.idempotencyKey||r["idempotency-key"]}_makeResponseEvent(e,r,o){let s=Date.now(),i=s-e.request_start_time;return Ht({api_version:o["stripe-version"],account:o["stripe-account"],idempotency_key:o["idempotency-key"],method:e.method,path:e.path,status:r,request_id:this._getRequestId(o),elapsed:i,request_start_time:e.request_start_time,request_end_time:s})}_getRequestId(e){return e["request-id"]}_streamingResponseHandler(e,r,o){return s=>{let i=s.getHeaders(),a=()=>{let c=this._makeResponseEvent(e,s.getStatusCode(),i);this._stripe._emitter.emit("response",c),this._recordRequestMetrics(this._getRequestId(i),c.elapsed,r)},u=s.toStream(a);return this._addHeadersDirectlyToObject(u,i),o(null,u)}}_jsonResponseHandler(e,r,o){return s=>{let i=s.getHeaders(),a=this._getRequestId(i),u=s.getStatusCode(),c=this._makeResponseEvent(e,u,i);this._stripe._emitter.emit("response",c),s.toJSON().then(l=>{if(l.error){let p;throw typeof l.error=="string"&&(l.error={type:l.error,message:l.error_description}),l.error.headers=i,l.error.statusCode=u,l.error.requestId=a,u===401?p=new ye(l.error):u===403?p=new Fe(l.error):u===429?p=new ve(l.error):p=O.generate(l.error),p}return l},l=>{throw new me({message:"Invalid JSON received from the Stripe API",exception:l,requestId:i["request-id"]})}).then(l=>{this._recordRequestMetrics(a,c.elapsed,r);let p=s.getRawResponse();this._addHeadersDirectlyToObject(p,i),Object.defineProperty(l,"lastResponse",{enumerable:!1,writable:!1,value:p}),o(null,l)},l=>o(l,null))}}static _generateConnectionErrorMessage(e){return`An error occurred with our connection to Stripe.${e>0?` Request was retried ${e} times.`:""}`}static _shouldRetry(e,r,o,s){return s&&r===0&&M.CONNECTION_CLOSED_ERROR_CODES.includes(s.code)?!0:r>=o?!1:e?e.getHeaders()["stripe-should-retry"]==="false"?!1:e.getHeaders()["stripe-should-retry"]==="true"||e.getStatusCode()===409||e.getStatusCode()>=500:!0}_getSleepTimeInMS(e,r=null){let o=this._stripe.getInitialNetworkRetryDelay(),s=this._stripe.getMaxNetworkRetryDelay(),i=Math.min(o*Math.pow(e-1,2),s);return i*=.5*(1+Math.random()),i=Math.max(o,i),Number.isInteger(r)&&r<=Wc&&(i=Math.max(i,r)),i*1e3}_getMaxNetworkRetries(e={}){return e.maxNetworkRetries!==void 0&&Number.isInteger(e.maxNetworkRetries)?e.maxNetworkRetries:this._stripe.getMaxNetworkRetries()}_defaultIdempotencyKey(e,r){let o=this._getMaxNetworkRetries(r);return e==="POST"&&o>0?`stripe-node-retry-${this._stripe._platformFunctions.uuid4()}`:null}_makeHeaders(e,r,o,s,i,a,u){let c={Authorization:e?`Bearer ${e}`:this._stripe.getApiField("auth"),Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":this._getUserAgentString(),"X-Stripe-Client-User-Agent":s,"X-Stripe-Client-Telemetry":this._getTelemetryHeader(),"Stripe-Version":o,"Stripe-Account":this._stripe.getApiField("stripeAccount"),"Idempotency-Key":this._defaultIdempotencyKey(i,u)},l=i=="POST"||i=="PUT"||i=="PATCH";return(l||r)&&(l||Ve(`${i} method had non-zero contentLength but no payload is expected for this verb`),c["Content-Length"]=r),Object.assign(Ht(c),cs(a))}_getUserAgentString(){let e=this._stripe.getConstant("PACKAGE_VERSION"),r=this._stripe._appInfo?this._stripe.getAppInfoAsString():"";return`Stripe/v1 NodeBindings/${e} ${r}`.trim()}_getTelemetryHeader(){if(this._stripe.getTelemetryEnabled()&&this._stripe._prevRequestMetrics.length>0){let e=this._stripe._prevRequestMetrics.shift();return JSON.stringify({last_request_metrics:e})}}_recordRequestMetrics(e,r,o){if(this._stripe.getTelemetryEnabled()&&e)if(this._stripe._prevRequestMetrics.length>this._maxBufferedRequestMetric)Ve("Request metrics buffer is full, dropping telemetry message.");else{let s={request_id:e,request_duration_ms:r};o&&o.length>0&&(s.usage=o),this._stripe._prevRequestMetrics.push(s)}}_request(e,r,o,s,i,a={},u=[],c,l=null){let p,h=(m,y,P,_,E)=>setTimeout(m,this._getSleepTimeInMS(_,E),y,P,_+1),d=(m,y,P)=>{let _=a.settings&&a.settings.timeout&&Number.isInteger(a.settings.timeout)&&a.settings.timeout>=0?a.settings.timeout:this._stripe.getApiField("timeout"),E=this._stripe.getApiField("httpClient").makeRequest(r||this._stripe.getApiField("host"),this._stripe.getApiField("port"),o,e,y,p,this._stripe.getApiField("protocol"),_),v=Date.now(),b=Ht({api_version:m,account:y["Stripe-Account"],idempotency_key:y["Idempotency-Key"],method:e,path:o,request_start_time:v}),q=P||0,D=this._getMaxNetworkRetries(a.settings||{});this._stripe._emitter.emit("request",b),E.then(R=>t._shouldRetry(R,q,D)?h(d,m,y,q,R.getHeaders()["retry-after"]):a.streaming&&R.getStatusCode()<400?this._streamingResponseHandler(b,u,c)(R):this._jsonResponseHandler(b,u,c)(R)).catch(R=>{if(t._shouldRetry(null,q,D,R))return h(d,m,y,q,null);{let $=R.code&&R.code===M.TIMEOUT_ERROR_CODE;return c(new Ue({message:$?`Request aborted due to timeout being reached (${_}ms)`:t._generateConnectionErrorMessage(q),detail:R}))}})},f=(m,y)=>{if(m)return c(m);p=y,this._stripe.getClientUserAgent(P=>{var _,E;let v=this._stripe.getApiField("version"),b=this._makeHeaders(i,p.length,v,P,e,(_=a.headers)!==null&&_!==void 0?_:null,(E=a.settings)!==null&&E!==void 0?E:{});d(v,b,0)})};l?l(e,s,a.headers,f):f(null,ee(s||{}))}};function co(t){let e={DEFAULT_TOLERANCE:300,signature:null,constructEvent(l,p,h,d,f,m){try{this.signature.verifyHeader(l,p,h,d||e.DEFAULT_TOLERANCE,f,m)}catch(P){throw P instanceof fe&&(P.message+="\nUse `await constructEventAsync(...)` instead of `constructEvent(...)`"),P}return l instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(l)):JSON.parse(l)},async constructEventAsync(l,p,h,d,f,m){return await this.signature.verifyHeaderAsync(l,p,h,d||e.DEFAULT_TOLERANCE,f,m),l instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(l)):JSON.parse(l)},generateTestHeaderString:function(l){if(!l)throw new O({message:"Options are required"});return l.timestamp=Math.floor(l.timestamp)||Math.floor(Date.now()/1e3),l.scheme=l.scheme||r.EXPECTED_SCHEME,l.cryptoProvider=l.cryptoProvider||c(),l.signature=l.signature||l.cryptoProvider.computeHMACSignature(l.timestamp+"."+l.payload,l.secret),["t="+l.timestamp,l.scheme+"="+l.signature].join(",")}},r={EXPECTED_SCHEME:"v1",verifyHeader(l,p,h,d,f,m){let{decodedHeader:y,decodedPayload:P,details:_,suspectPayloadType:E}=s(l,p,this.EXPECTED_SCHEME),v=/\s/.test(h);f=f||c();let b=f.computeHMACSignature(o(P,_),h);return i(P,y,_,b,d,E,v,m),!0},async verifyHeaderAsync(l,p,h,d,f,m){let{decodedHeader:y,decodedPayload:P,details:_,suspectPayloadType:E}=s(l,p,this.EXPECTED_SCHEME),v=/\s/.test(h);f=f||c();let b=await f.computeHMACSignatureAsync(o(P,_),h);return i(P,y,_,b,d,E,v,m)}};function o(l,p){return`${p.timestamp}.${l}`}function s(l,p,h){if(!l)throw new F(p,l,{message:"No webhook payload was provided."});let d=typeof l!="string"&&!(l instanceof Uint8Array),f=new TextDecoder("utf8"),m=l instanceof Uint8Array?f.decode(l):l;if(Array.isArray(p))throw new Error("Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.");if(p==null||p=="")throw new F(p,l,{message:"No stripe-signature header value was provided."});let y=p instanceof Uint8Array?f.decode(p):p,P=a(y,h);if(!P||P.timestamp===-1)throw new F(y,m,{message:"Unable to extract timestamp and signatures from header"});if(!P.signatures.length)throw new F(y,m,{message:"No signatures found with expected scheme"});return{decodedPayload:m,decodedHeader:y,details:P,suspectPayloadType:d}}function i(l,p,h,d,f,m,y,P){let _=!!h.signatures.filter(t.secureCompare.bind(t,d)).length,E=` 6 | Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing`,v=y?` 7 | 8 | Note: The provided signing secret contains whitespace. This often indicates an extra newline or space is in the value`:"";if(!_)throw m?new F(p,l,{message:`Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body.Payload was provided as a parsed JavaScript object instead. 9 | Signature verification is impossible without access to the original signed material. 10 | `+E+` 11 | `+v}):new F(p,l,{message:`No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? 12 | If a webhook request is being forwarded by a third-party tool, ensure that the exact request body, including JSON formatting and new line style, is preserved. 13 | `+E+` 14 | `+v});let b=Math.floor((typeof P=="number"?P:Date.now())/1e3)-h.timestamp;if(f>0&&b>f)throw new F(p,l,{message:"Timestamp outside the tolerance zone"});return!0}function a(l,p){return typeof l!="string"?null:l.split(",").reduce((h,d)=>{let f=d.split("=");return f[0]==="t"&&(h.timestamp=parseInt(f[1],10)),f[0]===p&&h.signatures.push(f[1]),h},{timestamp:-1,signatures:[]})}let u=null;function c(){return u||(u=t.createDefaultCryptoProvider()),u}return e.signature=r,e}var Ua="api.stripe.com",$a="443",La="/v1/",Ha=ys,Ba=8e4,Wa=2,za=.5,zc=["name","version","url","partner_id"],Va=["apiVersion","typescript","maxNetworkRetries","httpAgent","httpClient","timeout","host","port","protocol","telemetry","appInfo","stripeAccount"],Vc=t=>new pr(t,n.MAX_BUFFERED_REQUEST_METRICS);function Ka(t,e=Vc){o.PACKAGE_VERSION="14.20.0",o.USER_AGENT=Object.assign({bindings_version:o.PACKAGE_VERSION,lang:"node",publisher:"stripe",uname:null,typescript:!1},hs()),o.StripeResource=n,o.resources=dt,o.HttpClient=M,o.HttpClientResponse=J,o.CryptoProvider=Q;function r(s=t){return co(s)}o.webhooks=Object.assign(r,co(t));function o(s,i={}){if(!(this instanceof o))return new o(s,i);let a=this._getPropsFromConfig(i);this._platformFunctions=t,Object.defineProperty(this,"_emitter",{value:this._platformFunctions.createEmitter(),enumerable:!1,configurable:!1,writable:!1}),this.VERSION=o.PACKAGE_VERSION,this.on=this._emitter.on.bind(this._emitter),this.once=this._emitter.once.bind(this._emitter),this.off=this._emitter.removeListener.bind(this._emitter);let u=a.httpAgent||null;this._api={auth:null,host:a.host||Ua,port:a.port||$a,protocol:a.protocol||"https",basePath:La,version:a.apiVersion||Ha,timeout:Bt("timeout",a.timeout,Ba),maxNetworkRetries:Bt("maxNetworkRetries",a.maxNetworkRetries,1),agent:u,httpClient:a.httpClient||(u?this._platformFunctions.createNodeHttpClient(u):this._platformFunctions.createDefaultHttpClient()),dev:!1,stripeAccount:a.stripeAccount||null};let c=a.typescript||!1;c!==o.USER_AGENT.typescript&&(o.USER_AGENT.typescript=c),a.appInfo&&this._setAppInfo(a.appInfo),this._prepResources(),this._setApiKey(s),this.errors=xt,this.webhooks=r(),this._prevRequestMetrics=[],this._enableTelemetry=a.telemetry!==!1,this._requestSender=e(this),this.StripeResource=o.StripeResource}return o.errors=xt,o.createNodeHttpClient=t.createNodeHttpClient,o.createFetchHttpClient=t.createFetchHttpClient,o.createNodeCryptoProvider=t.createNodeCryptoProvider,o.createSubtleCryptoProvider=t.createSubtleCryptoProvider,o.prototype={_appInfo:void 0,on:null,off:null,once:null,VERSION:null,StripeResource:null,webhooks:null,errors:null,_api:null,_prevRequestMetrics:null,_emitter:null,_enableTelemetry:null,_requestSender:null,_platformFunctions:null,_setApiKey(s){s&&this._setApiField("auth",`Bearer ${s}`)},_setAppInfo(s){if(s&&typeof s!="object")throw new Error("AppInfo must be an object.");if(s&&!s.name)throw new Error("AppInfo.name is required");s=s||{},this._appInfo=zc.reduce((i,a)=>(typeof s[a]=="string"&&(i=i||{},i[a]=s[a]),i),void 0)},_setApiField(s,i){this._api[s]=i},getApiField(s){return this._api[s]},setClientId(s){this._clientId=s},getClientId(){return this._clientId},getConstant:s=>{switch(s){case"DEFAULT_HOST":return Ua;case"DEFAULT_PORT":return $a;case"DEFAULT_BASE_PATH":return La;case"DEFAULT_API_VERSION":return Ha;case"DEFAULT_TIMEOUT":return Ba;case"MAX_NETWORK_RETRY_DELAY_SEC":return Wa;case"INITIAL_NETWORK_RETRY_DELAY_SEC":return za}return o[s]},getMaxNetworkRetries(){return this.getApiField("maxNetworkRetries")},_setApiNumberField(s,i,a){let u=Bt(s,i,a);this._setApiField(s,u)},getMaxNetworkRetryDelay(){return Wa},getInitialNetworkRetryDelay(){return za},getClientUserAgent(s){return this.getClientUserAgentSeeded(o.USER_AGENT,s)},getClientUserAgentSeeded(s,i){this._platformFunctions.getUname().then(a=>{var u;let c={};for(let p in s)c[p]=encodeURIComponent((u=s[p])!==null&&u!==void 0?u:"null");c.uname=encodeURIComponent(a||"UNKNOWN");let l=this.getApiField("httpClient");l&&(c.httplib=encodeURIComponent(l.getClientName())),this._appInfo&&(c.application=this._appInfo),i(JSON.stringify(c))})},getAppInfoAsString(){if(!this._appInfo)return"";let s=this._appInfo.name;return this._appInfo.version&&(s+=`/${this._appInfo.version}`),this._appInfo.url&&(s+=` (${this._appInfo.url})`),s},getTelemetryEnabled(){return this._enableTelemetry},_prepResources(){for(let s in dt)this[ps(s)]=new dt[s](this)},_getPropsFromConfig(s){if(!s)return{};let i=typeof s=="string";if(!(s===Object(s)&&!Array.isArray(s))&&!i)throw new Error("Config must either be an object or a string");if(i)return{apiVersion:s};if(Object.keys(s).filter(c=>!Va.includes(c)).length>0)throw new Error(`Config object may only contain the following: ${Va.join(", ")}`);return s}},o}var Kc=Ka(new Wt),ja=Kc;var dr=require("@aws-sdk/client-s3"),Ya=require("@aws-sdk/s3-request-presigner"),jc=new dr.S3Client({region:process.env.S3_REGION,credentials:{accessKeyId:process.env.S3_ACCESS_KEY_ID,secretAccessKey:process.env.S3_SECRET_ACCESS_KEY}});async function Qa(t,e,r,o){return new Promise((s,i)=>{let a={...Ja.default.parse(t),method:"POST",headers:{...r,"Content-Length":e.length}};if(o){let u=po.default.request(a,function(c){let l="";c.on("data",p=>{l+=p}),c.on("end",()=>{s(l)})});u.write(e),u.end()}else{let u=po.default.request(a);u.write(e),u.end(null,null,()=>{s(u)})}})}var Qc=async t=>{let e=new ja(t.stageVariables.stripe_secret_api_key);if(t.queryStringParameters){if(!t.queryStringParameters.session_id)return{statusCode:400,body:"Bad Request: Missing session_id query parameter."}}else return{statusCode:400,body:"Bad Request: No query parameters supplied."};let r=t.queryStringParameters.session_id,o,s=!1;for(let i=0;i<20;i++){try{if(o=await e.checkout.sessions.retrieve(r),o.payment_status==="paid"){s=!0,console.log(`Charge succeeded for session id ${r} after ${i+1} attempts. Environment: ${t.stageVariables.environment}.`);break}}catch(a){return console.error(`Failed to retrieve session: ${a.message} after ${i+1} attempts. Environment: ${t.stageVariables.environment}.`),{statusCode:400,body:`Payment exception. Contact ${process.env.support_email}. 15 | Error Details: Failed to retrieve session: ${a.message} after ${i+1} attempts. Environment: ${t.stageVariables.environment}.`}}await new Promise(a=>setTimeout(a,250))}if(s){let i=o?.customer_details?.email;i||(i=process.env.fallback_email);let a=new dr.GetObjectCommand({Bucket:process.env.bucket_name,Key:process.env.object_key}),u=await(0,Ya.getSignedUrl)(jc,a,{expiresIn:parseInt(process.env.link_expiration,10)}),c=`${process.env.redirect_host}${encodeURIComponent(u)}${process.env.utm_parameters}`,l={templateId:parseInt(process.env.brevo_template_id,10),to:[{email:i}],params:{download_url:c}},p="https://api.sendinblue.com/v3/smtp/email",h=JSON.stringify(l),d={"Content-Type":"application/json",Accept:"application/json","api-key":process.env.brevo_api_key};if(process.env.email_mode==="ensure-delivery")try{await Qa(p,h,d,!0),console.log(`Email was sent for session id ${r}.`)}catch(f){console.log(`Failed to send email for session id ${r}.`,f)}else await Qa(p,h,d,!1).then(()=>{console.log(`Email request was sent for session id ${r}.`)}).catch(f=>{console.log(`Failed to send email for session id ${r}.`,f)});return console.log(`Redirecting to ${c} in environment ${t.stageVariables.environment}.`),{statusCode:302,headers:{Location:c},body:""}}else return console.log(`Charge did not succeed for session id ${r}. Environment: ${t.stageVariables.environment}.`),{statusCode:400,body:`Payment exception. Contact ${process.env.support_email}. 16 | Error Details: Charge did not succeed for session id ${r}. Environment: ${t.stageVariables.environment}.`}};0&&(module.exports={handler}); 17 | --------------------------------------------------------------------------------