@stacksjs/orm 0.73.3 → 0.74.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,35 +1,22 @@
1
1
  // @bun
2
- var Xc=Object.defineProperty;var Yc=(e)=>e;function Zc(e,t){this[e]=Yc.bind(null,t)}var Ii=(e,t)=>{for(var n in t)Xc(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Zc.bind(t,n)})};var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var T=import.meta.require;var ar;var lr=f(()=>{ar={api:"api.stripe.com",files:"files.stripe.com",connect:"connect.stripe.com",meter_events:"meter-events.stripe.com"}});function z(e){return Gd(e)}function dl(e){return encodeURIComponent(e).replace(/!/g,"%21").replace(/\*/g,"%2A").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/'/g,"%27").replace(/%5B/g,"[").replace(/%5D/g,"]")}function Nd(e){if(e instanceof Date)return Math.floor(e.getTime()/1000).toString();if(e===null)return"";return String(e)}function Gd(e){let t=[];function n(i,r){if(r===void 0)return;if(r===null||typeof r!=="object"||r instanceof Date){t.push(dl(i)+"="+dl(Nd(r)));return}if(Array.isArray(r)){for(let o=0;o<r.length;o++)if(r[o]!==void 0)n(i+"["+o+"]",r[o]);return}for(let o of Object.keys(r))n(i+"["+o+"]",r[o])}if(typeof e==="object"&&e!==null)for(let i of Object.keys(e))n(i,e[i]);return t.join("&")}function Bd(e){return["number","string","boolean"].includes(typeof e)}function fi(e){let t={authenticator:null,headers:{},settings:{},streaming:!1,apiBase:null};if(!e)return t;if(e.apiKey)t.authenticator=cr(e.apiKey);if(e.idempotencyKey)t.headers["Idempotency-Key"]=e.idempotencyKey;if(e.stripeAccount)t.headers["Stripe-Account"]=e.stripeAccount;if(e.stripeContext){if(t.headers["Stripe-Account"])throw Error("Can't specify both stripeAccount and stripeContext.");t.headers["Stripe-Context"]=e.stripeContext}if(e.apiVersion)t.headers["Stripe-Version"]=e.apiVersion;if(Number.isInteger(e.maxNetworkRetries))t.settings.maxNetworkRetries=e.maxNetworkRetries;if(Number.isInteger(e.timeout))t.settings.timeout=e.timeout;if(e.authenticator){if(e.apiKey)throw Error("Can't specify both apiKey and authenticator.");if(typeof e.authenticator!=="function")throw Error("The authenticator must be a function receiving a request as the first parameter.");t.authenticator=e.authenticator}if(e.headers)Object.assign(t.headers,e.headers);if(e.streaming)t.streaming=!0;return t}function _i(e){if(typeof e!=="object")throw Error("Argument must be an object");return Object.keys(e).reduce((t,n)=>{if(e[n]!=null)t[n]=e[n];return t},{})}function ml(e){if(!(e&&typeof e==="object"))return e;return Object.keys(e).reduce((t,n)=>(t[Ld(n)]=e[n],t),{})}function Ld(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()).join("-")}function pl(e){if(e==="OAuth")return"oauth";else return e[0].toLowerCase()+e.substring(1)}function Kd(e){let t=typeof e;return(t==="function"||t==="object")&&!!e}function fl(e){let t={},n=(i,r)=>{Object.entries(i).forEach(([o,s])=>{let a=r?`${r}[${o}]`:o;if(Kd(s))if(!(s instanceof Uint8Array)&&!Object.prototype.hasOwnProperty.call(s,"data"))return n(s,a);else t[a]=s;else t[a]=String(s)})};return n(e,null),t}function ki(e,t,n){if(!Number.isInteger(t))if(n!==void 0)return n;else throw Error(`${e} must be an integer`);return t}function _l(e){for(let[t,n]of Hd)if(e[t])return n;return""}function cr(e){let t=(n)=>(n.headers.Authorization="Bearer "+e,Promise.resolve());return t._apiKey=e,t}function Vd(e,t){if(this[e]instanceof Date)return Math.floor(this[e].getTime()/1000).toString();return t}function kl(e){return JSON.stringify(e,Vd)}function bi(e){if(!e)return"v1";return e.startsWith("/v2")?"v2":"v1"}function gi(e){if(Array.isArray(e))return e.join(", ");return String(e)}function bl(e){return Object.entries(e).map(([t,n])=>[t,gi(n)])}function ge(e,t){if(!e||!e.stack||!t)return;let n=t.substring(t.indexOf(`
3
- `)+1),i=e.stack.indexOf(ul),r=i>=0?e.stack.substring(0,i):e.stack;e.stack=`${r}${ul}
4
- ${n}`}var be,Hd,ul=`
5
- Originating from:`;var W=f(()=>{lr();be=(()=>{let e={"\n":"\\n",'"':"\\\"","\u2028":"\\u2028","\u2029":"\\u2029"};return(t)=>{let n=t.replace(/["\n\r\u2028\u2029]/g,(i)=>e[i]);return(i)=>n.replace(/\{([\s\S]+?)\}/g,(r,o)=>{let s=i[o];if(Bd(s))return encodeURIComponent(s);return""})}})();Hd=[["ANTIGRAVITY_CLI_ALIAS","antigravity"],["CLAUDECODE","claude_code"],["CLINE_ACTIVE","cline"],["CODEX_SANDBOX","codex_cli"],["CODEX_THREAD_ID","codex_cli"],["CODEX_SANDBOX_NETWORK_DISABLED","codex_cli"],["CODEX_CI","codex_cli"],["CURSOR_AGENT","cursor"],["GEMINI_CLI","gemini_cli"],["OPENCLAW_SHELL","openclaw"],["OPENCODE","open_code"]]});class q{getClientName(){throw Error("getClientName not implemented.")}makeRequest(e,t,n,i,r,o,s,a){throw Error("makeRequest not implemented.")}static makeTimeoutError(){let e=TypeError(q.TIMEOUT_ERROR_CODE);return e.code=q.TIMEOUT_ERROR_CODE,e}}class he{constructor(e,t){this._statusCode=e,this._headers=t}getStatusCode(){return this._statusCode}getHeaders(){return this._headers}getRawResponse(){throw Error("getRawResponse not implemented.")}toStream(e){throw Error("toStream not implemented.")}toJSON(){throw Error("toJSON not implemented.")}}var hi=f(()=>{q.CONNECTION_CLOSED_ERROR_CODES=["ECONNRESET","EPIPE"];q.TIMEOUT_ERROR_CODE="ETIMEDOUT"});var ye,dr;var gl=f(()=>{W();hi();ye=class ye extends q{constructor(e){super();if(!e){if(!globalThis.fetch)throw Error("fetch() function not provided and is not defined in the global scope. You must provide a fetch implementation.");e=globalThis.fetch}if(globalThis.AbortController)this._fetchFn=ye.makeFetchWithAbortTimeout(e);else this._fetchFn=ye.makeFetchWithRaceTimeout(e)}static makeFetchWithRaceTimeout(e){return(t,n,i)=>{let r,o=new Promise((a,c)=>{r=setTimeout(()=>{r=null,c(q.makeTimeoutError())},i)}),s=e(t,n);return Promise.race([s,o]).finally(()=>{if(r)clearTimeout(r)})}}static makeFetchWithAbortTimeout(e){return async(t,n,i)=>{let r=new AbortController,o=setTimeout(()=>{o=null,r.abort(q.makeTimeoutError())},i);try{return await e(t,{...n,signal:r.signal})}catch(s){if(s.name==="AbortError")throw q.makeTimeoutError();else throw s}finally{if(o)clearTimeout(o)}}}getClientName(){return"fetch"}async makeRequest(e,t,n,i,r,o,s,a){let c=s==="http";if(!n.startsWith("/"))throw Error(`Only relative paths are supported, got: "${n}"`);let l=new URL(`${c?"http":"https"}://${e}${n}`);l.port=t;let u=i=="POST"||i=="PUT"||i=="PATCH",m=o||(u?"":void 0),p=await this._fetchFn(l.toString(),{method:i,headers:bl(r),body:m},a);return new dr(p)}};dr=class dr extends he{constructor(e){super(e.status,dr._transformHeadersToObject(e.headers));this._res=e}getRawResponse(){return this._res}toStream(e){return e(),this._res.body}toJSON(){return this._res.text().then((e)=>{try{return JSON.parse(e)}catch(t){if(t instanceof Error)t.rawBody=e;throw t}})}static _transformHeadersToObject(e){let t={};for(let n of e){if(!Array.isArray(n)||n.length!=2)throw 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.");t[n[0]]=n[1]}return t}}});class Re{computeHMACSignature(e,t){throw Error("computeHMACSignature not implemented.")}computeHMACSignatureAsync(e,t){throw Error("computeHMACSignatureAsync not implemented.")}computeSHA256Async(e){throw Error("computeSHA256 not implemented.")}}var we;var yi=f(()=>{we=class we extends Error{}});var mr,ur;var hl=f(()=>{yi();mr=class mr extends Re{constructor(e){super();this.subtleCrypto=e||crypto.subtle}computeHMACSignature(e,t){throw new we("SubtleCryptoProvider cannot be used in a synchronous context.")}async computeHMACSignatureAsync(e,t){let n=new TextEncoder,i=await this.subtleCrypto.importKey("raw",n.encode(t),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),r=await this.subtleCrypto.sign("hmac",i,n.encode(e)),o=new Uint8Array(r),s=Array(o.length);for(let a=0;a<o.length;a++)s[a]=ur[o[a]];return s.join("")}async computeSHA256Async(e){return new Uint8Array(await this.subtleCrypto.digest("SHA-256",e))}};ur=Array(256);for(let e=0;e<ur.length;e++)ur[e]=e.toString(16).padStart(2,"0")});class pr{constructor(){this._fetchFn=null,this._agent=null}getPlatformInfo(){return null}getTelemetryId(){return null}emitWarning(e){console.warn(`Stripe: ${e}`)}getEnv(){return null}getRuntimeVersion(){return null}uuid4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e)=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}secureCompare(e,t){if(e.length!==t.length)return!1;let n=e.length,i=0;for(let r=0;r<n;++r)i|=e.charCodeAt(r)^t.charCodeAt(r);return i===0}createEmitter(){throw Error("createEmitter not implemented.")}tryBufferData(e){throw Error("tryBufferData not implemented.")}createNodeHttpClient(e){throw Error("createNodeHttpClient not implemented.")}createFetchHttpClient(e){return new ye(e)}createDefaultHttpClient(){throw Error("createDefaultHttpClient not implemented.")}createNodeCryptoProvider(){throw Error("createNodeCryptoProvider not implemented.")}createSubtleCryptoProvider(e){return new mr(e)}createDefaultCryptoProvider(){throw Error("createDefaultCryptoProvider not implemented.")}}var yl=f(()=>{gl();hl()});class fr{constructor(){this.eventTarget=new EventTarget,this.listenerMapping=new Map}on(e,t){let n=(i)=>{t(i.data)};return this.listenerMapping.set(t,n),this.eventTarget.addEventListener(e,n)}removeListener(e,t){let n=this.listenerMapping.get(t);return this.listenerMapping.delete(t),this.eventTarget.removeEventListener(e,n)}once(e,t){let n=(i)=>{t(i.data)};return this.listenerMapping.set(t,n),this.eventTarget.addEventListener(e,n,{once:!0})}emit(e,t){return this.eventTarget.dispatchEvent(new Rl(e,t))}}var Rl;var wl=f(()=>{Rl=class Rl extends Event{constructor(e,t){super(e);this.data=t}}});var _r;var Tl=f(()=>{yl();wl();_r=class _r extends pr{createEmitter(){return new fr}tryBufferData(e){if(e.file.data instanceof ReadableStream)throw Error("Uploading a file as a stream is not supported in non-Node environments. Please open or upvote an issue at github.com/stripe/stripe-node if you use this, detailing your use-case.");return Promise.resolve(e)}createNodeHttpClient(){throw Error("Stripe: `createNodeHttpClient()` is not available in non-Node environments. Please use `createFetchHttpClient()` instead.")}createDefaultHttpClient(){return super.createFetchHttpClient()}createNodeCryptoProvider(){throw Error("Stripe: `createNodeCryptoProvider()` is not available in non-Node environments. Please use `createSubtleCryptoProvider()` instead.")}createDefaultCryptoProvider(){return this.createSubtleCryptoProvider()}}});class j{constructor(e,t){let[n,i]=j.normalize(e,t);this._coefficient=n,this._exponent=i,Object.freeze(this)}static normalize(e,t){if(e===0n)return[0n,0];let n=e,i=t;while(n!==0n&&n%10n===0n)n/=10n,i+=1;return[n,i]}static roundDivision(e,t,n,i){if(t===0n)return e;if(i==="round-down")return e;let r=t>0n===n>0n?1n:-1n;if(i==="round-up")return e+r;if(i==="ceil")return r===1n?e+1n:e;if(i==="floor")return r===-1n?e-1n:e;let o=t<0n?-t:t,s=n<0n?-n:n,a=o*2n,c;if(a===s)c=0;else if(a<s)c=-1;else c=1;if(c<0)return e;if(c>0)return e+r;if(i==="half-up")return e+r;if(i==="half-down")return e;if(e%2n===0n)return e;else return e+r}add(e){let t=e;if(this._exponent===t._exponent)return new j(this._coefficient+t._coefficient,this._exponent);if(this._exponent<t._exponent){let n=10n**BigInt(t._exponent-this._exponent);return new j(this._coefficient+t._coefficient*n,this._exponent)}else{let n=10n**BigInt(this._exponent-t._exponent);return new j(this._coefficient*n+t._coefficient,t._exponent)}}sub(e){let t=e;if(this._exponent===t._exponent)return new j(this._coefficient-t._coefficient,this._exponent);if(this._exponent<t._exponent){let n=10n**BigInt(t._exponent-this._exponent);return new j(this._coefficient-t._coefficient*n,this._exponent)}else{let n=10n**BigInt(this._exponent-t._exponent);return new j(this._coefficient*n-t._coefficient,t._exponent)}}mul(e){let t=e;return new j(this._coefficient*t._coefficient,this._exponent+t._exponent)}div(e,t,n){if(t<0||!Number.isInteger(t))throw Error("precision must be a non-negative integer");let i=e;if(i._coefficient===0n)throw Error("Division by zero");let r=this._exponent-i._exponent+t,o,s,a;if(r>=0){let l=this._coefficient*10n**BigInt(r);o=l/i._coefficient,s=l%i._coefficient,a=i._coefficient}else{let l=i._coefficient*10n**BigInt(-r);o=this._coefficient/l,s=this._coefficient%l,a=l}let c=j.roundDivision(o,s,a,n);return new j(c,-t)}cmp(e){let t=e;if(this._exponent===t._exponent){if(this._coefficient<t._coefficient)return-1;if(this._coefficient>t._coefficient)return 1;return 0}if(this._exponent<t._exponent){let n=10n**BigInt(t._exponent-this._exponent),i=t._coefficient*n;if(this._coefficient<i)return-1;if(this._coefficient>i)return 1;return 0}else{let n=10n**BigInt(this._exponent-t._exponent),i=this._coefficient*n;if(i<t._coefficient)return-1;if(i>t._coefficient)return 1;return 0}}eq(e){return this.cmp(e)===0}lt(e){return this.cmp(e)===-1}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)===1}gte(e){return this.cmp(e)>=0}isZero(){return this._coefficient===0n}isNegative(){return this._coefficient<0n}isPositive(){return this._coefficient>0n}neg(){return new j(-this._coefficient,this._exponent)}abs(){if(this._coefficient<0n)return new j(-this._coefficient,this._exponent);return this}round(e,t){let n=typeof t==="string"?zd[t]:t;if(n===void 0)throw Error(`Unknown rounding preset: "${t}"`);if(n.value<0||!Number.isInteger(n.value))throw Error("DecimalRoundingOptions.value must be a non-negative integer");if(n.mode==="decimal-places"){let u=this.toFixed(n.value,e);return M.from(u)}if(this._coefficient===0n)return this;let r=(this._coefficient<0n?(-this._coefficient).toString():this._coefficient.toString()).length;if(n.value===0)return M.zero;if(r<=n.value)return this;let o=r-n.value,s=10n**BigInt(o),a=this._coefficient/s,c=this._coefficient%s,l=j.roundDivision(a,c,s,e);return new j(l,this._exponent+o)}toString(){if(this._coefficient===0n)return"0";let e=this._coefficient.toString(),t=e.startsWith("-"),n=t?e.slice(1):e;if(this._exponent<0){let r=-this._exponent;if((r>=n.length?r-n.length:0)>30){if(n.length===1)return`${e}E${String(this._exponent)}`;let s=n[0]??"",a=n.slice(1),c=this._exponent+n.length-1;return`${t?"-":""}${s}.${a}E${String(c)}`}if(r>=n.length){let s="0".repeat(r-n.length);return`${t?"-":""}0.${s}${n}`}else{let s=n.slice(0,n.length-r),a=n.slice(n.length-r);return`${t?"-":""}${s}.${a}`}}if(n.length+this._exponent<=30){if(this._exponent===0)return e;let r="0".repeat(this._exponent);return`${t?"-":""}${n}${r}`}else{if(n.length===1)return`${e}E+${String(this._exponent)}`;let r=n[0]??"",o=n.slice(1),s=this._exponent+n.length-1;return`${t?"-":""}${r}.${o}E+${String(s)}`}}toJSON(){return this.toString()}toNumber(){return Number(this.toString())}toFixed(e,t){if(e<0||!Number.isInteger(e))throw Error("decimalPlaces must be a non-negative integer");let n=(r)=>{let o=r.toString(),s=o.startsWith("-"),a=s?o.slice(1):o;if(e===0)return o;if(e>=a.length){let c="0".repeat(e-a.length);return`${s?"-":""}0.${c}${a}`}else{let c=a.slice(0,a.length-e),l=a.slice(a.length-e);return`${s?"-":""}${c}.${l}`}},i=-e;if(this._exponent===i)return n(this._coefficient);if(this._exponent<i){let r=i-this._exponent,o=10n**BigInt(r),s=this._coefficient/o,a=this._coefficient%o,c=j.roundDivision(s,a,o,t);return n(c)}else{let r=this._exponent-i,o=this._coefficient*10n**BigInt(r);return n(o)}}valueOf(){return this.toString()}}var zd,M;var Ri=f(()=>{zd={"ubb-usage-count":{mode:"significant-figures",value:15},"v1-api":{mode:"decimal-places",value:12}};M={from(e){if(typeof e==="bigint")return new j(e,0);if(typeof e==="number"){if(!Number.isFinite(e))throw Error("Number must be finite");return M.from(e.toString())}let t=e.trim();if(t==="")throw Error("Cannot parse empty string as Decimal");let n=/^([+-]?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(t);if(!n)throw Error(`Invalid decimal string: ${e}`);let i=n[1]==="-"?-1n:1n,r=n[2]??"",o=n[3]??"",s=n[4]?Number(n[4]):0;if(!Number.isSafeInteger(s)||s>1e6||s<-1e6)throw Error(`Exponent out of range: ${String(n[4])} exceeds safe integer bounds`);let a=r+o,c=i*BigInt(a),l=s-o.length;if(!Number.isSafeInteger(l)||l>1e6||l<-1e6)throw Error(`Computed exponent out of range: ${String(l)} exceeds safe integer bounds`);return new j(c,l)},zero:new j(0n,0)}});var Si={};Ii(Si,{RateLimitError:()=>jr,StripeAPIError:()=>ve,StripeAuthenticationError:()=>hr,StripeCardError:()=>gr,StripeConnectionError:()=>Ti,StripeError:()=>P,StripeIdempotencyError:()=>vi,StripeInvalidClientError:()=>Tr,StripeInvalidGrantError:()=>wr,StripeInvalidRequestError:()=>wi,StripeInvalidScopeError:()=>Sr,StripeOAuthError:()=>L,StripeOAuthInvalidRequestError:()=>vr,StripePermissionError:()=>yr,StripeRateLimitError:()=>Rr,StripeSignatureVerificationError:()=>N,StripeUnsupportedGrantTypeError:()=>xr,StripeUnsupportedResponseTypeError:()=>Cr,TemporarySessionExpiredError:()=>Pr,generateOAuthError:()=>kr,generateV1Error:()=>Te,generateV2Error:()=>br});var Te=(e)=>{let t=e.statusCode;if(t===429||t===400&&e.code==="rate_limit")return new Rr(e);if(t===400||t===404){if(e.type==="idempotency_error")return new vi(e);return new wi(e)}if(t===401)return new hr(e);if(t===402)return new gr(e);if(t===403)return new yr(e);return new ve(e)},kr=(e)=>{switch(e.type){case"invalid_grant":return new wr(e);case"invalid_client":return new Tr(e);case"invalid_request":return new vr(e);case"invalid_scope":return new Sr(e);case"unsupported_grant_type":return new xr(e);case"unsupported_response_type":return new Cr(e);default:return new L(e)}},br=(e)=>{switch(e.type){case"idempotency_error":return new vi(e);case"rate_limit":return new jr(e);case"temporary_session_expired":return new Pr(e)}switch(e.code){case"invalid_fields":return new wi(e)}return Te(e)},P,gr,wi,ve,hr,yr,Rr,Ti,N,vi,L,wr,Tr,vr,Sr,xr,Cr,jr,Pr;var xi=f(()=>{P=class P extends Error{constructor(e={},t=null){super(e.message);this.type=t||this.constructor.name,this.raw=e,this.rawType=e.type,this.detail=e.detail,this.headers=e.headers,this.requestId=e.requestId,this.statusCode=e.statusCode,this.message=e.message??"",this.userMessage=e.user_message,this.advice_code=e.advice_code,this.charge=e.charge,this.code=e.code,this.decline_code=e.decline_code,this.doc_url=e.doc_url,this.network_advice_code=e.network_advice_code,this.network_decline_code=e.network_decline_code,this.param=e.param,this.payment_intent=e.payment_intent,this.payment_method=e.payment_method,this.payment_method_type=e.payment_method_type,this.request_log_url=e.request_log_url,this.setup_intent=e.setup_intent,this.source=e.source,this.user_message=e.user_message}};P.generate=Te;gr=class gr extends P{constructor(e={}){super(e,"StripeCardError");this.decline_code=e.decline_code??""}};wi=class wi extends P{constructor(e={}){super(e,"StripeInvalidRequestError")}};ve=class ve extends P{constructor(e={}){super(e,"StripeAPIError")}};hr=class hr extends P{constructor(e={}){super(e,"StripeAuthenticationError")}};yr=class yr extends P{constructor(e={}){super(e,"StripePermissionError")}};Rr=class Rr extends P{constructor(e={}){super(e,"StripeRateLimitError")}};Ti=class Ti extends P{constructor(e={}){super(e,"StripeConnectionError")}};N=class N extends P{constructor(e,t,n={}){super(n,"StripeSignatureVerificationError");this.header=e,this.payload=t}};vi=class vi extends P{constructor(e={}){super(e,"StripeIdempotencyError")}};L=class L extends P{constructor(e={},t="StripeOAuthError"){super(e,t)}};wr=class wr extends L{constructor(e={}){super(e,"StripeInvalidGrantError")}};Tr=class Tr extends L{constructor(e={}){super(e,"StripeInvalidClientError")}};vr=class vr extends L{constructor(e={}){super(e,"StripeOAuthInvalidRequestError")}};Sr=class Sr extends L{constructor(e={}){super(e,"StripeInvalidScopeError")}};xr=class xr extends L{constructor(e={}){super(e,"StripeUnsupportedGrantTypeError")}};Cr=class Cr extends L{constructor(e={}){super(e,"StripeUnsupportedResponseTypeError")}};jr=class jr extends P{constructor(e={}){super(e,"RateLimitError")}};Pr=class Pr extends P{constructor(e={}){super(e,"TemporarySessionExpiredError")}}});class re{constructor(e,t){this._stripe=e,this._maxBufferedRequestMetric=t}_normalizeStripeContext(e,t){if(e)return e.toString()||null;return t?.toString()||null}_addHeadersDirectlyToObject(e,t){e.requestId=t["request-id"],e.stripeAccount=e.stripeAccount||t["stripe-account"],e.apiVersion=e.apiVersion||t["stripe-version"],e.idempotencyKey=e.idempotencyKey||t["idempotency-key"]}_makeResponseEvent(e,t,n){let i=Date.now(),r=i-e.request_start_time;return _i({api_version:n["stripe-version"],account:n["stripe-account"],idempotency_key:n["idempotency-key"],method:e.method,path:e.path,status:t,request_id:this._getRequestId(n),elapsed:r,request_start_time:e.request_start_time,request_end_time:i})}_getRequestId(e){return e["request-id"]}_emitStripeNotice(e){let t=e["stripe-notice"];if(t)this._stripe._platformFunctions.emitWarning(typeof t==="string"?t:t[0])}_streamingResponseHandler(e,t,n){return(i)=>{let r=i.getHeaders();this._emitStripeNotice(r);let o=()=>{let a=this._makeResponseEvent(e,i.getStatusCode(),r);this._stripe._emitter.emit("response",a),this._recordRequestMetrics(this._getRequestId(r),a.elapsed,t)},s=i.toStream(o);return this._addHeadersDirectlyToObject(s,r),n(null,s)}}_jsonResponseHandler(e,t,n,i){return(r)=>{let o=r.getHeaders();this._emitStripeNotice(o);let s=this._getRequestId(o),a=r.getStatusCode(),c=this._makeResponseEvent(e,a,o);r.toJSON().then((l)=>{if(this._stripe.getEmitEventBodiesEnabled())c.body=l;if(l.error){let u=typeof l.error==="string";if(u)l.error={type:l.error,message:l.error_description};l.error.headers=o,l.error.statusCode=a,l.error.requestId=s;let m;if(u)m=kr(l.error);else if(t==="v2")m=br(l.error);else m=Te(l.error);throw m}return l},(l)=>{if(this._stripe.getEmitEventBodiesEnabled()&&l.rawBody)c.body=l.rawBody;throw new ve({message:"Invalid JSON received from the Stripe API",exception:l,requestId:o["request-id"]})}).then((l)=>{this._stripe._emitter.emit("response",c),this._recordRequestMetrics(s,c.elapsed,n);let u=r.getRawResponse();this._addHeadersDirectlyToObject(u,o),Object.defineProperty(l,"lastResponse",{enumerable:!1,writable:!1,value:u}),i(null,l)},(l)=>{this._stripe._emitter.emit("response",c),i(l,null)})}}static _generateConnectionErrorMessage(e){return`An error occurred with our connection to Stripe.${e>0?` Request was retried ${e} times.`:""}`}static _shouldRetry(e,t,n,i){if(i&&t===0&&q.CONNECTION_CLOSED_ERROR_CODES.includes(i.code))return!0;if(t>=n)return!1;if(!e)return!0;if(e.getHeaders()["stripe-should-retry"]==="false")return!1;if(e.getHeaders()["stripe-should-retry"]==="true")return!0;if(e.getStatusCode()===409)return!0;if(e.getStatusCode()>=500)return!0;return!1}_getSleepTimeInMS(e){let t=this._stripe.getInitialNetworkRetryDelay(),n=this._stripe.getMaxNetworkRetryDelay(),i=Math.min(t*Math.pow(2,e-1),n);return i*=0.5*(1+Math.random()),i=Math.max(t,i),i*1000}_getMaxNetworkRetries(e={}){return e.maxNetworkRetries!==void 0&&Number.isInteger(e.maxNetworkRetries)?e.maxNetworkRetries:this._stripe.getMaxNetworkRetries()}_defaultIdempotencyKey(e,t,n){let i=this._getMaxNetworkRetries(t),r=()=>`stripe-node-retry-${this._stripe._platformFunctions.uuid4()}`;if(n==="v2"){if(e==="POST"||e==="DELETE")return r()}else if(n==="v1"){if(e==="POST"&&i>0)return r()}return null}_makeHeaders({contentType:e,contentLength:t,apiVersion:n,clientUserAgent:i,method:r,userSuppliedHeaders:o,userSuppliedSettings:s,stripeAccount:a,stripeContext:c,apiMode:l}){let u={Accept:"application/json","Content-Type":e,"User-Agent":this._getUserAgentString(l),"X-Stripe-Client-User-Agent":i,"X-Stripe-Client-Telemetry":this._getTelemetryHeader(),"Stripe-Version":n,"Stripe-Account":a,"Stripe-Context":c,"Idempotency-Key":this._defaultIdempotencyKey(r,s,l)},m=r=="POST"||r=="PUT"||r=="PATCH";if(m||t){if(!m)this._stripe._platformFunctions.emitWarning(`${r} method had non-zero contentLength but no payload is expected for this verb`);u["Content-Length"]=t}return Object.assign(_i(u),ml(o))}_getUserAgentString(e){let t=this._stripe.getConstant("PACKAGE_VERSION"),n=this._stripe._appInfo?this._stripe.getAppInfoAsString():"",i=this._stripe.getConstant("AI_AGENT"),r=`Stripe/${e} NodeBindings/${t}`;if(n)r+=` ${n}`;if(i)r+=` AIAgent/${i}`;return r}_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,t,n){if(this._stripe.getTelemetryEnabled()&&e)if(this._stripe._prevRequestMetrics.length>this._maxBufferedRequestMetric)this._stripe._platformFunctions.emitWarning("Request metrics buffer is full, dropping telemetry message.");else{let i={request_id:e,request_duration_ms:t};if(n&&n.length>0)i.usage=n;this._stripe._prevRequestMetrics.push(i)}}_rawRequest(e,t,n,i,r){return new Promise((o,s)=>{try{let a=e.toUpperCase();if(a!=="POST"&&n&&Object.keys(n).length!==0)throw Error("rawRequest only supports params on POST requests. Please pass null and add your parameters to path.");let c=a==="POST"?Object.assign({},n):null,l=fi(i);if(i?.additionalHeaders)Object.assign(l.headers,i.additionalHeaders);let u=l.apiBase||(i?.apiBase??null),m=u?this._stripe.resolveBaseAddress(u):null;this._request(a,m,t,c,l.authenticator,{headers:l.headers,settings:l.settings,streaming:l.streaming},r||["raw_request"],(p,k)=>{if(p)s(p);else o(k)})}catch(a){s(a)}})}_getContentLength(e){return typeof e==="string"?new TextEncoder().encode(e).length:e.length}_request(e,t,n,i,r,o,s=[],a,c=null){let l;r=r??this._stripe._authenticator;let u=bi(n),m=(_,g,y,R)=>setTimeout(_,this._getSleepTimeInMS(R),g,y,R+1),p=(_,g,y)=>{let R=o.settings&&o.settings.timeout&&Number.isInteger(o.settings.timeout)&&o.settings.timeout>=0?o.settings.timeout:this._stripe.getApiField("timeout"),w={host:t||this._stripe.getApiField("host"),port:this._stripe.getApiField("port"),path:n,method:e,headers:Object.assign({},g),body:l,protocol:this._stripe.getApiField("protocol")};if(!r)throw Error("Authenticator was't initialized. Please pass an API Key or an Authenticator when initializing StripeClient.");r(w).then(()=>{let S=this._stripe.getApiField("httpClient").makeRequest(w.host,w.port,w.path,w.method,w.headers,w.body,w.protocol,R),C=Date.now(),U=_i({api_version:_,account:gi(g["Stripe-Account"]),idempotency_key:gi(g["Idempotency-Key"]),method:e,path:n,body:this._stripe.getEmitEventBodiesEnabled()?i??void 0:void 0,request_start_time:C}),X=y||0,oi=this._getMaxNetworkRetries(o.settings||{});this._stripe._emitter.emit("request",U),S.then((O)=>{if(re._shouldRetry(O,X,oi))return m(p,_,g,X);else if(o.streaming&&O.getStatusCode()<400)return this._streamingResponseHandler(U,s,a)(O);else return this._jsonResponseHandler(U,u,s,a)(O)}).catch((O)=>{if(re._shouldRetry(null,X,oi,O))return m(p,_,g,X);else{let de=O.code&&O.code===q.TIMEOUT_ERROR_CODE;return a(new Ti({message:de?`Request aborted due to timeout being reached (${R}ms)`:re._generateConnectionErrorMessage(X),detail:O}))}})}).catch((S)=>{throw new P({message:"Unable to authenticate the request",exception:S})})},k=(_,g)=>{if(_)return a(_);l=g,this._stripe.getClientUserAgent((y)=>{let R=this._stripe.getApiField("version"),w=this._makeHeaders({contentType:u=="v2"?"application/json":"application/x-www-form-urlencoded",contentLength:this._getContentLength(g),apiVersion:R,clientUserAgent:y,method:e,userSuppliedHeaders:o.headers??null,userSuppliedSettings:o.settings??{},stripeAccount:o.stripeAccount??this._stripe.getApiField("stripeAccount"),stripeContext:this._normalizeStripeContext(o.stripeContext,this._stripe.getApiField("stripeContext")),apiMode:u});p(R,w,0)})};if(c)c(e,i,o.headers,k);else{let _;if(u=="v2")_=i?kl(i):"";else _=z(i||{});k(null,_)}}}var vl=f(()=>{xi();hi();W()});var Se=(e,t)=>{if(e==null)return e;switch(t.kind){case"int64_string":return typeof e==="bigint"||typeof e==="number"?String(e):e;case"decimal_string":return typeof e.toFixed==="function"&&typeof e.isZero==="function"?e.toString():e;case"object":{if(typeof e!=="object"||Array.isArray(e))return e;let n=e,i={};for(let r of Object.keys(n)){let o=t.fields[r];i[r]=o?Se(n[r],o):n[r]}return i}case"array":{if(!Array.isArray(e))return e;return e.map((n)=>Se(n,t.element))}case"nullable":return Se(e,t.inner)}},xe=(e,t)=>{if(e==null)return e;switch(t.kind){case"int64_string":if(typeof e==="string")try{return BigInt(e)}catch{throw Error(`Failed to coerce int64_string value: expected an integer string, got '${e}'`)}return e;case"decimal_string":if(typeof e==="string")try{return M.from(e)}catch{throw Error(`Failed to coerce decimal_string value: expected a decimal string, got '${e}'`)}return e;case"object":{if(typeof e!=="object"||Array.isArray(e))return e;let n=e;for(let i of Object.keys(t.fields))if(i in n)n[i]=xe(n[i],t.fields[i]);return n}case"array":{if(!Array.isArray(e))return e;for(let n=0;n<e.length;n++)e[n]=xe(e[n],t.element);return e}case"nullable":return xe(e,t.inner)}};var Sl=f(()=>{Ri()});class qr{constructor(e,t,n,i,r,o,s){this.index=0,this.pagePromise=e,this.promiseCache={currentPromise:null},this.params=t,this.options=n,this.method=i,this.path=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 t=!!this.params.ending_before;if(this.index<e.data.length){let n=t?e.data.length-1-this.index:this.index,i=e.data[n];return this.index+=1,{value:i,done:!1}}else if(e.has_more){this.index=0,this.pagePromise=this.getNextPage(e);let n=await this.pagePromise;return this.iterate(n)}return{done:!0,value:void 0}}getNextPage(e){throw Error("Unimplemented")}async _next(){return this.iterate(await this.pagePromise)}next(){if(this.promiseCache.currentPromise)return this.promiseCache.currentPromise;let e=(async()=>{let t=await this._next();return this.promiseCache.currentPromise=null,t})();return this.promiseCache.currentPromise=e,e}}class jl{constructor(e,t,n,i){this.firstPagePromise=e,this.currentPageIterator=null,this.nextPageUrl=null,this.promiseCache={currentPromise:null},this.options=t,this.spec=n,this.stripeResource=i}async initFirstPage(){if(this.firstPagePromise){let e=await this.firstPagePromise;this.firstPagePromise=null,this.currentPageIterator=e.data[Symbol.iterator](),this.nextPageUrl=e.next_page_url||null}}async turnPage(){if(!this.nextPageUrl)return null;let e=await this.stripeResource._makeRequest("GET",this.nextPageUrl,void 0,this.options,this.spec);return this.nextPageUrl=e.next_page_url||null,this.currentPageIterator=e.data[Symbol.iterator](),this.currentPageIterator}async _next(){if(await this.initFirstPage(),this.currentPageIterator){let e=this.currentPageIterator.next();if(!e.done)return{done:!1,value:e.value}}return this.nextFromNewPage()}async nextFromNewPage(){let e=await this.turnPage();if(!e)return{done:!0,value:void 0};let t=e.next();if(!t.done)return{done:!1,value:t.value};return this.nextFromNewPage()}next(){if(this.promiseCache.currentPromise)return this.promiseCache.currentPromise;let e=(async()=>{try{return await this._next()}finally{this.promiseCache.currentPromise=null}})();return this.promiseCache.currentPromise=e,e}}function Wd(){if(typeof Symbol<"u"&&Symbol.asyncIterator)return Symbol.asyncIterator;return"@@asyncIterator"}function Qd(e){if(e.length<2)return null;let t=e[1];if(typeof t!=="function")throw Error(`The second argument to autoPagingEach, if present, must be a callback function; received ${typeof t}`);return t}function Jd(e){if(e.length===0)return;let t=e[0];if(typeof t!=="function")throw Error(`The first argument to autoPagingEach, if present, must be a callback function; received ${typeof t}`);if(t.length===2)return t;if(t.length>2)throw Error(`The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${t}`);return function(i,r){let o=t(i);r(o)}}function Xd(e,t){let n=t?0:e.data.length-1,i=e.data[n],r=i&&i.id;if(!r)throw Error("Unexpected: No `id` found on the last item while auto-paging a list.");return r}function Yd(e){return function(){let n=Error().stack,i=[].slice.call(arguments),r=Jd(i),o=Qd(i);if(i.length>2)throw Error(`autoPagingEach takes up to two arguments; received ${i}`);let s=eu(e,r).catch((a)=>{throw ge(a,n),a});if(o)s.then(()=>o(),(a)=>o(a));return s}}function Zd(e){return function(n,i){let r=Error().stack,o=n&&n.limit;if(!o)throw Error("You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.");if(o>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 s=new Promise((a,c)=>{let l=[];e((u)=>{if(l.push(u),l.length>=o)return!1}).then(()=>{a(l)}).catch((u)=>{ge(u,r),c(u)})});if(i)s.then((a)=>i(null,a),(a)=>i(a));return s}}function eu(e,t){return new Promise((n,i)=>{function r(o){if(o.done){n();return}let s=o.value;return new Promise((a)=>{t(s,a)}).then((a)=>{if(a===!1)return r({done:!0,value:void 0});else return e().then(r)})}e().then(r).catch(i)})}var xl,Cl,Pl=(e,t,n,i,r,o,s)=>{let a=bi(r),c=o?.methodType;if(a!=="v2"&&c==="search")return Er(new Cl(s,t,n,i,r,o,e));if(a!=="v2"&&c==="list")return Er(new xl(s,t,n,i,r,o,e));if(a==="v2"&&c==="list")return Er(new jl(s,n,o,e));return null},Er=(e)=>{let t=Yd((...r)=>e.next(...r)),n=Zd(t),i={autoPagingEach:t,autoPagingToArray:n,next:()=>e.next(),return:()=>({}),[Wd()]:()=>i};return i};var El=f(()=>{W();xl=class xl extends qr{getNextPage(e){let t=!!this.params.ending_before,n=Xd(e,t),i={...this.params,[t?"ending_before":"starting_after"]:n};return this.stripeResource._makeRequest(this.method,this.path,i,this.options,this.spec)}};Cl=class Cl extends qr{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.");let t={...this.params,page:e.next_page};return this.stripeResource._makeRequest(this.method,this.path,t,this.options,this.spec)}}});class d{constructor(e,t){if(this.resourcePath="",this.requestDataProcessor=null,this._stripe=e,t)throw Error("Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.");this.basePath=be(this.basePath||e.getApiField("basePath"));let n=this.path||"";this.resourcePath=n,this.path=be(n),this.initialize(e,t)}initialize(e,t){}_makeRequest(e,t,n,i,r){let o=e.toUpperCase(),a=(r?.encode||((S)=>S))(n?{...n}:{}),c=fi(i),l=c.apiBase||r?.apiBase||null,u=l?this._stripe.resolveBaseAddress(l):null,m=c.streaming||!!r?.streaming,p=Object.assign(c.headers,r?.headers),k=r?.usage||[],_=o==="GET"||o==="DELETE",g=_?null:a,y=_?a:{};try{if(r?.validator)r.validator(a,{headers:p});if(r?.requestSchema&&g)g=Se(g,r.requestSchema)}catch(S){return Promise.reject(S)}let R=Error().stack,w=new Promise((S,C)=>{function U(O,de){if(O)ge(O,R),C(O);else try{if(r?.responseSchema)xe(de,r.responseSchema);S(r?.transformResponseData?r.transformResponseData(de):de)}catch(Jc){C(Jc)}}let X=Object.keys(y).length===0,oi=[t,X?"":"?",z(y)].join("");this._stripe._requestSender._request(o,u,oi,g,c.authenticator,{headers:p,settings:c.settings,streaming:m},k,U,this.requestDataProcessor?.bind(this))});if(r?.methodType)Object.assign(w,Pl(this,n?{...n}:{},i,o,t,r,w));return w}}var b=f(()=>{W();Sl();El();d.MAX_BUFFERED_REQUEST_METRICS=100});class K{constructor(e=[]){this._segments=[...e]}get segments(){return[...this._segments]}push(e){if(!e)throw Error("Segment cannot be null or undefined");return new K([...this._segments,e])}pop(){if(this._segments.length===0)throw Error("Cannot pop from an empty context");return new K(this._segments.slice(0,-1))}toString(){return this._segments.join("/")}static parse(e){if(!e)return new K([]);return new K(e.split("/"))}}function ql(e){let t={DEFAULT_TOLERANCE:300,signature:null,constructEvent(u,m,p,k,_,g){try{if(!this.signature)throw Error("ERR: missing signature helper, unable to verify");_=_||c(),this.signature.verifyHeader(u,m,p,k||t.DEFAULT_TOLERANCE,_,g)}catch(R){if(R instanceof we)R.message+="\nUse `await constructEventAsync(...)` instead of `constructEvent(...)`";throw R}let y=u instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(u)):JSON.parse(u);if(y&&y.object==="v2.core.event")throw Error("You passed an event notification to stripe.webhooks.constructEvent, which expects a webhook payload. Use stripe.parseEventNotification instead.");return y},async constructEventAsync(u,m,p,k,_,g){if(!this.signature)throw Error("ERR: missing signature helper, unable to verify");_=_||c(),await this.signature.verifyHeaderAsync(u,m,p,k||t.DEFAULT_TOLERANCE,_,g);let y=u instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(u)):JSON.parse(u);if(y&&y.object==="v2.core.event")throw Error("You passed an event notification to stripe.webhooks.constructEvent, which expects a webhook payload. Use stripe.parseEventNotificationAsync instead.");return y},generateTestHeaderString:function(u){let m=l(u),p=m.signature||m.cryptoProvider.computeHMACSignature(m.payloadString,m.secret);return m.generateHeaderString(p)},generateTestHeaderStringAsync:async function(u){let m=l(u),p=m.signature||await m.cryptoProvider.computeHMACSignatureAsync(m.payloadString,m.secret);return m.generateHeaderString(p)}},n={EXPECTED_SCHEME:"v1",verifyHeader(u,m,p,k,_,g){let{decodedHeader:y,decodedPayload:R,details:w,suspectPayloadType:S}=r(u,m,this.EXPECTED_SCHEME),C=/\s/.test(p);_=_||c();let U=_.computeHMACSignature(i(R,w),p);return o(R,y,w,U,k||0,S,C,g),!0},async verifyHeaderAsync(u,m,p,k,_,g){let{decodedHeader:y,decodedPayload:R,details:w,suspectPayloadType:S}=r(u,m,this.EXPECTED_SCHEME),C=/\s/.test(p);_=_||c();let U=await _.computeHMACSignatureAsync(i(R,w),p);return o(R,y,w,U,k||0,S,C,g)}};function i(u,m){return`${m.timestamp}.${u}`}function r(u,m,p){if(Array.isArray(m))throw Error("Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.");if(!u)throw new N(m,u,{message:"No webhook payload was provided."});let k=typeof u!="string"&&!(u instanceof Uint8Array),_=new TextDecoder("utf8"),g=u instanceof Uint8Array?_.decode(u):u;if(m==null||m=="")throw new N(m,u,{message:"No stripe-signature header value was provided."});let y=m instanceof Uint8Array?_.decode(m):m,R=s(y,p);if(!R||R.timestamp===-1)throw new N(y,g,{message:"Unable to extract timestamp and signatures from header"});if(!R.signatures.length)throw new N(y,g,{message:"No signatures found with expected scheme"});return{decodedPayload:g,decodedHeader:y,details:R,suspectPayloadType:k}}function o(u,m,p,k,_,g,y,R){let w=!!p.signatures.filter(e.secureCompare.bind(e,k)).length,S=`
6
- Learn more about webhook signing and explore webhook integration examples for various frameworks at https://docs.stripe.com/webhooks/signature`,C=y?`
7
-
8
- Note: The provided signing secret contains whitespace. This often indicates an extra newline or space is in the value`:"";if(!w){if(g)throw new N(m,u,{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
- `+S+`
11
- `+C});throw new N(m,u,{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
- `+S+`
14
- `+C})}let U=Math.floor((typeof R==="number"?R:Date.now())/1000)-p.timestamp;if(_>0&&U>_)throw new N(m,u,{message:"Timestamp outside the tolerance zone"});return!0}function s(u,m){if(typeof u!=="string")return null;return m=m||n.EXPECTED_SCHEME,u.split(",").reduce((p,k)=>{let _=k.split("=");if(_[0]==="t")p.timestamp=parseInt(_[1],10);if(_[0]===m)p.signatures.push(_[1]);return p},{timestamp:-1,signatures:[]})}let a=null;function c(){if(!a)a=e.createDefaultCryptoProvider();return a}function l(u){if(!u)throw new P({message:"Options are required"});let m=u.timestamp&&Math.floor(u.timestamp)||Math.floor(Date.now()/1000),p=u.scheme||n.EXPECTED_SCHEME,k=u.cryptoProvider||c(),_=`${m}.${u.payload}`;return{...u,timestamp:m,scheme:p,cryptoProvider:k,payloadString:_,generateHeaderString:(y)=>`t=${m},${p}=${y}`}}return t.signature=n,t}var Ol=f(()=>{xi();yi()});var Or="2026-06-24.dahlia";function tu(e,t){for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let i=n[0].toLowerCase()+n.substring(1),r=new t[n](e);this[i]=r}}function x(e,t){return function(n){return new tu(n,t)}}var Ce;var Ir=f(()=>{b();Ce=class Ce extends d{create(e,t){return this._makeRequest("POST","/v2/core/account_links",e,t)}}});var je;var Ar=f(()=>{b();je=class je extends d{create(e,t){return this._makeRequest("POST","/v2/core/account_tokens",e,t,{requestSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v2/core/account_tokens/${encodeURIComponent(e)}`,t,n)}}});var Pe;var $r=f(()=>{b();Pe=class Pe extends d{list(e,t){return this._makeRequest("GET","/v1/financial_connections/accounts",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/accounts/${encodeURIComponent(e)}`,t,n)}disconnect(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/disconnect`,t,n)}refresh(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/refresh`,t,n)}subscribe(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/subscribe`,t,n)}unsubscribe(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/unsubscribe`,t,n)}listOwners(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/owners`,t,n,{methodType:"list"})}}});var Ur;var Il=f(()=>{b();Ur=class Ur extends d{list(e,t,n){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}/persons`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}})}create(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/persons`,t,n,{requestSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}del(e,t,n,i){return this._makeRequest("DELETE",`/v2/core/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}retrieve(e,t,n,i){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i,{responseSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}update(e,t,n,i){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i,{requestSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}}});var Mr;var Al=f(()=>{b();Mr=class Mr extends d{create(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/person_tokens`,t,n,{requestSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}retrieve(e,t,n,i){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}/person_tokens/${encodeURIComponent(t)}`,n,i)}}});var Ee;var Dr=f(()=>{b();Il();Al();Ee=class Ee extends d{constructor(e){super(e);this.stripe=e,this.persons=new Ur(e),this.personTokens=new Mr(e)}list(e,t){return this._makeRequest("GET","/v2/core/accounts",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v2/core/accounts",e,t,{requestSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}},responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}},responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}close(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/close`,t,n,{responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}}});var qe;var Fr=f(()=>{b();qe=class qe extends d{list(e,t){return this._makeRequest("GET","/v1/entitlements/active_entitlements",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/entitlements/active_entitlements/${encodeURIComponent(e)}`,t,n)}}});var Oe;var Nr=f(()=>{b();Oe=class Oe extends d{list(e,t){return this._makeRequest("GET","/v1/billing/alerts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing/alerts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/alerts/${encodeURIComponent(e)}`,t,n)}activate(e,t,n){return this._makeRequest("POST",`/v1/billing/alerts/${encodeURIComponent(e)}/activate`,t,n)}archive(e,t,n){return this._makeRequest("POST",`/v1/billing/alerts/${encodeURIComponent(e)}/archive`,t,n)}deactivate(e,t,n){return this._makeRequest("POST",`/v1/billing/alerts/${encodeURIComponent(e)}/deactivate`,t,n)}}});var Ie;var Gr=f(()=>{b();Ie=class Ie extends d{find(e,t){return this._makeRequest("GET","/v1/tax/associations/find",e,t)}}});var Ae;var Br=f(()=>{b();Ae=class Ae extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/authorizations",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/authorizations/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/authorizations/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}approve(e,t,n){return this._makeRequest("POST",`/v1/issuing/authorizations/${encodeURIComponent(e)}/approve`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}decline(e,t,n){return this._makeRequest("POST",`/v1/issuing/authorizations/${encodeURIComponent(e)}/decline`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}}});var $e;var Lr=f(()=>{b();$e=class $e extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/issuing/authorizations",e,t,{requestSchema:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}capture(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/capture`,t,n,{requestSchema:{kind:"object",fields:{purchase_details:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}},receipt:{kind:"array",element:{kind:"object",fields:{quantity:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}expire(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/expire`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}finalizeAmount(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/finalize_amount`,t,n,{requestSchema:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}respond(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/fraud_challenges/respond`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}increment(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/increment`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}reverse(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/reverse`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}}});var Ue;var Kr=f(()=>{b();Ue=class Ue extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax/calculations/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/tax/calculations",e,t)}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/tax/calculations/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list"})}}});var Me;var Hr=f(()=>{b();Me=class Me extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/cardholders",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/cardholders",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/cardholders/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/cardholders/${encodeURIComponent(e)}`,t,n)}}});var De;var Vr=f(()=>{b();De=class De extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/cards",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/cards",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/cards/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/cards/${encodeURIComponent(e)}`,t,n)}}});var Fe;var zr=f(()=>{b();Fe=class Fe extends d{deliverCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/deliver`,t,n)}failCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/fail`,t,n)}returnCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/return`,t,n)}shipCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/ship`,t,n)}submitCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/submit`,t,n)}}});var Ne;var Wr=f(()=>{b();Ne=class Ne extends d{list(e,t){return this._makeRequest("GET","/v1/billing_portal/configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing_portal/configurations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing_portal/configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/billing_portal/configurations/${encodeURIComponent(e)}`,t,n)}}});var Ge;var Qr=f(()=>{b();Ge=class Ge extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/terminal/configurations/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/terminal/configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/terminal/configurations/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/terminal/configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/terminal/configurations",e,t)}}});var Be;var Jr=f(()=>{b();Be=class Be extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/confirmation_tokens",e,t)}}});var Le;var Xr=f(()=>{b();Le=class Le extends d{create(e,t){return this._makeRequest("POST","/v1/terminal/connection_tokens",e,t)}}});var Ke;var Yr=f(()=>{b();Ke=class Ke extends d{retrieve(e,t){return this._makeRequest("GET","/v1/billing/credit_balance_summary",e,t)}}});var He;var Zr=f(()=>{b();He=class He extends d{list(e,t){return this._makeRequest("GET","/v1/billing/credit_balance_transactions",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/credit_balance_transactions/${encodeURIComponent(e)}`,t,n)}}});var Ve;var eo=f(()=>{b();Ve=class Ve extends d{list(e,t){return this._makeRequest("GET","/v1/billing/credit_grants",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing/credit_grants",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/credit_grants/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/billing/credit_grants/${encodeURIComponent(e)}`,t,n)}expire(e,t,n){return this._makeRequest("POST",`/v1/billing/credit_grants/${encodeURIComponent(e)}/expire`,t,n)}voidGrant(e,t,n){return this._makeRequest("POST",`/v1/billing/credit_grants/${encodeURIComponent(e)}/void`,t,n)}}});var ze;var to=f(()=>{b();ze=class ze extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/credit_reversals",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/credit_reversals",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/credit_reversals/${encodeURIComponent(e)}`,t,n)}}});var We;var no=f(()=>{b();We=class We extends d{fundCashBalance(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/customers/${encodeURIComponent(e)}/fund_cash_balance`,t,n)}}});var Qe;var io=f(()=>{b();Qe=class Qe extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/debit_reversals",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/debit_reversals",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/debit_reversals/${encodeURIComponent(e)}`,t,n)}}});var Je;var ro=f(()=>{b();Je=class Je extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/disputes",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/disputes",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/disputes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/disputes/${encodeURIComponent(e)}`,t,n)}submit(e,t,n){return this._makeRequest("POST",`/v1/issuing/disputes/${encodeURIComponent(e)}/submit`,t,n)}}});var Xe;var oo=f(()=>{b();Xe=class Xe extends d{list(e,t){return this._makeRequest("GET","/v1/radar/early_fraud_warnings",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/radar/early_fraud_warnings/${encodeURIComponent(e)}`,t,n)}}});var Ye;var so=f(()=>{b();Ye=class Ye extends d{list(e,t){return this._makeRequest("GET","/v2/core/event_destinations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v2/core/event_destinations",e,t)}del(e,t,n){return this._makeRequest("DELETE",`/v2/core/event_destinations/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v2/core/event_destinations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}`,t,n)}disable(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}/disable`,t,n)}enable(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}/enable`,t,n)}ping(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}/ping`,t,n)}}});var Ze;var ao=f(()=>{b();Ze=class Ze extends d{list(e,t){let n=(i)=>({...i,data:i.data.map(this.addFetchRelatedObjectIfNeeded.bind(this))});return this._makeRequest("GET","/v2/core/events",e,t,{methodType:"list",transformResponseData:n})}retrieve(e,t,n){let i=(r)=>this.addFetchRelatedObjectIfNeeded(r);return this._makeRequest("GET",`/v2/core/events/${encodeURIComponent(e)}`,t,n,{transformResponseData:i})}addFetchRelatedObjectIfNeeded(e){if(!e.related_object||!e.related_object.url)return e;return{...e,fetchRelatedObject:()=>this._makeRequest("GET",e.related_object.url,void 0,{stripeContext:e.context,headers:{"Stripe-Request-Trigger":`event=${e.id}`}})}}}});var et;var lo=f(()=>{b();et=class et extends d{list(e,t){return this._makeRequest("GET","/v1/entitlements/features",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/entitlements/features",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/entitlements/features/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/entitlements/features/${encodeURIComponent(e)}`,t,n)}}});var tt;var co=f(()=>{b();tt=class tt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/financial_accounts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/financial_accounts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}`,t,n)}close(e,t,n){return this._makeRequest("POST",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}/close`,t,n)}updateFeatures(e,t,n){return this._makeRequest("POST",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}/features`,t,n)}retrieveFeatures(e,t,n){return this._makeRequest("GET",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}/features`,t,n)}}});var nt;var uo=f(()=>{b();nt=class nt extends d{list(e,t){return this._makeRequest("GET","/v2/commerce/product_catalog/imports",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{status_details:{kind:"object",fields:{processing:{kind:"object",fields:{error_count:{kind:"int64_string"},success_count:{kind:"int64_string"}}},succeeded:{kind:"object",fields:{success_count:{kind:"int64_string"}}},succeeded_with_errors:{kind:"object",fields:{error_count:{kind:"int64_string"},error_file:{kind:"object",fields:{size:{kind:"int64_string"}}},samples:{kind:"array",element:{kind:"object",fields:{row:{kind:"int64_string"}}}},success_count:{kind:"int64_string"}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v2/commerce/product_catalog/imports",e,t,{responseSchema:{kind:"object",fields:{status_details:{kind:"object",fields:{processing:{kind:"object",fields:{error_count:{kind:"int64_string"},success_count:{kind:"int64_string"}}},succeeded:{kind:"object",fields:{success_count:{kind:"int64_string"}}},succeeded_with_errors:{kind:"object",fields:{error_count:{kind:"int64_string"},error_file:{kind:"object",fields:{size:{kind:"int64_string"}}},samples:{kind:"array",element:{kind:"object",fields:{row:{kind:"int64_string"}}}},success_count:{kind:"int64_string"}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v2/commerce/product_catalog/imports/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{status_details:{kind:"object",fields:{processing:{kind:"object",fields:{error_count:{kind:"int64_string"},success_count:{kind:"int64_string"}}},succeeded:{kind:"object",fields:{success_count:{kind:"int64_string"}}},succeeded_with_errors:{kind:"object",fields:{error_count:{kind:"int64_string"},error_file:{kind:"object",fields:{size:{kind:"int64_string"}}},samples:{kind:"array",element:{kind:"object",fields:{row:{kind:"int64_string"}}}},success_count:{kind:"int64_string"}}}}}}}})}}});var it;var mo=f(()=>{b();it=class it extends d{fail(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/inbound_transfers/${encodeURIComponent(e)}/fail`,t,n)}returnInboundTransfer(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/inbound_transfers/${encodeURIComponent(e)}/return`,t,n)}succeed(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/inbound_transfers/${encodeURIComponent(e)}/succeed`,t,n)}}});var rt;var po=f(()=>{b();rt=class rt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/inbound_transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/inbound_transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/inbound_transfers/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/treasury/inbound_transfers/${encodeURIComponent(e)}/cancel`,t,n)}}});var ot;var fo=f(()=>{b();ot=class ot extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/terminal/locations/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/terminal/locations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/terminal/locations/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/terminal/locations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/terminal/locations",e,t)}}});var st;var _o=f(()=>{b();st=class st extends d{create(e,t){return this._makeRequest("POST","/v1/billing/meter_event_adjustments",e,t)}}});var at;var ko=f(()=>{b();at=class at extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_event_adjustments",e,t)}}});var lt;var bo=f(()=>{b();lt=class lt extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_event_session",e,t)}}});var ct;var go=f(()=>{b();ct=class ct extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_event_stream",e,t,{apiBase:"meter_events"})}}});var dt;var ho=f(()=>{b();dt=class dt extends d{create(e,t){return this._makeRequest("POST","/v1/billing/meter_events",e,t)}}});var ut;var yo=f(()=>{b();ut=class ut extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_events",e,t)}}});var mt;var Ro=f(()=>{b();mt=class mt extends d{list(e,t){return this._makeRequest("GET","/v1/billing/meters",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing/meters",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/meters/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/billing/meters/${encodeURIComponent(e)}`,t,n)}deactivate(e,t,n){return this._makeRequest("POST",`/v1/billing/meters/${encodeURIComponent(e)}/deactivate`,t,n)}reactivate(e,t,n){return this._makeRequest("POST",`/v1/billing/meters/${encodeURIComponent(e)}/reactivate`,t,n)}listEventSummaries(e,t,n){return this._makeRequest("GET",`/v1/billing/meters/${encodeURIComponent(e)}/event_summaries`,t,n,{methodType:"list"})}}});var pt;var wo=f(()=>{b();pt=class pt extends d{create(e,t){return this._makeRequest("POST","/v1/terminal/onboarding_links",e,t)}}});var ft;var To=f(()=>{b();ft=class ft extends d{list(e,t){return this._makeRequest("GET","/v1/climate/orders",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/climate/orders",e,t,{requestSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/climate/orders/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/climate/orders/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/climate/orders/${encodeURIComponent(e)}/cancel`,t,n,{responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}}});var _t;var vo=f(()=>{b();_t=class _t extends d{update(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}`,t,n)}fail(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}/fail`,t,n)}post(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}/post`,t,n)}returnOutboundPayment(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}/return`,t,n)}}});var kt;var So=f(()=>{b();kt=class kt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/outbound_payments",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/outbound_payments",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/outbound_payments/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/treasury/outbound_payments/${encodeURIComponent(e)}/cancel`,t,n)}}});var bt;var xo=f(()=>{b();bt=class bt extends d{update(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}`,t,n)}fail(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}/fail`,t,n)}post(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}/post`,t,n)}returnOutboundTransfer(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}/return`,t,n)}}});var gt;var Co=f(()=>{b();gt=class gt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/outbound_transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/outbound_transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/outbound_transfers/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/treasury/outbound_transfers/${encodeURIComponent(e)}/cancel`,t,n)}}});var ht;var jo=f(()=>{b();ht=class ht extends d{create(e,t){return this._makeRequest("POST","/v1/radar/payment_evaluations",e,t)}}});var yt;var Po=f(()=>{b();yt=class yt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/personalization_designs",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/personalization_designs",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/personalization_designs/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/personalization_designs/${encodeURIComponent(e)}`,t,n)}}});var Rt;var Eo=f(()=>{b();Rt=class Rt extends d{activate(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/personalization_designs/${encodeURIComponent(e)}/activate`,t,n)}deactivate(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/personalization_designs/${encodeURIComponent(e)}/deactivate`,t,n)}reject(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/personalization_designs/${encodeURIComponent(e)}/reject`,t,n)}}});var wt;var qo=f(()=>{b();wt=class wt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/physical_bundles",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/physical_bundles/${encodeURIComponent(e)}`,t,n)}}});var Tt;var Oo=f(()=>{b();Tt=class Tt extends d{list(e,t){return this._makeRequest("GET","/v1/climate/products",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{metric_tons_available:{kind:"decimal_string"}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/climate/products/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{metric_tons_available:{kind:"decimal_string"}}}})}}});var vt;var Io=f(()=>{b();vt=class vt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/terminal/readers/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/terminal/readers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/terminal/readers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/terminal/readers",e,t)}cancelAction(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/cancel_action`,t,n)}collectInputs(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/collect_inputs`,t,n)}collectPaymentMethod(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/collect_payment_method`,t,n)}confirmPaymentIntent(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/confirm_payment_intent`,t,n)}processPaymentIntent(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/process_payment_intent`,t,n)}processSetupIntent(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/process_setup_intent`,t,n)}refundPayment(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/refund_payment`,t,n)}setReaderDisplay(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/set_reader_display`,t,n)}}});var St;var Ao=f(()=>{b();St=class St extends d{presentPaymentMethod(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/terminal/readers/${encodeURIComponent(e)}/present_payment_method`,t,n)}succeedInputCollection(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/terminal/readers/${encodeURIComponent(e)}/succeed_input_collection`,t,n)}timeoutInputCollection(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/terminal/readers/${encodeURIComponent(e)}/timeout_input_collection`,t,n)}}});var xt;var $o=f(()=>{b();xt=class xt extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/treasury/received_credits",e,t)}}});var Ct;var Uo=f(()=>{b();Ct=class Ct extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/received_credits",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/received_credits/${encodeURIComponent(e)}`,t,n)}}});var jt;var Mo=f(()=>{b();jt=class jt extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/treasury/received_debits",e,t)}}});var Pt;var Do=f(()=>{b();Pt=class Pt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/received_debits",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/received_debits/${encodeURIComponent(e)}`,t,n)}}});var Et;var Fo=f(()=>{b();Et=class Et extends d{expire(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/refunds/${encodeURIComponent(e)}/expire`,t,n)}}});var qt;var No=f(()=>{b();qt=class qt extends d{list(e,t){return this._makeRequest("GET","/v1/tax/registrations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax/registrations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax/registrations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/tax/registrations/${encodeURIComponent(e)}`,t,n)}}});var Ot;var Go=f(()=>{b();Ot=class Ot extends d{list(e,t){return this._makeRequest("GET","/v1/reporting/report_runs",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/reporting/report_runs",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reporting/report_runs/${encodeURIComponent(e)}`,t,n)}}});var It;var Bo=f(()=>{b();It=class It extends d{list(e,t){return this._makeRequest("GET","/v1/reporting/report_types",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reporting/report_types/${encodeURIComponent(e)}`,t,n)}}});var At;var Lo=f(()=>{b();At=class At extends d{list(e,t){return this._makeRequest("GET","/v1/forwarding/requests",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/forwarding/requests",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/forwarding/requests/${encodeURIComponent(e)}`,t,n)}}});var $t;var Ko=f(()=>{b();$t=class $t extends d{list(e,t){return this._makeRequest("GET","/v1/sigma/scheduled_query_runs",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/sigma/scheduled_query_runs/${encodeURIComponent(e)}`,t,n)}}});var Ut;var Ho=f(()=>{b();Ut=class Ut extends d{list(e,t){return this._makeRequest("GET","/v1/apps/secrets",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/apps/secrets",e,t)}find(e,t){return this._makeRequest("GET","/v1/apps/secrets/find",e,t)}deleteWhere(e,t){return this._makeRequest("POST","/v1/apps/secrets/delete",e,t)}}});var Mt;var Vo=f(()=>{b();Mt=class Mt extends d{create(e,t){return this._makeRequest("POST","/v1/billing_portal/sessions",e,t)}}});var Dt;var zo=f(()=>{b();Dt=class Dt extends d{list(e,t){return this._makeRequest("GET","/v1/checkout/sessions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/checkout/sessions",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/checkout/sessions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/checkout/sessions/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}expire(e,t,n){return this._makeRequest("POST",`/v1/checkout/sessions/${encodeURIComponent(e)}/expire`,t,n,{responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/checkout/sessions/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Ft;var Wo=f(()=>{b();Ft=class Ft extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/sessions/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/financial_connections/sessions",e,t)}}});var Nt;var Qo=f(()=>{b();Nt=class Nt extends d{retrieve(e,t){return this._makeRequest("GET","/v1/tax/settings",e,t)}update(e,t){return this._makeRequest("POST","/v1/tax/settings",e,t)}}});var Gt;var Jo=f(()=>{b();Gt=class Gt extends d{list(e,t){return this._makeRequest("GET","/v1/climate/suppliers",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/climate/suppliers/${encodeURIComponent(e)}`,t,n)}}});var Bt;var Xo=f(()=>{b();Bt=class Bt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/test_helpers/test_clocks/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/test_helpers/test_clocks/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/test_helpers/test_clocks",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/test_helpers/test_clocks",e,t)}advance(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/test_clocks/${encodeURIComponent(e)}/advance`,t,n)}}});var Lt;var Yo=f(()=>{b();Lt=class Lt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/tokens",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/tokens/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/tokens/${encodeURIComponent(e)}`,t,n)}}});var Kt;var Zo=f(()=>{b();Kt=class Kt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/transaction_entries",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/transaction_entries/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}})}}});var Ht;var es=f(()=>{b();Ht=class Ht extends d{list(e,t){return this._makeRequest("GET","/v1/financial_connections/transactions",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/transactions/${encodeURIComponent(e)}`,t,n)}}});var Vt;var ts=f(()=>{b();Vt=class Vt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/transactions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/transactions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/transactions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}}});var zt;var ns=f(()=>{b();zt=class zt extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax/transactions/${encodeURIComponent(e)}`,t,n)}createFromCalculation(e,t){return this._makeRequest("POST","/v1/tax/transactions/create_from_calculation",e,t)}createReversal(e,t){return this._makeRequest("POST","/v1/tax/transactions/create_reversal",e,t)}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/tax/transactions/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list"})}}});var Wt;var is=f(()=>{b();Wt=class Wt extends d{refund(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/transactions/${encodeURIComponent(e)}/refund`,t,n,{responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}createForceCapture(e,t){return this._makeRequest("POST","/v1/test_helpers/issuing/transactions/create_force_capture",e,t,{requestSchema:{kind:"object",fields:{purchase_details:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}},receipt:{kind:"array",element:{kind:"object",fields:{quantity:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}createUnlinkedRefund(e,t){return this._makeRequest("POST","/v1/test_helpers/issuing/transactions/create_unlinked_refund",e,t,{requestSchema:{kind:"object",fields:{purchase_details:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}},receipt:{kind:"array",element:{kind:"object",fields:{quantity:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}}});var Qt;var rs=f(()=>{b();Qt=class Qt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/transactions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{entries:{kind:"nullable",inner:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/transactions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{entries:{kind:"nullable",inner:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}}}}}})}}});var Jt;var os=f(()=>{b();Jt=class Jt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/radar/value_list_items/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/radar/value_list_items/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/radar/value_list_items",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/radar/value_list_items",e,t)}}});var Xt;var ss=f(()=>{b();Xt=class Xt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/radar/value_lists/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/radar/value_lists/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/radar/value_lists/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/radar/value_lists",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/radar/value_lists",e,t)}}});var Yt;var as=f(()=>{b();Yt=class Yt extends d{list(e,t){return this._makeRequest("GET","/v1/identity/verification_reports",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/identity/verification_reports/${encodeURIComponent(e)}`,t,n)}}});var Zt;var ls=f(()=>{b();Zt=class Zt extends d{list(e,t){return this._makeRequest("GET","/v1/identity/verification_sessions",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/identity/verification_sessions",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/identity/verification_sessions/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/identity/verification_sessions/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/identity/verification_sessions/${encodeURIComponent(e)}/cancel`,t,n)}redact(e,t,n){return this._makeRequest("POST",`/v1/identity/verification_sessions/${encodeURIComponent(e)}/redact`,t,n)}}});var oe;var Ci=f(()=>{b();oe=class oe extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/accounts/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){if(typeof e==="string")return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}`,t,n);else return this._makeRequest("GET","/v1/account",t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}`,t,n)}retrieveCurrent(e,t){return this._makeRequest("GET","/v1/account",e,t)}list(e,t){return this._makeRequest("GET","/v1/accounts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/accounts",e,t)}reject(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/reject`,t,n)}listCapabilities(e,t,n){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/capabilities`,t,n,{methodType:"list"})}retrieveCapability(e,t,n,i){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/capabilities/${encodeURIComponent(t)}`,n,i)}updateCapability(e,t,n,i){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/capabilities/${encodeURIComponent(t)}`,n,i)}deleteExternalAccount(e,t,n,i){return this._makeRequest("DELETE",`/v1/accounts/${encodeURIComponent(e)}/external_accounts/${encodeURIComponent(t)}`,n,i)}retrieveExternalAccount(e,t,n,i){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/external_accounts/${encodeURIComponent(t)}`,n,i)}updateExternalAccount(e,t,n,i){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/external_accounts/${encodeURIComponent(t)}`,n,i)}listExternalAccounts(e,t,n){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/external_accounts`,t,n,{methodType:"list"})}createExternalAccount(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/external_accounts`,t,n)}createLoginLink(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/login_links`,t,n)}deletePerson(e,t,n,i){return this._makeRequest("DELETE",`/v1/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}retrievePerson(e,t,n,i){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}updatePerson(e,t,n,i){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}listPersons(e,t,n){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/persons`,t,n,{methodType:"list"})}createPerson(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/persons`,t,n)}}});var en;var cs=f(()=>{b();en=class en extends d{create(e,t){return this._makeRequest("POST","/v1/account_links",e,t)}}});var tn;var ds=f(()=>{b();tn=class tn extends d{create(e,t){return this._makeRequest("POST","/v1/account_sessions",e,t)}}});var nn;var us=f(()=>{b();nn=class nn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/apple_pay/domains/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/apple_pay/domains/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/apple_pay/domains",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/apple_pay/domains",e,t)}}});var rn;var ms=f(()=>{b();rn=class rn extends d{list(e,t){return this._makeRequest("GET","/v1/application_fees",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/application_fees/${encodeURIComponent(e)}`,t,n)}retrieveRefund(e,t,n,i){return this._makeRequest("GET",`/v1/application_fees/${encodeURIComponent(e)}/refunds/${encodeURIComponent(t)}`,n,i)}updateRefund(e,t,n,i){return this._makeRequest("POST",`/v1/application_fees/${encodeURIComponent(e)}/refunds/${encodeURIComponent(t)}`,n,i)}listRefunds(e,t,n){return this._makeRequest("GET",`/v1/application_fees/${encodeURIComponent(e)}/refunds`,t,n,{methodType:"list"})}createRefund(e,t,n){return this._makeRequest("POST",`/v1/application_fees/${encodeURIComponent(e)}/refunds`,t,n)}}});var se;var ji=f(()=>{b();se=class se extends d{retrieve(e,t){return this._makeRequest("GET","/v1/balance",e,t)}}});var on;var ps=f(()=>{b();on=class on extends d{retrieve(e,t){return this._makeRequest("GET","/v1/balance_settings",e,t)}update(e,t){return this._makeRequest("POST","/v1/balance_settings",e,t)}}});var sn;var fs=f(()=>{b();sn=class sn extends d{list(e,t){return this._makeRequest("GET","/v1/balance_transactions",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/balance_transactions/${encodeURIComponent(e)}`,t,n)}}});var an;var _s=f(()=>{b();an=class an extends d{list(e,t){return this._makeRequest("GET","/v1/charges",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/charges",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/charges/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/charges/${encodeURIComponent(e)}`,t,n)}search(e,t){return this._makeRequest("GET","/v1/charges/search",e,t,{methodType:"search"})}capture(e,t,n){return this._makeRequest("POST",`/v1/charges/${encodeURIComponent(e)}/capture`,t,n)}}});var ln;var ks=f(()=>{b();ln=class ln extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/confirmation_tokens/${encodeURIComponent(e)}`,t,n)}}});var cn;var bs=f(()=>{b();cn=class cn extends d{list(e,t){return this._makeRequest("GET","/v1/country_specs",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/country_specs/${encodeURIComponent(e)}`,t,n)}}});var dn;var gs=f(()=>{b();dn=class dn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/coupons/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/coupons/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/coupons/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/coupons",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/coupons",e,t)}}});var un;var hs=f(()=>{b();un=class un extends d{list(e,t){return this._makeRequest("GET","/v1/credit_notes",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/credit_notes",e,t,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/credit_notes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/credit_notes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}preview(e,t){return this._makeRequest("GET","/v1/credit_notes/preview",e,t,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}voidCreditNote(e,t,n){return this._makeRequest("POST",`/v1/credit_notes/${encodeURIComponent(e)}/void`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}listPreviewLineItems(e,t){return this._makeRequest("GET","/v1/credit_notes/preview/lines",e,t,{methodType:"list",requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/credit_notes/${encodeURIComponent(e)}/lines`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var mn;var ys=f(()=>{b();mn=class mn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}deleteDiscount(e,t,n){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}/discount`,t,n)}list(e,t){return this._makeRequest("GET","/v1/customers",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/customers",e,t,{responseSchema:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/customers/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}listBalanceTransactions(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/balance_transactions`,t,n,{methodType:"list"})}createBalanceTransaction(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/balance_transactions`,t,n)}retrieveBalanceTransaction(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/balance_transactions/${encodeURIComponent(t)}`,n,i)}updateBalanceTransaction(e,t,n,i){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/balance_transactions/${encodeURIComponent(t)}`,n,i)}retrieveCashBalance(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/cash_balance`,t,n)}updateCashBalance(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/cash_balance`,t,n)}listCashBalanceTransactions(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/cash_balance_transactions`,t,n,{methodType:"list"})}retrieveCashBalanceTransaction(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/cash_balance_transactions/${encodeURIComponent(t)}`,n,i)}createFundingInstructions(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/funding_instructions`,t,n)}listPaymentMethods(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/payment_methods`,t,n,{methodType:"list"})}retrievePaymentMethod(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/payment_methods/${encodeURIComponent(t)}`,n,i)}listSources(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/sources`,t,n,{methodType:"list"})}createSource(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/sources`,t,n)}retrieveSource(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}`,n,i)}updateSource(e,t,n,i){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}`,n,i)}deleteSource(e,t,n,i){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}`,n,i)}verifySource(e,t,n,i){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}/verify`,n,i)}deleteTaxId(e,t,n,i){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}/tax_ids/${encodeURIComponent(t)}`,n,i)}retrieveTaxId(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/tax_ids/${encodeURIComponent(t)}`,n,i)}listTaxIds(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/tax_ids`,t,n,{methodType:"list"})}createTaxId(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/tax_ids`,t,n)}}});var pn;var Rs=f(()=>{b();pn=class pn extends d{create(e,t){return this._makeRequest("POST","/v1/customer_sessions",e,t)}}});var fn;var ws=f(()=>{b();fn=class fn extends d{list(e,t){return this._makeRequest("GET","/v1/disputes",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/disputes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/disputes/${encodeURIComponent(e)}`,t,n)}close(e,t,n){return this._makeRequest("POST",`/v1/disputes/${encodeURIComponent(e)}/close`,t,n)}}});var _n;var Ts=f(()=>{b();_n=class _n extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/ephemeral_keys/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/ephemeral_keys",e,t,{validator:(n,i)=>{if(!i.headers||!i.headers["Stripe-Version"])throw Error("Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node")}})}}});var kn;var vs=f(()=>{b();kn=class kn extends d{list(e,t){return this._makeRequest("GET","/v1/events",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/events/${encodeURIComponent(e)}`,t,n)}}});var bn;var Ss=f(()=>{b();bn=class bn extends d{list(e,t){return this._makeRequest("GET","/v1/exchange_rates",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/exchange_rates/${encodeURIComponent(e)}`,t,n)}}});function $l(e,t,n,i){if(t=t||{},e!=="POST")return i(null,z(t));this._stripe._platformFunctions.tryBufferData(t).then((r)=>{let o=nu(e,r,n);return i(null,o)}).catch((r)=>i(r,null))}var nu=(e,t,n)=>{let i=(Math.round(Math.random()*10000000000000000)+Math.round(Math.random()*10000000000000000)).toString();n["Content-Type"]=`multipart/form-data; boundary=${i}`;let r=new TextEncoder,o=new Uint8Array(0),s=r.encode(`\r
15
- `);function a(u){let m=o,p=u instanceof Uint8Array?u:new Uint8Array(r.encode(u));o=new Uint8Array(m.length+p.length+2),o.set(m),o.set(p,m.length),o.set(s,o.length-2)}function c(u){return`"${u.replace(/"|"/g,"%22").replace(/\r\n|\r|\n/g," ")}"`}let l=fl(t);for(let u in l){if(!Object.prototype.hasOwnProperty.call(l,u))continue;let m=l[u];if(a(`--${i}`),Object.prototype.hasOwnProperty.call(m,"data")){let p=m;a(`Content-Disposition: form-data; name=${c(u)}; filename=${c(p.name||"blob")}`),a(`Content-Type: ${p.type||"application/octet-stream"}`),a(""),a(p.data)}else a(`Content-Disposition: form-data; name=${c(u)}`),a(""),a(m)}return a(`--${i}--`),o};var Ul=f(()=>{W()});var gn;var xs=f(()=>{Ul();b();gn=class gn extends d{constructor(){super(...arguments);this.requestDataProcessor=$l}list(e,t){return this._makeRequest("GET","/v1/files",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/files",e,t,{headers:{"Content-Type":"multipart/form-data"},apiBase:"files"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/files/${encodeURIComponent(e)}`,t,n)}}});var hn;var Cs=f(()=>{b();hn=class hn extends d{list(e,t){return this._makeRequest("GET","/v1/file_links",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/file_links",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/file_links/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/file_links/${encodeURIComponent(e)}`,t,n)}}});var yn;var js=f(()=>{b();yn=class yn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/invoices/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/invoices",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/invoices",e,t,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/invoices/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}addLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/add_lines`,t,n,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}attachPayment(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/attach_payment`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}finalizeInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/finalize`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}markUncollectible(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/mark_uncollectible`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}pay(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/pay`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}removeLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/remove_lines`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}sendInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/send`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}updateLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/update_lines`,t,n,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}voidInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/void`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}createPreview(e,t){return this._makeRequest("POST","/v1/invoices/create_preview",e,t,{requestSchema:{kind:"object",fields:{invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},schedule_details:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}},subscription_details:{kind:"object",fields:{items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/invoices/${encodeURIComponent(e)}/lines`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}updateLineItem(e,t,n,i){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/lines/${encodeURIComponent(t)}`,n,i,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}}});var Rn;var Ps=f(()=>{b();Rn=class Rn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}list(e,t){return this._makeRequest("GET","/v1/invoiceitems",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/invoiceitems",e,t,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}}});var wn;var Es=f(()=>{b();wn=class wn extends d{list(e,t){return this._makeRequest("GET","/v1/invoice_payments",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoice_payments/${encodeURIComponent(e)}`,t,n)}}});var Tn;var qs=f(()=>{b();Tn=class Tn extends d{list(e,t){return this._makeRequest("GET","/v1/invoice_rendering_templates",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}`,t,n)}archive(e,t,n){return this._makeRequest("POST",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}/archive`,t,n)}unarchive(e,t,n){return this._makeRequest("POST",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}/unarchive`,t,n)}}});var vn;var Os=f(()=>{b();vn=class vn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/mandates/${encodeURIComponent(e)}`,t,n)}}});var Sn;var Ml=f(()=>{b();W();Sn=class Sn extends d{constructor(){super(...arguments);this.basePath=be("/")}authorizeUrl(e,t){e=e||{},t=t||{};let n="oauth/authorize";if(t.express)n=`express/${n}`;if(!e.response_type)e.response_type="code";if(!e.client_id)e.client_id=this._stripe.getClientId();if(!e.scope)e.scope="read_write";return`https://${this._stripe.resolveBaseAddress("connect")}/${n}?${z(e)}`}token(e,t){return this._makeRequest("POST","/oauth/token",e,t,{apiBase:"connect"})}deauthorize(e,t){if(!e.client_id)e.client_id=this._stripe.getClientId();return this._makeRequest("POST","/oauth/deauthorize",e,t,{apiBase:"connect"})}}});var xn;var Is=f(()=>{b();xn=class xn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_attempt_records",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_attempt_records/${encodeURIComponent(e)}`,t,n)}}});var Cn;var As=f(()=>{b();Cn=class Cn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_intents",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_intents",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_intents/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}`,t,n)}search(e,t){return this._makeRequest("GET","/v1/payment_intents/search",e,t,{methodType:"search"})}applyCustomerBalance(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/apply_customer_balance`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/cancel`,t,n)}capture(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/capture`,t,n)}confirm(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/confirm`,t,n)}incrementAuthorization(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/increment_authorization`,t,n)}verifyMicrodeposits(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/verify_microdeposits`,t,n)}listAmountDetailsLineItems(e,t,n){return this._makeRequest("GET",`/v1/payment_intents/${encodeURIComponent(e)}/amount_details_line_items`,t,n,{methodType:"list"})}}});var jn;var $s=f(()=>{b();jn=class jn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_links",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/payment_links",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_links/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/payment_links/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/payment_links/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Pn;var Us=f(()=>{b();Pn=class Pn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_methods",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_methods",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_methods/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}`,t,n)}attach(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}/attach`,t,n)}detach(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}/detach`,t,n)}}});var En;var Ms=f(()=>{b();En=class En extends d{list(e,t){return this._makeRequest("GET","/v1/payment_method_configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_method_configurations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_method_configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_method_configurations/${encodeURIComponent(e)}`,t,n)}}});var qn;var Ds=f(()=>{b();qn=class qn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_method_domains",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_method_domains",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_method_domains/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_method_domains/${encodeURIComponent(e)}`,t,n)}validate(e,t,n){return this._makeRequest("POST",`/v1/payment_method_domains/${encodeURIComponent(e)}/validate`,t,n)}}});var On;var Fs=f(()=>{b();On=class On extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_records/${encodeURIComponent(e)}`,t,n)}reportPaymentAttempt(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt`,t,n)}reportPaymentAttemptCanceled(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_canceled`,t,n)}reportPaymentAttemptFailed(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_failed`,t,n)}reportPaymentAttemptGuaranteed(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_guaranteed`,t,n)}reportPaymentAttemptInformational(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_informational`,t,n)}reportRefund(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_refund`,t,n)}reportPayment(e,t){return this._makeRequest("POST","/v1/payment_records/report_payment",e,t)}}});var In;var Ns=f(()=>{b();In=class In extends d{list(e,t){return this._makeRequest("GET","/v1/payouts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payouts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payouts/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}/cancel`,t,n)}reverse(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}/reverse`,t,n)}}});var An;var Gs=f(()=>{b();An=class An extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/plans/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/plans/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/plans/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/plans",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/plans",e,t,{requestSchema:{kind:"object",fields:{amount_decimal:{kind:"decimal_string"},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var $n;var Bs=f(()=>{b();$n=class $n extends d{list(e,t){return this._makeRequest("GET","/v1/prices",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/prices",e,t,{requestSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/prices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/prices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}search(e,t){return this._makeRequest("GET","/v1/prices/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var Un;var Ls=f(()=>{b();Un=class Un extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/products/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/products/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/products",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/products",e,t,{requestSchema:{kind:"object",fields:{default_price_data:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}}}})}search(e,t){return this._makeRequest("GET","/v1/products/search",e,t,{methodType:"search"})}deleteFeature(e,t,n,i){return this._makeRequest("DELETE",`/v1/products/${encodeURIComponent(e)}/features/${encodeURIComponent(t)}`,n,i)}retrieveFeature(e,t,n,i){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}/features/${encodeURIComponent(t)}`,n,i)}listFeatures(e,t,n){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}/features`,t,n,{methodType:"list"})}createFeature(e,t,n){return this._makeRequest("POST",`/v1/products/${encodeURIComponent(e)}/features`,t,n)}}});var Mn;var Ks=f(()=>{b();Mn=class Mn extends d{list(e,t){return this._makeRequest("GET","/v1/promotion_codes",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/promotion_codes",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/promotion_codes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/promotion_codes/${encodeURIComponent(e)}`,t,n)}}});var Dn;var Hs=f(()=>{b();Dn=class Dn extends d{list(e,t){return this._makeRequest("GET","/v1/quotes",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/quotes",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}accept(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/accept`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/cancel`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}finalizeQuote(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/finalize`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}pdf(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/pdf`,t,n,{apiBase:"files",streaming:!0})}listComputedUpfrontLineItems(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/computed_upfront_line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Fn;var Vs=f(()=>{b();Fn=class Fn extends d{list(e,t){return this._makeRequest("GET","/v1/refunds",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/refunds",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/refunds/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/refunds/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/refunds/${encodeURIComponent(e)}/cancel`,t,n)}}});var Nn;var zs=f(()=>{b();Nn=class Nn extends d{list(e,t){return this._makeRequest("GET","/v1/reviews",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reviews/${encodeURIComponent(e)}`,t,n)}approve(e,t,n){return this._makeRequest("POST",`/v1/reviews/${encodeURIComponent(e)}/approve`,t,n)}}});var Gn;var Ws=f(()=>{b();Gn=class Gn extends d{list(e,t){return this._makeRequest("GET","/v1/setup_attempts",e,t,{methodType:"list"})}}});var Bn;var Qs=f(()=>{b();Bn=class Bn extends d{list(e,t){return this._makeRequest("GET","/v1/setup_intents",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/setup_intents",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/setup_intents/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/cancel`,t,n)}confirm(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/confirm`,t,n)}verifyMicrodeposits(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/verify_microdeposits`,t,n)}}});var Ln;var Js=f(()=>{b();Ln=class Ln extends d{list(e,t){return this._makeRequest("GET","/v1/shipping_rates",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/shipping_rates",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/shipping_rates/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/shipping_rates/${encodeURIComponent(e)}`,t,n)}}});var Kn;var Xs=f(()=>{b();Kn=class Kn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/sources/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/sources/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/sources",e,t)}verify(e,t,n){return this._makeRequest("POST",`/v1/sources/${encodeURIComponent(e)}/verify`,t,n)}listSourceTransactions(e,t,n){return this._makeRequest("GET",`/v1/sources/${encodeURIComponent(e)}/source_transactions`,t,n,{methodType:"list"})}}});var Hn;var Ys=f(()=>{b();Hn=class Hn extends d{cancel(e,t,n){return this._makeRequest("DELETE",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}deleteDiscount(e,t,n){return this._makeRequest("DELETE",`/v1/subscriptions/${encodeURIComponent(e)}/discount`,t,n)}list(e,t){return this._makeRequest("GET","/v1/subscriptions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/subscriptions",e,t,{requestSchema:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/subscriptions/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}})}migrate(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}/migrate`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}resume(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}/resume`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}}});var Vn;var Zs=f(()=>{b();Vn=class Vn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/subscription_items",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/subscription_items",e,t,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}}});var zn;var ea=f(()=>{b();zn=class zn extends d{list(e,t){return this._makeRequest("GET","/v1/subscription_schedules",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/subscription_schedules",e,t,{requestSchema:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscription_schedules/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}/cancel`,t,n)}release(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}/release`,t,n)}}});var Wn;var ta=f(()=>{b();Wn=class Wn extends d{list(e,t){return this._makeRequest("GET","/v1/tax_codes",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_codes/${encodeURIComponent(e)}`,t,n)}}});var Qn;var na=f(()=>{b();Qn=class Qn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/tax_ids/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_ids/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/tax_ids",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax_ids",e,t)}}});var Jn;var ia=f(()=>{b();Jn=class Jn extends d{list(e,t){return this._makeRequest("GET","/v1/tax_rates",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax_rates",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_rates/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/tax_rates/${encodeURIComponent(e)}`,t,n)}}});var Xn;var ra=f(()=>{b();Xn=class Xn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tokens/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/tokens",e,t)}}});var Yn;var oa=f(()=>{b();Yn=class Yn extends d{list(e,t){return this._makeRequest("GET","/v1/topups",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/topups",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/topups/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/topups/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/topups/${encodeURIComponent(e)}/cancel`,t,n)}}});var Zn;var sa=f(()=>{b();Zn=class Zn extends d{list(e,t){return this._makeRequest("GET","/v1/transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}`,t,n)}listReversals(e,t,n){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}/reversals`,t,n,{methodType:"list"})}createReversal(e,t,n){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}/reversals`,t,n)}retrieveReversal(e,t,n,i){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}/reversals/${encodeURIComponent(t)}`,n,i)}updateReversal(e,t,n,i){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}/reversals/${encodeURIComponent(t)}`,n,i)}}});var ei;var aa=f(()=>{b();ei=class ei extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/webhook_endpoints",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/webhook_endpoints",e,t)}}});var ae={};Ii(ae,{Account:()=>oe,AccountLinks:()=>en,AccountSessions:()=>tn,Accounts:()=>oe,ApplePayDomains:()=>nn,ApplicationFees:()=>rn,Apps:()=>iu,Balance:()=>se,BalanceSettings:()=>on,BalanceTransactions:()=>sn,Balances:()=>se,Billing:()=>ru,BillingPortal:()=>ou,Charges:()=>an,Checkout:()=>su,Climate:()=>au,ConfirmationTokens:()=>ln,CountrySpecs:()=>cn,Coupons:()=>dn,CreditNotes:()=>un,CustomerSessions:()=>pn,Customers:()=>mn,Disputes:()=>fn,Entitlements:()=>lu,EphemeralKeys:()=>_n,Events:()=>kn,ExchangeRates:()=>bn,FileLinks:()=>hn,Files:()=>gn,FinancialConnections:()=>cu,Forwarding:()=>du,Identity:()=>uu,InvoiceItems:()=>Rn,InvoicePayments:()=>wn,InvoiceRenderingTemplates:()=>Tn,Invoices:()=>yn,Issuing:()=>mu,Mandates:()=>vn,OAuthResource:()=>Sn,PaymentAttemptRecords:()=>xn,PaymentIntents:()=>Cn,PaymentLinks:()=>jn,PaymentMethodConfigurations:()=>En,PaymentMethodDomains:()=>qn,PaymentMethods:()=>Pn,PaymentRecords:()=>On,Payouts:()=>In,Plans:()=>An,Prices:()=>$n,Products:()=>Un,PromotionCodes:()=>Mn,Quotes:()=>Dn,Radar:()=>pu,Refunds:()=>Fn,Reporting:()=>fu,Reviews:()=>Nn,SetupAttempts:()=>Gn,SetupIntents:()=>Bn,ShippingRates:()=>Ln,Sigma:()=>_u,Sources:()=>Kn,SubscriptionItems:()=>Vn,SubscriptionSchedules:()=>zn,Subscriptions:()=>Hn,Tax:()=>ku,TaxCodes:()=>Wn,TaxIds:()=>Qn,TaxRates:()=>Jn,Terminal:()=>bu,TestHelpers:()=>gu,Tokens:()=>Xn,Topups:()=>Yn,Transfers:()=>Zn,Treasury:()=>hu,V2:()=>yu,WebhookEndpoints:()=>ei});var iu,ru,ou,su,au,lu,cu,du,uu,mu,pu,fu,_u,ku,bu,gu,hu,yu;var la=f(()=>{Ir();Ar();$r();Dr();Fr();Nr();Gr();Br();Lr();Kr();Hr();Vr();zr();Wr();Qr();Jr();Xr();Yr();Zr();eo();to();no();io();ro();oo();so();ao();lo();co();uo();mo();po();fo();_o();ko();bo();go();ho();yo();Ro();wo();To();vo();So();xo();Co();jo();Po();Eo();qo();Oo();Io();Ao();$o();Uo();Mo();Do();Fo();No();Go();Bo();Lo();Ko();Ho();Vo();zo();Wo();Qo();Jo();Xo();Yo();Zo();es();ts();ns();is();rs();os();ss();as();ls();Ci();Ci();cs();ds();us();ms();ji();ji();ps();fs();_s();ks();bs();gs();hs();ys();Rs();ws();Ts();vs();Ss();xs();Cs();js();Ps();Es();qs();Os();Ml();Is();As();$s();Us();Ms();Ds();Fs();Ns();Gs();Bs();Ls();Ks();Hs();Vs();zs();Ws();Qs();Js();Xs();Ys();Zs();ea();ta();na();ia();ra();oa();sa();aa();iu=x("apps",{Secrets:Ut}),ru=x("billing",{Alerts:Oe,CreditBalanceSummary:Ke,CreditBalanceTransactions:He,CreditGrants:Ve,MeterEventAdjustments:st,MeterEvents:dt,Meters:mt}),ou=x("billingPortal",{Configurations:Ne,Sessions:Mt}),su=x("checkout",{Sessions:Dt}),au=x("climate",{Orders:ft,Products:Tt,Suppliers:Gt}),lu=x("entitlements",{ActiveEntitlements:qe,Features:et}),cu=x("financialConnections",{Accounts:Pe,Sessions:Ft,Transactions:Ht}),du=x("forwarding",{Requests:At}),uu=x("identity",{VerificationReports:Yt,VerificationSessions:Zt}),mu=x("issuing",{Authorizations:Ae,Cardholders:Me,Cards:De,Disputes:Je,PersonalizationDesigns:yt,PhysicalBundles:wt,Tokens:Lt,Transactions:Vt}),pu=x("radar",{EarlyFraudWarnings:Xe,PaymentEvaluations:ht,ValueListItems:Jt,ValueLists:Xt}),fu=x("reporting",{ReportRuns:Ot,ReportTypes:It}),_u=x("sigma",{ScheduledQueryRuns:$t}),ku=x("tax",{Associations:Ie,Calculations:Ue,Registrations:qt,Settings:Nt,Transactions:zt}),bu=x("terminal",{Configurations:Ge,ConnectionTokens:Le,Locations:ot,OnboardingLinks:pt,Readers:vt}),gu=x("testHelpers",{ConfirmationTokens:Be,Customers:We,Refunds:Et,TestClocks:Bt,Issuing:x("issuing",{Authorizations:$e,Cards:Fe,PersonalizationDesigns:Rt,Transactions:Wt}),Terminal:x("terminal",{Readers:St}),Treasury:x("treasury",{InboundTransfers:it,OutboundPayments:_t,OutboundTransfers:bt,ReceivedCredits:xt,ReceivedDebits:jt})}),hu=x("treasury",{CreditReversals:ze,DebitReversals:Qe,FinancialAccounts:tt,InboundTransfers:rt,OutboundPayments:kt,OutboundTransfers:gt,ReceivedCredits:Ct,ReceivedDebits:Pt,TransactionEntries:Kt,Transactions:Qt}),yu=x("v2",{Billing:x("billing",{MeterEventAdjustments:at,MeterEventSession:lt,MeterEventStream:ct,MeterEvents:ut}),Commerce:x("commerce",{ProductCatalog:x("productCatalog",{Imports:nt})}),Core:x("core",{AccountLinks:Ce,AccountTokens:je,Accounts:Ee,EventDestinations:Ye,Events:Ze})})});var Dl=f(()=>{Ri()});class ca{constructor(e){this.stripe=e,this.secrets=new Ut(e)}}var Fl=f(()=>{Ho()});class da{constructor(e){this.stripe=e,this.alerts=new Oe(e),this.creditBalanceSummaries=new Ke(e),this.creditBalanceTransactions=new He(e),this.creditGrants=new Ve(e),this.meters=new mt(e),this.meterEvents=new dt(e),this.meterEventAdjustments=new st(e)}}var Nl=f(()=>{Nr();Yr();Zr();eo();Ro();ho();_o()});class ua{constructor(e){this.stripe=e,this.configurations=new Ne(e),this.sessions=new Mt(e)}}var Gl=f(()=>{Wr();Vo()});class ma{constructor(e){this.stripe=e,this.sessions=new Dt(e)}}var Bl=f(()=>{zo()});class pa{constructor(e){this.stripe=e,this.orders=new ft(e),this.products=new Tt(e),this.suppliers=new Gt(e)}}var Ll=f(()=>{To();Oo();Jo()});class fa{constructor(e){this.stripe=e,this.activeEntitlements=new qe(e),this.features=new et(e)}}var Kl=f(()=>{Fr();lo()});class _a{constructor(e){this.stripe=e,this.accounts=new Pe(e),this.sessions=new Ft(e),this.transactions=new Ht(e)}}var Hl=f(()=>{$r();Wo();es()});class ka{constructor(e){this.stripe=e,this.requests=new At(e)}}var Vl=f(()=>{Lo()});class ba{constructor(e){this.stripe=e,this.verificationReports=new Yt(e),this.verificationSessions=new Zt(e)}}var zl=f(()=>{as();ls()});class ga{constructor(e){this.stripe=e,this.authorizations=new Ae(e),this.cards=new De(e),this.cardholders=new Me(e),this.disputes=new Je(e),this.personalizationDesigns=new yt(e),this.physicalBundles=new wt(e),this.tokens=new Lt(e),this.transactions=new Vt(e)}}var Wl=f(()=>{Br();Vr();Hr();ro();Po();qo();Yo();ts()});class ha{constructor(e){this.stripe=e,this.earlyFraudWarnings=new Xe(e),this.paymentEvaluations=new ht(e),this.valueLists=new Xt(e),this.valueListItems=new Jt(e)}}var Ql=f(()=>{oo();jo();ss();os()});class ya{constructor(e){this.stripe=e,this.reportRuns=new Ot(e),this.reportTypes=new It(e)}}var Jl=f(()=>{Go();Bo()});class Ra{constructor(e){this.stripe=e,this.scheduledQueryRuns=new $t(e)}}var Xl=f(()=>{Ko()});class wa{constructor(e){this.stripe=e,this.associations=new Ie(e),this.calculations=new Ue(e),this.registrations=new qt(e),this.settings=new Nt(e),this.transactions=new zt(e)}}var Yl=f(()=>{Gr();Kr();No();Qo();ns()});class Ta{constructor(e){this.stripe=e,this.configurations=new Ge(e),this.connectionTokens=new Le(e),this.locations=new ot(e),this.onboardingLinks=new pt(e),this.readers=new vt(e)}}var Zl=f(()=>{Qr();Xr();fo();wo();Io()});class va{constructor(e){this.stripe=e,this.authorizations=new $e(e),this.cards=new Fe(e),this.personalizationDesigns=new Rt(e),this.transactions=new Wt(e)}}var ec=f(()=>{Lr();zr();Eo();is()});class Sa{constructor(e){this.stripe=e,this.readers=new St(e)}}var tc=f(()=>{Ao()});class xa{constructor(e){this.stripe=e,this.inboundTransfers=new it(e),this.outboundPayments=new _t(e),this.outboundTransfers=new bt(e),this.receivedCredits=new xt(e),this.receivedDebits=new jt(e)}}var nc=f(()=>{mo();vo();xo();$o();Mo()});class Ca{constructor(e){this.stripe=e,this.confirmationTokens=new Be(e),this.customers=new We(e),this.refunds=new Et(e),this.testClocks=new Bt(e),this.issuing=new va(e),this.terminal=new Sa(e),this.treasury=new xa(e)}}var ic=f(()=>{Jr();no();Fo();Xo();ec();tc();nc()});class ja{constructor(e){this.stripe=e,this.creditReversals=new ze(e),this.debitReversals=new Qe(e),this.financialAccounts=new tt(e),this.inboundTransfers=new rt(e),this.outboundPayments=new kt(e),this.outboundTransfers=new gt(e),this.receivedCredits=new Ct(e),this.receivedDebits=new Pt(e),this.transactions=new Qt(e),this.transactionEntries=new Kt(e)}}var rc=f(()=>{to();io();co();po();So();Co();Uo();Do();rs();Zo()});class Pa{constructor(e){this.stripe=e,this.meterEvents=new ut(e),this.meterEventAdjustments=new at(e),this.meterEventSession=new lt(e),this.meterEventStream=new ct(e)}}var oc=f(()=>{yo();ko();bo();go()});class Ea{constructor(e){this.stripe=e,this.imports=new nt(e)}}var sc=f(()=>{uo()});class qa{constructor(e){this.stripe=e,this.productCatalog=new Ea(e)}}var ac=f(()=>{sc()});class Oa{constructor(e){this.stripe=e,this.accounts=new Ee(e),this.accountLinks=new Ce(e),this.accountTokens=new je(e),this.events=new Ze(e),this.eventDestinations=new Ye(e)}}var lc=f(()=>{Dr();Ir();Ar();ao();so()});class Ia{constructor(e){this.stripe=e,this.billing=new Pa(e),this.commerce=new qa(e),this.core=new Oa(e)}}var cc=f(()=>{oc();ac();lc()});class v{static initialize(e,t=bc){v._platformFunctions=e,v._requestSenderFactory=t,v.webhooks=ql(e),v.createNodeHttpClient=e.createNodeHttpClient,v.createFetchHttpClient=e.createFetchHttpClient,v.createNodeCryptoProvider=e.createNodeCryptoProvider,v.createSubtleCryptoProvider=e.createSubtleCryptoProvider;let n=e.getEnv(),i=e.getRuntimeVersion();v.aiAgent=n?_l(n):"",v.AI_AGENT=v.aiAgent,v.USER_AGENT={bindings_version:v.PACKAGE_VERSION,lang:"node",typescript:!1,...i?{lang_version:i}:{},...v.aiAgent?{ai_agent:v.aiAgent}:{}}}constructor(e,t={}){this._authenticator=null;let n=this._getPropsFromConfig(t);this._platformFunctions=v._platformFunctions,Object.defineProperty(this,"_emitter",{value:this._platformFunctions.createEmitter(),enumerable:!1,configurable:!1,writable:!1}),this.VERSION=v.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 i=n.httpAgent||null;this._api={host:n.host||Aa,port:n.port||dc,protocol:n.protocol||"https",basePath:uc,version:n.apiVersion||mc,timeout:ki("timeout",n.timeout,pc),maxNetworkRetries:ki("maxNetworkRetries",n.maxNetworkRetries,2),agent:i,httpClient:n.httpClient||(i?this._platformFunctions.createNodeHttpClient(i):this._platformFunctions.createDefaultHttpClient()),dev:!1,stripeAccount:n.stripeAccount||null,stripeContext:n.stripeContext||null};let r=n.typescript||!1;if(r!==v.USER_AGENT.typescript)v.USER_AGENT.typescript=r;if(n.appInfo)this._setAppInfo(n.appInfo);this._setAuthenticator(e,n.authenticator||null),this.errors=Si,this.Decimal=M,this.webhooks=v.webhooks,this._prevRequestMetrics=[],this._enableTelemetry=n.telemetry!==!1,this._emitEventBodies=n.emitEventBodies===!0,this._requestSender=v._requestSenderFactory(this),this.accountLinks=new en(this),this.accountSessions=new tn(this),this.accounts=new oe(this),this.applePayDomains=new nn(this),this.applicationFees=new rn(this),this.balance=new se(this),this.balanceSettings=new on(this),this.balanceTransactions=new sn(this),this.charges=new an(this),this.confirmationTokens=new ln(this),this.countrySpecs=new cn(this),this.coupons=new dn(this),this.creditNotes=new un(this),this.customerSessions=new pn(this),this.customers=new mn(this),this.disputes=new fn(this),this.ephemeralKeys=new _n(this),this.events=new kn(this),this.exchangeRates=new bn(this),this.fileLinks=new hn(this),this.files=new gn(this),this.invoiceItems=new Rn(this),this.invoicePayments=new wn(this),this.invoiceRenderingTemplates=new Tn(this),this.invoices=new yn(this),this.mandates=new vn(this),this.paymentAttemptRecords=new xn(this),this.paymentIntents=new Cn(this),this.paymentLinks=new jn(this),this.paymentMethodConfigurations=new En(this),this.paymentMethodDomains=new qn(this),this.paymentMethods=new Pn(this),this.paymentRecords=new On(this),this.payouts=new In(this),this.plans=new An(this),this.prices=new $n(this),this.products=new Un(this),this.promotionCodes=new Mn(this),this.quotes=new Dn(this),this.refunds=new Fn(this),this.reviews=new Nn(this),this.setupAttempts=new Gn(this),this.setupIntents=new Bn(this),this.shippingRates=new Ln(this),this.sources=new Kn(this),this.subscriptionItems=new Vn(this),this.subscriptionSchedules=new zn(this),this.subscriptions=new Hn(this),this.taxCodes=new Wn(this),this.taxIds=new Qn(this),this.taxRates=new Jn(this),this.tokens=new Xn(this),this.topups=new Yn(this),this.transfers=new Zn(this),this.webhookEndpoints=new ei(this),this.apps=new ca(this),this.billing=new da(this),this.billingPortal=new ua(this),this.checkout=new ma(this),this.climate=new pa(this),this.entitlements=new fa(this),this.financialConnections=new _a(this),this.forwarding=new ka(this),this.identity=new ba(this),this.issuing=new ga(this),this.radar=new ha(this),this.reporting=new ya(this),this.sigma=new Ra(this),this.tax=new wa(this),this.terminal=new Ta(this),this.testHelpers=new Ca(this),this.treasury=new ja(this),this.v2=new Ia(this),this.account=this.accounts,this.oauth=new Sn(this)}rawRequest(e,t,n,i){return this._requestSender._rawRequest(e,t,n,i)}_setAuthenticator(e,t){if(e&&t)throw Error("Can't specify both apiKey and authenticator");if(!e&&!t)throw Error("Neither apiKey nor config.authenticator provided");this._authenticator=e?cr(e):t}_setAppInfo(e){if(e&&typeof e!=="object")throw Error("AppInfo must be an object.");if(e&&!e.name)throw Error("AppInfo.name is required");e=e||{},this._appInfo=Ru.reduce((t,n)=>{if(typeof e[n]=="string")t=t||{},t[n]=e[n];return t},{})}setClientId(e){this._clientId=e}getClientId(){return this._clientId}getConstant(e){switch(e){case"DEFAULT_HOST":return Aa;case"DEFAULT_PORT":return dc;case"DEFAULT_BASE_PATH":return uc;case"DEFAULT_API_VERSION":return mc;case"DEFAULT_TIMEOUT":return pc;case"MAX_NETWORK_RETRY_DELAY_SEC":return fc;case"INITIAL_NETWORK_RETRY_DELAY_SEC":return _c}return v[e]}resolveBaseAddress(e){let t=this.getApiField("host");if(t!==Aa)return t;return ar[e]}getMaxNetworkRetries(){return this.getApiField("maxNetworkRetries")}_setApiNumberField(e,t,n){let i=ki(e,t,n);this._setApiField(e,i)}getMaxNetworkRetryDelay(){return fc}getInitialNetworkRetryDelay(){return _c}getClientUserAgent(e){return this.getClientUserAgentSeeded(v.USER_AGENT,e)}getClientUserAgentSeeded(e,t){let n={};for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;n[o]=encodeURIComponent(e[o]??"null")}let i=this._platformFunctions.getPlatformInfo();if(i&&this.getTelemetryEnabled())n.platform=encodeURIComponent(i);else delete n.platform;let r=this.getApiField("httpClient");if(r)n.httplib=encodeURIComponent(r.getClientName());if(this._appInfo)n.application=this._appInfo;if(this.getTelemetryEnabled()){let o=this._platformFunctions.getTelemetryId();if(o)n.telemetry_id=o}t(JSON.stringify(n))}getAppInfoAsString(){if(!this._appInfo)return"";let e=this._appInfo.name;if(this._appInfo.version)e+=`/${this._appInfo.version}`;if(this._appInfo.url)e+=` (${this._appInfo.url})`;return e}getTelemetryEnabled(){return this._enableTelemetry}getEmitEventBodiesEnabled(){return this._emitEventBodies}_prepResources(){for(let e in ae){if(!Object.prototype.hasOwnProperty.call(ae,e))continue;this[pl(e.replace("Resource",""))]=new ae[e](this)}}_getPropsFromConfig(e){if(!e)return{};let t=typeof e==="string";if(!(e===Object(e)&&!Array.isArray(e))&&!t)throw Error("Config must either be an object or a string");if(t)return{apiVersion:e};if(Object.keys(e).filter((r)=>!kc.includes(r)).length>0)throw Error(`Config object may only contain the following: ${kc.join(", ")}`);return e}_setApiField(e,t){this._api[e]=t}getApiField(e){return this._api[e]}parseEventNotification(e,t,n,i,r,o){if(!this.webhooks.signature)throw Error("ERR: missing signature helper, unable to verify");this.webhooks.signature.verifyHeader(e,t,n,i||this.webhooks.DEFAULT_TOLERANCE,r||this._platformFunctions.createDefaultCryptoProvider(),o);let s=e instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(e)):JSON.parse(e);if(s&&s.object==="event")throw Error("You passed a webhook payload to stripe.parseEventNotification, which expects an event notification. Use stripe.webhooks.constructEvent instead.");if(s.context)s.context=K.parse(s.context);return s.fetchEvent=()=>this._requestSender._rawRequest("GET",`/v2/core/events/${s.id}`,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_event"]),s.fetchRelatedObject=()=>{if(!s.related_object)return Promise.resolve(null);return this._requestSender._rawRequest("GET",s.related_object.url,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_related_object"])},s}async parseEventNotificationAsync(e,t,n,i,r,o){if(!this.webhooks.signature)throw Error("ERR: missing signature helper, unable to verify");await this.webhooks.signature.verifyHeaderAsync(e,t,n,i||this.webhooks.DEFAULT_TOLERANCE,r||this._platformFunctions.createDefaultCryptoProvider(),o);let s=e instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(e)):JSON.parse(e);if(s&&s.object==="event")throw Error("You passed a webhook payload to stripe.parseEventNotificationAsync, which expects an event notification. Use stripe.webhooks.constructEventAsync instead.");if(s.context)s.context=K.parse(s.context);return s.fetchEvent=()=>this._requestSender._rawRequest("GET",`/v2/core/events/${s.id}`,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_event"]),s.fetchRelatedObject=()=>{if(!s.related_object)return Promise.resolve(null);return this._requestSender._rawRequest("GET",s.related_object.url,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_related_object"])},s}}var Aa="api.stripe.com",dc="443",uc="/v1/",mc,pc=80000,fc=5,_c=0.5,Ru,kc,bc=(e)=>new re(e,d.MAX_BUFFERED_REQUEST_METRICS);var gc=f(()=>{xi();vl();b();lr();Ol();yi();hi();la();W();Dl();Ci();cs();ds();us();ms();ji();ps();fs();_s();ks();bs();gs();hs();ys();Rs();ws();Ts();Ss();xs();Cs();js();Ps();Es();qs();Os();Is();As();$s();Us();Ms();Ds();Fs();Ns();Gs();Bs();Ls();Ks();Hs();Vs();zs();Ws();Qs();Js();Xs();Ys();Zs();ea();ta();na();ia();ra();oa();sa();aa();Fl();Nl();Gl();Bl();Ll();Kl();Hl();Vl();zl();Wl();Ql();Jl();Xl();Yl();Zl();ic();rc();cc();vs();la();mc=Or,Ru=["name","version","url","partner_id"],kc=["authenticator","apiVersion","typescript","maxNetworkRetries","httpAgent","httpClient","timeout","host","port","protocol","telemetry","emitEventBodies","appInfo","stripeAccount","stripeContext"];v.PACKAGE_VERSION="22.3.2";v.API_VERSION=Or;v.aiAgent="";v.AI_AGENT="";v.USER_AGENT={bindings_version:v.PACKAGE_VERSION,lang:"node",typescript:!1};v.StripeResource=d;v.resources=ae;v.HttpClient=q;v.HttpClientResponse=he;v.CryptoProvider=Re;v.StripeContext=K;v.errors=Si;v.Decimal=M;v._requestSenderFactory=bc});var hc={};Ii(hc,{Decimal:()=>M,Stripe:()=>v,default:()=>wu});var wu;var yc=f(()=>{Tl();Ri();gc();v.initialize(new _r);wu=v});import"@stacksjs/validation";import{log as Ai}from"@stacksjs/cli";import{db as Ga}from"@stacksjs/database";async function ed(e,t={}){let{olderThanDays:n=30,column:i="created_at",query:r}=t;try{if(r){let l=Ga.deleteFrom(e);l=r(l);let u=await l.execute(),m=Array.isArray(u)?u:[u],p=Number(m[0]?.numDeletedRows??m.length??0);return Ai.info(`Pruned ${p} records from ${e}`),p}let o=new Date;o.setDate(o.getDate()-n);let s=await Ga.deleteFrom(e).where(i,"<",o.toISOString()).execute(),a=Array.isArray(s)?s:[s],c=Number(a[0]?.numDeletedRows??a.length??0);return Ai.info(`Pruned ${c} records from ${e} older than ${n} days`),c}catch(o){throw Ai.error(`Failed to prune ${e}:`,o),o}}async function Sf(e,t={}){return ed(e,t)}function xf(e){if(!e?.prunable)return null;if(typeof e.prunable==="boolean")return{olderThanDays:30,column:"created_at"};return e.prunable}import{createCipheriv as td,createDecipheriv as nd,createHash as id,randomBytes as rd}from"crypto";import{log as ai}from"@stacksjs/logging";var Ba="enc:",La="aes-256-gcm",od=12,si=null;async function Ka(){if(si)return si;let e=process.env.APP_KEY;if(!e)try{e=(await import("@stacksjs/config").catch(()=>null))?.config?.app?.key}catch{}if(!e)return null;return si=id("sha256").update(e).digest(),si}function ue(e){return typeof e==="string"&&e.startsWith(Ba)}async function $i(e){if(e==null)return e;if(ue(e))return e;if(typeof e!=="string")return e;let t=await Ka();if(!t)return ai.warn("[orm] encrypted attribute: APP_KEY not set - storing value in plaintext"),e;let n=rd(od),i=td(La,t,n),r=Buffer.concat([i.update(e,"utf8"),i.final()]),o=i.getAuthTag();return`${Ba}${n.toString("base64")}:${o.toString("base64")}:${r.toString("base64")}`}async function Ui(e){if(e==null)return e;if(typeof e!=="string")return e;if(!ue(e))return e;try{let t=await Ka();if(!t)return ai.warn("[orm] encrypted attribute: APP_KEY not set - cannot decrypt"),null;let[,n,i,r]=e.split(":");if(!n||!i||!r)return ai.warn("[orm] encrypted attribute: malformed envelope, returning null"),null;let o=Buffer.from(n,"base64"),s=Buffer.from(i,"base64"),a=Buffer.from(r,"base64"),c=nd(La,t,o);return c.setAuthTag(s),Buffer.concat([c.update(a),c.final()]).toString("utf8")}catch(t){return ai.warn("[orm] encrypted attribute: decrypt failed (key rotation? corrupted ciphertext?)",{error:t}),null}}function Mi(e){let t=e.attributes;if(!t||typeof t!=="object")return[];let n=[];for(let[i,r]of Object.entries(t))if(r&&typeof r==="object"&&r.encrypted===!0)n.push(i);return n}import{sqlDateTime as sd}from"@stacksjs/database";import{log as pe}from"@stacksjs/logging";var ad=[/^password$/i,/^password_hash$/i,/^api_key$/i,/_token$/i,/_secret$/i,/^remember_token$/i],Va="model_audits",Ni=null;function ld(e){Ni=e}async function Di(){if(Ni!=null)return Ni;try{let e=await import("@stacksjs/router").catch(()=>null);if(!e)return null;let t=e.getCurrentRequest;if(typeof t!=="function")return null;let n=t();if(!n)return null;return(n.user??n._user)?.id??null}catch{return null}}function li(e){if(!e||typeof e!=="object")return null;let t={};for(let[n,i]of Object.entries(e)){if(ad.some((r)=>r.test(n)))continue;t[n]=i}return t}function me(e){if(!e||typeof e!=="object")return null;let t=e;if(t._attributes&&typeof t._attributes==="object")return{...t._attributes};return{...e}}function cd(e,t){if(!e||!t)return{old:e,next:t};let n={},i={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of r)if(e[o]!==t[o])n[o]=e[o],i[o]=t[o];return{old:n,next:i}}async function Fi(e,t=!1){try{let{db:n}=await import("@stacksjs/database");await n.insertInto(Va).values({auditable_type:e.auditable_type,auditable_id:e.auditable_id,event:e.event,old_values:e.old_values?JSON.stringify(e.old_values):null,new_values:e.new_values?JSON.stringify(e.new_values):null,user_id:e.user_id,created_at:sd()}).executeTakeFirst()}catch(n){if(pe.warn(`[orm] audit row write failed for ${e.auditable_type}#${String(e.auditable_id)} (${e.event})`,{error:n}),t)throw n}}function za(e){return{async audits(t){try{let{db:n}=await import("@stacksjs/database");return(await n.selectFrom(Va).selectAll().where("auditable_type","=",e).where("auditable_id","=",t).orderBy("created_at","desc").execute()??[]).map((r)=>({...r,old_values:typeof r.old_values==="string"?Ha(r.old_values):r.old_values,new_values:typeof r.new_values==="string"?Ha(r.new_values):r.new_values}))}catch(n){return pe.warn(`[orm] audits() lookup failed for ${e}#${String(t)}`,{error:n}),[]}}}}function Ha(e){try{return JSON.parse(e)}catch{return e}}function Wa(e){if(e&&typeof e==="object"&&"transactional"in e)return{transactional:e.transactional===!0};return{transactional:!1}}function Qa(e,t,n="id",i={}){let r=i.transactional===!0,o=e;if(typeof e.audits!=="function")e.audits=za(t).audits;let s=async(u)=>{if(!r)return await u();let{db:m}=await import("@stacksjs/database");return await m.transaction(async()=>u())},a=e.create;if(typeof a==="function")e.create=async function(...u){return await s(async()=>{let m=await a.apply(this,u);try{let p=me(m),k=p?.[n];if(k!=null){let _=await Di();await Fi({auditable_type:t,auditable_id:k,event:"created",old_values:null,new_values:li(p),user_id:_},r)}}catch(p){if(pe.warn(`[orm] audit(create) failed for ${t}`,{error:p}),r)throw p}return m})};let c=e.update;if(typeof c==="function")e.update=async function(u,m){return await s(async()=>{let p=o.find,k=typeof p==="function"?me(await p.call(o,u)):null,_=await c.call(this,u,m);try{let g=me(_)??(typeof p==="function"?me(await p.call(o,u)):null),{old:y,next:R}=cd(k,g);if(R&&Object.keys(R).length>0){let w=await Di();await Fi({auditable_type:t,auditable_id:u,event:"updated",old_values:li(y),new_values:li(R),user_id:w},r)}}catch(g){if(pe.warn(`[orm] audit(update) failed for ${t}#${String(u)}`,{error:g}),r)throw g}return _})};let l=(u)=>{let m=e[u];if(typeof m!=="function")return;e[u]=async function(p){return await s(async()=>{let k=o.find,_=typeof k==="function"?me(await k.call(o,p)):null,g=await m.call(this,p);try{if(g!==!1&&_){let y=await Di();await Fi({auditable_type:t,auditable_id:p,event:"deleted",old_values:li(_),new_values:null,user_id:y},r)}}catch(y){if(pe.warn(`[orm] audit(${u}) failed for ${t}#${String(p)}`,{error:y}),r)throw y}return g})}};l("delete"),l("softDelete")}import{db as dd,sql as ud,sqlDateTime as Gi}from"@stacksjs/database";function G(e,t){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/commentable] ${t} requires a positive numeric id (received ${String(e)})`)}var fe="commentable_upvotes",_e="commentables";function md(e){let t=e;return t.code==="SQLITE_CONSTRAINT_UNIQUE"||t.code==="SQLITE_CONSTRAINT"||t.code==="23505"||t.errno===1062||/unique|duplicate/i.test(t.message??"")}function Bi(e){let t=dd;return{async comments(n){return G(n,"comments"),await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).selectAll().execute()},async commentCount(n){let i=await t.selectFrom("commentables").select(ud`count(*) as count`).where("commentables_id","=",n).where("commentables_type","=",e).executeTakeFirst();return Number(i?.count)||0},async addComment(n,i){if(G(n,"addComment"),!i||typeof i.title!=="string"||i.title.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.title");if(typeof i.body!=="string"||i.body.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.body");let r=await t.insertInto("commentables").values({...i,commentables_id:n,commentables_type:e,status:"pending",created_at:Gi(),updated_at:Gi()}).returningAll().executeTakeFirst();if(r&&typeof r==="object"&&"id"in r)return r;let o=r?.lastInsertRowid;if(o==null)return r;return await t.selectFrom("commentables").where("id","=",Number(o)).selectAll().executeTakeFirst()},async approvedComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","approved").selectAll().execute()},async pendingComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","pending").selectAll().execute()},async rejectedComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","rejected").selectAll().execute()},async upvoteComment(n,i){G(n,"upvoteComment"),G(i,"upvoteComment");let r=()=>t.selectFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).selectAll().executeTakeFirst(),o=await r();if(o)return o;try{await t.insertInto(fe).values({upvoteable_id:n,upvoteable_type:_e,user_id:i,created_at:Gi()}).execute()}catch(s){if(!md(s))throw s}return await r()},async removeCommentUpvote(n,i){G(n,"removeCommentUpvote"),G(i,"removeCommentUpvote"),await t.deleteFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).execute()},async commentUpvoteCount(n){G(n,"commentUpvoteCount");let i=await t.selectFrom(fe).select("count(*) as count").where("upvoteable_id","=",n).where("upvoteable_type","=",_e).executeTakeFirst();return Number(i?.count)||0},async hasUpvotedComment(n,i){return G(n,"hasUpvotedComment"),G(i,"hasUpvotedComment"),!!await t.selectFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).selectAll().executeTakeFirst()}}}import{db as pd,sql as fd,sqlDateTime as Ja}from"@stacksjs/database";function Li(e,t){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/taggable] ${t} requires a positive numeric id (received ${String(e)})`)}function Ki(e){let t=pd;return{async tags(n){return Li(n,"tags"),await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).selectAll().execute()},async tagCount(n){Li(n,"tagCount");let i=await t.selectFrom("taggables").select(fd`count(*) as count`).where("taggable_id","=",n).where("taggable_type","=",e).executeTakeFirst();return Number(i?.count)||0},async addTag(n,i){if(Li(n,"addTag"),!i||typeof i.name!=="string"||i.name.trim().length===0)throw Error("[orm/taggable] addTag requires a non-empty tag.name");return await t.insertInto("taggables").values({...i,taggable_id:n,taggable_type:e,slug:i.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),is_active:!0,created_at:Ja(),updated_at:Ja()}).execute(),await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("name","=",i.name).selectAll().executeTakeFirst()},async activeTags(n){return await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("is_active","=",!0).selectAll().execute()},async inactiveTags(n){return await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("is_active","=",!1).selectAll().execute()},async removeTag(n,i){await t.deleteFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("id","=",i).execute()}}}import{db as _d,sqlDateTime as ci}from"@stacksjs/database";function Hi(e){let t=_d;async function n(i){return(await t.selectFrom("categorizable_models").where("categorizable_id","=",i).where("categorizable_type","=",e).selectAll().execute()).map((o)=>o.category_id)}return{async categories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).selectAll().execute()},async categoryCount(i){return(await n(i)).length},async addCategory(i,r){let o=()=>t.selectFrom("categorizables").where("name","=",r.name).where("categorizable_type","=",e).selectAll().executeTakeFirst(),s=await o();if(!s)await t.insertInto("categorizables").values({name:r.name,description:r.description,slug:r.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),categorizable_type:e,is_active:!0,created_at:ci(),updated_at:ci()}).execute(),s=await o();return await t.insertInto("categorizable_models").values({categorizable_id:i,categorizable_type:e,category_id:s?.id,created_at:ci(),updated_at:ci()}).execute(),s},async activeCategories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).where("is_active","=",!0).selectAll().execute()},async inactiveCategories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).where("is_active","=",!1).selectAll().execute()},async removeCategory(i,r){await t.deleteFrom("categorizable_models").where("categorizable_id","=",i).where("categorizable_type","=",e).where("category_id","=",r).execute()}}}import{db as kd,sqlDateTime as bd}from"@stacksjs/database";function Vi(e,t){let n=kd,i=t?.table||`${e}_likes`,r=t?.foreignKey||`${e.replace(/s$/,"")}_id`;return{async likes(o){return await n.selectFrom(i).where(r,"=",o).selectAll().execute()},async likeCount(o){let s=await n.selectFrom(i).select("count(*) as count").where(r,"=",o).executeTakeFirst();return Number(s?.count)||0},async like(o,s){if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`[orm/likeable] like requires a positive numeric id (received ${String(o)})`);if(typeof s!=="number"||!Number.isFinite(s)||s<=0)throw Error(`[orm/likeable] like requires a positive numeric userId (received ${String(s)})`);let a=bd();try{return await n.insertInto(i).values({[r]:o,user_id:s,created_at:a,updated_at:a}).returningAll().executeTakeFirst()}catch(c){let l=c;if(!(l.code==="SQLITE_CONSTRAINT_UNIQUE"||l.code==="SQLITE_CONSTRAINT"||l.code==="23505"||l.errno===1062||/unique|duplicate/i.test(l.message??"")))throw c;let m=await n.selectFrom(i).where(r,"=",o).where("user_id","=",s).selectAll().executeTakeFirst();if(m)return m;throw c}},async unlike(o,s){await n.deleteFrom(i).where(r,"=",o).where("user_id","=",s).execute()},async isLiked(o,s){return!!await n.selectFrom(i).where(r,"=",o).where("user_id","=",s).selectAll().executeTakeFirst()},async likedBy(o){return(await n.selectFrom(i).select([r]).where("user_id","=",o).execute()).map((a)=>Number(a[r])).filter(Boolean)}}}function Za(e){let t=e;return t?.code==="SQLITE_CONSTRAINT_UNIQUE"||t?.code==="SQLITE_CONSTRAINT"||t?.code==="23505"||t?.errno===1062||/unique|duplicate/i.test(t?.message??"")}function gd(e,t,n){let i=e;if(e instanceof Error&&typeof i.status==="number"&&Number.isInteger(i.status)&&i.status>=400&&i.status<600){let r={error:e.message};if(i.details!==void 0)r.details=i.details;return{status:i.status,body:r}}if(Za(e))return{status:409,body:{error:`${t} already exists`}};return{status:500,body:{error:`Failed to ${n} ${t}`,detail:String(e)}}}function A(e){return e.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase()}function hd(e){let t={};for(let[n,i]of Object.entries(e))t[A(n)]=i;return t}function Bf(e,t){let n=String(t||"").replace(/^\/+|\/+$/g,""),i=String(e).replace(/^\/+/,"");return`/api/${n?`${n}/`:""}${i}`}function Lf(e){if(!e)return null;let t=e.attributes??{};if(Object.prototype.hasOwnProperty.call(t,"teamId")||Object.prototype.hasOwnProperty.call(t,"team_id"))return"team_id";return e.belongsTo?.some((n)=>n==="Team")?"team_id":null}function Kf(e,t,n){let i=Object.keys(e).find((o)=>A(o)===A(t));if(Array.isArray(n)){if(i===void 0)return{data:e,error:"Ownership value is required"};if(!n.some((o)=>String(o)===String(e[i])))return{data:e,error:"Ownership value is not available to this caller"};return{data:{...e,[t]:e[i]}}}if(n===null||n===void 0)return{data:e,error:"Caller has no ownership identity"};let r={...e};for(let o of Object.keys(r))if(A(o)===A(t))delete r[o];return r[t]=n,{data:r}}function yd(e){if(!e)return[];let t=Object.entries(e.attributes??{}).filter(([,n])=>n?.fillable===!0).map(([n])=>n);for(let n of e.belongsTo??[]){if(typeof n!=="string"||!n.trim())continue;let i=A(n.trim()).split("_").filter(Boolean);if(i.length===0)continue;let r=`${i[0]}${i.slice(1).map((o)=>`${o[0]?.toUpperCase()}${o.slice(1)}`).join("")}Id`;t.push(r)}return[...new Set(t)]}function Rd(e,t){if(!e||t.length===0)return{};let n={};for(let i of t){if(i in e){n[i]=e[i];continue}let r=A(i);if(r!==i&&r in e)n[i]=e[r]}return n}function wd(e,t){if(e?.name!=="date"||t instanceof Date||typeof t!=="string")return t;let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!n)return t;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),s=new Date(Date.UTC(i,r-1,o));if(s.getUTCFullYear()!==i||s.getUTCMonth()!==r-1||s.getUTCDate()!==o)return t;return s}function Hf(e,t){if(!t.length)return e;let n={...e};for(let i of t)delete n[i],delete n[A(i)];return n}function Vf(e,t){if(!e||t.length===0)return e;let n={...e};for(let i of t)delete n[i],delete n[A(i)];return n}var Td=["id","uuid","created_at","updated_at","deleted_at"];function zf(e,t){let n=new Map;for(let i of[...Object.keys(e??{}),...Td]){let r=A(i);if(!/^\w+$/.test(r))continue;n.set(i,r),n.set(r,r)}for(let i of t)n.delete(i),n.delete(A(i));return n}function Wf(e,t,n){if(!t)return e;let i=String(t).split(",").map((o)=>o.trim()).filter(Boolean),r=e;for(let o of i){let s=o.startsWith("-"),a=s?o.slice(1):o;if(!/^\w+$/.test(a))continue;let c=n.get(a);if(!c)continue;r=r.orderBy(c,s?"desc":"asc")}return r}var vd={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>e==null?null:typeof e==="string"?Sd(e):e,set:(e)=>e==null?null:typeof e==="string"?e:JSON.stringify(e)},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>e==null?[]:Array.isArray(e)?e:typeof e==="string"?xd(e):[],set:(e)=>e==null?null:Array.isArray(e)?JSON.stringify(e):e}};function Sd(e){try{return JSON.parse(e)}catch{return e}}function xd(e){try{return JSON.parse(e)}catch{return[]}}function Qf(e,t,n){if(!e||typeof e!=="object"||!t||Object.keys(t).length===0)return e;let i={...e};for(let[r,o]of Object.entries(t)){let s=typeof o==="string"?vd[o]:o;if(!s||typeof s[n]!=="function")continue;if(Object.prototype.hasOwnProperty.call(i,r))i[r]=s[n](i[r]);let a=A(r);if(a!==r&&Object.prototype.hasOwnProperty.call(i,a))i[a]=s[n](i[a])}return i}function el(e,t,n){let i=t?.attributes??{},r={};for(let[o,s]of Object.entries(i)){let a=s?.validation?.rule;if(!a||typeof a.validate!=="function")continue;let c=Object.prototype.hasOwnProperty.call(e,o);if(!c&&n==="updating")continue;let l=s!==null&&typeof s==="object"&&Object.prototype.hasOwnProperty.call(s,"default"),u=c?e[o]:l?s.default:void 0,m=wd(a,u),p=a.validate(m);if(!p?.valid&&Array.isArray(p?.errors)&&p.errors.length>0)r[o]=p.errors.map((k)=>s?.validation?.message?.[k?.code]??k?.message??"invalid")}return Object.keys(r).length===0?{valid:!0}:{valid:!1,errors:r}}function Jf(e,t,n){let i=Xa(n);return e.find((r)=>r.method===t&&Xa(String(r.path??""))===i)}function Xa(e){return e.replace(/\{[^}]*\}/g,"{}").replace(/:[^/]+/g,"{}")}function zi(e){if(Array.isArray(e))return e.filter((t)=>typeof t==="string"&&t.length>0);return typeof e==="string"&&e?[e]:[]}function Xf(e){let t=typeof e==="object"&&e!==null&&"middleware"in e,n=e?.middleware;if(!t)return{read:["auth"],write:["auth"],declared:!1};if(n&&typeof n==="object"&&!Array.isArray(n)){let r=n;return{read:"read"in r?zi(r.read):["auth"],write:"write"in r?zi(r.write):["auth"],declared:!0}}let i=zi(n);return{read:i,write:i,declared:!0}}var Ya=15,Cd=100;function Yf(e){let t=Number.parseInt(e.get("page")||String(1),10),n=Number.isFinite(t)?Math.max(1,t):1,i=Number.parseInt(e.get("per_page")||String(Ya),10),r=Math.min(Number.isFinite(i)?Math.max(1,i):Ya,Cd);return{page:n,perPage:r,offset:(n-1)*r}}function di(e,t){let n=new URL(e.toString());return n.searchParams.set("page",String(t)),`${n.pathname}${n.search}`}function jd(e,t,n,i,r,o){let s=(t-1)*n,a=i===0,c={page:t,per_page:n,from:a?null:s+1,to:a?null:s+i,has_more_pages:r,prev_page_url:t>1?di(e,t-1):null,next_page_url:r?di(e,t+1):null};if(o!==void 0&&!Number.isNaN(o)){let l=Math.max(1,Math.ceil(o/n));c.total=o,c.last_page=l,c.first_page_url=di(e,1),c.last_page_url=di(e,l)}return c}function Zf(e,t,n,i,r,o){let{page:s,...a}=jd(e,t,n,i,r,o);return{current_page:s,...a}}import{cacheRequestQuery as Pd}from"@stacksjs/router";var ui=new WeakMap;function n_(e,t){return Pd(`batchLoad:${e.name??"model"}:${String(t)}`,async()=>new Promise((n,i)=>{let r=ui.get(e);if(!r)r={keys:[],resolvers:[],scheduled:!1},ui.set(e,r);if(r.keys.push(t),r.resolvers.push({key:t,resolve:n,reject:i}),r.scheduled)return;r.scheduled=!0,Promise.resolve().then(async()=>{let o=ui.get(e);if(!o)return;ui.delete(e);let s=Array.from(new Set(o.keys));try{let a=typeof e.findMany==="function"?await e.findMany(s):await Promise.all(s.map((l)=>e.find?.(l))),c=new Map;for(let l of a??[]){let u=l?.id;if(u!==void 0)c.set(u,l)}for(let l of o.resolvers)l.resolve(c.get(l.key))}catch(a){for(let c of o.resolvers)c.reject(a)}})}))}import{db as s_}from"@stacksjs/database";class Ed{conditions=[];where(e,...t){let[n,i]=t,r=i===void 0?"=":n,o=i===void 0?n:i;this.addCondition("and","where",e,r,o)}orWhere(e,...t){let[n,i]=t,r=i===void 0?"=":n,o=i===void 0?n:i;this.addCondition("or","where",e,r,o)}whereIn(e,t){this.conditions.push({type:"and",method:"whereIn",column:e,values:t})}whereNotIn(e,t){this.conditions.push({type:"and",method:"whereIn",column:e,values:t,operator:"not in"})}whereNull(e){this.conditions.push({type:"and",method:"whereNull",column:e})}whereNotNull(e){this.conditions.push({type:"and",method:"whereNotNull",column:e})}whereBetween(e,t){this.conditions.push({type:"and",method:"whereBetween",column:e,range:t})}whereExists(e){this.conditions.push({type:"and",method:"whereExists",column:"",callback:e})}addCondition(e,t,n,i,r){this.conditions.push({type:e,method:t,column:n,operator:i,value:r})}getConditions(){return this.conditions}}import{db as Wi,runInTransactionScope as qd}from"@stacksjs/database";async function c_(e,t){return await qd(async()=>await Wi.transaction(e,t))}async function d_(e){return await Wi.savepoint(e)}function u_(e,t){return Wi.transactional(e,t)}import{path as B}from"@stacksjs/path";import{fs as ne,globSync as Yi}from"@stacksjs/storage";import{plural as ol,singular as tl,snakeCase as E}from"@stacksjs/strings";import{isString as mi}from"@stacksjs/validation";function sl(e){let t=e.belongsToMany;if(!t)return[];if(Array.isArray(t))return t.map((n)=>({relationName:typeof n==="string"?E(n):E(String(n.model)),relation:n}));return Object.entries(t).map(([n,i])=>{if(typeof i==="string")return{relationName:n,relation:i};return{relationName:n,relation:{model:i.model,pivotTable:i.table,firstForeignKey:i.foreignKey,secondForeignKey:i.relatedKey}}})}async function b_(e){if(typeof e==="string")e=(await import(e)).default;return e.table??E(ol(e?.name||""))}function ke(e,t){if(e.name)return e.name;return B.basename(t).replace(/\.ts$/,"")}function F(e,t){if(e.table)return e.table;return E(ol(ke(e,t)))}function Od(e,t){let n=[e,t];return n.sort(),n.join("_")}function g_(e,t){return t in e}async function Id(e,t){let n=[];if(e.hasOne)for(let i of e.hasOne)n.push(await Qi(i,e,t,"hasOne"));if(e.hasMany)for(let i of e.hasMany)n.push(await Qi(i,e,t,"hasMany"));if(e.belongsTo)for(let i of e.belongsTo)n.push(await Qi(i,e,t,"belongsTo"));if(e.hasOneThrough)for(let i of e.hasOneThrough)n.push(await il(i,e,t,"hasOneThrough"));if(e.hasManyThrough)for(let i of e.hasManyThrough)n.push(await il(i,e,t,"hasManyThrough"));if(e.belongsToMany)for(let{relationName:i,relation:r}of sl(e))n.push(await $d(r,e,t,"belongsToMany",i));if(e.morphOne)n.push(await rl(e.morphOne,e,t,"morphOne"));if(e.morphMany){let i=Array.isArray(e.morphMany)?e.morphMany:[e.morphMany];for(let r of i)n.push(await rl(r,e,t,"morphMany"))}if(e.morphTo){let i=e.morphTo,r=Array.isArray(i)?i:typeof i==="object"&&i!==null?[i]:[];for(let o of r)n.push(Ad(o,e,t))}if(e.morphToMany){let i=Array.isArray(e.morphToMany)?e.morphToMany:[e.morphToMany];for(let r of i)n.push(nl(r,e,t,"morphToMany"))}if(e.morphedByMany){let i=Array.isArray(e.morphedByMany)?e.morphedByMany:[e.morphedByMany];for(let r of i)n.push(nl(r,e,t,"morphedByMany"))}return n}function Ad(e,t,n){let i=e&&typeof e==="object"&&e.name?String(e.name):`${E(n)}able`,r=e?.type||`${i}_type`;return{relationship:"morphTo",model:"",table:"",relationTable:"",foreignKey:e?.id||`${i}_id`,modelKey:r,relationName:i,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:""}}function nl(e,t,n,i){let r=typeof e==="object"&&e!==null,o=r?String(e.model||""):String(e),s=r&&e.morphName?String(e.morphName):`${E(n)}able`,a=r&&e.pivotTable?String(e.pivotTable):s,c=r&&e.id||`${s}_id`,l=r&&e.type||`${s}_type`;return{relationship:i,model:o,table:"",relationTable:"",foreignKey:c,modelKey:l,relationName:s,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:c,pivotKey:l,pivotTable:a}}async function pi(e,t){let n=Xi(`${t}.ts`),i=Xi(`${e}.ts`),r=Ji(`${e}.ts`),o=Ji(`${t}.ts`);if(!n&&!o)throw Error(`Model not found: ${t}`);if(!i&&!r)throw Error(`Model not found: ${e}`);let s;try{if(ne.existsSync(n))s=(await import(n)).default;else s=(await import(o)).default}catch(c){throw Error(`Failed to load model: ${t}. Error: ${c?.message||"Unknown error"}`)}let a=ne.existsSync(i)?i:r;return{modelRelation:s,modelPath:a,modelRelationPath:ne.existsSync(n)?n:o}}async function il(e,t,n,i){let r="",o="",s="",a="";if(mi(e))r=e;else r=e.model,o=e.relationName||"",s=e.through,a=e.throughForeignKey||"";let{modelRelation:c,modelPath:l,modelRelationPath:u}=await pi(n,r),m=F(c,u),p=F(t,l),k=E(ke(c,u)),_=E(n);return{relationship:i,model:r,table:m,relationTable:p,foreignKey:`${_}_id`,modelKey:`${k}_id`,relationName:o,relationModel:n,throughModel:s,throughForeignKey:a,pivotForeign:`${_}_id`,pivotKey:`${k}_id`,pivotTable:p}}async function $d(e,t,n,i,r){let o="",s="",a="",c=E(n);if(mi(e))o=e;else o=e.model,s=e.pivotTable||"",a=e.firstForeignKey||`${c}_id`;let{modelRelation:l,modelPath:u,modelRelationPath:m}=await pi(n,o),p=F(l,m),k=F(t,u),_=E(ke(l,m));return{relationship:i,model:o,table:p,relationTable:k,foreignKey:typeof e==="string"?`${c}_id`:e.firstForeignKey||`${c}_id`,modelKey:typeof e==="string"?`${_}_id`:e.secondForeignKey||`${_}_id`,relationName:r,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:a,pivotKey:`${_}_id`,pivotTable:s}}async function rl(e,t,n,i){let r="",o="",s="",a="";if(mi(e))r=e,o=`${E(n)}able`;else r=e.model,o=e.morphName||`${E(n)}able`,s=e.type||`${o}_type`,a=e.id||`${o}_id`;let{modelRelation:c,modelPath:l,modelRelationPath:u}=await pi(n,r),m=F(c,u),p=F(t,l);return{relationship:i,model:r,table:m,relationTable:p,foreignKey:a||`${o}_id`,modelKey:s||`${o}_type`,relationName:o,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:p}}async function Qi(e,t,n,i){let r="",o="";if(mi(e))r=e;else r=e.model,o=e.relationName||"";let{modelRelation:s,modelPath:a,modelRelationPath:c}=await pi(n,r),l=F(s,c),u=F(t,a),m=E(ke(s,c)),p=E(n),k=typeof e==="string"?"":e.foreignKey||"",_={relationship:i,model:r,table:l,relationTable:u,foreignKey:k||`${p}_id`,modelKey:`${m}_id`,relationName:o,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:`${p}_id`,pivotKey:`${m}_id`,pivotTable:u};if(i==="belongsTo"){if(_.foreignKey="",k)_.modelKey=k}return _}function h_(e){let t=/belongs/,n=/has/,i=/Through/,r=/morph/;if(i.test(e))return"throughType";if(t.test(e))return"belongsType";if(n.test(e))return"hasType";if(r.test(e))return"morphType";return""}function y_(e){let t=/One/;if(/Many/.test(e))return"many";if(t.test(e))return"one";return""}async function R_(e,t){let n=[];if("belongsToMany"in e){for(let{relation:i}of sl(e)){let r,o;if(typeof i==="string")o=i;else o=i.model;let s=Xi(`${o}.ts`),a=Ji(`${o}.ts`);if(ne.existsSync(s))r=(await import(s)).default;else r=(await import(a)).default;let c=F(r,s),l=F(e,t),u=typeof i==="object"&&"firstForeignKey"in i?i.firstForeignKey:`${tl(l)}_${e.primaryKey}`,m=typeof i==="object"&&"secondForeignKey"in i?i.secondForeignKey:`${tl(c)}_${e.primaryKey}`;n.push({table:(typeof i==="object"&&"pivotTable"in i?i.pivotTable:void 0)??Od(l,c),firstForeignKey:u,secondForeignKey:m})}return n}return[]}async function w_(e){let t=Yi([B.userModelsPath("*.ts"),B.storagePath("framework/defaults/app/Models/**/*.ts")],{absolute:!0}),n=[];for(let i=0;i<t.length;i++){let r=t[i],o=await import(r);if(e===o.default.name)continue;let s=ke(o,r),a=await Id(o.default,s);if(!a.length)continue;let c=a.find((l)=>l.model===e);if(c)n.push(c)}return n}function T_(e){if(e===void 0)return[];return Object.keys(e).filter((t)=>e[t]?.hidden===!0)}function v_(e){let t=e.attributes;if(t===void 0)return[];return Object.keys(t).filter((n)=>t[n]?.guarded===!0).map((n)=>E(n))}function S_(e,t){let n=e.attributes,i=[];if(n===void 0)return[];let r=typeof e.traits?.billable==="object"||typeof e.traits?.billable==="boolean",o=typeof e.traits?.useAuth==="object"?e.traits?.useAuth.usePasskey:!1,s=e.traits?.useUuid||!1;if(r)i.push("stripe_id");if(s)i.push("uuid");if(o)i.push(...["two_factor_secret","public_key"]);let a=t.map((c)=>c.foreignKey).filter((c)=>c);return[...Object.keys(n).filter((c)=>{if(n===void 0)return!1;return n[c]?.fillable===!0}).map((c)=>E(c)),...i,...a]}async function x_(e,t){let n=e.attributes;if(!n)n={};let i=Object.keys(n),r=[],o=Bun.file(t),s="";try{if(await o.exists())s=await o.text()}catch{s=""}let a=/rule:.*$/gm,c;c=a.exec(s);while(c!==null)r.push(c[0]),c=a.exec(s);return i.map((u,m)=>{let p=n[u],k=null,_=!1,g=!1,y=!1,R=!1;if(p)k=p||null,_=p.unique||!1,g=p.hidden||!1,y=p.fillable||!1;let w=r[m]??"";return R=(p.validation?.rule).isRequired??!1,{field:u,default:k,unique:_,hidden:g,fillable:y,required:R,fieldArray:Ud(w)}})}function Ud(e){let t=e.split("rule: schema.");if(t.length!==2)return null;if(!t[1])t[1]="";let n=t[1].replace(/,/g,"");if(!n)return null;let i=n.split("."),r=/\(([^)]+)\)/;return i.map((o)=>{let s=r.exec(o),a=s?s[1]:null;return{entity:o.replace(r,"").replace(/\(|\)/g,""),charValue:a}})[0]||null}function C_(e){let t=e.fieldArray?.entity;switch(t){case"enum":return"string | string[]";case"date":return"Date | string";case"timestamp":return"Date | string";case"datetime":return"Date | string";case"float":return"number";case"double":return"number";case"decimal":return"number";case"integer":return"number";case"bigint":return"number";default:return t}}function Ji(e){let t=B.join(B.storagePath("framework/defaults/app/Models"),"/"),n=B.join(t,e);if(ne.existsSync(n))return n;return Yi(`${t}**/${e}`,{absolute:!0})[0]??""}function Xi(e){let t=B.join(B.userModelsPath("/"),"/"),n=B.join(t,e);if(ne.existsSync(n))return n;return Yi(`${t}**/${e}`,{absolute:!0})[0]??""}function j_(e){let t=typeof e==="number"?new Date(e):typeof e==="string"?new Date(e):e;if(Number.isNaN(t.getTime()))throw Error(`Invalid date value: ${String(e)}`);return t.toISOString().replace("T"," ").split(".")[0]??""}function P_(e){return e.toISOString().split("T")[0]??""}function E_(e){return e.getTime()}import{createModel as Cu,registerModel as ju}from"@stacksjs/query-builder";import{log as I}from"@stacksjs/logging";import{snakeCase as H}from"@stacksjs/strings";import{AsyncLocalStorage as Oc}from"async_hooks";function Md(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&typeof t.current_page==="number"&&typeof t.per_page==="number"&&typeof t.total==="number"&&typeof t.last_page==="number"}function Dd(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&typeof t.current_page==="number"&&typeof t.per_page==="number"&&typeof t.has_more_pages==="boolean"&&!("total"in t)}function Fd(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&(typeof t.next_cursor==="string"||t.next_cursor===null)}function Zi(e){let{data:t}=e,{perPage:n,page:i,total:r,lastPage:o}=e.meta,s=t.length===0,a=s?null:(i-1)*n+1,c=s?null:a+t.length-1;return{data:t,current_page:i,per_page:n,total:r,last_page:o,from:a,to:c,has_more_pages:i<o}}function er(e){return{data:e.data,current_page:e.meta.page,per_page:e.meta.perPage,has_more_pages:e.meta.hasMore}}function tr(e){return{data:e.data,per_page:e.meta.perPage,next_cursor:al(e.meta.nextCursor),prev_cursor:al(e.meta.prevCursor),has_more_pages:e.meta.nextCursor!==null&&e.meta.nextCursor!==void 0}}function al(e){if(e===null||e===void 0)return null;if(typeof e==="string")return e;return JSON.stringify(e)}function ir(e,t){let n=sr(),i=n?nr(n,"per_page"):void 0,r=n?nr(n,"page"):void 0,o=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,i??15)),s=Math.max(1,Math.floor(t??r??1));return{perPage:o,page:s}}function rr(e,t){let n=sr(),i=n?cl(n,"cursor"):void 0,r=n?nr(n,"per_page"):void 0,o=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,r??15)),a=ll(t!==void 0?t:i??null);return{perPage:o,cursor:a}}function ll(e){if(e===null||e===void 0)return null;if(Array.isArray(e))return e;if(typeof e==="string"&&e.startsWith("["))try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e}function or(e){let t=sr();if(!t)return e;let n=(()=>{try{return new URL(t.url)}catch{return null}})();if(!n)return e;let i=n.pathname;if(e.path=i,"next_cursor"in e)return e.next_page_url=e.next_cursor!==null?Y(n,{cursor:e.next_cursor}):null,e.prev_page_url=e.prev_cursor!==null?Y(n,{cursor:e.prev_cursor}):null,e;let r=e.current_page;if(e.prev_page_url=r>1?Y(n,{page:r-1}):null,"total"in e){let o=e.last_page;e.next_page_url=r<o?Y(n,{page:r+1}):null,e.first_page_url=Y(n,{page:1}),e.last_page_url=Y(n,{page:o})}else e.next_page_url=e.has_more_pages?Y(n,{page:r+1}):null;return e}function Y(e,t){let n=new URL(e.toString());for(let[i,r]of Object.entries(t))n.searchParams.set(i,String(r));return`${n.pathname}${n.search}`}var ie;function sr(){if(ie===null)return;if(ie===void 0)try{let t=T("@stacksjs/router");if(typeof t.getCurrentRequest==="function")ie=t.getCurrentRequest;else{ie=null;return}}catch{ie=null;return}return ie()}function nr(e,t){let n=cl(e,t);if(n===void 0)return;let i=Number(n);return Number.isFinite(i)?i:void 0}function cl(e,t){let n=e.query?.[t];if(n===void 0)return;return Array.isArray(n)?n[0]:n}import{db as Tu}from"@stacksjs/database";function Rc(e){let t=Tu;return{async createStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.createStripeCustomer(n,i)},async updateStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.updateStripeCustomer(n,i)},async deleteStripeUser(n){let{manageCustomer:i}=await import("@stacksjs/payments");return await i.deleteStripeUser(n)},async createOrGetStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.createOrGetStripeUser(n,i)},async retrieveStripeUser(n){let{manageCustomer:i}=await import("@stacksjs/payments");return await i.retrieveStripeUser(n)},async defaultPaymentMethod(n){let{managePaymentMethod:i}=await import("@stacksjs/payments");return await i.retrieveDefaultPaymentMethod(n)},async setDefaultPaymentMethod(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.setDefaultPaymentMethod(n,i)},async addPaymentMethod(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.addPaymentMethod(n,i)},async paymentMethods(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.listPaymentMethods(n,i)},async newSubscription(n,i,r,o={}){let{manageSubscription:s}=await import("@stacksjs/payments"),a=await s.create(n,i,r,o),l=a.latest_invoice?.payment_intent;return{subscription:a,paymentIntent:l}},async updateSubscription(n,i,r,o={}){let{manageSubscription:s}=await import("@stacksjs/payments"),a=await s.update(n,i,r,o),l=a.latest_invoice?.payment_intent;return{subscription:a,paymentIntent:l}},async cancelSubscription(n,i,r={}){let{manageSubscription:o}=await import("@stacksjs/payments");return{subscription:await o.cancel(i,r)}},async activeSubscription(n){let{manageSubscription:i}=await import("@stacksjs/payments"),r=await t.selectFrom("subscriptions").where("user_id","=",n.id).where("provider_status","=","active").selectAll().executeTakeFirst();if(r){let o=await i.retrieve(n,r.provider_id||"");return{subscription:r,providerSubscription:o}}return},async checkout(n,i,r={}){let{manageCheckout:o,manageCustomer:s}=await import("@stacksjs/payments"),a={};if(r.enableTax)a.automatic_tax={enabled:!0},delete r.enableTax;if(r.allowPromotions)a.allow_promotion_codes=!0,delete r.allowPromotions;let u={...{mode:"payment",customer:(await s.createOrGetStripeUser(n,{})).id,line_items:i.map((m)=>({price:m.priceId,quantity:m.quantity||1}))},...a,...r};return await o.create(n,u)},async createSetupIntent(n,i={}){let{manageSetupIntent:r}=await import("@stacksjs/payments");return await r.create(n,i)},async subscriptionHistory(n){let{manageInvoice:i}=await import("@stacksjs/payments");return await i.list(n)},async transactionHistory(n){let{manageTransaction:i}=await import("@stacksjs/payments");return await i.list(n)},async connectAccount(n,i={}){let r=i.accountColumn||"stripe_account_id",o=(n._attributes??n)[r];if(!o)return null;let s=await ti();try{return await s.accounts.retrieve(o)}catch{return null}},async createConnectAccount(n,i={}){let r=i.accountColumn||"stripe_account_id",o=n._attributes??n,s=o[r],a=await ti();if(!s){let{stacksIdempotencyKey:c}=await import("@stacksjs/payments"),l=i.modelTable||e,u=await a.accounts.create({type:i.type??"express",email:i.email??o.email,country:i.country??"US",capabilities:i.capabilities??{card_payments:{requested:!0},transfers:{requested:!0}}},{idempotencyKey:c("connect.account.create",l,o.id)});return s=u.id,await t.updateTable(l).set({[r]:s}).where("id","=",Number(o.id)).execute(),u}return await a.accounts.retrieve(s)},async connectOnboardLink(n,i){let r=i.accountColumn||"stripe_account_id",s=(n._attributes??n)[r];if(!s)throw Error("connectOnboardLink: model has no Stripe Connect account; call createConnectAccount first");return{url:(await(await ti()).accountLinks.create({account:s,refresh_url:i.refreshUrl,return_url:i.returnUrl,type:i.type??"account_onboarding"})).url,accountId:s}},async syncConnectStatus(n,i={}){let r=i.accountColumn||"stripe_account_id",o=i.chargesColumn||"charges_enabled",s=i.payoutsColumn||"payouts_enabled",a=n._attributes??n,c=a[r];if(!c)return{chargesEnabled:!1,payoutsEnabled:!1};let u=await(await ti()).accounts.retrieve(c),m=!!u.charges_enabled,p=!!u.payouts_enabled,k=i.modelTable||e;return await t.updateTable(k).set({[o]:m,[s]:p}).where("id","=",Number(a.id)).execute(),{chargesEnabled:m,payoutsEnabled:p}},async chargeWithSplit(n,i){let r=await ti(),o=i.accountColumn||"stripe_account_id",s=n._attributes??n,a=i.connectAccountId||s[o],c={amount:i.amountCents,currency:i.currency||"usd",automatic_payment_methods:{enabled:!0},metadata:i.metadata};if(a){if(c.transfer_data={destination:a},i.platformFeeCents)c.application_fee_amount=i.platformFeeCents}let{freshIdempotencyKey:l}=await import("@stacksjs/payments");return await r.paymentIntents.create(c,{idempotencyKey:l("payment_intent.create",s.id,i.amountCents)})}}}async function ti(){let e=globalThis.process?.env?.STRIPE_SECRET_KEY;if(!e)throw Error("Stripe Connect: STRIPE_SECRET_KEY not configured");return new(await Promise.resolve().then(() => (yc(),hc))).default(e,{apiVersion:"2026-06-24.dahlia"})}function wc(){return{async generateTwoFactorForModel(e){let{generateTwoFactorSecret:t}=await import("@stacksjs/auth"),n=t();await e.update({two_factor_secret:n})},async verifyTwoFactorCode(e,t){let n=e.get("two_factor_secret");if(typeof n!=="string")return!1;let{verifyTwoFactorCode:i,RateLimiter:r}=await import("@stacksjs/auth"),o=String(e.id??e.get?.("id")??e.get?.("email")??n),s=`2fa:${o}`;if(await r.isRateLimited(s)){let{HttpError:c}=await import("@stacksjs/error-handling");throw new c(429,"Too many verification attempts. Please try again later.")}if(!await i(t,n))return await r.recordFailedAttempt(s),!1;try{let{cache:c}=await import("@stacksjs/cache"),l=`2fa:used:${o}:${t}`;if(await c.has(l))return await r.recordFailedAttempt(s),!1;await c.set(l,"1",90)}catch{}return await r.resetAttempts(s),!0}}}import{sqlDateTime as vu}from"@stacksjs/database";import{log as le}from"@stacksjs/logging";var Pi="deleted_at";function Tc(e,t="id"){return{async softDelete(n){let i=vu(),r=e.where(t,n);if(typeof r?.update==="function")return await r.update({[Pi]:i}),!0;return!1},async restore(n){let i=e.where(t,n);if(typeof i?.update==="function")return await i.update({[Pi]:null}),!0;return!1},async forceDelete(n){let i=e.where(t,n);if(typeof i?.delete==="function")return await i.delete(),!0;return!1},withTrashed(){return typeof e.query==="function"?e.query():e},onlyTrashed(){let n=typeof e.query==="function"?e.query():e;if(typeof n?.whereNotNull==="function")return n.whereNotNull(Pi);return n?.where?.(Pi,"!=",null)??n}}}function vc(e){if(e===!0||e==null)return{};if(typeof e==="object"&&!Array.isArray(e)){let t=e;if(Array.isArray(t.cascade)){let n=t.cascade.filter((i)=>typeof i==="string");return n.length?{cascade:n}:{}}return{}}return{}}function Su(e,t){let n=e.hasMany??[],i=e.hasOne??[],r=n.some((u)=>$a(u,t,!0)),o=i.some((u)=>$a(u,t,!1));if(!r&&!o)return le.warn(`[orm] soft-delete cascade: '${t}' is not a declared hasMany/hasOne relation - skipping`),null;let a=(r?n:i).find((u)=>$a(u,t,r))??null;if(!a)return null;let l=globalThis[a];if(!l)return le.warn(`[orm] soft-delete cascade: model '${a}' is not yet on globalThis - skipping cascade for '${t}'`),null;return{className:a,model:l}}function $a(e,t,n){let i=e.toLowerCase();if(t===i)return!0;if(n&&t===`${i}s`)return!0;if(n&&i.endsWith("y")&&t===`${i.slice(0,-1)}ies`)return!0;return!1}async function xu(e,t,n,i,r){try{let o=n.where;if(typeof o!=="function"){le.warn(`[orm] cascade ${r}: child model has no .where()`);return}if(r==="softDelete"){let s=n.softDelete;if(typeof s==="function"){let c=o.call(n,i,t),l=typeof c?.get==="function"?await c.get():Array.isArray(c)?c:[],u=n.primaryKey||"id";for(let m of l){let p=m?.[u];if(p!=null)await s.call(n,p)}return}let a=o.call(n,i,t);if(typeof a?.delete==="function"){le.debug(`[orm] cascade soft-delete: child has no softDeletes trait, hard-deleting from ${String(n.table??"?")}`),await a.delete();return}}else{let s=n.restore;if(typeof s!=="function"){le.debug("[orm] cascade restore: child has no restore() - nothing to do");return}let a=n.withTrashed,l=(typeof a==="function"?a.call(n):n).where?.(i,t),u=typeof l?.get==="function"?await l.get():[],m=n.primaryKey||"id";for(let p of u){let k=p?.[m];if(k!=null)await s.call(n,k)}}}catch(o){if(le.warn(`[orm] soft-delete cascade ${r} on ${e}#${String(t)} failed`,{error:o}),process.env.STACKS_ORM_CASCADE_SWALLOW!=="true")throw o}}async function ni(e,t,n,i){let r=t.cascade;if(!r||r.length===0)return;let o=`${e.name.toLowerCase()}_id`;for(let s of r){let a=Su(e,s);if(!a)continue;await xu(a.className,n,a.model,o,i)}}var Ic=new Oc;function te(){return Ic.getStore()?.suppressed===!0}function ee(e){return Promise.resolve(Ic.run({suppressed:!0},e))}var Ac=new Oc;function Pu(){return Ac.getStore()?.suppressed===!0}function Eu(e){return Promise.resolve(Ac.run({suppressed:!0},e))}var Na=Symbol.for("stacks.orm.modelDefinition");class $c extends Error{status=422;errors;constructor(e,t){let n=Object.keys(t).join(", ");super(`${e} validation failed: ${n}`);this.name="ModelValidationError",this.errors=t}}var Sc=new Set;function qu(e,t){let n=typeof e==="string"?e.slice(0,80):String(e),i=`${typeof e}:${n}`;if(Sc.has(i))return;Sc.add(i);let r=t instanceof Error?t.message:String(t);console.error(`[orm] JSON cast failed to parse value (returning null): ${r} - value preview: ${JSON.stringify(n)}`)}var Ou={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>{if(e==null)return null;if(typeof e==="string")try{return JSON.parse(e)}catch(t){return qu(e,t),null}return e},set:(e)=>{if(e==null)return null;return typeof e==="string"?e:JSON.stringify(e)}},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>{if(e==null)return[];if(Array.isArray(e))return e;if(typeof e==="string")try{return JSON.parse(e)}catch{return[]}return[]},set:(e)=>{if(e==null)return null;return Array.isArray(e)?JSON.stringify(e):e}}};function Uc(e){return typeof e==="string"?Ou[e]:e}function xc(e,t,n){if(!e||typeof e!=="object")return e;let i={...e};for(let[r,o]of Object.entries(t))if(r in i){let s=Uc(o);i[r]=s[n](i[r])}return i}var Ei=new Set(["_attributes","_original","_definition","_hasSaved","_relations"]),Cc=Symbol.for("stacks.modelInstanceProxy"),Iu={tags:{bag:"_taggable",mode:"id"},tagCount:{bag:"_taggable",mode:"id"},addTag:{bag:"_taggable",mode:"id"},activeTags:{bag:"_taggable",mode:"id"},inactiveTags:{bag:"_taggable",mode:"id"},removeTag:{bag:"_taggable",mode:"id"},categories:{bag:"_categorizable",mode:"id"},categoryCount:{bag:"_categorizable",mode:"id"},addCategory:{bag:"_categorizable",mode:"id"},activeCategories:{bag:"_categorizable",mode:"id"},inactiveCategories:{bag:"_categorizable",mode:"id"},removeCategory:{bag:"_categorizable",mode:"id"},comments:{bag:"_commentable",mode:"id"},commentCount:{bag:"_commentable",mode:"id"},addComment:{bag:"_commentable",mode:"id"},approvedComments:{bag:"_commentable",mode:"id"},pendingComments:{bag:"_commentable",mode:"id"},rejectedComments:{bag:"_commentable",mode:"id"},likes:{bag:"_likeable",mode:"id"},likeCount:{bag:"_likeable",mode:"id"},like:{bag:"_likeable",mode:"id"},unlike:{bag:"_likeable",mode:"id"},isLiked:{bag:"_likeable",mode:"id"},createStripeUser:{bag:"_billable",mode:"model"},updateStripeUser:{bag:"_billable",mode:"model"},deleteStripeUser:{bag:"_billable",mode:"model"},createOrGetStripeUser:{bag:"_billable",mode:"model"},retrieveStripeUser:{bag:"_billable",mode:"model"},defaultPaymentMethod:{bag:"_billable",mode:"model"},setDefaultPaymentMethod:{bag:"_billable",mode:"model"},addPaymentMethod:{bag:"_billable",mode:"model"},paymentMethods:{bag:"_billable",mode:"model"},newSubscription:{bag:"_billable",mode:"model"},updateSubscription:{bag:"_billable",mode:"model"},cancelSubscription:{bag:"_billable",mode:"model"},activeSubscription:{bag:"_billable",mode:"model"},checkout:{bag:"_billable",mode:"model"},createSetupIntent:{bag:"_billable",mode:"model"},subscriptionHistory:{bag:"_billable",mode:"model"},transactionHistory:{bag:"_billable",mode:"model"},connectAccount:{bag:"_billable",mode:"model"},createConnectAccount:{bag:"_billable",mode:"model"},connectOnboardLink:{bag:"_billable",mode:"model"},syncConnectStatus:{bag:"_billable",mode:"model"},chargeWithSplit:{bag:"_billable",mode:"model"},generateTwoFactorForModel:{bag:"_twoFactor",mode:"model"},verifyTwoFactorCode:{bag:"_twoFactor",mode:"model"}};function Au(e,t){if(!e||!t)return null;let n=t.split("."),i=e;for(let r of n){if(i==null||typeof i!=="object")return null;let o=i;if("_attributes"in o&&o._attributes&&typeof o._attributes==="object"){let s=o._attributes;if(r in s){i=s[r];continue}}if(r in o){i=o[r];continue}return null}return i??null}function D(e,t){if(!e||typeof e!=="object")return e;let n=e;if(n[Cc])return e;let i=n._attributes;if(!i||typeof i!=="object")return e;if(t&&Object.keys(t).length>0){for(let[r,o]of Object.entries(t))if(Object.prototype.hasOwnProperty.call(i,r))i[r]=Uc(o).get(i[r])}return new Proxy(e,{get(r,o,s){let a=r;if(o===Cc)return!0;if(o==="saveAsync")return async function(){let l=a._definition,u=l?.set;if(u&&typeof a.isDirty==="function"){for(let[p,k]of Object.entries(u)){if(typeof k!=="function")continue;if(!a.isDirty(p))continue;let _=k(a._attributes),g=_&&typeof _.then==="function"?await _:_;a._attributes[p]=g}let m=l.set;l.set={};try{return a.save()}finally{l.set=m}}return a.save()};if(o==="save")return function(){let l=a._definition,u=l?.set;if(u&&Object.keys(u).length>0&&typeof a.isDirty==="function"){for(let[p,k]of Object.entries(u)){if(typeof k!=="function")continue;if(!a.isDirty(p))continue;let _=k(a._attributes);if(_&&typeof _.then==="function")throw Error(`Setter for "${p}" returned a Promise - use \`saveAsync()\` instead of \`save()\` when a model has async setters.`);a._attributes[p]=_}let m=l.set;l.set={};try{return a.save()}finally{l.set=m}}return a.save()};if(o==="updateAsync")return async function(l){if(l&&typeof l==="object"&&!Array.isArray(l))for(let[u,m]of Object.entries(l))s[u]=m;return s.saveAsync()};if(o==="saveQuietly")return function(){return ee(()=>a.save())};if(o==="saveAsyncQuietly")return function(){return ee(()=>s.saveAsync())};if(o==="updateQuietly")return function(l){return ee(()=>a.update(l))};if(o==="updateAsyncQuietly")return function(l){return ee(()=>s.updateAsync(l))};if(o==="deleteQuietly")return function(){return ee(()=>a.delete())};if(o==="toSearchableObject")return function(){let m=a._definition?.traits?.useSearch;if(!m)return null;let p=a._attributes;if(!p)return null;if(m===!0){let R={...p};if(p.id!=null)R.id=String(p.id);return R}let k={},_=m.displayable?.length?m.displayable:[...m.searchable??[],...m.filterable??[],...m.sortable??[],"id"],g=m.denormalize??{},y=a._relations;for(let R of _){let w=H(R),S=p[w]??p[R];if(S!==void 0){k[w]=S;continue}let C=g[R]??g[w];if(C){k[w]=Au(y,C);continue}k[w]=void 0}if(p.id!=null)k.id=String(p.id);return k};if(typeof o==="string"&&!Ei.has(o)){let l=a._attributes;if(l&&Object.prototype.hasOwnProperty.call(l,o))return l[o];let u=a._relations;if(u&&Object.prototype.hasOwnProperty.call(u,o)){let p=u[o];if(Array.isArray(p))return p.map((k)=>D(k,t));return p&&typeof p==="object"?D(p,t):p}let m=Iu[o];if(m){let _=a._definition?.__traitMethods?.[m.bag]?.[o];if(typeof _==="function")return m.mode==="model"?(...g)=>_(s,...g):(...g)=>_(a.id,...g)}if(l){let p=H(o);if(p!==o&&Object.prototype.hasOwnProperty.call(l,p))return l[p]}}let c=Reflect.get(a,o,a);return typeof c==="function"?c.bind(a):c},set(r,o,s,a){let c=r;if(typeof o==="string"&&!Ei.has(o)){let{_attributes:l,set:u}=c;if(l&&Object.prototype.hasOwnProperty.call(l,o)){if(typeof u==="function")u.call(c,o,s);else l[o]=s;return!0}if(l){let m=H(o);if(m!==o&&Object.prototype.hasOwnProperty.call(l,m)){if(typeof u==="function")u.call(c,m,s);else l[m]=s;return!0}}if(l&&!(o in c)){if(typeof u==="function")u.call(c,o,s);else l[o]=s;return!0}}return Reflect.set(c,o,s,a)},has(r,o){let s=r;if(typeof o==="string"&&!Ei.has(o)){let a=s._attributes;if(a&&Object.prototype.hasOwnProperty.call(a,o))return!0;let c=s._relations;if(c&&Object.prototype.hasOwnProperty.call(c,o))return!0;if(a){let l=H(o);if(l!==o&&Object.prototype.hasOwnProperty.call(a,l))return!0}}return Reflect.has(s,o)},deleteProperty(r,o){let s=r;if(typeof o==="string"&&!Ei.has(o)){let a=s._attributes;if(a&&Object.prototype.hasOwnProperty.call(a,o))return delete a[o],!0}return Reflect.deleteProperty(s,o)},ownKeys(r){let s=r._attributes;return s?Object.keys(s):[]},getOwnPropertyDescriptor(r,o){let s=r;if(typeof o==="string"){let a=s._attributes;if(a&&Object.prototype.hasOwnProperty.call(a,o))return{configurable:!0,enumerable:!0,value:a[o],writable:!0}}return Object.getOwnPropertyDescriptor(s,o)}})}var $u=new Set(["get","first","last","firstOrFail","find","findOrFail","all","paginate","simplePaginate","cursorPaginate"]),Uu={paginate:Zi,simplePaginate:er,cursorPaginate:tr},jc=Symbol.for("stacks.queryBuilderProxy");function Mc(e,t){if(!e||typeof e!=="object")return e;if(e[jc])return e;return new Proxy(e,{get(n,i,r){if(i===jc)return!0;let o=Reflect.get(n,i,r);if(typeof o!=="function")return o;return function(...s){let a=s,c=String(i);if(c==="paginate"||c==="simplePaginate"){let{perPage:m,page:p}=ir(s[0],s[1]);a=[m,p]}else if(c==="cursorPaginate"){let{perPage:m,cursor:p}=rr(s[0],s[1]);a=[m,p,s[2],s[3]]}let l=o.apply(n,a),u=(m)=>{if($u.has(c)){if(Array.isArray(m))return m.map((k)=>D(k,t));let p=Uu[c];if(p&&m&&Array.isArray(m.data)){let k=m.data.map((g)=>D(g,t)),_=p({...m,data:k});return or(_)}if(m&&Array.isArray(m.data))return{...m,data:m.data.map((k)=>D(k,t))};return D(m,t)}if(m&&typeof m==="object"&&typeof m.get==="function")return Mc(m,t);return m};if(l&&typeof l.then==="function")return l.then(u);return u(l)}}})}function Mu(e,t){let n=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let o of n){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a),l=(u)=>Array.isArray(u)?u.map((m)=>D(m,t)):D(u,t);if(c&&typeof c.then==="function")return c.then(l);return l(c)}}let i=["create","firstOrCreate","updateOrCreate","make"];for(let o of i){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a),l=(u)=>Array.isArray(u)?u.map((m)=>D(m,t)):D(u,t);if(c&&typeof c.then==="function")return c.then(l);return l(c)}}let r=["query","where","orWhere","whereIn","whereNotIn","whereNull","whereNotNull","whereLike","whereBetween","whereNotBetween","orderBy","orderByDesc","select","with","limit","take","skip","latest","oldest"];for(let o of r){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a);return Mc(c,t)}}}class Dc extends Error{model;id;constructor(e,t){super(t!=null?`[ORM] ${e} not found for id=${String(t)}`:`[ORM] No matching ${e} row`);this.name="ModelNotFoundError",this.model=e,this.id=t}}class Ma extends Error{model;attribute;reason;constructor(e,t,n){let i=n==="guarded"?`'${t}' is marked guarded`:`'${t}' is not in the fillable allowlist`;super(`[ORM] Mass assignment to ${e} forbidden: ${i}. Use ${e}.forceCreate(...) / .forceUpdate(...) to bypass.`);this.name="MassAssignmentException",this.model=e,this.attribute=t,this.reason=n}}var Du=new Set(["id","created_at","updated_at","deleted_at","uuid"]);function ii(e,t,n={}){if(n.force)return t;if(!t||typeof t!=="object"||Array.isArray(t))return t;let i=e.attributes;if(!i)return t;let r=new Set,o=new Set,s=new Set;for(let[c,l]of Object.entries(i)){let u=H(c);if(r.add(u),l?.fillable===!0)o.add(u);if(l?.guarded===!0)s.add(u)}let a=o.size>0?o:r;for(let c of Object.keys(t)){let l=H(c);if(Du.has(l))continue;if(s.has(l))throw new Ma(e.name,c,"guarded");if(l.endsWith("_id"))continue;if(!a.has(l))throw new Ma(e.name,c,"not-fillable")}return t}async function Da(e,t){let n=e.set;if(!n||typeof n!=="object")return t;let i={...t};for(let[r,o]of Object.entries(n)){if(typeof o!=="function"||!(r in i))continue;try{i[r]=await o(i)}catch(s){I.error(`[orm] ${e.name}.set.${r} threw - skipping setter`,s)}}return i}function Fu(e,t){let n=t.primaryKey||"id",i=e.create;function r(l){let u=e.where;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} needs a working where(): the underlying query builder did not expose one`);return u}function o(l){let u=e.find;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} needs a working find(): the underlying query builder did not expose one`);return u}function s(l){let u=e.create;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} cannot create: the underlying query builder did not expose create()`);return u}if(typeof e.update!=="function")e.update=async function(l,u){if(l==null)throw Error(`[ORM] ${t.name}.update requires an id as the first argument`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.update requires a data object as the second argument`);if(Object.keys(u).length===0){I.debug(`[orm] ${t.name}.update called with empty data - short-circuiting and returning current row`);let k=e.find;return typeof k==="function"?await k.call(e,l):null}ii(t,u);let m=await Da(t,u);await r("update").call(e,n,l).update(m);let p=e.find;return typeof p==="function"?await p.call(e,l):null};if(typeof e.forceUpdate!=="function")e.forceUpdate=async function(l,u){if(l==null)throw Error(`[ORM] ${t.name}.forceUpdate requires an id as the first argument`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.forceUpdate requires a data object as the second argument`);let m=await Da(t,u);await r("forceUpdate").call(e,n,l).update(m);let p=e.find;return typeof p==="function"?await p.call(e,l):null};if(typeof e.forceCreate!=="function")e.forceCreate=async function(l){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.forceCreate requires a data object`);let u=e.make;if(typeof u==="function"){let m=await u.call(e);if(m&&typeof m.forceFill==="function"&&typeof m.save==="function")return m.forceFill(l),await m.save()??m}if(typeof i!=="function")throw Error(`[ORM] ${t.name}.forceCreate cannot create: the underlying query builder did not expose create()`);return await i.call(e,l)};if(typeof e.delete!=="function")e.delete=async function(l){if(l==null)throw Error(`[ORM] ${t.name}.delete requires an id as the first argument`);if(!await o("delete").call(e,l))return!1;return await r("delete").call(e,n,l).delete(),!0};if(typeof e.findOrFail!=="function")e.findOrFail=async function(l){let u=await o("findOrFail").call(e,l);if(u==null)throw new Dc(t.name,l);return u};if(typeof e.exists!=="function")e.exists=async function(l){if(l==null)return!1;let u=r("exists").call(e,n,l);if(typeof u.count==="function"){let p=await u.count();return Number(p)>0}let m=e.find;return typeof m==="function"?await m.call(e,l)!=null:!1};if(typeof e.firstOrCreate!=="function")e.firstOrCreate=async function(l,u={}){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.firstOrCreate requires a where-attrs object`);let m=r("firstOrCreate").call(e,l),p=typeof m.first==="function"?await m.first():await m;if(p)return p;let k={...l,...u};return ii(t,k),await s("firstOrCreate").call(e,k)};if(typeof e.updateOrCreate!=="function")e.updateOrCreate=async function(l,u){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.updateOrCreate requires a where-attrs object`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.updateOrCreate requires a values object`);let m=r("updateOrCreate").call(e,l),p=typeof m.first==="function"?await m.first():await m;if(p){ii(t,u);let _=p[n];await r("updateOrCreate").call(e,n,_).update(u);let g=e.find;return typeof g==="function"?await g.call(e,_):{...p,...u}}let k={...l,...u};return ii(t,k),await s("updateOrCreate").call(e,k)};if(typeof e.count!=="function")e.count=async function(){let l=e;if(typeof l.query==="function"){let p=l.query();if(typeof p?.count==="function"){let k=await p.count();return Number(k)||0}}let{all:u,get:m}=e;if(typeof u==="function")return(await u.call(e)||[]).length;if(typeof m==="function")return(await m.call(e)||[]).length;return 0};if(typeof e.pluck!=="function")e.pluck=async function(l){if(!l||typeof l!=="string")throw Error(`[ORM] ${t.name}.pluck requires a column name`);let u=e.all;return((typeof u==="function"?await u.call(e):[])||[]).map((p)=>p?.[l])};if(typeof e.whereIn!=="function")e.whereIn=async function(l,u){if(!l||typeof l!=="string")throw Error(`[ORM] ${t.name}.whereIn requires a column name`);if(!Array.isArray(u))throw Error(`[ORM] ${t.name}.whereIn requires an array of values`);if(u.length===0)return[];let m=e.where;if(typeof m!=="function")return[];let p=m.call(e,l,"in",u);if(p&&typeof p.get==="function")return await p.get();return await p};let a=[["latest","desc"],["oldest","asc"]];for(let[l,u]of a)if(typeof e[l]!=="function")e[l]=async function(m="created_at"){let p=e,k=typeof p.query==="function"?p.query():p;if(typeof k?.orderBy==="function"){let R=k.orderBy(m,u);if(typeof R.first==="function")return await R.first();if(typeof R.get==="function")return(await R.get())?.[0]??null}let _=e.all;if(typeof _!=="function")return null;return[...await _.call(e)||[]].sort((R,w)=>{let S=R?.[m],C=w?.[m];if(S===C)return 0;return(S>C?1:-1)*(u==="desc"?-1:1)})[0]??null};let c=Gc(t.traits?.useSearch,t);if(c){let l=c.index??t.table??H(`${t.name}s`);if(typeof e.search!=="function")e.search=function(u,m){return Lu(e,l,u,m,c.searchable)};if(typeof e.makeAllSearchable!=="function")e.makeAllSearchable=async function(u=500){let m=e.all;if(typeof m!=="function")throw Error(`[ORM] ${t.name}.makeAllSearchable cannot run: the underlying query builder did not expose all()`);let{useSearchEngine:p}=await import("@stacksjs/search-engine"),k=p(),_=0,g=e.query;if(typeof g==="function")try{let w=g.call(e);if(w&&typeof w.chunk==="function")return await w.chunk(u,async(S)=>{let C=await Fa(S,c);if(C.length>0)await k.addDocuments(l,C);_+=C.length}),_}catch{}let y=await m.call(e)||[],R=await Fa(y,c);if(R.length>0)await k.addDocuments(l,R);return R.length};if(typeof e.removeAllFromSearch!=="function")e.removeAllFromSearch=async function(){let{useSearchEngine:u}=await import("@stacksjs/search-engine"),m=u();if(typeof m.deleteAllDocuments==="function"){await m.deleteAllDocuments(l);return}let p=e.all,k=typeof p==="function"?await p.call(e)||[]:[],_=u();for(let g of k){let y=g?.id??g?._attributes?.id;if(y!=null)await _.deleteDocument(l,Number(y))}}}}async function Fa(e,t){if(e.length===0)return[];if(typeof t.shapeMany==="function"){let i=await t.shapeMany(e);if(!Array.isArray(i)||i.length!==e.length)throw TypeError(`[orm/search] shapeMany returned ${Array.isArray(i)?i.length:typeof i} documents for ${e.length} rows. It must return one document per row, in order, or documents are indexed under the wrong ids.`);return i.filter(Boolean)}return(await Promise.all(e.map((i)=>Bu(i,t)))).filter(Boolean)}function Nu(e){let t=new Set,n=e.attributes??{};for(let[i,r]of Object.entries(n))if(r?.hidden)t.add(i);return t}function Gu(e,t){if(!e||t.size===0)return e;let n={};for(let[i,r]of Object.entries(e))if(!t.has(i))n[i]=r;return n}async function Bu(e,t){if(typeof t.shape==="function")try{return await t.shape(e)}catch{return}let n=e?.toSearchableObject?.();if(n!==void 0)return n;return Gu(e?._attributes??(typeof e?.toJSON==="function"?e.toJSON():null),t.hidden??new Set)}function Lu(e,t,n,i,r){let o=r&&r.length>0?{query_by:[...r].join(",")}:{},s={q:n,...o,...i??{}},a={with(c){return s={...s,...c},a},where(c){return s={...s,filter:c},a},async get(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return(await c().search(t,s))?.hits??[]},async paginate(c,l=1){let{useSearchEngine:u}=await import("@stacksjs/search-engine"),p=await u().search(t,{...s,limit:c,offset:(l-1)*c});return{hits:p.hits??[],total:Number(p.estimatedTotalHits??p.nbHits??p.total??0),page:l,perPage:c}},async raw(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return await c().search(t,s)}};return a}function Fc(e){let t=H(e);return t===e?[e]:[e,t]}async function Ua(e,t){if(!e||typeof e!=="object")return;let n=e._attributes??e;for(let i of t)for(let r of Fc(i)){if(!(r in n))continue;let o=n[r];if(!ue(o))continue;n[r]=await Ui(o)}}function Ku(e,t){if(t.length===0)return;let n=async(a)=>{if(Array.isArray(a)){for(let c of a)await Ua(c,t);return a}if(a&&typeof a==="object"&&Array.isArray(a.data)){for(let c of a.data)await Ua(c,t);return a}if(a)await Ua(a,t);return a},i=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let a of i){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(...l){let u=await c.apply(this,l);return await n(u)}}let r=["create","firstOrCreate","updateOrCreate","make"];for(let a of r){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(...l){let u=await c.apply(this,l);return await n(u)}}for(let a of["update","forceUpdate"]){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(l,u){let m=await c.call(this,l,u);return await n(m)}}let o=["first","firstOrFail","get","all","find","findOrFail","last","paginate","simplePaginate"],s=(a)=>{if(!a||typeof a!=="object")return a;let c=a;if(c.__stacksEncryptedReads)return a;for(let l of o){let u=c[l];if(typeof u!=="function")continue;c[l]=async function(...m){return await n(await u.apply(this,m))}}for(let l of["where","whereIn","whereNull","whereNotNull","orWhere","orderBy","orderByDesc","limit","offset","with"]){let u=c[l];if(typeof u!=="function")continue;c[l]=function(...m){return s(u.apply(this,m))}}return Object.defineProperty(c,"__stacksEncryptedReads",{value:!0,enumerable:!1}),a};for(let a of["where","whereIn","whereNull","whereNotNull","orderBy","orderByDesc","limit","query"]){let c=e[a];if(typeof c!=="function")continue;e[a]=function(...l){return s(c.apply(this,l))}}}function Hu(e,t){if(t.length===0)return;let n=async(r)=>{if(!r||typeof r!=="object"||Array.isArray(r))return r;let o={...r};for(let s of t)for(let a of Fc(s))if(a in o)o[a]=await $i(o[a]);return o},i=["create","firstOrCreate","updateOrCreate","forceCreate"];for(let r of i){let o=e[r];if(typeof o!=="function")continue;e[r]=async function(...s){if(s[0]=await n(s[0]),s[1])s[1]=await n(s[1]);return await o.apply(this,s)}}for(let r of["update","forceUpdate"]){let o=e[r];if(typeof o!=="function")continue;e[r]=async function(s,a){let c=await n(a);return await o.call(this,s,c)}}}function Vu(e,t){let n=e.create;if(typeof n==="function")e.create=async function(i,...r){ii(t,i);let o=await Da(t,i);return await n.call(this,o,...r)};for(let i of["firstOrCreate","updateOrCreate"]){let r=e[i];if(typeof r!=="function")continue}}function zu(e,t){let n=String(t?.name??e.name??"Model"),i=(s,a)=>{if(Pu())return;if(!s||typeof s!=="object"||Array.isArray(s))return;let c=el(s,t,a);if(!c.valid)throw new $c(n,c.errors)},r=e.create;if(typeof r==="function")e.create=async function(s,...a){return i(s,"creating"),await r.call(this,s,...a)};let o=e.update;if(typeof o==="function")e.update=async function(s,a,...c){return i(a,"updating"),await o.call(this,s,a,...c)}}function Wu(e,t){let n=["create","firstOrCreate","updateOrCreate"];for(let r of n){let o=e[r];if(typeof o==="function")e[r]=async function(...s){if(I.debug(`[orm] ${r.charAt(0).toUpperCase()+r.slice(1)} ${String(e.name||"unknown")}`,s[0]),s[0]&&typeof s[0]==="object"&&!Array.isArray(s[0]))s[0]=xc(s[0],t,"set");return await o.apply(this,s)}}let i=e.update;if(typeof i==="function")e.update=async function(r,o){let s=o&&typeof o==="object"&&!Array.isArray(o)?xc(o,t,"set"):o;return await i.call(this,r,s)}}function Nc(e){I.debug(`[orm] Defining model: ${e.name} (table: ${e.table})`);let t=Qu(e),n=Xu(e),i=Ju(t,n),r=Yu(e);e.__traitMethods=r;let o=i?{...e,hooks:{...e.hooks,...i}}:e,a=Cu(o);if(Mu(a,e.casts),Fu(a,o),Vu(a,o),e.casts&&Object.keys(e.casts).length>0)Wu(a,e.casts);let c=Mi(e);if(c.length>0)Hu(a,c),Ku(a,c);let l=e.traits?.useSoftDeletes;if(l)Zu(a,o,l);let u=e.traits?.useAudit;if(u){let k=Wa(u);Qa(a,e.name,e.primaryKey||"id",k)}zu(a,o);let m=a;m.withoutValidation=function(k){return Eu(k)},m.withoutEvents=function(k){return ee(k)};for(let k of["create","update","firstOrCreate","updateOrCreate","forceCreate","forceUpdate","delete","forceDelete","softDelete","restore"]){let _=a[k];if(typeof _!=="function")continue;let g=`${k}Quietly`;if(typeof a[g]==="function")continue;a[g]=function(...y){return ee(()=>_.apply(a,y))}}let p=Object.assign(a,r,{...e,getDefinition:()=>e,_isStacksModel:!0});return ju(e.name,p),Object.defineProperty(p,Na,{value:e,enumerable:!1,configurable:!0}),p}function Qu(e){let t=e.traits?.observe;if(!t)return;let n=e.name.toLowerCase(),i=(p)=>{let k=p?.attributes;if(!k||typeof k!=="object")return p;let _=e.primaryKey||"id",g={...k};if(g[_]===void 0&&p[_]!==void 0)g[_]=p[_];return g},r=async(p,k)=>{if(te())return;try{let{dispatch:_}=await import("@stacksjs/events");await _(p,k)}catch(_){if(_&&typeof _==="object"&&"code"in _&&_.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Event '${p}' handler error:`,_),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw _}},o=e.traits?.broadcastOn,s=e.traits?.broadcastWith,a=typeof o==="function"&&typeof s==="function",c=async(p,k)=>{if(!a)return;if(te())return;try{let _=o(k),g=Array.isArray(_)?_:[_],y=s(k),w=(await import("@stacksjs/realtime").catch(()=>null))?.broadcast;if(typeof w!=="function")return;for(let S of g){if(typeof S!=="string"||S.length===0)continue;await w(S,p,y)}}catch(_){if(_&&typeof _==="object"&&"code"in _&&_.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Broadcast '${p}' handler error:`,_),process.env.STACKS_ORM_BROADCAST_ERRORS==="throw")throw _}},l=async(p,k)=>{if(te())return!0;try{let{dispatchAsync:_}=await import("@stacksjs/events"),g=await _(p,k);if(Array.isArray(g)&&g.some((y)=>y===!1))return!1}catch(_){if(_&&typeof _==="object"&&"code"in _&&_.code==="MODULE_NOT_FOUND")return!0;if(console.error(`[ORM] Before-event '${p}' handler error:`,_),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw _}return!0},u=t===!0?["create","update","delete"]:Array.isArray(t)?t:[],m={};if(u.includes("create"))m.beforeCreate=async(p)=>{if(I.debug(`[orm] Create ${n}`,p),!await l(`${n}:saving`,p))throw Error(`[ORM] ${n}:saving event cancelled the operation`);if(!await l(`${n}:creating`,p))throw Error(`[ORM] ${n}:creating event cancelled the operation`)},m.afterCreate=async(p)=>{let k=i(p);await r(`${n}:created`,k),await r(`${n}:saved`,k),await c(`${n}:created`,p)};if(u.includes("update"))m.beforeUpdate=async(p)=>{if(I.debug(`[orm] Update ${n}#${p?.id??"unknown"}`,p),!await l(`${n}:saving`,p))throw Error(`[ORM] ${n}:saving event cancelled the operation`);if(!await l(`${n}:updating`,p))throw Error(`[ORM] ${n}:updating event cancelled the operation`)},m.afterUpdate=async(p)=>{let k=i(p);await r(`${n}:updated`,k),await r(`${n}:saved`,k),await c(`${n}:updated`,p)};if(u.includes("delete"))m.beforeDelete=async(p)=>{if(I.debug(`[orm] Delete ${n}#${p?.id??"unknown"}`),!await l(`${n}:deleting`,p))throw Error(`[ORM] ${n}:deleting event cancelled the operation`)},m.afterDelete=async(p)=>{await r(`${n}:deleted`,i(p)),await c(`${n}:deleted`,p)};return m}function Ju(...e){let t={},n=new Set;for(let i of e){if(!i)continue;for(let r of Object.keys(i))n.add(r)}for(let i of n){let r=e.map((o)=>o?.[i]).filter((o)=>typeof o==="function");if(!r.length)continue;t[i]=async(...o)=>{for(let s of r)await s(...o)}}return Object.keys(t).length?t:void 0}function Gc(e,t){if(!e)return null;let n=e===!0?{}:typeof e==="object"?{...e}:null;if(!n)return null;if(t)n.hidden=Nu(t);return n}function Xu(e){let t=Gc(e.traits?.useSearch,e);if(!t)return;let n=t,i=n.index??e.table??H(`${e.name}s`);async function r(a){if(typeof n.shapeMany==="function")try{let[u]=await Fa([a],n);return u}catch(u){I.warn(`[orm/search] shapeMany() threw for ${e.name}: ${u.message}`);return}if(typeof n.shape==="function")try{return await n.shape(a)}catch(u){I.warn(`[orm/search] shape() threw for ${e.name}: ${u.message}`);return}let l=D(a).toSearchableObject?.();if(l!==void 0)return l;return a?._attributes??(typeof a?.toJSON==="function"?a.toJSON():null)}let o=async(a)=>{if(te())return;let c=await r(a);if(!c)return;if(t.queueable){try{let{Jobs:l}=await import("@stacksjs/queue");await l.dispatch("SyncSearchIndexJob",{index:i,op:"upsert",doc:c})}catch(l){I.warn(`[orm/search] queue dispatch failed for ${e.name}; falling back to inline: ${l.message}`),await Ec(i,c,e.name)}return}await Ec(i,c,e.name)};return{afterCreate:o,afterUpdate:o,afterDelete:async(a)=>{if(te())return;let c=a?.id??a?._attributes?.id;if(c==null)return;if(t.queueable){try{let{Jobs:l}=await import("@stacksjs/queue");await l.dispatch("SyncSearchIndexJob",{index:i,op:"delete",id:Number(c)})}catch(l){I.warn(`[orm/search] queue dispatch failed for ${e.name}#${c}; falling back to inline: ${l.message}`),await qc(i,Number(c),e.name)}return}await qc(i,Number(c),e.name)}}}var Pc=new Map;function Bc(e,t){let n=Pc.get(e)??0;if(Pc.set(e,n+1),n===0)I.warn(`[orm/search] ${t}`);else if(n===9)I.warn(`[orm/search] ${e} is still failing; further identical warnings suppressed for this process.`)}async function Ec(e,t,n){try{let{useSearchEngine:i}=await import("@stacksjs/search-engine");await i().addDocument(e,t)}catch(i){Bc(`index:${n}`,`Failed to index ${n}: ${i.message}`)}}async function qc(e,t,n){try{let{useSearchEngine:i}=await import("@stacksjs/search-engine");await i().deleteDocument(e,t)}catch(i){Bc(`remove:${n}`,`Failed to remove ${n}#${t}: ${i.message}`)}}function Yu(e){let t={},n=e.table,i=e.traits;if(!i)return t;if(i.taggable)t._taggable=Ki(n);if(i.categorizable)t._categorizable=Hi(n);if(i.commentable)t._commentable=Bi(n);if(i.billable)t._billable=Rc(n);if(i.likeable){let o=typeof i.likeable==="object"?i.likeable:void 0;t._likeable=Vi(n,o)}let r=i.useAuth||i.authenticatable;if(typeof r==="object"&&r&&"useTwoFactor"in r&&r.useTwoFactor)t._twoFactor=wc();return t}function Zu(e,t,n){let i=Tc(e,t.primaryKey||"id"),r=vc(n),o=t,s=t.name.toLowerCase(),a=t.traits?.observe!=null&&t.traits?.observe!==!1,c=async(k)=>{if(!a||te())return!0;try{let{dispatchAsync:_}=await import("@stacksjs/events"),g=await _(`${s}:restoring`,{id:k});if(Array.isArray(g)&&g.some((y)=>y===!1))return!1}catch(_){if(_?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Before-event '${s}:restoring' handler error:`,_)}return!0},l=async(k)=>{if(!a||te())return;try{let{dispatch:_}=await import("@stacksjs/events");await _(`${s}:restored`,{id:k})}catch(_){if(_?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Event '${s}:restored' handler error:`,_)}},u=process.env.STACKS_ORM_CASCADE_SWALLOW!=="true",m=async(k)=>{if(!r.cascade?.length||!u){let g=await i.softDelete(k);if(g&&r.cascade?.length)await ni(o,r,k,"softDelete");return g}let{db:_}=await import("@stacksjs/database");return await _.transaction(async()=>{let g=await i.softDelete(k);if(g)await ni(o,r,k,"softDelete");return g})},p=async(k)=>{if(!await c(k))return!1;if(!r.cascade?.length||!u){let R=await i.restore(k);if(R){if(r.cascade?.length)await ni(o,r,k,"restore");await l(k)}return R}let{db:g}=await import("@stacksjs/database"),y=await g.transaction(async()=>{let R=await i.restore(k);if(R)await ni(o,r,k,"restore");return R});if(y)await l(k);return y};e.softDelete=m,e.restore=p,e.forceDelete=i.forceDelete,e.withTrashed=i.withTrashed,e.onlyTrashed=i.onlyTrashed,e.delete=m}function em(e){if(e==null)return e;if(Array.isArray(e))return e.map((n)=>em(n));if(typeof e!=="object")return e;let t=e;if(typeof t.toJSON==="function")return t.toJSON();if(t._attributes&&typeof t._attributes==="object")return t._attributes;return e}var tm=["belongsTo","hasOne","hasMany","belongsToMany","morphMany","morphOne"],nm=["traits","dashboard"];function im(e){let t=e?.[Na];if(t&&typeof t==="object")return t;if(e&&typeof e==="object"&&"name"in e&&"attributes"in e)return e;throw TypeError("extendModel() expects a model created by defineModel(), or a model definition. Import the framework model itself rather than its table name.")}function rm(e,t){let n=Array.isArray(e)?e:[],i=Array.isArray(t)?t:[];if(!n.length&&!i.length)return;return[...new Set([...n,...i])]}function om(e){if(!e)return 0;return Object.values(e).reduce((t,n)=>{let i=Number(n?.order);return Number.isFinite(i)&&i>t?i:t},0)}function sm(e,t){let n={...e,...t},i=e.attributes??{},r=t.attributes??{};if(t.attributes){let o=om(i),s=Object.fromEntries(Object.entries(r).map(([a,c])=>{let l=!(a in i),u=Number.isFinite(Number(c?.order));if(l&&!u)return[a,{...c,order:++o}];return[a,c]}));n.attributes={...i,...s}}for(let o of tm){let s=rm(e[o],t[o]);if(s)n[o]=s}for(let o of nm){let s=e[o],a=t[o];if(s&&a&&typeof s==="object"&&typeof a==="object")n[o]={...s,...a}}return n}function wj(e,t){return Nc(sm(im(e),t))}import am from"process";import{log as lm}from"@stacksjs/logging";import{path as V}from"@stacksjs/path";import{fs as ri}from"@stacksjs/storage";function cm(e){if(e)return e;let t=String(am.env.DB_CONNECTION??"").toLowerCase();return t==="postgres"||t==="mysql"?t:"sqlite"}function qi(e){return e==="postgres"?"boolean":"number"}function Q(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function dm(e,t){let n=e.default;if(typeof n==="boolean")return qi(t);if(typeof n==="number")return"number";if(typeof n==="string")return"string";return"unknown"}function um(e){let t=e.validation;if(!t||typeof t!=="object")return null;let n=t.rule;return n&&typeof n==="object"?n:null}function mm(e){if(!e||String(e.name??"")!=="enum")return null;let n=(Array.isArray(e.allowedValues)?e.allowedValues:[]).filter((i)=>typeof i==="string"||typeof i==="number").map((i)=>typeof i==="number"?String(i):JSON.stringify(i));return n.length>0?n.join(" | "):null}function pm(e,t){let n=um(e),i=mm(n);if(i!==null)return e.nullable===!0?`${i} | null`:i;let r=typeof e.type==="string"?e.type.toLowerCase():String(n?.name??"").toLowerCase(),o=(()=>{switch(r){case"string":case"text":case"longtext":case"mediumtext":case"tinytext":case"char":case"varchar":case"enum":case"uuid":case"date":case"datetime":case"timestamp":case"timestamptz":case"password":case"time":case"year":return"string";case"number":case"integer":case"int":case"tinyint":case"smallint":case"mediumint":case"float":case"double":case"decimal":case"numeric":return"number";case"bigint":return"number | bigint";case"boolean":case"bool":return qi(t);case"json":case"jsonb":return"unknown";case"binary":case"blob":case"bytea":return"Uint8Array";case"unix":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return dm(e,t)}})();return e.nullable===!0?`${o} | null`:o}function fm(e){let t={},n=e.belongsTo;if(!n)return t;let i=Array.isArray(n)?n:Object.values(n);for(let r of i){if(typeof r==="string"){t[`${Q(r)}_id`]="number";continue}if(r&&typeof r==="object"){let o=r;if(typeof o.foreignKey==="string"){t[o.foreignKey]="number";continue}if(typeof o.model==="string")t[`${Q(o.model)}_id`]="number"}}return t}function _m(e,t){let[n,i]=[Q(e),Q(t)].sort();return`${n}_${i}`}function km(e,t){let n=e.default,i=typeof n==="string"?"string":typeof n==="number"?"number":typeof n==="boolean"?qi(t):n instanceof Date?"string":"unknown";return e.nullable?`${i} | null`:i}function bm(e,t,n){let i=t.belongsToMany;if(!i)return[];let r=[],o=Array.isArray(i)?i:Object.values(i);for(let s of o){let a,c,l,u,m={},p=!0;if(typeof s==="string")a=s;else if(s&&typeof s==="object"&&"model"in s){let R=s;if(a=R.model,"pivotTable"in R||"firstForeignKey"in R||"secondForeignKey"in R)c=R.pivotTable,l=R.firstForeignKey,u=R.secondForeignKey;else{let w=s;c=w.table,l=w.foreignKey,u=w.relatedKey,m=w.pivot?.columns??{},p=Boolean(w.pivot?.timestamps)}}else continue;let k=c??_m(e,a),_=l??`${Q(e)}_id`,g=u??`${Q(a)}_id`,y={id:"number",[_]:"number",[g]:"number"};for(let[R,w]of Object.entries(m))y[R]=km(w,n);if(p)y.created_at="string",y.updated_at="string | null";r.push({table:k,columns:y})}return r}function gm(e){return{email_verified_at:"string | null",password_changed_at:"string | null",two_factor_secret:"string | null",two_factor_enabled:`${qi(e)} | null`,two_factor_last_used_step:"number | null",stripe_id:"string | null"}}function hm(e,t){let n={id:"number"},i=e.traits??{};if(i.useUuid)n.uuid="string";if((i.useTimestamps??i.timestampable)!==!1)n.created_at="string",n.updated_at="string | null";if(i.useSoftDeletes??i.softDeletable)n.deleted_at="string | null";if((e.table??"")==="users"||e.name==="User")Object.assign(n,gm(t));return n}function ym(e,t){let n={},i=e.attributes??{};for(let[r,o]of Object.entries(i))n[Q(r)]=pm(o,t);return n}function Lc(e,t,n=2){let i=" ".repeat(n),r=" ".repeat(n+1),o=Object.entries(t).map(([a,c])=>`${r}${a}: ${c}`).join(`
16
- `),s=/^[A-Z_a-z]\w*$/.test(e)?e:`'${e}'`;return`${i}${s}: {
17
- ${r}// columns
18
- ${o}
19
- ${i}}`}var Rm=`/* eslint-disable */
2
+ var b=import.meta.require;import"@stacksjs/validation";import{log as le}from"@stacksjs/cli";import{db as Le}from"@stacksjs/database";async function qt(e,n={}){let{olderThanDays:t=30,column:r="created_at",query:o}=n;try{if(o){let u=Le.deleteFrom(e);u=o(u);let l=await u.execute(),f=Array.isArray(l)?l:[l],d=Number(f[0]?.numDeletedRows??f.length??0);return le.info(`Pruned ${d} records from ${e}`),d}let a=new Date;a.setDate(a.getDate()-t);let i=await Le.deleteFrom(e).where(r,"<",a.toISOString()).execute(),s=Array.isArray(i)?i:[i],c=Number(s[0]?.numDeletedRows??s.length??0);return le.info(`Pruned ${c} records from ${e} older than ${t} days`),c}catch(a){throw le.error(`Failed to prune ${e}:`,a),a}}async function Oa(e,n={}){return qt(e,n)}function va(e){if(!e?.prunable)return null;if(typeof e.prunable==="boolean")return{olderThanDays:30,column:"created_at"};return e.prunable}import{createCipheriv as Ut,createDecipheriv as Lt,createHash as Qt,randomBytes as Vt}from"crypto";import{log as X}from"@stacksjs/logging";var Qe="enc:",Ve="aes-256-gcm",Wt=12,Z=null;async function We(){if(Z)return Z;let e=process.env.APP_KEY;if(!e)try{e=(await import("@stacksjs/config").catch(()=>null))?.config?.app?.key}catch{}if(!e)return null;return Z=Qt("sha256").update(e).digest(),Z}function U(e){return typeof e==="string"&&e.startsWith(Qe)}async function de(e){if(e==null)return e;if(U(e))return e;if(typeof e!=="string")return e;let n=await We();if(!n)return X.warn("[orm] encrypted attribute: APP_KEY not set - storing value in plaintext"),e;let t=Vt(Wt),r=Ut(Ve,n,t),o=Buffer.concat([r.update(e,"utf8"),r.final()]),a=r.getAuthTag();return`${Qe}${t.toString("base64")}:${a.toString("base64")}:${o.toString("base64")}`}async function fe(e){if(e==null)return e;if(typeof e!=="string")return e;if(!U(e))return e;try{let n=await We();if(!n)return X.warn("[orm] encrypted attribute: APP_KEY not set - cannot decrypt"),null;let[,t,r,o]=e.split(":");if(!t||!r||!o)return X.warn("[orm] encrypted attribute: malformed envelope, returning null"),null;let a=Buffer.from(t,"base64"),i=Buffer.from(r,"base64"),s=Buffer.from(o,"base64"),c=Lt(Ve,n,a);return c.setAuthTag(i),Buffer.concat([c.update(s),c.final()]).toString("utf8")}catch(n){return X.warn("[orm] encrypted attribute: decrypt failed (key rotation? corrupted ciphertext?)",{error:n}),null}}function pe(e){let n=e.attributes;if(!n||typeof n!=="object")return[];let t=[];for(let[r,o]of Object.entries(n))if(o&&typeof o==="object"&&o.encrypted===!0)t.push(r);return t}import{sqlDateTime as zt}from"@stacksjs/database";import{log as Q}from"@stacksjs/logging";var Ht=[/^password$/i,/^password_hash$/i,/^api_key$/i,/_token$/i,/_secret$/i,/^remember_token$/i],He="model_audits",ye=null;function Gt(e){ye=e}async function me(){if(ye!=null)return ye;try{let e=await import("@stacksjs/router").catch(()=>null);if(!e)return null;let n=e.getCurrentRequest;if(typeof n!=="function")return null;let t=n();if(!t)return null;return(t.user??t._user)?.id??null}catch{return null}}function ee(e){if(!e||typeof e!=="object")return null;let n={};for(let[t,r]of Object.entries(e)){if(Ht.some((o)=>o.test(t)))continue;n[t]=r}return n}function L(e){if(!e||typeof e!=="object")return null;let n=e;if(n._attributes&&typeof n._attributes==="object")return{...n._attributes};return{...e}}function Jt(e,n){if(!e||!n)return{old:e,next:n};let t={},r={},o=new Set([...Object.keys(e),...Object.keys(n)]);for(let a of o)if(e[a]!==n[a])t[a]=e[a],r[a]=n[a];return{old:t,next:r}}async function ge(e,n=!1){try{let{db:t}=await import("@stacksjs/database");await t.insertInto(He).values({auditable_type:e.auditable_type,auditable_id:e.auditable_id,event:e.event,old_values:e.old_values?JSON.stringify(e.old_values):null,new_values:e.new_values?JSON.stringify(e.new_values):null,user_id:e.user_id,created_at:zt()}).executeTakeFirst()}catch(t){if(Q.warn(`[orm] audit row write failed for ${e.auditable_type}#${String(e.auditable_id)} (${e.event})`,{error:t}),n)throw t}}function Ge(e){return{async audits(n){try{let{db:t}=await import("@stacksjs/database");return(await t.selectFrom(He).selectAll().where("auditable_type","=",e).where("auditable_id","=",n).orderBy("created_at","desc").execute()??[]).map((o)=>({...o,old_values:typeof o.old_values==="string"?ze(o.old_values):o.old_values,new_values:typeof o.new_values==="string"?ze(o.new_values):o.new_values}))}catch(t){return Q.warn(`[orm] audits() lookup failed for ${e}#${String(n)}`,{error:t}),[]}}}}function ze(e){try{return JSON.parse(e)}catch{return e}}function Je(e){if(e&&typeof e==="object"&&"transactional"in e)return{transactional:e.transactional===!0};return{transactional:!1}}function Ye(e,n,t="id",r={}){let o=r.transactional===!0,a=e;if(typeof e.audits!=="function")e.audits=Ge(n).audits;let i=async(l)=>{if(!o)return await l();let{db:f}=await import("@stacksjs/database");return await f.transaction(async()=>l())},s=e.create;if(typeof s==="function")e.create=async function(...l){return await i(async()=>{let f=await s.apply(this,l);try{let d=L(f),m=d?.[t];if(m!=null){let p=await me();await ge({auditable_type:n,auditable_id:m,event:"created",old_values:null,new_values:ee(d),user_id:p},o)}}catch(d){if(Q.warn(`[orm] audit(create) failed for ${n}`,{error:d}),o)throw d}return f})};let c=e.update;if(typeof c==="function")e.update=async function(l,f){return await i(async()=>{let d=a.find,m=typeof d==="function"?L(await d.call(a,l)):null,p=await c.call(this,l,f);try{let y=L(p)??(typeof d==="function"?L(await d.call(a,l)):null),{old:w,next:h}=Jt(m,y);if(h&&Object.keys(h).length>0){let T=await me();await ge({auditable_type:n,auditable_id:l,event:"updated",old_values:ee(w),new_values:ee(h),user_id:T},o)}}catch(y){if(Q.warn(`[orm] audit(update) failed for ${n}#${String(l)}`,{error:y}),o)throw y}return p})};let u=(l)=>{let f=e[l];if(typeof f!=="function")return;e[l]=async function(d){return await i(async()=>{let m=a.find,p=typeof m==="function"?L(await m.call(a,d)):null,y=await f.call(this,d);try{if(y!==!1&&p){let w=await me();await ge({auditable_type:n,auditable_id:d,event:"deleted",old_values:ee(p),new_values:null,user_id:w},o)}}catch(w){if(Q.warn(`[orm] audit(${l}) failed for ${n}#${String(d)}`,{error:w}),o)throw w}return y})}};u("delete"),u("softDelete")}import{db as Yt,sql as Zt,sqlDateTime as be}from"@stacksjs/database";function M(e,n){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/commentable] ${n} requires a positive numeric id (received ${String(e)})`)}var V="commentable_upvotes",W="commentables";function Xt(e){let n=e;return n.code==="SQLITE_CONSTRAINT_UNIQUE"||n.code==="SQLITE_CONSTRAINT"||n.code==="23505"||n.errno===1062||/unique|duplicate/i.test(n.message??"")}function we(e){let n=Yt;return{async comments(t){return M(t,"comments"),await n.selectFrom("commentables").where("commentables_id","=",t).where("commentables_type","=",e).selectAll().execute()},async commentCount(t){let r=await n.selectFrom("commentables").select(Zt`count(*) as count`).where("commentables_id","=",t).where("commentables_type","=",e).executeTakeFirst();return Number(r?.count)||0},async addComment(t,r){if(M(t,"addComment"),!r||typeof r.title!=="string"||r.title.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.title");if(typeof r.body!=="string"||r.body.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.body");let o=await n.insertInto("commentables").values({...r,commentables_id:t,commentables_type:e,status:"pending",created_at:be(),updated_at:be()}).returningAll().executeTakeFirst();if(o&&typeof o==="object"&&"id"in o)return o;let a=o?.lastInsertRowid;if(a==null)return o;return await n.selectFrom("commentables").where("id","=",Number(a)).selectAll().executeTakeFirst()},async approvedComments(t){return await n.selectFrom("commentables").where("commentables_id","=",t).where("commentables_type","=",e).where("status","=","approved").selectAll().execute()},async pendingComments(t){return await n.selectFrom("commentables").where("commentables_id","=",t).where("commentables_type","=",e).where("status","=","pending").selectAll().execute()},async rejectedComments(t){return await n.selectFrom("commentables").where("commentables_id","=",t).where("commentables_type","=",e).where("status","=","rejected").selectAll().execute()},async upvoteComment(t,r){M(t,"upvoteComment"),M(r,"upvoteComment");let o=()=>n.selectFrom(V).where("upvoteable_id","=",t).where("upvoteable_type","=",W).where("user_id","=",r).selectAll().executeTakeFirst(),a=await o();if(a)return a;try{await n.insertInto(V).values({upvoteable_id:t,upvoteable_type:W,user_id:r,created_at:be()}).execute()}catch(i){if(!Xt(i))throw i}return await o()},async removeCommentUpvote(t,r){M(t,"removeCommentUpvote"),M(r,"removeCommentUpvote"),await n.deleteFrom(V).where("upvoteable_id","=",t).where("upvoteable_type","=",W).where("user_id","=",r).execute()},async commentUpvoteCount(t){M(t,"commentUpvoteCount");let r=await n.selectFrom(V).select("count(*) as count").where("upvoteable_id","=",t).where("upvoteable_type","=",W).executeTakeFirst();return Number(r?.count)||0},async hasUpvotedComment(t,r){return M(t,"hasUpvotedComment"),M(r,"hasUpvotedComment"),!!await n.selectFrom(V).where("upvoteable_id","=",t).where("upvoteable_type","=",W).where("user_id","=",r).selectAll().executeTakeFirst()}}}import{db as en,sql as tn,sqlDateTime as Ze}from"@stacksjs/database";function he(e,n){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/taggable] ${n} requires a positive numeric id (received ${String(e)})`)}function Te(e){let n=en;return{async tags(t){return he(t,"tags"),await n.selectFrom("taggables").where("taggable_id","=",t).where("taggable_type","=",e).selectAll().execute()},async tagCount(t){he(t,"tagCount");let r=await n.selectFrom("taggables").select(tn`count(*) as count`).where("taggable_id","=",t).where("taggable_type","=",e).executeTakeFirst();return Number(r?.count)||0},async addTag(t,r){if(he(t,"addTag"),!r||typeof r.name!=="string"||r.name.trim().length===0)throw Error("[orm/taggable] addTag requires a non-empty tag.name");return await n.insertInto("taggables").values({...r,taggable_id:t,taggable_type:e,slug:r.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),is_active:!0,created_at:Ze(),updated_at:Ze()}).execute(),await n.selectFrom("taggables").where("taggable_id","=",t).where("taggable_type","=",e).where("name","=",r.name).selectAll().executeTakeFirst()},async activeTags(t){return await n.selectFrom("taggables").where("taggable_id","=",t).where("taggable_type","=",e).where("is_active","=",!0).selectAll().execute()},async inactiveTags(t){return await n.selectFrom("taggables").where("taggable_id","=",t).where("taggable_type","=",e).where("is_active","=",!1).selectAll().execute()},async removeTag(t,r){await n.deleteFrom("taggables").where("taggable_id","=",t).where("taggable_type","=",e).where("id","=",r).execute()}}}import{db as nn,sqlDateTime as te}from"@stacksjs/database";function _e(e){let n=nn;async function t(r){return(await n.selectFrom("categorizable_models").where("categorizable_id","=",r).where("categorizable_type","=",e).selectAll().execute()).map((a)=>a.category_id)}return{async categories(r){let o=await t(r);if(o.length===0)return[];return await n.selectFrom("categorizables").where("id","in",o).selectAll().execute()},async categoryCount(r){return(await t(r)).length},async addCategory(r,o){let a=()=>n.selectFrom("categorizables").where("name","=",o.name).where("categorizable_type","=",e).selectAll().executeTakeFirst(),i=await a();if(!i)await n.insertInto("categorizables").values({name:o.name,description:o.description,slug:o.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),categorizable_type:e,is_active:!0,created_at:te(),updated_at:te()}).execute(),i=await a();return await n.insertInto("categorizable_models").values({categorizable_id:r,categorizable_type:e,category_id:i?.id,created_at:te(),updated_at:te()}).execute(),i},async activeCategories(r){let o=await t(r);if(o.length===0)return[];return await n.selectFrom("categorizables").where("id","in",o).where("is_active","=",!0).selectAll().execute()},async inactiveCategories(r){let o=await t(r);if(o.length===0)return[];return await n.selectFrom("categorizables").where("id","in",o).where("is_active","=",!1).selectAll().execute()},async removeCategory(r,o){await n.deleteFrom("categorizable_models").where("categorizable_id","=",r).where("categorizable_type","=",e).where("category_id","=",o).execute()}}}import{db as rn,sqlDateTime as on}from"@stacksjs/database";function ke(e,n){let t=rn,r=n?.table||`${e}_likes`,o=n?.foreignKey||`${e.replace(/s$/,"")}_id`;return{async likes(a){return await t.selectFrom(r).where(o,"=",a).selectAll().execute()},async likeCount(a){let i=await t.selectFrom(r).select("count(*) as count").where(o,"=",a).executeTakeFirst();return Number(i?.count)||0},async like(a,i){if(typeof a!=="number"||!Number.isFinite(a)||a<=0)throw Error(`[orm/likeable] like requires a positive numeric id (received ${String(a)})`);if(typeof i!=="number"||!Number.isFinite(i)||i<=0)throw Error(`[orm/likeable] like requires a positive numeric userId (received ${String(i)})`);let s=on();try{return await t.insertInto(r).values({[o]:a,user_id:i,created_at:s,updated_at:s}).returningAll().executeTakeFirst()}catch(c){let u=c;if(!(u.code==="SQLITE_CONSTRAINT_UNIQUE"||u.code==="SQLITE_CONSTRAINT"||u.code==="23505"||u.errno===1062||/unique|duplicate/i.test(u.message??"")))throw c;let f=await t.selectFrom(r).where(o,"=",a).where("user_id","=",i).selectAll().executeTakeFirst();if(f)return f;throw c}},async unlike(a,i){await t.deleteFrom(r).where(o,"=",a).where("user_id","=",i).execute()},async isLiked(a,i){return!!await t.selectFrom(r).where(o,"=",a).where("user_id","=",i).selectAll().executeTakeFirst()},async likedBy(a){return(await t.selectFrom(r).select([o]).where("user_id","=",a).execute()).map((s)=>Number(s[o])).filter(Boolean)}}}function tt(e){let n=e;return n?.code==="SQLITE_CONSTRAINT_UNIQUE"||n?.code==="SQLITE_CONSTRAINT"||n?.code==="23505"||n?.errno===1062||/unique|duplicate/i.test(n?.message??"")}function an(e,n,t){let r=e;if(e instanceof Error&&typeof r.status==="number"&&Number.isInteger(r.status)&&r.status>=400&&r.status<600){let o={error:e.message};if(r.details!==void 0)o.details=r.details;return{status:r.status,body:o}}if(tt(e))return{status:409,body:{error:`${n} already exists`}};return{status:500,body:{error:`Failed to ${t} ${n}`,detail:String(e)}}}function R(e){return e.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase()}function sn(e){let n={};for(let[t,r]of Object.entries(e))n[R(t)]=r;return n}function za(e,n){let t=String(n||"").replace(/^\/+|\/+$/g,""),r=String(e).replace(/^\/+/,"");return`/api/${t?`${t}/`:""}${r}`}function Ha(e){if(!e)return null;let n=e.attributes??{};if(Object.prototype.hasOwnProperty.call(n,"teamId")||Object.prototype.hasOwnProperty.call(n,"team_id"))return"team_id";return e.belongsTo?.some((t)=>t==="Team")?"team_id":null}function Ga(e,n,t){let r=Object.keys(e).find((a)=>R(a)===R(n));if(Array.isArray(t)){if(r===void 0)return{data:e,error:"Ownership value is required"};if(!t.some((a)=>String(a)===String(e[r])))return{data:e,error:"Ownership value is not available to this caller"};return{data:{...e,[n]:e[r]}}}if(t===null||t===void 0)return{data:e,error:"Caller has no ownership identity"};let o={...e};for(let a of Object.keys(o))if(R(a)===R(n))delete o[a];return o[n]=t,{data:o}}function un(e){if(!e)return[];let n=Object.entries(e.attributes??{}).filter(([,t])=>t?.fillable===!0).map(([t])=>t);for(let t of e.belongsTo??[]){if(typeof t!=="string"||!t.trim())continue;let r=R(t.trim()).split("_").filter(Boolean);if(r.length===0)continue;let o=`${r[0]}${r.slice(1).map((a)=>`${a[0]?.toUpperCase()}${a.slice(1)}`).join("")}Id`;n.push(o)}return[...new Set(n)]}function cn(e,n){if(!e||n.length===0)return{};let t={};for(let r of n){if(r in e){t[r]=e[r];continue}let o=R(r);if(o!==r&&o in e)t[r]=e[o]}return t}function ln(e,n){if(e?.name!=="date"||n instanceof Date||typeof n!=="string")return n;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(!t)return n;let r=Number(t[1]),o=Number(t[2]),a=Number(t[3]),i=new Date(Date.UTC(r,o-1,a));if(i.getUTCFullYear()!==r||i.getUTCMonth()!==o-1||i.getUTCDate()!==a)return n;return i}function Ja(e,n){if(!n.length)return e;let t={...e};for(let r of n)delete t[r],delete t[R(r)];return t}function Ya(e,n){if(!e||n.length===0)return e;let t={...e};for(let r of n)delete t[r],delete t[R(r)];return t}var dn=["id","uuid","created_at","updated_at","deleted_at"];function Za(e,n){let t=new Map;for(let r of[...Object.keys(e??{}),...dn]){let o=R(r);if(!/^\w+$/.test(o))continue;t.set(r,o),t.set(o,o)}for(let r of n)t.delete(r),t.delete(R(r));return t}function Xa(e,n,t){if(!n)return e;let r=String(n).split(",").map((a)=>a.trim()).filter(Boolean),o=e;for(let a of r){let i=a.startsWith("-"),s=i?a.slice(1):a;if(!/^\w+$/.test(s))continue;let c=t.get(s);if(!c)continue;o=o.orderBy(c,i?"desc":"asc")}return o}var fn={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>e==null?null:typeof e==="string"?pn(e):e,set:(e)=>e==null?null:typeof e==="string"?e:JSON.stringify(e)},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>e==null?[]:Array.isArray(e)?e:typeof e==="string"?mn(e):[],set:(e)=>e==null?null:Array.isArray(e)?JSON.stringify(e):e}};function pn(e){try{return JSON.parse(e)}catch{return e}}function mn(e){try{return JSON.parse(e)}catch{return[]}}function ei(e,n,t){if(!e||typeof e!=="object"||!n||Object.keys(n).length===0)return e;let r={...e};for(let[o,a]of Object.entries(n)){let i=typeof a==="string"?fn[a]:a;if(!i||typeof i[t]!=="function")continue;if(Object.prototype.hasOwnProperty.call(r,o))r[o]=i[t](r[o]);let s=R(o);if(s!==o&&Object.prototype.hasOwnProperty.call(r,s))r[s]=i[t](r[s])}return r}function nt(e,n,t){let r=n?.attributes??{},o={};for(let[a,i]of Object.entries(r)){let s=i?.validation?.rule;if(!s||typeof s.validate!=="function")continue;let c=Object.prototype.hasOwnProperty.call(e,a);if(!c&&t==="updating")continue;let u=i!==null&&typeof i==="object"&&Object.prototype.hasOwnProperty.call(i,"default"),l=c?e[a]:u?i.default:void 0,f=ln(s,l),d=s.validate(f);if(!d?.valid&&Array.isArray(d?.errors)&&d.errors.length>0)o[a]=d.errors.map((m)=>i?.validation?.message?.[m?.code]??m?.message??"invalid")}return Object.keys(o).length===0?{valid:!0}:{valid:!1,errors:o}}function ti(e,n,t){let r=Xe(t);return e.find((o)=>o.method===n&&Xe(String(o.path??""))===r)}function Xe(e){return e.replace(/\{[^}]*\}/g,"{}").replace(/:[^/]+/g,"{}")}function Re(e){if(Array.isArray(e))return e.filter((n)=>typeof n==="string"&&n.length>0);return typeof e==="string"&&e?[e]:[]}function ni(e){let n=typeof e==="object"&&e!==null&&"middleware"in e,t=e?.middleware;if(!n)return{read:["auth"],write:["auth"],declared:!1};if(t&&typeof t==="object"&&!Array.isArray(t)){let o=t;return{read:"read"in o?Re(o.read):["auth"],write:"write"in o?Re(o.write):["auth"],declared:!0}}let r=Re(t);return{read:r,write:r,declared:!0}}var et=15,gn=100;function ri(e){let n=Number.parseInt(e.get("page")||String(1),10),t=Number.isFinite(n)?Math.max(1,n):1,r=Number.parseInt(e.get("per_page")||String(et),10),o=Math.min(Number.isFinite(r)?Math.max(1,r):et,gn);return{page:t,perPage:o,offset:(t-1)*o}}function ne(e,n){let t=new URL(e.toString());return t.searchParams.set("page",String(n)),`${t.pathname}${t.search}`}function yn(e,n,t,r,o,a){let i=(n-1)*t,s=r===0,c={page:n,per_page:t,from:s?null:i+1,to:s?null:i+r,has_more_pages:o,prev_page_url:n>1?ne(e,n-1):null,next_page_url:o?ne(e,n+1):null};if(a!==void 0&&!Number.isNaN(a)){let u=Math.max(1,Math.ceil(a/t));c.total=a,c.last_page=u,c.first_page_url=ne(e,1),c.last_page_url=ne(e,u)}return c}function oi(e,n,t,r,o,a){let{page:i,...s}=yn(e,n,t,r,o,a);return{current_page:i,...s}}function ai(e,n){return(n??e??"").toString().trim().toLowerCase()==="deny"?"deny":"warn"}function ii(e,n){if(e.length===0)return null;let t=[...e].sort().join(", ");if(n==="deny")return`[orm] security.api.rowScoping is 'deny': NOT registering store/update/destroy for ${e.length} model(s) `+`with no row-level scoping \u2014 ${t}. Give a model an \`ownership\` config or a \`team_id\` column to restore its writes.`;return`[orm] ${e.length} model(s) publish mutating routes with no row-level scoping, so an authenticated caller can write any row \u2014 `+`${t}. Scope one with an \`ownership\` config or a \`team_id\` column; intended for public catalog tables. Set \`security.api.rowScoping: 'deny'\` (config/security.ts) to stop generating these routes instead.`}import{cacheRequestQuery as bn}from"@stacksjs/router";var re=new WeakMap;function ci(e,n){return bn(`batchLoad:${e.name??"model"}:${String(n)}`,async()=>new Promise((t,r)=>{let o=re.get(e);if(!o)o={keys:[],resolvers:[],scheduled:!1},re.set(e,o);if(o.keys.push(n),o.resolvers.push({key:n,resolve:t,reject:r}),o.scheduled)return;o.scheduled=!0,Promise.resolve().then(async()=>{let a=re.get(e);if(!a)return;re.delete(e);let i=Array.from(new Set(a.keys));try{let s=typeof e.findMany==="function"?await e.findMany(i):await Promise.all(i.map((u)=>e.find?.(u))),c=new Map;for(let u of s??[]){let l=u?.id;if(l!==void 0)c.set(l,u)}for(let u of a.resolvers)u.resolve(c.get(u.key))}catch(s){for(let c of a.resolvers)c.reject(s)}})}))}import{db as pi}from"@stacksjs/database";class wn{conditions=[];where(e,...n){let[t,r]=n,o=r===void 0?"=":t,a=r===void 0?t:r;this.addCondition("and","where",e,o,a)}orWhere(e,...n){let[t,r]=n,o=r===void 0?"=":t,a=r===void 0?t:r;this.addCondition("or","where",e,o,a)}whereIn(e,n){this.conditions.push({type:"and",method:"whereIn",column:e,values:n})}whereNotIn(e,n){this.conditions.push({type:"and",method:"whereIn",column:e,values:n,operator:"not in"})}whereNull(e){this.conditions.push({type:"and",method:"whereNull",column:e})}whereNotNull(e){this.conditions.push({type:"and",method:"whereNotNull",column:e})}whereBetween(e,n){this.conditions.push({type:"and",method:"whereBetween",column:e,range:n})}whereExists(e){this.conditions.push({type:"and",method:"whereExists",column:"",callback:e})}addCondition(e,n,t,r,o){this.conditions.push({type:e,method:n,column:t,operator:r,value:o})}getConditions(){return this.conditions}}import{db as Se,runInTransactionScope as hn}from"@stacksjs/database";async function yi(e,n){return await hn(async()=>await Se.transaction(e,n))}async function bi(e){return await Se.savepoint(e)}function wi(e,n){return Se.transactional(e,n)}import{path as C}from"@stacksjs/path";import{fs as B,globSync as Me}from"@stacksjs/storage";import{plural as st,singular as rt,snakeCase as _}from"@stacksjs/strings";import{isString as oe}from"@stacksjs/validation";function ut(e){let n=e.belongsToMany;if(!n)return[];if(Array.isArray(n))return n.map((t)=>({relationName:typeof t==="string"?_(t):_(String(t.model)),relation:t}));return Object.entries(n).map(([t,r])=>{if(typeof r==="string")return{relationName:t,relation:r};return{relationName:t,relation:{model:r.model,pivotTable:r.table,firstForeignKey:r.foreignKey,secondForeignKey:r.relatedKey}}})}async function Si(e){if(typeof e==="string")e=(await import(e)).default;return e.table??_(st(e?.name||""))}function z(e,n){if(e.name)return e.name;return C.basename(n).replace(/\.ts$/,"")}function x(e,n){if(e.table)return e.table;return _(st(z(e,n)))}function Tn(e,n){let t=[e,n];return t.sort(),t.join("_")}function Pi(e,n){return n in e}async function _n(e,n){let t=[];if(e.hasOne)for(let r of e.hasOne)t.push(await Pe(r,e,n,"hasOne"));if(e.hasMany)for(let r of e.hasMany)t.push(await Pe(r,e,n,"hasMany"));if(e.belongsTo)for(let r of e.belongsTo)t.push(await Pe(r,e,n,"belongsTo"));if(e.hasOneThrough)for(let r of e.hasOneThrough)t.push(await at(r,e,n,"hasOneThrough"));if(e.hasManyThrough)for(let r of e.hasManyThrough)t.push(await at(r,e,n,"hasManyThrough"));if(e.belongsToMany)for(let{relationName:r,relation:o}of ut(e))t.push(await Rn(o,e,n,"belongsToMany",r));if(e.morphOne)t.push(await it(e.morphOne,e,n,"morphOne"));if(e.morphMany){let r=Array.isArray(e.morphMany)?e.morphMany:[e.morphMany];for(let o of r)t.push(await it(o,e,n,"morphMany"))}if(e.morphTo){let r=e.morphTo,o=Array.isArray(r)?r:typeof r==="object"&&r!==null?[r]:[];for(let a of o)t.push(kn(a,e,n))}if(e.morphToMany){let r=Array.isArray(e.morphToMany)?e.morphToMany:[e.morphToMany];for(let o of r)t.push(ot(o,e,n,"morphToMany"))}if(e.morphedByMany){let r=Array.isArray(e.morphedByMany)?e.morphedByMany:[e.morphedByMany];for(let o of r)t.push(ot(o,e,n,"morphedByMany"))}return t}function kn(e,n,t){let r=e&&typeof e==="object"&&e.name?String(e.name):`${_(t)}able`,o=e?.type||`${r}_type`;return{relationship:"morphTo",model:"",table:"",relationTable:"",foreignKey:e?.id||`${r}_id`,modelKey:o,relationName:r,relationModel:t,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:""}}function ot(e,n,t,r){let o=typeof e==="object"&&e!==null,a=o?String(e.model||""):String(e),i=o&&e.morphName?String(e.morphName):`${_(t)}able`,s=o&&e.pivotTable?String(e.pivotTable):i,c=o&&e.id||`${i}_id`,u=o&&e.type||`${i}_type`;return{relationship:r,model:a,table:"",relationTable:"",foreignKey:c,modelKey:u,relationName:i,relationModel:t,throughModel:"",throughForeignKey:"",pivotForeign:c,pivotKey:u,pivotTable:s}}async function ae(e,n){let t=Ae(`${n}.ts`),r=Ae(`${e}.ts`),o=xe(`${e}.ts`),a=xe(`${n}.ts`);if(!t&&!a)throw Error(`Model not found: ${n}`);if(!r&&!o)throw Error(`Model not found: ${e}`);let i;try{if(B.existsSync(t))i=(await import(t)).default;else i=(await import(a)).default}catch(c){throw Error(`Failed to load model: ${n}. Error: ${c?.message||"Unknown error"}`)}let s=B.existsSync(r)?r:o;return{modelRelation:i,modelPath:s,modelRelationPath:B.existsSync(t)?t:a}}async function at(e,n,t,r){let o="",a="",i="",s="";if(oe(e))o=e;else o=e.model,a=e.relationName||"",i=e.through,s=e.throughForeignKey||"";let{modelRelation:c,modelPath:u,modelRelationPath:l}=await ae(t,o),f=x(c,l),d=x(n,u),m=_(z(c,l)),p=_(t);return{relationship:r,model:o,table:f,relationTable:d,foreignKey:`${p}_id`,modelKey:`${m}_id`,relationName:a,relationModel:t,throughModel:i,throughForeignKey:s,pivotForeign:`${p}_id`,pivotKey:`${m}_id`,pivotTable:d}}async function Rn(e,n,t,r,o){let a="",i="",s="",c=_(t);if(oe(e))a=e;else a=e.model,i=e.pivotTable||"",s=e.firstForeignKey||`${c}_id`;let{modelRelation:u,modelPath:l,modelRelationPath:f}=await ae(t,a),d=x(u,f),m=x(n,l),p=_(z(u,f));return{relationship:r,model:a,table:d,relationTable:m,foreignKey:typeof e==="string"?`${c}_id`:e.firstForeignKey||`${c}_id`,modelKey:typeof e==="string"?`${p}_id`:e.secondForeignKey||`${p}_id`,relationName:o,relationModel:t,throughModel:"",throughForeignKey:"",pivotForeign:s,pivotKey:`${p}_id`,pivotTable:i}}async function it(e,n,t,r){let o="",a="",i="",s="";if(oe(e))o=e,a=`${_(t)}able`;else o=e.model,a=e.morphName||`${_(t)}able`,i=e.type||`${a}_type`,s=e.id||`${a}_id`;let{modelRelation:c,modelPath:u,modelRelationPath:l}=await ae(t,o),f=x(c,l),d=x(n,u);return{relationship:r,model:o,table:f,relationTable:d,foreignKey:s||`${a}_id`,modelKey:i||`${a}_type`,relationName:a,relationModel:t,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:d}}async function Pe(e,n,t,r){let o="",a="";if(oe(e))o=e;else o=e.model,a=e.relationName||"";let{modelRelation:i,modelPath:s,modelRelationPath:c}=await ae(t,o),u=x(i,c),l=x(n,s),f=_(z(i,c)),d=_(t),m=typeof e==="string"?"":e.foreignKey||"",p={relationship:r,model:o,table:u,relationTable:l,foreignKey:m||`${d}_id`,modelKey:`${f}_id`,relationName:a,relationModel:t,throughModel:"",throughForeignKey:"",pivotForeign:`${d}_id`,pivotKey:`${f}_id`,pivotTable:l};if(r==="belongsTo"){if(p.foreignKey="",m)p.modelKey=m}return p}function xi(e){let n=/belongs/,t=/has/,r=/Through/,o=/morph/;if(r.test(e))return"throughType";if(n.test(e))return"belongsType";if(t.test(e))return"hasType";if(o.test(e))return"morphType";return""}function Ai(e){let n=/One/;if(/Many/.test(e))return"many";if(n.test(e))return"one";return""}async function Mi(e,n){let t=[];if("belongsToMany"in e){for(let{relation:r}of ut(e)){let o,a;if(typeof r==="string")a=r;else a=r.model;let i=Ae(`${a}.ts`),s=xe(`${a}.ts`);if(B.existsSync(i))o=(await import(i)).default;else o=(await import(s)).default;let c=x(o,i),u=x(e,n),l=typeof r==="object"&&"firstForeignKey"in r?r.firstForeignKey:`${rt(u)}_${e.primaryKey}`,f=typeof r==="object"&&"secondForeignKey"in r?r.secondForeignKey:`${rt(c)}_${e.primaryKey}`;t.push({table:(typeof r==="object"&&"pivotTable"in r?r.pivotTable:void 0)??Tn(u,c),firstForeignKey:l,secondForeignKey:f})}return t}return[]}async function Ci(e){let n=Me([C.userModelsPath("*.ts"),C.storagePath("framework/defaults/app/Models/**/*.ts")],{absolute:!0}),t=[];for(let r=0;r<n.length;r++){let o=n[r],a=await import(o);if(e===a.default.name)continue;let i=z(a,o),s=await _n(a.default,i);if(!s.length)continue;let c=s.find((u)=>u.model===e);if(c)t.push(c)}return t}function Oi(e){if(e===void 0)return[];return Object.keys(e).filter((n)=>e[n]?.hidden===!0)}function vi(e){let n=e.attributes;if(n===void 0)return[];return Object.keys(n).filter((t)=>n[t]?.guarded===!0).map((t)=>_(t))}function Di(e,n){let t=e.attributes,r=[];if(t===void 0)return[];let o=typeof e.traits?.billable==="object"||typeof e.traits?.billable==="boolean",a=typeof e.traits?.useAuth==="object"?e.traits?.useAuth.usePasskey:!1,i=e.traits?.useUuid||!1;if(o)r.push("stripe_id");if(i)r.push("uuid");if(a)r.push(...["two_factor_secret","public_key"]);let s=n.map((c)=>c.foreignKey).filter((c)=>c);return[...Object.keys(t).filter((c)=>{if(t===void 0)return!1;return t[c]?.fillable===!0}).map((c)=>_(c)),...r,...s]}async function Ei(e,n){let t=e.attributes;if(!t)t={};let r=Object.keys(t),o=[],a=Bun.file(n),i="";try{if(await a.exists())i=await a.text()}catch{i=""}let s=/rule:.*$/gm,c;c=s.exec(i);while(c!==null)o.push(c[0]),c=s.exec(i);return r.map((l,f)=>{let d=t[l],m=null,p=!1,y=!1,w=!1,h=!1;if(d)m=d||null,p=d.unique||!1,y=d.hidden||!1,w=d.fillable||!1;let T=o[f]??"";return h=(d.validation?.rule).isRequired??!1,{field:l,default:m,unique:p,hidden:y,fillable:w,required:h,fieldArray:Sn(T)}})}function Sn(e){let n=e.split("rule: schema.");if(n.length!==2)return null;if(!n[1])n[1]="";let t=n[1].replace(/,/g,"");if(!t)return null;let r=t.split("."),o=/\(([^)]+)\)/;return r.map((a)=>{let i=o.exec(a),s=i?i[1]:null;return{entity:a.replace(o,"").replace(/\(|\)/g,""),charValue:s}})[0]||null}function Fi(e){let n=e.fieldArray?.entity;switch(n){case"enum":return"string | string[]";case"date":return"Date | string";case"timestamp":return"Date | string";case"datetime":return"Date | string";case"float":return"number";case"double":return"number";case"decimal":return"number";case"integer":return"number";case"bigint":return"number";default:return n}}function xe(e){let n=C.join(C.storagePath("framework/defaults/app/Models"),"/"),t=C.join(n,e);if(B.existsSync(t))return t;return Me(`${n}**/${e}`,{absolute:!0})[0]??""}function Ae(e){let n=C.join(C.userModelsPath("/"),"/"),t=C.join(n,e);if(B.existsSync(t))return t;return Me(`${n}**/${e}`,{absolute:!0})[0]??""}function $i(e){let n=typeof e==="number"?new Date(e):typeof e==="string"?new Date(e):e;if(Number.isNaN(n.getTime()))throw Error(`Invalid date value: ${String(e)}`);return n.toISOString().replace("T"," ").split(".")[0]??""}function Ni(e){return e.toISOString().split("T")[0]??""}function ji(e){return e.getTime()}import{createModel as Dn,registerModel as En}from"@stacksjs/query-builder";import{log as k}from"@stacksjs/logging";import{snakeCase as O}from"@stacksjs/strings";import{AsyncLocalStorage as Rt}from"async_hooks";function Pn(e){if(e===null||typeof e!=="object")return!1;let n=e;return Array.isArray(n.data)&&typeof n.current_page==="number"&&typeof n.per_page==="number"&&typeof n.total==="number"&&typeof n.last_page==="number"}function xn(e){if(e===null||typeof e!=="object")return!1;let n=e;return Array.isArray(n.data)&&typeof n.current_page==="number"&&typeof n.per_page==="number"&&typeof n.has_more_pages==="boolean"&&!("total"in n)}function An(e){if(e===null||typeof e!=="object")return!1;let n=e;return Array.isArray(n.data)&&(typeof n.next_cursor==="string"||n.next_cursor===null)}function Ce(e){let{data:n}=e,{perPage:t,page:r,total:o,lastPage:a}=e.meta,i=n.length===0,s=i?null:(r-1)*t+1,c=i?null:s+n.length-1;return{data:n,current_page:r,per_page:t,total:o,last_page:a,from:s,to:c,has_more_pages:r<a}}function Oe(e){return{data:e.data,current_page:e.meta.page,per_page:e.meta.perPage,has_more_pages:e.meta.hasMore}}function ve(e){return{data:e.data,per_page:e.meta.perPage,next_cursor:ct(e.meta.nextCursor),prev_cursor:ct(e.meta.prevCursor),has_more_pages:e.meta.nextCursor!==null&&e.meta.nextCursor!==void 0}}function ct(e){if(e===null||e===void 0)return null;if(typeof e==="string")return e;return JSON.stringify(e)}function Ee(e,n){let t=Ne(),r=t?De(t,"per_page"):void 0,o=t?De(t,"page"):void 0,a=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,r??15)),i=Math.max(1,Math.floor(n??o??1));return{perPage:a,page:i}}function Fe(e,n){let t=Ne(),r=t?dt(t,"cursor"):void 0,o=t?De(t,"per_page"):void 0,a=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,o??15)),s=lt(n!==void 0?n:r??null);return{perPage:a,cursor:s}}function lt(e){if(e===null||e===void 0)return null;if(Array.isArray(e))return e;if(typeof e==="string"&&e.startsWith("["))try{let n=JSON.parse(e);if(Array.isArray(n))return n}catch{}return e}function $e(e){let n=Ne();if(!n)return e;let t=(()=>{try{return new URL(n.url)}catch{return null}})();if(!t)return e;let r=t.pathname;if(e.path=r,"next_cursor"in e)return e.next_page_url=e.next_cursor!==null?F(t,{cursor:e.next_cursor}):null,e.prev_page_url=e.prev_cursor!==null?F(t,{cursor:e.prev_cursor}):null,e;let o=e.current_page;if(e.prev_page_url=o>1?F(t,{page:o-1}):null,"total"in e){let a=e.last_page;e.next_page_url=o<a?F(t,{page:o+1}):null,e.first_page_url=F(t,{page:1}),e.last_page_url=F(t,{page:a})}else e.next_page_url=e.has_more_pages?F(t,{page:o+1}):null;return e}function F(e,n){let t=new URL(e.toString());for(let[r,o]of Object.entries(n))t.searchParams.set(r,String(o));return`${t.pathname}${t.search}`}var I;function Ne(){if(I===null)return;if(I===void 0)try{let n=b("@stacksjs/router");if(typeof n.getCurrentRequest==="function")I=n.getCurrentRequest;else{I=null;return}}catch{I=null;return}return I()}function De(e,n){let t=dt(e,n);if(t===void 0)return;let r=Number(t);return Number.isFinite(r)?r:void 0}function dt(e,n){let t=e.query?.[n];if(t===void 0)return;return Array.isArray(t)?t[0]:t}import{db as Mn}from"@stacksjs/database";function ft(e){let n=Mn;return{async createStripeUser(t,r){let{manageCustomer:o}=await import("@stacksjs/payments");return await o.createStripeCustomer(t,r)},async updateStripeUser(t,r){let{manageCustomer:o}=await import("@stacksjs/payments");return await o.updateStripeCustomer(t,r)},async deleteStripeUser(t){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.deleteStripeUser(t)},async createOrGetStripeUser(t,r){let{manageCustomer:o}=await import("@stacksjs/payments");return await o.createOrGetStripeUser(t,r)},async retrieveStripeUser(t){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.retrieveStripeUser(t)},async defaultPaymentMethod(t){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.retrieveDefaultPaymentMethod(t)},async setDefaultPaymentMethod(t,r){let{managePaymentMethod:o}=await import("@stacksjs/payments");return await o.setDefaultPaymentMethod(t,r)},async addPaymentMethod(t,r){let{managePaymentMethod:o}=await import("@stacksjs/payments");return await o.addPaymentMethod(t,r)},async paymentMethods(t,r){let{managePaymentMethod:o}=await import("@stacksjs/payments");return await o.listPaymentMethods(t,r)},async newSubscription(t,r,o,a={}){let{manageSubscription:i}=await import("@stacksjs/payments"),s=await i.create(t,r,o,a),u=s.latest_invoice?.payment_intent;return{subscription:s,paymentIntent:u}},async updateSubscription(t,r,o,a={}){let{manageSubscription:i}=await import("@stacksjs/payments"),s=await i.update(t,r,o,a),u=s.latest_invoice?.payment_intent;return{subscription:s,paymentIntent:u}},async cancelSubscription(t,r,o={}){let{manageSubscription:a}=await import("@stacksjs/payments");return{subscription:await a.cancel(r,o)}},async activeSubscription(t){let{manageSubscription:r}=await import("@stacksjs/payments"),o=await n.selectFrom("subscriptions").where("user_id","=",t.id).where("provider_status","=","active").selectAll().executeTakeFirst();if(o){let a=await r.retrieve(t,o.provider_id||"");return{subscription:o,providerSubscription:a}}return},async checkout(t,r,o={}){let{manageCheckout:a,manageCustomer:i}=await import("@stacksjs/payments"),s={};if(o.enableTax)s.automatic_tax={enabled:!0},delete o.enableTax;if(o.allowPromotions)s.allow_promotion_codes=!0,delete o.allowPromotions;let l={...{mode:"payment",customer:(await i.createOrGetStripeUser(t,{})).id,line_items:r.map((f)=>({price:f.priceId,quantity:f.quantity||1}))},...s,...o};return await a.create(t,l)},async createSetupIntent(t,r={}){let{manageSetupIntent:o}=await import("@stacksjs/payments");return await o.create(t,r)},async subscriptionHistory(t){let{manageInvoice:r}=await import("@stacksjs/payments");return await r.list(t)},async transactionHistory(t){let{manageTransaction:r}=await import("@stacksjs/payments");return await r.list(t)},async connectAccount(t,r={}){let o=r.accountColumn||"stripe_account_id",a=(t._attributes??t)[o];if(!a)return null;let i=await H();try{return await i.accounts.retrieve(a)}catch{return null}},async createConnectAccount(t,r={}){let o=r.accountColumn||"stripe_account_id",a=t._attributes??t,i=a[o],s=await H();if(!i){let{stacksIdempotencyKey:c}=await import("@stacksjs/payments"),u=r.modelTable||e,l=await s.accounts.create({type:r.type??"express",email:r.email??a.email,country:r.country??"US",capabilities:r.capabilities??{card_payments:{requested:!0},transfers:{requested:!0}}},{idempotencyKey:c("connect.account.create",u,a.id)});return i=l.id,await n.updateTable(u).set({[o]:i}).where("id","=",Number(a.id)).execute(),l}return await s.accounts.retrieve(i)},async connectOnboardLink(t,r){let o=r.accountColumn||"stripe_account_id",i=(t._attributes??t)[o];if(!i)throw Error("connectOnboardLink: model has no Stripe Connect account; call createConnectAccount first");return{url:(await(await H()).accountLinks.create({account:i,refresh_url:r.refreshUrl,return_url:r.returnUrl,type:r.type??"account_onboarding"})).url,accountId:i}},async syncConnectStatus(t,r={}){let o=r.accountColumn||"stripe_account_id",a=r.chargesColumn||"charges_enabled",i=r.payoutsColumn||"payouts_enabled",s=t._attributes??t,c=s[o];if(!c)return{chargesEnabled:!1,payoutsEnabled:!1};let l=await(await H()).accounts.retrieve(c),f=!!l.charges_enabled,d=!!l.payouts_enabled,m=r.modelTable||e;return await n.updateTable(m).set({[a]:f,[i]:d}).where("id","=",Number(s.id)).execute(),{chargesEnabled:f,payoutsEnabled:d}},async chargeWithSplit(t,r){let o=await H(),a=r.accountColumn||"stripe_account_id",i=t._attributes??t,s=r.connectAccountId||i[a],c={amount:r.amountCents,currency:r.currency||"usd",automatic_payment_methods:{enabled:!0},metadata:r.metadata};if(s){if(c.transfer_data={destination:s},r.platformFeeCents)c.application_fee_amount=r.platformFeeCents}let{freshIdempotencyKey:u}=await import("@stacksjs/payments");return await o.paymentIntents.create(c,{idempotencyKey:u("payment_intent.create",i.id,r.amountCents)})}}}async function H(){let e=globalThis.process?.env?.STRIPE_SECRET_KEY;if(!e)throw Error("Stripe Connect: STRIPE_SECRET_KEY not configured");return new(await import("stripe")).default(e,{apiVersion:"2026-06-24.dahlia"})}function pt(){return{async generateTwoFactorForModel(e){let{generateTwoFactorSecret:n}=await import("@stacksjs/auth"),t=n();await e.update({two_factor_secret:t})},async verifyTwoFactorCode(e,n){let t=e.get("two_factor_secret");if(typeof t!=="string")return!1;let{verifyTwoFactorCode:r,RateLimiter:o}=await import("@stacksjs/auth"),a=String(e.id??e.get?.("id")??e.get?.("email")??t),i=`2fa:${a}`;if(await o.isRateLimited(i)){let{HttpError:c}=await import("@stacksjs/error-handling");throw new c(429,"Too many verification attempts. Please try again later.")}if(!await r(n,t))return await o.recordFailedAttempt(i),!1;try{let{cache:c}=await import("@stacksjs/cache"),u=`2fa:used:${a}:${n}`;if(await c.has(u))return await o.recordFailedAttempt(i),!1;await c.set(u,"1",90)}catch{}return await o.resetAttempts(i),!0}}}import{sqlDateTime as Cn}from"@stacksjs/database";import{log as K}from"@stacksjs/logging";var ie="deleted_at";function mt(e,n="id"){return{async softDelete(t){let r=Cn(),o=e.where(n,t);if(typeof o?.update==="function")return await o.update({[ie]:r}),!0;return!1},async restore(t){let r=e.where(n,t);if(typeof r?.update==="function")return await r.update({[ie]:null}),!0;return!1},async forceDelete(t){let r=e.where(n,t);if(typeof r?.delete==="function")return await r.delete(),!0;return!1},withTrashed(){return typeof e.query==="function"?e.query():e},onlyTrashed(){let t=typeof e.query==="function"?e.query():e;if(typeof t?.whereNotNull==="function")return t.whereNotNull(ie);return t?.where?.(ie,"!=",null)??t}}}function gt(e){if(e===!0||e==null)return{};if(typeof e==="object"&&!Array.isArray(e)){let n=e;if(Array.isArray(n.cascade)){let t=n.cascade.filter((r)=>typeof r==="string");return t.length?{cascade:t}:{}}return{}}return{}}function On(e,n){let t=e.hasMany??[],r=e.hasOne??[],o=t.some((l)=>je(l,n,!0)),a=r.some((l)=>je(l,n,!1));if(!o&&!a)return K.warn(`[orm] soft-delete cascade: '${n}' is not a declared hasMany/hasOne relation - skipping`),null;let s=(o?t:r).find((l)=>je(l,n,o))??null;if(!s)return null;let u=globalThis[s];if(!u)return K.warn(`[orm] soft-delete cascade: model '${s}' is not yet on globalThis - skipping cascade for '${n}'`),null;return{className:s,model:u}}function je(e,n,t){let r=e.toLowerCase();if(n===r)return!0;if(t&&n===`${r}s`)return!0;if(t&&r.endsWith("y")&&n===`${r.slice(0,-1)}ies`)return!0;return!1}async function vn(e,n,t,r,o){try{let a=t.where;if(typeof a!=="function"){K.warn(`[orm] cascade ${o}: child model has no .where()`);return}if(o==="softDelete"){let i=t.softDelete;if(typeof i==="function"){let c=a.call(t,r,n),u=typeof c?.get==="function"?await c.get():Array.isArray(c)?c:[],l=t.primaryKey||"id";for(let f of u){let d=f?.[l];if(d!=null)await i.call(t,d)}return}let s=a.call(t,r,n);if(typeof s?.delete==="function"){K.debug(`[orm] cascade soft-delete: child has no softDeletes trait, hard-deleting from ${String(t.table??"?")}`),await s.delete();return}}else{let i=t.restore;if(typeof i!=="function"){K.debug("[orm] cascade restore: child has no restore() - nothing to do");return}let s=t.withTrashed,u=(typeof s==="function"?s.call(t):t).where?.(r,n),l=typeof u?.get==="function"?await u.get():[],f=t.primaryKey||"id";for(let d of l){let m=d?.[f];if(m!=null)await i.call(t,m)}}}catch(a){if(K.warn(`[orm] soft-delete cascade ${o} on ${e}#${String(n)} failed`,{error:a}),process.env.STACKS_ORM_CASCADE_SWALLOW!=="true")throw a}}async function G(e,n,t,r){let o=n.cascade;if(!o||o.length===0)return;let a=`${e.name.toLowerCase()}_id`;for(let i of o){let s=On(e,i);if(!s)continue;await vn(s.className,t,s.model,a,r)}}var St=new Rt;function j(){return St.getStore()?.suppressed===!0}function N(e){return Promise.resolve(St.run({suppressed:!0},e))}var Pt=new Rt;function Fn(){return Pt.getStore()?.suppressed===!0}function $n(e){return Promise.resolve(Pt.run({suppressed:!0},e))}var Ue=Symbol.for("stacks.orm.modelDefinition");class xt extends Error{status=422;errors;constructor(e,n){let t=Object.keys(n).join(", ");super(`${e} validation failed: ${t}`);this.name="ModelValidationError",this.errors=n}}var yt=new Set;function Nn(e,n){let t=typeof e==="string"?e.slice(0,80):String(e),r=`${typeof e}:${t}`;if(yt.has(r))return;yt.add(r);let o=n instanceof Error?n.message:String(n);console.error(`[orm] JSON cast failed to parse value (returning null): ${o} - value preview: ${JSON.stringify(t)}`)}var jn={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>{if(e==null)return null;if(typeof e==="string")try{return JSON.parse(e)}catch(n){return Nn(e,n),null}return e},set:(e)=>{if(e==null)return null;return typeof e==="string"?e:JSON.stringify(e)}},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>{if(e==null)return[];if(Array.isArray(e))return e;if(typeof e==="string")try{return JSON.parse(e)}catch{return[]}return[]},set:(e)=>{if(e==null)return null;return Array.isArray(e)?JSON.stringify(e):e}}};function At(e){return typeof e==="string"?jn[e]:e}function bt(e,n,t){if(!e||typeof e!=="object")return e;let r={...e};for(let[o,a]of Object.entries(n))if(o in r){let i=At(a);r[o]=i[t](r[o])}return r}var se=new Set(["_attributes","_original","_definition","_hasSaved","_relations"]),wt=Symbol.for("stacks.modelInstanceProxy"),Bn={tags:{bag:"_taggable",mode:"id"},tagCount:{bag:"_taggable",mode:"id"},addTag:{bag:"_taggable",mode:"id"},activeTags:{bag:"_taggable",mode:"id"},inactiveTags:{bag:"_taggable",mode:"id"},removeTag:{bag:"_taggable",mode:"id"},categories:{bag:"_categorizable",mode:"id"},categoryCount:{bag:"_categorizable",mode:"id"},addCategory:{bag:"_categorizable",mode:"id"},activeCategories:{bag:"_categorizable",mode:"id"},inactiveCategories:{bag:"_categorizable",mode:"id"},removeCategory:{bag:"_categorizable",mode:"id"},comments:{bag:"_commentable",mode:"id"},commentCount:{bag:"_commentable",mode:"id"},addComment:{bag:"_commentable",mode:"id"},approvedComments:{bag:"_commentable",mode:"id"},pendingComments:{bag:"_commentable",mode:"id"},rejectedComments:{bag:"_commentable",mode:"id"},likes:{bag:"_likeable",mode:"id"},likeCount:{bag:"_likeable",mode:"id"},like:{bag:"_likeable",mode:"id"},unlike:{bag:"_likeable",mode:"id"},isLiked:{bag:"_likeable",mode:"id"},createStripeUser:{bag:"_billable",mode:"model"},updateStripeUser:{bag:"_billable",mode:"model"},deleteStripeUser:{bag:"_billable",mode:"model"},createOrGetStripeUser:{bag:"_billable",mode:"model"},retrieveStripeUser:{bag:"_billable",mode:"model"},defaultPaymentMethod:{bag:"_billable",mode:"model"},setDefaultPaymentMethod:{bag:"_billable",mode:"model"},addPaymentMethod:{bag:"_billable",mode:"model"},paymentMethods:{bag:"_billable",mode:"model"},newSubscription:{bag:"_billable",mode:"model"},updateSubscription:{bag:"_billable",mode:"model"},cancelSubscription:{bag:"_billable",mode:"model"},activeSubscription:{bag:"_billable",mode:"model"},checkout:{bag:"_billable",mode:"model"},createSetupIntent:{bag:"_billable",mode:"model"},subscriptionHistory:{bag:"_billable",mode:"model"},transactionHistory:{bag:"_billable",mode:"model"},connectAccount:{bag:"_billable",mode:"model"},createConnectAccount:{bag:"_billable",mode:"model"},connectOnboardLink:{bag:"_billable",mode:"model"},syncConnectStatus:{bag:"_billable",mode:"model"},chargeWithSplit:{bag:"_billable",mode:"model"},generateTwoFactorForModel:{bag:"_twoFactor",mode:"model"},verifyTwoFactorCode:{bag:"_twoFactor",mode:"model"}};function In(e,n){if(!e||!n)return null;let t=n.split("."),r=e;for(let o of t){if(r==null||typeof r!=="object")return null;let a=r;if("_attributes"in a&&a._attributes&&typeof a._attributes==="object"){let i=a._attributes;if(o in i){r=i[o];continue}}if(o in a){r=a[o];continue}return null}return r??null}function P(e,n){if(!e||typeof e!=="object")return e;let t=e;if(t[wt])return e;let r=t._attributes;if(!r||typeof r!=="object")return e;if(n&&Object.keys(n).length>0){for(let[o,a]of Object.entries(n))if(Object.prototype.hasOwnProperty.call(r,o))r[o]=At(a).get(r[o])}return new Proxy(e,{get(o,a,i){let s=o;if(a===wt)return!0;if(a==="saveAsync")return async function(){let u=s._definition,l=u?.set;if(l&&typeof s.isDirty==="function"){for(let[d,m]of Object.entries(l)){if(typeof m!=="function")continue;if(!s.isDirty(d))continue;let p=m(s._attributes),y=p&&typeof p.then==="function"?await p:p;s._attributes[d]=y}let f=u.set;u.set={};try{return s.save()}finally{u.set=f}}return s.save()};if(a==="save")return function(){let u=s._definition,l=u?.set;if(l&&Object.keys(l).length>0&&typeof s.isDirty==="function"){for(let[d,m]of Object.entries(l)){if(typeof m!=="function")continue;if(!s.isDirty(d))continue;let p=m(s._attributes);if(p&&typeof p.then==="function")throw Error(`Setter for "${d}" returned a Promise - use \`saveAsync()\` instead of \`save()\` when a model has async setters.`);s._attributes[d]=p}let f=u.set;u.set={};try{return s.save()}finally{u.set=f}}return s.save()};if(a==="updateAsync")return async function(u){if(u&&typeof u==="object"&&!Array.isArray(u))for(let[l,f]of Object.entries(u))i[l]=f;return i.saveAsync()};if(a==="saveQuietly")return function(){return N(()=>s.save())};if(a==="saveAsyncQuietly")return function(){return N(()=>i.saveAsync())};if(a==="updateQuietly")return function(u){return N(()=>s.update(u))};if(a==="updateAsyncQuietly")return function(u){return N(()=>i.updateAsync(u))};if(a==="deleteQuietly")return function(){return N(()=>s.delete())};if(a==="toSearchableObject")return function(){let f=s._definition?.traits?.useSearch;if(!f)return null;let d=s._attributes;if(!d)return null;if(f===!0){let h={...d};if(d.id!=null)h.id=String(d.id);return h}let m={},p=f.displayable?.length?f.displayable:[...f.searchable??[],...f.filterable??[],...f.sortable??[],"id"],y=f.denormalize??{},w=s._relations;for(let h of p){let T=O(h),S=d[T]??d[h];if(S!==void 0){m[T]=S;continue}let A=y[h]??y[T];if(A){m[T]=In(w,A);continue}m[T]=void 0}if(d.id!=null)m.id=String(d.id);return m};if(typeof a==="string"&&!se.has(a)){let u=s._attributes;if(u&&Object.prototype.hasOwnProperty.call(u,a))return u[a];let l=s._relations;if(l&&Object.prototype.hasOwnProperty.call(l,a)){let d=l[a];if(Array.isArray(d))return d.map((m)=>P(m,n));return d&&typeof d==="object"?P(d,n):d}let f=Bn[a];if(f){let p=s._definition?.__traitMethods?.[f.bag]?.[a];if(typeof p==="function")return f.mode==="model"?(...y)=>p(i,...y):(...y)=>p(s.id,...y)}if(u){let d=O(a);if(d!==a&&Object.prototype.hasOwnProperty.call(u,d))return u[d]}}let c=Reflect.get(s,a,s);return typeof c==="function"?c.bind(s):c},set(o,a,i,s){let c=o;if(typeof a==="string"&&!se.has(a)){let{_attributes:u,set:l}=c;if(u&&Object.prototype.hasOwnProperty.call(u,a)){if(typeof l==="function")l.call(c,a,i);else u[a]=i;return!0}if(u){let f=O(a);if(f!==a&&Object.prototype.hasOwnProperty.call(u,f)){if(typeof l==="function")l.call(c,f,i);else u[f]=i;return!0}}if(u&&!(a in c)){if(typeof l==="function")l.call(c,a,i);else u[a]=i;return!0}}return Reflect.set(c,a,i,s)},has(o,a){let i=o;if(typeof a==="string"&&!se.has(a)){let s=i._attributes;if(s&&Object.prototype.hasOwnProperty.call(s,a))return!0;let c=i._relations;if(c&&Object.prototype.hasOwnProperty.call(c,a))return!0;if(s){let u=O(a);if(u!==a&&Object.prototype.hasOwnProperty.call(s,u))return!0}}return Reflect.has(i,a)},deleteProperty(o,a){let i=o;if(typeof a==="string"&&!se.has(a)){let s=i._attributes;if(s&&Object.prototype.hasOwnProperty.call(s,a))return delete s[a],!0}return Reflect.deleteProperty(i,a)},ownKeys(o){let i=o._attributes;return i?Object.keys(i):[]},getOwnPropertyDescriptor(o,a){let i=o;if(typeof a==="string"){let s=i._attributes;if(s&&Object.prototype.hasOwnProperty.call(s,a))return{configurable:!0,enumerable:!0,value:s[a],writable:!0}}return Object.getOwnPropertyDescriptor(i,a)}})}var Kn=new Set(["get","first","last","firstOrFail","find","findOrFail","all","paginate","simplePaginate","cursorPaginate"]),qn={paginate:Ce,simplePaginate:Oe,cursorPaginate:ve},ht=Symbol.for("stacks.queryBuilderProxy");function Mt(e,n){if(!e||typeof e!=="object")return e;if(e[ht])return e;return new Proxy(e,{get(t,r,o){if(r===ht)return!0;let a=Reflect.get(t,r,o);if(typeof a!=="function")return a;return function(...i){let s=i,c=String(r);if(c==="paginate"||c==="simplePaginate"){let{perPage:f,page:d}=Ee(i[0],i[1]);s=[f,d]}else if(c==="cursorPaginate"){let{perPage:f,cursor:d}=Fe(i[0],i[1]);s=[f,d,i[2],i[3]]}let u=a.apply(t,s),l=(f)=>{if(Kn.has(c)){if(Array.isArray(f))return f.map((m)=>P(m,n));let d=qn[c];if(d&&f&&Array.isArray(f.data)){let m=f.data.map((y)=>P(y,n)),p=d({...f,data:m});return $e(p)}if(f&&Array.isArray(f.data))return{...f,data:f.data.map((m)=>P(m,n))};return P(f,n)}if(f&&typeof f==="object"&&typeof f.get==="function")return Mt(f,n);return f};if(u&&typeof u.then==="function")return u.then(l);return l(u)}}})}function Un(e,n){let t=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let a of t){let i=e[a];if(typeof i!=="function")continue;e[a]=function(...s){let c=i.apply(this,s),u=(l)=>Array.isArray(l)?l.map((f)=>P(f,n)):P(l,n);if(c&&typeof c.then==="function")return c.then(u);return u(c)}}let r=["create","firstOrCreate","updateOrCreate","make"];for(let a of r){let i=e[a];if(typeof i!=="function")continue;e[a]=function(...s){let c=i.apply(this,s),u=(l)=>Array.isArray(l)?l.map((f)=>P(f,n)):P(l,n);if(c&&typeof c.then==="function")return c.then(u);return u(c)}}let o=["query","where","orWhere","whereIn","whereNotIn","whereNull","whereNotNull","whereLike","whereBetween","whereNotBetween","orderBy","orderByDesc","select","with","limit","take","skip","latest","oldest"];for(let a of o){let i=e[a];if(typeof i!=="function")continue;e[a]=function(...s){let c=i.apply(this,s);return Mt(c,n)}}}class Ct extends Error{model;id;constructor(e,n){super(n!=null?`[ORM] ${e} not found for id=${String(n)}`:`[ORM] No matching ${e} row`);this.name="ModelNotFoundError",this.model=e,this.id=n}}class Ie extends Error{model;attribute;reason;constructor(e,n,t){let r=t==="guarded"?`'${n}' is marked guarded`:`'${n}' is not in the fillable allowlist`;super(`[ORM] Mass assignment to ${e} forbidden: ${r}. Use ${e}.forceCreate(...) / .forceUpdate(...) to bypass.`);this.name="MassAssignmentException",this.model=e,this.attribute=n,this.reason=t}}var Ln=new Set(["id","created_at","updated_at","deleted_at","uuid"]);function J(e,n,t={}){if(t.force)return n;if(!n||typeof n!=="object"||Array.isArray(n))return n;let r=e.attributes;if(!r)return n;let o=new Set,a=new Set,i=new Set;for(let[c,u]of Object.entries(r)){let l=O(c);if(o.add(l),u?.fillable===!0)a.add(l);if(u?.guarded===!0)i.add(l)}let s=a.size>0?a:o;for(let c of Object.keys(n)){let u=O(c);if(Ln.has(u))continue;if(i.has(u))throw new Ie(e.name,c,"guarded");if(u.endsWith("_id"))continue;if(!s.has(u))throw new Ie(e.name,c,"not-fillable")}return n}async function Ke(e,n){let t=e.set;if(!t||typeof t!=="object")return n;let r={...n};for(let[o,a]of Object.entries(t)){if(typeof a!=="function"||!(o in r))continue;try{r[o]=await a(r)}catch(i){k.error(`[orm] ${e.name}.set.${o} threw - skipping setter`,i)}}return r}function Qn(e,n){let t=n.primaryKey||"id",r=e.create;function o(u){let l=e.where;if(typeof l!=="function")throw Error(`[ORM] ${n.name}.${u} needs a working where(): the underlying query builder did not expose one`);return l}function a(u){let l=e.find;if(typeof l!=="function")throw Error(`[ORM] ${n.name}.${u} needs a working find(): the underlying query builder did not expose one`);return l}function i(u){let l=e.create;if(typeof l!=="function")throw Error(`[ORM] ${n.name}.${u} cannot create: the underlying query builder did not expose create()`);return l}if(typeof e.update!=="function")e.update=async function(u,l){if(u==null)throw Error(`[ORM] ${n.name}.update requires an id as the first argument`);if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${n.name}.update requires a data object as the second argument`);if(Object.keys(l).length===0){k.debug(`[orm] ${n.name}.update called with empty data - short-circuiting and returning current row`);let m=e.find;return typeof m==="function"?await m.call(e,u):null}J(n,l);let f=await Ke(n,l);await o("update").call(e,t,u).update(f);let d=e.find;return typeof d==="function"?await d.call(e,u):null};if(typeof e.forceUpdate!=="function")e.forceUpdate=async function(u,l){if(u==null)throw Error(`[ORM] ${n.name}.forceUpdate requires an id as the first argument`);if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${n.name}.forceUpdate requires a data object as the second argument`);let f=await Ke(n,l);await o("forceUpdate").call(e,t,u).update(f);let d=e.find;return typeof d==="function"?await d.call(e,u):null};if(typeof e.forceCreate!=="function")e.forceCreate=async function(u){if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${n.name}.forceCreate requires a data object`);let l=e.make;if(typeof l==="function"){let f=await l.call(e);if(f&&typeof f.forceFill==="function"&&typeof f.save==="function")return f.forceFill(u),await f.save()??f}if(typeof r!=="function")throw Error(`[ORM] ${n.name}.forceCreate cannot create: the underlying query builder did not expose create()`);return await r.call(e,u)};if(typeof e.delete!=="function")e.delete=async function(u){if(u==null)throw Error(`[ORM] ${n.name}.delete requires an id as the first argument`);if(!await a("delete").call(e,u))return!1;return await o("delete").call(e,t,u).delete(),!0};if(typeof e.findOrFail!=="function")e.findOrFail=async function(u){let l=await a("findOrFail").call(e,u);if(l==null)throw new Ct(n.name,u);return l};if(typeof e.exists!=="function")e.exists=async function(u){if(u==null)return!1;let l=o("exists").call(e,t,u);if(typeof l.count==="function"){let d=await l.count();return Number(d)>0}let f=e.find;return typeof f==="function"?await f.call(e,u)!=null:!1};if(typeof e.firstOrCreate!=="function")e.firstOrCreate=async function(u,l={}){if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${n.name}.firstOrCreate requires a where-attrs object`);let f=o("firstOrCreate").call(e,u),d=typeof f.first==="function"?await f.first():await f;if(d)return d;let m={...u,...l};return J(n,m),await i("firstOrCreate").call(e,m)};if(typeof e.updateOrCreate!=="function")e.updateOrCreate=async function(u,l){if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${n.name}.updateOrCreate requires a where-attrs object`);if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${n.name}.updateOrCreate requires a values object`);let f=o("updateOrCreate").call(e,u),d=typeof f.first==="function"?await f.first():await f;if(d){J(n,l);let p=d[t];await o("updateOrCreate").call(e,t,p).update(l);let y=e.find;return typeof y==="function"?await y.call(e,p):{...d,...l}}let m={...u,...l};return J(n,m),await i("updateOrCreate").call(e,m)};if(typeof e.count!=="function")e.count=async function(){let u=e;if(typeof u.query==="function"){let d=u.query();if(typeof d?.count==="function"){let m=await d.count();return Number(m)||0}}let{all:l,get:f}=e;if(typeof l==="function")return(await l.call(e)||[]).length;if(typeof f==="function")return(await f.call(e)||[]).length;return 0};if(typeof e.pluck!=="function")e.pluck=async function(u){if(!u||typeof u!=="string")throw Error(`[ORM] ${n.name}.pluck requires a column name`);let l=e.all;return((typeof l==="function"?await l.call(e):[])||[]).map((d)=>d?.[u])};if(typeof e.whereIn!=="function")e.whereIn=async function(u,l){if(!u||typeof u!=="string")throw Error(`[ORM] ${n.name}.whereIn requires a column name`);if(!Array.isArray(l))throw Error(`[ORM] ${n.name}.whereIn requires an array of values`);if(l.length===0)return[];let f=e.where;if(typeof f!=="function")return[];let d=f.call(e,u,"in",l);if(d&&typeof d.get==="function")return await d.get();return await d};let s=[["latest","desc"],["oldest","asc"]];for(let[u,l]of s)if(typeof e[u]!=="function")e[u]=async function(f="created_at"){let d=e,m=typeof d.query==="function"?d.query():d;if(typeof m?.orderBy==="function"){let h=m.orderBy(f,l);if(typeof h.first==="function")return await h.first();if(typeof h.get==="function")return(await h.get())?.[0]??null}let p=e.all;if(typeof p!=="function")return null;return[...await p.call(e)||[]].sort((h,T)=>{let S=h?.[f],A=T?.[f];if(S===A)return 0;return(S>A?1:-1)*(l==="desc"?-1:1)})[0]??null};let c=Dt(n.traits?.useSearch,n);if(c){let u=c.index??n.table??O(`${n.name}s`);if(typeof e.search!=="function")e.search=function(l,f){return Hn(e,u,l,f,c.searchable)};if(typeof e.makeAllSearchable!=="function")e.makeAllSearchable=async function(l=500){let f=e.all;if(typeof f!=="function")throw Error(`[ORM] ${n.name}.makeAllSearchable cannot run: the underlying query builder did not expose all()`);let{useSearchEngine:d}=await import("@stacksjs/search-engine"),m=d(),p=0,y=e.query;if(typeof y==="function")try{let T=y.call(e);if(T&&typeof T.chunk==="function")return await T.chunk(l,async(S)=>{let A=await qe(S,c);if(A.length>0)await m.addDocuments(u,A);p+=A.length}),p}catch{}let w=await f.call(e)||[],h=await qe(w,c);if(h.length>0)await m.addDocuments(u,h);return h.length};if(typeof e.removeAllFromSearch!=="function")e.removeAllFromSearch=async function(){let{useSearchEngine:l}=await import("@stacksjs/search-engine"),f=l();if(typeof f.deleteAllDocuments==="function"){await f.deleteAllDocuments(u);return}let d=e.all,m=typeof d==="function"?await d.call(e)||[]:[],p=l();for(let y of m){let w=y?.id??y?._attributes?.id;if(w!=null)await p.deleteDocument(u,Number(w))}}}}async function qe(e,n){if(e.length===0)return[];if(typeof n.shapeMany==="function"){let r=await n.shapeMany(e);if(!Array.isArray(r)||r.length!==e.length)throw TypeError(`[orm/search] shapeMany returned ${Array.isArray(r)?r.length:typeof r} documents for ${e.length} rows. It must return one document per row, in order, or documents are indexed under the wrong ids.`);return r.filter(Boolean)}return(await Promise.all(e.map((r)=>zn(r,n)))).filter(Boolean)}function Vn(e){let n=new Set,t=e.attributes??{};for(let[r,o]of Object.entries(t))if(o?.hidden)n.add(r);return n}function Wn(e,n){if(!e||n.size===0)return e;let t={};for(let[r,o]of Object.entries(e))if(!n.has(r))t[r]=o;return t}async function zn(e,n){if(typeof n.shape==="function")try{return await n.shape(e)}catch{return}let t=e?.toSearchableObject?.();if(t!==void 0)return t;return Wn(e?._attributes??(typeof e?.toJSON==="function"?e.toJSON():null),n.hidden??new Set)}function Hn(e,n,t,r,o){let a=o&&o.length>0?{query_by:[...o].join(",")}:{},i={q:t,...a,...r??{}},s={with(c){return i={...i,...c},s},where(c){return i={...i,filter:c},s},async get(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return(await c().search(n,i))?.hits??[]},async paginate(c,u=1){let{useSearchEngine:l}=await import("@stacksjs/search-engine"),d=await l().search(n,{...i,limit:c,offset:(u-1)*c});return{hits:d.hits??[],total:Number(d.estimatedTotalHits??d.nbHits??d.total??0),page:u,perPage:c}},async raw(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return await c().search(n,i)}};return s}function Ot(e){let n=O(e);return n===e?[e]:[e,n]}async function Be(e,n){if(!e||typeof e!=="object")return;let t=e._attributes??e;for(let r of n)for(let o of Ot(r)){if(!(o in t))continue;let a=t[o];if(!U(a))continue;t[o]=await fe(a)}}function Gn(e,n){if(n.length===0)return;let t=async(s)=>{if(Array.isArray(s)){for(let c of s)await Be(c,n);return s}if(s&&typeof s==="object"&&Array.isArray(s.data)){for(let c of s.data)await Be(c,n);return s}if(s)await Be(s,n);return s},r=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let s of r){let c=e[s];if(typeof c!=="function")continue;e[s]=async function(...u){let l=await c.apply(this,u);return await t(l)}}let o=["create","firstOrCreate","updateOrCreate","make"];for(let s of o){let c=e[s];if(typeof c!=="function")continue;e[s]=async function(...u){let l=await c.apply(this,u);return await t(l)}}for(let s of["update","forceUpdate"]){let c=e[s];if(typeof c!=="function")continue;e[s]=async function(u,l){let f=await c.call(this,u,l);return await t(f)}}let a=["first","firstOrFail","get","all","find","findOrFail","last","paginate","simplePaginate"],i=(s)=>{if(!s||typeof s!=="object")return s;let c=s;if(c.__stacksEncryptedReads)return s;for(let u of a){let l=c[u];if(typeof l!=="function")continue;c[u]=async function(...f){return await t(await l.apply(this,f))}}for(let u of["where","whereIn","whereNull","whereNotNull","orWhere","orderBy","orderByDesc","limit","offset","with"]){let l=c[u];if(typeof l!=="function")continue;c[u]=function(...f){return i(l.apply(this,f))}}return Object.defineProperty(c,"__stacksEncryptedReads",{value:!0,enumerable:!1}),s};for(let s of["where","whereIn","whereNull","whereNotNull","orderBy","orderByDesc","limit","query"]){let c=e[s];if(typeof c!=="function")continue;e[s]=function(...u){return i(c.apply(this,u))}}}function Jn(e,n){if(n.length===0)return;let t=async(o)=>{if(!o||typeof o!=="object"||Array.isArray(o))return o;let a={...o};for(let i of n)for(let s of Ot(i))if(s in a)a[s]=await de(a[s]);return a},r=["create","firstOrCreate","updateOrCreate","forceCreate"];for(let o of r){let a=e[o];if(typeof a!=="function")continue;e[o]=async function(...i){if(i[0]=await t(i[0]),i[1])i[1]=await t(i[1]);return await a.apply(this,i)}}for(let o of["update","forceUpdate"]){let a=e[o];if(typeof a!=="function")continue;e[o]=async function(i,s){let c=await t(s);return await a.call(this,i,c)}}}function Yn(e,n){let t=e.create;if(typeof t==="function")e.create=async function(r,...o){J(n,r);let a=await Ke(n,r);return await t.call(this,a,...o)};for(let r of["firstOrCreate","updateOrCreate"]){let o=e[r];if(typeof o!=="function")continue}}function Zn(e,n){let t=String(n?.name??e.name??"Model"),r=(i,s)=>{if(Fn())return;if(!i||typeof i!=="object"||Array.isArray(i))return;let c=nt(i,n,s);if(!c.valid)throw new xt(t,c.errors)},o=e.create;if(typeof o==="function")e.create=async function(i,...s){return r(i,"creating"),await o.call(this,i,...s)};let a=e.update;if(typeof a==="function")e.update=async function(i,s,...c){return r(s,"updating"),await a.call(this,i,s,...c)}}function Xn(e,n){let t=["create","firstOrCreate","updateOrCreate"];for(let o of t){let a=e[o];if(typeof a==="function")e[o]=async function(...i){if(k.debug(`[orm] ${o.charAt(0).toUpperCase()+o.slice(1)} ${String(e.name||"unknown")}`,i[0]),i[0]&&typeof i[0]==="object"&&!Array.isArray(i[0]))i[0]=bt(i[0],n,"set");return await a.apply(this,i)}}let r=e.update;if(typeof r==="function")e.update=async function(o,a){let i=a&&typeof a==="object"&&!Array.isArray(a)?bt(a,n,"set"):a;return await r.call(this,o,i)}}function vt(e){k.debug(`[orm] Defining model: ${e.name} (table: ${e.table})`);let n=er(e),t=nr(e),r=tr(n,t),o=rr(e);e.__traitMethods=o;let a=r?{...e,hooks:{...e.hooks,...r}}:e,s=Dn(a);if(Un(s,e.casts),Qn(s,a),Yn(s,a),e.casts&&Object.keys(e.casts).length>0)Xn(s,e.casts);let c=pe(e);if(c.length>0)Jn(s,c),Gn(s,c);let u=e.traits?.useSoftDeletes;if(u)or(s,a,u);let l=e.traits?.useAudit;if(l){let m=Je(l);Ye(s,e.name,e.primaryKey||"id",m)}Zn(s,a);let f=s;f.withoutValidation=function(m){return $n(m)},f.withoutEvents=function(m){return N(m)};for(let m of["create","update","firstOrCreate","updateOrCreate","forceCreate","forceUpdate","delete","forceDelete","softDelete","restore"]){let p=s[m];if(typeof p!=="function")continue;let y=`${m}Quietly`;if(typeof s[y]==="function")continue;s[y]=function(...w){return N(()=>p.apply(s,w))}}let d=Object.assign(s,o,{...e,getDefinition:()=>e,_isStacksModel:!0});return En(e.name,d),Object.defineProperty(d,Ue,{value:e,enumerable:!1,configurable:!0}),d}function er(e){let n=e.traits?.observe;if(!n)return;let t=e.name.toLowerCase(),r=(d)=>{let m=d?.attributes;if(!m||typeof m!=="object")return d;let p=e.primaryKey||"id",y={...m};if(y[p]===void 0&&d[p]!==void 0)y[p]=d[p];return y},o=async(d,m)=>{if(j())return;try{let{dispatch:p}=await import("@stacksjs/events");await p(d,m)}catch(p){if(p&&typeof p==="object"&&"code"in p&&p.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Event '${d}' handler error:`,p),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw p}},a=e.traits?.broadcastOn,i=e.traits?.broadcastWith,s=typeof a==="function"&&typeof i==="function",c=async(d,m)=>{if(!s)return;if(j())return;try{let p=a(m),y=Array.isArray(p)?p:[p],w=i(m),T=(await import("@stacksjs/realtime").catch(()=>null))?.broadcast;if(typeof T!=="function")return;for(let S of y){if(typeof S!=="string"||S.length===0)continue;await T(S,d,w)}}catch(p){if(p&&typeof p==="object"&&"code"in p&&p.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Broadcast '${d}' handler error:`,p),process.env.STACKS_ORM_BROADCAST_ERRORS==="throw")throw p}},u=async(d,m)=>{if(j())return!0;try{let{dispatchAsync:p}=await import("@stacksjs/events"),y=await p(d,m);if(Array.isArray(y)&&y.some((w)=>w===!1))return!1}catch(p){if(p&&typeof p==="object"&&"code"in p&&p.code==="MODULE_NOT_FOUND")return!0;if(console.error(`[ORM] Before-event '${d}' handler error:`,p),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw p}return!0},l=n===!0?["create","update","delete"]:Array.isArray(n)?n:[],f={};if(l.includes("create"))f.beforeCreate=async(d)=>{if(k.debug(`[orm] Create ${t}`,d),!await u(`${t}:saving`,d))throw Error(`[ORM] ${t}:saving event cancelled the operation`);if(!await u(`${t}:creating`,d))throw Error(`[ORM] ${t}:creating event cancelled the operation`)},f.afterCreate=async(d)=>{let m=r(d);await o(`${t}:created`,m),await o(`${t}:saved`,m),await c(`${t}:created`,d)};if(l.includes("update"))f.beforeUpdate=async(d)=>{if(k.debug(`[orm] Update ${t}#${d?.id??"unknown"}`,d),!await u(`${t}:saving`,d))throw Error(`[ORM] ${t}:saving event cancelled the operation`);if(!await u(`${t}:updating`,d))throw Error(`[ORM] ${t}:updating event cancelled the operation`)},f.afterUpdate=async(d)=>{let m=r(d);await o(`${t}:updated`,m),await o(`${t}:saved`,m),await c(`${t}:updated`,d)};if(l.includes("delete"))f.beforeDelete=async(d)=>{if(k.debug(`[orm] Delete ${t}#${d?.id??"unknown"}`),!await u(`${t}:deleting`,d))throw Error(`[ORM] ${t}:deleting event cancelled the operation`)},f.afterDelete=async(d)=>{await o(`${t}:deleted`,r(d)),await c(`${t}:deleted`,d)};return f}function tr(...e){let n={},t=new Set;for(let r of e){if(!r)continue;for(let o of Object.keys(r))t.add(o)}for(let r of t){let o=e.map((a)=>a?.[r]).filter((a)=>typeof a==="function");if(!o.length)continue;n[r]=async(...a)=>{for(let i of o)await i(...a)}}return Object.keys(n).length?n:void 0}function Dt(e,n){if(!e)return null;let t=e===!0?{}:typeof e==="object"?{...e}:null;if(!t)return null;if(n)t.hidden=Vn(n);return t}function nr(e){let n=Dt(e.traits?.useSearch,e);if(!n)return;let t=n,r=t.index??e.table??O(`${e.name}s`);async function o(s){if(typeof t.shapeMany==="function")try{let[l]=await qe([s],t);return l}catch(l){k.warn(`[orm/search] shapeMany() threw for ${e.name}: ${l.message}`);return}if(typeof t.shape==="function")try{return await t.shape(s)}catch(l){k.warn(`[orm/search] shape() threw for ${e.name}: ${l.message}`);return}let u=P(s).toSearchableObject?.();if(u!==void 0)return u;return s?._attributes??(typeof s?.toJSON==="function"?s.toJSON():null)}let a=async(s)=>{if(j())return;let c=await o(s);if(!c)return;if(n.queueable){try{let{Jobs:u}=await import("@stacksjs/queue");await u.dispatch("SyncSearchIndexJob",{index:r,op:"upsert",doc:c})}catch(u){k.warn(`[orm/search] queue dispatch failed for ${e.name}; falling back to inline: ${u.message}`),await _t(r,c,e.name)}return}await _t(r,c,e.name)};return{afterCreate:a,afterUpdate:a,afterDelete:async(s)=>{if(j())return;let c=s?.id??s?._attributes?.id;if(c==null)return;if(n.queueable){try{let{Jobs:u}=await import("@stacksjs/queue");await u.dispatch("SyncSearchIndexJob",{index:r,op:"delete",id:Number(c)})}catch(u){k.warn(`[orm/search] queue dispatch failed for ${e.name}#${c}; falling back to inline: ${u.message}`),await kt(r,Number(c),e.name)}return}await kt(r,Number(c),e.name)}}}var Tt=new Map;function Et(e,n){let t=Tt.get(e)??0;if(Tt.set(e,t+1),t===0)k.warn(`[orm/search] ${n}`);else if(t===9)k.warn(`[orm/search] ${e} is still failing; further identical warnings suppressed for this process.`)}async function _t(e,n,t){try{let{useSearchEngine:r}=await import("@stacksjs/search-engine");await r().addDocument(e,n)}catch(r){Et(`index:${t}`,`Failed to index ${t}: ${r.message}`)}}async function kt(e,n,t){try{let{useSearchEngine:r}=await import("@stacksjs/search-engine");await r().deleteDocument(e,n)}catch(r){Et(`remove:${t}`,`Failed to remove ${t}#${n}: ${r.message}`)}}function rr(e){let n={},t=e.table,r=e.traits;if(!r)return n;if(r.taggable)n._taggable=Te(t);if(r.categorizable)n._categorizable=_e(t);if(r.commentable)n._commentable=we(t);if(r.billable)n._billable=ft(t);if(r.likeable){let a=typeof r.likeable==="object"?r.likeable:void 0;n._likeable=ke(t,a)}let o=r.useAuth||r.authenticatable;if(typeof o==="object"&&o&&"useTwoFactor"in o&&o.useTwoFactor)n._twoFactor=pt();return n}function or(e,n,t){let r=mt(e,n.primaryKey||"id"),o=gt(t),a=n,i=n.name.toLowerCase(),s=n.traits?.observe!=null&&n.traits?.observe!==!1,c=async(m)=>{if(!s||j())return!0;try{let{dispatchAsync:p}=await import("@stacksjs/events"),y=await p(`${i}:restoring`,{id:m});if(Array.isArray(y)&&y.some((w)=>w===!1))return!1}catch(p){if(p?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Before-event '${i}:restoring' handler error:`,p)}return!0},u=async(m)=>{if(!s||j())return;try{let{dispatch:p}=await import("@stacksjs/events");await p(`${i}:restored`,{id:m})}catch(p){if(p?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Event '${i}:restored' handler error:`,p)}},l=process.env.STACKS_ORM_CASCADE_SWALLOW!=="true",f=async(m)=>{if(!o.cascade?.length||!l){let y=await r.softDelete(m);if(y&&o.cascade?.length)await G(a,o,m,"softDelete");return y}let{db:p}=await import("@stacksjs/database");return await p.transaction(async()=>{let y=await r.softDelete(m);if(y)await G(a,o,m,"softDelete");return y})},d=async(m)=>{if(!await c(m))return!1;if(!o.cascade?.length||!l){let h=await r.restore(m);if(h){if(o.cascade?.length)await G(a,o,m,"restore");await u(m)}return h}let{db:y}=await import("@stacksjs/database"),w=await y.transaction(async()=>{let h=await r.restore(m);if(h)await G(a,o,m,"restore");return h});if(w)await u(m);return w};e.softDelete=f,e.restore=d,e.forceDelete=r.forceDelete,e.withTrashed=r.withTrashed,e.onlyTrashed=r.onlyTrashed,e.delete=f}function ar(e){if(e==null)return e;if(Array.isArray(e))return e.map((t)=>ar(t));if(typeof e!=="object")return e;let n=e;if(typeof n.toJSON==="function")return n.toJSON();if(n._attributes&&typeof n._attributes==="object")return n._attributes;return e}var ir=["belongsTo","hasOne","hasMany","belongsToMany","morphMany","morphOne"],sr=["traits","dashboard"];function ur(e){let n=e?.[Ue];if(n&&typeof n==="object")return n;if(e&&typeof e==="object"&&"name"in e&&"attributes"in e)return e;throw TypeError("extendModel() expects a model created by defineModel(), or a model definition. Import the framework model itself rather than its table name.")}function cr(e,n){let t=Array.isArray(e)?e:[],r=Array.isArray(n)?n:[];if(!t.length&&!r.length)return;return[...new Set([...t,...r])]}function lr(e){if(!e)return 0;return Object.values(e).reduce((n,t)=>{let r=Number(t?.order);return Number.isFinite(r)&&r>n?r:n},0)}function dr(e,n){let t={...e,...n},r=e.attributes??{},o=n.attributes??{};if(n.attributes){let a=lr(r),i=Object.fromEntries(Object.entries(o).map(([s,c])=>{let u=!(s in r),l=Number.isFinite(Number(c?.order));if(u&&!l)return[s,{...c,order:++a}];return[s,c]}));t.attributes={...r,...i}}for(let a of ir){let i=cr(e[a],n[a]);if(i)t[a]=i}for(let a of sr){let i=e[a],s=n[a];if(i&&s&&typeof i==="object"&&typeof s==="object")t[a]={...i,...s}}return t}function ds(e,n){return vt(dr(ur(e),n))}import fr from"process";import{log as pr}from"@stacksjs/logging";import{path as v}from"@stacksjs/path";import{fs as Y}from"@stacksjs/storage";function mr(e){if(e)return e;let n=String(fr.env.DB_CONNECTION??"").toLowerCase();return n==="postgres"||n==="mysql"?n:"sqlite"}function ue(e){return e==="postgres"?"boolean":"number"}function D(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function gr(e,n){let t=e.default;if(typeof t==="boolean")return ue(n);if(typeof t==="number")return"number";if(typeof t==="string")return"string";return"unknown"}function yr(e){let n=e.validation;if(!n||typeof n!=="object")return null;let t=n.rule;return t&&typeof t==="object"?t:null}function br(e){if(!e||String(e.name??"")!=="enum")return null;let t=(Array.isArray(e.allowedValues)?e.allowedValues:[]).filter((r)=>typeof r==="string"||typeof r==="number").map((r)=>typeof r==="number"?String(r):JSON.stringify(r));return t.length>0?t.join(" | "):null}function wr(e,n){let t=yr(e),r=br(t);if(r!==null)return e.nullable===!0?`${r} | null`:r;let o=typeof e.type==="string"?e.type.toLowerCase():String(t?.name??"").toLowerCase(),a=(()=>{switch(o){case"string":case"text":case"longtext":case"mediumtext":case"tinytext":case"char":case"varchar":case"enum":case"uuid":case"date":case"datetime":case"timestamp":case"timestamptz":case"password":case"time":case"year":return"string";case"number":case"integer":case"int":case"tinyint":case"smallint":case"mediumint":case"float":case"double":case"decimal":case"numeric":return"number";case"bigint":return"number | bigint";case"boolean":case"bool":return ue(n);case"json":case"jsonb":return"unknown";case"binary":case"blob":case"bytea":return"Uint8Array";case"unix":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return gr(e,n)}})();return e.nullable===!0?`${a} | null`:a}function hr(e){let n={},t=e.belongsTo;if(!t)return n;let r=Array.isArray(t)?t:Object.values(t);for(let o of r){if(typeof o==="string"){n[`${D(o)}_id`]="number";continue}if(o&&typeof o==="object"){let a=o;if(typeof a.foreignKey==="string"){n[a.foreignKey]="number";continue}if(typeof a.model==="string")n[`${D(a.model)}_id`]="number"}}return n}function Tr(e,n){let[t,r]=[D(e),D(n)].sort();return`${t}_${r}`}function _r(e,n){let t=e.default,r=typeof t==="string"?"string":typeof t==="number"?"number":typeof t==="boolean"?ue(n):t instanceof Date?"string":"unknown";return e.nullable?`${r} | null`:r}function kr(e,n,t){let r=n.belongsToMany;if(!r)return[];let o=[],a=Array.isArray(r)?r:Object.values(r);for(let i of a){let s,c,u,l,f={},d=!0;if(typeof i==="string")s=i;else if(i&&typeof i==="object"&&"model"in i){let h=i;if(s=h.model,"pivotTable"in h||"firstForeignKey"in h||"secondForeignKey"in h)c=h.pivotTable,u=h.firstForeignKey,l=h.secondForeignKey;else{let T=i;c=T.table,u=T.foreignKey,l=T.relatedKey,f=T.pivot?.columns??{},d=Boolean(T.pivot?.timestamps)}}else continue;let m=c??Tr(e,s),p=u??`${D(e)}_id`,y=l??`${D(s)}_id`,w={id:"number",[p]:"number",[y]:"number"};for(let[h,T]of Object.entries(f))w[h]=_r(T,t);if(d)w.created_at="string",w.updated_at="string | null";o.push({table:m,columns:w})}return o}function Rr(e){return{email_verified_at:"string | null",password_changed_at:"string | null",two_factor_secret:"string | null",two_factor_enabled:`${ue(e)} | null`,two_factor_last_used_step:"number | null",stripe_id:"string | null"}}function Sr(e,n){let t={id:"number"},r=e.traits??{};if(r.useUuid)t.uuid="string";if((r.useTimestamps??r.timestampable)!==!1)t.created_at="string",t.updated_at="string | null";if(r.useSoftDeletes??r.softDeletable)t.deleted_at="string | null";if((e.table??"")==="users"||e.name==="User")Object.assign(t,Rr(n));return t}function Pr(e,n){let t={},r=e.attributes??{};for(let[o,a]of Object.entries(r))t[D(o)]=wr(a,n);return t}function Ft(e,n,t=2){let r=" ".repeat(t),o=" ".repeat(t+1),a=Object.entries(n).map(([s,c])=>`${o}${s}: ${c}`).join(`
3
+ `),i=/^[A-Z_a-z]\w*$/.test(e)?e:`'${e}'`;return`${r}${i}: {
4
+ ${o}// columns
5
+ ${a}
6
+ ${r}}`}var xr=`/* eslint-disable */
20
7
  // AUTO-GENERATED by \`buddy generate:db-types\` \u2014 do not edit.
21
8
  // Regenerate after adding/removing a model or changing its attributes.
22
9
  // See stacksjs/stacks#1923.
23
10
 
24
11
  declare module '@stacksjs/database' {
25
12
  interface DatabaseSchema {
26
- `,wm=` }
13
+ `,Ar=` }
27
14
  }
28
15
 
29
16
  export {}
30
- `,Tm="/* eslint-disable */\n// AUTO-GENERATED by `buddy generate:db-types --framework` \u2014 do not edit.\n//\n// The shapes of the tables the framework itself ships, so framework code gets\n// real rows from `db.selectFrom(...)` without asserting them. An application's\n// own tables (and its overrides of these) live in `DatabaseSchema`, which takes\n// precedence - see `RowOf` in `./utils`.\n\nexport interface FrameworkSchema {\n",vm=`}
31
- `;function Kc(e){return e==="framework"?Tm:Rm}function Hc(e){return e==="framework"?vm:wm}async function Vc(e,t,n=[]){let i=[];if(!ri.existsSync(e))return i;let r=ri.readdirSync(e,{withFileTypes:!0});for(let o of r){let s=V.join(e,o.name);if(o.isDirectory()){if(t){let a=await Vc(s,!0,n);i.push(...a)}continue}if(!o.name.endsWith(".ts"))continue;if(o.name.startsWith("_")||o.name.startsWith("index"))continue;try{let a=await(V.isAbsolute(s)?import(s):import(V.resolve(s))),c=a.default||a;if(c?.name&&(c.attributes||c.table))i.push({filePath:s,model:c})}catch(a){n.push({file:s,error:a.message})}}return i}async function Sm(e={}){let t=cm(e.dialect),n=e.modelsDir??V.userModelsPath(),i=e.defaultsDir??V.frameworkPath("defaults/app/Models"),r=e.outFile??V.projectPath("database/types.d.ts"),o=[],s=[];for(let[_,g]of[[n,!1],[i,!0]])try{let y=await Vc(_,g,o);s.push(...y)}catch(y){o.push({file:_,error:y.message})}let a=new Map;for(let _ of s)a.set(_.model.name??V.basename(_.filePath).replace(/\.ts$/,""),_);for(let _ of s)if(_.filePath.startsWith(n))a.set(_.model.name??V.basename(_.filePath).replace(/\.ts$/,""),_);let c=[];for(let[_,{model:g}]of a){let y=g.table??`${Q(_)}s`,R={...hm(g,t),...ym(g,t),...fm(g)};c.push({table:y,model:_,columns:R})}let l=new Map;for(let[_,{model:g}]of a)for(let y of bm(_,g,t)){if(l.has(y.table))continue;l.set(y.table,{table:y.table,model:`(${y.table} pivot)`,columns:y.columns})}c.push(...l.values()),c.sort((_,g)=>_.table.localeCompare(g.table));let u=e.target??"app",m=u==="framework"?1:2,p=c.map((_)=>Lc(_.table,_.columns,m)).join(`
32
- `),k=`${Kc(u)}${p}
33
- ${Hc(u)}`;if(!e.dryRun){let _=V.dirname(r);if(!ri.existsSync(_))ri.mkdirSync(_,{recursive:!0});ri.writeFileSync(r,k,"utf-8"),lm.success(`[generate:db-types] wrote ${c.length} table(s) to ${r}`)}return{outFile:r,tables:c,errors:o,content:k}}function xm(e,t="app"){let n=[...e].sort((i,r)=>i.table.localeCompare(r.table)).map((i)=>Lc(i.table,i.columns,t==="framework"?1:2)).join(`
34
- `);return`${Kc(t)}${n}
35
- ${Hc(t)}`}import{configureOrm as Cm}from"@stacksjs/query-builder";function jm(){try{let e=process.env.DB_DATABASE_PATH||"database/stacks.sqlite";if((process.env.DB_CONNECTION||"sqlite")==="sqlite")Cm({database:e})}catch{}}jm();async function zc(e){for(let t=0;;t++){let n=await import(e);try{return n.default}catch(i){if(t<5&&i instanceof ReferenceError&&/before initialization/.test(i.message)){await new Promise((r)=>setTimeout(r,0));continue}throw i}}}async function Oi(e,t=[""]){let{path:n}=await import("@stacksjs/path"),i=n.userModelsPath(`${e}.ts`);try{if(await Bun.file(i).exists())return await zc(i)}catch(r){console.error(`[orm] Failed to import userland model ${e} from ${i} - falling back to framework default. Reason:`,r)}for(let r of t){let o=r?`${r}/`:"",s=n.frameworkPath(`defaults/app/Models/${o}${e}.ts`);try{if(await Bun.file(s).exists())return await zc(s)}catch(a){console.error(`[orm] Failed to import framework default model ${e} from ${s} - trying next subdir. Reason:`,a)}}return null}var J={},Wc=()=>{},qj=new Promise((e)=>{Wc=e});function h(e){return new Proxy(function(){},{get(t,n){if(n==="then")return;let i=J[e];if(i==null)return;let r=i[n];return typeof r==="function"?r.bind(i):r},set(t,n,i){let r=J[e];if(r==null)return!1;return r[n]=i,!0},has(t,n){let i=J[e];return i==null?!1:(n in i)},apply(t,n,i){let r=J[e];if(r==null||typeof r!=="function")return;return r.apply(n,i)}})}var Pm=h("User"),Em=h("Job"),qm=h("FailedJob"),Om=[["Team",[""],"auth"],["TeamInvitation",[""],"auth"],["TeamMember",[""],"auth"],["SocialAccount",[""],"auth"],["Subscriber",[""],"auth"],["SubscriberEmail",[""],"auth"],["Subscription",[""],"auth"],["Post",["Content"],"cms"],["Page",["Content"],"cms"],["PageRevision",["Content"],"cms"],["Redirect",["Content"],"cms"],["Menu",["Content"],"cms"],["MenuItem",["Content"],"cms"],["Author",["Content"],"cms"],["Comment",[""],"cms"],["Tag",[""],"cms"],["Site",[""],"auth"],["SiteDomain",[""],"auth"],["MagicLinkToken",[""],"auth"],["SmsOptOut",[""],"auth"],["Form",["Forms"],"forms"],["FormField",["Forms"],"forms"],["FormSubmission",["Forms"],"forms"],["Activity",[""],"dashboard"],["Board",[""],"dashboard"],["BoardColumn",[""],"dashboard"],["Card",[""],"dashboard"],["CardComment",[""],"dashboard"],["Deployment",[""],"dashboard"],["Label",[""],"dashboard"],["Release",[""],"dashboard"],["Notification",[""],"dashboard"],["NotificationDelivery",[""],"dashboard"],["MailPreference",[""],"dashboard"],["Log",[""],"dashboard"],["Request",[""],"dashboard"],["AnalyticsEvent",[""],"dashboard"],["QueryLog",[""],"dashboard"],["Error",[""],"monitoring"],["Websocket",["realtime"],"realtime"],["Campaign",[""],"marketing"],["CampaignSend",[""],"marketing"],["EmailList",[""],"marketing"],["EmailListSubscriber",[""],"marketing"],["EmailIdempotency",[""],"marketing"],["EmailSuppression",[""],"marketing"],["EmailWebhookEvent",[""],"marketing"],["SocialPost",[""],"marketing"],["Automation",[""],"marketing"],["AutomationRun",[""],"marketing"],["CampaignVariant",[""],"marketing"],["CommunicationSuppression",[""],"marketing"],["ConsentEvent",[""],"marketing"],["SenderDomain",[""],"marketing"],["UsageEvent",[""],"marketing"],["PaymentMethod",[""],"commerce"],["PaymentProduct",[""],"commerce"],["PaymentTransaction",[""],"commerce"],["Order",["commerce"],"commerce"],["OrderIdempotency",["commerce"],"commerce"],["OrderItem",["commerce"],"commerce"],["Cart",["commerce"],"commerce"],["CartItem",["commerce"],"commerce"],["Customer",["commerce"],"commerce"],["Product",["commerce"],"commerce"],["ProductVariant",["commerce"],"commerce"],["ProductUnit",["commerce"],"commerce"],["Manufacturer",["commerce"],"commerce"],["Category",["commerce"],"commerce"],["Coupon",["commerce"],"commerce"],["GiftCard",["commerce"],"commerce"],["LicenseKey",["commerce"],"commerce"],["Review",["commerce"],"commerce"],["Receipt",["commerce"],"commerce"],["PrintDevice",["commerce"],"commerce"],["ShippingMethod",["commerce"],"commerce"],["ShippingRate",["commerce"],"commerce"],["ShippingZone",["commerce"],"commerce"],["DeliveryRoute",["commerce"],"commerce"],["DeliveryStop",["commerce"],"commerce"],["DigitalDelivery",["commerce"],"commerce"],["Courier",["commerce"],"commerce"],["CourierPing",["commerce"],"commerce"],["TaxRate",["commerce"],"commerce"],["WaitlistProduct",["commerce"],"commerce"],["WaitlistRestaurant",["commerce"],"commerce"],["Auction",["commerce"],"commerce"],["AuctionItem",["commerce"],"commerce"],["Bid",["commerce"],"commerce"],["Pledge",["commerce"],"commerce"],["LoyaltyPoint",["commerce"],"commerce"],["LoyaltyReward",["commerce"],"commerce"],["Payment",["commerce"],"commerce"],["Transaction",["commerce"],"commerce"]];queueMicrotask(async()=>{try{let{feature:e}=await import("@stacksjs/config"),t=await Oi("User");if(t)J.User=t;if(e("queue")){let n=await Oi("Job");if(n)J.Job=n;let i=await Oi("FailedJob");if(i)J.FailedJob=i}for(let[n,i,r]of Om){if(!e(r))continue;let o=await Oi(n,i);if(o)J[n]=o}}catch(e){console.error("[orm] deferred model load failed:",e)}finally{Wc()}});var Im=h("Activity"),Am=h("AnalyticsEvent"),$m=h("Automation"),Um=h("AutomationRun"),Mm=h("Auction"),Dm=h("CampaignVariant"),Fm=h("CommunicationSuppression"),Nm=h("ConsentEvent"),Gm=h("SenderDomain"),Bm=h("UsageEvent"),Lm=h("AuctionItem"),Km=h("Author"),Hm=h("Bid"),Vm=h("Board"),zm=h("BoardColumn"),Wm=h("Campaign"),Qm=h("Card"),Jm=h("CardComment"),Xm=h("Cart"),Ym=h("CartItem"),Zm=h("Category"),ep=h("Comment"),tp=h("Coupon"),np=h("Customer"),ip=h("DeliveryRoute"),rp=h("DeliveryStop"),op=h("Deployment"),sp=h("DigitalDelivery"),ap=h("Courier"),lp=h("CourierPing"),cp=h("CampaignSend"),dp=h("EmailList"),up=h("EmailListSubscriber"),mp=h("Form"),pp=h("FormField"),fp=h("FormSubmission"),_p=h("MagicLinkToken"),kp=h("Menu"),bp=h("MenuItem"),gp=h("PageRevision"),hp=h("Pledge"),yp=h("Redirect"),Rp=h("Site"),wp=h("SiteDomain"),Tp=h("SmsOptOut"),vp=h("EmailIdempotency"),Sp=h("EmailSuppression"),xp=h("EmailWebhookEvent"),Cp=h("Error"),jp=h("GiftCard"),Pp=h("Label"),Ep=h("LicenseKey"),qp=h("Log"),Op=h("LoyaltyPoint"),Ip=h("LoyaltyReward"),Ap=h("MailPreference"),$p=h("Manufacturer"),Up=h("Notification"),Mp=h("NotificationDelivery"),Dp=h("Order"),Fp=h("OrderIdempotency"),Np=h("OrderItem"),Gp=h("Page"),Bp=h("Payment"),Lp=h("PaymentMethod"),Kp=h("PaymentProduct"),Hp=h("PaymentTransaction"),Vp=h("Post"),zp=h("PrintDevice"),Wp=h("Product"),Qp=h("ProductUnit"),Jp=h("ProductVariant"),Xp=h("QueryLog"),Yp=h("Receipt"),Zp=h("Release"),ef=h("Request"),tf=h("Review"),nf=h("ShippingMethod"),rf=h("ShippingRate"),of=h("ShippingZone"),sf=h("SocialPost"),af=h("SocialAccount"),lf=h("Subscriber"),cf=h("SubscriberEmail"),df=h("Subscription"),uf=h("Tag"),mf=h("TaxRate"),pf=h("Team"),ff=h("TeamInvitation"),_f=h("TeamMember"),kf=h("Transaction"),bf=h("WaitlistProduct"),gf=h("WaitlistRestaurant"),hf=h("Websocket"),Qc={User:Pm,Job:Em,FailedJob:qm,Activity:Im,AnalyticsEvent:Am,Automation:$m,AutomationRun:Um,Auction:Mm,AuctionItem:Lm,Author:Km,Bid:Hm,Board:Vm,BoardColumn:zm,Campaign:Wm,CampaignSend:cp,CampaignVariant:Dm,Card:Qm,CardComment:Jm,Cart:Xm,CartItem:Ym,Category:Zm,Comment:ep,Coupon:tp,Customer:np,CommunicationSuppression:Fm,ConsentEvent:Nm,DeliveryRoute:ip,DeliveryStop:rp,Deployment:op,DigitalDelivery:sp,Courier:ap,CourierPing:lp,EmailList:dp,EmailListSubscriber:up,EmailIdempotency:vp,EmailSuppression:Sp,EmailWebhookEvent:xp,ErrorModel:Cp,Form:mp,FormField:pp,FormSubmission:fp,GiftCard:jp,Label:Pp,LicenseKey:Ep,Log:qp,LoyaltyPoint:Op,LoyaltyReward:Ip,MailPreference:Ap,Manufacturer:$p,Notification:Up,MagicLinkToken:_p,Menu:kp,MenuItem:bp,NotificationDelivery:Mp,Order:Dp,OrderIdempotency:Fp,OrderItem:Np,Page:Gp,PageRevision:gp,Payment:Bp,PaymentMethod:Lp,PaymentProduct:Kp,PaymentTransaction:Hp,Pledge:hp,Post:Vp,PrintDevice:zp,Product:Wp,ProductUnit:Qp,ProductVariant:Jp,QueryLog:Xp,Receipt:Yp,Release:Zp,Request:ef,Review:tf,ShippingMethod:nf,Redirect:yp,SenderDomain:Gm,ShippingRate:rf,ShippingZone:of,Site:Rp,SiteDomain:wp,SmsOptOut:Tp,SocialAccount:af,SocialPost:sf,Subscriber:lf,SubscriberEmail:cf,Subscription:df,Tag:uf,TaxRate:mf,Team:pf,TeamInvitation:ff,TeamMember:_f,Transaction:kf,UsageEvent:Bm,WaitlistProduct:bf,WaitlistRestaurant:gf,Websocket:hf},ce=globalThis;for(let[e,t]of Object.entries(Qc))if(t&&ce[e]===void 0)ce[e]=t;var Oj=Object.keys(Qc);async function yf(e){if(!e)return[];try{if(typeof e.all==="function"){let t=await e.all();return Array.isArray(t)?t:[]}if(typeof e.get==="function"){let t=await e.get();return Array.isArray(t)?t:[]}}catch{}return[]}function Rf(e,t,n=""){if(!e)return n;try{if(typeof e.get==="function"){let r=e.get(t);if(r!==void 0&&r!==null)return r}}catch{}let i=e?.[t];return i!==void 0&&i!==null?i:n}if(ce.safeAll===void 0)ce.safeAll=yf;if(ce.safeGet===void 0)ce.safeGet=Rf;export{Im as Activity,Am as AnalyticsEvent,Mm as Auction,Lm as AuctionItem,Km as Author,$m as Automation,Um as AutomationRun,Hm as Bid,Vm as Board,zm as BoardColumn,Wm as Campaign,cp as CampaignSend,Dm as CampaignVariant,Qm as Card,Jm as CardComment,Xm as Cart,Ym as CartItem,Zm as Category,ep as Comment,Fm as CommunicationSuppression,Nm as ConsentEvent,tp as Coupon,ap as Courier,lp as CourierPing,np as Customer,ip as DeliveryRoute,rp as DeliveryStop,op as Deployment,sp as DigitalDelivery,vp as EmailIdempotency,dp as EmailList,up as EmailListSubscriber,Sp as EmailSuppression,xp as EmailWebhookEvent,Cp as ErrorModel,qm as FailedJob,mp as Form,pp as FormField,fp as FormSubmission,jp as GiftCard,Em as Job,Pp as Label,Ep as LicenseKey,qp as Log,Op as LoyaltyPoint,Ip as LoyaltyReward,Na as MODEL_DEFINITION,_p as MagicLinkToken,Ap as MailPreference,$p as Manufacturer,Ma as MassAssignmentException,kp as Menu,bp as MenuItem,Dc as ModelNotFoundError,$c as ModelValidationError,Up as Notification,Mp as NotificationDelivery,Dp as Order,Fp as OrderIdempotency,Np as OrderItem,Gp as Page,gp as PageRevision,Bp as Payment,Lp as PaymentMethod,Kp as PaymentProduct,Hp as PaymentTransaction,hp as Pledge,Vp as Post,zp as PrintDevice,Wp as Product,Qp as ProductUnit,Jp as ProductVariant,Xp as QueryLog,Yp as Receipt,yp as Redirect,Zp as Release,ef as Request,tf as Review,Gm as SenderDomain,nf as ShippingMethod,rf as ShippingRate,of as ShippingZone,Rp as Site,wp as SiteDomain,Tp as SmsOptOut,af as SocialAccount,sf as SocialPost,Ed as SubqueryBuilder,lf as Subscriber,cf as SubscriberEmail,df as Subscription,uf as Tag,mf as TaxRate,pf as Team,ff as TeamInvitation,_f as TeamMember,kf as Transaction,Bm as UsageEvent,Pm as User,bf as WaitlistProduct,gf as WaitlistRestaurant,hf as Websocket,n_ as batchLoad,Sm as buildDatabaseSchema,Mi as collectEncryptedAttributes,za as createAuditMethods,Hi as createCategorizableMethods,Bi as createCommentableMethods,Vi as createLikeableMethods,Ki as createTaggableMethods,s_ as db,Ui as decryptValue,Nc as defineModel,$i as encryptValue,or as enrichPaginatorUrls,wj as extendModel,P_ as extractDate,x_ as extractFields,w_ as fetchOtherModelRelations,Rd as filterFillable,Ji as findCoreModel,Xi as findUserModel,j_ as formatDate,S_ as getFillableAttributes,v_ as getGuardedAttributes,T_ as getHiddenAttributes,ke as getModelName,Od as getPivotTableName,R_ as getPivotTables,xf as getPrunableConfig,y_ as getRelationCount,h_ as getRelationType,Id as getRelations,F as getTableName,yd as getWritableFields,g_ as hasRelations,Fd as isCursorPaginator,ue as isEncrypted,Md as isPaginator,Dd as isSimplePaginator,Za as isUniqueViolation,C_ as mapEntity,gd as mapWriteError,Sf as massPrunable,sm as mergeModelDefinition,Oj as modelGlobalNames,b_ as modelTableName,qj as ormReady,ll as parseCursor,Fa as projectDocumentsFromTrait,ed as prunable,xm as renderDatabaseTypeFile,rr as resolveCursorArgs,ir as resolvePageArgs,d_ as savepoint,ld as setAuditUser,em as toAttrs,tr as toCursorPaginator,Zi as toPaginator,er as toSimplePaginator,hd as toSnakeCaseKeys,E_ as toTimestamp,c_ as transaction,u_ as transactional,ee as withoutEvents,Eu as withoutValidation};
17
+ `,Mr="/* eslint-disable */\n// AUTO-GENERATED by `buddy generate:db-types --framework` \u2014 do not edit.\n//\n// The shapes of the tables the framework itself ships, so framework code gets\n// real rows from `db.selectFrom(...)` without asserting them. An application's\n// own tables (and its overrides of these) live in `DatabaseSchema`, which takes\n// precedence - see `RowOf` in `./utils`.\n\nexport interface FrameworkSchema {\n",Cr=`}
18
+ `;function $t(e){return e==="framework"?Mr:xr}function Nt(e){return e==="framework"?Cr:Ar}async function jt(e,n,t=[]){let r=[];if(!Y.existsSync(e))return r;let o=Y.readdirSync(e,{withFileTypes:!0});for(let a of o){let i=v.join(e,a.name);if(a.isDirectory()){if(n){let s=await jt(i,!0,t);r.push(...s)}continue}if(!a.name.endsWith(".ts"))continue;if(a.name.startsWith("_")||a.name.startsWith("index"))continue;try{let s=await(v.isAbsolute(i)?import(i):import(v.resolve(i))),c=s.default||s;if(c?.name&&(c.attributes||c.table))r.push({filePath:i,model:c})}catch(s){t.push({file:i,error:s.message})}}return r}async function Or(e={}){let n=mr(e.dialect),t=e.modelsDir??v.userModelsPath(),r=e.defaultsDir??v.frameworkPath("defaults/app/Models"),o=e.outFile??v.projectPath("database/types.d.ts"),a=[],i=[];for(let[p,y]of[[t,!1],[r,!0]])try{let w=await jt(p,y,a);i.push(...w)}catch(w){a.push({file:p,error:w.message})}let s=new Map;for(let p of i)s.set(p.model.name??v.basename(p.filePath).replace(/\.ts$/,""),p);for(let p of i)if(p.filePath.startsWith(t))s.set(p.model.name??v.basename(p.filePath).replace(/\.ts$/,""),p);let c=[];for(let[p,{model:y}]of s){let w=y.table??`${D(p)}s`,h={...Sr(y,n),...Pr(y,n),...hr(y)};c.push({table:w,model:p,columns:h})}let u=new Map;for(let[p,{model:y}]of s)for(let w of kr(p,y,n)){if(u.has(w.table))continue;u.set(w.table,{table:w.table,model:`(${w.table} pivot)`,columns:w.columns})}c.push(...u.values()),c.sort((p,y)=>p.table.localeCompare(y.table));let l=e.target??"app",f=l==="framework"?1:2,d=c.map((p)=>Ft(p.table,p.columns,f)).join(`
19
+ `),m=`${$t(l)}${d}
20
+ ${Nt(l)}`;if(!e.dryRun){let p=v.dirname(o);if(!Y.existsSync(p))Y.mkdirSync(p,{recursive:!0});Y.writeFileSync(o,m,"utf-8"),pr.success(`[generate:db-types] wrote ${c.length} table(s) to ${o}`)}return{outFile:o,tables:c,errors:a,content:m}}function vr(e,n="app"){let t=[...e].sort((r,o)=>r.table.localeCompare(o.table)).map((r)=>Ft(r.table,r.columns,n==="framework"?1:2)).join(`
21
+ `);return`${$t(n)}${t}
22
+ ${Nt(n)}`}import{configureOrm as Dr}from"@stacksjs/query-builder";function Er(){try{let e=process.env.DB_DATABASE_PATH||"database/stacks.sqlite";if((process.env.DB_CONNECTION||"sqlite")==="sqlite")Dr({database:e})}catch{}}Er();async function Bt(e){for(let n=0;;n++){let t=await import(e);try{return t.default}catch(r){if(n<5&&r instanceof ReferenceError&&/before initialization/.test(r.message)){await new Promise((o)=>setTimeout(o,0));continue}throw r}}}async function ce(e,n=[""]){let{path:t}=await import("@stacksjs/path"),r=t.userModelsPath(`${e}.ts`);try{if(await Bun.file(r).exists())return await Bt(r)}catch(o){console.error(`[orm] Failed to import userland model ${e} from ${r} - falling back to framework default. Reason:`,o)}for(let o of n){let a=o?`${o}/`:"",i=t.frameworkPath(`defaults/app/Models/${a}${e}.ts`);try{if(await Bun.file(i).exists())return await Bt(i)}catch(s){console.error(`[orm] Failed to import framework default model ${e} from ${i} - trying next subdir. Reason:`,s)}}return null}var E={},It=()=>{},Ts=new Promise((e)=>{It=e});function g(e){return new Proxy(function(){},{get(n,t){if(t==="then")return;let r=E[e];if(r==null)return;let o=r[t];return typeof o==="function"?o.bind(r):o},set(n,t,r){let o=E[e];if(o==null)return!1;return o[t]=r,!0},has(n,t){let r=E[e];return r==null?!1:(t in r)},apply(n,t,r){let o=E[e];if(o==null||typeof o!=="function")return;return o.apply(t,r)}})}var Fr=g("User"),$r=g("Job"),Nr=g("FailedJob"),jr=[["Team",[""],"auth"],["TeamInvitation",[""],"auth"],["TeamMember",[""],"auth"],["SocialAccount",[""],"auth"],["Subscriber",[""],"auth"],["SubscriberEmail",[""],"auth"],["Subscription",[""],"auth"],["Post",["Content"],"cms"],["Page",["Content"],"cms"],["PageRevision",["Content"],"cms"],["Redirect",["Content"],"cms"],["Menu",["Content"],"cms"],["MenuItem",["Content"],"cms"],["Author",["Content"],"cms"],["Comment",[""],"cms"],["Tag",[""],"cms"],["Site",[""],"auth"],["SiteDomain",[""],"auth"],["MagicLinkToken",[""],"auth"],["SmsOptOut",[""],"auth"],["Form",["Forms"],"forms"],["FormField",["Forms"],"forms"],["FormSubmission",["Forms"],"forms"],["Activity",[""],"dashboard"],["Board",[""],"dashboard"],["BoardColumn",[""],"dashboard"],["Card",[""],"dashboard"],["CardComment",[""],"dashboard"],["Deployment",[""],"dashboard"],["Label",[""],"dashboard"],["Release",[""],"dashboard"],["Notification",[""],"dashboard"],["NotificationDelivery",[""],"dashboard"],["MailPreference",[""],"dashboard"],["Log",[""],"dashboard"],["Request",[""],"dashboard"],["AnalyticsEvent",[""],"dashboard"],["QueryLog",[""],"dashboard"],["Error",[""],"monitoring"],["Websocket",["realtime"],"realtime"],["Campaign",[""],"marketing"],["CampaignSend",[""],"marketing"],["EmailList",[""],"marketing"],["EmailListSubscriber",[""],"marketing"],["EmailIdempotency",[""],"marketing"],["EmailSuppression",[""],"marketing"],["EmailWebhookEvent",[""],"marketing"],["SocialPost",[""],"marketing"],["Automation",[""],"marketing"],["AutomationRun",[""],"marketing"],["CampaignVariant",[""],"marketing"],["CommunicationSuppression",[""],"marketing"],["ConsentEvent",[""],"marketing"],["SenderDomain",[""],"marketing"],["UsageEvent",[""],"marketing"],["PaymentMethod",[""],"commerce"],["PaymentProduct",[""],"commerce"],["PaymentTransaction",[""],"commerce"],["Order",["commerce"],"commerce"],["OrderIdempotency",["commerce"],"commerce"],["OrderItem",["commerce"],"commerce"],["Cart",["commerce"],"commerce"],["CartItem",["commerce"],"commerce"],["Customer",["commerce"],"commerce"],["Product",["commerce"],"commerce"],["ProductVariant",["commerce"],"commerce"],["ProductUnit",["commerce"],"commerce"],["Manufacturer",["commerce"],"commerce"],["Category",["commerce"],"commerce"],["Coupon",["commerce"],"commerce"],["GiftCard",["commerce"],"commerce"],["LicenseKey",["commerce"],"commerce"],["Review",["commerce"],"commerce"],["Receipt",["commerce"],"commerce"],["PrintDevice",["commerce"],"commerce"],["ShippingMethod",["commerce"],"commerce"],["ShippingRate",["commerce"],"commerce"],["ShippingZone",["commerce"],"commerce"],["DeliveryRoute",["commerce"],"commerce"],["DeliveryStop",["commerce"],"commerce"],["DigitalDelivery",["commerce"],"commerce"],["Courier",["commerce"],"commerce"],["CourierPing",["commerce"],"commerce"],["TaxRate",["commerce"],"commerce"],["WaitlistProduct",["commerce"],"commerce"],["WaitlistRestaurant",["commerce"],"commerce"],["Auction",["commerce"],"commerce"],["AuctionItem",["commerce"],"commerce"],["Bid",["commerce"],"commerce"],["Pledge",["commerce"],"commerce"],["LoyaltyPoint",["commerce"],"commerce"],["LoyaltyReward",["commerce"],"commerce"],["Payment",["commerce"],"commerce"],["Transaction",["commerce"],"commerce"]];queueMicrotask(async()=>{try{let{feature:e}=await import("@stacksjs/config"),n=await ce("User");if(n)E.User=n;if(e("queue")){let t=await ce("Job");if(t)E.Job=t;let r=await ce("FailedJob");if(r)E.FailedJob=r}for(let[t,r,o]of jr){if(!e(o))continue;let a=await ce(t,r);if(a)E[t]=a}}catch(e){console.error("[orm] deferred model load failed:",e)}finally{It()}});var Br=g("Activity"),Ir=g("AnalyticsEvent"),Kr=g("Automation"),qr=g("AutomationRun"),Ur=g("Auction"),Lr=g("CampaignVariant"),Qr=g("CommunicationSuppression"),Vr=g("ConsentEvent"),Wr=g("SenderDomain"),zr=g("UsageEvent"),Hr=g("AuctionItem"),Gr=g("Author"),Jr=g("Bid"),Yr=g("Board"),Zr=g("BoardColumn"),Xr=g("Campaign"),eo=g("Card"),to=g("CardComment"),no=g("Cart"),ro=g("CartItem"),oo=g("Category"),ao=g("Comment"),io=g("Coupon"),so=g("Customer"),uo=g("DeliveryRoute"),co=g("DeliveryStop"),lo=g("Deployment"),fo=g("DigitalDelivery"),po=g("Courier"),mo=g("CourierPing"),go=g("CampaignSend"),yo=g("EmailList"),bo=g("EmailListSubscriber"),wo=g("Form"),ho=g("FormField"),To=g("FormSubmission"),_o=g("MagicLinkToken"),ko=g("Menu"),Ro=g("MenuItem"),So=g("PageRevision"),Po=g("Pledge"),xo=g("Redirect"),Ao=g("Site"),Mo=g("SiteDomain"),Co=g("SmsOptOut"),Oo=g("EmailIdempotency"),vo=g("EmailSuppression"),Do=g("EmailWebhookEvent"),Eo=g("Error"),Fo=g("GiftCard"),$o=g("Label"),No=g("LicenseKey"),jo=g("Log"),Bo=g("LoyaltyPoint"),Io=g("LoyaltyReward"),Ko=g("MailPreference"),qo=g("Manufacturer"),Uo=g("Notification"),Lo=g("NotificationDelivery"),Qo=g("Order"),Vo=g("OrderIdempotency"),Wo=g("OrderItem"),zo=g("Page"),Ho=g("Payment"),Go=g("PaymentMethod"),Jo=g("PaymentProduct"),Yo=g("PaymentTransaction"),Zo=g("Post"),Xo=g("PrintDevice"),ea=g("Product"),ta=g("ProductUnit"),na=g("ProductVariant"),ra=g("QueryLog"),oa=g("Receipt"),aa=g("Release"),ia=g("Request"),sa=g("Review"),ua=g("ShippingMethod"),ca=g("ShippingRate"),la=g("ShippingZone"),da=g("SocialPost"),fa=g("SocialAccount"),pa=g("Subscriber"),ma=g("SubscriberEmail"),ga=g("Subscription"),ya=g("Tag"),ba=g("TaxRate"),wa=g("Team"),ha=g("TeamInvitation"),Ta=g("TeamMember"),_a=g("Transaction"),ka=g("WaitlistProduct"),Ra=g("WaitlistRestaurant"),Sa=g("Websocket"),Kt={User:Fr,Job:$r,FailedJob:Nr,Activity:Br,AnalyticsEvent:Ir,Automation:Kr,AutomationRun:qr,Auction:Ur,AuctionItem:Hr,Author:Gr,Bid:Jr,Board:Yr,BoardColumn:Zr,Campaign:Xr,CampaignSend:go,CampaignVariant:Lr,Card:eo,CardComment:to,Cart:no,CartItem:ro,Category:oo,Comment:ao,Coupon:io,Customer:so,CommunicationSuppression:Qr,ConsentEvent:Vr,DeliveryRoute:uo,DeliveryStop:co,Deployment:lo,DigitalDelivery:fo,Courier:po,CourierPing:mo,EmailList:yo,EmailListSubscriber:bo,EmailIdempotency:Oo,EmailSuppression:vo,EmailWebhookEvent:Do,ErrorModel:Eo,Form:wo,FormField:ho,FormSubmission:To,GiftCard:Fo,Label:$o,LicenseKey:No,Log:jo,LoyaltyPoint:Bo,LoyaltyReward:Io,MailPreference:Ko,Manufacturer:qo,Notification:Uo,MagicLinkToken:_o,Menu:ko,MenuItem:Ro,NotificationDelivery:Lo,Order:Qo,OrderIdempotency:Vo,OrderItem:Wo,Page:zo,PageRevision:So,Payment:Ho,PaymentMethod:Go,PaymentProduct:Jo,PaymentTransaction:Yo,Pledge:Po,Post:Zo,PrintDevice:Xo,Product:ea,ProductUnit:ta,ProductVariant:na,QueryLog:ra,Receipt:oa,Release:aa,Request:ia,Review:sa,ShippingMethod:ua,Redirect:xo,SenderDomain:Wr,ShippingRate:ca,ShippingZone:la,Site:Ao,SiteDomain:Mo,SmsOptOut:Co,SocialAccount:fa,SocialPost:da,Subscriber:pa,SubscriberEmail:ma,Subscription:ga,Tag:ya,TaxRate:ba,Team:wa,TeamInvitation:ha,TeamMember:Ta,Transaction:_a,UsageEvent:zr,WaitlistProduct:ka,WaitlistRestaurant:Ra,Websocket:Sa},q=globalThis;for(let[e,n]of Object.entries(Kt))if(n&&q[e]===void 0)q[e]=n;var _s=Object.keys(Kt);async function Pa(e){if(!e)return[];try{if(typeof e.all==="function"){let n=await e.all();return Array.isArray(n)?n:[]}if(typeof e.get==="function"){let n=await e.get();return Array.isArray(n)?n:[]}}catch{}return[]}function xa(e,n,t=""){if(!e)return t;try{if(typeof e.get==="function"){let o=e.get(n);if(o!==void 0&&o!==null)return o}}catch{}let r=e?.[n];return r!==void 0&&r!==null?r:t}if(q.safeAll===void 0)q.safeAll=Pa;if(q.safeGet===void 0)q.safeGet=xa;export{Br as Activity,Ir as AnalyticsEvent,Ur as Auction,Hr as AuctionItem,Gr as Author,Kr as Automation,qr as AutomationRun,Jr as Bid,Yr as Board,Zr as BoardColumn,Xr as Campaign,go as CampaignSend,Lr as CampaignVariant,eo as Card,to as CardComment,no as Cart,ro as CartItem,oo as Category,ao as Comment,Qr as CommunicationSuppression,Vr as ConsentEvent,io as Coupon,po as Courier,mo as CourierPing,so as Customer,uo as DeliveryRoute,co as DeliveryStop,lo as Deployment,fo as DigitalDelivery,Oo as EmailIdempotency,yo as EmailList,bo as EmailListSubscriber,vo as EmailSuppression,Do as EmailWebhookEvent,Eo as ErrorModel,Nr as FailedJob,wo as Form,ho as FormField,To as FormSubmission,Fo as GiftCard,$r as Job,$o as Label,No as LicenseKey,jo as Log,Bo as LoyaltyPoint,Io as LoyaltyReward,Ue as MODEL_DEFINITION,_o as MagicLinkToken,Ko as MailPreference,qo as Manufacturer,Ie as MassAssignmentException,ko as Menu,Ro as MenuItem,Ct as ModelNotFoundError,xt as ModelValidationError,Uo as Notification,Lo as NotificationDelivery,Qo as Order,Vo as OrderIdempotency,Wo as OrderItem,zo as Page,So as PageRevision,Ho as Payment,Go as PaymentMethod,Jo as PaymentProduct,Yo as PaymentTransaction,Po as Pledge,Zo as Post,Xo as PrintDevice,ea as Product,ta as ProductUnit,na as ProductVariant,ra as QueryLog,oa as Receipt,xo as Redirect,aa as Release,ia as Request,sa as Review,Wr as SenderDomain,ua as ShippingMethod,ca as ShippingRate,la as ShippingZone,Ao as Site,Mo as SiteDomain,Co as SmsOptOut,fa as SocialAccount,da as SocialPost,wn as SubqueryBuilder,pa as Subscriber,ma as SubscriberEmail,ga as Subscription,ya as Tag,ba as TaxRate,wa as Team,ha as TeamInvitation,Ta as TeamMember,_a as Transaction,zr as UsageEvent,Fr as User,ka as WaitlistProduct,Ra as WaitlistRestaurant,Sa as Websocket,ci as batchLoad,Or as buildDatabaseSchema,pe as collectEncryptedAttributes,Ge as createAuditMethods,_e as createCategorizableMethods,we as createCommentableMethods,ke as createLikeableMethods,Te as createTaggableMethods,pi as db,fe as decryptValue,vt as defineModel,de as encryptValue,$e as enrichPaginatorUrls,ds as extendModel,Ni as extractDate,Ei as extractFields,Ci as fetchOtherModelRelations,cn as filterFillable,xe as findCoreModel,Ae as findUserModel,$i as formatDate,Di as getFillableAttributes,vi as getGuardedAttributes,Oi as getHiddenAttributes,z as getModelName,Tn as getPivotTableName,Mi as getPivotTables,va as getPrunableConfig,Ai as getRelationCount,xi as getRelationType,_n as getRelations,x as getTableName,un as getWritableFields,Pi as hasRelations,An as isCursorPaginator,U as isEncrypted,Pn as isPaginator,xn as isSimplePaginator,tt as isUniqueViolation,Fi as mapEntity,an as mapWriteError,Oa as massPrunable,dr as mergeModelDefinition,_s as modelGlobalNames,Si as modelTableName,Ts as ormReady,lt as parseCursor,qe as projectDocumentsFromTrait,qt as prunable,vr as renderDatabaseTypeFile,Fe as resolveCursorArgs,Ee as resolvePageArgs,bi as savepoint,Gt as setAuditUser,ar as toAttrs,ve as toCursorPaginator,Ce as toPaginator,Oe as toSimplePaginator,sn as toSnakeCaseKeys,ji as toTimestamp,yi as transaction,wi as transactional,N as withoutEvents,$n as withoutValidation};