@schematichq/schematic-typescript-node 1.5.7 → 1.5.8
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/api/resources/companies/client/Client.d.ts +35 -0
- package/dist/api/resources/companies/client/requests/CountEntityKeysRequest.d.ts +18 -0
- package/dist/api/resources/companies/client/requests/index.d.ts +1 -0
- package/dist/api/resources/companies/types/CountEntityKeysParams.d.ts +12 -0
- package/dist/api/resources/companies/types/CountEntityKeysResponse.d.ts +6 -0
- package/dist/api/resources/companies/types/DeleteEntityKeyDefinitionResponse.d.ts +6 -0
- package/dist/api/resources/companies/types/index.d.ts +3 -0
- package/dist/api/types/BillingCreditView.d.ts +1 -1
- package/dist/api/types/BillingProductRecordResponseData.d.ts +12 -0
- package/dist/api/types/CompanyFeatureUsageExportMetadata.d.ts +9 -2
- package/dist/api/types/CompanyFeatureUsageExportMetadataSortOrderDirection.d.ts +6 -0
- package/dist/api/types/CompanyFeatureUsageExportMetadataVisibleColumnsItem.d.ts +7 -0
- package/dist/api/types/DataExportMetadata.d.ts +4 -1
- package/dist/api/types/DataExportType.d.ts +1 -0
- package/dist/api/types/EventExportMetadata.d.ts +19 -0
- package/dist/api/types/EventExportMetadataEventTypesItem.d.ts +7 -0
- package/dist/api/types/FeatureView.d.ts +1 -1
- package/dist/api/types/TestWebhookResponseData.d.ts +1 -0
- package/dist/api/types/index.d.ts +5 -0
- package/dist/index.js +9 -9
- package/dist/serialization/resources/companies/types/CountEntityKeysParams.d.ts +13 -0
- package/dist/serialization/resources/companies/types/CountEntityKeysResponse.d.ts +12 -0
- package/dist/serialization/resources/companies/types/DeleteEntityKeyDefinitionResponse.d.ts +11 -0
- package/dist/serialization/resources/companies/types/index.d.ts +3 -0
- package/dist/serialization/types/BillingCreditView.d.ts +2 -2
- package/dist/serialization/types/BillingProductRecordResponseData.d.ts +18 -0
- package/dist/serialization/types/CompanyFeatureUsageExportMetadata.d.ts +6 -1
- package/dist/serialization/types/CompanyFeatureUsageExportMetadataSortOrderDirection.d.ts +7 -0
- package/dist/serialization/types/CompanyFeatureUsageExportMetadataVisibleColumnsItem.d.ts +7 -0
- package/dist/serialization/types/DataExportMetadata.d.ts +5 -1
- package/dist/serialization/types/DataExportType.d.ts +1 -1
- package/dist/serialization/types/EventExportMetadata.d.ts +17 -0
- package/dist/serialization/types/EventExportMetadataEventTypesItem.d.ts +7 -0
- package/dist/serialization/types/FeatureView.d.ts +2 -2
- package/dist/serialization/types/TestWebhookResponseData.d.ts +1 -0
- package/dist/serialization/types/index.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var az=Object.create;var Vo=Object.defineProperty;var nz=Object.getOwnPropertyDescriptor;var sz=Object.getOwnPropertyNames;var cz=Object.getPrototypeOf,lz=Object.prototype.hasOwnProperty;var gi=(p,o)=>()=>(p&&(o=p(p=0)),o);var pz=(p,o)=>()=>(o||p((o={exports:{}}).exports,o),o.exports),Pr=(p,o)=>{for(var i in o)Vo(p,i,{get:o[i],enumerable:!0})},Ws=(p,o,i,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of sz(o))!lz.call(p,s)&&s!==i&&Vo(p,s,{get:()=>o[s],enumerable:!(t=nz(o,s))||t.enumerable});return p};var mo=(p,o,i)=>(i=p!=null?az(cz(p)):{},Ws(o||!p||!p.__esModule?Vo(i,"default",{value:p,enumerable:!0}):i,p)),Hs=p=>Ws(Vo({},"__esModule",{value:!0}),p);var wc={};Pr(wc,{Node18UniversalStreamWrapper:()=>Ga});var Ga,bc=gi(()=>{"use strict";Ga=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.on("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.on("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.off("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.off("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var zc={};Pr(zc,{UndiciStreamWrapper:()=>Wa});var Wa,Rc=gi(()=>{"use strict";Wa=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.on("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.on("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.off("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.off("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var fc={};Pr(fc,{NodePre18StreamWrapper:()=>Ha});var Ha,_c=gi(()=>{"use strict";Ha=class{constructor(o){this.readableStream=o}on(o,i){this.readableStream.on(o,i)}off(o,i){this.readableStream.off(o,i)}pipe(o){return this.readableStream.pipe(o),o}pipeTo(o){return this.pipe(o)}unpipe(o){o?this.readableStream.unpipe(o):this.readableStream.unpipe()}destroy(o){this.readableStream.destroy(o)}pause(){this.readableStream.pause()}resume(){this.readableStream.resume()}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((o,i)=>{let t=this.readableStream.read();t?o(t):(this.readableStream.once("readable",()=>{let s=this.readableStream.read();o(s)}),this.readableStream.once("error",i))})}setEncoding(o){this.readableStream.setEncoding(o),this.encoding=o}async text(){let o=[],i=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let s of this.readableStream)o.push(i.encode(s));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(o))}async json(){let o=await this.text();return JSON.parse(o)}[Symbol.asyncIterator](){let i=this.readableStream[Symbol.asyncIterator]();return{async next(){let{value:t,done:s}=await i.next();return{value:t,done:s}},[Symbol.asyncIterator](){return this}}}}});var uo,js=gi(()=>{"use strict";uo=class{constructor(){this._emitter=null}ensureEmitter(){if(!this._emitter){let{EventEmitter:o}=require("events");this._emitter=new o}return this._emitter}on(o,i){return this.ensureEmitter().on(o,i),this}emit(o,...i){return this._emitter?.emit(o,...i)??!1}removeAllListeners(o){return this._emitter?.removeAllListeners(o),this}}});var jb=pz((_se,jf)=>{jf.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.7",private:!1,repository:{type:"git",url:"git+https://github.com/schematichq/schematic-node.git"},main:"./dist/index.js",types:"./dist/index.d.ts",scripts:{format:"biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","format:check":"biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",lint:"biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","lint:fix":"biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",check:"biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","check:fix":"biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",build:"node build.js",prepack:"",test:"jest --config jest.config.mjs","test:unit":"jest --selectProjects unit","test:wire":"jest --selectProjects wire","build:legacy":"tsc","test:cloudflare":"node scripts/test-cloudflare.mjs"},dependencies:{"form-data":"^4.0.4","formdata-node":"^6.0.3","node-fetch":"^2.7.0","readable-stream":"^4.7.0",ws:"^8.18.1"},devDependencies:{"@types/node-fetch":"^2.6.12","@types/readable-stream":"^4.0.23",webpack:"^5.105.4","ts-loader":"^9.5.4",jest:"^29.7.0","@jest/globals":"^29.7.0","@types/jest":"^29.5.14","ts-jest":"^29.3.4","jest-environment-jsdom":"^29.7.0",msw:"2.11.2","@types/node":"^20.0.0",typescript:"~5.9.3","@biomejs/biome":"2.4.10",esbuild:"^0.25.9",miniflare:"^4.20260421.0",redis:"^4.7.0","@types/ws":"^8.18.1"},browser:{fs:!1,os:!1,path:!1,stream:!1,crypto:!1,timers:!1},packageManager:"yarn@1.22.22",engines:{node:">=18.0.0"},sideEffects:!1,license:"MIT",files:["dist/**/*.js","dist/**/*.d.ts","dist/**/*.wasm","!dist/**/*.js.map","!dist/**/*.test.*","README.md"]}});var Ab,Vb,Db,qb=gi(()=>{"use strict";Ab=jb(),Vb=Ab.name,Db=Ab.version});var Fb={};Pr(Fb,{DatastreamWSClient:()=>Ds});function If(p){let o=new URL(p);switch(o.protocol){case"https:":o.protocol="wss:";break;case"http:":o.protocol="ws:";break;default:throw new Error(`Unsupported scheme: ${o.protocol} (must be http: or https:)`)}if(o.hostname){let i=o.hostname.split(".");i.length>1&&i[0]==="api"&&(i[0]="datastream",o.hostname=i.join("."))}return o.pathname="/datastream",o.toString()}var Mb,Af,Ib,Vf,Df,qf,Mf,Ds,Kb=gi(()=>{"use strict";Mb=mo(require("ws"));qb();js();Af=10*1e3,Ib=60*1e3,Vf=Ib*9/10,Df=10,qf=1*1e3,Mf=30*1e3;Ds=class extends uo{constructor(i){super();this.connected=!1;this.ready=!1;this.shouldReconnect=!0;this.reconnectAttempts=0;if(!i.url)throw new Error("URL is required");if(!i.apiKey)throw new Error("ApiKey is required");if(!i.messageHandler)throw new Error("MessageHandler is required");i.url.startsWith("http://")||i.url.startsWith("https://")?this.url=If(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":Vb,"X-Schematic-Client-Version":Db,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??Df,this.minReconnectDelay=i.minReconnectDelay??qf,this.maxReconnectDelay=i.maxReconnectDelay??Mf}start(){this.shouldReconnect=!0,this.reconnectAttempts=0,this.connectAndRead()}isConnected(){return this.connected}isReady(){return this.ready&&this.connected}async sendMessage(i){if(!this.isConnected()||!this.ws)throw new Error("WebSocket connection is not available!");return new Promise((t,s)=>{if(!this.ws){s(new Error("WebSocket connection is not available!"));return}let r=setTimeout(()=>{s(new Error("Write timeout"))},Af);try{this.ws.send(JSON.stringify(i),a=>{clearTimeout(r),a?s(a):t()})}catch(a){clearTimeout(r),s(a)}})}close(){this.logger.info("Closing WebSocket connection"),this.shouldReconnect=!1,this.setReady(!1),this.setConnected(!1),this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.ws&&(this.ws.close(),this.ws=void 0)}async connectAndRead(){try{for(;this.shouldReconnect;)try{let i=await this.connect();if(this.reconnectAttempts=0,this.ws=i,this.setConnected(!0),this.setupWebSocketHandlers(i),this.connectionReadyHandler)try{await this.connectionReadyHandler(),this.logger.debug("Connection ready handler completed successfully")}catch(t){this.logger.error(`Connection ready handler failed: ${t}`),this.setConnected(!1),this.setReady(!1),i.close();continue}if(this.setReady(!0),this.logger.debug("WebSocket client is ready"),this.startPingPong(),await new Promise(t=>{let s=()=>{this.logger.info("WebSocket connection closed"),this.cleanup(),t()},r=a=>{this.logger.error(`WebSocket error: ${a.message}`),this.emit("error",a),this.cleanup(),t()};i.on("close",s),i.on("error",r)}),!this.shouldReconnect)break}catch(i){this.reconnectAttempts++,this.setConnected(!1),this.setReady(!1);let t=i instanceof Error?i.message:String(i);if(this.logger.warn(`WebSocket connection failed: ${t}, attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts}`),this.reconnectAttempts>=this.maxReconnectAttempts){this.logger.error("Max reconnection attempts reached"),this.emit("error",new Error("Max reconnection attempts reached"));break}let s=this.calculateBackoffDelay(this.reconnectAttempts);this.logger.debug(`Waiting ${s}ms before reconnecting...`),await new Promise(r=>{this.reconnectTimeout=setTimeout(r,s),this.reconnectTimeout.unref()})}}catch(i){this.emit("error",i)}}connect(){return new Promise((i,t)=>{this.logger.debug(`Connecting to WebSocket: ${this.url}`);let s=new Mb.default(this.url,{headers:this.headers,handshakeTimeout:3e4}),r=setTimeout(()=>{s.close(),t(new Error("Connection timeout"))},3e4);s.on("open",()=>{clearTimeout(r),i(s)}),s.on("error",a=>{clearTimeout(r),t(a)})})}setupWebSocketHandlers(i){i.on("message",t=>{this.handleMessage(t)}),i.on("pong",()=>{this.handlePong()}),i.on("close",t=>{this.handleClose(t)}),i.on("error",t=>{this.handleError(t)})}async handleMessage(i){try{let t;Buffer.isBuffer(i)?t=i.toString():Array.isArray(i)?t=Buffer.concat(i).toString():t=String(i);let s;try{s=JSON.parse(t)}catch(r){this.emit("error",new Error(`Failed to parse datastream message: ${r}`));return}try{await this.messageHandler(s)}catch(r){this.emit("error",new Error(`Message handler error: ${r}`))}}catch(t){this.emit("error",t)}}handleClose(i){this.logger.info(`WebSocket connection closed with code ${i}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}handleError(i){this.logger.error(`WebSocket error: ${i.message}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}startPingPong(){this.logger.debug("Starting ping/pong keepalive mechanism"),this.pingInterval=setInterval(()=>{this.sendPing()},Vf),this.pingInterval.unref()}sendPing(){if(this.ws){this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.pongTimeout=setTimeout(()=>{this.logger.warn("Pong timeout - closing connection"),this.setConnected(!1),this.ws&&this.ws.close()},Ib),this.pongTimeout.unref();try{this.ws.ping()}catch(i){this.logger.error(`Failed to send ping: ${i}`),this.setConnected(!1)}}}handlePong(){this.logger.debug("Received pong from server"),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}calculateBackoffDelay(i){let t=Math.floor(Math.random()*this.minReconnectDelay),s=Math.pow(2,i-1)*this.minReconnectDelay+t;return Math.min(s,this.maxReconnectDelay+t)}setConnected(i){let t=this.connected;this.connected=i,i||(this.ready=!1),t!==i&&(this.logger.debug(`Connection state changed: ${i}`),i?this.emit("connected"):this.emit("disconnected"))}setReady(i){let t=this.ready;this.ready=i,t!==i&&(this.logger.debug(`Ready state changed: ${i}`),i?this.emit("ready"):this.emit("not-ready"))}cleanup(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}}});var h_={};Pr(h_,{ConsoleLogger:()=>li,LocalCache:()=>or,LogLevel:()=>ir,RedisCacheProvider:()=>ui,RulesEngineClient:()=>po,Schematic:()=>ie,SchematicClient:()=>Da,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>pi,WEBHOOK_SIGNATURE_HEADER:()=>Fs,WEBHOOK_TIMESTAMP_HEADER:()=>Ks,WebhookSignatureError:()=>_r,computeHexSignature:()=>rz,computeSignature:()=>Ma,verifySignature:()=>Ls,verifyWebhookSignature:()=>iz});module.exports=Hs(h_);var ie={};Pr(ie,{AccountMemberPermission:()=>dz,AccountMemberRole:()=>mz,ActorType:()=>hz,ApiKeyScope:()=>gz,BadRequestError:()=>v,BillingCreditAutoTopupAvailability:()=>yz,BillingCreditBundleStatus:()=>wz,BillingCreditBurnStrategy:()=>bz,BillingCreditExpiryType:()=>zz,BillingCreditExpiryUnit:()=>Rz,BillingCreditGrantReason:()=>fz,BillingCreditGrantZeroedOutReason:()=>_z,BillingCreditLedgerAuthority:()=>Sz,BillingCreditRolloverPolicy:()=>xz,BillingPlanCreditGrantResetCadence:()=>Pz,BillingPlanCreditGrantResetStart:()=>Cz,BillingPlanCreditGrantResetType:()=>Ez,BillingPriceScheme:()=>Uz,BillingPriceUsageType:()=>vz,BillingProductPriceInterval:()=>Tz,BillingProviderType:()=>Oz,BillingStrategy:()=>kz,BillingSubscriptionTrialEndSetting:()=>Bz,BillingTiersMode:()=>jz,ChargeType:()=>Az,CompanyMatchingCriteria:()=>Vz,CompanyPlanInvalidReason:()=>Dz,ComparableOperator:()=>qz,ComponentEntityType:()=>Mz,ComponentState:()=>Iz,ConditionType:()=>Fz,CreditEventType:()=>Kz,CreditGrantSortOrder:()=>Lz,CreditUsageReason:()=>Gz,CustomPlanActivationStrategy:()=>Wz,CustomPlanBillingStatus:()=>Hz,DataExportOutputFileType:()=>Nz,DataExportStatus:()=>$z,DataExportType:()=>Jz,EntitlementPriceBehavior:()=>Yz,EntitlementType:()=>Zz,EntitlementValueType:()=>Xz,EntityType:()=>Qz,EnvironmentType:()=>eR,EventStatus:()=>rR,EventType:()=>Do,FeatureLifecyclePhase:()=>iR,FeatureType:()=>oR,ForbiddenError:()=>_,IntegrationState:()=>tR,IntegrationType:()=>aR,InternalServerError:()=>S,InvoiceStatus:()=>nR,MetricPeriod:()=>sR,MetricPeriodMonthReset:()=>cR,MigrationErrorCode:()=>lR,NotFoundError:()=>x,PlanBundleAction:()=>pR,PlanChangeAction:()=>uR,PlanChangeBasePlanAction:()=>dR,PlanChangeSubscriptionAction:()=>mR,PlanCreditGrantScaling:()=>hR,PlanIcon:()=>gR,PlanPriceCadence:()=>yR,PlanType:()=>wR,PlanVersionCompanyMigrationStatus:()=>bR,PlanVersionMigrationStatus:()=>zR,PlanVersionMigrationStrategy:()=>RR,PlanVersionStatus:()=>fR,ProrationBehavior:()=>_R,RuleType:()=>TR,RulesEngineSchemaVersion:()=>SR,RulesengineConditionType:()=>xR,RulesengineEntitlementValueType:()=>Ia,RulesengineEntityType:()=>PR,RulesengineMetricPeriod:()=>CR,RulesengineMetricPeriodMonthReset:()=>ER,RulesengineRuleType:()=>UR,RulesengineTraitDefinitionComparableType:()=>vR,ScheduledCheckoutStatus:()=>OR,ScheduledDowngradeConfigBehavior:()=>kR,SortDirection:()=>BR,SubscriptionStatus:()=>jR,SubscriptionType:()=>AR,TaxIdType:()=>VR,TimeSeriesGranularity:()=>DR,TraitDefinitionComparableType:()=>qR,TraitType:()=>MR,TrialStatus:()=>IR,UnauthorizedError:()=>P,WebhookEventStatus:()=>FR,WebhookRequestType:()=>KR,WebhookStatus:()=>LR,accesstokens:()=>Ns,accounts:()=>$s,billing:()=>Js,catalogs:()=>Ys,checkout:()=>Zs,companies:()=>Xs,components:()=>Qs,componentspublic:()=>ec,credits:()=>rc,dataexports:()=>ic,entitlements:()=>oc,events:()=>tc,features:()=>ac,insights:()=>nc,integrationsapi:()=>sc,licenses:()=>cc,planbundle:()=>lc,plangroups:()=>pc,planmigrations:()=>uc,plans:()=>dc,scheduledcheckout:()=>mc,webhooks:()=>hc});var Te=(p,o,i)=>JSON.stringify(p,o,i);function ho(p,o){return JSON.parse(p,o)}var b=class extends Error{constructor({message:o,statusCode:i,body:t,rawResponse:s,cause:r}){super(uz({message:o,statusCode:i,body:t})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=i,this.body=t,this.rawResponse=s,r!=null&&(this.cause=r)}};function uz({message:p,statusCode:o,body:i}){let t=[];return p!=null&&t.push(p),o!=null&&t.push(`Status code: ${o.toString()}`),i!=null&&t.push(`Body: ${Te(i,void 0,2)}`),t.join(`
|
|
2
|
-
`)}var pi=class extends Error{constructor(o,i){super(o),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,i?.cause!=null&&(this.cause=i.cause)}};var v=class extends b{constructor(o,i){super({message:"BadRequestError",statusCode:400,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var _=class extends b{constructor(o,i){super({message:"ForbiddenError",statusCode:403,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var S=class extends b{constructor(o,i){super({message:"InternalServerError",statusCode:500,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var x=class extends b{constructor(o,i){super({message:"NotFoundError",statusCode:404,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var P=class extends b{constructor(o,i){super({message:"UnauthorizedError",statusCode:401,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Ns={};var $s={};var Js={};var Ys={};var Zs={};var Xs={};var Qs={};var ec={};var rc={};var ic={};var oc={};var tc={};var ac={};var nc={};var sc={};var cc={};var lc={};var pc={};var uc={};var dc={};var mc={};var hc={};var dz={CompaniesEdit:"companies_edit",CompanyUsersEdit:"company_users_edit",ComponentsEdit:"components_edit",CustomPlansEdit:"custom_plans_edit",DataExportsEdit:"data_exports_edit",FeaturesEdit:"features_edit",FlagRulesEdit:"flag_rules_edit",FlagsEdit:"flags_edit",OverridesEdit:"overrides_edit",PlanBillingEdit:"plan_billing_edit",PlanEntitlementsEdit:"plan_entitlements_edit",PlanVersionsEdit:"plan_versions_edit",PlansEdit:"plans_edit",WebhooksEdit:"webhooks_edit",WebhooksRevealSecret:"webhooks_reveal_secret"};var mz={Admin:"admin",Member:"member"};var hz={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var gz={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var yz={Off:"off",Automatic:"automatic",UserControlled:"user_controlled"};var wz={Active:"active",Inactive:"inactive"};var bz={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var zz={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var Rz={BillingPeriods:"billing_periods",Days:"days"};var fz={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var _z={CustomerArchived:"customer_archived",Expired:"expired",IntegrationUninstalled:"integration_uninstalled",LicenseRetired:"license_retired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset",Reconciled:"reconciled"};var Sz={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var xz={Expire:"expire",None:"none",Rollover:"rollover"};var Pz={Daily:"daily",Every6Months:"every_6_months",Monthly:"monthly",Quarterly:"quarterly",Weekly:"weekly",Yearly:"yearly"};var Cz={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var Ez={NoReset:"no_reset",PlanPeriod:"plan_period"};var Uz={PerUnit:"per_unit",Tiered:"tiered"};var vz={Licensed:"licensed",Metered:"metered"};var Tz={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var Oz={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var kz={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var Bz={Cancel:"cancel",Subscribe:"subscribe"};var jz={Graduated:"graduated",Volume:"volume"};var Az={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var Vz={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var Dz={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var qz={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var Mz={Billing:"billing",Entitlement:"entitlement"};var Iz={Draft:"draft",Live:"live"};var Fz={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Kz={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var Lz={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var Gz={LeaseHold:"lease_hold",LeaseRelease:"lease_release",ManualAdjustment:"manual_adjustment",Reconciliation:"reconciliation",Track:"track"};var Wz={OnPayment:"on_payment",OnPublish:"on_publish"};var Hz={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var Nz={Csv:"csv",CsvGz:"csv.gz"};var $z={Failure:"failure",Pending:"pending",Success:"success"};var Jz={AuditLog:"audit-log",CompanyFeatureUsage:"company-feature-usage"};var Yz={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var Zz={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var Xz={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Qz={Company:"company",User:"user"};var eR={Development:"development",Production:"production",Staging:"staging"};var rR={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var Do={FlagCheck:"flag_check",Identify:"identify",Inference:"inference",Track:"track"};var iR={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var oR={Boolean:"boolean",Event:"event",License:"license",Trait:"trait"};var tR={Active:"active",Created:"created",Pending:"pending"};var aR={Clerk:"clerk",Metronome:"metronome",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var nR={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var sR={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var cR={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var lR={AmbiguousSubscriptionItem:"ambiguous_subscription_item",MultipleSubscriptions:"multiple_subscriptions",NoPriceForInterval:"no_price_for_interval",NotOnOriginVersion:"not_on_origin_version",OperationItemNotFound:"operation_item_not_found",PermanentConfig:"permanent_config",PermanentDecline:"permanent_decline",TransientDecline:"transient_decline",TransientInfra:"transient_infra",TransientStripe:"transient_stripe",Unknown:"unknown",WouldLeaveEmptySubscription:"would_leave_empty_subscription"};var pR={Create:"create",Update:"update",Delete:"delete"};var uR={Checkout:"checkout",CompanyUpsert:"company_upsert",FallbackPlan:"fallback_plan",ManagePlan:"manage_plan",Migration:"migration",PlanBillingProductChanged:"plan_billing_product_changed",PlanDeleted:"plan_deleted",PlanTraitChange:"plan_trait_change",PlanVersionMigration:"plan_version_migration",Quickstart:"quickstart",SubscriptionChange:"subscription_change"};var dR={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var mR={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var hR={Fixed:"fixed",PerLicense:"per_license"};var gR={Amber:"amber",Blue:"blue",BlueGray:"blueGray",BlueGreen:"blueGreen",Cyan:"cyan",Emerald:"emerald",Fuchsia:"fuchsia",Gray:"gray",Green:"green",Indigo:"indigo",LightBlue:"lightBlue",Lime:"lime",Orange:"orange",Pink:"pink",Purple:"purple",Red:"red",RedOrange:"redOrange",Rose:"rose",Sky:"sky",Slate:"slate",Teal:"teal",TrueGray:"trueGray",Violet:"violet",WarmGray:"warmGray",Yellow:"yellow"};var yR={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var wR={Plan:"plan",AddOn:"add_on"};var bR={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var zR={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var RR={Immediate:"immediate",Leave:"leave"};var fR={Published:"published",Draft:"draft",Archived:"archived"};var _R={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var SR={V5B3E7220:"v5b3e7220",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var xR={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Ia={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var PR={Company:"company",User:"user"};var CR={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var ER={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var UR={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var vR={Bool:"bool",Date:"date",Int:"int",String:"string"};var TR={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var OR={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var kR={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var BR={Asc:"asc",Desc:"desc"};var jR={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var AR={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var VR={AeTrn:"ae_trn",AuAbn:"au_abn",AuArn:"au_arn",BrCnpj:"br_cnpj",BrCpf:"br_cpf",CaBn:"ca_bn",CaGstHst:"ca_gst_hst",CaPstBc:"ca_pst_bc",CaPstMb:"ca_pst_mb",CaPstSk:"ca_pst_sk",CaQst:"ca_qst",ChUid:"ch_uid",ChVat:"ch_vat",EuVat:"eu_vat",GbVat:"gb_vat",HkBr:"hk_br",IdNpwp:"id_npwp",IlVat:"il_vat",InGst:"in_gst",JpCn:"jp_cn",JpRn:"jp_rn",JpTrn:"jp_trn",KrBrn:"kr_brn",MxRfc:"mx_rfc",MyFrp:"my_frp",MyItn:"my_itn",MySst:"my_sst",NoVat:"no_vat",NzGst:"nz_gst",PhTin:"ph_tin",SaVat:"sa_vat",SgGst:"sg_gst",SgUen:"sg_uen",ThVat:"th_vat",TrTin:"tr_tin",TwVat:"tw_vat",UsEin:"us_ein",ZaVat:"za_vat"};var DR={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var qR={Bool:"bool",Date:"date",Int:"int",String:"string"};var MR={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var IR={Active:"active",Converted:"converted",Expired:"expired"};var FR={Failure:"failure",Pending:"pending",Success:"success"};var KR={SubscriptionTrialEnded:"subscription.trial.ended",CompanyCreated:"company.created",CompanyDeleted:"company.deleted",CompanyOverrideCreated:"company.override.created",CompanyOverrideDeleted:"company.override.deleted",CompanyOverrideExpired:"company.override.expired",CompanyOverrideUpdated:"company.override.updated",CompanyPlanChanged:"company.plan_changed",CompanyScheduledDowngrade:"company.scheduled_downgrade",CompanyUpdated:"company.updated",CreditLimitReached:"credit.limit.reached",CreditLimitWarning:"credit.limit.warning",CreditPurchaseSuccess:"credit.purchase.success",EntitlementLimitReached:"entitlement.limit.reached",EntitlementLimitWarning:"entitlement.limit.warning",EntitlementSoftLimitReached:"entitlement.soft_limit.reached",EntitlementSoftLimitWarning:"entitlement.soft_limit.warning",EntitlementTierLimitReached:"entitlement.tier_limit.reached",EntitlementTierLimitWarning:"entitlement.tier_limit.warning",FeatureCreated:"feature.created",FeatureDeleted:"feature.deleted",FeatureUpdated:"feature.updated",FlagCreated:"flag.created",FlagDeleted:"flag.deleted",FlagRulesUpdated:"flag_rules.updated",FlagUpdated:"flag.updated",PlanCreated:"plan.created",PlanDeleted:"plan.deleted",PlanEntitlementCreated:"plan.entitlement.created",PlanEntitlementDeleted:"plan.entitlement.deleted",PlanEntitlementUpdated:"plan.entitlement.updated",PlanUpdated:"plan.updated",PlanVersionDeleted:"plan_version.deleted",RuleDeleted:"rule.deleted",TestSend:"test.send",UserCreated:"user.created",UserDeleted:"user.deleted",UserUpdated:"user.updated",AutoTopupHardFailure:"auto.topup.hard.failure",AutoTopupRetryExceeded:"auto.topup.retry.exceeded",AutoTopupSuccess:"auto.topup.success"};var LR={Active:"active",Inactive:"inactive"};var GR=2147483647,or=class{constructor({maxItems:o=1e3,ttl:i=5e3}={}){this.accessCounter=0;this.cache=new Map,this.maxItems=o,this.defaultTTL=i}async get(o){let i=this.cache.get(o);return i?i.expiration<=Date.now()?(this.evictItem(o,i),null):(this.accessCounter++,i.accessCounter=this.accessCounter,this.cache.set(o,i),i.value):null}async set(o,i,t){if(this.maxItems===0)return;let s=t??this.defaultTTL,r=this.cache.get(o);r&&this.evictItem(o,r),this.evictExpiredItems(),this.evictLRUItems(),this.accessCounter++;let a={value:i,accessCounter:this.accessCounter,expiration:Date.now()+s};a.timeoutId=setTimeout(()=>this.evictItem(o,a),Math.min(s,GR)),typeof a.timeoutId=="object"&&typeof a.timeoutId.unref=="function"&&a.timeoutId.unref(),this.cache.set(o,a)}async delete(o){let i=this.cache.get(o);i&&this.evictItem(o,i)}async deleteMissing(o,i){let t=new Set(o);for(let[s,r]of this.cache)t.has(s)||this.evictItem(s,r)}evictItem(o,i){i.timeoutId&&clearTimeout(i.timeoutId),this.cache.delete(o)}evictExpiredItems(){this.cache.forEach((o,i)=>{o.expiration<=Date.now()&&this.evictItem(i,o)})}evictLRUItems(){for(;this.cache.size>=this.maxItems;){let o,i=Number.MAX_SAFE_INTEGER;this.cache.forEach((t,s)=>{t.accessCounter<i&&(o=s,i=t.accessCounter)}),o&&this.evictItem(o,this.cache.get(o))}}};var ui=class{constructor(o){this.client=o.client,this.defaultTTL=Math.floor((o.ttl||5e3)/1e3),this.keyPrefix=o.keyPrefix||"schematic:"}getFullKey(o){return this.keyPrefix+o}async get(o){let i=this.getFullKey(o),t=await this.client.get(i);return t===null?null:JSON.parse(t)}async set(o,i,t){let s=this.getFullKey(o),r=JSON.stringify(i),a=t?Math.floor(t/1e3):this.defaultTTL;a>0?await this.client.setEx(s,a,r):await this.client.set(s,r)}async delete(o){let i=this.getFullKey(o);await this.client.del(i)}async deleteMissing(o,i){let t=i?.scanPattern?this.keyPrefix+i.scanPattern:this.keyPrefix+"*",s=new Set(o.map(d=>this.getFullKey(d))),r=[],a=1e3;for await(let d of this.client.scanIterator({MATCH:t,COUNT:1e3}))s.has(d)||(r.push(d),r.length>=a&&(await this.client.del(r),r.length=0));r.length>0&&await this.client.del(r)}};function Fa(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var yi=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var qo={get:async(p,o)=>typeof p=="function"?p(o):p};var Qe={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},gc={[Qe.Debug]:1,[Qe.Info]:2,[Qe.Warn]:3,[Qe.Error]:4},go=class{debug(o,...i){console.debug(o,...i)}info(o,...i){console.info(o,...i)}warn(o,...i){console.warn(o,...i)}error(o,...i){console.error(o,...i)}},wi=class{constructor(o){this.level=gc[o.level],this.logger=o.logger,this.silent=o.silent}shouldLog(o){return!this.silent&&this.level<=gc[o]}isDebug(){return this.shouldLog(Qe.Debug)}debug(o,...i){this.isDebug()&&this.logger.debug(o,...i)}isInfo(){return this.shouldLog(Qe.Info)}info(o,...i){this.isInfo()&&this.logger.info(o,...i)}isWarn(){return this.shouldLog(Qe.Warn)}warn(o,...i){this.isWarn()&&this.logger.warn(o,...i)}isError(){return this.shouldLog(Qe.Error)}error(o,...i){this.isError()&&this.logger.error(o,...i)}};function yo(p){return p==null?WR:p instanceof wi?p:(p=p??{},p.level??=Qe.Info,p.logger??=new go,p.silent??=!0,new wi(p))}var WR=new wi({level:Qe.Info,logger:new go,silent:!0});var HR={arrayFormat:"indices",encode:!0};function Ka(p,o){if(p===void 0||p===null)return"";let i=String(p);return o?encodeURIComponent(i):i}function La(p,o="",i){let t=[];for(let[s,r]of Object.entries(p)){let a=o?`${o}[${s}]`:s;if(r!==void 0)if(Array.isArray(r)){if(r.length===0)continue;let d=i.arrayFormat;if(d==="comma"){let y=i.encode?encodeURIComponent(a):a,g=r.filter(l=>l!=null).map(l=>Ka(l,i.encode));g.length>0&&t.push(`${y}=${g.join(",")}`)}else for(let y=0;y<r.length;y++){let g=r[y];if(g!==void 0)if(typeof g=="object"&&!Array.isArray(g)&&g!==null){let l=d==="indices"?`${a}[${y}]`:a;t.push(...La(g,l,i))}else{let l=d==="indices"?`${a}[${y}]`:a,h=i.encode?encodeURIComponent(l):l;t.push(`${h}=${Ka(g,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;t.push(...La(r,a,i))}else{let d=i.encode?encodeURIComponent(a):a;t.push(`${d}=${Ka(r,i.encode)}`)}}return t}function Cr(p,o){return p==null||typeof p!="object"?"":La(p,"",{...HR,...o}).join("&")}function Mo(p,o){let i=Cr(o,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function yc(p){let o={get bodyUsed(){return p.bodyUsed},stream:()=>p.body,arrayBuffer:p.arrayBuffer.bind(p),blob:p.blob.bind(p)};return"bytes"in p&&typeof p.bytes=="function"&&(o.bytes=p.bytes.bind(p)),o}var _e=NR();function NR(){if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let d=typeof process<"u"?process:void 0;return typeof d<"u"&&typeof d.versions?.node=="string"?{type:"node",version:d.versions.node,parsedVersion:Number(d.versions.node.split(".")[0])}:{type:"unknown"}}async function Sc(p){return _e.type==="node"&&_e.parsedVersion!=null&&_e.parsedVersion>=18?new(await Promise.resolve().then(()=>(bc(),wc))).Node18UniversalStreamWrapper(p):_e.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Rc(),zc))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(_c(),fc))).NodePre18StreamWrapper(p)}async function bi(p,o){switch(o){case"binary-response":return yc(p);case"blob":return await p.blob();case"arrayBuffer":return await p.arrayBuffer();case"sse":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:p.body;case"streaming":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:Sc(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return ho(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function xc(p){let o=p.headers.get("Content-Type")?.toLowerCase();if(o==null||o.length===0)return bi(p);switch(o.indexOf(";")!==-1&&(o=o.split(";")[0]?.trim()??""),o){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":{let i=await p.text();return i.length>0?ho(i):void 0}default:if(o.startsWith("application/vnd.")&&o.endsWith("+json")){let i=await p.text();return i.length>0?ho(i):void 0}return await p.text()}}async function zi(){return _e.type==="node"&&_e.parsedVersion!=null&&_e.parsedVersion>=18?fetch:_e.type==="node"?(await import("node-fetch")).default:typeof fetch=="function"?fetch:(await import("node-fetch")).default}async function Io({body:p,type:o}){return o==="form"?Cr(p,{arrayFormat:"repeat",encode:!0}):o.includes("json")?Te(p):p}var tr;typeof globalThis.Headers<"u"?tr=globalThis.Headers:tr=class Pc{constructor(o){if(this.headers=new Map,o)if(o instanceof Pc)o.forEach((i,t)=>this.append(t,i));else if(Array.isArray(o))for(let[i,t]of o)if(typeof i=="string"&&typeof t=="string")this.append(i,t);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[i,t]of Object.entries(o))if(typeof t=="string")this.append(i,t);else throw new TypeError("Header values must be strings")}append(o,i){let t=o.toLowerCase(),s=this.headers.get(t)||[];this.headers.set(t,[...s,i])}delete(o){let i=o.toLowerCase();this.headers.delete(i)}get(o){let i=o.toLowerCase(),t=this.headers.get(i);return t?t.join(", "):null}has(o){let i=o.toLowerCase();return this.headers.has(i)}set(o,i){let t=o.toLowerCase();this.headers.set(t,[i])}forEach(o,i){let t=i?o.bind(i):o;this.headers.forEach((s,r)=>t(s.join(", "),r,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[o,i]of this.headers.entries())yield[o,i.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let o of this.headers.values())yield o.join(", ")}[Symbol.iterator](){return this.entries()}};var $R="timeout";function Cc(p){let o=new AbortController,i=setTimeout(()=>o.abort($R),p);return{signal:o.signal,abortId:i}}function Ec(...p){let o=p.length===1&&Array.isArray(p[0])?p[0]:p,i=new AbortController;for(let t of o){if(t.aborted){i.abort(t?.reason);break}t.addEventListener("abort",()=>i.abort(t?.reason),{signal:i.signal})}return i.signal}var wo;function JR(){if(wo!=null)return wo;try{new Request("http://localhost",{cache:"no-store"}),wo=!0}catch{wo=!1}return wo}var Ri=async(p,o,i,t,s,r,a,d,y,g)=>{let l=[],h;if(r!=null){let{signal:T,abortId:O}=Cc(r);h=O,l.push(T)}a!=null&&l.push(a);let w=Ec(l),U=await p(o,{method:i,headers:t,body:s,signal:w,credentials:d?"include":void 0,duplex:y,...g&&JR()?{cache:"no-store"}:{}});return h!=null&&clearTimeout(h),U};var fi={headers:new tr,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},_i={headers:new tr,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function bo(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function YR(p){return[408,429].includes(p)||p>=500}function ZR(p){let o=1+Math.random()*.2;return p*o}function XR(p){let o=1+(Math.random()-.5)*.2;return p*o}function QR(p,o){let i=p.headers.get("Retry-After");if(i){let s=parseInt(i,10);if(!Number.isNaN(s)&&s>0)return Math.min(s*1e3,6e4);let r=new Date(i);if(!Number.isNaN(r.getTime())){let a=r.getTime()-Date.now();if(a>0)return Math.min(Math.max(a,0),6e4)}}let t=p.headers.get("X-RateLimit-Reset");if(t){let s=parseInt(t,10);if(!Number.isNaN(s)){let r=s*1e3-Date.now();if(r>0)return ZR(Math.min(r,6e4))}}return XR(Math.min(1e3*2**o,6e4))}async function Si(p,o=2){let i=await p();for(let t=0;t<o&&YR(i.status);++t){let s=QR(i,t);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var ef=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function Na(p){let o={};for(let[i,t]of p instanceof tr?p.entries():Object.entries(p))ef.has(i.toLowerCase())?o[i]="[REDACTED]":o[i]=t;return o}var $a=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function rf(p){if(p==null)return;let o={};for(let[i,t]of Object.entries(p))o[i]=$a.has(i.toLowerCase())?"[REDACTED]":t;return o}function di(p){let o=p.indexOf("://");if(o===-1)return p;let i=o+3,t=p.indexOf("/",i),s=p.indexOf("?",i),r=p.indexOf("#",i),a=Math.min(t===-1?p.length:t,s===-1?p.length:s,r===-1?p.length:r),d=-1;for(let T=i;T<a;T++)p[T]==="@"&&(d=T);if(d!==-1&&(p=`${p.slice(0,i)}[REDACTED]@${p.slice(d+1)}`),s=p.indexOf("?"),s===-1)return p;r=p.indexOf("#",s);let y=r!==-1?r:p.length,g=p.slice(s+1,y);if(g.length===0)return p;let l=g.toLowerCase();if(!(l.includes("token")||l.includes("key")||l.includes("password")||l.includes("passwd")||l.includes("secret")||l.includes("session")||l.includes("auth")))return p;let w=[],U=g.split("&");for(let T of U){let O=T.indexOf("=");if(O===-1){w.push(T);continue}let B=T.slice(0,O),j=$a.has(B.toLowerCase());if(!j&&B.includes("%"))try{let F=decodeURIComponent(B);j=$a.has(F.toLowerCase())}catch{}w.push(j?`${B}=[REDACTED]`:T)}return p.slice(0,s+1)+w.join("&")+p.slice(y)}async function of(p){let o=new tr;if(o.set("Accept",p.responseType==="json"?"application/json":p.responseType==="text"?"text/plain":p.responseType==="sse"?"text/event-stream":"*/*"),p.body!==void 0&&p.contentType!=null&&o.set("Content-Type",p.contentType),p.headers==null)return o;for(let[i,t]of Object.entries(p.headers)){let s=await qo.get(t,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){o.set(i,s);continue}s!=null&&o.set(i,`${s}`)}return o}async function tf(p){let o=p.url;p.queryString!=null&&p.queryString.length>0?o=`${o}?${p.queryString}`:o=Mo(p.url,p.queryParameters);let i=await Io({body:p.body,type:p.requestType??"other"}),t=p.fetchFn??await zi(),s=await of(p),r=yo(p.logging);if(r.isDebug()){let a={method:p.method,url:di(o),headers:Na(s),queryParameters:rf(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",a)}try{let a=await Si(async()=>Ri(t,o,p.method,s,i,p.timeoutMs,p.abortSignal,p.withCredentials,p.duplex,p.responseType==="streaming"||p.responseType==="sse"),p.maxRetries);if(a.status>=200&&a.status<400){if(r.isDebug()){let y={method:p.method,url:di(o),statusCode:a.status,responseHeaders:Na(a.headers)};r.debug("HTTP request succeeded",y)}return{ok:!0,body:await bi(a,p.responseType),headers:a.headers,rawResponse:bo(a)}}else{if(r.isError()){let d={method:p.method,url:di(o),statusCode:a.status,responseHeaders:Na(Object.fromEntries(a.headers.entries()))};r.error("HTTP request failed with error status",d)}return{ok:!1,error:{reason:"status-code",statusCode:a.status,body:await xc(a)},rawResponse:bo(a)}}}catch(a){if(p.abortSignal?.aborted){if(r.isError()){let d={method:p.method,url:di(o)};r.error("HTTP request was aborted",d)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:a},rawResponse:fi}}else if(a instanceof Error&&a.name==="AbortError"){if(r.isError()){let d={method:p.method,url:di(o),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",d)}return{ok:!1,error:{reason:"timeout",cause:a},rawResponse:fi}}else if(a instanceof Error){if(r.isError()){let d={method:p.method,url:di(o),errorMessage:a.message};r.error("HTTP request failed with error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:a.message,cause:a},rawResponse:_i}}if(r.isError()){let d={method:p.method,url:di(o),error:Te(a)};r.error("HTTP request failed with unknown error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:Te(a),cause:a},rawResponse:_i}}}var C=tf;var R=class p extends Promise{constructor(o){super(i=>{i(void 0)}),this.innerPromise=o}static fromFunction(o,...i){return new p(o(...i))}static interceptFunction(o){return(...i)=>p.fromPromise(o(...i))}static fromPromise(o){return new p(o)}static fromExecutor(o){let i=new Promise(o);return new p(i)}static fromResult(o){let i=Promise.resolve(o);return new p(i)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:o})=>o)),this.unwrappedPromise}then(o,i){return this.unwrap().then(o,i)}catch(o){return this.unwrap().catch(o)}finally(o){return this.unwrap().finally(o)}async withRawResponse(){return await this.innerPromise}};function Fo(p,...o){if(!p)return"";if(o.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return Uc(p,...o)}let s=o[o.length-1]?.endsWith("/");for(let r of o){let a=Tc(r);a&&(i.pathname=vc(i.pathname,a))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return Uc(p,...o)}function Uc(p,...o){if(o.length===0)return p;let i=p,s=o[o.length-1]?.endsWith("/");for(let r of o){let a=Tc(r);a&&(i=vc(i,a))}return s&&!i.endsWith("/")&&(i+="/"),i}function vc(p,o){return p.endsWith("/")?p+o:`${p}/${o}`}function Tc(p){if(!p)return p;let o=0,i=p.length;return p.startsWith("/")&&(o=1),p.endsWith("/")&&(i=p.length-1),o===0&&i===p.length?p:p.slice(o,i)}var m={get:async p=>typeof p=="function"?p():p};async function Ja(p,o,i,t){let s=yo(i.logging),r,a=o;p instanceof Request?(r=p.url,o==null&&(a={method:p.method,headers:Object.fromEntries(p.headers.entries()),body:p.body,signal:p.signal,credentials:p.credentials,cache:p.cache,redirect:p.redirect,referrer:p.referrer,integrity:p.integrity,mode:p.mode})):r=p instanceof URL?p.toString():p;let d=(i.baseUrl!=null?await m.get(i.baseUrl):void 0)??(i.environment!=null?await m.get(i.environment):void 0),y;r.startsWith("http://")||r.startsWith("https://")?y=r:d!=null?y=Fo(d,r):y=r;let g={};if(i.headers!=null)for(let[F,A]of Object.entries(i.headers)){let Z=await qo.get(A,{endpointMetadata:{}});Z!=null&&(g[F.toLowerCase()]=`${Z}`)}if(i.getAuthHeaders!=null){let F=await i.getAuthHeaders();for(let[A,Z]of Object.entries(F))g[A.toLowerCase()]=Z}if(a?.headers!=null){let F=a.headers instanceof Headers?Object.fromEntries(a.headers.entries()):Array.isArray(a.headers)?Object.fromEntries(a.headers):a.headers;for(let[A,Z]of Object.entries(F))Z!=null&&(g[A.toLowerCase()]=Z)}if(t?.headers!=null)for(let[F,A]of Object.entries(t.headers))g[F.toLowerCase()]=A;let l=a?.method??"GET",h=a?.body,w=t?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,T=t?.maxRetries??i.maxRetries,O=t?.abortSignal??a?.signal??void 0,B=i.fetch??await zi();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:l,url:y,hasBody:h!=null});let j=await Si(async()=>Ri(B,y,l,g,h??void 0,U,O,a?.credentials==="include",void 0,!1),T);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:l,url:y,statusCode:j.status}),j}var Ko={};Pr(Ko,{ConsoleLogger:()=>go,LogLevel:()=>Qe,Logger:()=>wi,createLogger:()=>yo});var e={};Pr(e,{JsonError:()=>xi,ParseError:()=>Pi,any:()=>Wc,bigint:()=>kc,boolean:()=>Hc,booleanLiteral:()=>Lc,date:()=>Bc,discriminant:()=>il,enum_:()=>zo,forwardCompatibleEnum_:()=>jc,getObjectLikeUtils:()=>er,getObjectUtils:()=>mi,getSchemaUtils:()=>Y,isProperty:()=>Ur,lazy:()=>Ac,lazyObject:()=>Fc,list:()=>Wo,never:()=>Nc,number:()=>$c,object:()=>Go,objectWithoutOptionalProperties:()=>Ic,optional:()=>Ya,partialRecord:()=>Xc,property:()=>Dc,record:()=>Zc,set:()=>Qc,string:()=>Jc,stringLiteral:()=>Gc,transform:()=>Za,undiscriminatedUnion:()=>rl,union:()=>tl,unknown:()=>Yc,withParsedProperties:()=>en});var I={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function J(p,o){return`Expected ${o}. Received ${af(p)}.`}function af(p){if(Array.isArray(p))return"list";if(p===null)return"null";if(p instanceof BigInt)return"BigInt";switch(typeof p){case"string":return`"${p}"`;case"bigint":case"number":case"boolean":case"undefined":return`${p}`}return typeof p}function we(p){return{...p,json:Oc(p.json),parse:Oc(p.parse)}}function Oc(p){return(o,i)=>{let t=p(o,i),{skipValidation:s=!1}=i??{};return!t.ok&&s?(console.warn(["Failed to validate.",...t.errors.map(r=>" - "+(r.path.length>0?`${r.path.join(".")}: ${r.message}`:r.message))].join(`
|
|
3
|
-
`)),{ok:!0,value:o}):t}}function Lo(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var xi=class extends Error{constructor(i){super(i.map(Lo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var Pi=class extends Error{constructor(i){super(i.map(Lo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function Y(p){return{nullable:()=>nf(p),optional:()=>Ya(p),optionalNullable:()=>sf(p),transform:o=>Za(p,o),parseOrThrow:(o,i)=>{let t=p.parse(o,i);if(t.ok)return t.value;throw new Pi(t.errors)},jsonOrThrow:(o,i)=>{let t=p.json(o,i);if(t.ok)return t.value;throw new xi(t.errors)}}}function nf(p){let o={parse:(i,t)=>i==null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.NULLABLE};return{...o,...Y(o)}}function Ya(p){let o={parse:(i,t)=>i==null?{ok:!0,value:void 0}:p.parse(i,t),json:(i,t)=>t?.omitUndefined&&i===void 0?{ok:!0,value:void 0}:i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.OPTIONAL};return{...o,...Y(o)}}function sf(p){let o={parse:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.OPTIONAL_NULLABLE};return{...o,...Y(o)}}function Za(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);return r.ok?{ok:!0,value:o.transform(r.value)}:r},json:(t,s)=>{let r=o.untransform(t);return p.json(r,s)},getType:()=>p.getType()};return{...i,...Y(i)}}function kc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o=="bigint"?{ok:!0,value:o}:typeof o=="number"?{ok:!0,value:BigInt(o)}:{ok:!1,errors:[{path:i,message:J(o,"bigint | number")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="bigint"?{ok:!1,errors:[{path:i,message:J(o,"bigint")}]}:{ok:!0,value:o},getType:()=>I.BIGINT};return{...we(p),...Y(p)}}var cf=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Bc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:i,message:J(o,"string")}]}:cf.test(o)?{ok:!0,value:new Date(o)}:{ok:!1,errors:[{path:i,message:J(o,"ISO 8601 date string")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>o instanceof Date?{ok:!0,value:o.toISOString()}:{ok:!1,errors:[{path:i,message:J(o,"Date object")}]},getType:()=>I.DATE};return{...we(p),...Y(p)}}function ze(p,o){return()=>{let i={parse:o,json:o,getType:()=>p};return{...we(i),...Y(i)}}}function zo(p){let o=new Set(p);return ze(I.ENUM,(t,{allowUnrecognizedEnumValues:s,breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:J(t,"string")}]}:!o.has(t)&&!s?{ok:!1,errors:[{path:r,message:J(t,"enum")}]}:{ok:!0,value:t})()}function jc(p){return zo(p).transform({transform:o=>o,untransform:o=>o})}function Ac(p){let o=Xa(p);return{...o,...Y(o)}}function Xa(p){return{parse:(o,i)=>Ci(p).parse(o,i),json:(o,i)=>Ci(p).json(o,i),getType:()=>Ci(p).getType()}}function Ci(p){let o=p;return o.__zurg_memoized==null&&(o.__zurg_memoized=p()),o.__zurg_memoized}function Qa(p){return Object.entries(p)}function Ro(p,o){let i=new Set(o);return Object.entries(p).reduce((t,[s,r])=>(i.has(s)&&(t[s]=r),t),{})}function Er(p){if(typeof p!="object"||p===null)return!1;let o=Object.getPrototypeOf(p);return o===null?!0:Object.getPrototypeOf(o)===null}function fo(p){return Object.keys(p)}function Vc(p,o){let i=[],t=[];for(let s of p)o(s)?i.push(s):t.push(s);return[i,t]}var lf=Object.prototype.hasOwnProperty;function er(p){return{withParsedProperties:o=>en(p,o)}}function en(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);if(!r.ok)return r;let a={};for(let d in o)if(lf.call(o,d)){let y=o[d];a[d]=typeof y=="function"?y(r.value):y}return{ok:!0,value:{...r.value,...a}}},json:(t,s)=>{if(!Er(t))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(t,"object")}]};let r=new Set(Object.keys(o)),a=Ro(t,Object.keys(t).filter(d=>!r.has(d)));return p.json(a,s)},getType:()=>p.getType()};return{...i,...Y(i),...er(i)}}function Dc(p,o){return{rawKey:p,valueSchema:o,isProperty:!0}}function Ur(p){return p.isProperty}var pf=Object.prototype.hasOwnProperty;function Go(p){let o;function i(){if(o==null){o={};for(let[w,U]of Qa(p)){let T=Ur(U)?U.rawKey:w,O=Ur(U)?U.valueSchema:U;o[T]={rawKey:T,parsedKey:w,valueSchema:O}}}return o}let t,s,r,a;function d(){if(t==null){t=[],s=[];for(let[w,U]of Qa(p)){let T=Ur(U)?U.rawKey:w,O=Ur(U)?U.valueSchema:U;uf(O)&&(t.push(T),s.push(w))}r=new Set(t),a=new Set(s)}return t}function y(){return s==null&&d(),s}function g(){return r==null&&d(),r}function l(){return a==null&&d(),a}let h={_getRawProperties:()=>Object.entries(p).map(([w,U])=>Ur(U)?U.rawKey:w),_getParsedProperties:()=>fo(p),parse:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return qc({value:w,requiredKeys:d(),requiredKeysSet:g(),getProperty:O=>{let B=i()[O];if(B!=null)return{transformedKey:B.parsedKey,transform:j=>{let F=[...T,O];return B.valueSchema.parse(j,{...U,breadcrumbsPrefix:F})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return qc({value:w,requiredKeys:y(),requiredKeysSet:l(),getProperty:O=>{let B=p[O];if(B!=null)return Ur(B)?{transformedKey:B.rawKey,transform:j=>{let F=[...T,O];return B.valueSchema.json(j,{...U,breadcrumbsPrefix:F})}}:{transformedKey:O,transform:j=>{let F=[...T,O];return B.json(j,{...U,breadcrumbsPrefix:F})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},getType:()=>I.OBJECT};return{...we(h),...Y(h),...er(h),...mi(h)}}function qc({value:p,requiredKeys:o,requiredKeysSet:i,getProperty:t,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:a=[]}){if(!Er(p))return{ok:!1,errors:[{path:a,message:J(p,"object")}]};let d=o.length,y=[],g={};for(let l in p){if(!pf.call(p,l))continue;let h=p[l],w=t(l);if(w!=null){d>0&&i.has(l)&&d--;let U=w.transform(h);U.ok?g[w.transformedKey]=U.value:(g[l]=h,y.push(...U.errors))}else switch(s){case"fail":y.push({path:[...a,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":g[l]=h;break}}if(d>0)for(let l of o)l in p||y.push({path:a,message:`Missing required key "${l}"`});return y.length===0||r?{ok:!0,value:g}:{ok:!1,errors:y}}function mi(p){return{extend:o=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...o._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...o._getRawProperties()],parse:(t,s)=>Mc({extensionKeys:o._getRawProperties(),value:t,transformBase:r=>p.parse(r,s),transformExtension:r=>o.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Mc({extensionKeys:o._getParsedProperties(),value:t,transformBase:r=>p.json(r,s),transformExtension:r=>o.json(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.OBJECT};return{...i,...Y(i),...er(i),...mi(i)}},passthrough:()=>{let o=new Set(p._getRawProperties()),i=new Set(p._getParsedProperties()),t={_getParsedProperties:()=>p._getParsedProperties(),_getRawProperties:()=>p._getRawProperties(),parse:(s,r)=>{let a=p.parse(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let d={};if(typeof s=="object"&&s!=null)for(let[y,g]of Object.entries(s))o.has(y)||(d[y]=g);return{ok:!0,value:{...d,...a.value}}},json:(s,r)=>{let a=p.json(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let d={};if(typeof s=="object"&&s!=null)for(let[y,g]of Object.entries(s))i.has(y)||(d[y]=g);return{ok:!0,value:{...d,...a.value}}},getType:()=>I.OBJECT};return{...t,...Y(t),...er(t),...mi(t)}}}}function Mc({extensionKeys:p,value:o,transformBase:i,transformExtension:t,breadcrumbsPrefix:s=[]}){if(!Er(o))return{ok:!1,errors:[{path:s,message:J(o,"object")}]};let r=new Set(p),[a,d]=Vc(fo(o),l=>r.has(l)),y=i(Ro(o,d)),g=t(Ro(o,a));return y.ok&&g.ok?{ok:!0,value:{...y.value,...g.value}}:{ok:!1,errors:[...y.ok?[]:y.errors,...g.ok?[]:g.errors]}}function uf(p){return!df(p)}function df(p){switch(p.getType()){case I.ANY:case I.UNKNOWN:case I.OPTIONAL:case I.OPTIONAL_NULLABLE:return!0;default:return!1}}function Ic(p){return Go(p)}function Fc(p){let o={...Xa(p),_getRawProperties:()=>Ci(p)._getRawProperties(),_getParsedProperties:()=>Ci(p)._getParsedProperties()};return{...o,...Y(o),...er(o),...mi(o)}}function Wo(p){let o={parse:(i,t)=>Kc(i,(s,r)=>p.parse(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,t)=>Kc(i,(s,r)=>p.json(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>I.LIST};return{...we(o),...Y(o)}}function Kc(p,o){if(!Array.isArray(p))return{ok:!1,errors:[{message:J(p,"list"),path:[]}]};let i=[],t=[];for(let s=0;s<p.length;s++){let r=o(p[s],s);r.ok?i.push(r.value):t.push(...r.errors)}return t.length===0?{ok:!0,value:i}:{ok:!1,errors:t}}function Lc(p){return ze(I.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(i,`${p.toString()}`)}]})()}function Gc(p){return ze(I.STRING_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(i,`"${p}"`)}]})()}var Wc=ze(I.ANY,p=>({ok:!0,value:p}));var Hc=ze(I.BOOLEAN,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"boolean")}]});var Nc=ze(I.NEVER,(p,{breadcrumbsPrefix:o=[]}={})=>({ok:!1,errors:[{path:o,message:"Expected never"}]}));var $c=ze(I.NUMBER,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"number")}]});var Jc=ze(I.STRING,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"string")}]});var Yc=ze(I.UNKNOWN,p=>({ok:!0,value:p}));var mf=Object.prototype.hasOwnProperty;function Zc(p,o){let i={parse:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...we(i),...Y(i)}}function Xc(p,o){let i={parse:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...we(i),...Y(i)}}function Ho({value:p,isKeyNumeric:o,transformKey:i,transformValue:t,breadcrumbsPrefix:s=[]}){if(!Er(p))return{ok:!1,errors:[{path:s,message:J(p,"object")}]};let r={},a=[];for(let d in p){if(!mf.call(p,d))continue;let y=p[d];if(y===void 0)continue;let g=d;if(o){let w=d.length>0?Number(d):NaN;Number.isNaN(w)||(g=w)}let l=i(g),h=t(y,g);l.ok&&h.ok?r[l.value]=h.value:(l.ok||a.push(...l.errors),h.ok||a.push(...h.errors))}return a.length===0?{ok:!0,value:r}:{ok:!1,errors:a}}function Qc(p){let o=Wo(p),i={parse:(t,s)=>{let r=o.parse(t,s);return r.ok?{ok:!0,value:new Set(r.value)}:r},json:(t,s)=>t instanceof Set?o.json([...t],s):{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(t,"Set")}]},getType:()=>I.SET};return{...we(i),...Y(i)}}function rl(p){let o={parse:(i,t)=>el((s,r)=>s.parse(i,r),p,t),json:(i,t)=>el((s,r)=>s.json(i,r),p,t),getType:()=>I.UNDISCRIMINATED_UNION};return{...we(o),...Y(o)}}function el(p,o,i){let t=[];for(let[s,r]of o.entries()){let a=p(r,{...i,skipValidation:!1});if(a.ok)return a;for(let d of a.errors)t.push({path:d.path,message:`[Variant ${s}] ${d.message}`})}return{ok:!1,errors:t}}function il(p,o){return{parsedDiscriminant:p,rawDiscriminant:o}}var hf=Object.prototype.hasOwnProperty;function tl(p,o){let i=typeof p=="string"?p:p.rawDiscriminant,t=typeof p=="string"?p:p.parsedDiscriminant,s=zo(fo(o)),r={parse:(a,d)=>ol({value:a,discriminant:i,transformedDiscriminant:t,transformDiscriminantValue:y=>s.parse(y,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:y=>o[y],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(y,g)=>g.parse(y,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),json:(a,d)=>ol({value:a,discriminant:t,transformedDiscriminant:i,transformDiscriminantValue:y=>s.json(y,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],t]}),getAdditionalPropertiesSchema:y=>o[y],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(y,g)=>g.json(y,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),getType:()=>I.UNION};return{...we(r),...Y(r),...er(r)}}function ol({value:p,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:t,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:a,breadcrumbsPrefix:d=[]}){if(!Er(p))return{ok:!1,errors:[{path:d,message:J(p,"object")}]};let y=p[o],g={};for(let U in p)hf.call(p,U)&&U!==o&&(g[U]=p[U]);if(y==null)return{ok:!1,errors:[{path:d,message:`Missing discriminant ("${o}")`}]};let l=t(y);if(!l.ok)return{ok:!1,errors:l.errors};let h=s(l.value);if(h==null)return r?{ok:!0,value:{[i]:l.value,...g}}:{ok:!1,errors:[{path:[...d,o],message:"Unexpected discriminant value"}]};let w=a(g,h);return w.ok?{ok:!0,value:{[i]:y,...w.value}}:w}var u={};Pr(u,{encodePathParam:()=>al,join:()=>Fo,queryBuilder:()=>nl,toQueryString:()=>Cr});function al(p){if(p===null)return"null";switch(typeof p){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:p=String(p);break}return encodeURIComponent(p)}function nl(){return new rn}var rn=class{constructor(){this.parts=new Map}add(o,i,t){if(i==null)return this;let s=Cr({[o]:i},{arrayFormat:t?.style==="comma"?"comma":"repeat"});return s.length>0&&this.parts.set(o,s),this}addMany(o){if(o!=null)for(let[i,t]of Object.entries(o))this.add(i,t);return this}mergeAdditional(o){if(o!=null)for(let[i,t]of Object.entries(o)){if(t==null)continue;let s=Cr({[i]:t},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var on="apiKey",gf="X-Schematic-Api-Key",Ei=class p{constructor(o){this.options=o}static canCreate(o){return o?.[on]!=null}async getAuthRequest({endpointMetadata:o}={}){let i=await m.get(this.options[on]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[gf]:i}}}};(t=>{t.AUTH_SCHEME="ApiKeyAuth",t.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${on}' when initializing the client`;function i(s){return new t(s)}t.createInstance=i})(Ei||={});function f(...p){let o={};for(let[i,t]of p.filter(s=>s!=null).flatMap(s=>Object.entries(s))){let s=i.toLowerCase();t!=null?o[s]=t:s in o&&delete o[s]}return o}function yf(p){let o=f({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.7","User-Agent":"@schematichq/schematic-typescript-node/1.5.7","X-Fern-Runtime":_e.type,"X-Fern-Runtime-Version":_e.version},p?.headers);return{...p,logging:Ko.createLogger(p?.logging),headers:o}}function L(p){let o=yf(p);if(p.auth===!1)return o.authProvider=new yi,o;if(p.auth!=null){if(typeof p.auth=="function")return o.authProvider={getAuthRequest:p.auth},o;if(Fa(p.auth))return o.authProvider=p.auth,o;Object.assign(o,p.auth)}let i=wf(o);return o.authProvider??=new Ei(i),o}function wf(p){return{...p,authProvider:new yi}}var z={Default:"https://api.schematichq.com"};function E(p,o,i,t){switch(p.reason){case"non-json":throw new b({statusCode:p.statusCode,body:p.rawBody,rawResponse:o});case"body-is-null":throw new b({statusCode:p.statusCode,rawResponse:o});case"timeout":throw new pi(`Timeout exceeded when calling ${i} ${t}.`,{cause:p.cause});case"unknown":throw new b({message:p.errorMessage,rawResponse:o,cause:p.cause});default:throw new b({message:"Unknown error",rawResponse:o})}}var tn=e.object({lookup:e.record(e.string(),e.string())});var sl=e.stringLiteral("company");var cl=e.object({apiKeyId:e.property("api_key_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expiredAt:e.property("expired_at",e.date()),id:e.string(),resourceType:e.property("resource_type",sl),token:e.string(),updatedAt:e.property("updated_at",e.date())});var ll=e.object({data:cl,params:e.record(e.string(),e.unknown())});var an=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional()),readonly:e.boolean().optional()});var qr=e.enum_(["development","production","staging"]);var nn=e.object({environmentType:e.property("environment_type",qr),name:e.string()});var sn=e.object({description:e.string().optional(),name:e.string().optional(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional())});var cn=e.object({environmentType:e.property("environment_type",qr.optional()),name:e.string().optional()});var vr=e.enum_(["admin","member"]);var pl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),role:vr.optional()});var V=e.object({count:e.number().optional()});var ul=e.object({data:V,params:pl});var dl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var ml=e.object({data:V,params:dl});var Ue=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var hl=e.object({actorType:e.property("actor_type",Ue.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var gl=e.object({data:V,params:hl});var Ie=e.enum_(["active","created","pending"]);var Pe=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var No=e.object({id:e.string(),state:Ie,type:Pe});var $o=e.enum_(["admin","capture","read","write"]);var Ce=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",qr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var yl=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Ce.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:No.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional()),readonly:e.boolean(),scopes:e.list($o),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var wl=e.object({data:yl,params:e.record(e.string(),e.unknown())});var Ee=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Ce.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:No.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional()),readonly:e.boolean(),scopes:e.list($o),updatedAt:e.property("updated_at",e.date())});var bl=e.object({apiKeys:e.property("api_keys",e.list(Ee)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",qr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var zl=e.object({data:bl,params:e.record(e.string(),e.unknown())});var K=e.object({deleted:e.boolean().optional()});var Rl=e.object({data:K,params:e.record(e.string(),e.unknown())});var fl=e.object({data:K,params:e.record(e.string(),e.unknown())});var _l=e.enum_(["companies_edit","company_users_edit","components_edit","custom_plans_edit","data_exports_edit","features_edit","flag_rules_edit","flags_edit","overrides_edit","plan_billing_edit","plan_entitlements_edit","plan_versions_edit","plans_edit","webhooks_edit","webhooks_reveal_secret"]);var Mr=e.object({createdAt:e.property("created_at",e.date()),email:e.string().optional(),firstName:e.property("first_name",e.string().optional()),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),lastName:e.property("last_name",e.string().optional()),name:e.string().optional(),permissions:e.record(e.string(),e.list(_l)),role:vr.optional(),updatedAt:e.property("updated_at",e.date())});var Sl=e.object({data:Mr,params:e.record(e.string(),e.unknown())});var xl=e.object({data:Ee,params:e.record(e.string(),e.unknown())});var Pl=e.object({actorType:e.property("actor_type",Ue),apiKey:e.property("api_key",Ee.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Ce.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),reqBody:e.property("req_body",e.string().optional()),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respBody:e.property("resp_body",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var Cl=e.object({data:Pl,params:e.record(e.string(),e.unknown())});var El=e.object({data:Ce,params:e.record(e.string(),e.unknown())});var Ul=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",Ue),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(Ce),stripeUserId:e.property("stripe_user_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var vl=e.object({data:Ul,params:e.record(e.string(),e.unknown())});var Tl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),role:vr.optional()});var Ol=e.object({data:e.list(Mr),params:Tl});var kl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var Bl=e.object({data:e.list(Ee),params:kl});var jl=e.object({actorType:e.property("actor_type",Ue.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Jo=e.object({actorType:e.property("actor_type",Ue),apiKey:e.property("api_key",Ee.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Ce.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userName:e.property("user_name",e.string().optional())});var Al=e.object({data:e.list(Jo),params:jl});var Vl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var Dl=e.object({data:e.list(Ce),params:Vl});var ql=e.object({ok:e.boolean()});var Ml=e.object({data:ql,params:e.record(e.string(),e.unknown())});var Il=e.object({data:Ee,params:e.record(e.string(),e.unknown())});var Fl=e.object({data:Ce,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var ln=e.object({companyId:e.property("company_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),email:e.string(),externalId:e.property("external_id",e.string()),meta:e.record(e.string(),e.string()),name:e.string(),providerType:e.property("provider_type",k.optional())});var ar=e.enum_(["per_unit","tiered"]);var pe=e.enum_(["licensed","metered"]);var me=e.enum_(["graduated","volume"]);var Kl=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitDecimal:e.property("per_unit_decimal",e.string().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),priceExternalId:e.property("price_external_id",e.string()),providerType:e.property("provider_type",k.optional()),upTo:e.property("up_to",e.number().optional())});var pn=e.object({billingScheme:e.property("billing_scheme",ar),currency:e.string(),externalAccountId:e.property("external_account_id",e.string()),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceTiers:e.property("price_tiers",e.list(Kl)),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k.optional()),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",pe)});var un=e.object({externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean().optional()),name:e.string().optional(),price:e.number(),providerType:e.property("provider_type",k.optional())});var Ll=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),currency:e.string(),interval:e.string(),meterId:e.property("meter_id",e.string().optional()),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),quantity:e.number(),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),usageType:e.property("usage_type",pe)});var Gl=e.object({couponExternalId:e.property("coupon_external_id",e.string()),customerFacingCode:e.property("customer_facing_code",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var Ir=e.enum_(["cancel","subscribe"]);var dn=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodExternalId:e.property("default_payment_method_external_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(Gl),expiredAt:e.property("expired_at",e.date()),interval:e.string().optional(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number().optional()),periodStart:e.property("period_start",e.number().optional()),productExternalIds:e.property("product_external_ids",e.list(Ll)),providerType:e.property("provider_type",k.optional()),status:e.string().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Ir.optional())});var mn=e.object({amountOff:e.property("amount_off",e.number()),currency:e.string().optional(),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number()),externalId:e.property("external_id",e.string()),maxRedemptions:e.property("max_redemptions",e.number()),name:e.string(),percentOff:e.property("percent_off",e.number()),timesRedeemed:e.property("times_redeemed",e.number())});var Yo=e.enum_(["draft","open","paid","uncollectible","void"]);var hn=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number().optional()),externalId:e.property("external_id",e.string().optional()),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),startingBalance:e.property("starting_balance",e.number().optional()),status:Yo.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var gn=e.object({displayName:e.property("display_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalId:e.property("external_id",e.string()),providerType:e.property("provider_type",k.optional())});var yn=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string()),externalId:e.property("external_id",e.string()),paymentMethodType:e.property("payment_method_type",e.string())});var Wl=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",pe.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var Hl=e.object({data:V,params:Wl});var Nl=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var $l=e.object({data:V,params:Nl});var Jl=e.object({data:K,params:e.record(e.string(),e.unknown())});var Yl=e.object({data:K,params:e.record(e.string(),e.unknown())});var Zl=e.object({data:K,params:e.record(e.string(),e.unknown())});var Xl=e.object({data:K,params:e.record(e.string(),e.unknown())});var Ql=e.object({data:K,params:e.record(e.string(),e.unknown())});var ep=e.object({data:K,params:e.record(e.string(),e.unknown())});var rp=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",pe.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Ui=e.enum_(["day","month","one-time","year"]);var Zo=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var N=e.object({billingScheme:e.property("billing_scheme",ar),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:Ui,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterEventName:e.property("meter_event_name",e.string().optional()),meterEventPayloadKey:e.property("meter_event_payload_key",e.string().optional()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list(Zo)),productExternalId:e.property("product_external_id",e.string()),productId:e.property("product_id",e.string()),productName:e.property("product_name",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",me.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",pe)});var ip=e.object({data:e.list(N),params:rp});var op=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",pe.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var tp=e.object({data:e.list(N),params:op});var ap=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",pe.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var G=e.object({currency:e.string(),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),interval:Ui,intervalCount:e.property("interval_count",e.number()),nickname:e.string().optional(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),providerType:e.property("provider_type",k),scheme:ar});var nr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),prices:e.list(G),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionCount:e.property("subscription_count",e.number()),updatedAt:e.property("updated_at",e.date())});var np=e.object({data:e.list(nr),params:ap});var sp=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Xo=e.object({accountId:e.property("account_id",e.string()),amountOff:e.property("amount_off",e.number().optional()),currency:e.string().optional(),duration:e.string().optional(),durationInMonths:e.property("duration_in_months",e.number().optional()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),isActive:e.property("is_active",e.boolean()),maxRedemptions:e.property("max_redemptions",e.number().optional()),metadata:e.record(e.string(),e.unknown()),name:e.string(),percentOff:e.property("percent_off",e.number().optional()),providerType:e.property("provider_type",k),timesRedeemed:e.property("times_redeemed",e.number()),validFrom:e.property("valid_from",e.date().optional()),validUntil:e.property("valid_until",e.date().optional())});var cp=e.object({data:e.list(Xo),params:sp});var lp=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var pp=e.object({currency:e.string(),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),meteredUsage:e.property("metered_usage",e.boolean()),perUnitPrice:e.property("per_unit_price",e.number()),totalPrice:e.property("total_price",e.number())});var up=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),subscriptions:e.list(pp),updatedAt:e.property("updated_at",e.date())});var dp=e.object({data:e.list(up),params:lp});var mp=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional())});var De=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string().optional()),id:e.string(),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),providerType:e.property("provider_type",k),startingBalance:e.property("starting_balance",e.number()),status:Yo.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),updatedAt:e.property("updated_at",e.date()),url:e.string().optional()});var hp=e.object({data:e.list(De),params:mp});var gp=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var Qo=e.object({dispalyName:e.property("dispaly_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),providerType:e.property("provider_type",k)});var yp=e.object({data:e.list(Qo),params:gp});var wp=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var qe=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),customerExternalId:e.property("customer_external_id",e.string()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),paymentMethodType:e.property("payment_method_type",e.string()),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var bp=e.object({data:e.list(qe),params:wp});var zp=e.object({data:Xo,params:e.record(e.string(),e.unknown())});var Rp=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var fp=e.object({data:Rp,params:e.record(e.string(),e.unknown())});var _p=e.object({data:Qo,params:e.record(e.string(),e.unknown())});var Sp=e.object({data:G,params:e.record(e.string(),e.unknown())});var sr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),updatedAt:e.property("updated_at",e.date())});var xp=e.object({data:sr,params:e.record(e.string(),e.unknown())});var Pp=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Ir.optional())});var Cp=e.object({data:Pp,params:e.record(e.string(),e.unknown())});var Ep=e.object({data:De,params:e.record(e.string(),e.unknown())});var Up=e.object({data:qe,params:e.record(e.string(),e.unknown())});var wn=e.object({description:e.string().optional(),name:e.string()});var vp=e.object({bundleId:e.property("bundle_id",e.string())});var Tp=e.object({featureId:e.property("feature_id",e.string()),visible:e.boolean().optional()});var bn=e.object({entitlements:e.list(Tp).optional(),planId:e.property("plan_id",e.string())});var zn=e.object({customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(bn).optional()),orderedBundles:e.property("ordered_bundles",e.list(vp).optional()),orderedPlans:e.property("ordered_plans",e.list(bn).optional()),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var Rn=e.object({description:e.string().optional(),isDefault:e.property("is_default",e.boolean().optional()),name:e.string().optional()});var cr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),description:e.string().optional(),id:e.string(),isDefault:e.property("is_default",e.boolean()),name:e.string(),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Op=e.object({data:cr,params:e.record(e.string(),e.unknown())});var kp=e.object({data:K,params:e.record(e.string(),e.unknown())});var Bp=e.object({data:cr,params:e.record(e.string(),e.unknown())});var jp=e.object({bundleId:e.property("bundle_id",e.string())});var Ap=e.object({featureId:e.property("feature_id",e.string()),visible:e.boolean()});var fn=e.object({entitlements:e.list(Ap),planId:e.property("plan_id",e.string())});var Fr=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var W=e.enum_(["billing_periods","days"]);var Kr=e.enum_(["expire","none","rollover"]);var Vp=e.object({currency:e.string(),price:G.optional()});var ye=e.object({burnStrategy:e.property("burn_strategy",Fr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Vp)),defaultExpiryUnit:e.property("default_expiry_unit",W),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr),description:e.string(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:G.optional(),product:sr.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Oe=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var lr=e.enum_(["off","automatic","user_controlled"]);var Q=e.enum_(["duration","end_of_billing_period","end_of_next_billing_period","end_of_trial","no_expiry"]);var ke=e.enum_(["daily","every_6_months","monthly","quarterly","weekly","yearly"]);var Fe=e.enum_(["billing_period","first_of_month"]);var pr=e.enum_(["no_reset","plan_period"]);var ur=e.enum_(["fixed","per_license"]);var et=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Be=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",e.string().optional()),autoTopupAvailability:e.property("auto_topup_availability",lr),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Q.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:ye.optional(),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),creditPluralName:e.property("credit_plural_name",e.string().optional()),creditSingularName:e.property("credit_singular_name",e.string().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),licenseId:e.property("license_id",e.string().optional()),plan:et.optional(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",ke.optional()),resetStart:e.property("reset_start",Fe.optional()),resetType:e.property("reset_type",pr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number()),scaling:ur,updatedAt:e.property("updated_at",e.date())});var Ke=e.enum_(["schematic_managed","provider_managed","no_billing"]);var Le=e.enum_(["free","none","one_time","recurring"]);var rt=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var ae=e.enum_(["company","user"]);var he=e.enum_(["boolean","currency","date","number","string","url"]);var ge=e.object({createdAt:e.property("created_at",e.date()),displayName:e.property("display_name",e.string()),entityType:e.property("entity_type",ae),hierarchy:e.list(e.string()),id:e.string(),traitType:e.property("trait_type",he),updatedAt:e.property("updated_at",e.date())});var vi=e.object({companyCount:e.property("company_count",e.number()),environmentId:e.property("environment_id",e.string()),eventCount:e.property("event_count",e.number()),eventSubtype:e.property("event_subtype",e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),userCount:e.property("user_count",e.number())});var Ge=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var ue=e.enum_(["boolean","event","license","trait"]);var We=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ue),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var dr=e.stringLiteral("boolean");var Lr=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var Ti=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var H=e.enum_(["all_time","current_day","current_month","current_week"]);var $=e.enum_(["billing_cycle","first_of_month"]);var it=e.object({comparisonTrait:e.property("comparison_trait",ge.optional()),comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionGroupId:e.property("condition_group_id",e.string().optional()),conditionType:e.property("condition_type",Ti),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list(et),ruleId:e.property("rule_id",e.string()),trait:ge.optional(),traitEntityType:e.property("trait_entity_type",ae.optional()),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var Dp=e.object({conditions:e.list(it),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),ruleId:e.property("rule_id",e.string()),updatedAt:e.property("updated_at",e.date())});var Gr=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Oi=e.object({conditionGroups:e.property("condition_groups",e.list(Dp)),conditions:e.list(it),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Gr),updatedAt:e.property("updated_at",e.date()),value:e.boolean()});var qp=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:We.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",dr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Oi),updatedAt:e.property("updated_at",e.date())});var Wr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var He=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",vi.optional()),featureType:e.property("feature_type",ue),flags:e.list(qp),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Wr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:ge.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var Hr=e.object({id:e.string(),name:e.string()});var Nr=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",G.optional()),oneTimePrice:e.property("one_time_price",G.optional()),quarterlyPrice:e.property("quarterly_price",G.optional()),yearlyPrice:e.property("yearly_price",G.optional())});var Mp=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",N.optional()),quarterlyPrice:e.property("quarterly_price",N.optional()),yearlyPrice:e.property("yearly_price",N.optional())});var Re=e.enum_(["credit_burndown","overage","pay_as_you_go","pay_in_advance","tier"]);var oe=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var de=e.enum_(["amber","blue","blueGray","blueGreen","cyan","emerald","fuchsia","gray","green","indigo","lightBlue","lime","orange","pink","purple","red","redOrange","rose","sky","slate","teal","trueGray","violet","warmGray","yellow"]);var re=e.enum_(["plan","add_on"]);var mr=e.object({audienceType:e.property("audience_type",e.string().optional()),companyId:e.property("company_id",e.string().optional()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),description:e.string(),icon:de,id:e.string(),name:e.string(),planType:e.property("plan_type",re),updatedAt:e.property("updated_at",e.date())});var Ip=e.object({id:e.string(),key:e.string(),value:e.number()});var te=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Mp)),environmentId:e.property("environment_id",e.string()),feature:We.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),meteredMonthlyPrice:e.property("metered_monthly_price",N.optional()),meteredQuarterlyPrice:e.property("metered_quarterly_price",N.optional()),meteredYearlyPrice:e.property("metered_yearly_price",N.optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),plan:mr.optional(),planId:e.property("plan_id",e.string()),priceBehavior:e.property("price_behavior",Re.optional()),ruleId:e.property("rule_id",e.string()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageBasedProduct:e.property("usage_based_product",sr.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",ye.optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",ge.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe),warningTiers:e.property("warning_tiers",e.list(Ip))});var ki=e.enum_(["monthly","quarterly","yearly"]);var Fp=e.enum_(["published","draft","archived"]);var fe=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:de,id:e.string(),name:e.string(),originalPlanId:e.property("original_plan_id",e.string().optional()),planType:e.property("plan_type",re),status:Fp,updatedAt:e.property("updated_at",e.date()),version:e.number()});var hr=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),customPlanConfig:e.property("custom_plan_config",rt.optional()),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(te).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Be).optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",re),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var Kp=e.object({addOns:e.property("add_ons",e.list(hr)),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),orderedAddOns:e.property("ordered_add_ons",e.list(fn)),orderedBundles:e.property("ordered_bundles",e.list(jp)),orderedPlans:e.property("ordered_plans",e.list(fn)),plans:e.list(hr),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var Lp=e.object({data:Kp,params:e.record(e.string(),e.unknown())});var Gp=e.object({creditBundleIds:e.property("credit_bundle_ids",e.list(e.string()))});var Wp=e.object({data:Gp,params:e.record(e.string(),e.unknown())});var Hp=e.object({icon:e.string(),id:e.string(),name:e.string()});var Np=e.object({features:e.list(Hp)});var $p=e.object({data:Np,params:e.record(e.string(),e.unknown())});var Jp=e.object({planIds:e.property("plan_ids",e.list(e.string()))});var Yp=e.object({data:Jp,params:e.record(e.string(),e.unknown())});var Zp=e.object({isDefault:e.property("is_default",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Xp=e.object({data:e.list(cr),params:Zp});var Qp=e.object({data:cr,params:e.record(e.string(),e.unknown())});var eu=e.object({data:cr,params:e.record(e.string(),e.unknown())});var _n=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var Sn=e.object({companyId:e.property("company_id",e.string()),currency:e.string().optional(),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var $r=e.object({id:e.string(),value:e.string()});var ot=e.object({city:e.string(),country:e.string(),line1:e.string(),line2:e.string(),postalCode:e.property("postal_code",e.string()),state:e.string()});var ru=e.enum_(["ae_trn","au_abn","au_arn","br_cnpj","br_cpf","ca_bn","ca_gst_hst","ca_pst_bc","ca_pst_mb","ca_pst_sk","ca_qst","ch_uid","ch_vat","eu_vat","gb_vat","hk_br","id_npwp","il_vat","in_gst","jp_cn","jp_rn","jp_trn","kr_brn","mx_rfc","my_frp","my_itn","my_sst","no_vat","nz_gst","ph_tin","sa_vat","sg_gst","sg_uen","th_vat","tr_tin","tw_vat","us_ein","za_vat"]);var tt=e.object({type:ru,value:e.string()});var xn=e.object({address:ot.optional(),email:e.string().optional(),phone:e.string().optional(),taxId:e.property("tax_id",tt.optional()),values:e.list($r)});var Pn=e.object({trialEnd:e.property("trial_end",e.date().optional())});var Bi=e.object({billingScheme:e.property("billing_scheme",ar),billingThreshold:e.property("billing_threshold",e.number().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),meterId:e.property("meter_id",e.string().optional()),name:e.string(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list(Zo)),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionId:e.property("subscription_id",e.string()),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",pe)});var ji=e.object({amountOff:e.property("amount_off",e.number().optional()),couponId:e.property("coupon_id",e.string()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),discountExternalId:e.property("discount_external_id",e.string()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date()),subscriptionExternalId:e.property("subscription_external_id",e.string())});var _o=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(ji),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",De.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",qe.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(Bi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Ir.optional())});var iu=e.object({accountId:e.property("account_id",e.string()),capturedAtMax:e.property("captured_at_max",e.date()),capturedAtMin:e.property("captured_at_min",e.date()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",$),period:H,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var ou=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var tu=e.object({currency:e.string(),price:N.optional()});var at=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",Fr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(tu)),defaultExpiryUnit:e.property("default_expiry_unit",W),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),ledgerAuthority:e.property("ledger_authority",ou),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:N.optional(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),product:sr.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ai=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var au=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",lr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Q.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",W.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),companyAutoTopupAmount:e.property("company_auto_topup_amount",e.number().optional()),companyAutoTopupEnabled:e.property("company_auto_topup_enabled",e.boolean().optional()),companyAutoTopupThresholdCredits:e.property("company_auto_topup_threshold_credits",e.number().optional()),createdAt:e.property("created_at",e.date()),credit:at.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),licenseId:e.property("license_id",e.string().optional()),plan:Ai.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",ke.optional()),resetStart:e.property("reset_start",Fe.optional()),resetType:e.property("reset_type",pr),rolloverPercentage:e.property("rollover_percentage",e.number()),scaling:ur,singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Cn=e.object({addedOn:e.property("added_on",e.date().optional()),billingProductExternalId:e.property("billing_product_external_id",e.string().optional()),billingProductId:e.property("billing_product_id",e.string().optional()),description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),includedCreditGrants:e.property("included_credit_grants",e.list(au)),name:e.string(),planPeriod:e.property("plan_period",e.string().optional()),planPrice:e.property("plan_price",e.number().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var Vi=e.enum_(["on_payment","on_publish"]);var Tr=e.enum_(["active","expired","paid","pending"]);var Jr=e.object({activationStrategy:e.property("activation_strategy",Vi),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),daysUntilDue:e.property("days_until_due",e.number()),externalInvoiceId:e.property("external_invoice_id",e.string().optional()),id:e.string(),paidAt:e.property("paid_at",e.date().optional()),planId:e.property("plan_id",e.string()),publishedAt:e.property("published_at",e.date().optional()),sendInvoice:e.property("send_invoice",e.boolean()),status:Tr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var nt=e.object({createdAt:e.property("created_at",e.date()),entityType:e.property("entity_type",ae),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date())});var st=e.object({createdAt:e.property("created_at",e.date()),definition:nt.optional(),definitionId:e.property("definition_id",e.string()),entityId:e.property("entity_id",e.string()),entityType:e.property("entity_type",ae),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var ct=e.object({createdAt:e.property("created_at",e.date()),definition:ge.optional(),definitionId:e.property("definition_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var nu=e.object({key:e.string(),value:e.number()});var lt=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",oe),warningTiers:e.property("warning_tiers",e.list(nu).optional())});var su=e.enum_(["bool","date","int","string"]);var En=e.object({comparableType:e.property("comparable_type",su),entityType:e.property("entity_type",ae),id:e.string()});var pt=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",En.optional()),conditionType:e.property("condition_type",Ti),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",En.optional()),traitValue:e.property("trait_value",e.string())});var cu=e.object({conditions:e.list(pt)});var lu=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(cu)),conditions:e.list(pt),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Gr),value:e.boolean()});var ut=e.object({currency:e.string(),effectiveAfter:e.property("effective_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),fromPlanName:e.property("from_plan_name",e.string()),fromSubscriptionPrice:e.property("from_subscription_price",e.number()),id:e.string(),interval:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),toPlanId:e.property("to_plan_id",e.string()),toPlanName:e.property("to_plan_name",e.string())});var ee=e.object({addOns:e.property("add_ons",e.list(Cn)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",_o.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(_o)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(Jr)),defaultPaymentMethod:e.property("default_payment_method",qe.optional()),entitlements:e.list(lt),entityTraits:e.property("entity_traits",e.list(ct)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(st),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(iu),name:e.string(),paymentMethods:e.property("payment_methods",e.list(qe)),plan:Cn.optional(),plans:e.list(Ai),rules:e.list(lu),scheduledDowngrade:e.property("scheduled_downgrade",ut.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var dt=e.object({company:ee.optional(),success:e.boolean()});var pu=e.object({data:dt,params:e.record(e.string(),e.unknown())});var uu=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),confirmPaymentIntentClientSecret:e.property("confirm_payment_intent_client_secret",e.string().optional()),confirmPaymentIntentId:e.property("confirm_payment_intent_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),invoiceId:e.property("invoice_id",e.string().optional()),invoiceUrl:e.property("invoice_url",e.string().optional()),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Ir.optional())});var du=e.object({data:uu,params:e.record(e.string(),e.unknown())});var ve=e.enum_(["active","inactive"]);var Me=e.stringLiteral("fixed");var mu=e.object({currency:e.string(),price:G.optional()});var Ne=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",Me),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(mu)),expiryType:e.property("expiry_type",Q),expiryUnit:e.property("expiry_unit",W),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:G.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:ve,unitPrice:e.property("unit_price",G.optional()),updatedAt:e.property("updated_at",e.date())});var Di=e.object({definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),value:e.string().optional()});var qi=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(ji),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",De.optional()),paymentMethod:e.property("payment_method",qe.optional()),products:e.list(Bi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var hu=e.object({bundle:Ne.optional(),quantity:e.number(),total:e.number()});var je=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased","rollover"]);var gu=e.object({createdAt:e.property("created_at",e.date()),externalUserId:e.property("external_user_id",e.string()),externalUserName:e.property("external_user_name",e.string()),id:e.string(),note:e.string(),updatedAt:e.property("updated_at",e.date())});var $e=e.object({company:ee.optional(),companyId:e.property("company_id",e.string()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expirationDate:e.property("expiration_date",e.date().optional()),feature:We.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),notes:e.list(gu),ruleId:e.property("rule_id",e.string().optional()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),updatedAt:e.property("updated_at",e.date()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",ge.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe)});var Mi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",je),quantity:e.number()});var Ii=e.object({usageThisBillingPeriod:e.property("usage_this_billing_period",e.number().optional()),usageThisCalendarMonth:e.property("usage_this_calendar_month",e.number().optional()),usageThisWeek:e.property("usage_this_week",e.number().optional()),usageToday:e.property("usage_today",e.number().optional())});var Yr=e.enum_(["company_override","plan_entitlement","unknown"]);var Zr=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",oe),companyOverride:e.property("company_override",$e.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Mi).optional()),creditGrantReason:e.property("credit_grant_reason",je.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Ii.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Yr),feature:He.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:H.optional(),plan:mr.optional(),planEntitlement:e.property("plan_entitlement",te.optional()),priceBehavior:e.property("price_behavior",Re.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var Fi=e.object({features:e.list(Zr)});var be=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(te).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Be).optional()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",re),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var So=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),featureId:e.property("feature_id",e.string()),meteredPrice:e.property("metered_price",N.optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),priceBehavior:e.property("price_behavior",Re.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueType:e.property("value_type",oe),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var yu=e.object({activeAddOns:e.property("active_add_ons",e.list(be)),activePlan:e.property("active_plan",be.optional()),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(So)),availableCreditBundles:e.property("available_credit_bundles",e.list(Ne)),company:ee.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(Di)),featureUsage:e.property("feature_usage",Fi.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(hu)),selectedPlan:e.property("selected_plan",be.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(So)),subscription:qi.optional()});var wu=e.object({data:yu,params:e.record(e.string(),e.unknown())});var bu=e.object({city:e.string(),country:e.string(),line1:e.string(),line2:e.string(),postalCode:e.property("postal_code",e.string()),state:e.string()});var zu=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean())});var Ru=e.object({country:e.string(),id:e.string(),type:e.string(),value:e.string(),verificationStatus:e.property("verification_status",e.string().optional())});var mt=e.object({address:bu.optional(),checkoutSettings:e.property("checkout_settings",zu),customFields:e.property("custom_fields",e.list(Di)),email:e.string().optional(),phone:e.string().optional(),taxIds:e.property("tax_ids",e.list(Ru))});var fu=e.object({data:mt,params:e.record(e.string(),e.unknown())});var _u=e.object({data:dt,params:e.record(e.string(),e.unknown())});var Su=e.object({amountOff:e.property("amount_off",e.number().optional()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var xu=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var Pu=e.object({amountOff:e.property("amount_off",e.number()),discounts:e.list(Su),dueNow:e.property("due_now",e.number()),newCharges:e.property("new_charges",e.number()),percentOff:e.property("percent_off",e.number()),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),taxAmount:e.property("tax_amount",e.number().optional()),taxDisplayName:e.property("tax_display_name",e.string().optional()),taxRequireBillingDetails:e.property("tax_require_billing_details",e.boolean()),totalPerBillingPeriod:e.property("total_per_billing_period",e.number()),trialEnd:e.property("trial_end",e.date().optional()),upcomingInvoiceLineItems:e.property("upcoming_invoice_line_items",e.list(xu))});var ht=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:Pu.optional(),isScheduledDowngrade:e.property("is_scheduled_downgrade",e.boolean()),newCharges:e.property("new_charges",e.number()),optInRequired:e.property("opt_in_required",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),paymentMethodRequired:e.property("payment_method_required",e.boolean()),percentOff:e.property("percent_off",e.number()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),scheduledChangeTime:e.property("scheduled_change_time",e.date().optional()),trialEnd:e.property("trial_end",e.date().optional()),usageViolations:e.property("usage_violations",e.list(Zr))});var Cu=e.object({data:ht,params:e.record(e.string(),e.unknown())});var Eu=e.object({subscriptionChangePreview:e.property("subscription_change_preview",ht.optional())});var Uu=e.object({data:Eu,params:e.record(e.string(),e.unknown())});var vu=e.object({data:mt,params:e.record(e.string(),e.unknown())});var Tu=e.object({data:_o,params:e.record(e.string(),e.unknown())});var Un=e.object({displayName:e.property("display_name",e.string().optional()),entityType:e.property("entity_type",ae),hierarchy:e.list(e.string()),traitType:e.property("trait_type",he)});var vn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var Tn=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",he)});var Ou=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var On=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(Ou)});var Ae=e.enum_(["asc","desc"]);var Or=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var kr=e.enum_(["free","one_time","paid","trial"]);var ku=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",Ae.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(Or).optional()),subscriptionTypes:e.property("subscription_types",e.list(kr).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var Bu=e.object({data:V,params:ku});var ju=e.object({entityType:e.property("entity_type",ae.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Au=e.object({data:V,params:ju});var Vu=e.object({entityType:e.property("entity_type",ae.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",he.optional()),traitTypes:e.property("trait_types",e.list(he).optional())});var Du=e.object({data:V,params:Vu});var qu=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var Mu=e.object({data:V,params:qu});var Iu=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Fu=e.object({data:V,params:Iu});var Ku=e.object({data:ee,params:e.record(e.string(),e.unknown())});var gr=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ki=e.object({company:gr.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),id:e.string(),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string())});var Je=e.object({companyMemberships:e.property("company_memberships",e.list(Ki)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(ct)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(st),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date())});var Lu=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Gu=e.object({data:gr,params:e.record(e.string(),e.unknown())});var Wu=e.object({data:K,params:e.record(e.string(),e.unknown())});var Hu=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var Nu=e.object({data:K,params:Hu});var yr=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var $u=e.object({data:yr,params:e.record(e.string(),e.unknown())});var Ju=e.object({data:K,params:e.record(e.string(),e.unknown())});var Yu=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional()});var Zu=e.object({data:e.list(qi),params:Yu});var Xu=e.object({companyId:e.property("company_id",e.string().optional())});var Qu=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),company:gr.optional(),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(ji),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",De.optional()),paymentMethod:e.property("payment_method",qe.optional()),planName:e.property("plan_name",e.string()),products:e.list(Bi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var ed=e.object({data:e.list(Qu),params:Xu});var rd=e.object({companyId:e.property("company_id",e.string().optional())});var id=e.object({billingEntity:e.property("billing_entity",gr.optional()),hasOwnStripeCustomer:e.property("has_own_stripe_customer",e.boolean())});var od=e.object({data:e.list(id),params:rd});var td=e.object({data:ee,params:e.record(e.string(),e.unknown())});var ad=e.object({data:ge,params:e.record(e.string(),e.unknown())});var nd=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var sd=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var cd=e.object({data:e.list(sd),params:nd});var ld=e.object({data:Ki,params:e.record(e.string(),e.unknown())});var pd=e.object({data:ge,params:e.record(e.string(),e.unknown())});var gt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Ie,type:Pe,updatedAt:e.property("updated_at",e.date())});var Li=e.enum_(["checkout","company_upsert","fallback_plan","manage_plan","migration","plan_billing_product_changed","plan_deleted","plan_trait_change","plan_version_migration","quickstart","subscription_change"]);var Gi=e.enum_(["fallback","initial","trait","trial_expiry"]);var ud=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var xo=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var kn=e.object({id:e.string(),name:e.string(),version:e.number()});var dd=e.object({featureId:e.property("feature_id",e.string()),hierarchy:e.list(e.string()),reason:e.string(),traitId:e.property("trait_id",e.string()),traitName:e.property("trait_name",e.string()),traitType:e.property("trait_type",he),value:e.string()});var yt=e.object({action:Li,actorType:e.property("actor_type",Ue),addOnsAdded:e.property("add_ons_added",e.list(xo)),addOnsRemoved:e.property("add_ons_removed",e.list(xo)),apiKey:e.property("api_key",Ee.optional()),auditLog:e.property("audit_log",Jo.optional()),basePlan:e.property("base_plan",xo.optional()),basePlanAction:e.property("base_plan_action",Gi.optional()),basePlanVersion:e.property("base_plan_version",kn.optional()),company:gr.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),integration:gt.optional(),isVersionUpgrade:e.property("is_version_upgrade",e.boolean()),previousBasePlan:e.property("previous_base_plan",xo.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",kn.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",ud.optional()),traitsUpdated:e.property("traits_updated",e.list(dd)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var md=e.object({data:yt,params:e.record(e.string(),e.unknown())});var Wi=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),planId:e.property("plan_id",e.string()),planType:e.property("plan_type",e.string()),traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var hd=e.object({data:Wi,params:e.record(e.string(),e.unknown())});var gd=e.object({data:Je,params:e.record(e.string(),e.unknown())});var yd=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",Ae.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(Or).optional()),subscriptionTypes:e.property("subscription_types",e.list(kr).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var wd=e.object({data:e.list(ee),params:yd});var bd=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var zd=e.object({data:e.list(Ki),params:bd});var Rd=e.object({entityType:e.property("entity_type",ae.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fd=e.object({data:e.list(nt),params:Rd});var _d=e.object({entityType:e.property("entity_type",ae.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",he.optional()),traitTypes:e.property("trait_types",e.list(he).optional())});var Sd=e.object({data:e.list(ge),params:_d});var xd=e.object({action:Li.optional(),basePlanAction:e.property("base_plan_action",Gi.optional()),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),planIds:e.property("plan_ids",e.list(e.string()).optional())});var Pd=e.object({data:e.list(yt),params:xd});var Cd=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var Ed=e.object({data:e.list(Wi),params:Cd});var Ud=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var vd=e.object({data:e.list(Je),params:Ud});var Td=e.object({keys:e.record(e.string(),e.string()).optional()});var Od=e.object({data:ee,params:Td});var kd=e.object({keys:e.record(e.string(),e.string()).optional()});var Bd=e.object({data:Je,params:kd});var jd=e.object({data:ge,params:e.record(e.string(),e.unknown())});var Ad=e.object({data:e.list(Wi),params:e.record(e.string(),e.unknown())});var Vd=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Dd=e.object({data:ee,params:e.record(e.string(),e.unknown())});var qd=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Md=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Bn=e.object({catalogId:e.property("catalog_id",e.string().optional())});var Hi=e.enum_(["billing","entitlement"]);var jn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Hi),name:e.string()});var wt=e.enum_(["draft","live"]);var An=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Hi.optional()),name:e.string().optional(),state:wt.optional()});var Ye=e.object({ast:e.record(e.string(),e.number()).optional(),catalogId:e.property("catalog_id",e.string().optional()),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:wt,type:Hi,updatedAt:e.property("updated_at",e.date())});var Id=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Fd=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Kd=e.object({data:V,params:Fd});var Ld=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Gd=e.object({data:K,params:e.record(e.string(),e.unknown())});var Wd=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Hd=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Nd=e.object({data:e.list(Ye),params:Hd});var $d=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var Po=e.object({billingScheme:e.property("billing_scheme",ar),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:Ui,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",me.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",pe)});var Jd=e.object({currency:e.string(),price:N.optional()});var Yd=e.object({bundleType:e.property("bundle_type",Me),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(Jd)),expiryType:e.property("expiry_type",Q),expiryUnit:e.property("expiry_unit",W),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:Po.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:ve,unitPrice:e.property("unit_price",Po.optional()),updatedAt:e.property("updated_at",e.date())});var Zd=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var Xr=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var bt=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",lr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Q.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",W.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:at.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),licenseId:e.property("license_id",e.string().optional()),plan:Ai.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",ke.optional()),resetStart:e.property("reset_start",Fe.optional()),resetType:e.property("reset_type",pr),rolloverPercentage:e.property("rollover_percentage",e.number()),scaling:ur,singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Vn=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCanTrial:e.property("company_can_trial",e.boolean()),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Xr.optional()),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(te).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(bt)),invalidReason:e.property("invalid_reason",Zd.optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",re),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageViolations:e.property("usage_violations",e.list(Zr)),valid:e.boolean(),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var Qr=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var zt=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var Ni=e.enum_(["create_prorations","invoice_immediately"]);var Xd=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),prorationBehavior:e.property("proration_behavior",Ni),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean())});var Rt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var ei=e.enum_(["customer_archived","expired","integration_uninstalled","license_retired","manual","plan_change","plan_period_reset","reconciled"]);var Qd=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var em=e.object({billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),exhaustedAt:e.property("exhausted_at",e.date().optional()),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),grantReason:e.property("grant_reason",je),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),price:Po.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",ke.optional()),reserved:e.number().optional(),settled:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(Qd).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",ei.optional())});var rm=e.object({accountId:e.property("account_id",e.string().optional()),publishableKey:e.property("publishable_key",e.string().optional()),schematicPublishableKey:e.property("schematic_publishable_key",e.string()),setupIntentClientSecret:e.property("setup_intent_client_secret",e.string().optional())});var im=e.object({activeAddOns:e.property("active_add_ons",e.list(Vn)),activePlans:e.property("active_plans",e.list(Vn)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(So)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr)),capabilities:zt.optional(),checkoutSettings:e.property("checkout_settings",Xd),company:ee.optional(),component:Ye.optional(),creditBundles:e.property("credit_bundles",e.list(Yd)),creditGrants:e.property("credit_grants",e.list(em)),customCheckoutFields:e.property("custom_checkout_fields",e.list(Di)),defaultPlan:e.property("default_plan",be.optional()),displaySettings:e.property("display_settings",Rt),featureUsage:e.property("feature_usage",Fi.optional()),invoices:e.list(De),postTrialPlan:e.property("post_trial_plan",be.optional()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),scheduledDowngrade:e.property("scheduled_downgrade",ut.optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),stripeEmbed:e.property("stripe_embed",rm.optional()),subscription:qi.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",De.optional())});var om=e.object({data:im,params:$d});var tm=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Dn=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Xr.optional()),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(te).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(bt)),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",re),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var am=e.object({activeAddOns:e.property("active_add_ons",e.list(Dn)),activePlans:e.property("active_plans",e.list(Dn)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr)),capabilities:zt.optional(),displaySettings:e.property("display_settings",Rt),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var nm=e.object({data:am,params:e.record(e.string(),e.unknown())});var qn=e.object({companyId:e.property("company_id",e.string()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date().optional()),requestedAmount:e.property("requested_amount",e.number())});var ft=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var Mn=e.object({burnStrategy:e.property("burn_strategy",Fr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(ft).optional()),defaultExpiryUnit:e.property("default_expiry_unit",W.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var In=e.object({billingPeriodsCount:e.property("billing_periods_count",e.number().optional()),companyId:e.property("company_id",e.string()),creditId:e.property("credit_id",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),quantity:e.number(),reason:je,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",Fe.optional())});var _t=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var Fn=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",Me.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(_t).optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:ve.optional()});var Kn=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var Ln=e.object({burnStrategy:e.property("burn_strategy",Fr.optional()),currencyPrices:e.property("currency_prices",e.list(ft).optional()),defaultExpiryUnit:e.property("default_expiry_unit",W.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Gn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(_t).optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:ve.optional()});var Wn=e.object({reason:ei.optional()});var $i=e.object({companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date()),grantedAmount:e.property("granted_amount",e.number()),id:e.string(),releasedAt:e.property("released_at",e.date().optional()),updatedAt:e.property("updated_at",e.date())});var sm=e.object({data:$i,params:e.record(e.string(),e.unknown())});var cm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var lm=e.object({data:V,params:cm});var pm=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var um=e.object({data:V,params:pm});var dm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var mm=e.object({data:V,params:dm});var hi=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var hm=e.object({companyId:e.property("company_id",e.string().optional()),dir:Ae.optional(),limit:e.number().optional(),offset:e.number().optional(),order:hi.optional()});var gm=e.object({data:V,params:hm});var ym=e.object({bundleType:e.property("bundle_type",Me.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:ve.optional()});var wm=e.object({data:V,params:ym});var Br=e.enum_(["grant","transfer","usage","zero_out"]);var bm=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",Br.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var zm=e.object({data:V,params:bm});var Rm=e.object({data:ye,params:e.record(e.string(),e.unknown())});var fm=e.object({data:Be,params:e.record(e.string(),e.unknown())});var _m=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Sm=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var xm=e.object({data:K,params:Sm});var Pm=e.object({data:K,params:e.record(e.string(),e.unknown())});var Cm=e.object({data:$i,params:e.record(e.string(),e.unknown())});var Em=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Um=e.object({data:ye,params:e.record(e.string(),e.unknown())});var vm=e.object({data:Be,params:e.record(e.string(),e.unknown())});var Tm=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var ri=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",je),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),price:G.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",ke.optional()),reserved:e.number().optional(),settled:e.number().optional(),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(Tm).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",ei.optional())});var Om=e.object({data:ri,params:e.record(e.string(),e.unknown())});var km=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Bm=e.object({data:e.list(ye),params:km});var jm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var Am=e.object({data:e.list(Be),params:jm});var Vm=e.object({companyId:e.property("company_id",e.string().optional())});var Dm=e.object({creditId:e.property("credit_id",e.string()),remaining:e.number(),reserved:e.number(),settled:e.number(),source:k,total:e.number().optional()});var qm=e.object({data:e.list(Dm),params:Vm});var Mm=e.object({companyId:e.property("company_id",e.string().optional()),dir:Ae.optional(),limit:e.number().optional(),offset:e.number().optional(),order:hi.optional()});var Im=e.object({data:e.list(ri),params:Mm});var Fm=e.object({bundleType:e.property("bundle_type",Me.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:ve.optional()});var Km=e.object({data:e.list(Ne),params:Fm});var Lm=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",Br.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var Gm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Wm=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var Hm=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var Nm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var $m=e.object({amount:e.number(),autoTopupLogId:e.property("auto_topup_log_id",e.string().optional()),billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),company:Wm.optional(),companyId:e.property("company_id",e.string()),credit:Gm.optional(),creditName:e.property("credit_name",e.string()),environmentId:e.property("environment_id",e.string()),eventAt:e.property("event_at",e.date()),eventId:e.property("event_id",e.string()),eventType:e.property("event_type",Br),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:Nm.optional(),featureId:e.property("feature_id",e.string().optional()),fromGrantId:e.property("from_grant_id",e.string().optional()),grantExpiresAt:e.property("grant_expires_at",e.date().optional()),grantId:e.property("grant_id",e.string().optional()),grantQuantity:e.property("grant_quantity",e.number().optional()),grantQuantityRemaining:e.property("grant_quantity_remaining",e.number().optional()),grantReason:e.property("grant_reason",je.optional()),grantValidFrom:e.property("grant_valid_from",e.date().optional()),planId:e.property("plan_id",e.string().optional()),quantityConsumed:e.property("quantity_consumed",e.number().optional()),quantityRemainingAtZeroOut:e.property("quantity_remaining_at_zero_out",e.number().optional()),sourceId:e.property("source_id",e.number()),toGrantId:e.property("to_grant_id",e.string().optional()),usageEventId:e.property("usage_event_id",e.string().optional()),usageReason:e.property("usage_reason",Hm.optional()),zeroedOutReason:e.property("zeroed_out_reason",ei.optional())});var Jm=e.object({data:e.list($m),params:Lm});var Ym=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var Zm=e.object({data:e.list(ri),params:Ym});var Xm=e.object({data:$i,params:e.record(e.string(),e.unknown())});var Qm=e.object({data:K,params:e.record(e.string(),e.unknown())});var eh=e.object({data:ye,params:e.record(e.string(),e.unknown())});var rh=e.object({data:Be,params:e.record(e.string(),e.unknown())});var ih=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var oh=e.object({data:ri,params:e.record(e.string(),e.unknown())});var th=e.object({actorType:e.property("actor_type",e.string().optional()),endTime:e.property("end_time",e.date().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var ah=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string())),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),subscriptionStatuses:e.property("subscription_statuses",e.list(e.string()).optional()),subscriptionTypes:e.property("subscription_types",e.list(e.string()).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var St=e.union(e.discriminant("exportType","export_type"),{"audit-log":th,"company-feature-usage":ah}).transform({transform:p=>p,untransform:p=>p});var xt=e.enum_(["csv","csv.gz"]);var ii=e.enum_(["audit-log","company-feature-usage"]);var Hn=e.object({exportType:e.property("export_type",ii),metadata:St.optional(),outputFileType:e.property("output_file_type",xt)});var Ji=e.enum_(["failure","pending","success"]);var Yi=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),exportType:e.property("export_type",ii),id:e.string(),metadata:St.optional(),outputFileType:e.property("output_file_type",xt),status:Ji,updatedAt:e.property("updated_at",e.date())});var nh=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var sh=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var ch=e.object({exportType:e.property("export_type",ii.optional()),limit:e.number().optional(),offset:e.number().optional(),status:Ji.optional()});var lh=e.object({data:e.list(Yi),params:ch});var se=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var oi=e.object({currency:e.string(),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var ti=e.object({key:e.string(),value:e.number()});var Nn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingProvider:e.property("billing_provider",k),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),externalResourceId:e.property("external_resource_id",e.string()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var $n=e.object({companyId:e.property("company_id",e.string()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe)});var Jn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Yn=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var Zn=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe)});var Xn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var ph=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var uh=e.object({data:V,params:ph});var dh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var mh=e.object({data:V,params:dh});var hh=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var gh=e.object({data:V,params:hh});var yh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var wh=e.object({data:V,params:yh});var bh=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var zh=e.object({data:V,params:bh});var Rh=e.object({data:$e,params:e.record(e.string(),e.unknown())});var fh=e.object({data:te,params:e.record(e.string(),e.unknown())});var _h=e.object({data:K,params:e.record(e.string(),e.unknown())});var Sh=e.object({data:K,params:e.record(e.string(),e.unknown())});var Pt=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var xh=e.object({message:e.string()});var Ph=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(xh),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var Ch=e.object({data:e.list(te),issues:e.list(Pt),skipped:e.list(Ph)});var Eh=e.object({data:Ch,params:e.record(e.string(),e.unknown())});var Uh=e.object({data:$e,params:e.record(e.string(),e.unknown())});var vh=e.object({keys:e.record(e.string(),e.string()).optional()});var Th=e.object({data:Fi,params:vh});var rr=e.enum_(["daily","hourly","monthly","weekly"]);var Oh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:rr.optional(),startTime:e.property("start_time",e.date().optional())});var kh=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Yr),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional())});var Bh=e.object({periodEnd:e.property("period_end",e.date().optional()),periodStart:e.property("period_start",e.date().optional()),timestamp:e.date(),usage:e.number()});var jh=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",ue),limits:e.list(kh),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(Bh))});var Ah=e.object({data:jh,params:Oh});var Vh=e.object({data:te,params:e.record(e.string(),e.unknown())});var Dh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),startTime:e.property("start_time",e.date().optional())});var Ct=e.object({billingCreditId:e.property("billing_credit_id",e.string()),creditName:e.property("credit_name",e.string()),creditsUsed:e.property("credits_used",e.number()),share:e.number(),user:yr.optional(),userId:e.property("user_id",e.string().optional())});var Et=e.object({feature:We.optional(),lastSeen:e.property("last_seen",e.date()),share:e.number(),user:yr.optional(),userId:e.property("user_id",e.string().optional()),value:e.number()});var qh=e.object({credits:e.list(Ct),endTime:e.property("end_time",e.date()),rows:e.list(Et),startTime:e.property("start_time",e.date())});var Mh=e.object({data:qh,params:Dh});var Ih=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),startTime:e.property("start_time",e.date().optional()),userId:e.property("user_id",e.string().optional())});var Fh=e.object({creditsUsed:e.property("credits_used",e.number()),date:e.date()});var Kh=e.object({date:e.date(),feature:We.optional(),value:e.number()});var Lh=e.object({credits:e.list(Ct),dailyCreditPoints:e.property("daily_credit_points",e.list(Fh)),dailyPoints:e.property("daily_points",e.list(Kh)),endTime:e.property("end_time",e.date()),featureTotals:e.property("feature_totals",e.list(Et)),startTime:e.property("start_time",e.date()),user:yr.optional()});var Gh=e.object({data:Lh,params:Ih});var Wh=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var Hh=e.object({data:e.list($e),params:Wh});var Nh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var $h=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Mi).optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditTypeName:e.property("credit_type_name",e.string().optional()),creditUsed:e.property("credit_used",e.number().optional()),usageAggregation:e.property("usage_aggregation",Ii.optional())});var Jh=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",oe),company:ee.optional(),companyOverride:e.property("company_override",$e.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Mi).optional()),creditGrantReason:e.property("credit_grant_reason",je.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsage:e.property("credit_usage",$h.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Ii.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Yr),feature:He.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:H.optional(),plan:mr.optional(),planEntitlement:e.property("plan_entitlement",te.optional()),priceBehavior:e.property("price_behavior",Re.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var Yh=e.object({data:e.list(Jh),params:Nh});var Zh=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var Xh=e.object({data:e.list(Zr),params:Zh});var Qh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var wr=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:We.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",dr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:Mr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Oi),updatedAt:e.property("updated_at",e.date())});var Ze=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",sr.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",vi.optional()),featureType:e.property("feature_type",ue),flags:e.list(wr),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainer:Mr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Wr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:ge.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var eg=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",oe),company:ee.optional(),entitlementId:e.property("entitlement_id",e.string()),entitlementType:e.property("entitlement_type",Yr),feature:Ze.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),period:H.optional(),plan:mr.optional(),usage:e.number().optional(),user:yr.optional()});var rg=e.object({data:e.list(eg),params:Qh});var ig=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var og=e.object({data:e.list(te),params:ig});var tg=e.object({data:$e,params:e.record(e.string(),e.unknown())});var ag=e.object({data:te,params:e.record(e.string(),e.unknown())});var ng=e.object({data:te,params:e.record(e.string(),e.unknown())});var sg=e.object({companyId:e.property("company_id",e.string().optional()),error:e.string().optional(),flagId:e.property("flag_id",e.string().optional()),flagKey:e.property("flag_key",e.string()),reason:e.string(),reqCompany:e.property("req_company",e.record(e.string(),e.string()).optional()),reqUser:e.property("req_user",e.record(e.string(),e.string()).optional()),ruleId:e.property("rule_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var cg=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var lg=e.object({company:cg.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var pg=e.object({cachedInputTokens:e.property("cached_input_tokens",e.number().optional()),company:e.record(e.string(),e.string()),cost:e.string().optional(),currency:e.string().optional(),event:e.string().optional(),inputTokens:e.property("input_tokens",e.number()),operation:e.string().optional(),outputTokens:e.property("output_tokens",e.number()),provider:e.string(),reasoningTokens:e.property("reasoning_tokens",e.number().optional()),requestModel:e.property("request_model",e.string().optional()),requests:e.number().optional(),responseModel:e.property("response_model",e.string()),user:e.record(e.string(),e.string()).optional()});var ug=e.object({company:e.record(e.string(),e.string()).optional(),event:e.string(),leaseId:e.property("lease_id",e.string().optional()),quantity:e.number().optional(),traits:e.record(e.string(),e.unknown()).optional(),user:e.record(e.string(),e.string()).optional()});var Ut=e.undiscriminatedUnion([ug,sg,lg,pg]);var jr=e.enum_(["flag_check","identify","inference","track"]);var vt=e.object({backfill:e.boolean().optional(),body:Ut.optional(),eventType:e.property("event_type",jr),idempotencyKey:e.property("idempotency_key",e.string().optional()),sentAt:e.property("sent_at",e.date().optional()),trustedClientClock:e.property("trusted_client_clock",e.boolean().optional())});var Qn=e.object({events:e.list(vt)});var Tt=e.object({capturedAt:e.property("captured_at",e.date()),eventId:e.property("event_id",e.string().optional()),remoteAddr:e.property("remote_addr",e.string().optional()),remoteIp:e.property("remote_ip",e.string()),userAgent:e.property("user_agent",e.string())});var dg=e.object({events:e.list(Tt)});var mg=e.object({data:dg,params:e.record(e.string(),e.unknown())});var hg=e.object({data:Tt,params:e.record(e.string(),e.unknown())});var gg=e.enum_(["enriched","failed","pending","processed","unknown"]);var Ot=e.object({apiKey:e.property("api_key",e.string().optional()),apiKeyView:e.property("api_key_view",Ee.optional()),body:e.record(e.string(),e.unknown()),bodyPreview:e.property("body_preview",e.string()),capturedAt:e.property("captured_at",e.date()),company:Wr.optional(),companyId:e.property("company_id",e.string().optional()),enrichedAt:e.property("enriched_at",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),errorMessage:e.property("error_message",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string())),features:e.list(Wr),id:e.string(),idempotencyKey:e.property("idempotency_key",e.string().optional()),leaseId:e.property("lease_id",e.string().optional()),loadedAt:e.property("loaded_at",e.date().optional()),processedAt:e.property("processed_at",e.date().optional()),quantity:e.number(),sentAt:e.property("sent_at",e.date().optional()),status:gg,subtype:e.string().optional(),type:jr,updatedAt:e.property("updated_at",e.date().optional()),user:Wr.optional(),userId:e.property("user_id",e.string().optional())});var yg=e.object({data:Ot,params:e.record(e.string(),e.unknown())});var wg=e.object({eventSubtypes:e.property("event_subtypes",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var bg=e.object({data:e.list(vi),params:wg});var zg=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var Rg=e.object({data:zg,params:e.record(e.string(),e.unknown())});var fg=e.object({companyId:e.property("company_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),eventTypes:e.property("event_types",e.list(jr).optional()),flagId:e.property("flag_id",e.string().optional()),idempotencyKey:e.property("idempotency_key",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var _g=e.object({data:e.list(Ot),params:fg});var Co=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var es=e.object({contexts:e.list(Co)});var Zi=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",dr),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var rs=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),externalResourceId:e.property("external_resource_id",e.string()),featureType:e.property("feature_type",ue),flag:Zi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var is=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ue),flag:Zi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var os=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ue.optional()),flag:Zi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string().optional(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var kt=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",Ti),creditCost:e.property("credit_cost",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string().optional(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string().optional())});var Sg=e.object({conditions:e.list(kt),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var xg=e.object({conditionGroups:e.property("condition_groups",e.list(Sg)),conditions:e.list(kt),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Gr.optional()),value:e.boolean()});var ts=e.object({rules:e.list(xg)});var Bt=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:lt.optional(),error:e.string().optional(),featureAllocation:e.property("feature_allocation",e.number().optional()),featureUsage:e.property("feature_usage",e.number().optional()),featureUsageEvent:e.property("feature_usage_event",e.string().optional()),featureUsagePeriod:e.property("feature_usage_period",H.optional()),featureUsageResetAt:e.property("feature_usage_reset_at",e.date().optional()),flag:e.string(),flagId:e.property("flag_id",e.string().optional()),reason:e.string(),ruleId:e.property("rule_id",e.string().optional()),ruleType:e.property("rule_type",Gr.optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var Pg=e.object({data:Bt,params:e.record(e.string(),e.unknown())});var Cg=e.object({remaining:e.number(),reserved:e.number(),settled:e.number()});var Eg=e.enum_(["active","converted","expired"]);var Ug=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",Eg.optional())});var jt=e.object({creditBalances:e.property("credit_balances",e.record(e.string(),Cg).optional()),flags:e.list(Bt),plan:Ug.optional()});var vg=e.object({data:e.list(jt)});var Tg=e.object({data:vg,params:e.record(e.string(),e.unknown())});var Og=e.object({data:jt,params:e.record(e.string(),e.unknown())});var kg=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(ue).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var Bg=e.object({data:V,params:kg});var jg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ag=e.object({data:V,params:jg});var Vg=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Dg=e.object({data:wr,params:e.record(e.string(),e.unknown())});var qg=e.object({data:K,params:e.record(e.string(),e.unknown())});var Mg=e.object({data:K,params:e.record(e.string(),e.unknown())});var Ig=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Fg=e.object({data:wr,params:e.record(e.string(),e.unknown())});var Kg=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(ue).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var Lg=e.object({data:e.list(Ze),params:Kg});var Gg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Wg=e.object({data:e.list(wr),params:Gg});var Hg=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Ng=e.object({data:wr,params:e.record(e.string(),e.unknown())});var $g=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",dr),id:e.string(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Jg=e.object({flag:$g.optional(),rules:e.list(Oi)});var Yg=e.object({data:Jg,params:e.record(e.string(),e.unknown())});var Zg=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Xg=e.object({limit:e.number().optional()});var Qg=e.object({actorName:e.property("actor_name",e.string()),method:e.string(),resourceName:e.property("resource_name",e.string()),resourceType:e.property("resource_type",e.string()),timestamp:e.date(),title:e.string()});var ey=e.object({entries:e.list(Qg)});var ry=e.object({data:ey,params:Xg});var iy=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:rr.optional(),startTime:e.property("start_time",e.date().optional())});var At=e.object({timestamp:e.date(),usage:e.number()});var oy=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(At)});var ty=e.object({data:oy,params:iy});var ay=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:rr.optional(),startTime:e.property("start_time",e.date().optional())});var ny=e.object({featureId:e.property("feature_id",e.string()),points:e.list(At),traitDefinitionId:e.property("trait_definition_id",e.string())});var sy=e.object({data:ny,params:ay});var cy=e.object({months:e.number().optional()});var ly=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var py=e.object({points:e.list(ly)});var uy=e.object({data:py,params:cy});var dy=e.object({amount:e.number(),currency:e.string()});var my=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(dy),paidCompanies:e.property("paid_companies",e.number()),totalCompanies:e.property("total_companies",e.number()),totalFeatures:e.property("total_features",e.number()),totalPlans:e.property("total_plans",e.number())});var hy=e.object({data:my,params:e.record(e.string(),e.unknown())});var gy=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var yy=e.object({changePct:e.property("change_pct",e.number().optional()),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string()),pluralName:e.property("plural_name",e.string().optional()),priorUsage:e.property("prior_usage",e.number()),usage:e.number()});var wy=e.object({features:e.list(yy)});var by=e.object({data:wy,params:gy});var Xi=e.enum_(["billing_meta_object","manual_upsert"]);var as=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Xi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var Vt=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var zy=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Ry=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var fy=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var _y=e.object({accountId:e.property("account_id",e.string().optional()),accountName:e.property("account_name",e.string().optional()),companyUpdateOnly:e.property("company_update_only",e.boolean().optional()),isSandbox:e.property("is_sandbox",e.boolean()),liveMode:e.property("live_mode",e.boolean()),onboardUrl:e.property("onboard_url",e.string().optional())});var Sy=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Dt=e.union("type",{clerk:zy,metronome:Ry,orb:fy,stripe:_y,workos:Sy}).transform({transform:p=>p,untransform:p=>p});var xy=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Xi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:Dt.optional(),createdAt:e.property("created_at",e.date()),id:e.string(),integrationId:e.property("integration_id",e.string()),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),liveMode:e.property("live_mode",e.boolean()),updatedAt:e.property("updated_at",e.date())});var Qi=e.object({capabilities:Vt,config:xy,integration:gt});var Py=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var Cy=e.object({type:Pe,url:e.string()});var Ey=e.object({data:Cy,params:e.record(e.string(),e.unknown())});var Uy=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var vy=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var Ty=e.object({billingOnly:e.property("billing_only",e.boolean().optional()),excludeIds:e.property("exclude_ids",e.list(e.string()).optional()),id:e.string().optional(),limit:e.number().optional(),offset:e.number().optional(),state:Ie.optional(),type:Pe.optional()});var Oy=e.object({capabilities:Vt,config:Dt.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),lastWebhookReceivedAt:e.property("last_webhook_received_at",e.date().optional()),state:Ie,type:Pe});var ky=e.object({data:e.list(Oy),params:Ty});var By=e.object({keys:e.list(e.string())});var jy=e.object({data:By,params:e.record(e.string(),e.unknown())});var qt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Ie,type:Pe,updatedAt:e.property("updated_at",e.date())});var Ay=e.object({data:qt,params:e.record(e.string(),e.unknown())});var Vy=e.object({data:qt,params:e.record(e.string(),e.unknown())});var Dy=e.object({data:K,params:e.record(e.string(),e.unknown())});var qy=e.object({featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var My=e.object({data:V,params:qy});var Mt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Iy=e.object({data:Mt,params:e.record(e.string(),e.unknown())});var Fy=e.object({featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Ky=e.object({data:e.list(Mt),params:Fy});var Ly=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:de.optional(),name:e.string()});var It=e.stringLiteral("credit");var Ft=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",It.optional()),autoTopupAvailability:e.property("auto_topup_availability",lr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Q.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),licenseId:e.property("license_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",ke),resetStart:e.property("reset_start",Fe),resetType:e.property("reset_type",pr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional()),scaling:ur.optional()});var Gy=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var Kt=e.enum_(["create","update","delete"]);var Lt=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",It.optional()),autoTopupAvailability:e.property("auto_topup_availability",lr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Q.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),licenseId:e.property("license_id",e.string().optional()),resetCadence:e.property("reset_cadence",ke),resetStart:e.property("reset_start",Fe),resetType:e.property("reset_type",pr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional()),scaling:ur.optional()});var eo=e.object({action:Kt,createReq:e.property("create_req",Ft.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",Gy.optional()),updateReq:e.property("update_req",Lt.optional())});var Wy=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",oe),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var ro=e.object({action:Kt,entitlementId:e.property("entitlement_id",e.string().optional()),req:Wy.optional()});var Hy=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",e.number().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional())});var ai=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Ke.optional()),chargeType:e.property("charge_type",Le),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Hy).optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",e.number().optional()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),quarterlyPriceId:e.property("quarterly_price_id",e.string().optional()),trialDays:e.property("trial_days",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var ns=e.object({billingProduct:e.property("billing_product",ai.optional()),creditGrants:e.property("credit_grants",e.list(eo).optional()),entitlements:e.list(ro),plan:Ly.optional()});var Gt=e.object({description:e.string(),icon:de.optional(),name:e.string(),planType:e.property("plan_type",re)});var ss=e.object({billingProduct:e.property("billing_product",ai.optional()),creditGrants:e.property("credit_grants",e.list(eo).optional()),entitlements:e.list(ro),plan:Gt.optional()});var Wt=e.object({description:e.string().optional(),icon:de.optional(),name:e.string()});var cs=e.object({billingProduct:e.property("billing_product",ai.optional()),creditGrants:e.property("credit_grants",e.list(eo).optional()),entitlements:e.list(ro),plan:Wt.optional(),planVersionId:e.property("plan_version_id",e.string().optional())});var Ht=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Ke),chargeType:e.property("charge_type",Le),controlledBy:e.property("controlled_by",k),environmentId:e.property("environment_id",e.string()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),planId:e.property("plan_id",e.string()),trialDays:e.property("trial_days",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var io=e.object({billingProduct:e.property("billing_product",Ht.optional()),creditGrants:e.property("credit_grants",e.list(Be).optional()),entitlements:e.list(te).optional(),plan:mr.optional()});var Ny=e.object({data:io,params:e.record(e.string(),e.unknown())});var $y=e.object({data:io,params:e.record(e.string(),e.unknown())});var Jy=e.object({data:io,params:e.record(e.string(),e.unknown())});var Nt=e.object({definitionId:e.property("definition_id",e.string().optional()),helperText:e.property("helper_text",e.string().optional()),id:e.string().optional(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string())});var Yy=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var Ar=e.object({entitlements:e.list(Yy).optional(),planId:e.property("plan_id",e.string())});var oo=e.object({bundleId:e.string()});var $t=e.enum_(["end_of_billing_period","none"]);var ls=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(Nt).optional()),customPlanConfig:e.property("custom_plan_config",Xr.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(Ar)),orderedBundleList:e.property("ordered_bundle_list",e.list(oo)),orderedPlans:e.property("ordered_plans",e.list(Ar)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Ni),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",$t.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var ps=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(Nt).optional()),customPlanConfig:e.property("custom_plan_config",Xr.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(Ar)),orderedBundleList:e.property("ordered_bundle_list",e.list(oo)),orderedPlans:e.property("ordered_plans",e.list(Ar)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Ni),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",$t.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Jt=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional())});var Zy=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Yt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Zt=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Zy)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",Jt),componentSettings:e.property("component_settings",Yt),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnIds:e.property("ordered_add_on_ids",e.list(Ar)),planIds:e.property("plan_ids",e.list(Ar)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Xy=e.object({data:Zt,params:e.record(e.string(),e.unknown())});var Qy=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var ew=e.object({createdAt:e.property("created_at",e.date()),definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),position:e.number(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),traitHierarchy:e.property("trait_hierarchy",e.list(e.string())),updatedAt:e.property("updated_at",e.date())});var rw=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var us=e.object({entitlements:e.list(rw).optional(),planId:e.property("plan_id",e.string())});var iw=e.object({addOns:e.property("add_ons",e.list(hr)),checkoutSettings:e.property("checkout_settings",Jt),componentSettings:e.property("component_settings",Yt),customCheckoutFields:e.property("custom_checkout_fields",e.list(ew)),customPlanConfig:e.property("custom_plan_config",rt.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",hr.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",hr.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",hr.optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPrice:e.property("initial_plan_price",N.optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnList:e.property("ordered_add_on_list",e.list(us)),orderedBundleList:e.property("ordered_bundle_list",e.list(oo)),orderedPlanList:e.property("ordered_plan_list",e.list(us)),plans:e.list(hr),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlan:e.property("trial_expiry_plan",hr.optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPrice:e.property("trial_expiry_plan_price",N.optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var ow=e.object({data:iw,params:Qy});var tw=e.object({data:Zt,params:e.record(e.string(),e.unknown())});var to=e.enum_(["immediate","leave"]);var ds=e.object({companyIds:e.property("company_ids",e.list(e.string())),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),strategy:to,targetPlanType:e.property("target_plan_type",re)});var ms=e.object({companyIds:e.property("company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),targetPlanType:e.property("target_plan_type",re)});var Xt=e.enum_(["ambiguous_subscription_item","multiple_subscriptions","no_price_for_interval","not_on_origin_version","operation_item_not_found","permanent_config","permanent_decline","transient_decline","transient_infra","transient_stripe","unknown","would_leave_empty_subscription"]);var hs=e.object({errorCodes:e.property("error_codes",e.list(Xt))});var Vr=e.enum_(["completed","failed","in_progress","pending","skipped"]);var aw=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Vr.optional()});var nw=e.object({data:V,params:aw});var Dr=e.enum_(["completed","failed","in_progress","pending"]);var sw=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Dr.optional()});var cw=e.object({data:V,params:sw});var ni=e.object({completedAt:e.property("completed_at",e.date().optional()),completedCompanies:e.property("completed_companies",e.number()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),failedCompanies:e.property("failed_companies",e.number()),id:e.string(),planId:e.property("plan_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),skippedCompanies:e.property("skipped_companies",e.number()),startedAt:e.property("started_at",e.date().optional()),status:Dr,strategy:to,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var lw=e.object({data:ni,params:e.record(e.string(),e.unknown())});var pw=e.object({data:ni,params:e.record(e.string(),e.unknown())});var uw=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Vr.optional()});var Qt=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),errorCode:e.property("error_code",Xt.optional()),id:e.string(),migrationId:e.property("migration_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),startedAt:e.property("started_at",e.date().optional()),status:Vr,updatedAt:e.property("updated_at",e.date())});var dw=e.object({data:e.list(Qt),params:uw});var mw=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Dr.optional()});var hw=e.object({data:e.list(ni),params:mw});var gw=e.object({companyId:e.property("company_id",e.string()),hasBillingChanges:e.property("has_billing_changes",e.boolean()),hasCustomPricing:e.property("has_custom_pricing",e.boolean()),note:e.string().optional(),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),willUpdateSubscription:e.property("will_update_subscription",e.boolean())});var yw=e.object({companies:e.list(gw)});var ww=e.object({data:yw,params:e.record(e.string(),e.unknown())});var bw=e.object({data:Qt,params:e.record(e.string(),e.unknown())});var zw=e.object({data:ni,params:e.record(e.string(),e.unknown())});var gs=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),externalResourceId:e.property("external_resource_id",e.string()),externalResourceVersion:e.property("external_resource_version",e.string().optional()),icon:de.optional(),name:e.string(),planType:e.property("plan_type",re)});var ys=e.object({companyId:e.property("company_id",e.string()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),description:e.string(),icon:de.optional(),name:e.string()});var ws=e.object({activationStrategy:e.property("activation_strategy",Vi.optional()),address:ot.optional(),couponExternalId:e.property("coupon_external_id",e.string().optional()),customFieldValues:e.property("custom_field_values",e.list($r).optional()),customerEmail:e.property("customer_email",e.string().optional()),daysUntilDue:e.property("days_until_due",e.number().optional()),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),migrationStrategy:e.property("migration_strategy",to),phone:e.string().optional(),sendInvoice:e.property("send_invoice",e.boolean().optional()),taxId:e.property("tax_id",tt.optional())});var bs=e.object({activationStrategy:e.property("activation_strategy",Vi.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional()),sendInvoice:e.property("send_invoice",e.boolean().optional())});var zs=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var Rw=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var fw=e.object({data:V,params:Rw});var _w=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",re.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var Sw=e.object({data:V,params:_w});var xw=e.object({data:be,params:e.record(e.string(),e.unknown())});var Pw=e.object({data:be,params:e.record(e.string(),e.unknown())});var Cw=e.object({data:K,params:e.record(e.string(),e.unknown())});var Ew=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var Uw=e.object({data:K,params:Ew});var vw=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var Tw=e.object({data:be,params:vw});var Ow=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var kw=e.object({data:e.list(ee),params:Ow});var Bw=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),status:Tr.optional(),statuses:e.list(Tr).optional()});var jw=e.object({data:e.list(Jr),params:Bw});var Aw=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var Vw=e.object({data:e.list(Pt),params:Aw});var Dw=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",re.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var qw=e.object({data:e.list(be),params:Dw});var Mw=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Iw=e.object({data:fe,params:e.record(e.string(),e.unknown())});var Fw=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Kw=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Lw=e.object({data:be,params:e.record(e.string(),e.unknown())});var Gw=e.object({data:Ht,params:e.record(e.string(),e.unknown())});var Ww=e.object({data:be,params:e.record(e.string(),e.unknown())});var Rs=e.object({companyId:e.property("company_id",e.string()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),toPlanId:e.property("to_plan_id",e.string())});var si=e.enum_(["cancelled","error","executing","pending","success"]);var fs=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:si.optional()});var ci=e.object({actorType:e.property("actor_type",e.string()),companyId:e.property("company_id",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),errorMessage:e.property("error_message",e.string().optional()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),id:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),startedAt:e.property("started_at",e.date().optional()),status:si,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var Hw=e.object({data:ci,params:e.record(e.string(),e.unknown())});var Nw=e.object({data:ci,params:e.record(e.string(),e.unknown())});var $w=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:si.optional()});var Jw=e.object({data:e.list(ci),params:$w});var Yw=e.object({data:ci,params:e.record(e.string(),e.unknown())});var ao=e.object({creditId:e.property("credit_id",e.string())});var no=e.object({featureId:e.property("feature_id",e.string())});var br=e.enum_(["subscription.trial.ended","company.created","company.deleted","company.override.created","company.override.deleted","company.override.expired","company.override.updated","company.plan_changed","company.scheduled_downgrade","company.updated","credit.limit.reached","credit.limit.warning","credit.purchase.success","entitlement.limit.reached","entitlement.limit.warning","entitlement.soft_limit.reached","entitlement.soft_limit.warning","entitlement.tier_limit.reached","entitlement.tier_limit.warning","feature.created","feature.deleted","feature.updated","flag.created","flag.deleted","flag_rules.updated","flag.updated","plan.created","plan.deleted","plan.entitlement.created","plan.entitlement.deleted","plan.entitlement.updated","plan.updated","plan_version.deleted","rule.deleted","test.send","user.created","user.deleted","user.updated","auto.topup.hard.failure","auto.topup.retry.exceeded","auto.topup.success"]);var _s=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(ao).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(no).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(br)),url:e.string()});var Ss=e.object({requestType:e.property("request_type",br)});var ea=e.enum_(["active","inactive"]);var xs=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(ao).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(no).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(br).optional()),status:ea.optional(),url:e.string().optional()});var Zw=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var Xw=e.object({data:V,params:Zw});var Qw=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var eb=e.object({data:V,params:Qw});var zr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(ao).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(no).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(br)),secret:e.string(),status:ea,updatedAt:e.property("updated_at",e.date()),url:e.string()});var rb=e.object({data:zr,params:e.record(e.string(),e.unknown())});var ib=e.object({data:K,params:e.record(e.string(),e.unknown())});var ob=e.enum_(["failure","pending","success"]);var ra=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",br),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:ob,updatedAt:e.property("updated_at",e.date()),webhook:zr.optional(),webhookId:e.property("webhook_id",e.string())});var tb=e.object({data:ra,params:e.record(e.string(),e.unknown())});var ab=e.object({data:zr,params:e.record(e.string(),e.unknown())});var nb=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var sb=e.object({data:e.list(ra),params:nb});var cb=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var lb=e.object({data:e.list(zr),params:cb});var pb=e.object({responseCode:e.property("response_code",e.number()),success:e.boolean()});var ub=e.object({data:pb,params:e.record(e.string(),e.unknown())});var db=e.object({data:zr,params:e.record(e.string(),e.unknown())});var n=e.object({error:e.string()});var mb=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var hb=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),planCreditGrantId:e.property("plan_credit_grant_id",e.string())});var ia=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var oa=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Ps=e.object({addOnIds:e.property("add_on_ids",e.list(mb)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(hb)),billingEntityId:e.property("billing_entity_id",e.string().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(ia)),customFieldValues:e.property("custom_field_values",e.list($r)),newPlanId:e.property("new_plan_id",e.string()),newPriceId:e.property("new_price_id",e.string()),optInAccepted:e.property("opt_in_accepted",e.boolean().optional()),payInAdvance:e.property("pay_in_advance",e.list(oa)),paymentMethodId:e.property("payment_method_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),skipTrial:e.property("skip_trial",e.boolean())});var Cs=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",dr),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var ta=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Xi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:e.record(e.string(),e.unknown()).optional(),isSandbox:e.property("is_sandbox",e.boolean().optional()),liveMode:e.property("live_mode",e.boolean().optional()),type:Pe});var Es=e.object({keys:e.record(e.string(),e.string())});var gb=e.object({planId:e.property("plan_id",e.string()),priceId:e.property("price_id",e.string().optional()),versionId:e.property("version_id",e.string().optional())});var Us=e.object({addOnSelections:e.property("add_on_selections",e.list(gb)),basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),basePlanVersionId:e.property("base_plan_version_id",e.string().optional()),billingEntityId:e.property("billing_entity_id",e.string().optional()),cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(ia)),customFieldValues:e.property("custom_field_values",e.list($r)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(oa)),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),prorate:e.boolean().optional(),trialEnd:e.property("trial_end",e.date().optional())});var yb=e.record(e.string(),e.unknown());var wb=e.record(e.string(),e.unknown());var bb=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var so=e.enum_(["all_time","current_day","current_month","current_week"]);var co=e.enum_(["billing_cycle","first_of_month"]);var zb=e.object({key:e.string(),value:e.number()});var aa=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",so.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",co.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",bb),warningTiers:e.property("warning_tiers",e.list(zb).optional())});var Rb=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var na=e.object({accountId:e.property("account_id",e.string()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",co),period:so,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var fb=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var _b=e.enum_(["company","user"]);var Sb=e.enum_(["bool","date","int","string"]);var Eo=e.object({comparableType:e.property("comparable_type",Sb),entityType:e.property("entity_type",_b),id:e.string()});var sa=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",Eo.optional()),conditionType:e.property("condition_type",fb),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",so.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",co.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",Eo.optional()),traitValue:e.property("trait_value",e.string())});var xb=e.object({conditions:e.list(sa)});var lo=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(xb)),conditions:e.list(sa),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Rb),value:e.boolean()});var Pb=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var ca=e.object({traitDefinition:e.property("trait_definition",Eo.optional()),value:e.string()});var Cb=e.object({accountId:e.property("account_id",e.string()),basePlanId:e.property("base_plan_id",e.string().optional()),billingProductIds:e.property("billing_product_ids",e.list(e.string())),creditBalances:e.property("credit_balances",e.record(e.string(),e.number())),entitlements:e.list(aa).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(na),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list(lo),subscription:Pb.optional(),traits:e.list(ca)});var vs=e.object({accountId:e.property("account_id",e.string()),defaultValue:e.property("default_value",e.boolean()),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),rules:e.list(lo)});var Eb=e.object({accountId:e.property("account_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),rules:e.list(lo),traits:e.list(ca)});var Ts=e.object({basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),preventKeyRemap:e.property("prevent_key_remap",e.boolean().optional()),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var Os=e.object({incr:e.number().optional(),keys:e.record(e.string(),e.string()),set:e.string().optional(),trait:e.string(),updateOnly:e.property("update_only",e.boolean().optional())});var ks=e.object({companies:e.list(e.record(e.string(),e.string())).optional(),company:e.record(e.string(),e.string()).optional(),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var la=class{constructor(o){this._options=L(o)}issueTemporaryAccessToken(o,i){return R.fromPromise(this.__issueTemporaryAccessToken(o,i))}async __issueTemporaryAccessToken(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"temporary-access-tokens"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:{...tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),resource_type:"company"},timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ll.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/temporary-access-tokens")}};var pa=class{constructor(o){this._options=L(o)}listAccountMembers(o={},i){return R.fromPromise(this.__listAccountMembers(o,i))}async __listAccountMembers(o={},i){let{ids:t,q:s,role:r,limit:a,offset:d}=o,y={ids:t,q:s,role:r!=null?vr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ol.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/account-members")}getAccountMember(o,i){return R.fromPromise(this.__getAccountMember(o,i))}async __getAccountMember(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`account-members/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/account-members/{account_member_id}")}countAccountMembers(o={},i){return R.fromPromise(this.__countAccountMembers(o,i))}async __countAccountMembers(o={},i){let{ids:t,q:s,role:r,limit:a,offset:d}=o,y={ids:t,q:s,role:r!=null?vr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:ul.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/account-members/count")}listApiKeys(o,i){return R.fromPromise(this.__listApiKeys(o,i))}async __listApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,d={environment_id:t,require_environment:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Bl.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/api-keys")}createApiKey(o,i){return R.fromPromise(this.__createApiKey(o,i))}async __createApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:an.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/api-keys")}getApiKey(o,i){return R.fromPromise(this.__getApiKey(o,i))}async __getApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/api-keys/{api_key_id}")}updateApiKey(o,i={},t){return R.fromPromise(this.__updateApiKey(o,i,t))}async __updateApiKey(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:sn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Il.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/api-keys/{api_key_id}")}deleteApiKey(o,i){return R.fromPromise(this.__deleteApiKey(o,i))}async __deleteApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Rl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/api-keys/{api_key_id}")}countApiKeys(o,i){return R.fromPromise(this.__countApiKeys(o,i))}async __countApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,d={environment_id:t,require_environment:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ml.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/api-keys/count")}listAuditLogs(o={},i){return R.fromPromise(this.__listAuditLogs(o,i))}async __listAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:d,limit:y,offset:g}=o,l={actor_type:t!=null?Ue.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:d?.toISOString(),limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Al.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/audit-log")}getAuditLog(o,i){return R.fromPromise(this.__getAuditLog(o,i))}async __getAuditLog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`audit-log/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/audit-log/{audit_log_id}")}countAuditLogs(o={},i){return R.fromPromise(this.__countAuditLogs(o,i))}async __countAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:d,limit:y,offset:g}=o,l={actor_type:t!=null?Ue.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:d?.toISOString(),limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:gl.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/audit-log/count")}listEnvironments(o={},i){return R.fromPromise(this.__listEnvironments(o,i))}async __listEnvironments(o={},i){let{ids:t,limit:s,offset:r}=o,a={ids:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Dl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/environments")}createEnvironment(o,i){return R.fromPromise(this.__createEnvironment(o,i))}async __createEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/environments")}getEnvironment(o,i){return R.fromPromise(this.__getEnvironment(o,i))}async __getEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:El.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/environments/{environment_id}")}updateEnvironment(o,i={},t){return R.fromPromise(this.__updateEnvironment(o,i,t))}async __updateEnvironment(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:cn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Fl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/environments/{environment_id}")}deleteEnvironment(o,i){return R.fromPromise(this.__deleteEnvironment(o,i))}async __deleteEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/environments/{environment_id}")}quickstart(o){return R.fromPromise(this.__quickstart(o))}async __quickstart(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"quickstart"),method:"POST",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ml.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 400:throw new v(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"POST","/quickstart")}getWhoAmI(o){return R.fromPromise(this.__getWhoAmI(o))}async __getWhoAmI(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"whoami"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:vl.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/whoami")}};var ua=class{constructor(o){this._options=L(o)}listCoupons(o={},i){return R.fromPromise(this.__listCoupons(o,i))}async __listCoupons(o={},i){let{isActive:t,q:s,limit:r,offset:a}=o,d={is_active:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:cp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/coupons")}upsertBillingCoupon(o,i){return R.fromPromise(this.__upsertBillingCoupon(o,i))}async __upsertBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:mn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/coupons")}deleteBillingCoupon(o,i){return R.fromPromise(this.__deleteBillingCoupon(o,i))}async __deleteBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/coupons/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Jl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/coupons/{billing_id}")}deleteBillingCustomer(o,i){return R.fromPromise(this.__deleteBillingCustomer(o,i))}async __deleteBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/customer/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Yl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/customer/{billing_id}")}upsertBillingCustomer(o,i){return R.fromPromise(this.__upsertBillingCustomer(o,i))}async __upsertBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customer/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ln.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/customer/upsert")}listCustomersWithSubscriptions(o={},i){return R.fromPromise(this.__listCustomersWithSubscriptions(o,i))}async __listCustomersWithSubscriptions(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:d,offset:y}=o,g={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:dp.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/customers")}countCustomers(o={},i){return R.fromPromise(this.__countCustomers(o,i))}async __countCustomers(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:d,offset:y}=o,g={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:$l.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/customers/count")}listInvoices(o,i){return R.fromPromise(this.__listInvoices(o,i))}async __listInvoices(o,i){let{companyId:t,customerExternalId:s,subscriptionExternalId:r,limit:a,offset:d}=o,y={company_id:t,customer_external_id:s,subscription_external_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:hp.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/invoices")}upsertInvoice(o,i){return R.fromPromise(this.__upsertInvoice(o,i))}async __upsertInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:hn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ep.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/invoices")}deleteBillingInvoice(o,i){return R.fromPromise(this.__deleteBillingInvoice(o,i))}async __deleteBillingInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/invoices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Zl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/invoices/{billing_id}")}listMeters(o={},i){return R.fromPromise(this.__listMeters(o,i))}async __listMeters(o={},i){let{displayName:t,limit:s,offset:r}=o,a={display_name:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:yp.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/billing/meter")}upsertBillingMeter(o,i){return R.fromPromise(this.__upsertBillingMeter(o,i))}async __upsertBillingMeter(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:gn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_p.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/meter/upsert")}listPaymentMethods(o,i){return R.fromPromise(this.__listPaymentMethods(o,i))}async __listPaymentMethods(o,i){let{companyId:t,customerExternalId:s,limit:r,offset:a}=o,d={company_id:t,customer_external_id:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:bp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/payment-methods")}upsertPaymentMethod(o,i){return R.fromPromise(this.__upsertPaymentMethod(o,i))}async __upsertPaymentMethod(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Up.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/payment-methods")}deletePaymentMethodByExternalId(o,i){return R.fromPromise(this.__deletePaymentMethodByExternalId(o,i))}async __deletePaymentMethodByExternalId(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/payment-methods/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ql.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/payment-methods/{billing_id}")}listBillingPrices(o={},i){return R.fromPromise(this.__listBillingPrices(o,i))}async __listBillingPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:d,intervalCount:y,isActive:g,planVersionId:l,price:h,productId:w,productIds:U,providerType:T,q:O,tiersMode:B,usageType:j,withMeter:F,limit:A,offset:Z}=o,ne={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:d,interval_count:y,is_active:g,plan_version_id:l,price:h,product_id:w,product_ids:U,provider_type:T!=null?k.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,q:O,tiers_mode:B!=null?me.jsonOrThrow(B,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:j!=null?pe.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:F,limit:A,offset:Z},Se=await this._options.authProvider.getAuthRequest(),D=f(Se.headers,this._options?.headers,i?.headers),q=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price"),method:"GET",headers:D,queryString:u.queryBuilder().addMany(ne).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(q.ok)return{data:ip.parseOrThrow(q.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:q.rawResponse};if(q.error.reason==="status-code")switch(q.error.statusCode){case 400:throw new v(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new P(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new _(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new x(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new S(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);default:throw new b({statusCode:q.error.statusCode,body:q.error.body,rawResponse:q.rawResponse})}return E(q.error,q.rawResponse,"GET","/billing/price")}upsertBillingPrice(o,i){return R.fromPromise(this.__upsertBillingPrice(o,i))}async __upsertBillingPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:pn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/price/upsert")}deleteBillingProduct(o,i){return R.fromPromise(this.__deleteBillingProduct(o,i))}async __deleteBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/product/{billing_id}")}listBillingProductPrices(o={},i){return R.fromPromise(this.__listBillingProductPrices(o,i))}async __listBillingProductPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:d,intervalCount:y,isActive:g,planVersionId:l,price:h,productId:w,productIds:U,providerType:T,q:O,tiersMode:B,usageType:j,withMeter:F,limit:A,offset:Z}=o,ne={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:d,interval_count:y,is_active:g,plan_version_id:l,price:h,product_id:w,product_ids:U,provider_type:T!=null?k.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,q:O,tiers_mode:B!=null?me.jsonOrThrow(B,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:j!=null?pe.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:F,limit:A,offset:Z},Se=await this._options.authProvider.getAuthRequest(),D=f(Se.headers,this._options?.headers,i?.headers),q=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/prices"),method:"GET",headers:D,queryString:u.queryBuilder().addMany(ne).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(q.ok)return{data:tp.parseOrThrow(q.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:q.rawResponse};if(q.error.reason==="status-code")switch(q.error.statusCode){case 400:throw new v(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new P(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new _(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new x(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new S(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);default:throw new b({statusCode:q.error.statusCode,body:q.error.body,rawResponse:q.rawResponse})}return E(q.error,q.rawResponse,"GET","/billing/product/prices")}deleteProductPrice(o,i){return R.fromPromise(this.__deleteProductPrice(o,i))}async __deleteProductPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/prices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ep.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/product/prices/{billing_id}")}upsertBillingProduct(o,i){return R.fromPromise(this.__upsertBillingProduct(o,i))}async __upsertBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/product/upsert")}listBillingProducts(o={},i){return R.fromPromise(this.__listBillingProducts(o,i))}async __listBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:d,q:y,recurringChargesOnly:g,withOneTimeCharges:l,withPricesOnly:h,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,B={ids:t,is_active:s,name:r,price_usage_type:a!=null?pe.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,recurring_charges_only:g,with_one_time_charges:l,with_prices_only:h,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),F=f(j.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products"),method:"GET",headers:F,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:np.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return E(A.error,A.rawResponse,"GET","/billing/products")}countBillingProducts(o={},i){return R.fromPromise(this.__countBillingProducts(o,i))}async __countBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:d,q:y,recurringChargesOnly:g,withOneTimeCharges:l,withPricesOnly:h,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,B={ids:t,is_active:s,name:r,price_usage_type:a!=null?pe.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,recurring_charges_only:g,with_one_time_charges:l,with_prices_only:h,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),F=f(j.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products/count"),method:"GET",headers:F,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:Hl.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return E(A.error,A.rawResponse,"GET","/billing/products/count")}upsertBillingSubscription(o,i){return R.fromPromise(this.__upsertBillingSubscription(o,i))}async __upsertBillingSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/subscription/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:dn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/subscription/upsert")}};var da=class{constructor(o){this._options=L(o)}listCatalogs(o={},i){return R.fromPromise(this.__listCatalogs(o,i))}async __listCatalogs(o={},i){let{isDefault:t,q:s,limit:r,offset:a}=o,d={is_default:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Xp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/catalogs")}createCatalog(o,i){return R.fromPromise(this.__createCatalog(o,i))}async __createCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:wn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Op.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/catalogs")}getCatalog(o,i){return R.fromPromise(this.__getCatalog(o,i))}async __getCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Bp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}")}updateCatalog(o,i={},t){return R.fromPromise(this.__updateCatalog(o,i,t))}async __updateCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Qp.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}")}deleteCatalog(o,i){return R.fromPromise(this.__deleteCatalog(o,i))}async __deleteCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/catalogs/{catalog_id}")}getConfiguration(o,i){return R.fromPromise(this.__getConfiguration(o,i))}async __getConfiguration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/configuration`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/configuration")}updateConfiguration(o,i={},t){return R.fromPromise(this.__updateConfiguration(o,i,t))}async __updateConfiguration(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/configuration`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:zn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:eu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}/configuration")}getCreditBundlesInCatalog(o,i){return R.fromPromise(this.__getCreditBundlesInCatalog(o,i))}async __getCreditBundlesInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/credit-bundles")}addCreditBundle(o,i,t){return R.fromPromise(this.__addCreditBundle(o,i,t))}async __addCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles/${u.encodePathParam(i)}`),method:"POST",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}removeCreditBundle(o,i,t){return R.fromPromise(this.__removeCreditBundle(o,i,t))}async __removeCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles/${u.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}getDerivedFeatures(o,i){return R.fromPromise(this.__getDerivedFeatures(o,i))}async __getDerivedFeatures(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/features`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$p.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/features")}getPlansInCatalog(o,i){return R.fromPromise(this.__getPlansInCatalog(o,i))}async __getPlansInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Yp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/plans")}addPlan(o,i,t){return R.fromPromise(this.__addPlan(o,i,t))}async __addPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans/${u.encodePathParam(i)}`),method:"POST",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/plans/{plan_id}")}removePlan(o,i,t){return R.fromPromise(this.__removePlan(o,i,t))}async __removePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans/${u.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/plans/{plan_id}")}};var ma=class{constructor(o){this._options=L(o)}internal(o,i){return R.fromPromise(this.__internal(o,i))}async __internal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ps.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:du.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal")}getCheckoutData(o,i){return R.fromPromise(this.__getCheckoutData(o,i))}async __getCheckoutData(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/data"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Sn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal/data")}previewCheckoutInternal(o,i){return R.fromPromise(this.__previewCheckoutInternal(o,i))}async __previewCheckoutInternal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ps.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal/preview")}getCompanyBillingDetails(o,i){return R.fromPromise(this.__getCompanyBillingDetails(o,i))}async __getCompanyBillingDetails(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}/billing-details`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/companies/{company_id}/billing-details")}updateCompanyBillingDetails(o,i,t){return R.fromPromise(this.__updateCompanyBillingDetails(o,i,t))}async __updateCompanyBillingDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}/billing-details`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:vu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/companies/{company_id}/billing-details")}managePlan(o,i){return R.fromPromise(this.__managePlan(o,i))}async __managePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Us.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_u.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan")}previewManagePlan(o,i){return R.fromPromise(this.__previewManagePlan(o,i))}async __previewManagePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Us.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Uu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan/preview")}cancelSubscription(o,i){return R.fromPromise(this.__cancelSubscription(o,i))}async __cancelSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/subscription/cancel"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:_n.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan/subscription/cancel")}updateCustomerSubscriptionTrialEnd(o,i={},t){return R.fromPromise(this.__updateCustomerSubscriptionTrialEnd(o,i,t))}async __updateCustomerSubscriptionTrialEnd(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`subscription/${u.encodePathParam(o)}/edit-trial-end`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Pn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Tu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/subscription/{subscription_id}/edit-trial-end")}};var ha=class{constructor(o){this._options=L(o)}listCompanies(o={},i){return R.fromPromise(this.__listCompanies(o,i))}async __listCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:d,planIds:y,planVersionId:g,planVersionIds:l,q:h,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:B,withoutFeatureOverrideFor:j,withoutPlan:F,withoutSubscription:A,withSubscription:Z,limit:ne,offset:Se}=o,D={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:d,plan_ids:y,plan_version_id:g,plan_version_ids:l,q:h,sort_order_column:w,sort_order_direction:U!=null?Ae.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(xr=>Or.jsonOrThrow(xr,{unrecognizedObjectKeys:"strip"})):T!=null?Or.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(xr=>kr.jsonOrThrow(xr,{unrecognizedObjectKeys:"strip"})):O!=null?kr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:B,without_feature_override_for:j,without_plan:F,without_subscription:A,with_subscription:Z,limit:ne,offset:Se},q=await this._options.authProvider.getAuthRequest(),Sr=f(q.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"GET",headers:Sr,queryString:u.queryBuilder().addMany(D).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:wd.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return E(M.error,M.rawResponse,"GET","/companies")}upsertCompany(o,i){return R.fromPromise(this.__upsertCompany(o,i))}async __upsertCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ts.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies")}getCompany(o,i){return R.fromPromise(this.__getCompany(o,i))}async __getCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:td.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/companies/{company_id}")}deleteCompany(o,i={},t){return R.fromPromise(this.__deleteCompany(o,i,t))}async __deleteCompany(o,i={},t){let{cancelSubscription:s,prorate:r}=i,a={cancel_subscription:s,prorate:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}`),method:"DELETE",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Nu.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"DELETE","/companies/{company_id}")}countCompanies(o={},i){return R.fromPromise(this.__countCompanies(o,i))}async __countCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:d,planIds:y,planVersionId:g,planVersionIds:l,q:h,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:B,withoutFeatureOverrideFor:j,withoutPlan:F,withoutSubscription:A,withSubscription:Z,limit:ne,offset:Se}=o,D={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:d,plan_ids:y,plan_version_id:g,plan_version_ids:l,q:h,sort_order_column:w,sort_order_direction:U!=null?Ae.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(xr=>Or.jsonOrThrow(xr,{unrecognizedObjectKeys:"strip"})):T!=null?Or.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(xr=>kr.jsonOrThrow(xr,{unrecognizedObjectKeys:"strip"})):O!=null?kr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:B,without_feature_override_for:j,without_plan:F,without_subscription:A,with_subscription:Z,limit:ne,offset:Se},q=await this._options.authProvider.getAuthRequest(),Sr=f(q.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/count"),method:"GET",headers:Sr,queryString:u.queryBuilder().addMany(D).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:Bu.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return E(M.error,M.rawResponse,"GET","/companies/count")}createCompany(o,i){return R.fromPromise(this.__createCompany(o,i))}async __createCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ts.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ku.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies/create")}deleteCompanyByKeys(o,i){return R.fromPromise(this.__deleteCompanyByKeys(o,i))}async __deleteCompanyByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies/delete")}lookupCompany(o,i){return R.fromPromise(this.__lookupCompany(o,i))}async __lookupCompany(o,i){let{keys:t}=o,s={keys:Te(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/lookup"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Od.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/companies/lookup")}getCompanyBillingEntity(o={},i){return R.fromPromise(this.__getCompanyBillingEntity(o,i))}async __getCompanyBillingEntity(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:od.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/company-billing-entity")}getBillingEntityChildSubscriptions(o={},i){return R.fromPromise(this.__getBillingEntityChildSubscriptions(o,i))}async __getBillingEntityChildSubscriptions(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity-subscriptions"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:ed.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/company-billing-entity-subscriptions")}listCompanyMemberships(o={},i){return R.fromPromise(this.__listCompanyMemberships(o,i))}async __listCompanyMemberships(o={},i){let{companyId:t,userId:s,limit:r,offset:a}=o,d={company_id:t,user_id:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:zd.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/company-memberships")}getOrCreateCompanyMembership(o,i){return R.fromPromise(this.__getOrCreateCompanyMembership(o,i))}async __getOrCreateCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ld.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-memberships")}deleteCompanyMembership(o,i){return R.fromPromise(this.__deleteCompanyMembership(o,i))}async __deleteCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-memberships/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/company-memberships/{company_membership_id}")}getActiveCompanySubscription(o={},i){return R.fromPromise(this.__getActiveCompanySubscription(o,i))}async __getActiveCompanySubscription(o={},i){let{companyId:t,companyIds:s,limit:r,offset:a}=o,d={company_id:t,company_ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-subscriptions"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Zu.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/company-subscriptions")}upsertCompanyTrait(o,i){return R.fromPromise(this.__upsertCompanyTrait(o,i))}async __upsertCompanyTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Os.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-traits")}listEntityKeyDefinitions(o={},i){return R.fromPromise(this.__listEntityKeyDefinitions(o,i))}async __listEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:d}=o,y={entity_type:t!=null?ae.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:fd.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/entity-key-definitions")}countEntityKeyDefinitions(o={},i){return R.fromPromise(this.__countEntityKeyDefinitions(o,i))}async __countEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:d}=o,y={entity_type:t!=null?ae.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Au.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/entity-key-definitions/count")}listEntityTraitDefinitions(o={},i){return R.fromPromise(this.__listEntityTraitDefinitions(o,i))}async __listEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:d,limit:y,offset:g}=o,l={entity_type:t!=null?ae.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?he.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(T=>he.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):d!=null?he.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Sd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/entity-trait-definitions")}getOrCreateEntityTraitDefinition(o,i){return R.fromPromise(this.__getOrCreateEntityTraitDefinition(o,i))}async __getOrCreateEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/entity-trait-definitions")}getEntityTraitDefinition(o,i){return R.fromPromise(this.__getEntityTraitDefinition(o,i))}async __getEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ad.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/entity-trait-definitions/{entity_trait_definition_id}")}updateEntityTraitDefinition(o,i,t){return R.fromPromise(this.__updateEntityTraitDefinition(o,i,t))}async __updateEntityTraitDefinition(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Tn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:jd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/entity-trait-definitions/{entity_trait_definition_id}")}countEntityTraitDefinitions(o={},i){return R.fromPromise(this.__countEntityTraitDefinitions(o,i))}async __countEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:d,limit:y,offset:g}=o,l={entity_type:t!=null?ae.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?he.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(T=>he.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):d!=null?he.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Du.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/entity-trait-definitions/count")}getEntityTraitValues(o,i){return R.fromPromise(this.__getEntityTraitValues(o,i))}async __getEntityTraitValues(o,i){let{definitionId:t,q:s,limit:r,offset:a}=o,d={definition_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-values"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:cd.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/entity-trait-values")}listPlanChanges(o={},i){return R.fromPromise(this.__listPlanChanges(o,i))}async __listPlanChanges(o={},i){let{action:t,basePlanAction:s,companyId:r,companyIds:a,planIds:d,limit:y,offset:g}=o,l={action:t!=null?Li.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Gi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,company_id:r,company_ids:a,plan_ids:d,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-changes"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Pd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/plan-changes")}getPlanChange(o,i){return R.fromPromise(this.__getPlanChange(o,i))}async __getPlanChange(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-changes/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:md.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-changes/{plan_change_id}")}listPlanTraits(o={},i){return R.fromPromise(this.__listPlanTraits(o,i))}async __listPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:d,offset:y}=o,g={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Ed.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/plan-traits")}getPlanTrait(o,i){return R.fromPromise(this.__getPlanTrait(o,i))}async __getPlanTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-traits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-traits/{plan_trait_id}")}updatePlanTraitsBulk(o,i){return R.fromPromise(this.__updatePlanTraitsBulk(o,i))}async __updatePlanTraitsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:On.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ad.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-traits/bulk")}countPlanTraits(o={},i){return R.fromPromise(this.__countPlanTraits(o,i))}async __countPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:d,offset:y}=o,g={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Mu.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/plan-traits/count")}upsertUserTrait(o,i){return R.fromPromise(this.__upsertUserTrait(o,i))}async __upsertUserTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Os.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Md.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/user-traits")}listUsers(o={},i){return R.fromPromise(this.__listUsers(o,i))}async __listUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:d,offset:y}=o,g={company_id:t,ids:s,plan_id:r,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:vd.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/users")}upsertUser(o,i){return R.fromPromise(this.__upsertUser(o,i))}async __upsertUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ks.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users")}getUser(o,i){return R.fromPromise(this.__getUser(o,i))}async __getUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/users/{user_id}")}deleteUser(o,i){return R.fromPromise(this.__deleteUser(o,i))}async __deleteUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ju.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/users/{user_id}")}countUsers(o={},i){return R.fromPromise(this.__countUsers(o,i))}async __countUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:d,offset:y}=o,g={company_id:t,ids:s,plan_id:r,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Fu.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/users/count")}createUser(o,i){return R.fromPromise(this.__createUser(o,i))}async __createUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ks.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users/create")}deleteUserByKeys(o,i){return R.fromPromise(this.__deleteUserByKeys(o,i))}async __deleteUserByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$u.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users/delete")}lookupUser(o,i){return R.fromPromise(this.__lookupUser(o,i))}async __lookupUser(o,i){let{keys:t}=o,s={keys:Te(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/lookup"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Bd.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/users/lookup")}};var ga=class{constructor(o){this._options=L(o)}listComponents(o={},i){return R.fromPromise(this.__listComponents(o,i))}async __listComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Nd.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/components")}createComponent(o,i){return R.fromPromise(this.__createComponent(o,i))}async __createComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ld.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/components")}getComponent(o,i){return R.fromPromise(this.__getComponent(o,i))}async __getComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/components/{component_id}")}updateComponent(o,i={},t){return R.fromPromise(this.__updateComponent(o,i,t))}async __updateComponent(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:An.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:tm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/components/{component_id}")}deleteComponent(o,i){return R.fromPromise(this.__deleteComponent(o,i))}async __deleteComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/components/{component_id}")}bindCatalog(o,i={},t){return R.fromPromise(this.__bindCatalog(o,i,t))}async __bindCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}/catalog`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Id.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/components/{component_id}/catalog")}countComponents(o={},i){return R.fromPromise(this.__countComponents(o,i))}async __countComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Kd.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/components/count")}previewComponentData(o={},i){return R.fromPromise(this.__previewComponentData(o,i))}async __previewComponentData(o={},i){let{companyId:t,componentId:s}=o,r={company_id:t,component_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/preview-data"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:om.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/components/preview-data")}};var ya=class{constructor(o){this._options=L(o)}getPublicPlans(o){return R.fromPromise(this.__getPublicPlans(o))}async __getPublicPlans(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"public/plans"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:nm.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/public/plans")}};var wa=class{constructor(o){this._options=L(o)}listBillingCredits(o={},i){return R.fromPromise(this.__listBillingCredits(o,i))}async __listBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,d={ids:t,name:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Bm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits")}createBillingCredit(o,i){return R.fromPromise(this.__createBillingCredit(o,i))}async __createBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Mn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Rm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits")}getSingleBillingCredit(o,i){return R.fromPromise(this.__getSingleBillingCredit(o,i))}async __getSingleBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Um.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/{credit_id}")}updateBillingCredit(o,i,t){return R.fromPromise(this.__updateBillingCredit(o,i,t))}async __updateBillingCredit(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Ln.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:eh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/{credit_id}")}softDeleteBillingCredit(o,i){return R.fromPromise(this.__softDeleteBillingCredit(o,i))}async __softDeleteBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Qm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/credits/{credit_id}")}listCompanyCreditBalances(o,i){return R.fromPromise(this.__listCompanyCreditBalances(o,i))}async __listCompanyCreditBalances(o,i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/balance"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:qm.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/billing/credits/balance")}listCreditBundles(o={},i){return R.fromPromise(this.__listCreditBundles(o,i))}async __listCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:d,offset:y}=o,g={ids:t,credit_id:s,status:r!=null?ve.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?Me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Km.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/credits/bundles")}createCreditBundle(o,i){return R.fromPromise(this.__createCreditBundle(o,i))}async __createCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Fn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_m.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/bundles")}getCreditBundle(o,i){return R.fromPromise(this.__getCreditBundle(o,i))}async __getCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Em.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/bundles/{bundle_id}")}updateCreditBundleDetails(o,i,t){return R.fromPromise(this.__updateCreditBundleDetails(o,i,t))}async __updateCreditBundleDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Gn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ih.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/bundles/{bundle_id}")}deleteCreditBundle(o,i){return R.fromPromise(this.__deleteCreditBundle(o,i))}async __deleteCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Pm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/credits/bundles/{bundle_id}")}countCreditBundles(o={},i){return R.fromPromise(this.__countCreditBundles(o,i))}async __countCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:d,offset:y}=o,g={ids:t,credit_id:s,status:r!=null?ve.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?Me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:wm.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/credits/bundles/count")}countBillingCredits(o={},i){return R.fromPromise(this.__countBillingCredits(o,i))}async __countBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,d={ids:t,name:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:um.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits/count")}zeroOutGrant(o,i={},t){return R.fromPromise(this.__zeroOutGrant(o,i,t))}async __zeroOutGrant(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/grants/${u.encodePathParam(o)}/zero-out`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Wn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:oh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/grants/{grant_id}/zero-out")}grantBillingCreditsToCompany(o,i){return R.fromPromise(this.__grantBillingCreditsToCompany(o,i))}async __grantBillingCreditsToCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:In.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Om.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/grants/company")}countCompanyGrants(o={},i){return R.fromPromise(this.__countCompanyGrants(o,i))}async __countCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:d}=o,y={company_id:t,order:s!=null?hi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Ae.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:gm.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/credits/grants/company/count")}listCompanyGrants(o={},i){return R.fromPromise(this.__listCompanyGrants(o,i))}async __listCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:d}=o,y={company_id:t,order:s!=null?hi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Ae.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/list"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Im.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/credits/grants/company/list")}countBillingCreditsGrants(o={},i){return R.fromPromise(this.__countBillingCreditsGrants(o,i))}async __countBillingCreditsGrants(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,d={credit_id:t,ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:lm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits/grants/count")}listGrantsForCredit(o={},i){return R.fromPromise(this.__listGrantsForCredit(o,i))}async __listGrantsForCredit(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,d={credit_id:t,ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/list"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Zm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits/grants/list")}acquireCreditLease(o,i){return R.fromPromise(this.__acquireCreditLease(o,i))}async __acquireCreditLease(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/lease"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:qn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:sm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/lease")}extendCreditLease(o,i,t){return R.fromPromise(this.__extendCreditLease(o,i,t))}async __extendCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${u.encodePathParam(o)}/extend`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Kn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Cm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/extend")}releaseCreditLease(o,i,t){return R.fromPromise(this.__releaseCreditLease(o,i,t))}async __releaseCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${u.encodePathParam(o)}/release`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:wb.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Xm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/release")}listBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__listBillingPlanCreditGrants(o,i))}async __listBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:d,planVersionIds:y,limit:g,offset:l}=o,h={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:d,plan_version_ids:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Am.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/billing/credits/plan-grants")}createBillingPlanCreditGrant(o,i){return R.fromPromise(this.__createBillingPlanCreditGrant(o,i))}async __createBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ft.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/plan-grants")}getSingleBillingPlanCreditGrant(o,i){return R.fromPromise(this.__getSingleBillingPlanCreditGrant(o,i))}async __getSingleBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/plan-grants/{plan_grant_id}")}updateBillingPlanCreditGrant(o,i,t){return R.fromPromise(this.__updateBillingPlanCreditGrant(o,i,t))}async __updateBillingPlanCreditGrant(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Lt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:rh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/plan-grants/{plan_grant_id}")}deleteBillingPlanCreditGrant(o,i={},t){return R.fromPromise(this.__deleteBillingPlanCreditGrant(o,i,t))}async __deleteBillingPlanCreditGrant(o,i={},t){let{applyToExisting:s}=i,r={apply_to_existing:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:xm.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"DELETE","/billing/credits/plan-grants/{plan_grant_id}")}countBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__countBillingPlanCreditGrants(o,i))}async __countBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:d,planVersionIds:y,limit:g,offset:l}=o,h={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:d,plan_version_ids:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:mm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/billing/credits/plan-grants/count")}listCreditEventLedger(o,i){return R.fromPromise(this.__listCreditEventLedger(o,i))}async __listCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:d,startTime:y,limit:g,offset:l}=o,h={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?Br.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Jm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger")}countCreditEventLedger(o,i){return R.fromPromise(this.__countCreditEventLedger(o,i))}async __countCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:d,startTime:y,limit:g,offset:l}=o,h={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?Br.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:zm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger/count")}};var ba=class{constructor(o){this._options=L(o)}listDataExports(o={},i){return R.fromPromise(this.__listDataExports(o,i))}async __listDataExports(o={},i){let{exportType:t,status:s,limit:r,offset:a}=o,d={export_type:t!=null?ii.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,status:s!=null?Ji.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:lh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/data-exports")}createDataExport(o,i){return R.fromPromise(this.__createDataExport(o,i))}async __createDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Hn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:nh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/data-exports")}getDataExport(o,i){return R.fromPromise(this.__getDataExport(o,i))}async __getDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:sh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}")}getDataExportArtifact(o,i){return R.fromPromise(this.__getDataExportArtifact(o,i))}async __getDataExportArtifact(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${u.encodePathParam(o)}/artifact`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),responseType:"streaming",timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:r.body,rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}/artifact")}};var za=class{constructor(o){this._options=L(o)}listCompanyOverrides(o={},i){return R.fromPromise(this.__listCompanyOverrides(o,i))}async __listCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:d,withoutExpired:y,q:g,limit:l,offset:h}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:d,without_expired:y,q:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Hh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/company-overrides")}createCompanyOverride(o,i){return R.fromPromise(this.__createCompanyOverride(o,i))}async __createCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:$n.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Rh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-overrides")}getCompanyOverride(o,i){return R.fromPromise(this.__getCompanyOverride(o,i))}async __getCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Uh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/company-overrides/{company_override_id}")}updateCompanyOverride(o,i,t){return R.fromPromise(this.__updateCompanyOverride(o,i,t))}async __updateCompanyOverride(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Zn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:tg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/company-overrides/{company_override_id}")}deleteCompanyOverride(o,i){return R.fromPromise(this.__deleteCompanyOverride(o,i))}async __deleteCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_h.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/company-overrides/{company_override_id}")}countCompanyOverrides(o={},i){return R.fromPromise(this.__countCompanyOverrides(o,i))}async __countCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:d,withoutExpired:y,q:g,limit:l,offset:h}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:d,without_expired:y,q:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides/count"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:uh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/company-overrides/count")}listFeatureCompanies(o,i){return R.fromPromise(this.__listFeatureCompanies(o,i))}async __listFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Yh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-companies")}countFeatureCompanies(o,i){return R.fromPromise(this.__countFeatureCompanies(o,i))}async __countFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:mh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-companies/count")}listFeatureUsage(o={},i){return R.fromPromise(this.__listFeatureUsage(o,i))}async __listFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:d,q:y,withoutNegativeEntitlements:g,limit:l,offset:h}=o,w={company_id:t,company_keys:s!=null?Te(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,without_negative_entitlements:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Xh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/feature-usage")}getFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getFeatureUsageTimeSeries(o,i))}async __getFeatureUsageTimeSeries(o,i){let{companyId:t,endTime:s,featureId:r,granularity:a,startTime:d}=o,y={company_id:t,end_time:s.toISOString(),feature_id:r,granularity:a!=null?rr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,start_time:d.toISOString()},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage-timeseries"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ah.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/feature-usage-timeseries")}countFeatureUsage(o={},i){return R.fromPromise(this.__countFeatureUsage(o,i))}async __countFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:d,q:y,withoutNegativeEntitlements:g,limit:l,offset:h}=o,w={company_id:t,company_keys:s!=null?Te(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,without_negative_entitlements:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage/count"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:gh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/feature-usage/count")}listFeatureUsers(o,i){return R.fromPromise(this.__listFeatureUsers(o,i))}async __listFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:rg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-users")}countFeatureUsers(o,i){return R.fromPromise(this.__countFeatureUsers(o,i))}async __countFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:wh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-users/count")}listPlanEntitlements(o={},i){return R.fromPromise(this.__listPlanEntitlements(o,i))}async __listPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:d,planVersionId:y,planVersionIds:g,q:l,withMeteredProducts:h,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:d,plan_version_id:y,plan_version_ids:g,q:l,with_metered_products:h,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),B=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"GET",headers:B,queryString:u.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:og.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return E(j.error,j.rawResponse,"GET","/plan-entitlements")}createPlanEntitlement(o,i){return R.fromPromise(this.__createPlanEntitlement(o,i))}async __createPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements")}getPlanEntitlement(o,i){return R.fromPromise(this.__getPlanEntitlement(o,i))}async __getPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-entitlements/{plan_entitlement_id}")}updatePlanEntitlement(o,i,t){return R.fromPromise(this.__updatePlanEntitlement(o,i,t))}async __updatePlanEntitlement(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ag.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-entitlements/{plan_entitlement_id}")}deletePlanEntitlement(o,i){return R.fromPromise(this.__deletePlanEntitlement(o,i))}async __deletePlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/plan-entitlements/{plan_entitlement_id}")}upsertPlanEntitlementForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanEntitlementForBillingProduct(o,i))}async __upsertPlanEntitlementForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ng.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements/billing-linked")}countPlanEntitlements(o={},i){return R.fromPromise(this.__countPlanEntitlements(o,i))}async __countPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:d,planVersionId:y,planVersionIds:g,q:l,withMeteredProducts:h,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:d,plan_version_id:y,plan_version_ids:g,q:l,with_metered_products:h,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),B=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/count"),method:"GET",headers:B,queryString:u.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:zh.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return E(j.error,j.rawResponse,"GET","/plan-entitlements/count")}duplicatePlanEntitlements(o,i){return R.fromPromise(this.__duplicatePlanEntitlements(o,i))}async __duplicatePlanEntitlements(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/duplicate"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Eh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements/duplicate")}getFeatureUsageByCompany(o,i){return R.fromPromise(this.__getFeatureUsageByCompany(o,i))}async __getFeatureUsageByCompany(o,i){let{keys:t}=o,s={keys:Te(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"usage-by-company"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Th.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/usage-by-company")}getUserUsageByCompany(o,i){return R.fromPromise(this.__getUserUsageByCompany(o,i))}async __getUserUsageByCompany(o,i){let{companyId:t,endTime:s,featureId:r,startTime:a}=o,d={company_id:t,end_time:s?.toISOString(),feature_id:r,start_time:a?.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-usage-by-company"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Mh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/user-usage-by-company")}getUserUsageDetail(o,i){return R.fromPromise(this.__getUserUsageDetail(o,i))}async __getUserUsageDetail(o,i){let{companyId:t,endTime:s,startTime:r,userId:a}=o,d={company_id:t,end_time:s?.toISOString(),start_time:r?.toISOString(),user_id:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-usage-detail"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Gh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/user-usage-detail")}};var Ra=class{constructor(o){this._options=L(o)}createEventBatch(o,i){return R.fromPromise(this.__createEventBatch(o,i))}async __createEventBatch(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-batch"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/event-batch")}getEventSummaries(o={},i){return R.fromPromise(this.__getEventSummaries(o,i))}async __getEventSummaries(o={},i){let{q:t,eventSubtypes:s,limit:r,offset:a}=o,d={q:t,event_subtypes:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-types"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:bg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/event-types")}listEvents(o={},i){return R.fromPromise(this.__listEvents(o,i))}async __listEvents(o={},i){let{companyId:t,eventSubtype:s,eventTypes:r,flagId:a,idempotencyKey:d,userId:y,limit:g,offset:l}=o,h={company_id:t,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>jr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?jr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:a,idempotency_key:d,user_id:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:_g.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/events")}createEvent(o,i){return R.fromPromise(this.__createEvent(o,i))}async __createEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/events")}getEvent(o,i){return R.fromPromise(this.__getEvent(o,i))}async __getEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/events/{event_id}")}getSegmentIntegrationStatus(o){return R.fromPromise(this.__getSegmentIntegrationStatus(o))}async __getSegmentIntegrationStatus(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"segment-integration"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Rg.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/segment-integration")}};var fa=class{constructor(o){this._options=L(o)}listFeatures(o={},i){return R.fromPromise(this.__listFeatures(o,i))}async __listFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:d,q:y,withoutCompanyOverrideFor:g,withoutPlanEntitlementFor:l,limit:h,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>ue.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?ue.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:d,q:y,without_company_override_for:g,without_plan_entitlement_for:l,limit:h,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Lg.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/features")}createFeature(o,i){return R.fromPromise(this.__createFeature(o,i))}async __createFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:is.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/features")}getFeature(o,i){return R.fromPromise(this.__getFeature(o,i))}async __getFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ig.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/features/{feature_id}")}updateFeature(o,i={},t){return R.fromPromise(this.__updateFeature(o,i,t))}async __updateFeature(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:os.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Hg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/features/{feature_id}")}deleteFeature(o,i){return R.fromPromise(this.__deleteFeature(o,i))}async __deleteFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/features/{feature_id}")}upsertFeatureForBillingProduct(o,i){return R.fromPromise(this.__upsertFeatureForBillingProduct(o,i))}async __upsertFeatureForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Zg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/features/billing-linked")}countFeatures(o={},i){return R.fromPromise(this.__countFeatures(o,i))}async __countFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:d,q:y,withoutCompanyOverrideFor:g,withoutPlanEntitlementFor:l,limit:h,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>ue.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?ue.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:d,q:y,without_company_override_for:g,without_plan_entitlement_for:l,limit:h,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/count"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Bg.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/features/count")}listFlags(o={},i){return R.fromPromise(this.__listFlags(o,i))}async __listFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:d}=o,y={feature_id:t,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Wg.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/flags")}createFlag(o,i){return R.fromPromise(this.__createFlag(o,i))}async __createFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags")}getFlag(o,i){return R.fromPromise(this.__getFlag(o,i))}async __getFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Fg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/flags/{flag_id}")}updateFlag(o,i,t){return R.fromPromise(this.__updateFlag(o,i,t))}async __updateFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Cs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Ng.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/flags/{flag_id}")}deleteFlag(o,i){return R.fromPromise(this.__deleteFlag(o,i))}async __deleteFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Mg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/flags/{flag_id}")}updateFlagRules(o,i,t){return R.fromPromise(this.__updateFlagRules(o,i,t))}async __updateFlagRules(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}/rules`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ts.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Yg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/flags/{flag_id}/rules")}checkFlag(o,i,t){return R.fromPromise(this.__checkFlag(o,i,t))}async __checkFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}/check`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Co.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Pg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/flags/{key}/check")}checkFlags(o,i){return R.fromPromise(this.__checkFlags(o,i))}async __checkFlags(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Co.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Og.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags/check")}checkFlagsBulk(o,i){return R.fromPromise(this.__checkFlagsBulk(o,i))}async __checkFlagsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check-bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Tg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags/check-bulk")}countFlags(o={},i){return R.fromPromise(this.__countFlags(o,i))}async __countFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:d}=o,y={feature_id:t,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ag.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/flags/count")}};var _a=class{constructor(o){this._options=L(o)}getActivity(o={},i){return R.fromPromise(this.__getActivity(o,i))}async __getActivity(o={},i){let{limit:t}=o,s={limit:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/activity"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:ry.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/insights/activity")}getEnvironmentFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentFeatureUsageTimeSeries(o,i))}async __getEnvironmentFeatureUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/feature-usage-timeseries"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ty.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/insights/feature-usage-timeseries")}getPlanGrowth(o={},i){return R.fromPromise(this.__getPlanGrowth(o,i))}async __getPlanGrowth(o={},i){let{months:t}=o,s={months:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/plan-growth"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:uy.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/insights/plan-growth")}getSummary(o){return R.fromPromise(this.__getSummary(o))}async __getSummary(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/summary"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:hy.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/insights/summary")}getTopFeaturesByUsage(o,i){return R.fromPromise(this.__getTopFeaturesByUsage(o,i))}async __getTopFeaturesByUsage(o,i){let{endTime:t,limit:s,startTime:r}=o,a={end_time:t.toISOString(),limit:s,start_time:r.toISOString()},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/top-features"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:by.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/insights/top-features")}getEnvironmentTraitUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentTraitUsageTimeSeries(o,i))}async __getEnvironmentTraitUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/trait-usage-timeseries"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:sy.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/insights/trait-usage-timeseries")}};var Sa=class{constructor(o){this._options=L(o)}runIntegration(o,i){return R.fromPromise(this.__runIntegration(o,i))}async __runIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integration/start/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ay.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/integration/start/{integration_id}")}listIntegrations(o={},i){return R.fromPromise(this.__listIntegrations(o,i))}async __listIntegrations(o={},i){let{billingOnly:t,excludeIds:s,id:r,state:a,type:d,limit:y,offset:g}=o,l={billing_only:t,exclude_ids:s,id:r,state:a!=null?Ie.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,type:d!=null?Pe.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:ky.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/integrations")}getIntegrationWebhookUrl(o,i){return R.fromPromise(this.__getIntegrationWebhookUrl(o,i))}async __getIntegrationWebhookUrl(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/${u.encodePathParam(o)}/webhook-url`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ey.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/integrations/{type}/webhook-url")}installIntegration(o,i){return R.fromPromise(this.__installIntegration(o,i))}async __installIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/install"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ta.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Uy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/install")}startDataImport(o,i){return R.fromPromise(this.__startDataImport(o,i))}async __startDataImport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/start-data-import"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:as.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/start-data-import")}loadSampleDataSet(o){return R.fromPromise(this.__loadSampleDataSet(o))}async __loadSampleDataSet(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/dataset-sample-v2"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:jy.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/integrations/stripe/dataset-sample-v2")}assumeStripeInstalled(o,i){return R.fromPromise(this.__assumeStripeInstalled(o,i))}async __assumeStripeInstalled(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/assume-installed"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ta.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Py.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/stripe/v2/assume-installed")}installStripe(o,i){return R.fromPromise(this.__installStripe(o,i))}async __installStripe(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/install"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ta.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/stripe/v2/install")}uninstallIntegration(o,i){return R.fromPromise(this.__uninstallIntegration(o,i))}async __uninstallIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/uninstall/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/integrations/uninstall/{integration_id}")}};var xa=class{constructor(o){this._options=L(o)}listLicenses(o={},i){return R.fromPromise(this.__listLicenses(o,i))}async __listLicenses(o={},i){let{featureIds:t,ids:s,name:r,limit:a,offset:d}=o,y={feature_ids:t,ids:s,name:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"licenses"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ky.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/licenses")}getSingleLicense(o,i){return R.fromPromise(this.__getSingleLicense(o,i))}async __getSingleLicense(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`licenses/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Iy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/licenses/{license_id}")}countLicenses(o={},i){return R.fromPromise(this.__countLicenses(o,i))}async __countLicenses(o={},i){let{featureIds:t,ids:s,name:r,limit:a,offset:d}=o,y={feature_ids:t,ids:s,name:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"licenses/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:My.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/licenses/count")}};var Pa=class{constructor(o){this._options=L(o)}createCustomPlanBundle(o,i){return R.fromPromise(this.__createCustomPlanBundle(o,i))}async __createCustomPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ns.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ny.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/custom-plan-bundles")}createPlanBundle(o,i){return R.fromPromise(this.__createPlanBundle(o,i))}async __createPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ss.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$y.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-bundles")}updatePlanBundle(o,i,t){return R.fromPromise(this.__updatePlanBundle(o,i,t))}async __updatePlanBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:cs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Jy.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var Ca=class{constructor(o){this._options=L(o)}getPlanGroup(o={},i){return R.fromPromise(this.__getPlanGroup(o,i))}async __getPlanGroup(o={},i){let{includeCompanyCounts:t}=o,s={include_company_counts:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:ow.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/plan-groups")}createPlanGroup(o,i){return R.fromPromise(this.__createPlanGroup(o,i))}async __createPlanGroup(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ls.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-groups")}updatePlanGroup(o,i,t){return R.fromPromise(this.__updatePlanGroup(o,i,t))}async __updatePlanGroup(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-groups/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ps.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:tw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var Ea=class{constructor(o){this._options=L(o)}listCompanyMigrations(o={},i){return R.fromPromise(this.__listCompanyMigrations(o,i))}async __listCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:d}=o,y={migration_id:t,q:s,status:r!=null?Vr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:dw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/plan-version-company-migrations")}retryCompanyMigration(o,i){return R.fromPromise(this.__retryCompanyMigration(o,i))}async __retryCompanyMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-company-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-company-migrations/{plan_version_company_migration_id}/retry")}countCompanyMigrations(o={},i){return R.fromPromise(this.__countCompanyMigrations(o,i))}async __countCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:d}=o,y={migration_id:t,q:s,status:r!=null?Vr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:nw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/plan-version-company-migrations/count")}listMigrations(o={},i){return R.fromPromise(this.__listMigrations(o,i))}async __listMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,d={plan_version_id:t,status:s!=null?Dr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:hw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plan-version-migrations")}createMigration(o,i){return R.fromPromise(this.__createMigration(o,i))}async __createMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ds.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:lw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-migrations")}getMigration(o,i){return R.fromPromise(this.__getMigration(o,i))}async __getMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-version-migrations/{plan_version_migration_id}")}retryMigration(o,i,t){return R.fromPromise(this.__retryMigration(o,i,t))}async __retryMigration(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:hs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:zw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/plan-version-migrations/{plan_version_migration_id}/retry")}countMigrations(o={},i){return R.fromPromise(this.__countMigrations(o,i))}async __countMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,d={plan_version_id:t,status:s!=null?Dr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:cw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plan-version-migrations/count")}previewMigration(o,i){return R.fromPromise(this.__previewMigration(o,i))}async __previewMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ms.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ww.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-migrations/preview")}};var Ua=class{constructor(o){this._options=L(o)}updateCompanyPlans(o,i,t){return R.fromPromise(this.__updateCompanyPlans(o,i,t))}async __updateCompanyPlans(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:zs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Kw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/company-plans/{company_plan_id}")}listCustomPlanBillings(o={},i){return R.fromPromise(this.__listCustomPlanBillings(o,i))}async __listCustomPlanBillings(o={},i){let{companyId:t,planId:s,status:r,statuses:a,limit:d,offset:y}=o,g={company_id:t,plan_id:s,status:r!=null?Tr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(a)?a.map(U=>Tr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):a!=null?Tr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-billings"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:jw.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/custom-plan-billings")}markCustomPlanBillingPaid(o,i,t){return R.fromPromise(this.__markCustomPlanBillingPaid(o,i,t))}async __markCustomPlanBillingPaid(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${u.encodePathParam(o)}/mark-paid`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:yb.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Mw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/mark-paid")}retryCustomPlanBilling(o,i,t){return R.fromPromise(this.__retryCustomPlanBilling(o,i,t))}async __retryCustomPlanBilling(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${u.encodePathParam(o)}/retry`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:bs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Fw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/retry")}createCustomPlan(o,i){return R.fromPromise(this.__createCustomPlan(o,i))}async __createCustomPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ys.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/custom-plans")}listPlans(o={},i){return R.fromPromise(this.__listPlans(o,i))}async __listPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:d,forTrialExpiryPlan:y,hasProductId:g,ids:l,includeDraftVersions:h,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:B,withoutPaidProductId:j,limit:F,offset:A}=o,Z={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:d,for_trial_expiry_plan:y,has_product_id:g,ids:l,include_draft_versions:h,plan_type:w!=null?re.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:B,without_paid_product_id:j,limit:F,offset:A},ne=await this._options.authProvider.getAuthRequest(),Se=f(ne.headers,this._options?.headers,i?.headers),D=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"GET",headers:Se,queryString:u.queryBuilder().addMany(Z).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(D.ok)return{data:qw.parseOrThrow(D.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:D.rawResponse};if(D.error.reason==="status-code")switch(D.error.statusCode){case 400:throw new v(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 401:throw new P(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 403:throw new _(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 404:throw new x(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 500:throw new S(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);default:throw new b({statusCode:D.error.statusCode,body:D.error.body,rawResponse:D.rawResponse})}return E(D.error,D.rawResponse,"GET","/plans")}createPlan(o,i){return R.fromPromise(this.__createPlan(o,i))}async __createPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Gt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Pw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plans")}getPlan(o,i={},t){return R.fromPromise(this.__getPlan(o,i,t))}async __getPlan(o,i={},t){let{planVersionId:s}=i,r={plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Tw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/plans/{plan_id}")}updatePlan(o,i,t){return R.fromPromise(this.__updatePlan(o,i,t))}async __updatePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Wt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Lw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/{plan_id}")}deletePlan(o,i){return R.fromPromise(this.__deletePlan(o,i))}async __deletePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/plans/{plan_id}")}upsertBillingProductPlan(o,i,t){return R.fromPromise(this.__upsertBillingProductPlan(o,i,t))}async __upsertBillingProductPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}/billing_products`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ai.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Gw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/{plan_id}/billing_products")}upsertPlanForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanForBillingProduct(o,i))}async __upsertPlanForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:gs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ww.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plans/billing-linked")}listBillingProductMatchCompanies(o,i){return R.fromPromise(this.__listBillingProductMatchCompanies(o,i))}async __listBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,d={plan_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:kw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies")}countBillingProductMatchCompanies(o,i){return R.fromPromise(this.__countBillingProductMatchCompanies(o,i))}async __countBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,d={plan_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:fw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies/count")}countPlans(o={},i){return R.fromPromise(this.__countPlans(o,i))}async __countPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:d,forTrialExpiryPlan:y,hasProductId:g,ids:l,includeDraftVersions:h,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:B,withoutPaidProductId:j,limit:F,offset:A}=o,Z={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:d,for_trial_expiry_plan:y,has_product_id:g,ids:l,include_draft_versions:h,plan_type:w!=null?re.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:B,without_paid_product_id:j,limit:F,offset:A},ne=await this._options.authProvider.getAuthRequest(),Se=f(ne.headers,this._options?.headers,i?.headers),D=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/count"),method:"GET",headers:Se,queryString:u.queryBuilder().addMany(Z).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(D.ok)return{data:Sw.parseOrThrow(D.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:D.rawResponse};if(D.error.reason==="status-code")switch(D.error.statusCode){case 400:throw new v(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 401:throw new P(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 403:throw new _(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 404:throw new x(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 500:throw new S(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);default:throw new b({statusCode:D.error.statusCode,body:D.error.body,rawResponse:D.rawResponse})}return E(D.error,D.rawResponse,"GET","/plans/count")}listPlanIssues(o,i){return R.fromPromise(this.__listPlanIssues(o,i))}async __listPlanIssues(o,i){let{planId:t,planVersionId:s}=o,r={plan_id:t,plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/issues"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Vw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/plans/issues")}deletePlanVersion(o,i={},t){return R.fromPromise(this.__deletePlanVersion(o,i,t))}async __deletePlanVersion(o,i={},t){let{promoteArchivedVersion:s}=i,r={promote_archived_version:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Uw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"DELETE","/plans/version/{plan_id}")}publishPlanVersion(o,i,t){return R.fromPromise(this.__publishPlanVersion(o,i,t))}async __publishPlanVersion(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${u.encodePathParam(o)}/publish`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ws.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Iw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/version/{plan_id}/publish")}};var va=class{constructor(o){this._options=L(o)}listScheduledCheckouts(o={},i){return R.fromPromise(this.__listScheduledCheckouts(o,i))}async __listScheduledCheckouts(o={},i){let{companyId:t,status:s,limit:r,offset:a}=o,d={company_id:t,status:s!=null?si.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Jw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/scheduled-checkout")}createScheduledCheckout(o,i){return R.fromPromise(this.__createScheduledCheckout(o,i))}async __createScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/scheduled-checkout")}getScheduledCheckout(o,i){return R.fromPromise(this.__getScheduledCheckout(o,i))}async __getScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Nw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/scheduled-checkout/{scheduled_checkout_id}")}updateScheduledCheckout(o,i={},t){return R.fromPromise(this.__updateScheduledCheckout(o,i,t))}async __updateScheduledCheckout(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:fs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Yw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/scheduled-checkout/{scheduled_checkout_id}")}};var Ta=class{constructor(o){this._options=L(o)}listWebhookEvents(o={},i){return R.fromPromise(this.__listWebhookEvents(o,i))}async __listWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:d}=o,y={ids:t,q:s,webhook_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:sb.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/webhook-events")}getWebhookEvent(o,i){return R.fromPromise(this.__getWebhookEvent(o,i))}async __getWebhookEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhook-events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:tb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/webhook-events/{webhook_event_id}")}countWebhookEvents(o={},i){return R.fromPromise(this.__countWebhookEvents(o,i))}async __countWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:d}=o,y={ids:t,q:s,webhook_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Xw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/webhook-events/count")}listWebhooks(o={},i){return R.fromPromise(this.__listWebhooks(o,i))}async __listWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:lb.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/webhooks")}createWebhook(o,i){return R.fromPromise(this.__createWebhook(o,i))}async __createWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:_s.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:rb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/webhooks")}getWebhook(o,i){return R.fromPromise(this.__getWebhook(o,i))}async __getWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ab.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/webhooks/{webhook_id}")}updateWebhook(o,i={},t){return R.fromPromise(this.__updateWebhook(o,i,t))}async __updateWebhook(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:db.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/webhooks/{webhook_id}")}deleteWebhook(o,i){return R.fromPromise(this.__deleteWebhook(o,i))}async __deleteWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ib.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/webhooks/{webhook_id}")}sendTestWebhookAction(o,i,t){return R.fromPromise(this.__sendTestWebhookAction(o,i,t))}async __sendTestWebhookAction(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}/test`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Ss.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ub.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/webhooks/{webhook_id}/test")}countWebhooks(o={},i){return R.fromPromise(this.__countWebhooks(o,i))}async __countWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:eb.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/webhooks/count")}};var Oa=class{constructor(o){this._options=L(o)}get accounts(){return this._accounts??=new pa(this._options)}get billing(){return this._billing??=new ua(this._options)}get credits(){return this._credits??=new wa(this._options)}get catalogs(){return this._catalogs??=new da(this._options)}get checkout(){return this._checkout??=new ma(this._options)}get companies(){return this._companies??=new ha(this._options)}get entitlements(){return this._entitlements??=new za(this._options)}get plans(){return this._plans??=new Ua(this._options)}get components(){return this._components??=new ga(this._options)}get planbundle(){return this._planbundle??=new Pa(this._options)}get dataexports(){return this._dataexports??=new ba(this._options)}get events(){return this._events??=new Ra(this._options)}get features(){return this._features??=new fa(this._options)}get insights(){return this._insights??=new _a(this._options)}get integrationsapi(){return this._integrationsapi??=new Sa(this._options)}get licenses(){return this._licenses??=new xa(this._options)}get plangroups(){return this._plangroups??=new Ca(this._options)}get planmigrations(){return this._planmigrations??=new Ea(this._options)}get componentspublic(){return this._componentspublic??=new ya(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new va(this._options)}get accesstokens(){return this._accesstokens??=new la(this._options)}get webhooks(){return this._webhooks??=new Ta(this._options)}getCreditLedger(o){return R.fromPromise(this.__getCreditLedger(o))}async __getCreditLedger(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/ledger"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:void 0,rawResponse:s.rawResponse};if(s.error.reason==="status-code")throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse});return E(s.error,s.rawResponse,"GET","/billing/credits/ledger")}async fetch(o,i,t){return Ja(o,i,{baseUrl:this._options.baseUrl??this._options.environment,headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:async()=>(await this._options.authProvider.getAuthRequest()).headers},t)}};var ir={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Bs={[ir.Debug]:1,[ir.Info]:2,[ir.Warn]:3,[ir.Error]:4},Ub=ir.Warn,li=class{constructor(o=Ub){this.level=Bs[o]??Bs[Ub]}shouldLog(o){return Bs[o]>=this.level}error(o,...i){this.shouldLog(ir.Error)&&console.error(o,...i)}warn(o,...i){this.shouldLog(ir.Warn)&&console.warn(o,...i)}info(o,...i){this.shouldLog(ir.Info)&&console.info(o,...i)}debug(o,...i){this.shouldLog(ir.Debug)&&console.debug(o,...i)}};var bf=1e3,zf=1e3,Rf=3,ff=1e3,ka=class{constructor(o,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:t=new li,maxSize:s=zf,interval:r=bf,offline:a=!1,maxRetries:d=Rf,initialRetryDelay:y=ff}=i||{};this.captureClient=o,this.interval=r,this.logger=t,this.maxSize=s,this.offline=a,this.maxRetries=d,this.initialRetryDelay=y,this.startPeriodicFlush()}async flush(){if(!(this.events.length===0||this.flushing)){this.flushing=!0;try{let o=[...this.events];this.events=[];let i=0,t=!1,s=null;for(;i<=this.maxRetries&&!t;)try{i>0&&this.logger.info(`Retrying event batch submission (attempt ${i} of ${this.maxRetries})`),await this.captureClient.sendBatch(o),t=!0}catch(r){if(s=r,i++,i<=this.maxRetries){let a=this.initialRetryDelay*Math.pow(2,i-1),d=Math.random()*.1*a,y=a+d;this.logger.warn(`Event batch submission failed: ${r}. Retrying in ${(y/1e3).toFixed(2)} seconds...`),process.env.NODE_ENV!=="test"&&await new Promise(g=>setTimeout(g,y))}}t?i>0&&this.logger.info(`Event batch submission succeeded after ${i} retries`):this.logger.error(`Event batch submission failed after ${this.maxRetries} retries:`,s)}finally{this.flushing=!1}}}async push(o){if(!this.offline){if(this.stopped){this.logger.error("Event buffer is stopped, not accepting new events");return}this.events.length>=this.maxSize&&!this.flushing&&await this.flush(),this.events.push(o)}}async stop(){this.shutdown=!0,this.stopped=!0,this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),await this.flush()}startPeriodicFlush(){this.offline||this.intervalId||(this.intervalId=setInterval(async()=>{this.shutdown||await this.flush()},this.interval),this.intervalId.unref&&this.intervalId.unref())}};var _f="https://c.schematichq.com",Sf=1e4,xf=p=>p.replace(/\/+$/,"")+"/batch",Pf=(p,o)=>{let i={api_key:o,type:p.eventType};return p.body!==void 0&&(i.body=Ut.jsonOrThrow(p.body,{unrecognizedObjectKeys:"strip"})),p.idempotencyKey!==void 0&&(i.idempotency_key=p.idempotencyKey),p.sentAt!==void 0&&(i.sent_at=p.sentAt instanceof Date?p.sentAt.toISOString():p.sentAt),p.trustedClientClock!==void 0&&(i.trusted_client_clock=p.trustedClientClock),p.backfill!==void 0&&(i.backfill=p.backfill),i},Cf=(p,o)=>({events:p.map(i=>Pf(i,o))}),Ef=p=>{if(typeof p!="object"||p===null||!("reason"in p))return"unknown error";let o=p;switch(o.reason){case"status-code":{let i=typeof o.body=="string"?o.body:JSON.stringify(o.body??"");return`HTTP ${o.statusCode}: ${i}`}case"timeout":return"request timed out";case"non-json":return`non-JSON response (HTTP ${o.statusCode})`;case"body-is-null":return`empty response body (HTTP ${o.statusCode})`;default:return o.errorMessage??"unknown error"}},Ba=class{constructor(o){this.apiKey=o.apiKey,this.baseUrl=o.baseUrl&&o.baseUrl.trim()!==""?o.baseUrl:_f,this.timeoutMs=o.timeoutMs??Sf,this.fetcher=o.fetcher,this.headers=o.headers??{}}async sendBatch(o){if(o.length===0)return;let i=await this.fetcher({url:xf(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:Cf(o,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${Ef(i.error)}`)}};function vb(p){return async function(i){let t={};if(p&&Object.assign(t,p),i.body!==void 0&&i.contentType!=null&&(t["Content-Type"]=i.contentType),i.headers!=null)for(let[d,y]of Object.entries(i.headers))y!=null&&typeof y=="string"&&(t[d]=y);let s=i.queryString!=null&&i.queryString.length>0?`${i.url}?${i.queryString}`:Mo(i.url,i.queryParameters),r=await Io({body:i.body,type:i.requestType==="json"?"json":"other"}),a=await zi();try{let d=await Si(async()=>Ri(a,s,i.method,t,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),y=await bi(d,i.responseType),g=bo(d);return d.status>=200&&d.status<400?{ok:!0,body:y,headers:d.headers,rawResponse:g}:{ok:!1,error:{reason:"status-code",statusCode:d.status,body:y},rawResponse:g}}catch(d){return i.abortSignal!=null&&i.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:fi}:d instanceof Error&&d.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:fi}:d instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:d.message},rawResponse:_i}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(d)},rawResponse:_i}}}}async function Uf(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new tr,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var Tb=Uf;var po=class{constructor(){this.wasmInstance=null;this.initialized=!1}async initialize(){if(!this.initialized)try{let o=await import("./wasm/rulesengine.js"),i=o.RulesEngineJS?o:o.default??o;this.wasmInstance=new i.RulesEngineJS,this.initialized=!0}catch(o){throw new Error(`Failed to initialize WASM rules engine: ${o}`)}}async checkFlag(o,i,t){return this.checkFlagWithOptions(o,i,t)}async checkFlagWithOptions(o,i,t,s){this.ensureInitialized();let r=(a,d)=>d===null?void 0:d;try{let a=JSON.stringify(o,r),d=i?JSON.stringify(i,r):void 0,y=t?JSON.stringify(t,r):void 0,g=s?JSON.stringify(vf(s),r):void 0,l=this.wasmInstance.checkFlagWithOptions(a,d,y,g);return JSON.parse(l)}catch(a){throw new Error(`WASM flag check failed: ${a}`)}}getVersionKey(){return this.ensureInitialized(),this.wasmInstance.getVersionKey()}isInitialized(){return this.initialized}ensureInitialized(){if(!this.initialized||!this.wasmInstance)throw new Error("WASM rules engine not initialized. Call initialize() first.")}};function vf(p){let o={};return p.creditCost&&Object.keys(p.creditCost).length>0&&(o.credit_cost=p.creditCost),p.usage!==void 0&&(o.usage=p.usage),p.eventUsage&&(o.event_usage={event_subtype:p.eventUsage.eventSubtype,quantity:p.eventUsage.quantity}),o}js();var Tf={unrecognizedObjectKeys:"passthrough"};function Ob(p,o){let i=p.parse(o,Tf);return i.ok?i.value:o}function Vs(p){return JSON.parse(JSON.stringify(p))}function Of(p){return JSON.parse(JSON.stringify(p))}function kb(p,o){let i=Vs(p),t,s=!1;for(let r of Object.keys(o))switch(r){case"id":i.id=o[r];break;case"account_id":i.accountId=o[r];break;case"environment_id":i.environmentId=o[r];break;case"base_plan_id":i.basePlanId=o[r]??null;break;case"billing_product_ids":i.billingProductIds=o[r];break;case"plan_ids":i.planIds=o[r];break;case"plan_version_ids":i.planVersionIds=o[r];break;case"entitlements":{let a=o[r]??[];i.entitlements=a.map(d=>Ob(aa,d));break}case"rules":i.rules=o[r];break;case"traits":i.traits=o[r];break;case"subscription":i.subscription=o[r];break;case"keys":{let a=i.keys??{},d=o[r];i.keys={...a,...d};break}case"credit_balances":{let a=i.creditBalances??{},d=o[r]??{};i.creditBalances={...a,...d},t=d;break}case"credit_lease_balance":{let a=i.creditBalances??{},d=o[r]??{},y={};for(let[g,l]of Object.entries(d))l&&typeof l.remaining=="number"&&(y[g]=l.remaining);i.creditBalances={...a,...y},t={...t??{},...y};break}case"metrics":{let a=i.metrics??[],d=(o[r]??[]).map(y=>Ob(na,y));i.metrics=Bf(a,d),s=!0;break}}return(t||s)&&!("entitlements"in o)&&kf(i,t,s),i}function kf(p,o,i){let t=p.entitlements??[];if(t.length===0)return;let s=new Map;if(i){let r=p.metrics??[];for(let a of r)a&&s.set(ja(As(a)),a.value??0)}for(let r of t){let a=r.creditId??r.credit_id;o&&a&&a in o&&(r.creditRemaining=o[a],delete r.credit_remaining);let d=r.eventName??r.event_name;if(s.size>0&&d){let y=(r.metricPeriod??r.metric_period)||"all_time",g=(r.monthReset??r.month_reset)||"first_of_month",l=s.get(ja({eventSubtype:d,period:y,monthReset:g}));l!==void 0&&(r.usage=l)}}}function Bb(p,o){let i=Of(p);for(let t of Object.keys(o))switch(t){case"id":i.id=o[t];break;case"account_id":i.accountId=o[t];break;case"environment_id":i.environmentId=o[t];break;case"keys":{let s=i.keys??{},r=o[t];i.keys={...s,...r};break}case"traits":i.traits=o[t];break;case"rules":i.rules=o[t];break}return i}function ja(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function As(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function Bf(p,o){let i=[...p],t=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let a=ja(As(r));t.set(a,s)}}for(let s of o){if(!s)continue;let r=ja(As(s)),a=t.get(r);a!==void 0?i[a]=s:i.push(s)}return i}var Rr="company",fr="user",Ff="flags",qs=30*1e3,Kf=1440*60*1e3,Lf=720*60*60*1e3,Uo=class extends uo{constructor(i){super();this.replicatorReady=!1;this.pendingCompanyRequests=new Map;this.pendingUserRequests=new Map;if(this.apiKey=i.apiKey,this.baseURL=i.baseURL??z.Default,this.logger=i.logger,this.cacheTTL=i.cacheTTL??Kf,this.companyCacheProvider=this.createCacheProvider(i,"company"),this.userCacheProvider=this.createCacheProvider(i,"user"),this.flagsCacheProvider=this.createCacheProvider(i,"flag"),this.companyKeyCacheProvider=this.createKeyCacheProvider(i),this.userKeyCacheProvider=this.createKeyCacheProvider(i),this.replicatorMode=i.replicatorMode??!1,this.replicatorHealthURL=i.replicatorHealthURL,this.replicatorHealthCheck=i.replicatorHealthCheck??30*1e3,this.replicatorMode&&!i.redisClient&&!i.companyCache&&!i.userCache&&!i.flagCache)throw new Error("Replicator mode requires a Redis client or custom cache providers for shared cache access");this.rulesEngine=new po}createCacheProvider(i,t){let s;switch(t){case"company":s=i.companyCache;break;case"user":s=i.userCache;break;case"flag":s=i.flagCache;break}if(s)return this.logger.debug(`Using custom cache provider for ${t} cache`),s;let r=this.calculateCacheTTL(t);return i.redisClient?(this.logger.debug(`Using Redis cache provider for ${t} cache (TTL: ${r}ms)`),new ui({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${t} cache (TTL: ${r}ms)`),new or({ttl:r}))}createKeyCacheProvider(i){let t=this.cacheTTL;return i.redisClient?new ui({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:t}):new or({ttl:t})}calculateCacheTTL(i){return i==="flag"?Math.max(Lf,this.cacheTTL):this.cacheTTL}async start(){try{await this.rulesEngine.initialize(),this.logger.debug("Rules engine initialized successfully")}catch(t){this.logger.warn(`Failed to initialize rules engine: ${t}`)}if(this.replicatorMode){this.logger.info("Replicator mode enabled - skipping WebSocket connection"),this.replicatorHealthURL&&this.startReplicatorHealthCheck();return}this.logger.info("Starting DataStream client");let{DatastreamWSClient:i}=(Kb(),Hs(Fb));this.wsClient=new i({url:this.baseURL,apiKey:this.apiKey,logger:this.logger,messageHandler:this.handleMessage.bind(this),connectionReadyHandler:this.handleConnectionReady.bind(this)}),this.wsClient.on("connected",()=>{this.emit("connected")}),this.wsClient.on("disconnected",()=>{this.emit("disconnected"),this.clearPendingRequests()}),this.wsClient.on("ready",()=>{this.emit("ready")}),this.wsClient.on("not-ready",()=>{this.emit("not-ready")}),this.wsClient.on("error",t=>{this.emit("error",t)}),this.wsClient.start()}isConnected(){return this.replicatorMode?this.isReplicatorReady():this.wsClient?.isConnected()??!1}async getCompany(i){let t=await this.getCompanyFromCache(i);if(t)return this.logger.debug(`Company found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("Company not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForCompany(i),r=!1;for(let a of s)if(this.pendingCompanyRequests.has(a)){r=!0;break}return new Promise((a,d)=>{let y=setTimeout(()=>{this.cleanupPendingCompanyRequests(s,g),d(new Error("Timeout while waiting for company data"))},qs),g=l=>{clearTimeout(y),l?a(l):d(new Error("Company not found"))};for(let l of s)this.pendingCompanyRequests.has(l)||this.pendingCompanyRequests.set(l,[]),this.pendingCompanyRequests.get(l).push(g);r||this.sendDataStreamRequest({entity_type:"rulesengine.Company",keys:i}).catch(l=>{this.cleanupPendingCompanyRequests(s,g),d(l)})})}async getUser(i){let t=await this.getUserFromCache(i);if(t)return this.logger.debug(`User found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("User not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForUser(i),r=!1;for(let a of s)if(this.pendingUserRequests.has(a)){r=!0;break}return new Promise((a,d)=>{let y=setTimeout(()=>{this.cleanupPendingUserRequests(s,g),d(new Error("Timeout while waiting for user data"))},qs),g=l=>{clearTimeout(y),l?a(l):d(new Error("User not found"))};for(let l of s)this.pendingUserRequests.has(l)||this.pendingUserRequests.set(l,[]),this.pendingUserRequests.get(l).push(g);r||this.sendDataStreamRequest({entity_type:"rulesengine.User",keys:i}).catch(l=>{this.cleanupPendingUserRequests(s,g),d(l)})})}async getFlag(i){let t=this.flagCacheKey(i);this.logger.debug(`Retrieving flag from cache: ${i} (cache key: ${t})`);try{return await this.flagsCacheProvider.get(t)||null}catch(s){return this.logger.warn(`Failed to retrieve flag from cache: ${s}`),null}}async getAllFlags(){return this.pendingFlagRequest?new Promise((i,t)=>{let s=this.pendingFlagRequest;this.pendingFlagRequest=r=>{s(r),r?i():t(new Error("Failed to refresh flags"))}}):new Promise((i,t)=>{let s=setTimeout(()=>{this.pendingFlagRequest=void 0,t(new Error("Timeout while waiting for flags data"))},qs);this.pendingFlagRequest=r=>{clearTimeout(s),this.pendingFlagRequest=void 0,r?i():t(new Error("Failed to refresh flags"))},this.sendDataStreamRequest({entity_type:"rulesengine.Flags"}).catch(r=>{clearTimeout(s),this.pendingFlagRequest=void 0,t(r)})})}async checkFlag(i,t,s){let r=await this.getFlag(t);if(!r)throw new Error(`Flag not found: ${t}`);let a=i.company&&Object.keys(i.company).length>0,d=i.user&&Object.keys(i.user).length>0,y=null,g=null;if(a&&(y=await this.getCompanyFromCache(i.company),this.logger.debug(`Company ${y?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.company)}`)),d&&(g=await this.getUserFromCache(i.user),this.logger.debug(`User ${g?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.user)}`)),this.replicatorMode)return this.evaluateFlag(r,y,g,s);if((!a||y)&&(!d||g))return this.logger.debug(`All required resources found in cache for flag ${t} evaluation`),this.evaluateFlag(r,y,g,s);if(!this.isConnected())throw new Error("Datastream not connected and required entities not in cache");let l=a&&!y?this.getCompany(i.company):Promise.resolve(y),h=d&&!g?this.getUser(i.user):Promise.resolve(g),[w,U]=await Promise.all([l,h]);return this.evaluateFlag(r,w,U,s)}async getCachedCompany(i){return this.getCompanyFromCache(i)}async getCachedUser(i){return this.getUserFromCache(i)}getRulesEngine(){return this.rulesEngine}async updateCompanyMetrics(i,t,s){let r=await this.getCompanyFromCache(i);if(!r)return;let a=this.deepCopyCompany(r);if(a.metrics)for(let d of a.metrics)(d.eventSubtype??d.event_subtype)===t&&(d.value=(d.value||0)+s);await this.cacheCompanyForKeys(a)}close(){this.logger.info("Closing DataStream client"),this.replicatorHealthInterval&&(clearInterval(this.replicatorHealthInterval),this.replicatorHealthInterval=void 0),this.clearPendingRequests(),this.wsClient&&(this.wsClient.close(),this.wsClient=void 0),this.logger.info("DataStream client closed")}isReplicatorReady(){return this.replicatorReady}isReplicatorMode(){return this.replicatorMode}getReplicatorCacheVersion(){return this.replicatorCacheVersion}async getReplicatorCacheVersionAsync(i=2e3){if(this.replicatorCacheVersion)return this.replicatorCacheVersion;if(this.replicatorMode&&this.replicatorHealthURL)try{let t=new AbortController,s=setTimeout(()=>t.abort(),i),r=await fetch(this.replicatorHealthURL,{method:"GET",signal:t.signal});if(clearTimeout(s),r.ok){let a=await r.json(),d=a.cache_version||a.cacheVersion;if(d)return this.replicatorCacheVersion=d,d}}catch(t){this.logger.debug(`Failed to fetch replicator cache version: ${t}`)}}async handleMessage(i){this.logger.debug(`Processing datastream message: EntityType=${i.entity_type}, MessageType=${i.message_type}`);try{if(i.message_type==="error"){await this.handleErrorMessage(i);return}switch(i.entity_type){case"rulesengine.Company":case"rulesengine.Companies":await this.handleCompanyMessage(i);break;case"rulesengine.User":case"rulesengine.Users":await this.handleUserMessage(i);break;case"rulesengine.Flags":await this.handleFlagsMessage(i);break;case"rulesengine.Flag":await this.handleFlagMessage(i);break;default:this.logger.warn(`Unknown entity type in datastream message: ${i.entity_type}`)}}catch(t){this.logger.error(`Error processing datastream message: ${t}`),this.emit("error",t)}}async handleCompanyMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial company message missing entity_id");return}let r=this.resourceIdCacheKey(Rr,s),a=await this.companyCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{t=kb(a,i.data)}catch(d){this.logger.error(`Failed to merge partial company: ${d}`);return}}else try{t=Cb.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize company payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(Rr,r,a);try{await this.companyKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete company key mapping from cache: ${y}`)}}let s=this.resourceIdCacheKey(Rr,t.id);try{await this.companyCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete company resource from cache: ${r}`)}return}await this.cacheCompanyForKeys(t),this.notifyPendingCompanyRequests(t.keys||{},t)}}async handleUserMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial user message missing entity_id");return}let r=this.resourceIdCacheKey(fr,s),a=await this.userCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{t=Bb(a,i.data)}catch(d){this.logger.error(`Failed to merge partial user: ${d}`);return}}else try{t=Eb.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize user payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(fr,r,a);try{await this.userKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete user key mapping from cache: ${y}`)}}let s=this.resourceIdCacheKey(fr,t.id);try{await this.userCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete user resource from cache: ${r}`)}return}await this.cacheUserForKeys(t),this.notifyPendingUserRequests(t.keys||{},t)}}async handleFlagsMessage(i){let t=i.data;if(!Array.isArray(t)){this.logger.warn("Expected flags array in bulk flags message");return}let s=[],r=0,a;for(let l of t)try{s.push(vs.parseOrThrow(l,{unrecognizedObjectKeys:"passthrough"}))}catch(h){r++,a===void 0&&(a=h)}r>0&&this.logger.warn(`Failed to deserialize ${r} flag(s) in bulk message: ${String(a)}`);let d=await Promise.allSettled(s.filter(l=>l?.key).map(async l=>{let h=this.flagCacheKey(l.key);return await this.flagsCacheProvider.set(h,l),h})),y=d.filter(l=>l.status==="fulfilled").map(l=>l.value),g=d.filter(l=>l.status==="rejected");if(g.length>0&&this.logger.warn(`Failed to cache ${g.length} flag(s)`),this.flagsCacheProvider.deleteMissing)try{await this.flagsCacheProvider.deleteMissing(y,{scanPattern:"flags:*"})}catch(l){this.logger.warn(`Failed to delete missing flags: ${l}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleFlagMessage(i){let t;try{t=vs.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(r){this.logger.warn(`Failed to deserialize flag payload: ${r}`);return}if(!t?.key)return;let s=this.flagCacheKey(t.key);try{switch(i.message_type){case"delete":await this.flagsCacheProvider.delete(s);break;case"full":await this.flagsCacheProvider.set(s,t);break;default:this.logger.warn(`Unhandled message type for flag: ${i.message_type}`);break}}catch(r){this.logger.warn(`Failed to update flag cache: ${r}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleErrorMessage(i){let t=i.data;if(t?.keys&&t?.entity_type)switch(t.entity_type){case"rulesengine.Company":this.notifyPendingCompanyRequests(t.keys,null);break;case"rulesengine.User":this.notifyPendingUserRequests(t.keys,null);break;default:this.logger.warn(`Received error for unsupported entity type: ${t.entity_type}`)}let s=t?.error||"Unknown datastream error";this.logger.warn(`DataStream error received: ${s}`)}async handleConnectionReady(){this.logger.info("DataStream connection is ready");try{await this.getAllFlags(),this.logger.debug("Requested initial flag data")}catch(i){throw this.logger.error(`Failed to request initial flag data: ${i}`),i}}async sendDataStreamRequest(i){if(!this.wsClient||!this.wsClient.isConnected())throw new Error("DataStream client is not connected");this.logger.debug(`Sending datastream request: EntityType=${i.entity_type}, Keys=${JSON.stringify(i.keys)}`);let t={data:i};await this.wsClient.sendMessage(t)}async getCompanyFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(Rr,t,s);try{let a=await this.companyKeyCacheProvider.get(r);if(a){let d=this.resourceIdCacheKey(Rr,a),y=await this.companyCacheProvider.get(d);if(y)return y}}catch(a){this.logger.warn(`Failed to retrieve company from cache: ${a}`)}}return null}async getUserFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(fr,t,s);try{let a=await this.userKeyCacheProvider.get(r);if(a){let d=this.resourceIdCacheKey(fr,a),y=await this.userCacheProvider.get(d);if(y)return y}}catch(a){this.logger.warn(`Failed to retrieve user from cache: ${a}`)}}return null}async cacheCompanyForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for company lookup");let t=this.resourceIdCacheKey(Rr,i.id),s=await this.companyCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let d=this.resourceKeyToCacheKey(Rr,r,a);try{await this.companyKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete stale company key mapping '${d}': ${y}`)}}}await this.companyCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(Rr,r,a);try{await this.companyKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(y){this.logger.warn(`Failed to cache company key mapping '${d}': ${y}`)}}}async cacheUserForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for user lookup");let t=this.resourceIdCacheKey(fr,i.id),s=await this.userCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let d=this.resourceKeyToCacheKey(fr,r,a);try{await this.userKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete stale user key mapping '${d}': ${y}`)}}}await this.userCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(fr,r,a);try{await this.userKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(y){this.logger.warn(`Failed to cache user key mapping '${d}': ${y}`)}}}generateCacheKeysForCompany(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(Rr,t,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(fr,t,s))}notifyPendingCompanyRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(Rr,s,r),d=this.pendingCompanyRequests.get(a);d&&(this.pendingCompanyRequests.delete(a),d.forEach(y=>{try{y(t)}catch(g){this.logger.error(`Error in company request handler: ${g}`)}}))}}notifyPendingUserRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(fr,s,r),d=this.pendingUserRequests.get(a);d&&(this.pendingUserRequests.delete(a),d.forEach(y=>{try{y(t)}catch(g){this.logger.error(`Error in user request handler: ${g}`)}}))}}cleanupPendingCompanyRequests(i,t){for(let s of i){let r=this.pendingCompanyRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingCompanyRequests.delete(s)}}}cleanupPendingUserRequests(i,t){for(let s of i){let r=this.pendingUserRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingUserRequests.delete(s)}}}clearPendingRequests(){for(let[,i]of this.pendingCompanyRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing company request: ${s}`)}});this.pendingCompanyRequests.clear();for(let[,i]of this.pendingUserRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing user request: ${s}`)}});if(this.pendingUserRequests.clear(),this.pendingFlagRequest){try{this.pendingFlagRequest(!1)}catch(i){this.logger.error(`Error clearing flag request: ${i}`)}this.pendingFlagRequest=void 0}}startReplicatorHealthCheck(){this.replicatorHealthURL&&(this.logger.info(`Starting replicator health check with URL: ${this.replicatorHealthURL}, interval: ${this.replicatorHealthCheck}ms`),this.checkReplicatorHealth(),this.replicatorHealthInterval=setInterval(()=>{this.checkReplicatorHealth()},this.replicatorHealthCheck),this.replicatorHealthInterval.unref())}async checkReplicatorHealth(){if(this.replicatorHealthURL)try{let i=new AbortController,t=setTimeout(()=>i.abort(),5e3),s=await fetch(this.replicatorHealthURL,{method:"GET",signal:i.signal});if(clearTimeout(t),!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let r=await s.json(),a=this.replicatorReady;this.replicatorReady=r.ready??!1;let d=r.cache_version||r.cacheVersion;if(d&&d!==this.replicatorCacheVersion){let y=this.replicatorCacheVersion;this.replicatorCacheVersion=d,this.logger.info(`Cache version changed from ${y||"(null)"} to ${d}`)}this.replicatorReady&&!a?(this.logger.info("External replicator is now ready"),this.emit("replicator-health-changed",!0)):!this.replicatorReady&&a&&(this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1))}catch(i){this.replicatorReady&&(this.replicatorReady=!1,this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1)),this.logger.debug(`Replicator health check failed: ${i}`)}}flagCacheKey(i){let t=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey(),s=`${Ff}:${t}:${i.toLowerCase()}`;return this.logger.debug(`Generated flag cache key - flag: ${i}, mode: ${this.replicatorMode?"replicator":"datastream"}, version: ${t}, cacheKey: ${s}`),s}resourceIdCacheKey(i,t){let s=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${s}:${t}`}resourceKeyToCacheKey(i,t,s){let r=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${r}:${t.toLowerCase()}:${s.toLowerCase()}`}deepCopyCompany(i){return Vs(i)}async evaluateFlag(i,t,s,r){let a=i.defaultValue??!1;try{if(this.rulesEngine.isInitialized()){this.logger.debug(`Evaluating flag with rules engine: ${JSON.stringify({flagId:i.id,flagRules:i.rules?.length||0,companyId:t?.id,userId:s?.id})}`);let d=await this.rulesEngine.checkFlagWithOptions(i,t,s,r);return this.logger.debug(`Rules engine evaluation result: ${JSON.stringify(d)}`),{flagKey:i.key,value:d.value??a,reason:d.reason||"RULES_ENGINE_EVALUATION",companyId:t?.id,userId:s?.id,flagId:i.id,ruleId:d.ruleId,ruleType:d.ruleType,entitlement:d.entitlement?{...d.entitlement,metricResetAt:d.entitlement.metricResetAt?new Date(d.entitlement.metricResetAt):void 0}:void 0}}else return this.logger.warn("Rules engine not initialized, using default flag value"),{flagKey:i.key,value:a,reason:"RULES_ENGINE_UNAVAILABLE",companyId:t?.id,userId:s?.id,flagId:i.id}}catch(d){return this.logger.error(`Rules engine evaluation failed: ${d}`),{flagKey:i.key,value:a,reason:"RULES_ENGINE_ERROR",companyId:t?.id,userId:s?.id,flagId:i.id}}}getRulesEngineVersionKey(){try{if(this.rulesEngine.isInitialized())return this.rulesEngine.getVersionKey()}catch(i){this.logger.warn(`Failed to get rules engine version key: ${i}`)}return"1"}};function Xe(p,o){return`${p}:${o}`}var vo=class{constructor(){this.leases=new Map;this.locks=new Map}get(o,i){let t=this.leases.get(Xe(o,i));return t?{...t}:void 0}async replace(o){let i=Xe(o.companyId,o.creditTypeId);return this.withLock(i,()=>{let t=this.leases.get(i);return t&&t.expiresAt.getTime()>Date.now()?!1:(this.leases.set(i,{...o,localRemainingCredits:o.grantedAmount}),!0)})}async extend(o,i,t,s,r){let a=Xe(o,i);return this.withLock(a,()=>{let d=this.leases.get(a);if(!d||r!==void 0&&d.leaseId!==r)return;let y=t-d.grantedAmount;y>0&&(d.grantedAmount=t,d.localRemainingCredits+=y),s&&s.getTime()>d.expiresAt.getTime()&&(d.expiresAt=s)})}async drop(o,i){let t=Xe(o,i);return this.withLock(t,()=>{this.leases.delete(t)})}async tryReserve(o,i,t){if(!Number.isFinite(t)||t<0)return null;let s=Xe(o,i);return this.withLock(s,()=>{let r=this.leases.get(s);return!r||r.expiresAt.getTime()<=Date.now()||r.localRemainingCredits<t?null:(r.localRemainingCredits-=t,r.localRemainingCredits)})}async refund(o,i,t,s){if(t<=0)return;let r=Xe(o,i);return this.withLock(r,()=>{let a=this.leases.get(r);a&&(s!==void 0&&a.leaseId!==s||(a.localRemainingCredits=Math.min(a.localRemainingCredits+t,a.grantedAmount)))})}list(){return Array.from(this.leases.values(),o=>({...o}))}async withLock(o,i){let t=this.locks.get(o)??Promise.resolve(),s,r=new Promise(d=>s=d),a=t.then(()=>r);this.locks.set(o,a),await t;try{return await i()}finally{s(),this.locks.get(o)===a&&this.locks.delete(o)}}};var To=class{constructor(o,i=1e3){this.leaseStore=o;this.sweepIntervalMs=i;this.reservations=new Map;this.sweepInterval=null;this.stopped=!1}add(o){this.reservations.set(o.id,o)}get(o){return this.reservations.get(o)}reservedCredits(o,i){let t=0;for(let s of this.reservations.values())s.companyId===o&&s.creditTypeId===i&&(t+=s.creditsReserved);return t}async consume(o,i){let t=this.reservations.get(o);if(!t)return null;this.reservations.delete(o);let s=Math.max(0,Math.min(i,t.creditsReserved)),r=t.creditsReserved-s;return r>0&&await this.leaseStore.refund(t.companyId,t.creditTypeId,r,t.leaseId),s}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=0;for(let[t,s]of this.reservations)s.expiresAt.getTime()<=o.getTime()&&(this.reservations.delete(t),await this.leaseStore.refund(s.companyId,s.creditTypeId,s.creditsReserved,s.leaseId),i++);return i}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}size(){return this.reservations.size}};var Oo=class{constructor(o){this.inflightAcquire=new Map;this.inflightExtend=new Map;this.creditsClient=o.creditsClient,this.leaseStore=o.leaseStore,this.logger=o.logger,this.config=o.config}resolveConfig(o){let i=this.config.overrides?.[o];return{leaseDuration:i?.defaultLeaseDuration??this.config.defaultLeaseDuration??3e5,reservationTTL:i?.defaultReservationTTL??this.config.defaultReservationTTL??6e4,leaseSize:i?.defaultLeaseSize??this.config.defaultLeaseSize??1e4,lowWaterMark:i?.lowWaterMark??this.config.lowWaterMark??.25}}async acquireIfNeeded(o,i,t){let s;try{s=await this.leaseStore.get(o,i)}catch(y){this.logger.error(`Failed to read lease store for ${o}/${i}: ${y}`);return}if(s&&s.expiresAt.getTime()>Date.now())return s;let r=Xe(o,i),a=this.inflightAcquire.get(r);if(a)return a;let d=this.acquire(o,i,t).finally(()=>{this.inflightAcquire.delete(r)});return this.inflightAcquire.set(r,d),d}async acquire(o,i,t){let s=this.resolveConfig(i),r={companyId:o,creditTypeId:i,requestedAmount:s.leaseSize,expiresAt:new Date(Date.now()+s.leaseDuration)};try{let d=(await this.creditsClient.acquireCreditLease(r,t)).data;if(await this.leaseStore.replace({leaseId:d.id,companyId:d.companyId,creditTypeId:d.creditTypeId,grantedAmount:d.grantedAmount,expiresAt:d.expiresAt}))this.logger.debug(`Acquired credit lease ${d.id} for ${o}/${i} (granted=${d.grantedAmount}, expires=${d.expiresAt.toISOString()})`);else{let g=await this.leaseStore.get(o,i);return g&&g.leaseId!==d.id?(this.logger.debug(`Lost acquire race for ${o}/${i}; releasing redundant lease ${d.id}`),this.creditsClient.releaseCreditLease(d.id,{}).catch(l=>this.logger.warn(`Failed to release redundant credit lease ${d.id}: ${l}`))):this.logger.debug(`Lost acquire race for ${o}/${i}; server returned the installed lease ${d.id}, nothing to release`),g}return await this.leaseStore.get(o,i)}catch(a){this.logger.error(`Failed to acquire credit lease for ${o}/${i}: ${a}`);return}}async maybeExtendInBackground(o,i,t,s){let r;try{r=await this.leaseStore.get(o,i)}catch(U){this.logger.warn(`Failed to read lease store for ${o}/${i}: ${U}`);return}if(!r||r.expiresAt.getTime()<=Date.now())return;let a=this.resolveConfig(i),y=r.localRemainingCredits/Math.max(r.grantedAmount,1)<=a.lowWaterMark,g=t!==void 0&&r.localRemainingCredits<t;if(!y&&!g)return r;let l=Xe(o,i),h=this.inflightExtend.get(l);if(h)return h;let w=this.extend(r,a,t,s).finally(()=>{this.inflightExtend.delete(l)});return this.inflightExtend.set(l,w),w}async extend(o,i,t,s){let r=t!==void 0?t-o.localRemainingCredits:0,a={additionalAmount:Math.max(i.leaseSize,r),expiresAt:new Date(Date.now()+i.leaseDuration)};try{let y=(await this.creditsClient.extendCreditLease(o.leaseId,a,s)).data;return await this.leaseStore.extend(o.companyId,o.creditTypeId,y.grantedAmount,y.expiresAt,o.leaseId),this.logger.debug(`Extended credit lease ${o.leaseId} to ${y.grantedAmount} (was ${o.grantedAmount} at last read, expires ${y.expiresAt.toISOString()})`),await this.leaseStore.get(o.companyId,o.creditTypeId)}catch(d){this.logger.warn(`Failed to extend credit lease ${o.leaseId}: ${d}`);return}}async releaseAllLocalLeases(){let o=this.leaseStore.list?.();!o||o.length===0||await Promise.all(o.map(async i=>{if(!(i.expiresAt.getTime()<=Date.now()))try{await this.creditsClient.releaseCreditLease(i.leaseId,{}),await this.leaseStore.drop(i.companyId,i.creditTypeId),this.logger.debug(`Released credit lease ${i.leaseId} on close`)}catch(t){this.logger.warn(`Failed to release credit lease ${i.leaseId} on close (it will expire server-side): ${t}`)}}))}};var Wf="schematic:",Hf="credit-lease:",Lb=6e4,Gb=`
|
|
1
|
+
"use strict";var mz=Object.create;var Vo=Object.defineProperty;var hz=Object.getOwnPropertyDescriptor;var gz=Object.getOwnPropertyNames;var yz=Object.getPrototypeOf,wz=Object.prototype.hasOwnProperty;var gi=(p,o)=>()=>(p&&(o=p(p=0)),o);var bz=(p,o)=>()=>(o||p((o={exports:{}}).exports,o),o.exports),xr=(p,o)=>{for(var i in o)Vo(p,i,{get:o[i],enumerable:!0})},Ws=(p,o,i,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of gz(o))!wz.call(p,s)&&s!==i&&Vo(p,s,{get:()=>o[s],enumerable:!(t=hz(o,s))||t.enumerable});return p};var mo=(p,o,i)=>(i=p!=null?mz(yz(p)):{},Ws(o||!p||!p.__esModule?Vo(i,"default",{value:p,enumerable:!0}):i,p)),Hs=p=>Ws(Vo({},"__esModule",{value:!0}),p);var wc={};xr(wc,{Node18UniversalStreamWrapper:()=>Ga});var Ga,bc=gi(()=>{"use strict";Ga=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.on("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.on("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.off("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.off("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var zc={};xr(zc,{UndiciStreamWrapper:()=>Wa});var Wa,Rc=gi(()=>{"use strict";Wa=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.on("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.on("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.off("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.off("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var fc={};xr(fc,{NodePre18StreamWrapper:()=>Ha});var Ha,_c=gi(()=>{"use strict";Ha=class{constructor(o){this.readableStream=o}on(o,i){this.readableStream.on(o,i)}off(o,i){this.readableStream.off(o,i)}pipe(o){return this.readableStream.pipe(o),o}pipeTo(o){return this.pipe(o)}unpipe(o){o?this.readableStream.unpipe(o):this.readableStream.unpipe()}destroy(o){this.readableStream.destroy(o)}pause(){this.readableStream.pause()}resume(){this.readableStream.resume()}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((o,i)=>{let t=this.readableStream.read();t?o(t):(this.readableStream.once("readable",()=>{let s=this.readableStream.read();o(s)}),this.readableStream.once("error",i))})}setEncoding(o){this.readableStream.setEncoding(o),this.encoding=o}async text(){let o=[],i=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let s of this.readableStream)o.push(i.encode(s));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(o))}async json(){let o=await this.text();return JSON.parse(o)}[Symbol.asyncIterator](){let i=this.readableStream[Symbol.asyncIterator]();return{async next(){let{value:t,done:s}=await i.next();return{value:t,done:s}},[Symbol.asyncIterator](){return this}}}}});var uo,js=gi(()=>{"use strict";uo=class{constructor(){this._emitter=null}ensureEmitter(){if(!this._emitter){let{EventEmitter:o}=require("events");this._emitter=new o}return this._emitter}on(o,i){return this.ensureEmitter().on(o,i),this}emit(o,...i){return this._emitter?.emit(o,...i)??!1}removeAllListeners(o){return this._emitter?.removeAllListeners(o),this}}});var Kb=bz((Qse,Wf)=>{Wf.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.8",private:!1,repository:{type:"git",url:"git+https://github.com/schematichq/schematic-node.git"},main:"./dist/index.js",types:"./dist/index.d.ts",scripts:{format:"biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","format:check":"biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",lint:"biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","lint:fix":"biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",check:"biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","check:fix":"biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",build:"node build.js",prepack:"",test:"jest --config jest.config.mjs","test:unit":"jest --selectProjects unit","test:wire":"jest --selectProjects wire","build:legacy":"tsc","test:cloudflare":"node scripts/test-cloudflare.mjs"},dependencies:{"form-data":"^4.0.4","formdata-node":"^6.0.3","node-fetch":"^2.7.0","readable-stream":"^4.7.0",ws:"^8.18.1"},devDependencies:{"@types/node-fetch":"^2.6.12","@types/readable-stream":"^4.0.23",webpack:"^5.105.4","ts-loader":"^9.5.4",jest:"^29.7.0","@jest/globals":"^29.7.0","@types/jest":"^29.5.14","ts-jest":"^29.3.4","jest-environment-jsdom":"^29.7.0",msw:"2.11.2","@types/node":"^20.0.0",typescript:"~5.9.3","@biomejs/biome":"2.4.10",esbuild:"^0.25.9",miniflare:"^4.20260421.0",redis:"^4.7.0","@types/ws":"^8.18.1"},browser:{fs:!1,os:!1,path:!1,stream:!1,crypto:!1,timers:!1},packageManager:"yarn@1.22.22",engines:{node:">=18.0.0"},sideEffects:!1,license:"MIT",files:["dist/**/*.js","dist/**/*.d.ts","dist/**/*.wasm","!dist/**/*.js.map","!dist/**/*.test.*","README.md"]}});var Lb,Gb,Wb,Hb=gi(()=>{"use strict";Lb=Kb(),Gb=Lb.name,Wb=Lb.version});var Jb={};xr(Jb,{DatastreamWSClient:()=>Ds});function Zf(p){let o=new URL(p);switch(o.protocol){case"https:":o.protocol="wss:";break;case"http:":o.protocol="ws:";break;default:throw new Error(`Unsupported scheme: ${o.protocol} (must be http: or https:)`)}if(o.hostname){let i=o.hostname.split(".");i.length>1&&i[0]==="api"&&(i[0]="datastream",o.hostname=i.join("."))}return o.pathname="/datastream",o.toString()}var Nb,Hf,$b,Nf,$f,Jf,Yf,Ds,Yb=gi(()=>{"use strict";Nb=mo(require("ws"));Hb();js();Hf=10*1e3,$b=60*1e3,Nf=$b*9/10,$f=10,Jf=1*1e3,Yf=30*1e3;Ds=class extends uo{constructor(i){super();this.connected=!1;this.ready=!1;this.shouldReconnect=!0;this.reconnectAttempts=0;if(!i.url)throw new Error("URL is required");if(!i.apiKey)throw new Error("ApiKey is required");if(!i.messageHandler)throw new Error("MessageHandler is required");i.url.startsWith("http://")||i.url.startsWith("https://")?this.url=Zf(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":Gb,"X-Schematic-Client-Version":Wb,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??$f,this.minReconnectDelay=i.minReconnectDelay??Jf,this.maxReconnectDelay=i.maxReconnectDelay??Yf}start(){this.shouldReconnect=!0,this.reconnectAttempts=0,this.connectAndRead()}isConnected(){return this.connected}isReady(){return this.ready&&this.connected}async sendMessage(i){if(!this.isConnected()||!this.ws)throw new Error("WebSocket connection is not available!");return new Promise((t,s)=>{if(!this.ws){s(new Error("WebSocket connection is not available!"));return}let r=setTimeout(()=>{s(new Error("Write timeout"))},Hf);try{this.ws.send(JSON.stringify(i),a=>{clearTimeout(r),a?s(a):t()})}catch(a){clearTimeout(r),s(a)}})}close(){this.logger.info("Closing WebSocket connection"),this.shouldReconnect=!1,this.setReady(!1),this.setConnected(!1),this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.ws&&(this.ws.close(),this.ws=void 0)}async connectAndRead(){try{for(;this.shouldReconnect;)try{let i=await this.connect();if(this.reconnectAttempts=0,this.ws=i,this.setConnected(!0),this.setupWebSocketHandlers(i),this.connectionReadyHandler)try{await this.connectionReadyHandler(),this.logger.debug("Connection ready handler completed successfully")}catch(t){this.logger.error(`Connection ready handler failed: ${t}`),this.setConnected(!1),this.setReady(!1),i.close();continue}if(this.setReady(!0),this.logger.debug("WebSocket client is ready"),this.startPingPong(),await new Promise(t=>{let s=()=>{this.logger.info("WebSocket connection closed"),this.cleanup(),t()},r=a=>{this.logger.error(`WebSocket error: ${a.message}`),this.emit("error",a),this.cleanup(),t()};i.on("close",s),i.on("error",r)}),!this.shouldReconnect)break}catch(i){this.reconnectAttempts++,this.setConnected(!1),this.setReady(!1);let t=i instanceof Error?i.message:String(i);if(this.logger.warn(`WebSocket connection failed: ${t}, attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts}`),this.reconnectAttempts>=this.maxReconnectAttempts){this.logger.error("Max reconnection attempts reached"),this.emit("error",new Error("Max reconnection attempts reached"));break}let s=this.calculateBackoffDelay(this.reconnectAttempts);this.logger.debug(`Waiting ${s}ms before reconnecting...`),await new Promise(r=>{this.reconnectTimeout=setTimeout(r,s),this.reconnectTimeout.unref()})}}catch(i){this.emit("error",i)}}connect(){return new Promise((i,t)=>{this.logger.debug(`Connecting to WebSocket: ${this.url}`);let s=new Nb.default(this.url,{headers:this.headers,handshakeTimeout:3e4}),r=setTimeout(()=>{s.close(),t(new Error("Connection timeout"))},3e4);s.on("open",()=>{clearTimeout(r),i(s)}),s.on("error",a=>{clearTimeout(r),t(a)})})}setupWebSocketHandlers(i){i.on("message",t=>{this.handleMessage(t)}),i.on("pong",()=>{this.handlePong()}),i.on("close",t=>{this.handleClose(t)}),i.on("error",t=>{this.handleError(t)})}async handleMessage(i){try{let t;Buffer.isBuffer(i)?t=i.toString():Array.isArray(i)?t=Buffer.concat(i).toString():t=String(i);let s;try{s=JSON.parse(t)}catch(r){this.emit("error",new Error(`Failed to parse datastream message: ${r}`));return}try{await this.messageHandler(s)}catch(r){this.emit("error",new Error(`Message handler error: ${r}`))}}catch(t){this.emit("error",t)}}handleClose(i){this.logger.info(`WebSocket connection closed with code ${i}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}handleError(i){this.logger.error(`WebSocket error: ${i.message}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}startPingPong(){this.logger.debug("Starting ping/pong keepalive mechanism"),this.pingInterval=setInterval(()=>{this.sendPing()},Nf),this.pingInterval.unref()}sendPing(){if(this.ws){this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.pongTimeout=setTimeout(()=>{this.logger.warn("Pong timeout - closing connection"),this.setConnected(!1),this.ws&&this.ws.close()},$b),this.pongTimeout.unref();try{this.ws.ping()}catch(i){this.logger.error(`Failed to send ping: ${i}`),this.setConnected(!1)}}}handlePong(){this.logger.debug("Received pong from server"),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}calculateBackoffDelay(i){let t=Math.floor(Math.random()*this.minReconnectDelay),s=Math.pow(2,i-1)*this.minReconnectDelay+t;return Math.min(s,this.maxReconnectDelay+t)}setConnected(i){let t=this.connected;this.connected=i,i||(this.ready=!1),t!==i&&(this.logger.debug(`Connection state changed: ${i}`),i?this.emit("connected"):this.emit("disconnected"))}setReady(i){let t=this.ready;this.ready=i,t!==i&&(this.logger.debug(`Ready state changed: ${i}`),i?this.emit("ready"):this.emit("not-ready"))}cleanup(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}}});var P_={};xr(P_,{ConsoleLogger:()=>li,LocalCache:()=>or,LogLevel:()=>ir,RedisCacheProvider:()=>ui,RulesEngineClient:()=>po,Schematic:()=>oe,SchematicClient:()=>Da,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>pi,WEBHOOK_SIGNATURE_HEADER:()=>Fs,WEBHOOK_TIMESTAMP_HEADER:()=>Ks,WebhookSignatureError:()=>fr,computeHexSignature:()=>lz,computeSignature:()=>Ma,verifySignature:()=>Ls,verifyWebhookSignature:()=>pz});module.exports=Hs(P_);var oe={};xr(oe,{AccountMemberPermission:()=>Rz,AccountMemberRole:()=>fz,ActorType:()=>_z,ApiKeyScope:()=>Sz,BadRequestError:()=>v,BillingCreditAutoTopupAvailability:()=>xz,BillingCreditBundleStatus:()=>Pz,BillingCreditBurnStrategy:()=>Ez,BillingCreditExpiryType:()=>Cz,BillingCreditExpiryUnit:()=>Uz,BillingCreditGrantReason:()=>vz,BillingCreditGrantZeroedOutReason:()=>Tz,BillingCreditLedgerAuthority:()=>Oz,BillingCreditRolloverPolicy:()=>kz,BillingPlanCreditGrantResetCadence:()=>Bz,BillingPlanCreditGrantResetStart:()=>jz,BillingPlanCreditGrantResetType:()=>Az,BillingPriceScheme:()=>Vz,BillingPriceUsageType:()=>Dz,BillingProductPriceInterval:()=>qz,BillingProviderType:()=>Mz,BillingStrategy:()=>Iz,BillingSubscriptionTrialEndSetting:()=>Fz,BillingTiersMode:()=>Kz,ChargeType:()=>Lz,CompanyFeatureUsageExportMetadataSortOrderDirection:()=>Gz,CompanyFeatureUsageExportMetadataVisibleColumnsItem:()=>Wz,CompanyMatchingCriteria:()=>Hz,CompanyPlanInvalidReason:()=>Nz,ComparableOperator:()=>$z,ComponentEntityType:()=>Jz,ComponentState:()=>Yz,ConditionType:()=>Zz,CreditEventType:()=>Xz,CreditGrantSortOrder:()=>Qz,CreditUsageReason:()=>eR,CustomPlanActivationStrategy:()=>rR,CustomPlanBillingStatus:()=>iR,DataExportOutputFileType:()=>oR,DataExportStatus:()=>tR,DataExportType:()=>aR,EntitlementPriceBehavior:()=>nR,EntitlementType:()=>sR,EntitlementValueType:()=>cR,EntityType:()=>lR,EnvironmentType:()=>pR,EventExportMetadataEventTypesItem:()=>uR,EventStatus:()=>dR,EventType:()=>Do,FeatureLifecyclePhase:()=>mR,FeatureType:()=>hR,ForbiddenError:()=>_,IntegrationState:()=>gR,IntegrationType:()=>yR,InternalServerError:()=>S,InvoiceStatus:()=>wR,MetricPeriod:()=>bR,MetricPeriodMonthReset:()=>zR,MigrationErrorCode:()=>RR,NotFoundError:()=>x,PlanBundleAction:()=>fR,PlanChangeAction:()=>_R,PlanChangeBasePlanAction:()=>SR,PlanChangeSubscriptionAction:()=>xR,PlanCreditGrantScaling:()=>PR,PlanIcon:()=>ER,PlanPriceCadence:()=>CR,PlanType:()=>UR,PlanVersionCompanyMigrationStatus:()=>vR,PlanVersionMigrationStatus:()=>TR,PlanVersionMigrationStrategy:()=>OR,PlanVersionStatus:()=>kR,ProrationBehavior:()=>BR,RuleType:()=>FR,RulesEngineSchemaVersion:()=>jR,RulesengineConditionType:()=>AR,RulesengineEntitlementValueType:()=>Ia,RulesengineEntityType:()=>VR,RulesengineMetricPeriod:()=>DR,RulesengineMetricPeriodMonthReset:()=>qR,RulesengineRuleType:()=>MR,RulesengineTraitDefinitionComparableType:()=>IR,ScheduledCheckoutStatus:()=>KR,ScheduledDowngradeConfigBehavior:()=>LR,SortDirection:()=>GR,SubscriptionStatus:()=>WR,SubscriptionType:()=>HR,TaxIdType:()=>NR,TimeSeriesGranularity:()=>$R,TraitDefinitionComparableType:()=>JR,TraitType:()=>YR,TrialStatus:()=>ZR,UnauthorizedError:()=>P,WebhookEventStatus:()=>XR,WebhookRequestType:()=>QR,WebhookStatus:()=>ef,accesstokens:()=>Ns,accounts:()=>$s,billing:()=>Js,catalogs:()=>Ys,checkout:()=>Zs,companies:()=>Xs,components:()=>Qs,componentspublic:()=>ec,credits:()=>rc,dataexports:()=>ic,entitlements:()=>oc,events:()=>tc,features:()=>ac,insights:()=>nc,integrationsapi:()=>sc,licenses:()=>cc,planbundle:()=>lc,plangroups:()=>pc,planmigrations:()=>uc,plans:()=>dc,scheduledcheckout:()=>mc,webhooks:()=>hc});var Te=(p,o,i)=>JSON.stringify(p,o,i);function ho(p,o){return JSON.parse(p,o)}var b=class extends Error{constructor({message:o,statusCode:i,body:t,rawResponse:s,cause:r}){super(zz({message:o,statusCode:i,body:t})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=i,this.body=t,this.rawResponse=s,r!=null&&(this.cause=r)}};function zz({message:p,statusCode:o,body:i}){let t=[];return p!=null&&t.push(p),o!=null&&t.push(`Status code: ${o.toString()}`),i!=null&&t.push(`Body: ${Te(i,void 0,2)}`),t.join(`
|
|
2
|
+
`)}var pi=class extends Error{constructor(o,i){super(o),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,i?.cause!=null&&(this.cause=i.cause)}};var v=class extends b{constructor(o,i){super({message:"BadRequestError",statusCode:400,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var _=class extends b{constructor(o,i){super({message:"ForbiddenError",statusCode:403,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var S=class extends b{constructor(o,i){super({message:"InternalServerError",statusCode:500,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var x=class extends b{constructor(o,i){super({message:"NotFoundError",statusCode:404,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var P=class extends b{constructor(o,i){super({message:"UnauthorizedError",statusCode:401,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Ns={};var $s={};var Js={};var Ys={};var Zs={};var Xs={};var Qs={};var ec={};var rc={};var ic={};var oc={};var tc={};var ac={};var nc={};var sc={};var cc={};var lc={};var pc={};var uc={};var dc={};var mc={};var hc={};var Rz={CompaniesEdit:"companies_edit",CompanyUsersEdit:"company_users_edit",ComponentsEdit:"components_edit",CustomPlansEdit:"custom_plans_edit",DataExportsEdit:"data_exports_edit",FeaturesEdit:"features_edit",FlagRulesEdit:"flag_rules_edit",FlagsEdit:"flags_edit",OverridesEdit:"overrides_edit",PlanBillingEdit:"plan_billing_edit",PlanEntitlementsEdit:"plan_entitlements_edit",PlanVersionsEdit:"plan_versions_edit",PlansEdit:"plans_edit",WebhooksEdit:"webhooks_edit",WebhooksRevealSecret:"webhooks_reveal_secret"};var fz={Admin:"admin",Member:"member"};var _z={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var Sz={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var xz={Off:"off",Automatic:"automatic",UserControlled:"user_controlled"};var Pz={Active:"active",Inactive:"inactive"};var Ez={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var Cz={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var Uz={BillingPeriods:"billing_periods",Days:"days"};var vz={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var Tz={CustomerArchived:"customer_archived",Expired:"expired",IntegrationUninstalled:"integration_uninstalled",LicenseRetired:"license_retired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset",Reconciled:"reconciled"};var Oz={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var kz={Expire:"expire",None:"none",Rollover:"rollover"};var Bz={Daily:"daily",Every6Months:"every_6_months",Monthly:"monthly",Quarterly:"quarterly",Weekly:"weekly",Yearly:"yearly"};var jz={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var Az={NoReset:"no_reset",PlanPeriod:"plan_period"};var Vz={PerUnit:"per_unit",Tiered:"tiered"};var Dz={Licensed:"licensed",Metered:"metered"};var qz={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var Mz={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var Iz={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var Fz={Cancel:"cancel",Subscribe:"subscribe"};var Kz={Graduated:"graduated",Volume:"volume"};var Lz={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var Gz={Asc:"asc",Desc:"desc"};var Wz={Plan:"plan",Subscription:"subscription",Users:"users",LastSeenAt:"last_seen_at"};var Hz={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var Nz={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var $z={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var Jz={Billing:"billing",Entitlement:"entitlement"};var Yz={Draft:"draft",Live:"live"};var Zz={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Xz={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var Qz={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var eR={LeaseHold:"lease_hold",LeaseRelease:"lease_release",ManualAdjustment:"manual_adjustment",Reconciliation:"reconciliation",Track:"track"};var rR={OnPayment:"on_payment",OnPublish:"on_publish"};var iR={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var oR={Csv:"csv",CsvGz:"csv.gz"};var tR={Failure:"failure",Pending:"pending",Success:"success"};var aR={AuditLog:"audit-log",CompanyFeatureUsage:"company-feature-usage",Event:"event"};var nR={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var sR={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var cR={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var lR={Company:"company",User:"user"};var pR={Development:"development",Production:"production",Staging:"staging"};var uR={FlagCheck:"flag_check",Identify:"identify",Inference:"inference",Track:"track"};var dR={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var Do={FlagCheck:"flag_check",Identify:"identify",Inference:"inference",Track:"track"};var mR={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var hR={Boolean:"boolean",Event:"event",License:"license",Trait:"trait"};var gR={Active:"active",Created:"created",Pending:"pending"};var yR={Clerk:"clerk",Metronome:"metronome",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var wR={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var bR={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var zR={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var RR={AmbiguousSubscriptionItem:"ambiguous_subscription_item",MultipleSubscriptions:"multiple_subscriptions",NoPriceForInterval:"no_price_for_interval",NotOnOriginVersion:"not_on_origin_version",OperationItemNotFound:"operation_item_not_found",PermanentConfig:"permanent_config",PermanentDecline:"permanent_decline",TransientDecline:"transient_decline",TransientInfra:"transient_infra",TransientStripe:"transient_stripe",Unknown:"unknown",WouldLeaveEmptySubscription:"would_leave_empty_subscription"};var fR={Create:"create",Update:"update",Delete:"delete"};var _R={Checkout:"checkout",CompanyUpsert:"company_upsert",FallbackPlan:"fallback_plan",ManagePlan:"manage_plan",Migration:"migration",PlanBillingProductChanged:"plan_billing_product_changed",PlanDeleted:"plan_deleted",PlanTraitChange:"plan_trait_change",PlanVersionMigration:"plan_version_migration",Quickstart:"quickstart",SubscriptionChange:"subscription_change"};var SR={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var xR={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var PR={Fixed:"fixed",PerLicense:"per_license"};var ER={Amber:"amber",Blue:"blue",BlueGray:"blueGray",BlueGreen:"blueGreen",Cyan:"cyan",Emerald:"emerald",Fuchsia:"fuchsia",Gray:"gray",Green:"green",Indigo:"indigo",LightBlue:"lightBlue",Lime:"lime",Orange:"orange",Pink:"pink",Purple:"purple",Red:"red",RedOrange:"redOrange",Rose:"rose",Sky:"sky",Slate:"slate",Teal:"teal",TrueGray:"trueGray",Violet:"violet",WarmGray:"warmGray",Yellow:"yellow"};var CR={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var UR={Plan:"plan",AddOn:"add_on"};var vR={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var TR={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var OR={Immediate:"immediate",Leave:"leave"};var kR={Published:"published",Draft:"draft",Archived:"archived"};var BR={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var jR={V5B3E7220:"v5b3e7220",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var AR={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Ia={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var VR={Company:"company",User:"user"};var DR={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var qR={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var MR={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var IR={Bool:"bool",Date:"date",Int:"int",String:"string"};var FR={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var KR={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var LR={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var GR={Asc:"asc",Desc:"desc"};var WR={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var HR={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var NR={AeTrn:"ae_trn",AuAbn:"au_abn",AuArn:"au_arn",BrCnpj:"br_cnpj",BrCpf:"br_cpf",CaBn:"ca_bn",CaGstHst:"ca_gst_hst",CaPstBc:"ca_pst_bc",CaPstMb:"ca_pst_mb",CaPstSk:"ca_pst_sk",CaQst:"ca_qst",ChUid:"ch_uid",ChVat:"ch_vat",EuVat:"eu_vat",GbVat:"gb_vat",HkBr:"hk_br",IdNpwp:"id_npwp",IlVat:"il_vat",InGst:"in_gst",JpCn:"jp_cn",JpRn:"jp_rn",JpTrn:"jp_trn",KrBrn:"kr_brn",MxRfc:"mx_rfc",MyFrp:"my_frp",MyItn:"my_itn",MySst:"my_sst",NoVat:"no_vat",NzGst:"nz_gst",PhTin:"ph_tin",SaVat:"sa_vat",SgGst:"sg_gst",SgUen:"sg_uen",ThVat:"th_vat",TrTin:"tr_tin",TwVat:"tw_vat",UsEin:"us_ein",ZaVat:"za_vat"};var $R={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var JR={Bool:"bool",Date:"date",Int:"int",String:"string"};var YR={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var ZR={Active:"active",Converted:"converted",Expired:"expired"};var XR={Failure:"failure",Pending:"pending",Success:"success"};var QR={SubscriptionTrialEnded:"subscription.trial.ended",CompanyCreated:"company.created",CompanyDeleted:"company.deleted",CompanyOverrideCreated:"company.override.created",CompanyOverrideDeleted:"company.override.deleted",CompanyOverrideExpired:"company.override.expired",CompanyOverrideUpdated:"company.override.updated",CompanyPlanChanged:"company.plan_changed",CompanyScheduledDowngrade:"company.scheduled_downgrade",CompanyUpdated:"company.updated",CreditLimitReached:"credit.limit.reached",CreditLimitWarning:"credit.limit.warning",CreditPurchaseSuccess:"credit.purchase.success",EntitlementLimitReached:"entitlement.limit.reached",EntitlementLimitWarning:"entitlement.limit.warning",EntitlementSoftLimitReached:"entitlement.soft_limit.reached",EntitlementSoftLimitWarning:"entitlement.soft_limit.warning",EntitlementTierLimitReached:"entitlement.tier_limit.reached",EntitlementTierLimitWarning:"entitlement.tier_limit.warning",FeatureCreated:"feature.created",FeatureDeleted:"feature.deleted",FeatureUpdated:"feature.updated",FlagCreated:"flag.created",FlagDeleted:"flag.deleted",FlagRulesUpdated:"flag_rules.updated",FlagUpdated:"flag.updated",PlanCreated:"plan.created",PlanDeleted:"plan.deleted",PlanEntitlementCreated:"plan.entitlement.created",PlanEntitlementDeleted:"plan.entitlement.deleted",PlanEntitlementUpdated:"plan.entitlement.updated",PlanUpdated:"plan.updated",PlanVersionDeleted:"plan_version.deleted",RuleDeleted:"rule.deleted",TestSend:"test.send",UserCreated:"user.created",UserDeleted:"user.deleted",UserUpdated:"user.updated",AutoTopupHardFailure:"auto.topup.hard.failure",AutoTopupRetryExceeded:"auto.topup.retry.exceeded",AutoTopupSuccess:"auto.topup.success"};var ef={Active:"active",Inactive:"inactive"};var rf=2147483647,or=class{constructor({maxItems:o=1e3,ttl:i=5e3}={}){this.accessCounter=0;this.cache=new Map,this.maxItems=o,this.defaultTTL=i}async get(o){let i=this.cache.get(o);return i?i.expiration<=Date.now()?(this.evictItem(o,i),null):(this.accessCounter++,i.accessCounter=this.accessCounter,this.cache.set(o,i),i.value):null}async set(o,i,t){if(this.maxItems===0)return;let s=t??this.defaultTTL,r=this.cache.get(o);r&&this.evictItem(o,r),this.evictExpiredItems(),this.evictLRUItems(),this.accessCounter++;let a={value:i,accessCounter:this.accessCounter,expiration:Date.now()+s};a.timeoutId=setTimeout(()=>this.evictItem(o,a),Math.min(s,rf)),typeof a.timeoutId=="object"&&typeof a.timeoutId.unref=="function"&&a.timeoutId.unref(),this.cache.set(o,a)}async delete(o){let i=this.cache.get(o);i&&this.evictItem(o,i)}async deleteMissing(o,i){let t=new Set(o);for(let[s,r]of this.cache)t.has(s)||this.evictItem(s,r)}evictItem(o,i){i.timeoutId&&clearTimeout(i.timeoutId),this.cache.delete(o)}evictExpiredItems(){this.cache.forEach((o,i)=>{o.expiration<=Date.now()&&this.evictItem(i,o)})}evictLRUItems(){for(;this.cache.size>=this.maxItems;){let o,i=Number.MAX_SAFE_INTEGER;this.cache.forEach((t,s)=>{t.accessCounter<i&&(o=s,i=t.accessCounter)}),o&&this.evictItem(o,this.cache.get(o))}}};var ui=class{constructor(o){this.client=o.client,this.defaultTTL=Math.floor((o.ttl||5e3)/1e3),this.keyPrefix=o.keyPrefix||"schematic:"}getFullKey(o){return this.keyPrefix+o}async get(o){let i=this.getFullKey(o),t=await this.client.get(i);return t===null?null:JSON.parse(t)}async set(o,i,t){let s=this.getFullKey(o),r=JSON.stringify(i),a=t?Math.floor(t/1e3):this.defaultTTL;a>0?await this.client.setEx(s,a,r):await this.client.set(s,r)}async delete(o){let i=this.getFullKey(o);await this.client.del(i)}async deleteMissing(o,i){let t=i?.scanPattern?this.keyPrefix+i.scanPattern:this.keyPrefix+"*",s=new Set(o.map(d=>this.getFullKey(d))),r=[],a=1e3;for await(let d of this.client.scanIterator({MATCH:t,COUNT:1e3}))s.has(d)||(r.push(d),r.length>=a&&(await this.client.del(r),r.length=0));r.length>0&&await this.client.del(r)}};function Fa(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var yi=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var qo={get:async(p,o)=>typeof p=="function"?p(o):p};var Qe={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},gc={[Qe.Debug]:1,[Qe.Info]:2,[Qe.Warn]:3,[Qe.Error]:4},go=class{debug(o,...i){console.debug(o,...i)}info(o,...i){console.info(o,...i)}warn(o,...i){console.warn(o,...i)}error(o,...i){console.error(o,...i)}},wi=class{constructor(o){this.level=gc[o.level],this.logger=o.logger,this.silent=o.silent}shouldLog(o){return!this.silent&&this.level<=gc[o]}isDebug(){return this.shouldLog(Qe.Debug)}debug(o,...i){this.isDebug()&&this.logger.debug(o,...i)}isInfo(){return this.shouldLog(Qe.Info)}info(o,...i){this.isInfo()&&this.logger.info(o,...i)}isWarn(){return this.shouldLog(Qe.Warn)}warn(o,...i){this.isWarn()&&this.logger.warn(o,...i)}isError(){return this.shouldLog(Qe.Error)}error(o,...i){this.isError()&&this.logger.error(o,...i)}};function yo(p){return p==null?of:p instanceof wi?p:(p=p??{},p.level??=Qe.Info,p.logger??=new go,p.silent??=!0,new wi(p))}var of=new wi({level:Qe.Info,logger:new go,silent:!0});var tf={arrayFormat:"indices",encode:!0};function Ka(p,o){if(p===void 0||p===null)return"";let i=String(p);return o?encodeURIComponent(i):i}function La(p,o="",i){let t=[];for(let[s,r]of Object.entries(p)){let a=o?`${o}[${s}]`:s;if(r!==void 0)if(Array.isArray(r)){if(r.length===0)continue;let d=i.arrayFormat;if(d==="comma"){let y=i.encode?encodeURIComponent(a):a,g=r.filter(l=>l!=null).map(l=>Ka(l,i.encode));g.length>0&&t.push(`${y}=${g.join(",")}`)}else for(let y=0;y<r.length;y++){let g=r[y];if(g!==void 0)if(typeof g=="object"&&!Array.isArray(g)&&g!==null){let l=d==="indices"?`${a}[${y}]`:a;t.push(...La(g,l,i))}else{let l=d==="indices"?`${a}[${y}]`:a,h=i.encode?encodeURIComponent(l):l;t.push(`${h}=${Ka(g,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;t.push(...La(r,a,i))}else{let d=i.encode?encodeURIComponent(a):a;t.push(`${d}=${Ka(r,i.encode)}`)}}return t}function Pr(p,o){return p==null||typeof p!="object"?"":La(p,"",{...tf,...o}).join("&")}function Mo(p,o){let i=Pr(o,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function yc(p){let o={get bodyUsed(){return p.bodyUsed},stream:()=>p.body,arrayBuffer:p.arrayBuffer.bind(p),blob:p.blob.bind(p)};return"bytes"in p&&typeof p.bytes=="function"&&(o.bytes=p.bytes.bind(p)),o}var _e=af();function af(){if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let d=typeof process<"u"?process:void 0;return typeof d<"u"&&typeof d.versions?.node=="string"?{type:"node",version:d.versions.node,parsedVersion:Number(d.versions.node.split(".")[0])}:{type:"unknown"}}async function Sc(p){return _e.type==="node"&&_e.parsedVersion!=null&&_e.parsedVersion>=18?new(await Promise.resolve().then(()=>(bc(),wc))).Node18UniversalStreamWrapper(p):_e.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Rc(),zc))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(_c(),fc))).NodePre18StreamWrapper(p)}async function bi(p,o){switch(o){case"binary-response":return yc(p);case"blob":return await p.blob();case"arrayBuffer":return await p.arrayBuffer();case"sse":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:p.body;case"streaming":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:Sc(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return ho(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function xc(p){let o=p.headers.get("Content-Type")?.toLowerCase();if(o==null||o.length===0)return bi(p);switch(o.indexOf(";")!==-1&&(o=o.split(";")[0]?.trim()??""),o){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":{let i=await p.text();return i.length>0?ho(i):void 0}default:if(o.startsWith("application/vnd.")&&o.endsWith("+json")){let i=await p.text();return i.length>0?ho(i):void 0}return await p.text()}}async function zi(){return _e.type==="node"&&_e.parsedVersion!=null&&_e.parsedVersion>=18?fetch:_e.type==="node"?(await import("node-fetch")).default:typeof fetch=="function"?fetch:(await import("node-fetch")).default}async function Io({body:p,type:o}){return o==="form"?Pr(p,{arrayFormat:"repeat",encode:!0}):o.includes("json")?Te(p):p}var tr;typeof globalThis.Headers<"u"?tr=globalThis.Headers:tr=class Pc{constructor(o){if(this.headers=new Map,o)if(o instanceof Pc)o.forEach((i,t)=>this.append(t,i));else if(Array.isArray(o))for(let[i,t]of o)if(typeof i=="string"&&typeof t=="string")this.append(i,t);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[i,t]of Object.entries(o))if(typeof t=="string")this.append(i,t);else throw new TypeError("Header values must be strings")}append(o,i){let t=o.toLowerCase(),s=this.headers.get(t)||[];this.headers.set(t,[...s,i])}delete(o){let i=o.toLowerCase();this.headers.delete(i)}get(o){let i=o.toLowerCase(),t=this.headers.get(i);return t?t.join(", "):null}has(o){let i=o.toLowerCase();return this.headers.has(i)}set(o,i){let t=o.toLowerCase();this.headers.set(t,[i])}forEach(o,i){let t=i?o.bind(i):o;this.headers.forEach((s,r)=>t(s.join(", "),r,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[o,i]of this.headers.entries())yield[o,i.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let o of this.headers.values())yield o.join(", ")}[Symbol.iterator](){return this.entries()}};var nf="timeout";function Ec(p){let o=new AbortController,i=setTimeout(()=>o.abort(nf),p);return{signal:o.signal,abortId:i}}function Cc(...p){let o=p.length===1&&Array.isArray(p[0])?p[0]:p,i=new AbortController;for(let t of o){if(t.aborted){i.abort(t?.reason);break}t.addEventListener("abort",()=>i.abort(t?.reason),{signal:i.signal})}return i.signal}var wo;function sf(){if(wo!=null)return wo;try{new Request("http://localhost",{cache:"no-store"}),wo=!0}catch{wo=!1}return wo}var Ri=async(p,o,i,t,s,r,a,d,y,g)=>{let l=[],h;if(r!=null){let{signal:T,abortId:O}=Ec(r);h=O,l.push(T)}a!=null&&l.push(a);let w=Cc(l),U=await p(o,{method:i,headers:t,body:s,signal:w,credentials:d?"include":void 0,duplex:y,...g&&sf()?{cache:"no-store"}:{}});return h!=null&&clearTimeout(h),U};var fi={headers:new tr,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},_i={headers:new tr,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function bo(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function cf(p){return[408,429].includes(p)||p>=500}function lf(p){let o=1+Math.random()*.2;return p*o}function pf(p){let o=1+(Math.random()-.5)*.2;return p*o}function uf(p,o){let i=p.headers.get("Retry-After");if(i){let s=parseInt(i,10);if(!Number.isNaN(s)&&s>0)return Math.min(s*1e3,6e4);let r=new Date(i);if(!Number.isNaN(r.getTime())){let a=r.getTime()-Date.now();if(a>0)return Math.min(Math.max(a,0),6e4)}}let t=p.headers.get("X-RateLimit-Reset");if(t){let s=parseInt(t,10);if(!Number.isNaN(s)){let r=s*1e3-Date.now();if(r>0)return lf(Math.min(r,6e4))}}return pf(Math.min(1e3*2**o,6e4))}async function Si(p,o=2){let i=await p();for(let t=0;t<o&&cf(i.status);++t){let s=uf(i,t);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var df=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function Na(p){let o={};for(let[i,t]of p instanceof tr?p.entries():Object.entries(p))df.has(i.toLowerCase())?o[i]="[REDACTED]":o[i]=t;return o}var $a=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function mf(p){if(p==null)return;let o={};for(let[i,t]of Object.entries(p))o[i]=$a.has(i.toLowerCase())?"[REDACTED]":t;return o}function di(p){let o=p.indexOf("://");if(o===-1)return p;let i=o+3,t=p.indexOf("/",i),s=p.indexOf("?",i),r=p.indexOf("#",i),a=Math.min(t===-1?p.length:t,s===-1?p.length:s,r===-1?p.length:r),d=-1;for(let T=i;T<a;T++)p[T]==="@"&&(d=T);if(d!==-1&&(p=`${p.slice(0,i)}[REDACTED]@${p.slice(d+1)}`),s=p.indexOf("?"),s===-1)return p;r=p.indexOf("#",s);let y=r!==-1?r:p.length,g=p.slice(s+1,y);if(g.length===0)return p;let l=g.toLowerCase();if(!(l.includes("token")||l.includes("key")||l.includes("password")||l.includes("passwd")||l.includes("secret")||l.includes("session")||l.includes("auth")))return p;let w=[],U=g.split("&");for(let T of U){let O=T.indexOf("=");if(O===-1){w.push(T);continue}let B=T.slice(0,O),j=$a.has(B.toLowerCase());if(!j&&B.includes("%"))try{let K=decodeURIComponent(B);j=$a.has(K.toLowerCase())}catch{}w.push(j?`${B}=[REDACTED]`:T)}return p.slice(0,s+1)+w.join("&")+p.slice(y)}async function hf(p){let o=new tr;if(o.set("Accept",p.responseType==="json"?"application/json":p.responseType==="text"?"text/plain":p.responseType==="sse"?"text/event-stream":"*/*"),p.body!==void 0&&p.contentType!=null&&o.set("Content-Type",p.contentType),p.headers==null)return o;for(let[i,t]of Object.entries(p.headers)){let s=await qo.get(t,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){o.set(i,s);continue}s!=null&&o.set(i,`${s}`)}return o}async function gf(p){let o=p.url;p.queryString!=null&&p.queryString.length>0?o=`${o}?${p.queryString}`:o=Mo(p.url,p.queryParameters);let i=await Io({body:p.body,type:p.requestType??"other"}),t=p.fetchFn??await zi(),s=await hf(p),r=yo(p.logging);if(r.isDebug()){let a={method:p.method,url:di(o),headers:Na(s),queryParameters:mf(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",a)}try{let a=await Si(async()=>Ri(t,o,p.method,s,i,p.timeoutMs,p.abortSignal,p.withCredentials,p.duplex,p.responseType==="streaming"||p.responseType==="sse"),p.maxRetries);if(a.status>=200&&a.status<400){if(r.isDebug()){let y={method:p.method,url:di(o),statusCode:a.status,responseHeaders:Na(a.headers)};r.debug("HTTP request succeeded",y)}return{ok:!0,body:await bi(a,p.responseType),headers:a.headers,rawResponse:bo(a)}}else{if(r.isError()){let d={method:p.method,url:di(o),statusCode:a.status,responseHeaders:Na(Object.fromEntries(a.headers.entries()))};r.error("HTTP request failed with error status",d)}return{ok:!1,error:{reason:"status-code",statusCode:a.status,body:await xc(a)},rawResponse:bo(a)}}}catch(a){if(p.abortSignal?.aborted){if(r.isError()){let d={method:p.method,url:di(o)};r.error("HTTP request was aborted",d)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:a},rawResponse:fi}}else if(a instanceof Error&&a.name==="AbortError"){if(r.isError()){let d={method:p.method,url:di(o),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",d)}return{ok:!1,error:{reason:"timeout",cause:a},rawResponse:fi}}else if(a instanceof Error){if(r.isError()){let d={method:p.method,url:di(o),errorMessage:a.message};r.error("HTTP request failed with error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:a.message,cause:a},rawResponse:_i}}if(r.isError()){let d={method:p.method,url:di(o),error:Te(a)};r.error("HTTP request failed with unknown error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:Te(a),cause:a},rawResponse:_i}}}var E=gf;var R=class p extends Promise{constructor(o){super(i=>{i(void 0)}),this.innerPromise=o}static fromFunction(o,...i){return new p(o(...i))}static interceptFunction(o){return(...i)=>p.fromPromise(o(...i))}static fromPromise(o){return new p(o)}static fromExecutor(o){let i=new Promise(o);return new p(i)}static fromResult(o){let i=Promise.resolve(o);return new p(i)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:o})=>o)),this.unwrappedPromise}then(o,i){return this.unwrap().then(o,i)}catch(o){return this.unwrap().catch(o)}finally(o){return this.unwrap().finally(o)}async withRawResponse(){return await this.innerPromise}};function Fo(p,...o){if(!p)return"";if(o.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return Uc(p,...o)}let s=o[o.length-1]?.endsWith("/");for(let r of o){let a=Tc(r);a&&(i.pathname=vc(i.pathname,a))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return Uc(p,...o)}function Uc(p,...o){if(o.length===0)return p;let i=p,s=o[o.length-1]?.endsWith("/");for(let r of o){let a=Tc(r);a&&(i=vc(i,a))}return s&&!i.endsWith("/")&&(i+="/"),i}function vc(p,o){return p.endsWith("/")?p+o:`${p}/${o}`}function Tc(p){if(!p)return p;let o=0,i=p.length;return p.startsWith("/")&&(o=1),p.endsWith("/")&&(i=p.length-1),o===0&&i===p.length?p:p.slice(o,i)}var m={get:async p=>typeof p=="function"?p():p};async function Ja(p,o,i,t){let s=yo(i.logging),r,a=o;p instanceof Request?(r=p.url,o==null&&(a={method:p.method,headers:Object.fromEntries(p.headers.entries()),body:p.body,signal:p.signal,credentials:p.credentials,cache:p.cache,redirect:p.redirect,referrer:p.referrer,integrity:p.integrity,mode:p.mode})):r=p instanceof URL?p.toString():p;let d=(i.baseUrl!=null?await m.get(i.baseUrl):void 0)??(i.environment!=null?await m.get(i.environment):void 0),y;r.startsWith("http://")||r.startsWith("https://")?y=r:d!=null?y=Fo(d,r):y=r;let g={};if(i.headers!=null)for(let[K,A]of Object.entries(i.headers)){let Z=await qo.get(A,{endpointMetadata:{}});Z!=null&&(g[K.toLowerCase()]=`${Z}`)}if(i.getAuthHeaders!=null){let K=await i.getAuthHeaders();for(let[A,Z]of Object.entries(K))g[A.toLowerCase()]=Z}if(a?.headers!=null){let K=a.headers instanceof Headers?Object.fromEntries(a.headers.entries()):Array.isArray(a.headers)?Object.fromEntries(a.headers):a.headers;for(let[A,Z]of Object.entries(K))Z!=null&&(g[A.toLowerCase()]=Z)}if(t?.headers!=null)for(let[K,A]of Object.entries(t.headers))g[K.toLowerCase()]=A;let l=a?.method??"GET",h=a?.body,w=t?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,T=t?.maxRetries??i.maxRetries,O=t?.abortSignal??a?.signal??void 0,B=i.fetch??await zi();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:l,url:y,hasBody:h!=null});let j=await Si(async()=>Ri(B,y,l,g,h??void 0,U,O,a?.credentials==="include",void 0,!1),T);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:l,url:y,statusCode:j.status}),j}var Ko={};xr(Ko,{ConsoleLogger:()=>go,LogLevel:()=>Qe,Logger:()=>wi,createLogger:()=>yo});var e={};xr(e,{JsonError:()=>xi,ParseError:()=>Pi,any:()=>Wc,bigint:()=>kc,boolean:()=>Hc,booleanLiteral:()=>Lc,date:()=>Bc,discriminant:()=>il,enum_:()=>zo,forwardCompatibleEnum_:()=>jc,getObjectLikeUtils:()=>er,getObjectUtils:()=>mi,getSchemaUtils:()=>Y,isProperty:()=>Cr,lazy:()=>Ac,lazyObject:()=>Fc,list:()=>Wo,never:()=>Nc,number:()=>$c,object:()=>Go,objectWithoutOptionalProperties:()=>Ic,optional:()=>Ya,partialRecord:()=>Xc,property:()=>Dc,record:()=>Zc,set:()=>Qc,string:()=>Jc,stringLiteral:()=>Gc,transform:()=>Za,undiscriminatedUnion:()=>rl,union:()=>tl,unknown:()=>Yc,withParsedProperties:()=>en});var F={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function J(p,o){return`Expected ${o}. Received ${yf(p)}.`}function yf(p){if(Array.isArray(p))return"list";if(p===null)return"null";if(p instanceof BigInt)return"BigInt";switch(typeof p){case"string":return`"${p}"`;case"bigint":case"number":case"boolean":case"undefined":return`${p}`}return typeof p}function we(p){return{...p,json:Oc(p.json),parse:Oc(p.parse)}}function Oc(p){return(o,i)=>{let t=p(o,i),{skipValidation:s=!1}=i??{};return!t.ok&&s?(console.warn(["Failed to validate.",...t.errors.map(r=>" - "+(r.path.length>0?`${r.path.join(".")}: ${r.message}`:r.message))].join(`
|
|
3
|
+
`)),{ok:!0,value:o}):t}}function Lo(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var xi=class extends Error{constructor(i){super(i.map(Lo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var Pi=class extends Error{constructor(i){super(i.map(Lo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function Y(p){return{nullable:()=>wf(p),optional:()=>Ya(p),optionalNullable:()=>bf(p),transform:o=>Za(p,o),parseOrThrow:(o,i)=>{let t=p.parse(o,i);if(t.ok)return t.value;throw new Pi(t.errors)},jsonOrThrow:(o,i)=>{let t=p.json(o,i);if(t.ok)return t.value;throw new xi(t.errors)}}}function wf(p){let o={parse:(i,t)=>i==null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>F.NULLABLE};return{...o,...Y(o)}}function Ya(p){let o={parse:(i,t)=>i==null?{ok:!0,value:void 0}:p.parse(i,t),json:(i,t)=>t?.omitUndefined&&i===void 0?{ok:!0,value:void 0}:i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>F.OPTIONAL};return{...o,...Y(o)}}function bf(p){let o={parse:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.json(i,t),getType:()=>F.OPTIONAL_NULLABLE};return{...o,...Y(o)}}function Za(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);return r.ok?{ok:!0,value:o.transform(r.value)}:r},json:(t,s)=>{let r=o.untransform(t);return p.json(r,s)},getType:()=>p.getType()};return{...i,...Y(i)}}function kc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o=="bigint"?{ok:!0,value:o}:typeof o=="number"?{ok:!0,value:BigInt(o)}:{ok:!1,errors:[{path:i,message:J(o,"bigint | number")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="bigint"?{ok:!1,errors:[{path:i,message:J(o,"bigint")}]}:{ok:!0,value:o},getType:()=>F.BIGINT};return{...we(p),...Y(p)}}var zf=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Bc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:i,message:J(o,"string")}]}:zf.test(o)?{ok:!0,value:new Date(o)}:{ok:!1,errors:[{path:i,message:J(o,"ISO 8601 date string")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>o instanceof Date?{ok:!0,value:o.toISOString()}:{ok:!1,errors:[{path:i,message:J(o,"Date object")}]},getType:()=>F.DATE};return{...we(p),...Y(p)}}function ze(p,o){return()=>{let i={parse:o,json:o,getType:()=>p};return{...we(i),...Y(i)}}}function zo(p){let o=new Set(p);return ze(F.ENUM,(t,{allowUnrecognizedEnumValues:s,breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:J(t,"string")}]}:!o.has(t)&&!s?{ok:!1,errors:[{path:r,message:J(t,"enum")}]}:{ok:!0,value:t})()}function jc(p){return zo(p).transform({transform:o=>o,untransform:o=>o})}function Ac(p){let o=Xa(p);return{...o,...Y(o)}}function Xa(p){return{parse:(o,i)=>Ei(p).parse(o,i),json:(o,i)=>Ei(p).json(o,i),getType:()=>Ei(p).getType()}}function Ei(p){let o=p;return o.__zurg_memoized==null&&(o.__zurg_memoized=p()),o.__zurg_memoized}function Qa(p){return Object.entries(p)}function Ro(p,o){let i=new Set(o);return Object.entries(p).reduce((t,[s,r])=>(i.has(s)&&(t[s]=r),t),{})}function Er(p){if(typeof p!="object"||p===null)return!1;let o=Object.getPrototypeOf(p);return o===null?!0:Object.getPrototypeOf(o)===null}function fo(p){return Object.keys(p)}function Vc(p,o){let i=[],t=[];for(let s of p)o(s)?i.push(s):t.push(s);return[i,t]}var Rf=Object.prototype.hasOwnProperty;function er(p){return{withParsedProperties:o=>en(p,o)}}function en(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);if(!r.ok)return r;let a={};for(let d in o)if(Rf.call(o,d)){let y=o[d];a[d]=typeof y=="function"?y(r.value):y}return{ok:!0,value:{...r.value,...a}}},json:(t,s)=>{if(!Er(t))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(t,"object")}]};let r=new Set(Object.keys(o)),a=Ro(t,Object.keys(t).filter(d=>!r.has(d)));return p.json(a,s)},getType:()=>p.getType()};return{...i,...Y(i),...er(i)}}function Dc(p,o){return{rawKey:p,valueSchema:o,isProperty:!0}}function Cr(p){return p.isProperty}var ff=Object.prototype.hasOwnProperty;function Go(p){let o;function i(){if(o==null){o={};for(let[w,U]of Qa(p)){let T=Cr(U)?U.rawKey:w,O=Cr(U)?U.valueSchema:U;o[T]={rawKey:T,parsedKey:w,valueSchema:O}}}return o}let t,s,r,a;function d(){if(t==null){t=[],s=[];for(let[w,U]of Qa(p)){let T=Cr(U)?U.rawKey:w,O=Cr(U)?U.valueSchema:U;_f(O)&&(t.push(T),s.push(w))}r=new Set(t),a=new Set(s)}return t}function y(){return s==null&&d(),s}function g(){return r==null&&d(),r}function l(){return a==null&&d(),a}let h={_getRawProperties:()=>Object.entries(p).map(([w,U])=>Cr(U)?U.rawKey:w),_getParsedProperties:()=>fo(p),parse:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return qc({value:w,requiredKeys:d(),requiredKeysSet:g(),getProperty:O=>{let B=i()[O];if(B!=null)return{transformedKey:B.parsedKey,transform:j=>{let K=[...T,O];return B.valueSchema.parse(j,{...U,breadcrumbsPrefix:K})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return qc({value:w,requiredKeys:y(),requiredKeysSet:l(),getProperty:O=>{let B=p[O];if(B!=null)return Cr(B)?{transformedKey:B.rawKey,transform:j=>{let K=[...T,O];return B.valueSchema.json(j,{...U,breadcrumbsPrefix:K})}}:{transformedKey:O,transform:j=>{let K=[...T,O];return B.json(j,{...U,breadcrumbsPrefix:K})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},getType:()=>F.OBJECT};return{...we(h),...Y(h),...er(h),...mi(h)}}function qc({value:p,requiredKeys:o,requiredKeysSet:i,getProperty:t,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:a=[]}){if(!Er(p))return{ok:!1,errors:[{path:a,message:J(p,"object")}]};let d=o.length,y=[],g={};for(let l in p){if(!ff.call(p,l))continue;let h=p[l],w=t(l);if(w!=null){d>0&&i.has(l)&&d--;let U=w.transform(h);U.ok?g[w.transformedKey]=U.value:(g[l]=h,y.push(...U.errors))}else switch(s){case"fail":y.push({path:[...a,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":g[l]=h;break}}if(d>0)for(let l of o)l in p||y.push({path:a,message:`Missing required key "${l}"`});return y.length===0||r?{ok:!0,value:g}:{ok:!1,errors:y}}function mi(p){return{extend:o=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...o._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...o._getRawProperties()],parse:(t,s)=>Mc({extensionKeys:o._getRawProperties(),value:t,transformBase:r=>p.parse(r,s),transformExtension:r=>o.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Mc({extensionKeys:o._getParsedProperties(),value:t,transformBase:r=>p.json(r,s),transformExtension:r=>o.json(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>F.OBJECT};return{...i,...Y(i),...er(i),...mi(i)}},passthrough:()=>{let o=new Set(p._getRawProperties()),i=new Set(p._getParsedProperties()),t={_getParsedProperties:()=>p._getParsedProperties(),_getRawProperties:()=>p._getRawProperties(),parse:(s,r)=>{let a=p.parse(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let d={};if(typeof s=="object"&&s!=null)for(let[y,g]of Object.entries(s))o.has(y)||(d[y]=g);return{ok:!0,value:{...d,...a.value}}},json:(s,r)=>{let a=p.json(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let d={};if(typeof s=="object"&&s!=null)for(let[y,g]of Object.entries(s))i.has(y)||(d[y]=g);return{ok:!0,value:{...d,...a.value}}},getType:()=>F.OBJECT};return{...t,...Y(t),...er(t),...mi(t)}}}}function Mc({extensionKeys:p,value:o,transformBase:i,transformExtension:t,breadcrumbsPrefix:s=[]}){if(!Er(o))return{ok:!1,errors:[{path:s,message:J(o,"object")}]};let r=new Set(p),[a,d]=Vc(fo(o),l=>r.has(l)),y=i(Ro(o,d)),g=t(Ro(o,a));return y.ok&&g.ok?{ok:!0,value:{...y.value,...g.value}}:{ok:!1,errors:[...y.ok?[]:y.errors,...g.ok?[]:g.errors]}}function _f(p){return!Sf(p)}function Sf(p){switch(p.getType()){case F.ANY:case F.UNKNOWN:case F.OPTIONAL:case F.OPTIONAL_NULLABLE:return!0;default:return!1}}function Ic(p){return Go(p)}function Fc(p){let o={...Xa(p),_getRawProperties:()=>Ei(p)._getRawProperties(),_getParsedProperties:()=>Ei(p)._getParsedProperties()};return{...o,...Y(o),...er(o),...mi(o)}}function Wo(p){let o={parse:(i,t)=>Kc(i,(s,r)=>p.parse(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,t)=>Kc(i,(s,r)=>p.json(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>F.LIST};return{...we(o),...Y(o)}}function Kc(p,o){if(!Array.isArray(p))return{ok:!1,errors:[{message:J(p,"list"),path:[]}]};let i=[],t=[];for(let s=0;s<p.length;s++){let r=o(p[s],s);r.ok?i.push(r.value):t.push(...r.errors)}return t.length===0?{ok:!0,value:i}:{ok:!1,errors:t}}function Lc(p){return ze(F.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(i,`${p.toString()}`)}]})()}function Gc(p){return ze(F.STRING_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(i,`"${p}"`)}]})()}var Wc=ze(F.ANY,p=>({ok:!0,value:p}));var Hc=ze(F.BOOLEAN,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"boolean")}]});var Nc=ze(F.NEVER,(p,{breadcrumbsPrefix:o=[]}={})=>({ok:!1,errors:[{path:o,message:"Expected never"}]}));var $c=ze(F.NUMBER,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"number")}]});var Jc=ze(F.STRING,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"string")}]});var Yc=ze(F.UNKNOWN,p=>({ok:!0,value:p}));var xf=Object.prototype.hasOwnProperty;function Zc(p,o){let i={parse:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===F.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===F.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>F.RECORD};return{...we(i),...Y(i)}}function Xc(p,o){let i={parse:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===F.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Ho({value:t,isKeyNumeric:p.getType()===F.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>F.RECORD};return{...we(i),...Y(i)}}function Ho({value:p,isKeyNumeric:o,transformKey:i,transformValue:t,breadcrumbsPrefix:s=[]}){if(!Er(p))return{ok:!1,errors:[{path:s,message:J(p,"object")}]};let r={},a=[];for(let d in p){if(!xf.call(p,d))continue;let y=p[d];if(y===void 0)continue;let g=d;if(o){let w=d.length>0?Number(d):NaN;Number.isNaN(w)||(g=w)}let l=i(g),h=t(y,g);l.ok&&h.ok?r[l.value]=h.value:(l.ok||a.push(...l.errors),h.ok||a.push(...h.errors))}return a.length===0?{ok:!0,value:r}:{ok:!1,errors:a}}function Qc(p){let o=Wo(p),i={parse:(t,s)=>{let r=o.parse(t,s);return r.ok?{ok:!0,value:new Set(r.value)}:r},json:(t,s)=>t instanceof Set?o.json([...t],s):{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(t,"Set")}]},getType:()=>F.SET};return{...we(i),...Y(i)}}function rl(p){let o={parse:(i,t)=>el((s,r)=>s.parse(i,r),p,t),json:(i,t)=>el((s,r)=>s.json(i,r),p,t),getType:()=>F.UNDISCRIMINATED_UNION};return{...we(o),...Y(o)}}function el(p,o,i){let t=[];for(let[s,r]of o.entries()){let a=p(r,{...i,skipValidation:!1});if(a.ok)return a;for(let d of a.errors)t.push({path:d.path,message:`[Variant ${s}] ${d.message}`})}return{ok:!1,errors:t}}function il(p,o){return{parsedDiscriminant:p,rawDiscriminant:o}}var Pf=Object.prototype.hasOwnProperty;function tl(p,o){let i=typeof p=="string"?p:p.rawDiscriminant,t=typeof p=="string"?p:p.parsedDiscriminant,s=zo(fo(o)),r={parse:(a,d)=>ol({value:a,discriminant:i,transformedDiscriminant:t,transformDiscriminantValue:y=>s.parse(y,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:y=>o[y],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(y,g)=>g.parse(y,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),json:(a,d)=>ol({value:a,discriminant:t,transformedDiscriminant:i,transformDiscriminantValue:y=>s.json(y,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],t]}),getAdditionalPropertiesSchema:y=>o[y],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(y,g)=>g.json(y,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),getType:()=>F.UNION};return{...we(r),...Y(r),...er(r)}}function ol({value:p,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:t,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:a,breadcrumbsPrefix:d=[]}){if(!Er(p))return{ok:!1,errors:[{path:d,message:J(p,"object")}]};let y=p[o],g={};for(let U in p)Pf.call(p,U)&&U!==o&&(g[U]=p[U]);if(y==null)return{ok:!1,errors:[{path:d,message:`Missing discriminant ("${o}")`}]};let l=t(y);if(!l.ok)return{ok:!1,errors:l.errors};let h=s(l.value);if(h==null)return r?{ok:!0,value:{[i]:l.value,...g}}:{ok:!1,errors:[{path:[...d,o],message:"Unexpected discriminant value"}]};let w=a(g,h);return w.ok?{ok:!0,value:{[i]:y,...w.value}}:w}var u={};xr(u,{encodePathParam:()=>al,join:()=>Fo,queryBuilder:()=>nl,toQueryString:()=>Pr});function al(p){if(p===null)return"null";switch(typeof p){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:p=String(p);break}return encodeURIComponent(p)}function nl(){return new rn}var rn=class{constructor(){this.parts=new Map}add(o,i,t){if(i==null)return this;let s=Pr({[o]:i},{arrayFormat:t?.style==="comma"?"comma":"repeat"});return s.length>0&&this.parts.set(o,s),this}addMany(o){if(o!=null)for(let[i,t]of Object.entries(o))this.add(i,t);return this}mergeAdditional(o){if(o!=null)for(let[i,t]of Object.entries(o)){if(t==null)continue;let s=Pr({[i]:t},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var on="apiKey",Ef="X-Schematic-Api-Key",Ci=class p{constructor(o){this.options=o}static canCreate(o){return o?.[on]!=null}async getAuthRequest({endpointMetadata:o}={}){let i=await m.get(this.options[on]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[Ef]:i}}}};(t=>{t.AUTH_SCHEME="ApiKeyAuth",t.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${on}' when initializing the client`;function i(s){return new t(s)}t.createInstance=i})(Ci||={});function f(...p){let o={};for(let[i,t]of p.filter(s=>s!=null).flatMap(s=>Object.entries(s))){let s=i.toLowerCase();t!=null?o[s]=t:s in o&&delete o[s]}return o}function Cf(p){let o=f({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.8","User-Agent":"@schematichq/schematic-typescript-node/1.5.8","X-Fern-Runtime":_e.type,"X-Fern-Runtime-Version":_e.version},p?.headers);return{...p,logging:Ko.createLogger(p?.logging),headers:o}}function L(p){let o=Cf(p);if(p.auth===!1)return o.authProvider=new yi,o;if(p.auth!=null){if(typeof p.auth=="function")return o.authProvider={getAuthRequest:p.auth},o;if(Fa(p.auth))return o.authProvider=p.auth,o;Object.assign(o,p.auth)}let i=Uf(o);return o.authProvider??=new Ci(i),o}function Uf(p){return{...p,authProvider:new yi}}var z={Default:"https://api.schematichq.com"};function C(p,o,i,t){switch(p.reason){case"non-json":throw new b({statusCode:p.statusCode,body:p.rawBody,rawResponse:o});case"body-is-null":throw new b({statusCode:p.statusCode,rawResponse:o});case"timeout":throw new pi(`Timeout exceeded when calling ${i} ${t}.`,{cause:p.cause});case"unknown":throw new b({message:p.errorMessage,rawResponse:o,cause:p.cause});default:throw new b({message:"Unknown error",rawResponse:o})}}var tn=e.object({lookup:e.record(e.string(),e.string())});var sl=e.stringLiteral("company");var cl=e.object({apiKeyId:e.property("api_key_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expiredAt:e.property("expired_at",e.date()),id:e.string(),resourceType:e.property("resource_type",sl),token:e.string(),updatedAt:e.property("updated_at",e.date())});var ll=e.object({data:cl,params:e.record(e.string(),e.unknown())});var an=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional()),readonly:e.boolean().optional()});var Dr=e.enum_(["development","production","staging"]);var nn=e.object({environmentType:e.property("environment_type",Dr),name:e.string()});var sn=e.object({description:e.string().optional(),name:e.string().optional(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional())});var cn=e.object({environmentType:e.property("environment_type",Dr.optional()),name:e.string().optional()});var Ur=e.enum_(["admin","member"]);var pl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),role:Ur.optional()});var V=e.object({count:e.number().optional()});var ul=e.object({data:V,params:pl});var dl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var ml=e.object({data:V,params:dl});var Ue=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var hl=e.object({actorType:e.property("actor_type",Ue.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var gl=e.object({data:V,params:hl});var Ie=e.enum_(["active","created","pending"]);var Pe=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var No=e.object({id:e.string(),state:Ie,type:Pe});var $o=e.enum_(["admin","capture","read","write"]);var Ee=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",Dr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var yl=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Ee.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:No.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional()),readonly:e.boolean(),scopes:e.list($o),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var wl=e.object({data:yl,params:e.record(e.string(),e.unknown())});var Ce=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Ee.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:No.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),rateLimitPercent:e.property("rate_limit_percent",e.number().optional()),readonly:e.boolean(),scopes:e.list($o),updatedAt:e.property("updated_at",e.date())});var bl=e.object({apiKeys:e.property("api_keys",e.list(Ce)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",Dr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var zl=e.object({data:bl,params:e.record(e.string(),e.unknown())});var q=e.object({deleted:e.boolean().optional()});var Rl=e.object({data:q,params:e.record(e.string(),e.unknown())});var fl=e.object({data:q,params:e.record(e.string(),e.unknown())});var _l=e.enum_(["companies_edit","company_users_edit","components_edit","custom_plans_edit","data_exports_edit","features_edit","flag_rules_edit","flags_edit","overrides_edit","plan_billing_edit","plan_entitlements_edit","plan_versions_edit","plans_edit","webhooks_edit","webhooks_reveal_secret"]);var qr=e.object({createdAt:e.property("created_at",e.date()),email:e.string().optional(),firstName:e.property("first_name",e.string().optional()),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),lastName:e.property("last_name",e.string().optional()),name:e.string().optional(),permissions:e.record(e.string(),e.list(_l)),role:Ur.optional(),updatedAt:e.property("updated_at",e.date())});var Sl=e.object({data:qr,params:e.record(e.string(),e.unknown())});var xl=e.object({data:Ce,params:e.record(e.string(),e.unknown())});var Pl=e.object({actorType:e.property("actor_type",Ue),apiKey:e.property("api_key",Ce.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Ee.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),reqBody:e.property("req_body",e.string().optional()),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respBody:e.property("resp_body",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var El=e.object({data:Pl,params:e.record(e.string(),e.unknown())});var Cl=e.object({data:Ee,params:e.record(e.string(),e.unknown())});var Ul=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",Ue),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(Ee),stripeUserId:e.property("stripe_user_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var vl=e.object({data:Ul,params:e.record(e.string(),e.unknown())});var Tl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),role:Ur.optional()});var Ol=e.object({data:e.list(qr),params:Tl});var kl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var Bl=e.object({data:e.list(Ce),params:kl});var jl=e.object({actorType:e.property("actor_type",Ue.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Jo=e.object({actorType:e.property("actor_type",Ue),apiKey:e.property("api_key",Ce.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Ee.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userName:e.property("user_name",e.string().optional())});var Al=e.object({data:e.list(Jo),params:jl});var Vl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var Dl=e.object({data:e.list(Ee),params:Vl});var ql=e.object({ok:e.boolean()});var Ml=e.object({data:ql,params:e.record(e.string(),e.unknown())});var Il=e.object({data:Ce,params:e.record(e.string(),e.unknown())});var Fl=e.object({data:Ee,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var ln=e.object({companyId:e.property("company_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),email:e.string(),externalId:e.property("external_id",e.string()),meta:e.record(e.string(),e.string()),name:e.string(),providerType:e.property("provider_type",k.optional())});var ar=e.enum_(["per_unit","tiered"]);var pe=e.enum_(["licensed","metered"]);var me=e.enum_(["graduated","volume"]);var Kl=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitDecimal:e.property("per_unit_decimal",e.string().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),priceExternalId:e.property("price_external_id",e.string()),providerType:e.property("provider_type",k.optional()),upTo:e.property("up_to",e.number().optional())});var pn=e.object({billingScheme:e.property("billing_scheme",ar),currency:e.string(),externalAccountId:e.property("external_account_id",e.string()),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceTiers:e.property("price_tiers",e.list(Kl)),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k.optional()),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",pe)});var un=e.object({externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean().optional()),name:e.string().optional(),price:e.number(),providerType:e.property("provider_type",k.optional())});var Ll=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),currency:e.string(),interval:e.string(),meterId:e.property("meter_id",e.string().optional()),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),quantity:e.number(),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),usageType:e.property("usage_type",pe)});var Gl=e.object({couponExternalId:e.property("coupon_external_id",e.string()),customerFacingCode:e.property("customer_facing_code",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var Mr=e.enum_(["cancel","subscribe"]);var dn=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodExternalId:e.property("default_payment_method_external_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(Gl),expiredAt:e.property("expired_at",e.date()),interval:e.string().optional(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number().optional()),periodStart:e.property("period_start",e.number().optional()),productExternalIds:e.property("product_external_ids",e.list(Ll)),providerType:e.property("provider_type",k.optional()),status:e.string().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Mr.optional())});var mn=e.object({amountOff:e.property("amount_off",e.number()),currency:e.string().optional(),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number()),externalId:e.property("external_id",e.string()),maxRedemptions:e.property("max_redemptions",e.number()),name:e.string(),percentOff:e.property("percent_off",e.number()),timesRedeemed:e.property("times_redeemed",e.number())});var Yo=e.enum_(["draft","open","paid","uncollectible","void"]);var hn=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number().optional()),externalId:e.property("external_id",e.string().optional()),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),startingBalance:e.property("starting_balance",e.number().optional()),status:Yo.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var gn=e.object({displayName:e.property("display_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalId:e.property("external_id",e.string()),providerType:e.property("provider_type",k.optional())});var yn=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string()),externalId:e.property("external_id",e.string()),paymentMethodType:e.property("payment_method_type",e.string())});var Wl=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",pe.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var Hl=e.object({data:V,params:Wl});var Nl=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var $l=e.object({data:V,params:Nl});var Jl=e.object({data:q,params:e.record(e.string(),e.unknown())});var Yl=e.object({data:q,params:e.record(e.string(),e.unknown())});var Zl=e.object({data:q,params:e.record(e.string(),e.unknown())});var Xl=e.object({data:q,params:e.record(e.string(),e.unknown())});var Ql=e.object({data:q,params:e.record(e.string(),e.unknown())});var ep=e.object({data:q,params:e.record(e.string(),e.unknown())});var rp=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",pe.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Ui=e.enum_(["day","month","one-time","year"]);var Zo=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var N=e.object({billingScheme:e.property("billing_scheme",ar),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:Ui,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterEventName:e.property("meter_event_name",e.string().optional()),meterEventPayloadKey:e.property("meter_event_payload_key",e.string().optional()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list(Zo)),productExternalId:e.property("product_external_id",e.string()),productId:e.property("product_id",e.string()),productName:e.property("product_name",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",me.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",pe)});var ip=e.object({data:e.list(N),params:rp});var op=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",pe.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var tp=e.object({data:e.list(N),params:op});var ap=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",pe.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var G=e.object({currency:e.string(),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),interval:Ui,intervalCount:e.property("interval_count",e.number()),nickname:e.string().optional(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),providerType:e.property("provider_type",k),scheme:ar});var nr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),prices:e.list(G),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionCount:e.property("subscription_count",e.number()),updatedAt:e.property("updated_at",e.date())});var np=e.object({data:e.list(nr),params:ap});var sp=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Xo=e.object({accountId:e.property("account_id",e.string()),amountOff:e.property("amount_off",e.number().optional()),currency:e.string().optional(),duration:e.string().optional(),durationInMonths:e.property("duration_in_months",e.number().optional()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),isActive:e.property("is_active",e.boolean()),maxRedemptions:e.property("max_redemptions",e.number().optional()),metadata:e.record(e.string(),e.unknown()),name:e.string(),percentOff:e.property("percent_off",e.number().optional()),providerType:e.property("provider_type",k),timesRedeemed:e.property("times_redeemed",e.number()),validFrom:e.property("valid_from",e.date().optional()),validUntil:e.property("valid_until",e.date().optional())});var cp=e.object({data:e.list(Xo),params:sp});var lp=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var pp=e.object({currency:e.string(),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),meteredUsage:e.property("metered_usage",e.boolean()),perUnitPrice:e.property("per_unit_price",e.number()),totalPrice:e.property("total_price",e.number())});var up=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),subscriptions:e.list(pp),updatedAt:e.property("updated_at",e.date())});var dp=e.object({data:e.list(up),params:lp});var mp=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional())});var De=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string().optional()),id:e.string(),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),providerType:e.property("provider_type",k),startingBalance:e.property("starting_balance",e.number()),status:Yo.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),updatedAt:e.property("updated_at",e.date()),url:e.string().optional()});var hp=e.object({data:e.list(De),params:mp});var gp=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var Qo=e.object({dispalyName:e.property("dispaly_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),providerType:e.property("provider_type",k)});var yp=e.object({data:e.list(Qo),params:gp});var wp=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var qe=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),customerExternalId:e.property("customer_external_id",e.string()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),paymentMethodType:e.property("payment_method_type",e.string()),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var bp=e.object({data:e.list(qe),params:wp});var zp=e.object({data:Xo,params:e.record(e.string(),e.unknown())});var Rp=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var fp=e.object({data:Rp,params:e.record(e.string(),e.unknown())});var _p=e.object({data:Qo,params:e.record(e.string(),e.unknown())});var Sp=e.object({data:G,params:e.record(e.string(),e.unknown())});var Ir=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),updatedAt:e.property("updated_at",e.date())});var xp=e.object({data:Ir,params:e.record(e.string(),e.unknown())});var Pp=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Mr.optional())});var Ep=e.object({data:Pp,params:e.record(e.string(),e.unknown())});var Cp=e.object({data:De,params:e.record(e.string(),e.unknown())});var Up=e.object({data:qe,params:e.record(e.string(),e.unknown())});var wn=e.object({description:e.string().optional(),name:e.string()});var vp=e.object({bundleId:e.property("bundle_id",e.string())});var Tp=e.object({featureId:e.property("feature_id",e.string()),visible:e.boolean().optional()});var bn=e.object({entitlements:e.list(Tp).optional(),planId:e.property("plan_id",e.string())});var zn=e.object({customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(bn).optional()),orderedBundles:e.property("ordered_bundles",e.list(vp).optional()),orderedPlans:e.property("ordered_plans",e.list(bn).optional()),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var Rn=e.object({description:e.string().optional(),isDefault:e.property("is_default",e.boolean().optional()),name:e.string().optional()});var sr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),description:e.string().optional(),id:e.string(),isDefault:e.property("is_default",e.boolean()),name:e.string(),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Op=e.object({data:sr,params:e.record(e.string(),e.unknown())});var kp=e.object({data:q,params:e.record(e.string(),e.unknown())});var Bp=e.object({data:sr,params:e.record(e.string(),e.unknown())});var jp=e.object({bundleId:e.property("bundle_id",e.string())});var Ap=e.object({featureId:e.property("feature_id",e.string()),visible:e.boolean()});var fn=e.object({entitlements:e.list(Ap),planId:e.property("plan_id",e.string())});var Fr=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var W=e.enum_(["billing_periods","days"]);var Kr=e.enum_(["expire","none","rollover"]);var Vp=e.object({currency:e.string(),price:G.optional()});var ye=e.object({burnStrategy:e.property("burn_strategy",Fr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Vp)),defaultExpiryUnit:e.property("default_expiry_unit",W),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr),description:e.string(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:G.optional(),product:Ir.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Oe=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var cr=e.enum_(["off","automatic","user_controlled"]);var Q=e.enum_(["duration","end_of_billing_period","end_of_next_billing_period","end_of_trial","no_expiry"]);var ke=e.enum_(["daily","every_6_months","monthly","quarterly","weekly","yearly"]);var Fe=e.enum_(["billing_period","first_of_month"]);var lr=e.enum_(["no_reset","plan_period"]);var pr=e.enum_(["fixed","per_license"]);var et=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Be=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",e.string().optional()),autoTopupAvailability:e.property("auto_topup_availability",cr),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Q.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:ye.optional(),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),creditPluralName:e.property("credit_plural_name",e.string().optional()),creditSingularName:e.property("credit_singular_name",e.string().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),licenseId:e.property("license_id",e.string().optional()),plan:et.optional(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",ke.optional()),resetStart:e.property("reset_start",Fe.optional()),resetType:e.property("reset_type",lr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number()),scaling:pr,updatedAt:e.property("updated_at",e.date())});var Ke=e.enum_(["schematic_managed","provider_managed","no_billing"]);var Le=e.enum_(["free","none","one_time","recurring"]);var rt=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var ee=e.enum_(["company","user"]);var he=e.enum_(["boolean","currency","date","number","string","url"]);var ge=e.object({createdAt:e.property("created_at",e.date()),displayName:e.property("display_name",e.string()),entityType:e.property("entity_type",ee),hierarchy:e.list(e.string()),id:e.string(),traitType:e.property("trait_type",he),updatedAt:e.property("updated_at",e.date())});var vi=e.object({companyCount:e.property("company_count",e.number()),environmentId:e.property("environment_id",e.string()),eventCount:e.property("event_count",e.number()),eventSubtype:e.property("event_subtype",e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),userCount:e.property("user_count",e.number())});var Ge=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var ue=e.enum_(["boolean","event","license","trait"]);var We=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ue),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var ur=e.stringLiteral("boolean");var Lr=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var Ti=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var H=e.enum_(["all_time","current_day","current_month","current_week"]);var $=e.enum_(["billing_cycle","first_of_month"]);var it=e.object({comparisonTrait:e.property("comparison_trait",ge.optional()),comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionGroupId:e.property("condition_group_id",e.string().optional()),conditionType:e.property("condition_type",Ti),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list(et),ruleId:e.property("rule_id",e.string()),trait:ge.optional(),traitEntityType:e.property("trait_entity_type",ee.optional()),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var Dp=e.object({conditions:e.list(it),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),ruleId:e.property("rule_id",e.string()),updatedAt:e.property("updated_at",e.date())});var Gr=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Oi=e.object({conditionGroups:e.property("condition_groups",e.list(Dp)),conditions:e.list(it),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Gr),updatedAt:e.property("updated_at",e.date()),value:e.boolean()});var qp=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:We.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ur),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Oi),updatedAt:e.property("updated_at",e.date())});var Wr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var He=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",vi.optional()),featureType:e.property("feature_type",ue),flags:e.list(qp),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Wr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:ge.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var Hr=e.object({id:e.string(),name:e.string()});var Nr=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",G.optional()),oneTimePrice:e.property("one_time_price",G.optional()),quarterlyPrice:e.property("quarterly_price",G.optional()),yearlyPrice:e.property("yearly_price",G.optional())});var Mp=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",N.optional()),quarterlyPrice:e.property("quarterly_price",N.optional()),yearlyPrice:e.property("yearly_price",N.optional())});var Re=e.enum_(["credit_burndown","overage","pay_as_you_go","pay_in_advance","tier"]);var te=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var de=e.enum_(["amber","blue","blueGray","blueGreen","cyan","emerald","fuchsia","gray","green","indigo","lightBlue","lime","orange","pink","purple","red","redOrange","rose","sky","slate","teal","trueGray","violet","warmGray","yellow"]);var ie=e.enum_(["plan","add_on"]);var dr=e.object({audienceType:e.property("audience_type",e.string().optional()),companyId:e.property("company_id",e.string().optional()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),description:e.string(),icon:de,id:e.string(),name:e.string(),planType:e.property("plan_type",ie),updatedAt:e.property("updated_at",e.date())});var Ip=e.object({id:e.string(),key:e.string(),value:e.number()});var ae=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Mp)),environmentId:e.property("environment_id",e.string()),feature:We.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),meteredMonthlyPrice:e.property("metered_monthly_price",N.optional()),meteredQuarterlyPrice:e.property("metered_quarterly_price",N.optional()),meteredYearlyPrice:e.property("metered_yearly_price",N.optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),plan:dr.optional(),planId:e.property("plan_id",e.string()),priceBehavior:e.property("price_behavior",Re.optional()),ruleId:e.property("rule_id",e.string()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageBasedProduct:e.property("usage_based_product",Ir.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",ye.optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",ge.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te),warningTiers:e.property("warning_tiers",e.list(Ip))});var ki=e.enum_(["monthly","quarterly","yearly"]);var Fp=e.enum_(["published","draft","archived"]);var fe=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:de,id:e.string(),name:e.string(),originalPlanId:e.property("original_plan_id",e.string().optional()),planType:e.property("plan_type",ie),status:Fp,updatedAt:e.property("updated_at",e.date()),version:e.number()});var mr=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),customPlanConfig:e.property("custom_plan_config",rt.optional()),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(ae).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Be).optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",ie),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var Kp=e.object({addOns:e.property("add_ons",e.list(mr)),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),orderedAddOns:e.property("ordered_add_ons",e.list(fn)),orderedBundles:e.property("ordered_bundles",e.list(jp)),orderedPlans:e.property("ordered_plans",e.list(fn)),plans:e.list(mr),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var Lp=e.object({data:Kp,params:e.record(e.string(),e.unknown())});var Gp=e.object({creditBundleIds:e.property("credit_bundle_ids",e.list(e.string()))});var Wp=e.object({data:Gp,params:e.record(e.string(),e.unknown())});var Hp=e.object({icon:e.string(),id:e.string(),name:e.string()});var Np=e.object({features:e.list(Hp)});var $p=e.object({data:Np,params:e.record(e.string(),e.unknown())});var Jp=e.object({planIds:e.property("plan_ids",e.list(e.string()))});var Yp=e.object({data:Jp,params:e.record(e.string(),e.unknown())});var Zp=e.object({isDefault:e.property("is_default",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Xp=e.object({data:e.list(sr),params:Zp});var Qp=e.object({data:sr,params:e.record(e.string(),e.unknown())});var eu=e.object({data:sr,params:e.record(e.string(),e.unknown())});var _n=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var Sn=e.object({companyId:e.property("company_id",e.string()),currency:e.string().optional(),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var $r=e.object({id:e.string(),value:e.string()});var ot=e.object({city:e.string(),country:e.string(),line1:e.string(),line2:e.string(),postalCode:e.property("postal_code",e.string()),state:e.string()});var ru=e.enum_(["ae_trn","au_abn","au_arn","br_cnpj","br_cpf","ca_bn","ca_gst_hst","ca_pst_bc","ca_pst_mb","ca_pst_sk","ca_qst","ch_uid","ch_vat","eu_vat","gb_vat","hk_br","id_npwp","il_vat","in_gst","jp_cn","jp_rn","jp_trn","kr_brn","mx_rfc","my_frp","my_itn","my_sst","no_vat","nz_gst","ph_tin","sa_vat","sg_gst","sg_uen","th_vat","tr_tin","tw_vat","us_ein","za_vat"]);var tt=e.object({type:ru,value:e.string()});var xn=e.object({address:ot.optional(),email:e.string().optional(),phone:e.string().optional(),taxId:e.property("tax_id",tt.optional()),values:e.list($r)});var Pn=e.object({trialEnd:e.property("trial_end",e.date().optional())});var Bi=e.object({billingScheme:e.property("billing_scheme",ar),billingThreshold:e.property("billing_threshold",e.number().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),meterId:e.property("meter_id",e.string().optional()),name:e.string(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list(Zo)),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionId:e.property("subscription_id",e.string()),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",pe)});var ji=e.object({amountOff:e.property("amount_off",e.number().optional()),couponId:e.property("coupon_id",e.string()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),discountExternalId:e.property("discount_external_id",e.string()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date()),subscriptionExternalId:e.property("subscription_external_id",e.string())});var _o=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(ji),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",De.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",qe.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(Bi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Mr.optional())});var iu=e.object({accountId:e.property("account_id",e.string()),capturedAtMax:e.property("captured_at_max",e.date()),capturedAtMin:e.property("captured_at_min",e.date()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",$),period:H,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var ou=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var tu=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),isActive:e.property("is_active",e.boolean()),name:e.string(),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var au=e.object({currency:e.string(),price:N.optional()});var at=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",Fr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(au)),defaultExpiryUnit:e.property("default_expiry_unit",W),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),ledgerAuthority:e.property("ledger_authority",ou),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:N.optional(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),product:tu.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ai=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var nu=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",cr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Q.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",W.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),companyAutoTopupAmount:e.property("company_auto_topup_amount",e.number().optional()),companyAutoTopupEnabled:e.property("company_auto_topup_enabled",e.boolean().optional()),companyAutoTopupThresholdCredits:e.property("company_auto_topup_threshold_credits",e.number().optional()),createdAt:e.property("created_at",e.date()),credit:at.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),licenseId:e.property("license_id",e.string().optional()),plan:Ai.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",ke.optional()),resetStart:e.property("reset_start",Fe.optional()),resetType:e.property("reset_type",lr),rolloverPercentage:e.property("rollover_percentage",e.number()),scaling:pr,singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var En=e.object({addedOn:e.property("added_on",e.date().optional()),billingProductExternalId:e.property("billing_product_external_id",e.string().optional()),billingProductId:e.property("billing_product_id",e.string().optional()),description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),includedCreditGrants:e.property("included_credit_grants",e.list(nu)),name:e.string(),planPeriod:e.property("plan_period",e.string().optional()),planPrice:e.property("plan_price",e.number().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var Vi=e.enum_(["on_payment","on_publish"]);var vr=e.enum_(["active","expired","paid","pending"]);var Jr=e.object({activationStrategy:e.property("activation_strategy",Vi),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),daysUntilDue:e.property("days_until_due",e.number()),externalInvoiceId:e.property("external_invoice_id",e.string().optional()),id:e.string(),paidAt:e.property("paid_at",e.date().optional()),planId:e.property("plan_id",e.string()),publishedAt:e.property("published_at",e.date().optional()),sendInvoice:e.property("send_invoice",e.boolean()),status:vr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var nt=e.object({createdAt:e.property("created_at",e.date()),entityType:e.property("entity_type",ee),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date())});var st=e.object({createdAt:e.property("created_at",e.date()),definition:nt.optional(),definitionId:e.property("definition_id",e.string()),entityId:e.property("entity_id",e.string()),entityType:e.property("entity_type",ee),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var ct=e.object({createdAt:e.property("created_at",e.date()),definition:ge.optional(),definitionId:e.property("definition_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var su=e.object({key:e.string(),value:e.number()});var lt=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",te),warningTiers:e.property("warning_tiers",e.list(su).optional())});var cu=e.enum_(["bool","date","int","string"]);var Cn=e.object({comparableType:e.property("comparable_type",cu),entityType:e.property("entity_type",ee),id:e.string()});var pt=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",Cn.optional()),conditionType:e.property("condition_type",Ti),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",Cn.optional()),traitValue:e.property("trait_value",e.string())});var lu=e.object({conditions:e.list(pt)});var pu=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(lu)),conditions:e.list(pt),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Gr),value:e.boolean()});var ut=e.object({currency:e.string(),effectiveAfter:e.property("effective_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),fromPlanName:e.property("from_plan_name",e.string()),fromSubscriptionPrice:e.property("from_subscription_price",e.number()),id:e.string(),interval:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),toPlanId:e.property("to_plan_id",e.string()),toPlanName:e.property("to_plan_name",e.string())});var re=e.object({addOns:e.property("add_ons",e.list(En)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",_o.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(_o)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(Jr)),defaultPaymentMethod:e.property("default_payment_method",qe.optional()),entitlements:e.list(lt),entityTraits:e.property("entity_traits",e.list(ct)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(st),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(iu),name:e.string(),paymentMethods:e.property("payment_methods",e.list(qe)),plan:En.optional(),plans:e.list(Ai),rules:e.list(pu),scheduledDowngrade:e.property("scheduled_downgrade",ut.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var dt=e.object({company:re.optional(),success:e.boolean()});var uu=e.object({data:dt,params:e.record(e.string(),e.unknown())});var du=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),confirmPaymentIntentClientSecret:e.property("confirm_payment_intent_client_secret",e.string().optional()),confirmPaymentIntentId:e.property("confirm_payment_intent_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),invoiceId:e.property("invoice_id",e.string().optional()),invoiceUrl:e.property("invoice_url",e.string().optional()),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Mr.optional())});var mu=e.object({data:du,params:e.record(e.string(),e.unknown())});var ve=e.enum_(["active","inactive"]);var Me=e.stringLiteral("fixed");var hu=e.object({currency:e.string(),price:G.optional()});var Ne=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",Me),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(hu)),expiryType:e.property("expiry_type",Q),expiryUnit:e.property("expiry_unit",W),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:G.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:ve,unitPrice:e.property("unit_price",G.optional()),updatedAt:e.property("updated_at",e.date())});var Di=e.object({definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),value:e.string().optional()});var qi=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(ji),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",De.optional()),paymentMethod:e.property("payment_method",qe.optional()),products:e.list(Bi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var gu=e.object({bundle:Ne.optional(),quantity:e.number(),total:e.number()});var je=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased","rollover"]);var yu=e.object({createdAt:e.property("created_at",e.date()),externalUserId:e.property("external_user_id",e.string()),externalUserName:e.property("external_user_name",e.string()),id:e.string(),note:e.string(),updatedAt:e.property("updated_at",e.date())});var $e=e.object({company:re.optional(),companyId:e.property("company_id",e.string()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expirationDate:e.property("expiration_date",e.date().optional()),feature:We.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),notes:e.list(yu),ruleId:e.property("rule_id",e.string().optional()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),updatedAt:e.property("updated_at",e.date()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",ge.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te)});var Mi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",je),quantity:e.number()});var Ii=e.object({usageThisBillingPeriod:e.property("usage_this_billing_period",e.number().optional()),usageThisCalendarMonth:e.property("usage_this_calendar_month",e.number().optional()),usageThisWeek:e.property("usage_this_week",e.number().optional()),usageToday:e.property("usage_today",e.number().optional())});var Yr=e.enum_(["company_override","plan_entitlement","unknown"]);var Zr=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",te),companyOverride:e.property("company_override",$e.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Mi).optional()),creditGrantReason:e.property("credit_grant_reason",je.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Ii.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Yr),feature:He.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:H.optional(),plan:dr.optional(),planEntitlement:e.property("plan_entitlement",ae.optional()),priceBehavior:e.property("price_behavior",Re.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var Fi=e.object({features:e.list(Zr)});var be=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(ae).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Be).optional()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",ie),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var So=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),featureId:e.property("feature_id",e.string()),meteredPrice:e.property("metered_price",N.optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),priceBehavior:e.property("price_behavior",Re.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueType:e.property("value_type",te),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var wu=e.object({activeAddOns:e.property("active_add_ons",e.list(be)),activePlan:e.property("active_plan",be.optional()),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(So)),availableCreditBundles:e.property("available_credit_bundles",e.list(Ne)),company:re.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(Di)),featureUsage:e.property("feature_usage",Fi.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(gu)),selectedPlan:e.property("selected_plan",be.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(So)),subscription:qi.optional()});var bu=e.object({data:wu,params:e.record(e.string(),e.unknown())});var zu=e.object({city:e.string(),country:e.string(),line1:e.string(),line2:e.string(),postalCode:e.property("postal_code",e.string()),state:e.string()});var Ru=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean())});var fu=e.object({country:e.string(),id:e.string(),type:e.string(),value:e.string(),verificationStatus:e.property("verification_status",e.string().optional())});var mt=e.object({address:zu.optional(),checkoutSettings:e.property("checkout_settings",Ru),customFields:e.property("custom_fields",e.list(Di)),email:e.string().optional(),phone:e.string().optional(),taxIds:e.property("tax_ids",e.list(fu))});var _u=e.object({data:mt,params:e.record(e.string(),e.unknown())});var Su=e.object({data:dt,params:e.record(e.string(),e.unknown())});var xu=e.object({amountOff:e.property("amount_off",e.number().optional()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var Pu=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var Eu=e.object({amountOff:e.property("amount_off",e.number()),discounts:e.list(xu),dueNow:e.property("due_now",e.number()),newCharges:e.property("new_charges",e.number()),percentOff:e.property("percent_off",e.number()),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),taxAmount:e.property("tax_amount",e.number().optional()),taxDisplayName:e.property("tax_display_name",e.string().optional()),taxRequireBillingDetails:e.property("tax_require_billing_details",e.boolean()),totalPerBillingPeriod:e.property("total_per_billing_period",e.number()),trialEnd:e.property("trial_end",e.date().optional()),upcomingInvoiceLineItems:e.property("upcoming_invoice_line_items",e.list(Pu))});var ht=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:Eu.optional(),isScheduledDowngrade:e.property("is_scheduled_downgrade",e.boolean()),newCharges:e.property("new_charges",e.number()),optInRequired:e.property("opt_in_required",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),paymentMethodRequired:e.property("payment_method_required",e.boolean()),percentOff:e.property("percent_off",e.number()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),scheduledChangeTime:e.property("scheduled_change_time",e.date().optional()),trialEnd:e.property("trial_end",e.date().optional()),usageViolations:e.property("usage_violations",e.list(Zr))});var Cu=e.object({data:ht,params:e.record(e.string(),e.unknown())});var Uu=e.object({subscriptionChangePreview:e.property("subscription_change_preview",ht.optional())});var vu=e.object({data:Uu,params:e.record(e.string(),e.unknown())});var Tu=e.object({data:mt,params:e.record(e.string(),e.unknown())});var Ou=e.object({data:_o,params:e.record(e.string(),e.unknown())});var Un=e.object({displayName:e.property("display_name",e.string().optional()),entityType:e.property("entity_type",ee),hierarchy:e.list(e.string()),traitType:e.property("trait_type",he)});var vn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var Tn=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",he)});var ku=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var On=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(ku)});var Ae=e.enum_(["asc","desc"]);var Tr=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var Or=e.enum_(["free","one_time","paid","trial"]);var Bu=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",Ae.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(Tr).optional()),subscriptionTypes:e.property("subscription_types",e.list(Or).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var ju=e.object({data:V,params:Bu});var Au=e.object({entityType:e.property("entity_type",ee.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Vu=e.object({data:V,params:Au});var Du=e.object({definitionId:e.property("definition_id",e.string().optional()),entityType:e.property("entity_type",ee.optional()),limit:e.number().optional(),offset:e.number().optional()});var qu=e.object({data:V,params:Du});var Mu=e.object({entityType:e.property("entity_type",ee.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",he.optional()),traitTypes:e.property("trait_types",e.list(he).optional())});var Iu=e.object({data:V,params:Mu});var Fu=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var Ku=e.object({data:V,params:Fu});var Lu=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Gu=e.object({data:V,params:Lu});var Wu=e.object({data:re,params:e.record(e.string(),e.unknown())});var hr=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ki=e.object({company:hr.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),id:e.string(),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string())});var Je=e.object({companyMemberships:e.property("company_memberships",e.list(Ki)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(ct)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(st),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date())});var Hu=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Nu=e.object({data:hr,params:e.record(e.string(),e.unknown())});var $u=e.object({data:q,params:e.record(e.string(),e.unknown())});var Ju=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var Yu=e.object({data:q,params:Ju});var Zu=e.object({data:q,params:e.record(e.string(),e.unknown())});var gr=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Xu=e.object({data:gr,params:e.record(e.string(),e.unknown())});var Qu=e.object({data:q,params:e.record(e.string(),e.unknown())});var ed=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional()});var rd=e.object({data:e.list(qi),params:ed});var id=e.object({companyId:e.property("company_id",e.string().optional())});var od=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),company:hr.optional(),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(ji),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",De.optional()),paymentMethod:e.property("payment_method",qe.optional()),planName:e.property("plan_name",e.string()),products:e.list(Bi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var td=e.object({data:e.list(od),params:id});var ad=e.object({companyId:e.property("company_id",e.string().optional())});var nd=e.object({billingEntity:e.property("billing_entity",hr.optional()),hasOwnStripeCustomer:e.property("has_own_stripe_customer",e.boolean())});var sd=e.object({data:e.list(nd),params:ad});var cd=e.object({data:re,params:e.record(e.string(),e.unknown())});var ld=e.object({data:ge,params:e.record(e.string(),e.unknown())});var pd=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var ud=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var dd=e.object({data:e.list(ud),params:pd});var md=e.object({data:Ki,params:e.record(e.string(),e.unknown())});var hd=e.object({data:ge,params:e.record(e.string(),e.unknown())});var gt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Ie,type:Pe,updatedAt:e.property("updated_at",e.date())});var Li=e.enum_(["checkout","company_upsert","fallback_plan","manage_plan","migration","plan_billing_product_changed","plan_deleted","plan_trait_change","plan_version_migration","quickstart","subscription_change"]);var Gi=e.enum_(["fallback","initial","trait","trial_expiry"]);var gd=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var xo=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var kn=e.object({id:e.string(),name:e.string(),version:e.number()});var yd=e.object({featureId:e.property("feature_id",e.string()),hierarchy:e.list(e.string()),reason:e.string(),traitId:e.property("trait_id",e.string()),traitName:e.property("trait_name",e.string()),traitType:e.property("trait_type",he),value:e.string()});var yt=e.object({action:Li,actorType:e.property("actor_type",Ue),addOnsAdded:e.property("add_ons_added",e.list(xo)),addOnsRemoved:e.property("add_ons_removed",e.list(xo)),apiKey:e.property("api_key",Ce.optional()),auditLog:e.property("audit_log",Jo.optional()),basePlan:e.property("base_plan",xo.optional()),basePlanAction:e.property("base_plan_action",Gi.optional()),basePlanVersion:e.property("base_plan_version",kn.optional()),company:hr.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),integration:gt.optional(),isVersionUpgrade:e.property("is_version_upgrade",e.boolean()),previousBasePlan:e.property("previous_base_plan",xo.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",kn.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",gd.optional()),traitsUpdated:e.property("traits_updated",e.list(yd)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var wd=e.object({data:yt,params:e.record(e.string(),e.unknown())});var Wi=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),planId:e.property("plan_id",e.string()),planType:e.property("plan_type",e.string()),traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var bd=e.object({data:Wi,params:e.record(e.string(),e.unknown())});var zd=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Rd=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",Ae.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(Tr).optional()),subscriptionTypes:e.property("subscription_types",e.list(Or).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var fd=e.object({data:e.list(re),params:Rd});var _d=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var Sd=e.object({data:e.list(Ki),params:_d});var xd=e.object({entityType:e.property("entity_type",ee.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Pd=e.object({data:e.list(nt),params:xd});var Ed=e.object({entityType:e.property("entity_type",ee.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",he.optional()),traitTypes:e.property("trait_types",e.list(he).optional())});var Cd=e.object({data:e.list(ge),params:Ed});var Ud=e.object({action:Li.optional(),basePlanAction:e.property("base_plan_action",Gi.optional()),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),planIds:e.property("plan_ids",e.list(e.string()).optional())});var vd=e.object({data:e.list(yt),params:Ud});var Td=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var Od=e.object({data:e.list(Wi),params:Td});var kd=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Bd=e.object({data:e.list(Je),params:kd});var jd=e.object({keys:e.record(e.string(),e.string()).optional()});var Ad=e.object({data:re,params:jd});var Vd=e.object({keys:e.record(e.string(),e.string()).optional()});var Dd=e.object({data:Je,params:Vd});var qd=e.object({data:ge,params:e.record(e.string(),e.unknown())});var Md=e.object({data:e.list(Wi),params:e.record(e.string(),e.unknown())});var Id=e.object({data:re,params:e.record(e.string(),e.unknown())});var Fd=e.object({data:re,params:e.record(e.string(),e.unknown())});var Kd=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Ld=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Bn=e.object({catalogId:e.property("catalog_id",e.string().optional())});var Hi=e.enum_(["billing","entitlement"]);var jn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Hi),name:e.string()});var wt=e.enum_(["draft","live"]);var An=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Hi.optional()),name:e.string().optional(),state:wt.optional()});var Ye=e.object({ast:e.record(e.string(),e.number()).optional(),catalogId:e.property("catalog_id",e.string().optional()),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:wt,type:Hi,updatedAt:e.property("updated_at",e.date())});var Gd=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Wd=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Hd=e.object({data:V,params:Wd});var Nd=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var $d=e.object({data:q,params:e.record(e.string(),e.unknown())});var Jd=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Yd=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Zd=e.object({data:e.list(Ye),params:Yd});var Xd=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var Po=e.object({billingScheme:e.property("billing_scheme",ar),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:Ui,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",me.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",pe)});var Qd=e.object({currency:e.string(),price:N.optional()});var em=e.object({bundleType:e.property("bundle_type",Me),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(Qd)),expiryType:e.property("expiry_type",Q),expiryUnit:e.property("expiry_unit",W),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:Po.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:ve,unitPrice:e.property("unit_price",Po.optional()),updatedAt:e.property("updated_at",e.date())});var rm=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var Xr=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var bt=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",cr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Q.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",W.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:at.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),licenseId:e.property("license_id",e.string().optional()),plan:Ai.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",ke.optional()),resetStart:e.property("reset_start",Fe.optional()),resetType:e.property("reset_type",lr),rolloverPercentage:e.property("rollover_percentage",e.number()),scaling:pr,singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Vn=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCanTrial:e.property("company_can_trial",e.boolean()),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Xr.optional()),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(ae).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(bt)),invalidReason:e.property("invalid_reason",rm.optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",ie),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageViolations:e.property("usage_violations",e.list(Zr)),valid:e.boolean(),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var Qr=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var zt=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var Ni=e.enum_(["create_prorations","invoice_immediately"]);var im=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),prorationBehavior:e.property("proration_behavior",Ni),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean())});var Rt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var ei=e.enum_(["customer_archived","expired","integration_uninstalled","license_retired","manual","plan_change","plan_period_reset","reconciled"]);var om=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var tm=e.object({billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),exhaustedAt:e.property("exhausted_at",e.date().optional()),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),grantReason:e.property("grant_reason",je),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),price:Po.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",ke.optional()),reserved:e.number().optional(),settled:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(om).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",ei.optional())});var am=e.object({accountId:e.property("account_id",e.string().optional()),publishableKey:e.property("publishable_key",e.string().optional()),schematicPublishableKey:e.property("schematic_publishable_key",e.string()),setupIntentClientSecret:e.property("setup_intent_client_secret",e.string().optional())});var nm=e.object({activeAddOns:e.property("active_add_ons",e.list(Vn)),activePlans:e.property("active_plans",e.list(Vn)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(So)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr)),capabilities:zt.optional(),checkoutSettings:e.property("checkout_settings",im),company:re.optional(),component:Ye.optional(),creditBundles:e.property("credit_bundles",e.list(em)),creditGrants:e.property("credit_grants",e.list(tm)),customCheckoutFields:e.property("custom_checkout_fields",e.list(Di)),defaultPlan:e.property("default_plan",be.optional()),displaySettings:e.property("display_settings",Rt),featureUsage:e.property("feature_usage",Fi.optional()),invoices:e.list(De),postTrialPlan:e.property("post_trial_plan",be.optional()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),scheduledDowngrade:e.property("scheduled_downgrade",ut.optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),stripeEmbed:e.property("stripe_embed",am.optional()),subscription:qi.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",De.optional())});var sm=e.object({data:nm,params:Xd});var cm=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var Dn=e.object({activeVersion:e.property("active_version",fe.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",nr.optional()),billingStrategy:e.property("billing_strategy",Ke),catalogs:e.list(Hr).optional(),chargeType:e.property("charge_type",Le),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ye),currencyPrices:e.property("currency_prices",e.list(Nr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Xr.optional()),description:e.string(),draftVersion:e.property("draft_version",fe.optional()),entitlements:e.list(ae).optional(),features:e.list(He),icon:de,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(bt)),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean().optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",ie),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(fe),yearlyPrice:e.property("yearly_price",G.optional())});var lm=e.object({activeAddOns:e.property("active_add_ons",e.list(Dn)),activePlans:e.property("active_plans",e.list(Dn)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr)),capabilities:zt.optional(),displaySettings:e.property("display_settings",Rt),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var pm=e.object({data:lm,params:e.record(e.string(),e.unknown())});var qn=e.object({companyId:e.property("company_id",e.string()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date().optional()),requestedAmount:e.property("requested_amount",e.number())});var ft=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var Mn=e.object({burnStrategy:e.property("burn_strategy",Fr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(ft).optional()),defaultExpiryUnit:e.property("default_expiry_unit",W.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var In=e.object({billingPeriodsCount:e.property("billing_periods_count",e.number().optional()),companyId:e.property("company_id",e.string()),creditId:e.property("credit_id",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),quantity:e.number(),reason:je,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",Fe.optional())});var _t=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var Fn=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",Me.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(_t).optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:ve.optional()});var Kn=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var Ln=e.object({burnStrategy:e.property("burn_strategy",Fr.optional()),currencyPrices:e.property("currency_prices",e.list(ft).optional()),defaultExpiryUnit:e.property("default_expiry_unit",W.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Kr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Gn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(_t).optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:ve.optional()});var Wn=e.object({reason:ei.optional()});var $i=e.object({companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date()),grantedAmount:e.property("granted_amount",e.number()),id:e.string(),releasedAt:e.property("released_at",e.date().optional()),updatedAt:e.property("updated_at",e.date())});var um=e.object({data:$i,params:e.record(e.string(),e.unknown())});var dm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var mm=e.object({data:V,params:dm});var hm=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var gm=e.object({data:V,params:hm});var ym=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var wm=e.object({data:V,params:ym});var hi=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var bm=e.object({companyId:e.property("company_id",e.string().optional()),dir:Ae.optional(),limit:e.number().optional(),offset:e.number().optional(),order:hi.optional()});var zm=e.object({data:V,params:bm});var Rm=e.object({bundleType:e.property("bundle_type",Me.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:ve.optional()});var fm=e.object({data:V,params:Rm});var kr=e.enum_(["grant","transfer","usage","zero_out"]);var _m=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",kr.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var Sm=e.object({data:V,params:_m});var xm=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Pm=e.object({data:Be,params:e.record(e.string(),e.unknown())});var Em=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Cm=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var Um=e.object({data:q,params:Cm});var vm=e.object({data:q,params:e.record(e.string(),e.unknown())});var Tm=e.object({data:$i,params:e.record(e.string(),e.unknown())});var Om=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var km=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Bm=e.object({data:Be,params:e.record(e.string(),e.unknown())});var jm=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var ri=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",je),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),price:G.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",ke.optional()),reserved:e.number().optional(),settled:e.number().optional(),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(jm).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",ei.optional())});var Am=e.object({data:ri,params:e.record(e.string(),e.unknown())});var Vm=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Dm=e.object({data:e.list(ye),params:Vm});var qm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var Mm=e.object({data:e.list(Be),params:qm});var Im=e.object({companyId:e.property("company_id",e.string().optional())});var Fm=e.object({creditId:e.property("credit_id",e.string()),remaining:e.number(),reserved:e.number(),settled:e.number(),source:k,total:e.number().optional()});var Km=e.object({data:e.list(Fm),params:Im});var Lm=e.object({companyId:e.property("company_id",e.string().optional()),dir:Ae.optional(),limit:e.number().optional(),offset:e.number().optional(),order:hi.optional()});var Gm=e.object({data:e.list(ri),params:Lm});var Wm=e.object({bundleType:e.property("bundle_type",Me.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:ve.optional()});var Hm=e.object({data:e.list(Ne),params:Wm});var Nm=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",kr.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var $m=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Jm=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var Ym=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var Zm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var Xm=e.object({amount:e.number(),autoTopupLogId:e.property("auto_topup_log_id",e.string().optional()),billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),company:Jm.optional(),companyId:e.property("company_id",e.string()),credit:$m.optional(),creditName:e.property("credit_name",e.string()),environmentId:e.property("environment_id",e.string()),eventAt:e.property("event_at",e.date()),eventId:e.property("event_id",e.string()),eventType:e.property("event_type",kr),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:Zm.optional(),featureId:e.property("feature_id",e.string().optional()),fromGrantId:e.property("from_grant_id",e.string().optional()),grantExpiresAt:e.property("grant_expires_at",e.date().optional()),grantId:e.property("grant_id",e.string().optional()),grantQuantity:e.property("grant_quantity",e.number().optional()),grantQuantityRemaining:e.property("grant_quantity_remaining",e.number().optional()),grantReason:e.property("grant_reason",je.optional()),grantValidFrom:e.property("grant_valid_from",e.date().optional()),planId:e.property("plan_id",e.string().optional()),quantityConsumed:e.property("quantity_consumed",e.number().optional()),quantityRemainingAtZeroOut:e.property("quantity_remaining_at_zero_out",e.number().optional()),sourceId:e.property("source_id",e.number()),toGrantId:e.property("to_grant_id",e.string().optional()),usageEventId:e.property("usage_event_id",e.string().optional()),usageReason:e.property("usage_reason",Ym.optional()),zeroedOutReason:e.property("zeroed_out_reason",ei.optional())});var Qm=e.object({data:e.list(Xm),params:Nm});var eh=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var rh=e.object({data:e.list(ri),params:eh});var ih=e.object({data:$i,params:e.record(e.string(),e.unknown())});var oh=e.object({data:q,params:e.record(e.string(),e.unknown())});var th=e.object({data:ye,params:e.record(e.string(),e.unknown())});var ah=e.object({data:Be,params:e.record(e.string(),e.unknown())});var nh=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var sh=e.object({data:ri,params:e.record(e.string(),e.unknown())});var ch=e.object({actorType:e.property("actor_type",e.string().optional()),endTime:e.property("end_time",e.date().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var lh=e.enum_(["asc","desc"]);var ph=e.enum_(["plan","subscription","users","last_seen_at"]);var uh=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",lh.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(e.string()).optional()),subscriptionTypes:e.property("subscription_types",e.list(e.string()).optional()),visibleColumns:e.property("visible_columns",e.list(ph).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var dh=e.enum_(["flag_check","identify","inference","track"]);var mh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),eventTypes:e.property("event_types",e.list(dh).optional()),flagId:e.property("flag_id",e.string().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),startTime:e.property("start_time",e.date().optional()),userId:e.property("user_id",e.string().optional())});var St=e.union(e.discriminant("exportType","export_type"),{"audit-log":ch,"company-feature-usage":uh,event:mh}).transform({transform:p=>p,untransform:p=>p});var xt=e.enum_(["csv","csv.gz"]);var ii=e.enum_(["audit-log","company-feature-usage","event"]);var Hn=e.object({exportType:e.property("export_type",ii),metadata:St.optional(),outputFileType:e.property("output_file_type",xt)});var Ji=e.enum_(["failure","pending","success"]);var Yi=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),exportType:e.property("export_type",ii),id:e.string(),metadata:St.optional(),outputFileType:e.property("output_file_type",xt),status:Ji,updatedAt:e.property("updated_at",e.date())});var hh=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var gh=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var yh=e.object({exportType:e.property("export_type",ii.optional()),limit:e.number().optional(),offset:e.number().optional(),status:Ji.optional()});var wh=e.object({data:e.list(Yi),params:yh});var se=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var oi=e.object({currency:e.string(),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var ti=e.object({key:e.string(),value:e.number()});var Nn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingProvider:e.property("billing_provider",k),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),externalResourceId:e.property("external_resource_id",e.string()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var $n=e.object({companyId:e.property("company_id",e.string()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te)});var Jn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Yn=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var Zn=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te)});var Xn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var bh=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var zh=e.object({data:V,params:bh});var Rh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fh=e.object({data:V,params:Rh});var _h=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var Sh=e.object({data:V,params:_h});var xh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ph=e.object({data:V,params:xh});var Eh=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var Ch=e.object({data:V,params:Eh});var Uh=e.object({data:$e,params:e.record(e.string(),e.unknown())});var vh=e.object({data:ae,params:e.record(e.string(),e.unknown())});var Th=e.object({data:q,params:e.record(e.string(),e.unknown())});var Oh=e.object({data:q,params:e.record(e.string(),e.unknown())});var Pt=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var kh=e.object({message:e.string()});var Bh=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(kh),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var jh=e.object({data:e.list(ae),issues:e.list(Pt),skipped:e.list(Bh)});var Ah=e.object({data:jh,params:e.record(e.string(),e.unknown())});var Vh=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Dh=e.object({keys:e.record(e.string(),e.string()).optional()});var qh=e.object({data:Fi,params:Dh});var rr=e.enum_(["daily","hourly","monthly","weekly"]);var Mh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:rr.optional(),startTime:e.property("start_time",e.date().optional())});var Ih=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Yr),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional())});var Fh=e.object({periodEnd:e.property("period_end",e.date().optional()),periodStart:e.property("period_start",e.date().optional()),timestamp:e.date(),usage:e.number()});var Kh=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",ue),limits:e.list(Ih),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(Fh))});var Lh=e.object({data:Kh,params:Mh});var Gh=e.object({data:ae,params:e.record(e.string(),e.unknown())});var Wh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),startTime:e.property("start_time",e.date().optional())});var Et=e.object({billingCreditId:e.property("billing_credit_id",e.string()),creditName:e.property("credit_name",e.string()),creditsUsed:e.property("credits_used",e.number()),share:e.number(),user:gr.optional(),userId:e.property("user_id",e.string().optional())});var Ct=e.object({feature:We.optional(),lastSeen:e.property("last_seen",e.date()),share:e.number(),user:gr.optional(),userId:e.property("user_id",e.string().optional()),value:e.number()});var Hh=e.object({credits:e.list(Et),endTime:e.property("end_time",e.date()),rows:e.list(Ct),startTime:e.property("start_time",e.date())});var Nh=e.object({data:Hh,params:Wh});var $h=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),startTime:e.property("start_time",e.date().optional()),userId:e.property("user_id",e.string().optional())});var Jh=e.object({creditsUsed:e.property("credits_used",e.number()),date:e.date()});var Yh=e.object({date:e.date(),feature:We.optional(),value:e.number()});var Zh=e.object({credits:e.list(Et),dailyCreditPoints:e.property("daily_credit_points",e.list(Jh)),dailyPoints:e.property("daily_points",e.list(Yh)),endTime:e.property("end_time",e.date()),featureTotals:e.property("feature_totals",e.list(Ct)),startTime:e.property("start_time",e.date()),user:gr.optional()});var Xh=e.object({data:Zh,params:$h});var Qh=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var eg=e.object({data:e.list($e),params:Qh});var rg=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var ig=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Mi).optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditTypeName:e.property("credit_type_name",e.string().optional()),creditUsed:e.property("credit_used",e.number().optional()),usageAggregation:e.property("usage_aggregation",Ii.optional())});var og=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",te),company:re.optional(),companyOverride:e.property("company_override",$e.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Mi).optional()),creditGrantReason:e.property("credit_grant_reason",je.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsage:e.property("credit_usage",ig.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Ii.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Yr),feature:He.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:H.optional(),plan:dr.optional(),planEntitlement:e.property("plan_entitlement",ae.optional()),priceBehavior:e.property("price_behavior",Re.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var tg=e.object({data:e.list(og),params:rg});var ag=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var ng=e.object({data:e.list(Zr),params:ag});var sg=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var yr=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:We.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ur),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:qr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Oi),updatedAt:e.property("updated_at",e.date())});var Ze=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",Ir.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",vi.optional()),featureType:e.property("feature_type",ue),flags:e.list(yr),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainer:qr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Wr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:ge.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var cg=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",te),company:re.optional(),entitlementId:e.property("entitlement_id",e.string()),entitlementType:e.property("entitlement_type",Yr),feature:Ze.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),period:H.optional(),plan:dr.optional(),usage:e.number().optional(),user:gr.optional()});var lg=e.object({data:e.list(cg),params:sg});var pg=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var ug=e.object({data:e.list(ae),params:pg});var dg=e.object({data:$e,params:e.record(e.string(),e.unknown())});var mg=e.object({data:ae,params:e.record(e.string(),e.unknown())});var hg=e.object({data:ae,params:e.record(e.string(),e.unknown())});var gg=e.object({companyId:e.property("company_id",e.string().optional()),error:e.string().optional(),flagId:e.property("flag_id",e.string().optional()),flagKey:e.property("flag_key",e.string()),reason:e.string(),reqCompany:e.property("req_company",e.record(e.string(),e.string()).optional()),reqUser:e.property("req_user",e.record(e.string(),e.string()).optional()),ruleId:e.property("rule_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var yg=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var wg=e.object({company:yg.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var bg=e.object({cachedInputTokens:e.property("cached_input_tokens",e.number().optional()),company:e.record(e.string(),e.string()),cost:e.string().optional(),currency:e.string().optional(),event:e.string().optional(),inputTokens:e.property("input_tokens",e.number()),operation:e.string().optional(),outputTokens:e.property("output_tokens",e.number()),provider:e.string(),reasoningTokens:e.property("reasoning_tokens",e.number().optional()),requestModel:e.property("request_model",e.string().optional()),requests:e.number().optional(),responseModel:e.property("response_model",e.string()),user:e.record(e.string(),e.string()).optional()});var zg=e.object({company:e.record(e.string(),e.string()).optional(),event:e.string(),leaseId:e.property("lease_id",e.string().optional()),quantity:e.number().optional(),traits:e.record(e.string(),e.unknown()).optional(),user:e.record(e.string(),e.string()).optional()});var Ut=e.undiscriminatedUnion([zg,gg,wg,bg]);var Br=e.enum_(["flag_check","identify","inference","track"]);var vt=e.object({backfill:e.boolean().optional(),body:Ut.optional(),eventType:e.property("event_type",Br),idempotencyKey:e.property("idempotency_key",e.string().optional()),sentAt:e.property("sent_at",e.date().optional()),trustedClientClock:e.property("trusted_client_clock",e.boolean().optional())});var Qn=e.object({events:e.list(vt)});var Tt=e.object({capturedAt:e.property("captured_at",e.date()),eventId:e.property("event_id",e.string().optional()),remoteAddr:e.property("remote_addr",e.string().optional()),remoteIp:e.property("remote_ip",e.string()),userAgent:e.property("user_agent",e.string())});var Rg=e.object({events:e.list(Tt)});var fg=e.object({data:Rg,params:e.record(e.string(),e.unknown())});var _g=e.object({data:Tt,params:e.record(e.string(),e.unknown())});var Sg=e.enum_(["enriched","failed","pending","processed","unknown"]);var Ot=e.object({apiKey:e.property("api_key",e.string().optional()),apiKeyView:e.property("api_key_view",Ce.optional()),body:e.record(e.string(),e.unknown()),bodyPreview:e.property("body_preview",e.string()),capturedAt:e.property("captured_at",e.date()),company:Wr.optional(),companyId:e.property("company_id",e.string().optional()),enrichedAt:e.property("enriched_at",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),errorMessage:e.property("error_message",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string())),features:e.list(Wr),id:e.string(),idempotencyKey:e.property("idempotency_key",e.string().optional()),leaseId:e.property("lease_id",e.string().optional()),loadedAt:e.property("loaded_at",e.date().optional()),processedAt:e.property("processed_at",e.date().optional()),quantity:e.number(),sentAt:e.property("sent_at",e.date().optional()),status:Sg,subtype:e.string().optional(),type:Br,updatedAt:e.property("updated_at",e.date().optional()),user:Wr.optional(),userId:e.property("user_id",e.string().optional())});var xg=e.object({data:Ot,params:e.record(e.string(),e.unknown())});var Pg=e.object({eventSubtypes:e.property("event_subtypes",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Eg=e.object({data:e.list(vi),params:Pg});var Cg=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var Ug=e.object({data:Cg,params:e.record(e.string(),e.unknown())});var vg=e.object({companyId:e.property("company_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),eventTypes:e.property("event_types",e.list(Br).optional()),flagId:e.property("flag_id",e.string().optional()),idempotencyKey:e.property("idempotency_key",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var Tg=e.object({data:e.list(Ot),params:vg});var Eo=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var es=e.object({contexts:e.list(Eo)});var Zi=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ur),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var rs=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),externalResourceId:e.property("external_resource_id",e.string()),featureType:e.property("feature_type",ue),flag:Zi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var is=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ue),flag:Zi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var os=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ue.optional()),flag:Zi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ge.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string().optional(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var kt=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",Ti),creditCost:e.property("credit_cost",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string().optional(),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string().optional())});var Og=e.object({conditions:e.list(kt),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var kg=e.object({conditionGroups:e.property("condition_groups",e.list(Og)),conditions:e.list(kt),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Gr.optional()),value:e.boolean()});var ts=e.object({rules:e.list(kg)});var Bt=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:lt.optional(),error:e.string().optional(),featureAllocation:e.property("feature_allocation",e.number().optional()),featureUsage:e.property("feature_usage",e.number().optional()),featureUsageEvent:e.property("feature_usage_event",e.string().optional()),featureUsagePeriod:e.property("feature_usage_period",H.optional()),featureUsageResetAt:e.property("feature_usage_reset_at",e.date().optional()),flag:e.string(),flagId:e.property("flag_id",e.string().optional()),reason:e.string(),ruleId:e.property("rule_id",e.string().optional()),ruleType:e.property("rule_type",Gr.optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var Bg=e.object({data:Bt,params:e.record(e.string(),e.unknown())});var jg=e.object({remaining:e.number(),reserved:e.number(),settled:e.number()});var Ag=e.enum_(["active","converted","expired"]);var Vg=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",Ag.optional())});var jt=e.object({creditBalances:e.property("credit_balances",e.record(e.string(),jg).optional()),flags:e.list(Bt),plan:Vg.optional()});var Dg=e.object({data:e.list(jt)});var qg=e.object({data:Dg,params:e.record(e.string(),e.unknown())});var Mg=e.object({data:jt,params:e.record(e.string(),e.unknown())});var Ig=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(ue).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var Fg=e.object({data:V,params:Ig});var Kg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Lg=e.object({data:V,params:Kg});var Gg=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Wg=e.object({data:yr,params:e.record(e.string(),e.unknown())});var Hg=e.object({data:q,params:e.record(e.string(),e.unknown())});var Ng=e.object({data:q,params:e.record(e.string(),e.unknown())});var $g=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Jg=e.object({data:yr,params:e.record(e.string(),e.unknown())});var Yg=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(ue).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var Zg=e.object({data:e.list(Ze),params:Yg});var Xg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Qg=e.object({data:e.list(yr),params:Xg});var ey=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var ry=e.object({data:yr,params:e.record(e.string(),e.unknown())});var iy=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ur),id:e.string(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var oy=e.object({flag:iy.optional(),rules:e.list(Oi)});var ty=e.object({data:oy,params:e.record(e.string(),e.unknown())});var ay=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var ny=e.object({limit:e.number().optional()});var sy=e.object({actorName:e.property("actor_name",e.string()),method:e.string(),resourceName:e.property("resource_name",e.string()),resourceType:e.property("resource_type",e.string()),timestamp:e.date(),title:e.string()});var cy=e.object({entries:e.list(sy)});var ly=e.object({data:cy,params:ny});var py=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:rr.optional(),startTime:e.property("start_time",e.date().optional())});var At=e.object({timestamp:e.date(),usage:e.number()});var uy=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(At)});var dy=e.object({data:uy,params:py});var my=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:rr.optional(),startTime:e.property("start_time",e.date().optional())});var hy=e.object({featureId:e.property("feature_id",e.string()),points:e.list(At),traitDefinitionId:e.property("trait_definition_id",e.string())});var gy=e.object({data:hy,params:my});var yy=e.object({months:e.number().optional()});var wy=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var by=e.object({points:e.list(wy)});var zy=e.object({data:by,params:yy});var Ry=e.object({amount:e.number(),currency:e.string()});var fy=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(Ry),paidCompanies:e.property("paid_companies",e.number()),totalCompanies:e.property("total_companies",e.number()),totalFeatures:e.property("total_features",e.number()),totalPlans:e.property("total_plans",e.number())});var _y=e.object({data:fy,params:e.record(e.string(),e.unknown())});var Sy=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var xy=e.object({changePct:e.property("change_pct",e.number().optional()),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string()),pluralName:e.property("plural_name",e.string().optional()),priorUsage:e.property("prior_usage",e.number()),usage:e.number()});var Py=e.object({features:e.list(xy)});var Ey=e.object({data:Py,params:Sy});var Xi=e.enum_(["billing_meta_object","manual_upsert"]);var as=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Xi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var Vt=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var Cy=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Uy=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var vy=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var Ty=e.object({accountId:e.property("account_id",e.string().optional()),accountName:e.property("account_name",e.string().optional()),companyUpdateOnly:e.property("company_update_only",e.boolean().optional()),isSandbox:e.property("is_sandbox",e.boolean()),liveMode:e.property("live_mode",e.boolean()),onboardUrl:e.property("onboard_url",e.string().optional())});var Oy=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Dt=e.union("type",{clerk:Cy,metronome:Uy,orb:vy,stripe:Ty,workos:Oy}).transform({transform:p=>p,untransform:p=>p});var ky=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Xi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:Dt.optional(),createdAt:e.property("created_at",e.date()),id:e.string(),integrationId:e.property("integration_id",e.string()),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),liveMode:e.property("live_mode",e.boolean()),updatedAt:e.property("updated_at",e.date())});var Qi=e.object({capabilities:Vt,config:ky,integration:gt});var By=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var jy=e.object({type:Pe,url:e.string()});var Ay=e.object({data:jy,params:e.record(e.string(),e.unknown())});var Vy=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var Dy=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var qy=e.object({billingOnly:e.property("billing_only",e.boolean().optional()),excludeIds:e.property("exclude_ids",e.list(e.string()).optional()),id:e.string().optional(),limit:e.number().optional(),offset:e.number().optional(),state:Ie.optional(),type:Pe.optional()});var My=e.object({capabilities:Vt,config:Dt.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),lastWebhookReceivedAt:e.property("last_webhook_received_at",e.date().optional()),state:Ie,type:Pe});var Iy=e.object({data:e.list(My),params:qy});var Fy=e.object({keys:e.list(e.string())});var Ky=e.object({data:Fy,params:e.record(e.string(),e.unknown())});var qt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Ie,type:Pe,updatedAt:e.property("updated_at",e.date())});var Ly=e.object({data:qt,params:e.record(e.string(),e.unknown())});var Gy=e.object({data:qt,params:e.record(e.string(),e.unknown())});var Wy=e.object({data:q,params:e.record(e.string(),e.unknown())});var Hy=e.object({featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Ny=e.object({data:V,params:Hy});var Mt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var $y=e.object({data:Mt,params:e.record(e.string(),e.unknown())});var Jy=e.object({featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Yy=e.object({data:e.list(Mt),params:Jy});var Zy=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:de.optional(),name:e.string()});var It=e.stringLiteral("credit");var Ft=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",It.optional()),autoTopupAvailability:e.property("auto_topup_availability",cr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Q.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),licenseId:e.property("license_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",ke),resetStart:e.property("reset_start",Fe),resetType:e.property("reset_type",lr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional()),scaling:pr.optional()});var Xy=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var Kt=e.enum_(["create","update","delete"]);var Lt=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",It.optional()),autoTopupAvailability:e.property("auto_topup_availability",cr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Q.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number().optional()),expiryType:e.property("expiry_type",Q.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),licenseId:e.property("license_id",e.string().optional()),resetCadence:e.property("reset_cadence",ke),resetStart:e.property("reset_start",Fe),resetType:e.property("reset_type",lr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional()),scaling:pr.optional()});var eo=e.object({action:Kt,createReq:e.property("create_req",Ft.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",Xy.optional()),updateReq:e.property("update_req",Lt.optional())});var Qy=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(oi).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",H.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(se).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",Re.optional()),priceTiers:e.property("price_tiers",e.list(se).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(se).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",me.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",te),warningTiers:e.property("warning_tiers",e.list(ti).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(se).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var ro=e.object({action:Kt,entitlementId:e.property("entitlement_id",e.string().optional()),req:Qy.optional()});var ew=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",e.number().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional())});var ai=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Ke.optional()),chargeType:e.property("charge_type",Le),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(ew).optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",e.number().optional()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),quarterlyPriceId:e.property("quarterly_price_id",e.string().optional()),trialDays:e.property("trial_days",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var ns=e.object({billingProduct:e.property("billing_product",ai.optional()),creditGrants:e.property("credit_grants",e.list(eo).optional()),entitlements:e.list(ro),plan:Zy.optional()});var Gt=e.object({description:e.string(),icon:de.optional(),name:e.string(),planType:e.property("plan_type",ie)});var ss=e.object({billingProduct:e.property("billing_product",ai.optional()),creditGrants:e.property("credit_grants",e.list(eo).optional()),entitlements:e.list(ro),plan:Gt.optional()});var Wt=e.object({description:e.string().optional(),icon:de.optional(),name:e.string()});var cs=e.object({billingProduct:e.property("billing_product",ai.optional()),creditGrants:e.property("credit_grants",e.list(eo).optional()),entitlements:e.list(ro),plan:Wt.optional(),planVersionId:e.property("plan_version_id",e.string().optional())});var Ht=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Ke),chargeType:e.property("charge_type",Le),controlledBy:e.property("controlled_by",k),environmentId:e.property("environment_id",e.string()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),planId:e.property("plan_id",e.string()),trialDays:e.property("trial_days",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var io=e.object({billingProduct:e.property("billing_product",Ht.optional()),creditGrants:e.property("credit_grants",e.list(Be).optional()),entitlements:e.list(ae).optional(),plan:dr.optional()});var rw=e.object({data:io,params:e.record(e.string(),e.unknown())});var iw=e.object({data:io,params:e.record(e.string(),e.unknown())});var ow=e.object({data:io,params:e.record(e.string(),e.unknown())});var Nt=e.object({definitionId:e.property("definition_id",e.string().optional()),helperText:e.property("helper_text",e.string().optional()),id:e.string().optional(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string())});var tw=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var jr=e.object({entitlements:e.list(tw).optional(),planId:e.property("plan_id",e.string())});var oo=e.object({bundleId:e.string()});var $t=e.enum_(["end_of_billing_period","none"]);var ls=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(Nt).optional()),customPlanConfig:e.property("custom_plan_config",Xr.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(jr)),orderedBundleList:e.property("ordered_bundle_list",e.list(oo)),orderedPlans:e.property("ordered_plans",e.list(jr)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Ni),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",$t.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var ps=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Qr).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(Nt).optional()),customPlanConfig:e.property("custom_plan_config",Xr.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(jr)),orderedBundleList:e.property("ordered_bundle_list",e.list(oo)),orderedPlans:e.property("ordered_plans",e.list(jr)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Ni),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",$t.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Jt=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional())});var aw=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Yt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Zt=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(aw)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",Jt),componentSettings:e.property("component_settings",Yt),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnIds:e.property("ordered_add_on_ids",e.list(jr)),planIds:e.property("plan_ids",e.list(jr)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var nw=e.object({data:Zt,params:e.record(e.string(),e.unknown())});var sw=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var cw=e.object({createdAt:e.property("created_at",e.date()),definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),position:e.number(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),traitHierarchy:e.property("trait_hierarchy",e.list(e.string())),updatedAt:e.property("updated_at",e.date())});var lw=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var us=e.object({entitlements:e.list(lw).optional(),planId:e.property("plan_id",e.string())});var pw=e.object({addOns:e.property("add_ons",e.list(mr)),checkoutSettings:e.property("checkout_settings",Jt),componentSettings:e.property("component_settings",Yt),customCheckoutFields:e.property("custom_checkout_fields",e.list(cw)),customPlanConfig:e.property("custom_plan_config",rt.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",mr.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",mr.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",mr.optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPrice:e.property("initial_plan_price",N.optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnList:e.property("ordered_add_on_list",e.list(us)),orderedBundleList:e.property("ordered_bundle_list",e.list(oo)),orderedPlanList:e.property("ordered_plan_list",e.list(us)),plans:e.list(mr),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlan:e.property("trial_expiry_plan",mr.optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPrice:e.property("trial_expiry_plan_price",N.optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var uw=e.object({data:pw,params:sw});var dw=e.object({data:Zt,params:e.record(e.string(),e.unknown())});var to=e.enum_(["immediate","leave"]);var ds=e.object({companyIds:e.property("company_ids",e.list(e.string())),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),strategy:to,targetPlanType:e.property("target_plan_type",ie)});var ms=e.object({companyIds:e.property("company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),targetPlanType:e.property("target_plan_type",ie)});var Xt=e.enum_(["ambiguous_subscription_item","multiple_subscriptions","no_price_for_interval","not_on_origin_version","operation_item_not_found","permanent_config","permanent_decline","transient_decline","transient_infra","transient_stripe","unknown","would_leave_empty_subscription"]);var hs=e.object({errorCodes:e.property("error_codes",e.list(Xt))});var Ar=e.enum_(["completed","failed","in_progress","pending","skipped"]);var mw=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Ar.optional()});var hw=e.object({data:V,params:mw});var Vr=e.enum_(["completed","failed","in_progress","pending"]);var gw=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Vr.optional()});var yw=e.object({data:V,params:gw});var ni=e.object({completedAt:e.property("completed_at",e.date().optional()),completedCompanies:e.property("completed_companies",e.number()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),failedCompanies:e.property("failed_companies",e.number()),id:e.string(),planId:e.property("plan_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),skippedCompanies:e.property("skipped_companies",e.number()),startedAt:e.property("started_at",e.date().optional()),status:Vr,strategy:to,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var ww=e.object({data:ni,params:e.record(e.string(),e.unknown())});var bw=e.object({data:ni,params:e.record(e.string(),e.unknown())});var zw=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Ar.optional()});var Qt=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),errorCode:e.property("error_code",Xt.optional()),id:e.string(),migrationId:e.property("migration_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),startedAt:e.property("started_at",e.date().optional()),status:Ar,updatedAt:e.property("updated_at",e.date())});var Rw=e.object({data:e.list(Qt),params:zw});var fw=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Vr.optional()});var _w=e.object({data:e.list(ni),params:fw});var Sw=e.object({companyId:e.property("company_id",e.string()),hasBillingChanges:e.property("has_billing_changes",e.boolean()),hasCustomPricing:e.property("has_custom_pricing",e.boolean()),note:e.string().optional(),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),willUpdateSubscription:e.property("will_update_subscription",e.boolean())});var xw=e.object({companies:e.list(Sw)});var Pw=e.object({data:xw,params:e.record(e.string(),e.unknown())});var Ew=e.object({data:Qt,params:e.record(e.string(),e.unknown())});var Cw=e.object({data:ni,params:e.record(e.string(),e.unknown())});var gs=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),externalResourceId:e.property("external_resource_id",e.string()),externalResourceVersion:e.property("external_resource_version",e.string().optional()),icon:de.optional(),name:e.string(),planType:e.property("plan_type",ie)});var ys=e.object({companyId:e.property("company_id",e.string()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),description:e.string(),icon:de.optional(),name:e.string()});var ws=e.object({activationStrategy:e.property("activation_strategy",Vi.optional()),address:ot.optional(),couponExternalId:e.property("coupon_external_id",e.string().optional()),customFieldValues:e.property("custom_field_values",e.list($r).optional()),customerEmail:e.property("customer_email",e.string().optional()),daysUntilDue:e.property("days_until_due",e.number().optional()),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),migrationStrategy:e.property("migration_strategy",to),phone:e.string().optional(),sendInvoice:e.property("send_invoice",e.boolean().optional()),taxId:e.property("tax_id",tt.optional())});var bs=e.object({activationStrategy:e.property("activation_strategy",Vi.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional()),sendInvoice:e.property("send_invoice",e.boolean().optional())});var zs=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var Uw=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var vw=e.object({data:V,params:Uw});var Tw=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",ie.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var Ow=e.object({data:V,params:Tw});var kw=e.object({data:be,params:e.record(e.string(),e.unknown())});var Bw=e.object({data:be,params:e.record(e.string(),e.unknown())});var jw=e.object({data:q,params:e.record(e.string(),e.unknown())});var Aw=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var Vw=e.object({data:q,params:Aw});var Dw=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var qw=e.object({data:be,params:Dw});var Mw=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Iw=e.object({data:e.list(re),params:Mw});var Fw=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),status:vr.optional(),statuses:e.list(vr).optional()});var Kw=e.object({data:e.list(Jr),params:Fw});var Lw=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var Gw=e.object({data:e.list(Pt),params:Lw});var Ww=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",ie.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var Hw=e.object({data:e.list(be),params:Ww});var Nw=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var $w=e.object({data:fe,params:e.record(e.string(),e.unknown())});var Jw=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Yw=e.object({data:re,params:e.record(e.string(),e.unknown())});var Zw=e.object({data:be,params:e.record(e.string(),e.unknown())});var Xw=e.object({data:Ht,params:e.record(e.string(),e.unknown())});var Qw=e.object({data:be,params:e.record(e.string(),e.unknown())});var Rs=e.object({companyId:e.property("company_id",e.string()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),toPlanId:e.property("to_plan_id",e.string())});var si=e.enum_(["cancelled","error","executing","pending","success"]);var fs=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:si.optional()});var ci=e.object({actorType:e.property("actor_type",e.string()),companyId:e.property("company_id",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),errorMessage:e.property("error_message",e.string().optional()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),id:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),startedAt:e.property("started_at",e.date().optional()),status:si,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var eb=e.object({data:ci,params:e.record(e.string(),e.unknown())});var rb=e.object({data:ci,params:e.record(e.string(),e.unknown())});var ib=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:si.optional()});var ob=e.object({data:e.list(ci),params:ib});var tb=e.object({data:ci,params:e.record(e.string(),e.unknown())});var ao=e.object({creditId:e.property("credit_id",e.string())});var no=e.object({featureId:e.property("feature_id",e.string())});var wr=e.enum_(["subscription.trial.ended","company.created","company.deleted","company.override.created","company.override.deleted","company.override.expired","company.override.updated","company.plan_changed","company.scheduled_downgrade","company.updated","credit.limit.reached","credit.limit.warning","credit.purchase.success","entitlement.limit.reached","entitlement.limit.warning","entitlement.soft_limit.reached","entitlement.soft_limit.warning","entitlement.tier_limit.reached","entitlement.tier_limit.warning","feature.created","feature.deleted","feature.updated","flag.created","flag.deleted","flag_rules.updated","flag.updated","plan.created","plan.deleted","plan.entitlement.created","plan.entitlement.deleted","plan.entitlement.updated","plan.updated","plan_version.deleted","rule.deleted","test.send","user.created","user.deleted","user.updated","auto.topup.hard.failure","auto.topup.retry.exceeded","auto.topup.success"]);var _s=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(ao).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(no).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(wr)),url:e.string()});var Ss=e.object({requestType:e.property("request_type",wr)});var ea=e.enum_(["active","inactive"]);var xs=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(ao).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(no).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(wr).optional()),status:ea.optional(),url:e.string().optional()});var ab=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var nb=e.object({data:V,params:ab});var sb=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var cb=e.object({data:V,params:sb});var br=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(ao).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(no).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(wr)),secret:e.string(),status:ea,updatedAt:e.property("updated_at",e.date()),url:e.string()});var lb=e.object({data:br,params:e.record(e.string(),e.unknown())});var pb=e.object({data:q,params:e.record(e.string(),e.unknown())});var ub=e.enum_(["failure","pending","success"]);var ra=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",wr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:ub,updatedAt:e.property("updated_at",e.date()),webhook:br.optional(),webhookId:e.property("webhook_id",e.string())});var db=e.object({data:ra,params:e.record(e.string(),e.unknown())});var mb=e.object({data:br,params:e.record(e.string(),e.unknown())});var hb=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var gb=e.object({data:e.list(ra),params:hb});var yb=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var wb=e.object({data:e.list(br),params:yb});var bb=e.object({failureReason:e.property("failure_reason",e.string().optional()),responseCode:e.property("response_code",e.number()),success:e.boolean()});var zb=e.object({data:bb,params:e.record(e.string(),e.unknown())});var Rb=e.object({data:br,params:e.record(e.string(),e.unknown())});var n=e.object({error:e.string()});var fb=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var _b=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),planCreditGrantId:e.property("plan_credit_grant_id",e.string())});var ia=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var oa=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Ps=e.object({addOnIds:e.property("add_on_ids",e.list(fb)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(_b)),billingEntityId:e.property("billing_entity_id",e.string().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(ia)),customFieldValues:e.property("custom_field_values",e.list($r)),newPlanId:e.property("new_plan_id",e.string()),newPriceId:e.property("new_price_id",e.string()),optInAccepted:e.property("opt_in_accepted",e.boolean().optional()),payInAdvance:e.property("pay_in_advance",e.list(oa)),paymentMethodId:e.property("payment_method_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),skipTrial:e.property("skip_trial",e.boolean())});var Es=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ur),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var ta=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Xi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:e.record(e.string(),e.unknown()).optional(),isSandbox:e.property("is_sandbox",e.boolean().optional()),liveMode:e.property("live_mode",e.boolean().optional()),type:Pe});var Cs=e.object({keys:e.record(e.string(),e.string())});var Sb=e.object({planId:e.property("plan_id",e.string()),priceId:e.property("price_id",e.string().optional()),versionId:e.property("version_id",e.string().optional())});var Us=e.object({addOnSelections:e.property("add_on_selections",e.list(Sb)),basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),basePlanVersionId:e.property("base_plan_version_id",e.string().optional()),billingEntityId:e.property("billing_entity_id",e.string().optional()),cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(ia)),customFieldValues:e.property("custom_field_values",e.list($r)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(oa)),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),prorate:e.boolean().optional(),trialEnd:e.property("trial_end",e.date().optional())});var xb=e.record(e.string(),e.unknown());var Pb=e.record(e.string(),e.unknown());var Eb=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var so=e.enum_(["all_time","current_day","current_month","current_week"]);var co=e.enum_(["billing_cycle","first_of_month"]);var Cb=e.object({key:e.string(),value:e.number()});var aa=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",so.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",co.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",Eb),warningTiers:e.property("warning_tiers",e.list(Cb).optional())});var Ub=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var na=e.object({accountId:e.property("account_id",e.string()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",co),period:so,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var vb=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var Tb=e.enum_(["company","user"]);var Ob=e.enum_(["bool","date","int","string"]);var Co=e.object({comparableType:e.property("comparable_type",Ob),entityType:e.property("entity_type",Tb),id:e.string()});var sa=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",Co.optional()),conditionType:e.property("condition_type",vb),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",so.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",co.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Lr,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",Co.optional()),traitValue:e.property("trait_value",e.string())});var kb=e.object({conditions:e.list(sa)});var lo=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(kb)),conditions:e.list(sa),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Ub),value:e.boolean()});var Bb=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var ca=e.object({traitDefinition:e.property("trait_definition",Co.optional()),value:e.string()});var jb=e.object({accountId:e.property("account_id",e.string()),basePlanId:e.property("base_plan_id",e.string().optional()),billingProductIds:e.property("billing_product_ids",e.list(e.string())),creditBalances:e.property("credit_balances",e.record(e.string(),e.number())),entitlements:e.list(aa).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(na),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list(lo),subscription:Bb.optional(),traits:e.list(ca)});var vs=e.object({accountId:e.property("account_id",e.string()),defaultValue:e.property("default_value",e.boolean()),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),rules:e.list(lo)});var Ab=e.object({accountId:e.property("account_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),rules:e.list(lo),traits:e.list(ca)});var Ts=e.object({basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),preventKeyRemap:e.property("prevent_key_remap",e.boolean().optional()),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var Os=e.object({incr:e.number().optional(),keys:e.record(e.string(),e.string()),set:e.string().optional(),trait:e.string(),updateOnly:e.property("update_only",e.boolean().optional())});var ks=e.object({companies:e.list(e.record(e.string(),e.string())).optional(),company:e.record(e.string(),e.string()).optional(),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var la=class{constructor(o){this._options=L(o)}issueTemporaryAccessToken(o,i){return R.fromPromise(this.__issueTemporaryAccessToken(o,i))}async __issueTemporaryAccessToken(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"temporary-access-tokens"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:{...tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),resource_type:"company"},timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ll.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/temporary-access-tokens")}};var pa=class{constructor(o){this._options=L(o)}listAccountMembers(o={},i){return R.fromPromise(this.__listAccountMembers(o,i))}async __listAccountMembers(o={},i){let{ids:t,q:s,role:r,limit:a,offset:d}=o,y={ids:t,q:s,role:r!=null?Ur.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ol.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/account-members")}getAccountMember(o,i){return R.fromPromise(this.__getAccountMember(o,i))}async __getAccountMember(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`account-members/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/account-members/{account_member_id}")}countAccountMembers(o={},i){return R.fromPromise(this.__countAccountMembers(o,i))}async __countAccountMembers(o={},i){let{ids:t,q:s,role:r,limit:a,offset:d}=o,y={ids:t,q:s,role:r!=null?Ur.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:ul.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/account-members/count")}listApiKeys(o,i){return R.fromPromise(this.__listApiKeys(o,i))}async __listApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,d={environment_id:t,require_environment:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Bl.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/api-keys")}createApiKey(o,i){return R.fromPromise(this.__createApiKey(o,i))}async __createApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:an.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/api-keys")}getApiKey(o,i){return R.fromPromise(this.__getApiKey(o,i))}async __getApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/api-keys/{api_key_id}")}updateApiKey(o,i={},t){return R.fromPromise(this.__updateApiKey(o,i,t))}async __updateApiKey(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:sn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Il.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/api-keys/{api_key_id}")}deleteApiKey(o,i){return R.fromPromise(this.__deleteApiKey(o,i))}async __deleteApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Rl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/api-keys/{api_key_id}")}countApiKeys(o,i){return R.fromPromise(this.__countApiKeys(o,i))}async __countApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,d={environment_id:t,require_environment:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ml.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/api-keys/count")}listAuditLogs(o={},i){return R.fromPromise(this.__listAuditLogs(o,i))}async __listAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:d,limit:y,offset:g}=o,l={actor_type:t!=null?Ue.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:d?.toISOString(),limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Al.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/audit-log")}getAuditLog(o,i){return R.fromPromise(this.__getAuditLog(o,i))}async __getAuditLog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`audit-log/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:El.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/audit-log/{audit_log_id}")}countAuditLogs(o={},i){return R.fromPromise(this.__countAuditLogs(o,i))}async __countAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:d,limit:y,offset:g}=o,l={actor_type:t!=null?Ue.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:d?.toISOString(),limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:gl.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/audit-log/count")}listEnvironments(o={},i){return R.fromPromise(this.__listEnvironments(o,i))}async __listEnvironments(o={},i){let{ids:t,limit:s,offset:r}=o,a={ids:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Dl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/environments")}createEnvironment(o,i){return R.fromPromise(this.__createEnvironment(o,i))}async __createEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/environments")}getEnvironment(o,i){return R.fromPromise(this.__getEnvironment(o,i))}async __getEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/environments/{environment_id}")}updateEnvironment(o,i={},t){return R.fromPromise(this.__updateEnvironment(o,i,t))}async __updateEnvironment(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:cn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Fl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/environments/{environment_id}")}deleteEnvironment(o,i){return R.fromPromise(this.__deleteEnvironment(o,i))}async __deleteEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/environments/{environment_id}")}quickstart(o){return R.fromPromise(this.__quickstart(o))}async __quickstart(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"quickstart"),method:"POST",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ml.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 400:throw new v(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"POST","/quickstart")}getWhoAmI(o){return R.fromPromise(this.__getWhoAmI(o))}async __getWhoAmI(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"whoami"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:vl.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/whoami")}};var ua=class{constructor(o){this._options=L(o)}listCoupons(o={},i){return R.fromPromise(this.__listCoupons(o,i))}async __listCoupons(o={},i){let{isActive:t,q:s,limit:r,offset:a}=o,d={is_active:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:cp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/coupons")}upsertBillingCoupon(o,i){return R.fromPromise(this.__upsertBillingCoupon(o,i))}async __upsertBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:mn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/coupons")}deleteBillingCoupon(o,i){return R.fromPromise(this.__deleteBillingCoupon(o,i))}async __deleteBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/coupons/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Jl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/coupons/{billing_id}")}deleteBillingCustomer(o,i){return R.fromPromise(this.__deleteBillingCustomer(o,i))}async __deleteBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/customer/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Yl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/customer/{billing_id}")}upsertBillingCustomer(o,i){return R.fromPromise(this.__upsertBillingCustomer(o,i))}async __upsertBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customer/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ln.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/customer/upsert")}listCustomersWithSubscriptions(o={},i){return R.fromPromise(this.__listCustomersWithSubscriptions(o,i))}async __listCustomersWithSubscriptions(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:d,offset:y}=o,g={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:dp.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/customers")}countCustomers(o={},i){return R.fromPromise(this.__countCustomers(o,i))}async __countCustomers(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:d,offset:y}=o,g={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:$l.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/customers/count")}listInvoices(o,i){return R.fromPromise(this.__listInvoices(o,i))}async __listInvoices(o,i){let{companyId:t,customerExternalId:s,subscriptionExternalId:r,limit:a,offset:d}=o,y={company_id:t,customer_external_id:s,subscription_external_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:hp.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/billing/invoices")}upsertInvoice(o,i){return R.fromPromise(this.__upsertInvoice(o,i))}async __upsertInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:hn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/invoices")}deleteBillingInvoice(o,i){return R.fromPromise(this.__deleteBillingInvoice(o,i))}async __deleteBillingInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/invoices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Zl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/invoices/{billing_id}")}listMeters(o={},i){return R.fromPromise(this.__listMeters(o,i))}async __listMeters(o={},i){let{displayName:t,limit:s,offset:r}=o,a={display_name:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:yp.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/billing/meter")}upsertBillingMeter(o,i){return R.fromPromise(this.__upsertBillingMeter(o,i))}async __upsertBillingMeter(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:gn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_p.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/meter/upsert")}listPaymentMethods(o,i){return R.fromPromise(this.__listPaymentMethods(o,i))}async __listPaymentMethods(o,i){let{companyId:t,customerExternalId:s,limit:r,offset:a}=o,d={company_id:t,customer_external_id:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:bp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/payment-methods")}upsertPaymentMethod(o,i){return R.fromPromise(this.__upsertPaymentMethod(o,i))}async __upsertPaymentMethod(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Up.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/payment-methods")}deletePaymentMethodByExternalId(o,i){return R.fromPromise(this.__deletePaymentMethodByExternalId(o,i))}async __deletePaymentMethodByExternalId(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/payment-methods/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ql.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/payment-methods/{billing_id}")}listBillingPrices(o={},i){return R.fromPromise(this.__listBillingPrices(o,i))}async __listBillingPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:d,intervalCount:y,isActive:g,planVersionId:l,price:h,productId:w,productIds:U,providerType:T,q:O,tiersMode:B,usageType:j,withMeter:K,limit:A,offset:Z}=o,ne={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:d,interval_count:y,is_active:g,plan_version_id:l,price:h,product_id:w,product_ids:U,provider_type:T!=null?k.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,q:O,tiers_mode:B!=null?me.jsonOrThrow(B,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:j!=null?pe.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:K,limit:A,offset:Z},Se=await this._options.authProvider.getAuthRequest(),D=f(Se.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price"),method:"GET",headers:D,queryString:u.queryBuilder().addMany(ne).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:ip.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return C(M.error,M.rawResponse,"GET","/billing/price")}upsertBillingPrice(o,i){return R.fromPromise(this.__upsertBillingPrice(o,i))}async __upsertBillingPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:pn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/price/upsert")}deleteBillingProduct(o,i){return R.fromPromise(this.__deleteBillingProduct(o,i))}async __deleteBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/product/{billing_id}")}listBillingProductPrices(o={},i){return R.fromPromise(this.__listBillingProductPrices(o,i))}async __listBillingProductPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:d,intervalCount:y,isActive:g,planVersionId:l,price:h,productId:w,productIds:U,providerType:T,q:O,tiersMode:B,usageType:j,withMeter:K,limit:A,offset:Z}=o,ne={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:d,interval_count:y,is_active:g,plan_version_id:l,price:h,product_id:w,product_ids:U,provider_type:T!=null?k.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,q:O,tiers_mode:B!=null?me.jsonOrThrow(B,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:j!=null?pe.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:K,limit:A,offset:Z},Se=await this._options.authProvider.getAuthRequest(),D=f(Se.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/prices"),method:"GET",headers:D,queryString:u.queryBuilder().addMany(ne).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:tp.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return C(M.error,M.rawResponse,"GET","/billing/product/prices")}deleteProductPrice(o,i){return R.fromPromise(this.__deleteProductPrice(o,i))}async __deleteProductPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/prices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ep.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/product/prices/{billing_id}")}upsertBillingProduct(o,i){return R.fromPromise(this.__upsertBillingProduct(o,i))}async __upsertBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/product/upsert")}listBillingProducts(o={},i){return R.fromPromise(this.__listBillingProducts(o,i))}async __listBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:d,q:y,recurringChargesOnly:g,withOneTimeCharges:l,withPricesOnly:h,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,B={ids:t,is_active:s,name:r,price_usage_type:a!=null?pe.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,recurring_charges_only:g,with_one_time_charges:l,with_prices_only:h,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),K=f(j.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products"),method:"GET",headers:K,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:np.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return C(A.error,A.rawResponse,"GET","/billing/products")}countBillingProducts(o={},i){return R.fromPromise(this.__countBillingProducts(o,i))}async __countBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:d,q:y,recurringChargesOnly:g,withOneTimeCharges:l,withPricesOnly:h,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,B={ids:t,is_active:s,name:r,price_usage_type:a!=null?pe.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,recurring_charges_only:g,with_one_time_charges:l,with_prices_only:h,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),K=f(j.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products/count"),method:"GET",headers:K,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:Hl.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return C(A.error,A.rawResponse,"GET","/billing/products/count")}upsertBillingSubscription(o,i){return R.fromPromise(this.__upsertBillingSubscription(o,i))}async __upsertBillingSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/subscription/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:dn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ep.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/subscription/upsert")}};var da=class{constructor(o){this._options=L(o)}listCatalogs(o={},i){return R.fromPromise(this.__listCatalogs(o,i))}async __listCatalogs(o={},i){let{isDefault:t,q:s,limit:r,offset:a}=o,d={is_default:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Xp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/catalogs")}createCatalog(o,i){return R.fromPromise(this.__createCatalog(o,i))}async __createCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:wn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Op.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/catalogs")}getCatalog(o,i){return R.fromPromise(this.__getCatalog(o,i))}async __getCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Bp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}")}updateCatalog(o,i={},t){return R.fromPromise(this.__updateCatalog(o,i,t))}async __updateCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Qp.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}")}deleteCatalog(o,i){return R.fromPromise(this.__deleteCatalog(o,i))}async __deleteCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/catalogs/{catalog_id}")}getConfiguration(o,i){return R.fromPromise(this.__getConfiguration(o,i))}async __getConfiguration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/configuration`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/configuration")}updateConfiguration(o,i={},t){return R.fromPromise(this.__updateConfiguration(o,i,t))}async __updateConfiguration(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/configuration`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:zn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:eu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}/configuration")}getCreditBundlesInCatalog(o,i){return R.fromPromise(this.__getCreditBundlesInCatalog(o,i))}async __getCreditBundlesInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/credit-bundles")}addCreditBundle(o,i,t){return R.fromPromise(this.__addCreditBundle(o,i,t))}async __addCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles/${u.encodePathParam(i)}`),method:"POST",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}removeCreditBundle(o,i,t){return R.fromPromise(this.__removeCreditBundle(o,i,t))}async __removeCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles/${u.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}getDerivedFeatures(o,i){return R.fromPromise(this.__getDerivedFeatures(o,i))}async __getDerivedFeatures(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/features`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$p.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/features")}getPlansInCatalog(o,i){return R.fromPromise(this.__getPlansInCatalog(o,i))}async __getPlansInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Yp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/plans")}addPlan(o,i,t){return R.fromPromise(this.__addPlan(o,i,t))}async __addPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans/${u.encodePathParam(i)}`),method:"POST",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/plans/{plan_id}")}removePlan(o,i,t){return R.fromPromise(this.__removePlan(o,i,t))}async __removePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans/${u.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/plans/{plan_id}")}};var ma=class{constructor(o){this._options=L(o)}internal(o,i){return R.fromPromise(this.__internal(o,i))}async __internal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ps.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/checkout-internal")}getCheckoutData(o,i){return R.fromPromise(this.__getCheckoutData(o,i))}async __getCheckoutData(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/data"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Sn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/checkout-internal/data")}previewCheckoutInternal(o,i){return R.fromPromise(this.__previewCheckoutInternal(o,i))}async __previewCheckoutInternal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ps.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/checkout-internal/preview")}getCompanyBillingDetails(o,i){return R.fromPromise(this.__getCompanyBillingDetails(o,i))}async __getCompanyBillingDetails(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}/billing-details`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_u.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/companies/{company_id}/billing-details")}updateCompanyBillingDetails(o,i,t){return R.fromPromise(this.__updateCompanyBillingDetails(o,i,t))}async __updateCompanyBillingDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}/billing-details`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Tu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/companies/{company_id}/billing-details")}managePlan(o,i){return R.fromPromise(this.__managePlan(o,i))}async __managePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Us.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Su.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/manage-plan")}previewManagePlan(o,i){return R.fromPromise(this.__previewManagePlan(o,i))}async __previewManagePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Us.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/manage-plan/preview")}cancelSubscription(o,i){return R.fromPromise(this.__cancelSubscription(o,i))}async __cancelSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/subscription/cancel"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:_n.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:uu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/manage-plan/subscription/cancel")}updateCustomerSubscriptionTrialEnd(o,i={},t){return R.fromPromise(this.__updateCustomerSubscriptionTrialEnd(o,i,t))}async __updateCustomerSubscriptionTrialEnd(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`subscription/${u.encodePathParam(o)}/edit-trial-end`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Pn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Ou.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/subscription/{subscription_id}/edit-trial-end")}};var ha=class{constructor(o){this._options=L(o)}listCompanies(o={},i){return R.fromPromise(this.__listCompanies(o,i))}async __listCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:d,planIds:y,planVersionId:g,planVersionIds:l,q:h,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:B,withoutFeatureOverrideFor:j,withoutPlan:K,withoutSubscription:A,withSubscription:Z,limit:ne,offset:Se}=o,D={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:d,plan_ids:y,plan_version_id:g,plan_version_ids:l,q:h,sort_order_column:w,sort_order_direction:U!=null?Ae.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(Sr=>Tr.jsonOrThrow(Sr,{unrecognizedObjectKeys:"strip"})):T!=null?Tr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(Sr=>Or.jsonOrThrow(Sr,{unrecognizedObjectKeys:"strip"})):O!=null?Or.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:B,without_feature_override_for:j,without_plan:K,without_subscription:A,with_subscription:Z,limit:ne,offset:Se},M=await this._options.authProvider.getAuthRequest(),_r=f(M.headers,this._options?.headers,i?.headers),I=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"GET",headers:_r,queryString:u.queryBuilder().addMany(D).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(I.ok)return{data:fd.parseOrThrow(I.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:I.rawResponse};if(I.error.reason==="status-code")switch(I.error.statusCode){case 400:throw new v(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 401:throw new P(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 403:throw new _(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 404:throw new x(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 500:throw new S(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);default:throw new b({statusCode:I.error.statusCode,body:I.error.body,rawResponse:I.rawResponse})}return C(I.error,I.rawResponse,"GET","/companies")}upsertCompany(o,i){return R.fromPromise(this.__upsertCompany(o,i))}async __upsertCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ts.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Id.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/companies")}getCompany(o,i){return R.fromPromise(this.__getCompany(o,i))}async __getCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:cd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/companies/{company_id}")}deleteCompany(o,i={},t){return R.fromPromise(this.__deleteCompany(o,i,t))}async __deleteCompany(o,i={},t){let{cancelSubscription:s,prorate:r}=i,a={cancel_subscription:s,prorate:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}`),method:"DELETE",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Yu.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"DELETE","/companies/{company_id}")}countCompanies(o={},i){return R.fromPromise(this.__countCompanies(o,i))}async __countCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:d,planIds:y,planVersionId:g,planVersionIds:l,q:h,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:B,withoutFeatureOverrideFor:j,withoutPlan:K,withoutSubscription:A,withSubscription:Z,limit:ne,offset:Se}=o,D={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:d,plan_ids:y,plan_version_id:g,plan_version_ids:l,q:h,sort_order_column:w,sort_order_direction:U!=null?Ae.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(Sr=>Tr.jsonOrThrow(Sr,{unrecognizedObjectKeys:"strip"})):T!=null?Tr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(Sr=>Or.jsonOrThrow(Sr,{unrecognizedObjectKeys:"strip"})):O!=null?Or.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:B,without_feature_override_for:j,without_plan:K,without_subscription:A,with_subscription:Z,limit:ne,offset:Se},M=await this._options.authProvider.getAuthRequest(),_r=f(M.headers,this._options?.headers,i?.headers),I=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/count"),method:"GET",headers:_r,queryString:u.queryBuilder().addMany(D).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(I.ok)return{data:ju.parseOrThrow(I.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:I.rawResponse};if(I.error.reason==="status-code")switch(I.error.statusCode){case 400:throw new v(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 401:throw new P(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 403:throw new _(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 404:throw new x(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);case 500:throw new S(n.parseOrThrow(I.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),I.rawResponse);default:throw new b({statusCode:I.error.statusCode,body:I.error.body,rawResponse:I.rawResponse})}return C(I.error,I.rawResponse,"GET","/companies/count")}createCompany(o,i){return R.fromPromise(this.__createCompany(o,i))}async __createCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ts.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/companies/create")}deleteCompanyByKeys(o,i){return R.fromPromise(this.__deleteCompanyByKeys(o,i))}async __deleteCompanyByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Nu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/companies/delete")}lookupCompany(o,i){return R.fromPromise(this.__lookupCompany(o,i))}async __lookupCompany(o,i){let{keys:t}=o,s={keys:Te(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/lookup"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Ad.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/companies/lookup")}getCompanyBillingEntity(o={},i){return R.fromPromise(this.__getCompanyBillingEntity(o,i))}async __getCompanyBillingEntity(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:sd.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/company-billing-entity")}getBillingEntityChildSubscriptions(o={},i){return R.fromPromise(this.__getBillingEntityChildSubscriptions(o,i))}async __getBillingEntityChildSubscriptions(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity-subscriptions"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:td.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/company-billing-entity-subscriptions")}listCompanyMemberships(o={},i){return R.fromPromise(this.__listCompanyMemberships(o,i))}async __listCompanyMemberships(o={},i){let{companyId:t,userId:s,limit:r,offset:a}=o,d={company_id:t,user_id:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Sd.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/company-memberships")}getOrCreateCompanyMembership(o,i){return R.fromPromise(this.__getOrCreateCompanyMembership(o,i))}async __getOrCreateCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:md.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/company-memberships")}deleteCompanyMembership(o,i){return R.fromPromise(this.__deleteCompanyMembership(o,i))}async __deleteCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-memberships/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$u.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/company-memberships/{company_membership_id}")}getActiveCompanySubscription(o={},i){return R.fromPromise(this.__getActiveCompanySubscription(o,i))}async __getActiveCompanySubscription(o={},i){let{companyId:t,companyIds:s,limit:r,offset:a}=o,d={company_id:t,company_ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-subscriptions"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:rd.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/company-subscriptions")}upsertCompanyTrait(o,i){return R.fromPromise(this.__upsertCompanyTrait(o,i))}async __upsertCompanyTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Os.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Fd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/company-traits")}listEntityKeyDefinitions(o={},i){return R.fromPromise(this.__listEntityKeyDefinitions(o,i))}async __listEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:d}=o,y={entity_type:t!=null?ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Pd.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/entity-key-definitions")}deleteEntityKeyDefinition(o,i){return R.fromPromise(this.__deleteEntityKeyDefinition(o,i))}async __deleteEntityKeyDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-key-definitions/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Zu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/entity-key-definitions/{entity_key_definition_id}")}countEntityKeyDefinitions(o={},i){return R.fromPromise(this.__countEntityKeyDefinitions(o,i))}async __countEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:d}=o,y={entity_type:t!=null?ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Vu.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/entity-key-definitions/count")}countEntityKeys(o={},i){return R.fromPromise(this.__countEntityKeys(o,i))}async __countEntityKeys(o={},i){let{definitionId:t,entityType:s,limit:r,offset:a}=o,d={definition_id:t,entity_type:s!=null?ee.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-keys/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:qu.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/entity-keys/count")}listEntityTraitDefinitions(o={},i){return R.fromPromise(this.__listEntityTraitDefinitions(o,i))}async __listEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:d,limit:y,offset:g}=o,l={entity_type:t!=null?ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?he.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(T=>he.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):d!=null?he.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Cd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/entity-trait-definitions")}getOrCreateEntityTraitDefinition(o,i){return R.fromPromise(this.__getOrCreateEntityTraitDefinition(o,i))}async __getOrCreateEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/entity-trait-definitions")}getEntityTraitDefinition(o,i){return R.fromPromise(this.__getEntityTraitDefinition(o,i))}async __getEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ld.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/entity-trait-definitions/{entity_trait_definition_id}")}updateEntityTraitDefinition(o,i,t){return R.fromPromise(this.__updateEntityTraitDefinition(o,i,t))}async __updateEntityTraitDefinition(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Tn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:qd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/entity-trait-definitions/{entity_trait_definition_id}")}countEntityTraitDefinitions(o={},i){return R.fromPromise(this.__countEntityTraitDefinitions(o,i))}async __countEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:d,limit:y,offset:g}=o,l={entity_type:t!=null?ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?he.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(T=>he.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):d!=null?he.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Iu.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/entity-trait-definitions/count")}getEntityTraitValues(o,i){return R.fromPromise(this.__getEntityTraitValues(o,i))}async __getEntityTraitValues(o,i){let{definitionId:t,q:s,limit:r,offset:a}=o,d={definition_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-values"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:dd.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/entity-trait-values")}listPlanChanges(o={},i){return R.fromPromise(this.__listPlanChanges(o,i))}async __listPlanChanges(o={},i){let{action:t,basePlanAction:s,companyId:r,companyIds:a,planIds:d,limit:y,offset:g}=o,l={action:t!=null?Li.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Gi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,company_id:r,company_ids:a,plan_ids:d,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-changes"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:vd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/plan-changes")}getPlanChange(o,i){return R.fromPromise(this.__getPlanChange(o,i))}async __getPlanChange(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-changes/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-changes/{plan_change_id}")}listPlanTraits(o={},i){return R.fromPromise(this.__listPlanTraits(o,i))}async __listPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:d,offset:y}=o,g={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Od.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/plan-traits")}getPlanTrait(o,i){return R.fromPromise(this.__getPlanTrait(o,i))}async __getPlanTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-traits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-traits/{plan_trait_id}")}updatePlanTraitsBulk(o,i){return R.fromPromise(this.__updatePlanTraitsBulk(o,i))}async __updatePlanTraitsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:On.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Md.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-traits/bulk")}countPlanTraits(o={},i){return R.fromPromise(this.__countPlanTraits(o,i))}async __countPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:d,offset:y}=o,g={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Ku.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/plan-traits/count")}upsertUserTrait(o,i){return R.fromPromise(this.__upsertUserTrait(o,i))}async __upsertUserTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Os.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ld.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/user-traits")}listUsers(o={},i){return R.fromPromise(this.__listUsers(o,i))}async __listUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:d,offset:y}=o,g={company_id:t,ids:s,plan_id:r,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Bd.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/users")}upsertUser(o,i){return R.fromPromise(this.__upsertUser(o,i))}async __upsertUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ks.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Kd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/users")}getUser(o,i){return R.fromPromise(this.__getUser(o,i))}async __getUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/users/{user_id}")}deleteUser(o,i){return R.fromPromise(this.__deleteUser(o,i))}async __deleteUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Qu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/users/{user_id}")}countUsers(o={},i){return R.fromPromise(this.__countUsers(o,i))}async __countUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:d,offset:y}=o,g={company_id:t,ids:s,plan_id:r,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Gu.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/users/count")}createUser(o,i){return R.fromPromise(this.__createUser(o,i))}async __createUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ks.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/users/create")}deleteUserByKeys(o,i){return R.fromPromise(this.__deleteUserByKeys(o,i))}async __deleteUserByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/users/delete")}lookupUser(o,i){return R.fromPromise(this.__lookupUser(o,i))}async __lookupUser(o,i){let{keys:t}=o,s={keys:Te(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/lookup"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Dd.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/users/lookup")}};var ga=class{constructor(o){this._options=L(o)}listComponents(o={},i){return R.fromPromise(this.__listComponents(o,i))}async __listComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Zd.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/components")}createComponent(o,i){return R.fromPromise(this.__createComponent(o,i))}async __createComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Nd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/components")}getComponent(o,i){return R.fromPromise(this.__getComponent(o,i))}async __getComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Jd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/components/{component_id}")}updateComponent(o,i={},t){return R.fromPromise(this.__updateComponent(o,i,t))}async __updateComponent(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:An.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:cm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/components/{component_id}")}deleteComponent(o,i){return R.fromPromise(this.__deleteComponent(o,i))}async __deleteComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$d.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/components/{component_id}")}bindCatalog(o,i={},t){return R.fromPromise(this.__bindCatalog(o,i,t))}async __bindCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}/catalog`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Gd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/components/{component_id}/catalog")}countComponents(o={},i){return R.fromPromise(this.__countComponents(o,i))}async __countComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Hd.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/components/count")}previewComponentData(o={},i){return R.fromPromise(this.__previewComponentData(o,i))}async __previewComponentData(o={},i){let{companyId:t,componentId:s}=o,r={company_id:t,component_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/preview-data"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:sm.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/components/preview-data")}};var ya=class{constructor(o){this._options=L(o)}getPublicPlans(o){return R.fromPromise(this.__getPublicPlans(o))}async __getPublicPlans(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"public/plans"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:pm.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/public/plans")}};var wa=class{constructor(o){this._options=L(o)}listBillingCredits(o={},i){return R.fromPromise(this.__listBillingCredits(o,i))}async __listBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,d={ids:t,name:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Dm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits")}createBillingCredit(o,i){return R.fromPromise(this.__createBillingCredit(o,i))}async __createBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Mn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits")}getSingleBillingCredit(o,i){return R.fromPromise(this.__getSingleBillingCredit(o,i))}async __getSingleBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:km.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/billing/credits/{credit_id}")}updateBillingCredit(o,i,t){return R.fromPromise(this.__updateBillingCredit(o,i,t))}async __updateBillingCredit(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Ln.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:th.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/{credit_id}")}softDeleteBillingCredit(o,i){return R.fromPromise(this.__softDeleteBillingCredit(o,i))}async __softDeleteBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:oh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/credits/{credit_id}")}listCompanyCreditBalances(o,i){return R.fromPromise(this.__listCompanyCreditBalances(o,i))}async __listCompanyCreditBalances(o,i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/balance"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Km.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/billing/credits/balance")}listCreditBundles(o={},i){return R.fromPromise(this.__listCreditBundles(o,i))}async __listCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:d,offset:y}=o,g={ids:t,credit_id:s,status:r!=null?ve.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?Me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Hm.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/credits/bundles")}createCreditBundle(o,i){return R.fromPromise(this.__createCreditBundle(o,i))}async __createCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Fn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Em.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/bundles")}getCreditBundle(o,i){return R.fromPromise(this.__getCreditBundle(o,i))}async __getCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Om.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/billing/credits/bundles/{bundle_id}")}updateCreditBundleDetails(o,i,t){return R.fromPromise(this.__updateCreditBundleDetails(o,i,t))}async __updateCreditBundleDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Gn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:nh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/bundles/{bundle_id}")}deleteCreditBundle(o,i){return R.fromPromise(this.__deleteCreditBundle(o,i))}async __deleteCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/credits/bundles/{bundle_id}")}countCreditBundles(o={},i){return R.fromPromise(this.__countCreditBundles(o,i))}async __countCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:d,offset:y}=o,g={ids:t,credit_id:s,status:r!=null?ve.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?Me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:fm.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/credits/bundles/count")}countBillingCredits(o={},i){return R.fromPromise(this.__countBillingCredits(o,i))}async __countBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,d={ids:t,name:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:gm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits/count")}zeroOutGrant(o,i={},t){return R.fromPromise(this.__zeroOutGrant(o,i,t))}async __zeroOutGrant(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/grants/${u.encodePathParam(o)}/zero-out`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Wn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:sh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/grants/{grant_id}/zero-out")}grantBillingCreditsToCompany(o,i){return R.fromPromise(this.__grantBillingCreditsToCompany(o,i))}async __grantBillingCreditsToCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:In.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Am.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/grants/company")}countCompanyGrants(o={},i){return R.fromPromise(this.__countCompanyGrants(o,i))}async __countCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:d}=o,y={company_id:t,order:s!=null?hi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Ae.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:zm.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/billing/credits/grants/company/count")}listCompanyGrants(o={},i){return R.fromPromise(this.__listCompanyGrants(o,i))}async __listCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:d}=o,y={company_id:t,order:s!=null?hi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Ae.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/list"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Gm.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/billing/credits/grants/company/list")}countBillingCreditsGrants(o={},i){return R.fromPromise(this.__countBillingCreditsGrants(o,i))}async __countBillingCreditsGrants(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,d={credit_id:t,ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:mm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits/grants/count")}listGrantsForCredit(o={},i){return R.fromPromise(this.__listGrantsForCredit(o,i))}async __listGrantsForCredit(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,d={credit_id:t,ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/list"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:rh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits/grants/list")}acquireCreditLease(o,i){return R.fromPromise(this.__acquireCreditLease(o,i))}async __acquireCreditLease(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/lease"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:qn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:um.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/lease")}extendCreditLease(o,i,t){return R.fromPromise(this.__extendCreditLease(o,i,t))}async __extendCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${u.encodePathParam(o)}/extend`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Kn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Tm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/extend")}releaseCreditLease(o,i,t){return R.fromPromise(this.__releaseCreditLease(o,i,t))}async __releaseCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${u.encodePathParam(o)}/release`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Pb.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ih.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/release")}listBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__listBillingPlanCreditGrants(o,i))}async __listBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:d,planVersionIds:y,limit:g,offset:l}=o,h={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:d,plan_version_ids:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Mm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/billing/credits/plan-grants")}createBillingPlanCreditGrant(o,i){return R.fromPromise(this.__createBillingPlanCreditGrant(o,i))}async __createBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ft.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Pm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/plan-grants")}getSingleBillingPlanCreditGrant(o,i){return R.fromPromise(this.__getSingleBillingPlanCreditGrant(o,i))}async __getSingleBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Bm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/billing/credits/plan-grants/{plan_grant_id}")}updateBillingPlanCreditGrant(o,i,t){return R.fromPromise(this.__updateBillingPlanCreditGrant(o,i,t))}async __updateBillingPlanCreditGrant(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Lt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ah.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/plan-grants/{plan_grant_id}")}deleteBillingPlanCreditGrant(o,i={},t){return R.fromPromise(this.__deleteBillingPlanCreditGrant(o,i,t))}async __deleteBillingPlanCreditGrant(o,i={},t){let{applyToExisting:s}=i,r={apply_to_existing:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Um.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"DELETE","/billing/credits/plan-grants/{plan_grant_id}")}countBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__countBillingPlanCreditGrants(o,i))}async __countBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:d,planVersionIds:y,limit:g,offset:l}=o,h={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:d,plan_version_ids:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:wm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/billing/credits/plan-grants/count")}listCreditEventLedger(o,i){return R.fromPromise(this.__listCreditEventLedger(o,i))}async __listCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:d,startTime:y,limit:g,offset:l}=o,h={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?kr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Qm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger")}countCreditEventLedger(o,i){return R.fromPromise(this.__countCreditEventLedger(o,i))}async __countCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:d,startTime:y,limit:g,offset:l}=o,h={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?kr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Sm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger/count")}};var ba=class{constructor(o){this._options=L(o)}listDataExports(o={},i){return R.fromPromise(this.__listDataExports(o,i))}async __listDataExports(o={},i){let{exportType:t,status:s,limit:r,offset:a}=o,d={export_type:t!=null?ii.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,status:s!=null?Ji.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:wh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/data-exports")}createDataExport(o,i){return R.fromPromise(this.__createDataExport(o,i))}async __createDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Hn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/data-exports")}getDataExport(o,i){return R.fromPromise(this.__getDataExport(o,i))}async __getDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}")}getDataExportArtifact(o,i){return R.fromPromise(this.__getDataExportArtifact(o,i))}async __getDataExportArtifact(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${u.encodePathParam(o)}/artifact`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),responseType:"streaming",timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:r.body,rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}/artifact")}};var za=class{constructor(o){this._options=L(o)}listCompanyOverrides(o={},i){return R.fromPromise(this.__listCompanyOverrides(o,i))}async __listCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:d,withoutExpired:y,q:g,limit:l,offset:h}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:d,without_expired:y,q:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:eg.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/company-overrides")}createCompanyOverride(o,i){return R.fromPromise(this.__createCompanyOverride(o,i))}async __createCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:$n.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Uh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/company-overrides")}getCompanyOverride(o,i){return R.fromPromise(this.__getCompanyOverride(o,i))}async __getCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/company-overrides/{company_override_id}")}updateCompanyOverride(o,i,t){return R.fromPromise(this.__updateCompanyOverride(o,i,t))}async __updateCompanyOverride(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Zn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:dg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/company-overrides/{company_override_id}")}deleteCompanyOverride(o,i){return R.fromPromise(this.__deleteCompanyOverride(o,i))}async __deleteCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Th.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/company-overrides/{company_override_id}")}countCompanyOverrides(o={},i){return R.fromPromise(this.__countCompanyOverrides(o,i))}async __countCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:d,withoutExpired:y,q:g,limit:l,offset:h}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:d,without_expired:y,q:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides/count"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:zh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/company-overrides/count")}listFeatureCompanies(o,i){return R.fromPromise(this.__listFeatureCompanies(o,i))}async __listFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:tg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-companies")}countFeatureCompanies(o,i){return R.fromPromise(this.__countFeatureCompanies(o,i))}async __countFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:fh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-companies/count")}listFeatureUsage(o={},i){return R.fromPromise(this.__listFeatureUsage(o,i))}async __listFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:d,q:y,withoutNegativeEntitlements:g,limit:l,offset:h}=o,w={company_id:t,company_keys:s!=null?Te(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,without_negative_entitlements:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:ng.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/feature-usage")}getFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getFeatureUsageTimeSeries(o,i))}async __getFeatureUsageTimeSeries(o,i){let{companyId:t,endTime:s,featureId:r,granularity:a,startTime:d}=o,y={company_id:t,end_time:s.toISOString(),feature_id:r,granularity:a!=null?rr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,start_time:d.toISOString()},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage-timeseries"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Lh.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/feature-usage-timeseries")}countFeatureUsage(o={},i){return R.fromPromise(this.__countFeatureUsage(o,i))}async __countFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:d,q:y,withoutNegativeEntitlements:g,limit:l,offset:h}=o,w={company_id:t,company_keys:s!=null?Te(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,without_negative_entitlements:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage/count"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Sh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/feature-usage/count")}listFeatureUsers(o,i){return R.fromPromise(this.__listFeatureUsers(o,i))}async __listFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:lg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-users")}countFeatureUsers(o,i){return R.fromPromise(this.__countFeatureUsers(o,i))}async __countFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Ph.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-users/count")}listPlanEntitlements(o={},i){return R.fromPromise(this.__listPlanEntitlements(o,i))}async __listPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:d,planVersionId:y,planVersionIds:g,q:l,withMeteredProducts:h,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:d,plan_version_id:y,plan_version_ids:g,q:l,with_metered_products:h,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),B=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"GET",headers:B,queryString:u.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:ug.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return C(j.error,j.rawResponse,"GET","/plan-entitlements")}createPlanEntitlement(o,i){return R.fromPromise(this.__createPlanEntitlement(o,i))}async __createPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-entitlements")}getPlanEntitlement(o,i){return R.fromPromise(this.__getPlanEntitlement(o,i))}async __getPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-entitlements/{plan_entitlement_id}")}updatePlanEntitlement(o,i,t){return R.fromPromise(this.__updatePlanEntitlement(o,i,t))}async __updatePlanEntitlement(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:mg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plan-entitlements/{plan_entitlement_id}")}deletePlanEntitlement(o,i){return R.fromPromise(this.__deletePlanEntitlement(o,i))}async __deletePlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Oh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/plan-entitlements/{plan_entitlement_id}")}upsertPlanEntitlementForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanEntitlementForBillingProduct(o,i))}async __upsertPlanEntitlementForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-entitlements/billing-linked")}countPlanEntitlements(o={},i){return R.fromPromise(this.__countPlanEntitlements(o,i))}async __countPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:d,planVersionId:y,planVersionIds:g,q:l,withMeteredProducts:h,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:d,plan_version_id:y,plan_version_ids:g,q:l,with_metered_products:h,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),B=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/count"),method:"GET",headers:B,queryString:u.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:Ch.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return C(j.error,j.rawResponse,"GET","/plan-entitlements/count")}duplicatePlanEntitlements(o,i){return R.fromPromise(this.__duplicatePlanEntitlements(o,i))}async __duplicatePlanEntitlements(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/duplicate"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ah.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-entitlements/duplicate")}getFeatureUsageByCompany(o,i){return R.fromPromise(this.__getFeatureUsageByCompany(o,i))}async __getFeatureUsageByCompany(o,i){let{keys:t}=o,s={keys:Te(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"usage-by-company"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:qh.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/usage-by-company")}getUserUsageByCompany(o,i){return R.fromPromise(this.__getUserUsageByCompany(o,i))}async __getUserUsageByCompany(o,i){let{companyId:t,endTime:s,featureId:r,startTime:a}=o,d={company_id:t,end_time:s?.toISOString(),feature_id:r,start_time:a?.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-usage-by-company"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Nh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/user-usage-by-company")}getUserUsageDetail(o,i){return R.fromPromise(this.__getUserUsageDetail(o,i))}async __getUserUsageDetail(o,i){let{companyId:t,endTime:s,startTime:r,userId:a}=o,d={company_id:t,end_time:s?.toISOString(),start_time:r?.toISOString(),user_id:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-usage-detail"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Xh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/user-usage-detail")}};var Ra=class{constructor(o){this._options=L(o)}createEventBatch(o,i){return R.fromPromise(this.__createEventBatch(o,i))}async __createEventBatch(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-batch"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/event-batch")}getEventSummaries(o={},i){return R.fromPromise(this.__getEventSummaries(o,i))}async __getEventSummaries(o={},i){let{q:t,eventSubtypes:s,limit:r,offset:a}=o,d={q:t,event_subtypes:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-types"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Eg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/event-types")}listEvents(o={},i){return R.fromPromise(this.__listEvents(o,i))}async __listEvents(o={},i){let{companyId:t,eventSubtype:s,eventTypes:r,flagId:a,idempotencyKey:d,userId:y,limit:g,offset:l}=o,h={company_id:t,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>Br.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?Br.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:a,idempotency_key:d,user_id:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Tg.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/events")}createEvent(o,i){return R.fromPromise(this.__createEvent(o,i))}async __createEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_g.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/events")}getEvent(o,i){return R.fromPromise(this.__getEvent(o,i))}async __getEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/events/{event_id}")}getSegmentIntegrationStatus(o){return R.fromPromise(this.__getSegmentIntegrationStatus(o))}async __getSegmentIntegrationStatus(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"segment-integration"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ug.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/segment-integration")}};var fa=class{constructor(o){this._options=L(o)}listFeatures(o={},i){return R.fromPromise(this.__listFeatures(o,i))}async __listFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:d,q:y,withoutCompanyOverrideFor:g,withoutPlanEntitlementFor:l,limit:h,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>ue.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?ue.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:d,q:y,without_company_override_for:g,without_plan_entitlement_for:l,limit:h,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Zg.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return C(B.error,B.rawResponse,"GET","/features")}createFeature(o,i){return R.fromPromise(this.__createFeature(o,i))}async __createFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:is.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/features")}getFeature(o,i){return R.fromPromise(this.__getFeature(o,i))}async __getFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$g.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/features/{feature_id}")}updateFeature(o,i={},t){return R.fromPromise(this.__updateFeature(o,i,t))}async __updateFeature(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:os.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ey.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/features/{feature_id}")}deleteFeature(o,i){return R.fromPromise(this.__deleteFeature(o,i))}async __deleteFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/features/{feature_id}")}upsertFeatureForBillingProduct(o,i){return R.fromPromise(this.__upsertFeatureForBillingProduct(o,i))}async __upsertFeatureForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ay.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/features/billing-linked")}countFeatures(o={},i){return R.fromPromise(this.__countFeatures(o,i))}async __countFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:d,q:y,withoutCompanyOverrideFor:g,withoutPlanEntitlementFor:l,limit:h,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>ue.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?ue.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:d,q:y,without_company_override_for:g,without_plan_entitlement_for:l,limit:h,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/count"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Fg.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return C(B.error,B.rawResponse,"GET","/features/count")}listFlags(o={},i){return R.fromPromise(this.__listFlags(o,i))}async __listFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:d}=o,y={feature_id:t,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Qg.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/flags")}createFlag(o,i){return R.fromPromise(this.__createFlag(o,i))}async __createFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/flags")}getFlag(o,i){return R.fromPromise(this.__getFlag(o,i))}async __getFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Jg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/flags/{flag_id}")}updateFlag(o,i,t){return R.fromPromise(this.__updateFlag(o,i,t))}async __updateFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Es.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ry.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/flags/{flag_id}")}deleteFlag(o,i){return R.fromPromise(this.__deleteFlag(o,i))}async __deleteFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ng.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/flags/{flag_id}")}updateFlagRules(o,i,t){return R.fromPromise(this.__updateFlagRules(o,i,t))}async __updateFlagRules(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}/rules`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ts.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ty.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/flags/{flag_id}/rules")}checkFlag(o,i,t){return R.fromPromise(this.__checkFlag(o,i,t))}async __checkFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}/check`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Eo.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Bg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/flags/{key}/check")}checkFlags(o,i){return R.fromPromise(this.__checkFlags(o,i))}async __checkFlags(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Eo.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Mg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/flags/check")}checkFlagsBulk(o,i){return R.fromPromise(this.__checkFlagsBulk(o,i))}async __checkFlagsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check-bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/flags/check-bulk")}countFlags(o={},i){return R.fromPromise(this.__countFlags(o,i))}async __countFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:d}=o,y={feature_id:t,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Lg.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/flags/count")}};var _a=class{constructor(o){this._options=L(o)}getActivity(o={},i){return R.fromPromise(this.__getActivity(o,i))}async __getActivity(o={},i){let{limit:t}=o,s={limit:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/activity"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:ly.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/insights/activity")}getEnvironmentFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentFeatureUsageTimeSeries(o,i))}async __getEnvironmentFeatureUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/feature-usage-timeseries"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:dy.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/insights/feature-usage-timeseries")}getPlanGrowth(o={},i){return R.fromPromise(this.__getPlanGrowth(o,i))}async __getPlanGrowth(o={},i){let{months:t}=o,s={months:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/plan-growth"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:zy.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/insights/plan-growth")}getSummary(o){return R.fromPromise(this.__getSummary(o))}async __getSummary(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/summary"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:_y.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/insights/summary")}getTopFeaturesByUsage(o,i){return R.fromPromise(this.__getTopFeaturesByUsage(o,i))}async __getTopFeaturesByUsage(o,i){let{endTime:t,limit:s,startTime:r}=o,a={end_time:t.toISOString(),limit:s,start_time:r.toISOString()},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/top-features"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Ey.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/insights/top-features")}getEnvironmentTraitUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentTraitUsageTimeSeries(o,i))}async __getEnvironmentTraitUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/trait-usage-timeseries"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:gy.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/insights/trait-usage-timeseries")}};var Sa=class{constructor(o){this._options=L(o)}runIntegration(o,i){return R.fromPromise(this.__runIntegration(o,i))}async __runIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integration/start/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ly.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/integration/start/{integration_id}")}listIntegrations(o={},i){return R.fromPromise(this.__listIntegrations(o,i))}async __listIntegrations(o={},i){let{billingOnly:t,excludeIds:s,id:r,state:a,type:d,limit:y,offset:g}=o,l={billing_only:t,exclude_ids:s,id:r,state:a!=null?Ie.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,type:d!=null?Pe.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Iy.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/integrations")}getIntegrationWebhookUrl(o,i){return R.fromPromise(this.__getIntegrationWebhookUrl(o,i))}async __getIntegrationWebhookUrl(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/${u.encodePathParam(o)}/webhook-url`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ay.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/integrations/{type}/webhook-url")}installIntegration(o,i){return R.fromPromise(this.__installIntegration(o,i))}async __installIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/install"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ta.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/install")}startDataImport(o,i){return R.fromPromise(this.__startDataImport(o,i))}async __startDataImport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/start-data-import"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:as.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/start-data-import")}loadSampleDataSet(o){return R.fromPromise(this.__loadSampleDataSet(o))}async __loadSampleDataSet(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/dataset-sample-v2"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ky.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/integrations/stripe/dataset-sample-v2")}assumeStripeInstalled(o,i){return R.fromPromise(this.__assumeStripeInstalled(o,i))}async __assumeStripeInstalled(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/assume-installed"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ta.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:By.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/stripe/v2/assume-installed")}installStripe(o,i){return R.fromPromise(this.__installStripe(o,i))}async __installStripe(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/install"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ta.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/stripe/v2/install")}uninstallIntegration(o,i){return R.fromPromise(this.__uninstallIntegration(o,i))}async __uninstallIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/uninstall/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/integrations/uninstall/{integration_id}")}};var xa=class{constructor(o){this._options=L(o)}listLicenses(o={},i){return R.fromPromise(this.__listLicenses(o,i))}async __listLicenses(o={},i){let{featureIds:t,ids:s,name:r,limit:a,offset:d}=o,y={feature_ids:t,ids:s,name:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"licenses"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Yy.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/licenses")}getSingleLicense(o,i){return R.fromPromise(this.__getSingleLicense(o,i))}async __getSingleLicense(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`licenses/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$y.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/licenses/{license_id}")}countLicenses(o={},i){return R.fromPromise(this.__countLicenses(o,i))}async __countLicenses(o={},i){let{featureIds:t,ids:s,name:r,limit:a,offset:d}=o,y={feature_ids:t,ids:s,name:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"licenses/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ny.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/licenses/count")}};var Pa=class{constructor(o){this._options=L(o)}createCustomPlanBundle(o,i){return R.fromPromise(this.__createCustomPlanBundle(o,i))}async __createCustomPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ns.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:rw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/custom-plan-bundles")}createPlanBundle(o,i){return R.fromPromise(this.__createPlanBundle(o,i))}async __createPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ss.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:iw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-bundles")}updatePlanBundle(o,i,t){return R.fromPromise(this.__updatePlanBundle(o,i,t))}async __updatePlanBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:cs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ow.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var Ea=class{constructor(o){this._options=L(o)}getPlanGroup(o={},i){return R.fromPromise(this.__getPlanGroup(o,i))}async __getPlanGroup(o={},i){let{includeCompanyCounts:t}=o,s={include_company_counts:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:uw.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/plan-groups")}createPlanGroup(o,i){return R.fromPromise(this.__createPlanGroup(o,i))}async __createPlanGroup(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ls.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:nw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-groups")}updatePlanGroup(o,i,t){return R.fromPromise(this.__updatePlanGroup(o,i,t))}async __updatePlanGroup(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-groups/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ps.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:dw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var Ca=class{constructor(o){this._options=L(o)}listCompanyMigrations(o={},i){return R.fromPromise(this.__listCompanyMigrations(o,i))}async __listCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:d}=o,y={migration_id:t,q:s,status:r!=null?Ar.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Rw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/plan-version-company-migrations")}retryCompanyMigration(o,i){return R.fromPromise(this.__retryCompanyMigration(o,i))}async __retryCompanyMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-company-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ew.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-version-company-migrations/{plan_version_company_migration_id}/retry")}countCompanyMigrations(o={},i){return R.fromPromise(this.__countCompanyMigrations(o,i))}async __countCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:d}=o,y={migration_id:t,q:s,status:r!=null?Ar.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:hw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/plan-version-company-migrations/count")}listMigrations(o={},i){return R.fromPromise(this.__listMigrations(o,i))}async __listMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,d={plan_version_id:t,status:s!=null?Vr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:_w.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plan-version-migrations")}createMigration(o,i){return R.fromPromise(this.__createMigration(o,i))}async __createMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ds.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ww.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-version-migrations")}getMigration(o,i){return R.fromPromise(this.__getMigration(o,i))}async __getMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-version-migrations/{plan_version_migration_id}")}retryMigration(o,i,t){return R.fromPromise(this.__retryMigration(o,i,t))}async __retryMigration(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:hs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Cw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/plan-version-migrations/{plan_version_migration_id}/retry")}countMigrations(o={},i){return R.fromPromise(this.__countMigrations(o,i))}async __countMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,d={plan_version_id:t,status:s!=null?Vr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:yw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plan-version-migrations/count")}previewMigration(o,i){return R.fromPromise(this.__previewMigration(o,i))}async __previewMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ms.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Pw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-version-migrations/preview")}};var Ua=class{constructor(o){this._options=L(o)}updateCompanyPlans(o,i,t){return R.fromPromise(this.__updateCompanyPlans(o,i,t))}async __updateCompanyPlans(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:zs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Yw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/company-plans/{company_plan_id}")}listCustomPlanBillings(o={},i){return R.fromPromise(this.__listCustomPlanBillings(o,i))}async __listCustomPlanBillings(o={},i){let{companyId:t,planId:s,status:r,statuses:a,limit:d,offset:y}=o,g={company_id:t,plan_id:s,status:r!=null?vr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(a)?a.map(U=>vr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):a!=null?vr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-billings"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Kw.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/custom-plan-billings")}markCustomPlanBillingPaid(o,i,t){return R.fromPromise(this.__markCustomPlanBillingPaid(o,i,t))}async __markCustomPlanBillingPaid(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${u.encodePathParam(o)}/mark-paid`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xb.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Nw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/mark-paid")}retryCustomPlanBilling(o,i,t){return R.fromPromise(this.__retryCustomPlanBilling(o,i,t))}async __retryCustomPlanBilling(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${u.encodePathParam(o)}/retry`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:bs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Jw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/retry")}createCustomPlan(o,i){return R.fromPromise(this.__createCustomPlan(o,i))}async __createCustomPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ys.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/custom-plans")}listPlans(o={},i){return R.fromPromise(this.__listPlans(o,i))}async __listPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:d,forTrialExpiryPlan:y,hasProductId:g,ids:l,includeDraftVersions:h,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:B,withoutPaidProductId:j,limit:K,offset:A}=o,Z={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:d,for_trial_expiry_plan:y,has_product_id:g,ids:l,include_draft_versions:h,plan_type:w!=null?ie.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:B,without_paid_product_id:j,limit:K,offset:A},ne=await this._options.authProvider.getAuthRequest(),Se=f(ne.headers,this._options?.headers,i?.headers),D=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"GET",headers:Se,queryString:u.queryBuilder().addMany(Z).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(D.ok)return{data:Hw.parseOrThrow(D.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:D.rawResponse};if(D.error.reason==="status-code")switch(D.error.statusCode){case 400:throw new v(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 401:throw new P(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 403:throw new _(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 404:throw new x(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 500:throw new S(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);default:throw new b({statusCode:D.error.statusCode,body:D.error.body,rawResponse:D.rawResponse})}return C(D.error,D.rawResponse,"GET","/plans")}createPlan(o,i){return R.fromPromise(this.__createPlan(o,i))}async __createPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Gt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Bw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plans")}getPlan(o,i={},t){return R.fromPromise(this.__getPlan(o,i,t))}async __getPlan(o,i={},t){let{planVersionId:s}=i,r={plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:qw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/plans/{plan_id}")}updatePlan(o,i,t){return R.fromPromise(this.__updatePlan(o,i,t))}async __updatePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Wt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Zw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plans/{plan_id}")}deletePlan(o,i){return R.fromPromise(this.__deletePlan(o,i))}async __deletePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:jw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/plans/{plan_id}")}upsertBillingProductPlan(o,i,t){return R.fromPromise(this.__upsertBillingProductPlan(o,i,t))}async __upsertBillingProductPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}/billing_products`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ai.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Xw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plans/{plan_id}/billing_products")}upsertPlanForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanForBillingProduct(o,i))}async __upsertPlanForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:gs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Qw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plans/billing-linked")}listBillingProductMatchCompanies(o,i){return R.fromPromise(this.__listBillingProductMatchCompanies(o,i))}async __listBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,d={plan_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Iw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies")}countBillingProductMatchCompanies(o,i){return R.fromPromise(this.__countBillingProductMatchCompanies(o,i))}async __countBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,d={plan_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:vw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies/count")}countPlans(o={},i){return R.fromPromise(this.__countPlans(o,i))}async __countPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:d,forTrialExpiryPlan:y,hasProductId:g,ids:l,includeDraftVersions:h,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:B,withoutPaidProductId:j,limit:K,offset:A}=o,Z={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:d,for_trial_expiry_plan:y,has_product_id:g,ids:l,include_draft_versions:h,plan_type:w!=null?ie.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:B,without_paid_product_id:j,limit:K,offset:A},ne=await this._options.authProvider.getAuthRequest(),Se=f(ne.headers,this._options?.headers,i?.headers),D=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/count"),method:"GET",headers:Se,queryString:u.queryBuilder().addMany(Z).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(D.ok)return{data:Ow.parseOrThrow(D.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:D.rawResponse};if(D.error.reason==="status-code")switch(D.error.statusCode){case 400:throw new v(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 401:throw new P(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 403:throw new _(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 404:throw new x(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);case 500:throw new S(n.parseOrThrow(D.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),D.rawResponse);default:throw new b({statusCode:D.error.statusCode,body:D.error.body,rawResponse:D.rawResponse})}return C(D.error,D.rawResponse,"GET","/plans/count")}listPlanIssues(o,i){return R.fromPromise(this.__listPlanIssues(o,i))}async __listPlanIssues(o,i){let{planId:t,planVersionId:s}=o,r={plan_id:t,plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/issues"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Gw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/plans/issues")}deletePlanVersion(o,i={},t){return R.fromPromise(this.__deletePlanVersion(o,i,t))}async __deletePlanVersion(o,i={},t){let{promoteArchivedVersion:s}=i,r={promote_archived_version:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Vw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"DELETE","/plans/version/{plan_id}")}publishPlanVersion(o,i,t){return R.fromPromise(this.__publishPlanVersion(o,i,t))}async __publishPlanVersion(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${u.encodePathParam(o)}/publish`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ws.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:$w.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plans/version/{plan_id}/publish")}};var va=class{constructor(o){this._options=L(o)}listScheduledCheckouts(o={},i){return R.fromPromise(this.__listScheduledCheckouts(o,i))}async __listScheduledCheckouts(o={},i){let{companyId:t,status:s,limit:r,offset:a}=o,d={company_id:t,status:s!=null?si.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ob.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/scheduled-checkout")}createScheduledCheckout(o,i){return R.fromPromise(this.__createScheduledCheckout(o,i))}async __createScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:eb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/scheduled-checkout")}getScheduledCheckout(o,i){return R.fromPromise(this.__getScheduledCheckout(o,i))}async __getScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:rb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/scheduled-checkout/{scheduled_checkout_id}")}updateScheduledCheckout(o,i={},t){return R.fromPromise(this.__updateScheduledCheckout(o,i,t))}async __updateScheduledCheckout(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:fs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:tb.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/scheduled-checkout/{scheduled_checkout_id}")}};var Ta=class{constructor(o){this._options=L(o)}listWebhookEvents(o={},i){return R.fromPromise(this.__listWebhookEvents(o,i))}async __listWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:d}=o,y={ids:t,q:s,webhook_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:gb.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/webhook-events")}getWebhookEvent(o,i){return R.fromPromise(this.__getWebhookEvent(o,i))}async __getWebhookEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhook-events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:db.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/webhook-events/{webhook_event_id}")}countWebhookEvents(o={},i){return R.fromPromise(this.__countWebhookEvents(o,i))}async __countWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:d}=o,y={ids:t,q:s,webhook_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:nb.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/webhook-events/count")}listWebhooks(o={},i){return R.fromPromise(this.__listWebhooks(o,i))}async __listWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:wb.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/webhooks")}createWebhook(o,i){return R.fromPromise(this.__createWebhook(o,i))}async __createWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:_s.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:lb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/webhooks")}getWebhook(o,i){return R.fromPromise(this.__getWebhook(o,i))}async __getWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/webhooks/{webhook_id}")}updateWebhook(o,i={},t){return R.fromPromise(this.__updateWebhook(o,i,t))}async __updateWebhook(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Rb.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/webhooks/{webhook_id}")}deleteWebhook(o,i){return R.fromPromise(this.__deleteWebhook(o,i))}async __deleteWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pb.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/webhooks/{webhook_id}")}sendTestWebhookAction(o,i,t){return R.fromPromise(this.__sendTestWebhookAction(o,i,t))}async __sendTestWebhookAction(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}/test`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Ss.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:zb.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/webhooks/{webhook_id}/test")}countWebhooks(o={},i){return R.fromPromise(this.__countWebhooks(o,i))}async __countWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:cb.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/webhooks/count")}};var Oa=class{constructor(o){this._options=L(o)}get accounts(){return this._accounts??=new pa(this._options)}get billing(){return this._billing??=new ua(this._options)}get credits(){return this._credits??=new wa(this._options)}get catalogs(){return this._catalogs??=new da(this._options)}get checkout(){return this._checkout??=new ma(this._options)}get companies(){return this._companies??=new ha(this._options)}get entitlements(){return this._entitlements??=new za(this._options)}get plans(){return this._plans??=new Ua(this._options)}get components(){return this._components??=new ga(this._options)}get planbundle(){return this._planbundle??=new Pa(this._options)}get dataexports(){return this._dataexports??=new ba(this._options)}get events(){return this._events??=new Ra(this._options)}get features(){return this._features??=new fa(this._options)}get insights(){return this._insights??=new _a(this._options)}get integrationsapi(){return this._integrationsapi??=new Sa(this._options)}get licenses(){return this._licenses??=new xa(this._options)}get plangroups(){return this._plangroups??=new Ea(this._options)}get planmigrations(){return this._planmigrations??=new Ca(this._options)}get componentspublic(){return this._componentspublic??=new ya(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new va(this._options)}get accesstokens(){return this._accesstokens??=new la(this._options)}get webhooks(){return this._webhooks??=new Ta(this._options)}getCreditLedger(o){return R.fromPromise(this.__getCreditLedger(o))}async __getCreditLedger(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/ledger"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:void 0,rawResponse:s.rawResponse};if(s.error.reason==="status-code")throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse});return C(s.error,s.rawResponse,"GET","/billing/credits/ledger")}async fetch(o,i,t){return Ja(o,i,{baseUrl:this._options.baseUrl??this._options.environment,headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:async()=>(await this._options.authProvider.getAuthRequest()).headers},t)}};var ir={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Bs={[ir.Debug]:1,[ir.Info]:2,[ir.Warn]:3,[ir.Error]:4},Vb=ir.Warn,li=class{constructor(o=Vb){this.level=Bs[o]??Bs[Vb]}shouldLog(o){return Bs[o]>=this.level}error(o,...i){this.shouldLog(ir.Error)&&console.error(o,...i)}warn(o,...i){this.shouldLog(ir.Warn)&&console.warn(o,...i)}info(o,...i){this.shouldLog(ir.Info)&&console.info(o,...i)}debug(o,...i){this.shouldLog(ir.Debug)&&console.debug(o,...i)}};var vf=1e3,Tf=1e3,Of=3,kf=1e3,ka=class{constructor(o,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:t=new li,maxSize:s=Tf,interval:r=vf,offline:a=!1,maxRetries:d=Of,initialRetryDelay:y=kf}=i||{};this.captureClient=o,this.interval=r,this.logger=t,this.maxSize=s,this.offline=a,this.maxRetries=d,this.initialRetryDelay=y,this.startPeriodicFlush()}async flush(){if(!(this.events.length===0||this.flushing)){this.flushing=!0;try{let o=[...this.events];this.events=[];let i=0,t=!1,s=null;for(;i<=this.maxRetries&&!t;)try{i>0&&this.logger.info(`Retrying event batch submission (attempt ${i} of ${this.maxRetries})`),await this.captureClient.sendBatch(o),t=!0}catch(r){if(s=r,i++,i<=this.maxRetries){let a=this.initialRetryDelay*Math.pow(2,i-1),d=Math.random()*.1*a,y=a+d;this.logger.warn(`Event batch submission failed: ${r}. Retrying in ${(y/1e3).toFixed(2)} seconds...`),process.env.NODE_ENV!=="test"&&await new Promise(g=>setTimeout(g,y))}}t?i>0&&this.logger.info(`Event batch submission succeeded after ${i} retries`):this.logger.error(`Event batch submission failed after ${this.maxRetries} retries:`,s)}finally{this.flushing=!1}}}async push(o){if(!this.offline){if(this.stopped){this.logger.error("Event buffer is stopped, not accepting new events");return}this.events.length>=this.maxSize&&!this.flushing&&await this.flush(),this.events.push(o)}}async stop(){this.shutdown=!0,this.stopped=!0,this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),await this.flush()}startPeriodicFlush(){this.offline||this.intervalId||(this.intervalId=setInterval(async()=>{this.shutdown||await this.flush()},this.interval),this.intervalId.unref&&this.intervalId.unref())}};var Bf="https://c.schematichq.com",jf=1e4,Af=p=>p.replace(/\/+$/,"")+"/batch",Vf=(p,o)=>{let i={api_key:o,type:p.eventType};return p.body!==void 0&&(i.body=Ut.jsonOrThrow(p.body,{unrecognizedObjectKeys:"strip"})),p.idempotencyKey!==void 0&&(i.idempotency_key=p.idempotencyKey),p.sentAt!==void 0&&(i.sent_at=p.sentAt instanceof Date?p.sentAt.toISOString():p.sentAt),p.trustedClientClock!==void 0&&(i.trusted_client_clock=p.trustedClientClock),p.backfill!==void 0&&(i.backfill=p.backfill),i},Df=(p,o)=>({events:p.map(i=>Vf(i,o))}),qf=p=>{if(typeof p!="object"||p===null||!("reason"in p))return"unknown error";let o=p;switch(o.reason){case"status-code":{let i=typeof o.body=="string"?o.body:JSON.stringify(o.body??"");return`HTTP ${o.statusCode}: ${i}`}case"timeout":return"request timed out";case"non-json":return`non-JSON response (HTTP ${o.statusCode})`;case"body-is-null":return`empty response body (HTTP ${o.statusCode})`;default:return o.errorMessage??"unknown error"}},Ba=class{constructor(o){this.apiKey=o.apiKey,this.baseUrl=o.baseUrl&&o.baseUrl.trim()!==""?o.baseUrl:Bf,this.timeoutMs=o.timeoutMs??jf,this.fetcher=o.fetcher,this.headers=o.headers??{}}async sendBatch(o){if(o.length===0)return;let i=await this.fetcher({url:Af(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:Df(o,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${qf(i.error)}`)}};function Db(p){return async function(i){let t={};if(p&&Object.assign(t,p),i.body!==void 0&&i.contentType!=null&&(t["Content-Type"]=i.contentType),i.headers!=null)for(let[d,y]of Object.entries(i.headers))y!=null&&typeof y=="string"&&(t[d]=y);let s=i.queryString!=null&&i.queryString.length>0?`${i.url}?${i.queryString}`:Mo(i.url,i.queryParameters),r=await Io({body:i.body,type:i.requestType==="json"?"json":"other"}),a=await zi();try{let d=await Si(async()=>Ri(a,s,i.method,t,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),y=await bi(d,i.responseType),g=bo(d);return d.status>=200&&d.status<400?{ok:!0,body:y,headers:d.headers,rawResponse:g}:{ok:!1,error:{reason:"status-code",statusCode:d.status,body:y},rawResponse:g}}catch(d){return i.abortSignal!=null&&i.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:fi}:d instanceof Error&&d.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:fi}:d instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:d.message},rawResponse:_i}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(d)},rawResponse:_i}}}}async function Mf(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new tr,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var qb=Mf;var po=class{constructor(){this.wasmInstance=null;this.initialized=!1}async initialize(){if(!this.initialized)try{let o=await import("./wasm/rulesengine.js"),i=o.RulesEngineJS?o:o.default??o;this.wasmInstance=new i.RulesEngineJS,this.initialized=!0}catch(o){throw new Error(`Failed to initialize WASM rules engine: ${o}`)}}async checkFlag(o,i,t){return this.checkFlagWithOptions(o,i,t)}async checkFlagWithOptions(o,i,t,s){this.ensureInitialized();let r=(a,d)=>d===null?void 0:d;try{let a=JSON.stringify(o,r),d=i?JSON.stringify(i,r):void 0,y=t?JSON.stringify(t,r):void 0,g=s?JSON.stringify(If(s),r):void 0,l=this.wasmInstance.checkFlagWithOptions(a,d,y,g);return JSON.parse(l)}catch(a){throw new Error(`WASM flag check failed: ${a}`)}}getVersionKey(){return this.ensureInitialized(),this.wasmInstance.getVersionKey()}isInitialized(){return this.initialized}ensureInitialized(){if(!this.initialized||!this.wasmInstance)throw new Error("WASM rules engine not initialized. Call initialize() first.")}};function If(p){let o={};return p.creditCost&&Object.keys(p.creditCost).length>0&&(o.credit_cost=p.creditCost),p.usage!==void 0&&(o.usage=p.usage),p.eventUsage&&(o.event_usage={event_subtype:p.eventUsage.eventSubtype,quantity:p.eventUsage.quantity}),o}js();var Ff={unrecognizedObjectKeys:"passthrough"};function Mb(p,o){let i=p.parse(o,Ff);return i.ok?i.value:o}function Vs(p){return JSON.parse(JSON.stringify(p))}function Kf(p){return JSON.parse(JSON.stringify(p))}function Ib(p,o){let i=Vs(p),t,s=!1;for(let r of Object.keys(o))switch(r){case"id":i.id=o[r];break;case"account_id":i.accountId=o[r];break;case"environment_id":i.environmentId=o[r];break;case"base_plan_id":i.basePlanId=o[r]??null;break;case"billing_product_ids":i.billingProductIds=o[r];break;case"plan_ids":i.planIds=o[r];break;case"plan_version_ids":i.planVersionIds=o[r];break;case"entitlements":{let a=o[r]??[];i.entitlements=a.map(d=>Mb(aa,d));break}case"rules":i.rules=o[r];break;case"traits":i.traits=o[r];break;case"subscription":i.subscription=o[r];break;case"keys":{let a=i.keys??{},d=o[r];i.keys={...a,...d};break}case"credit_balances":{let a=i.creditBalances??{},d=o[r]??{};i.creditBalances={...a,...d},t=d;break}case"credit_lease_balance":{let a=i.creditBalances??{},d=o[r]??{},y={};for(let[g,l]of Object.entries(d))l&&typeof l.remaining=="number"&&(y[g]=l.remaining);i.creditBalances={...a,...y},t={...t??{},...y};break}case"metrics":{let a=i.metrics??[],d=(o[r]??[]).map(y=>Mb(na,y));i.metrics=Gf(a,d),s=!0;break}}return(t||s)&&!("entitlements"in o)&&Lf(i,t,s),i}function Lf(p,o,i){let t=p.entitlements??[];if(t.length===0)return;let s=new Map;if(i){let r=p.metrics??[];for(let a of r)a&&s.set(ja(As(a)),a.value??0)}for(let r of t){let a=r.creditId??r.credit_id;o&&a&&a in o&&(r.creditRemaining=o[a],delete r.credit_remaining);let d=r.eventName??r.event_name;if(s.size>0&&d){let y=(r.metricPeriod??r.metric_period)||"all_time",g=(r.monthReset??r.month_reset)||"first_of_month",l=s.get(ja({eventSubtype:d,period:y,monthReset:g}));l!==void 0&&(r.usage=l)}}}function Fb(p,o){let i=Kf(p);for(let t of Object.keys(o))switch(t){case"id":i.id=o[t];break;case"account_id":i.accountId=o[t];break;case"environment_id":i.environmentId=o[t];break;case"keys":{let s=i.keys??{},r=o[t];i.keys={...s,...r};break}case"traits":i.traits=o[t];break;case"rules":i.rules=o[t];break}return i}function ja(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function As(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function Gf(p,o){let i=[...p],t=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let a=ja(As(r));t.set(a,s)}}for(let s of o){if(!s)continue;let r=ja(As(s)),a=t.get(r);a!==void 0?i[a]=s:i.push(s)}return i}var zr="company",Rr="user",Xf="flags",qs=30*1e3,Qf=1440*60*1e3,e_=720*60*60*1e3,Uo=class extends uo{constructor(i){super();this.replicatorReady=!1;this.pendingCompanyRequests=new Map;this.pendingUserRequests=new Map;if(this.apiKey=i.apiKey,this.baseURL=i.baseURL??z.Default,this.logger=i.logger,this.cacheTTL=i.cacheTTL??Qf,this.companyCacheProvider=this.createCacheProvider(i,"company"),this.userCacheProvider=this.createCacheProvider(i,"user"),this.flagsCacheProvider=this.createCacheProvider(i,"flag"),this.companyKeyCacheProvider=this.createKeyCacheProvider(i),this.userKeyCacheProvider=this.createKeyCacheProvider(i),this.replicatorMode=i.replicatorMode??!1,this.replicatorHealthURL=i.replicatorHealthURL,this.replicatorHealthCheck=i.replicatorHealthCheck??30*1e3,this.replicatorMode&&!i.redisClient&&!i.companyCache&&!i.userCache&&!i.flagCache)throw new Error("Replicator mode requires a Redis client or custom cache providers for shared cache access");this.rulesEngine=new po}createCacheProvider(i,t){let s;switch(t){case"company":s=i.companyCache;break;case"user":s=i.userCache;break;case"flag":s=i.flagCache;break}if(s)return this.logger.debug(`Using custom cache provider for ${t} cache`),s;let r=this.calculateCacheTTL(t);return i.redisClient?(this.logger.debug(`Using Redis cache provider for ${t} cache (TTL: ${r}ms)`),new ui({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${t} cache (TTL: ${r}ms)`),new or({ttl:r}))}createKeyCacheProvider(i){let t=this.cacheTTL;return i.redisClient?new ui({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:t}):new or({ttl:t})}calculateCacheTTL(i){return i==="flag"?Math.max(e_,this.cacheTTL):this.cacheTTL}async start(){try{await this.rulesEngine.initialize(),this.logger.debug("Rules engine initialized successfully")}catch(t){this.logger.warn(`Failed to initialize rules engine: ${t}`)}if(this.replicatorMode){this.logger.info("Replicator mode enabled - skipping WebSocket connection"),this.replicatorHealthURL&&this.startReplicatorHealthCheck();return}this.logger.info("Starting DataStream client");let{DatastreamWSClient:i}=(Yb(),Hs(Jb));this.wsClient=new i({url:this.baseURL,apiKey:this.apiKey,logger:this.logger,messageHandler:this.handleMessage.bind(this),connectionReadyHandler:this.handleConnectionReady.bind(this)}),this.wsClient.on("connected",()=>{this.emit("connected")}),this.wsClient.on("disconnected",()=>{this.emit("disconnected"),this.clearPendingRequests()}),this.wsClient.on("ready",()=>{this.emit("ready")}),this.wsClient.on("not-ready",()=>{this.emit("not-ready")}),this.wsClient.on("error",t=>{this.emit("error",t)}),this.wsClient.start()}isConnected(){return this.replicatorMode?this.isReplicatorReady():this.wsClient?.isConnected()??!1}async getCompany(i){let t=await this.getCompanyFromCache(i);if(t)return this.logger.debug(`Company found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("Company not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForCompany(i),r=!1;for(let a of s)if(this.pendingCompanyRequests.has(a)){r=!0;break}return new Promise((a,d)=>{let y=setTimeout(()=>{this.cleanupPendingCompanyRequests(s,g),d(new Error("Timeout while waiting for company data"))},qs),g=l=>{clearTimeout(y),l?a(l):d(new Error("Company not found"))};for(let l of s)this.pendingCompanyRequests.has(l)||this.pendingCompanyRequests.set(l,[]),this.pendingCompanyRequests.get(l).push(g);r||this.sendDataStreamRequest({entity_type:"rulesengine.Company",keys:i}).catch(l=>{this.cleanupPendingCompanyRequests(s,g),d(l)})})}async getUser(i){let t=await this.getUserFromCache(i);if(t)return this.logger.debug(`User found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("User not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForUser(i),r=!1;for(let a of s)if(this.pendingUserRequests.has(a)){r=!0;break}return new Promise((a,d)=>{let y=setTimeout(()=>{this.cleanupPendingUserRequests(s,g),d(new Error("Timeout while waiting for user data"))},qs),g=l=>{clearTimeout(y),l?a(l):d(new Error("User not found"))};for(let l of s)this.pendingUserRequests.has(l)||this.pendingUserRequests.set(l,[]),this.pendingUserRequests.get(l).push(g);r||this.sendDataStreamRequest({entity_type:"rulesengine.User",keys:i}).catch(l=>{this.cleanupPendingUserRequests(s,g),d(l)})})}async getFlag(i){let t=this.flagCacheKey(i);this.logger.debug(`Retrieving flag from cache: ${i} (cache key: ${t})`);try{return await this.flagsCacheProvider.get(t)||null}catch(s){return this.logger.warn(`Failed to retrieve flag from cache: ${s}`),null}}async getAllFlags(){return this.pendingFlagRequest?new Promise((i,t)=>{let s=this.pendingFlagRequest;this.pendingFlagRequest=r=>{s(r),r?i():t(new Error("Failed to refresh flags"))}}):new Promise((i,t)=>{let s=setTimeout(()=>{this.pendingFlagRequest=void 0,t(new Error("Timeout while waiting for flags data"))},qs);this.pendingFlagRequest=r=>{clearTimeout(s),this.pendingFlagRequest=void 0,r?i():t(new Error("Failed to refresh flags"))},this.sendDataStreamRequest({entity_type:"rulesengine.Flags"}).catch(r=>{clearTimeout(s),this.pendingFlagRequest=void 0,t(r)})})}async checkFlag(i,t,s){let r=await this.getFlag(t);if(!r)throw new Error(`Flag not found: ${t}`);let a=i.company&&Object.keys(i.company).length>0,d=i.user&&Object.keys(i.user).length>0,y=null,g=null;if(a&&(y=await this.getCompanyFromCache(i.company),this.logger.debug(`Company ${y?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.company)}`)),d&&(g=await this.getUserFromCache(i.user),this.logger.debug(`User ${g?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.user)}`)),this.replicatorMode)return this.evaluateFlag(r,y,g,s);if((!a||y)&&(!d||g))return this.logger.debug(`All required resources found in cache for flag ${t} evaluation`),this.evaluateFlag(r,y,g,s);if(!this.isConnected())throw new Error("Datastream not connected and required entities not in cache");let l=a&&!y?this.getCompany(i.company):Promise.resolve(y),h=d&&!g?this.getUser(i.user):Promise.resolve(g),[w,U]=await Promise.all([l,h]);return this.evaluateFlag(r,w,U,s)}async getCachedCompany(i){return this.getCompanyFromCache(i)}async getCachedUser(i){return this.getUserFromCache(i)}getRulesEngine(){return this.rulesEngine}async updateCompanyMetrics(i,t,s){let r=await this.getCompanyFromCache(i);if(!r)return;let a=this.deepCopyCompany(r);if(a.metrics)for(let d of a.metrics)(d.eventSubtype??d.event_subtype)===t&&(d.value=(d.value||0)+s);await this.cacheCompanyForKeys(a)}close(){this.logger.info("Closing DataStream client"),this.replicatorHealthInterval&&(clearInterval(this.replicatorHealthInterval),this.replicatorHealthInterval=void 0),this.clearPendingRequests(),this.wsClient&&(this.wsClient.close(),this.wsClient=void 0),this.logger.info("DataStream client closed")}isReplicatorReady(){return this.replicatorReady}isReplicatorMode(){return this.replicatorMode}getReplicatorCacheVersion(){return this.replicatorCacheVersion}async getReplicatorCacheVersionAsync(i=2e3){if(this.replicatorCacheVersion)return this.replicatorCacheVersion;if(this.replicatorMode&&this.replicatorHealthURL)try{let t=new AbortController,s=setTimeout(()=>t.abort(),i),r=await fetch(this.replicatorHealthURL,{method:"GET",signal:t.signal});if(clearTimeout(s),r.ok){let a=await r.json(),d=a.cache_version||a.cacheVersion;if(d)return this.replicatorCacheVersion=d,d}}catch(t){this.logger.debug(`Failed to fetch replicator cache version: ${t}`)}}async handleMessage(i){this.logger.debug(`Processing datastream message: EntityType=${i.entity_type}, MessageType=${i.message_type}`);try{if(i.message_type==="error"){await this.handleErrorMessage(i);return}switch(i.entity_type){case"rulesengine.Company":case"rulesengine.Companies":await this.handleCompanyMessage(i);break;case"rulesengine.User":case"rulesengine.Users":await this.handleUserMessage(i);break;case"rulesengine.Flags":await this.handleFlagsMessage(i);break;case"rulesengine.Flag":await this.handleFlagMessage(i);break;default:this.logger.warn(`Unknown entity type in datastream message: ${i.entity_type}`)}}catch(t){this.logger.error(`Error processing datastream message: ${t}`),this.emit("error",t)}}async handleCompanyMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial company message missing entity_id");return}let r=this.resourceIdCacheKey(zr,s),a=await this.companyCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{t=Ib(a,i.data)}catch(d){this.logger.error(`Failed to merge partial company: ${d}`);return}}else try{t=jb.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize company payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(zr,r,a);try{await this.companyKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete company key mapping from cache: ${y}`)}}let s=this.resourceIdCacheKey(zr,t.id);try{await this.companyCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete company resource from cache: ${r}`)}return}await this.cacheCompanyForKeys(t),this.notifyPendingCompanyRequests(t.keys||{},t)}}async handleUserMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial user message missing entity_id");return}let r=this.resourceIdCacheKey(Rr,s),a=await this.userCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{t=Fb(a,i.data)}catch(d){this.logger.error(`Failed to merge partial user: ${d}`);return}}else try{t=Ab.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize user payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(Rr,r,a);try{await this.userKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete user key mapping from cache: ${y}`)}}let s=this.resourceIdCacheKey(Rr,t.id);try{await this.userCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete user resource from cache: ${r}`)}return}await this.cacheUserForKeys(t),this.notifyPendingUserRequests(t.keys||{},t)}}async handleFlagsMessage(i){let t=i.data;if(!Array.isArray(t)){this.logger.warn("Expected flags array in bulk flags message");return}let s=[],r=0,a;for(let l of t)try{s.push(vs.parseOrThrow(l,{unrecognizedObjectKeys:"passthrough"}))}catch(h){r++,a===void 0&&(a=h)}r>0&&this.logger.warn(`Failed to deserialize ${r} flag(s) in bulk message: ${String(a)}`);let d=await Promise.allSettled(s.filter(l=>l?.key).map(async l=>{let h=this.flagCacheKey(l.key);return await this.flagsCacheProvider.set(h,l),h})),y=d.filter(l=>l.status==="fulfilled").map(l=>l.value),g=d.filter(l=>l.status==="rejected");if(g.length>0&&this.logger.warn(`Failed to cache ${g.length} flag(s)`),this.flagsCacheProvider.deleteMissing)try{await this.flagsCacheProvider.deleteMissing(y,{scanPattern:"flags:*"})}catch(l){this.logger.warn(`Failed to delete missing flags: ${l}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleFlagMessage(i){let t;try{t=vs.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(r){this.logger.warn(`Failed to deserialize flag payload: ${r}`);return}if(!t?.key)return;let s=this.flagCacheKey(t.key);try{switch(i.message_type){case"delete":await this.flagsCacheProvider.delete(s);break;case"full":await this.flagsCacheProvider.set(s,t);break;default:this.logger.warn(`Unhandled message type for flag: ${i.message_type}`);break}}catch(r){this.logger.warn(`Failed to update flag cache: ${r}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleErrorMessage(i){let t=i.data;if(t?.keys&&t?.entity_type)switch(t.entity_type){case"rulesengine.Company":this.notifyPendingCompanyRequests(t.keys,null);break;case"rulesengine.User":this.notifyPendingUserRequests(t.keys,null);break;default:this.logger.warn(`Received error for unsupported entity type: ${t.entity_type}`)}let s=t?.error||"Unknown datastream error";this.logger.warn(`DataStream error received: ${s}`)}async handleConnectionReady(){this.logger.info("DataStream connection is ready");try{await this.getAllFlags(),this.logger.debug("Requested initial flag data")}catch(i){throw this.logger.error(`Failed to request initial flag data: ${i}`),i}}async sendDataStreamRequest(i){if(!this.wsClient||!this.wsClient.isConnected())throw new Error("DataStream client is not connected");this.logger.debug(`Sending datastream request: EntityType=${i.entity_type}, Keys=${JSON.stringify(i.keys)}`);let t={data:i};await this.wsClient.sendMessage(t)}async getCompanyFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(zr,t,s);try{let a=await this.companyKeyCacheProvider.get(r);if(a){let d=this.resourceIdCacheKey(zr,a),y=await this.companyCacheProvider.get(d);if(y)return y}}catch(a){this.logger.warn(`Failed to retrieve company from cache: ${a}`)}}return null}async getUserFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(Rr,t,s);try{let a=await this.userKeyCacheProvider.get(r);if(a){let d=this.resourceIdCacheKey(Rr,a),y=await this.userCacheProvider.get(d);if(y)return y}}catch(a){this.logger.warn(`Failed to retrieve user from cache: ${a}`)}}return null}async cacheCompanyForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for company lookup");let t=this.resourceIdCacheKey(zr,i.id),s=await this.companyCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let d=this.resourceKeyToCacheKey(zr,r,a);try{await this.companyKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete stale company key mapping '${d}': ${y}`)}}}await this.companyCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(zr,r,a);try{await this.companyKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(y){this.logger.warn(`Failed to cache company key mapping '${d}': ${y}`)}}}async cacheUserForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for user lookup");let t=this.resourceIdCacheKey(Rr,i.id),s=await this.userCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let d=this.resourceKeyToCacheKey(Rr,r,a);try{await this.userKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete stale user key mapping '${d}': ${y}`)}}}await this.userCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(Rr,r,a);try{await this.userKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(y){this.logger.warn(`Failed to cache user key mapping '${d}': ${y}`)}}}generateCacheKeysForCompany(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(zr,t,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(Rr,t,s))}notifyPendingCompanyRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(zr,s,r),d=this.pendingCompanyRequests.get(a);d&&(this.pendingCompanyRequests.delete(a),d.forEach(y=>{try{y(t)}catch(g){this.logger.error(`Error in company request handler: ${g}`)}}))}}notifyPendingUserRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(Rr,s,r),d=this.pendingUserRequests.get(a);d&&(this.pendingUserRequests.delete(a),d.forEach(y=>{try{y(t)}catch(g){this.logger.error(`Error in user request handler: ${g}`)}}))}}cleanupPendingCompanyRequests(i,t){for(let s of i){let r=this.pendingCompanyRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingCompanyRequests.delete(s)}}}cleanupPendingUserRequests(i,t){for(let s of i){let r=this.pendingUserRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingUserRequests.delete(s)}}}clearPendingRequests(){for(let[,i]of this.pendingCompanyRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing company request: ${s}`)}});this.pendingCompanyRequests.clear();for(let[,i]of this.pendingUserRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing user request: ${s}`)}});if(this.pendingUserRequests.clear(),this.pendingFlagRequest){try{this.pendingFlagRequest(!1)}catch(i){this.logger.error(`Error clearing flag request: ${i}`)}this.pendingFlagRequest=void 0}}startReplicatorHealthCheck(){this.replicatorHealthURL&&(this.logger.info(`Starting replicator health check with URL: ${this.replicatorHealthURL}, interval: ${this.replicatorHealthCheck}ms`),this.checkReplicatorHealth(),this.replicatorHealthInterval=setInterval(()=>{this.checkReplicatorHealth()},this.replicatorHealthCheck),this.replicatorHealthInterval.unref())}async checkReplicatorHealth(){if(this.replicatorHealthURL)try{let i=new AbortController,t=setTimeout(()=>i.abort(),5e3),s=await fetch(this.replicatorHealthURL,{method:"GET",signal:i.signal});if(clearTimeout(t),!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let r=await s.json(),a=this.replicatorReady;this.replicatorReady=r.ready??!1;let d=r.cache_version||r.cacheVersion;if(d&&d!==this.replicatorCacheVersion){let y=this.replicatorCacheVersion;this.replicatorCacheVersion=d,this.logger.info(`Cache version changed from ${y||"(null)"} to ${d}`)}this.replicatorReady&&!a?(this.logger.info("External replicator is now ready"),this.emit("replicator-health-changed",!0)):!this.replicatorReady&&a&&(this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1))}catch(i){this.replicatorReady&&(this.replicatorReady=!1,this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1)),this.logger.debug(`Replicator health check failed: ${i}`)}}flagCacheKey(i){let t=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey(),s=`${Xf}:${t}:${i.toLowerCase()}`;return this.logger.debug(`Generated flag cache key - flag: ${i}, mode: ${this.replicatorMode?"replicator":"datastream"}, version: ${t}, cacheKey: ${s}`),s}resourceIdCacheKey(i,t){let s=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${s}:${t}`}resourceKeyToCacheKey(i,t,s){let r=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${r}:${t.toLowerCase()}:${s.toLowerCase()}`}deepCopyCompany(i){return Vs(i)}async evaluateFlag(i,t,s,r){let a=i.defaultValue??!1;try{if(this.rulesEngine.isInitialized()){this.logger.debug(`Evaluating flag with rules engine: ${JSON.stringify({flagId:i.id,flagRules:i.rules?.length||0,companyId:t?.id,userId:s?.id})}`);let d=await this.rulesEngine.checkFlagWithOptions(i,t,s,r);return this.logger.debug(`Rules engine evaluation result: ${JSON.stringify(d)}`),{flagKey:i.key,value:d.value??a,reason:d.reason||"RULES_ENGINE_EVALUATION",companyId:t?.id,userId:s?.id,flagId:i.id,ruleId:d.ruleId,ruleType:d.ruleType,entitlement:d.entitlement?{...d.entitlement,metricResetAt:d.entitlement.metricResetAt?new Date(d.entitlement.metricResetAt):void 0}:void 0}}else return this.logger.warn("Rules engine not initialized, using default flag value"),{flagKey:i.key,value:a,reason:"RULES_ENGINE_UNAVAILABLE",companyId:t?.id,userId:s?.id,flagId:i.id}}catch(d){return this.logger.error(`Rules engine evaluation failed: ${d}`),{flagKey:i.key,value:a,reason:"RULES_ENGINE_ERROR",companyId:t?.id,userId:s?.id,flagId:i.id}}}getRulesEngineVersionKey(){try{if(this.rulesEngine.isInitialized())return this.rulesEngine.getVersionKey()}catch(i){this.logger.warn(`Failed to get rules engine version key: ${i}`)}return"1"}};function Xe(p,o){return`${p}:${o}`}var vo=class{constructor(){this.leases=new Map;this.locks=new Map}get(o,i){let t=this.leases.get(Xe(o,i));return t?{...t}:void 0}async replace(o){let i=Xe(o.companyId,o.creditTypeId);return this.withLock(i,()=>{let t=this.leases.get(i);return t&&t.expiresAt.getTime()>Date.now()?!1:(this.leases.set(i,{...o,localRemainingCredits:o.grantedAmount}),!0)})}async extend(o,i,t,s,r){let a=Xe(o,i);return this.withLock(a,()=>{let d=this.leases.get(a);if(!d||r!==void 0&&d.leaseId!==r)return;let y=t-d.grantedAmount;y>0&&(d.grantedAmount=t,d.localRemainingCredits+=y),s&&s.getTime()>d.expiresAt.getTime()&&(d.expiresAt=s)})}async drop(o,i){let t=Xe(o,i);return this.withLock(t,()=>{this.leases.delete(t)})}async tryReserve(o,i,t){if(!Number.isFinite(t)||t<0)return null;let s=Xe(o,i);return this.withLock(s,()=>{let r=this.leases.get(s);return!r||r.expiresAt.getTime()<=Date.now()||r.localRemainingCredits<t?null:(r.localRemainingCredits-=t,r.localRemainingCredits)})}async refund(o,i,t,s){if(t<=0)return;let r=Xe(o,i);return this.withLock(r,()=>{let a=this.leases.get(r);a&&(s!==void 0&&a.leaseId!==s||(a.localRemainingCredits=Math.min(a.localRemainingCredits+t,a.grantedAmount)))})}list(){return Array.from(this.leases.values(),o=>({...o}))}async withLock(o,i){let t=this.locks.get(o)??Promise.resolve(),s,r=new Promise(d=>s=d),a=t.then(()=>r);this.locks.set(o,a),await t;try{return await i()}finally{s(),this.locks.get(o)===a&&this.locks.delete(o)}}};var To=class{constructor(o,i=1e3){this.leaseStore=o;this.sweepIntervalMs=i;this.reservations=new Map;this.sweepInterval=null;this.stopped=!1}add(o){this.reservations.set(o.id,o)}get(o){return this.reservations.get(o)}reservedCredits(o,i){let t=0;for(let s of this.reservations.values())s.companyId===o&&s.creditTypeId===i&&(t+=s.creditsReserved);return t}async consume(o,i){let t=this.reservations.get(o);if(!t)return null;this.reservations.delete(o);let s=Math.max(0,Math.min(i,t.creditsReserved)),r=t.creditsReserved-s;return r>0&&await this.leaseStore.refund(t.companyId,t.creditTypeId,r,t.leaseId),s}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=0;for(let[t,s]of this.reservations)s.expiresAt.getTime()<=o.getTime()&&(this.reservations.delete(t),await this.leaseStore.refund(s.companyId,s.creditTypeId,s.creditsReserved,s.leaseId),i++);return i}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}size(){return this.reservations.size}};var Oo=class{constructor(o){this.inflightAcquire=new Map;this.inflightExtend=new Map;this.creditsClient=o.creditsClient,this.leaseStore=o.leaseStore,this.logger=o.logger,this.config=o.config}resolveConfig(o){let i=this.config.overrides?.[o];return{leaseDuration:i?.defaultLeaseDuration??this.config.defaultLeaseDuration??3e5,reservationTTL:i?.defaultReservationTTL??this.config.defaultReservationTTL??6e4,leaseSize:i?.defaultLeaseSize??this.config.defaultLeaseSize??1e4,lowWaterMark:i?.lowWaterMark??this.config.lowWaterMark??.25}}async acquireIfNeeded(o,i,t){let s;try{s=await this.leaseStore.get(o,i)}catch(y){this.logger.error(`Failed to read lease store for ${o}/${i}: ${y}`);return}if(s&&s.expiresAt.getTime()>Date.now())return s;let r=Xe(o,i),a=this.inflightAcquire.get(r);if(a)return a;let d=this.acquire(o,i,t).finally(()=>{this.inflightAcquire.delete(r)});return this.inflightAcquire.set(r,d),d}async acquire(o,i,t){let s=this.resolveConfig(i),r={companyId:o,creditTypeId:i,requestedAmount:s.leaseSize,expiresAt:new Date(Date.now()+s.leaseDuration)};try{let d=(await this.creditsClient.acquireCreditLease(r,t)).data;if(await this.leaseStore.replace({leaseId:d.id,companyId:d.companyId,creditTypeId:d.creditTypeId,grantedAmount:d.grantedAmount,expiresAt:d.expiresAt}))this.logger.debug(`Acquired credit lease ${d.id} for ${o}/${i} (granted=${d.grantedAmount}, expires=${d.expiresAt.toISOString()})`);else{let g=await this.leaseStore.get(o,i);return g&&g.leaseId!==d.id?(this.logger.debug(`Lost acquire race for ${o}/${i}; releasing redundant lease ${d.id}`),this.creditsClient.releaseCreditLease(d.id,{}).catch(l=>this.logger.warn(`Failed to release redundant credit lease ${d.id}: ${l}`))):this.logger.debug(`Lost acquire race for ${o}/${i}; server returned the installed lease ${d.id}, nothing to release`),g}return await this.leaseStore.get(o,i)}catch(a){this.logger.error(`Failed to acquire credit lease for ${o}/${i}: ${a}`);return}}async maybeExtendInBackground(o,i,t,s){let r;try{r=await this.leaseStore.get(o,i)}catch(U){this.logger.warn(`Failed to read lease store for ${o}/${i}: ${U}`);return}if(!r||r.expiresAt.getTime()<=Date.now())return;let a=this.resolveConfig(i),y=r.localRemainingCredits/Math.max(r.grantedAmount,1)<=a.lowWaterMark,g=t!==void 0&&r.localRemainingCredits<t;if(!y&&!g)return r;let l=Xe(o,i),h=this.inflightExtend.get(l);if(h)return h;let w=this.extend(r,a,t,s).finally(()=>{this.inflightExtend.delete(l)});return this.inflightExtend.set(l,w),w}async extend(o,i,t,s){let r=t!==void 0?t-o.localRemainingCredits:0,a={additionalAmount:Math.max(i.leaseSize,r),expiresAt:new Date(Date.now()+i.leaseDuration)};try{let y=(await this.creditsClient.extendCreditLease(o.leaseId,a,s)).data;return await this.leaseStore.extend(o.companyId,o.creditTypeId,y.grantedAmount,y.expiresAt,o.leaseId),this.logger.debug(`Extended credit lease ${o.leaseId} to ${y.grantedAmount} (was ${o.grantedAmount} at last read, expires ${y.expiresAt.toISOString()})`),await this.leaseStore.get(o.companyId,o.creditTypeId)}catch(d){this.logger.warn(`Failed to extend credit lease ${o.leaseId}: ${d}`);return}}async releaseAllLocalLeases(){let o=this.leaseStore.list?.();!o||o.length===0||await Promise.all(o.map(async i=>{if(!(i.expiresAt.getTime()<=Date.now()))try{await this.creditsClient.releaseCreditLease(i.leaseId,{}),await this.leaseStore.drop(i.companyId,i.creditTypeId),this.logger.debug(`Released credit lease ${i.leaseId} on close`)}catch(t){this.logger.warn(`Failed to release credit lease ${i.leaseId} on close (it will expire server-side): ${t}`)}}))}};var i_="schematic:",o_="credit-lease:",Zb=6e4,Xb=`
|
|
4
4
|
redis.replicate_commands()
|
|
5
5
|
local t = redis.call('TIME')
|
|
6
6
|
local now = (tonumber(t[1]) * 1000) + math.floor(tonumber(t[2]) / 1000)
|
|
7
|
-
`,
|
|
7
|
+
`,t_=Xb+`
|
|
8
8
|
local existing_id = redis.call('HGET', KEYS[1], 'leaseId')
|
|
9
9
|
local existing_expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
|
|
10
10
|
local new_id = ARGV[1]
|
|
@@ -26,7 +26,7 @@ redis.call('HSET', KEYS[1],
|
|
|
26
26
|
'expiresAt', ARGV[3])
|
|
27
27
|
redis.call('PEXPIREAT', KEYS[1], new_expiry + grace)
|
|
28
28
|
return 1
|
|
29
|
-
|
|
29
|
+
`,a_=Xb+`
|
|
30
30
|
local raw = redis.call('HGET', KEYS[1], 'localRemainingCredits')
|
|
31
31
|
if not raw then return false end
|
|
32
32
|
local expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
|
|
@@ -37,7 +37,7 @@ if remaining < requested then return false end
|
|
|
37
37
|
local new_remaining = remaining - requested
|
|
38
38
|
redis.call('HSET', KEYS[1], 'localRemainingCredits', tostring(new_remaining))
|
|
39
39
|
return tostring(new_remaining)
|
|
40
|
-
`,
|
|
40
|
+
`,n_=`
|
|
41
41
|
local raw_remaining = redis.call('HGET', KEYS[1], 'localRemainingCredits')
|
|
42
42
|
if not raw_remaining then return 0 end
|
|
43
43
|
local required_lease = ARGV[2]
|
|
@@ -52,7 +52,7 @@ local new_balance = remaining + refund
|
|
|
52
52
|
if new_balance > granted then new_balance = granted end
|
|
53
53
|
redis.call('HSET', KEYS[1], 'localRemainingCredits', tostring(new_balance))
|
|
54
54
|
return 1
|
|
55
|
-
`,
|
|
55
|
+
`,s_=`
|
|
56
56
|
local raw_granted = redis.call('HGET', KEYS[1], 'grantedAmount')
|
|
57
57
|
if not raw_granted then return 0 end
|
|
58
58
|
local required_lease = ARGV[4]
|
|
@@ -77,9 +77,9 @@ if new_expiry > current_expiry then
|
|
|
77
77
|
redis.call('PEXPIREAT', KEYS[1], new_expiry + grace)
|
|
78
78
|
end
|
|
79
79
|
return 1
|
|
80
|
-
`,ko=class{constructor(o){this.client=o.client,this.keyPrefix=o.keyPrefix??
|
|
80
|
+
`,ko=class{constructor(o){this.client=o.client,this.keyPrefix=o.keyPrefix??i_,this.defaultLeaseDurationMs=o.defaultLeaseDurationMs??3e5}hashKey(o,i){return`${this.keyPrefix}${o_}${Xe(o,i)}`}async get(o,i){let t=await this.client.hGetAll(this.hashKey(o,i));if(!(!t||!t.leaseId))return c_(t)}async replace(o){let i=await this.client.eval(t_,{keys:[this.hashKey(o.companyId,o.creditTypeId)],arguments:[o.leaseId,String(o.grantedAmount),String(o.expiresAt.getTime()),String(Zb),o.companyId,o.creditTypeId]});return Number(i)===1}async extend(o,i,t,s,r){let a=(s??new Date(Date.now()+this.defaultLeaseDurationMs)).getTime();await this.client.eval(s_,{keys:[this.hashKey(o,i)],arguments:[String(t),String(a),String(Zb),r??""]})}async drop(o,i){await this.client.del(this.hashKey(o,i))}async tryReserve(o,i,t){if(!Number.isFinite(t)||t<0)return null;let s=await this.client.eval(a_,{keys:[this.hashKey(o,i)],arguments:[String(t)]});return s==null?null:Number(s)}async refund(o,i,t,s){t<=0||await this.client.eval(n_,{keys:[this.hashKey(o,i)],arguments:[String(t),s??""]})}};function c_(p){return{leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,grantedAmount:Number(p.grantedAmount??"0"),localRemainingCredits:Number(p.localRemainingCredits??"0"),expiresAt:new Date(Number(p.expiresAt??"0"))}}var l_="schematic:",p_="credit-reservation:",u_="credit-reservations:byExpiry",d_="credit-reservations:byCredit:";var m_=`
|
|
81
81
|
local raw = redis.call('HGETALL', KEYS[1])
|
|
82
82
|
if #raw == 0 then return nil end
|
|
83
83
|
redis.call('DEL', KEYS[1])
|
|
84
84
|
return raw
|
|
85
|
-
`;function Wb(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function o_(p){let o=p.split("|");if(o.length===3)return{companyId:o[0],creditTypeId:o[1],id:o[2]}}var Hb=256,t_=16,Bo=class{constructor(o){this.sweepInterval=null;this.stopped=!1;this.client=o.client,this.leaseStore=o.leaseStore,this.sweepIntervalMs=o.sweepIntervalMs??1e3,this.keyPrefix=o.keyPrefix??Xf}hashKey(o){return`${this.keyPrefix}${Qf}${o}`}indexKey(){return`${this.keyPrefix}${e_}`}byCreditKey(o,i){return`${this.keyPrefix}${r_}${o}:${i}`}async add(o){let i=o.expiresAt.getTime(),t=this.hashKey(o.id);await this.client.hSet(t,{id:o.id,leaseId:o.leaseId,companyId:o.companyId,creditTypeId:o.creditTypeId,eventSubtype:o.eventSubtype,quantityReserved:String(o.quantityReserved),creditsReserved:String(o.creditsReserved),consumptionRate:String(o.consumptionRate),expiresAt:String(i),evalCtx:JSON.stringify(o.evalCtx)}),await Promise.all([this.client.pExpireAt(t,i+3e4),this.client.zAdd(this.indexKey(),{score:i,value:Wb(o)}),this.client.hSet(this.byCreditKey(o.companyId,o.creditTypeId),o.id,String(o.creditsReserved))])}async get(o){let i=await this.client.hGetAll(this.hashKey(o));if(!(!i||!i.id))return n_(i)}async reservedCredits(o,i){let t=await this.client.hGetAll(this.byCreditKey(o,i)).catch(()=>({})),s=0;for(let r of Object.values(t))s+=Number(r)||0;return s}async consume(o,i){let t=await this.client.eval(i_,{keys:[this.hashKey(o)],arguments:[]}),s=a_(t);if(!s||!s.id)return null;let r=s.companyId,a=s.creditTypeId,d=Number(s.creditsReserved)||0;await this.client.zRem(this.indexKey(),Wb({companyId:r,creditTypeId:a,id:o})).catch(()=>{}),await this.client.hDel(this.byCreditKey(r,a),o).catch(()=>{});let y=i;y<0&&(y=0),y>d&&(y=d);let g=d-y;return g>0&&await this.leaseStore.refund(r,a,g,s.leaseId),y}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=o.getTime(),t=0;for(let s=0;s<t_;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:Hb}});if(r.length===0)break;for(let a of r){let d=o_(a);if(!d){await this.client.zRem(this.indexKey(),a).catch(()=>{});continue}let y=await this.consume(d.id,0);if(await this.client.zRem(this.indexKey(),a).catch(()=>{}),y!==null){t++;continue}await this.client.hDel(this.byCreditKey(d.companyId,d.creditTypeId),d.id).catch(()=>{})}if(r.length<Hb)break}return t}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}async size(){return this.client.zCard(this.indexKey()).catch(()=>0)}};function a_(p){if(!Array.isArray(p)||p.length===0)return;let o={};for(let i=0;i+1<p.length;i+=2)o[String(p[i])]=String(p[i+1]);return o}function n_(p){return{id:p.id,leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:Number(p.quantityReserved),creditsReserved:Number(p.creditsReserved),consumptionRate:Number(p.consumptionRate),expiresAt:new Date(Number(p.expiresAt)),evalCtx:p.evalCtx?JSON.parse(p.evalCtx):{}}}var $b=require("crypto");function jo(p,o,i,t){return p.enqueueFlagCheckEvent({flagKey:i.flagKey,value:i.value,reason:i.reason,error:i.err,flagId:i.flagId,companyId:t?.companyId,userId:t?.userId,ruleId:t?.ruleId,reqCompany:o.company,reqUser:o.user}),i}async function Jb(p,o,i,t,s){let{datastream:r,leaseStore:a,reservations:d,manager:y,logger:g}=p,l=t.onAcquireFailure??"fail-closed";if(t.usage===void 0||!Number.isFinite(t.usage)||t.usage<0)return g.error(`Lease check: invalid usage ${t.usage} for flag ${o} \u2014 must be a finite, non-negative number`),jo(p,i,Aa(l,o,"invalid_usage",null));if(t.usage===0)return g.debug(`Lease check: usage is 0 for flag ${o} \u2014 nothing to reserve, using plain check`),s();if(!r)return g.debug("Credit-lease check requested without datastream \u2014 falling back to plain check"),s();let h=null;try{h=await r.getFlag(o)}catch(xe){g.warn(`Lease check: failed to load flag ${o}: ${xe}`)}if(!h)return g.debug(`Lease check: no cached flag for ${o}, falling back`),s();let{eventSubtype:w,quantity:U}=c_(t);if(!i.company)return g.debug("Lease check: no company on evalCtx, falling back"),s();let T=null;try{T=await r.getCompany(i.company)}catch(xe){g.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${xe}), falling back`)}if(!T)return s();let O=null;if(i.user){try{O=await r.getUser(i.user)}catch(xe){g.debug(`Lease check: user fetch failed for keys ${JSON.stringify(i.user)} (${xe}), falling back`)}if(!O)return s()}let B;try{B=await r.getRulesEngine().checkFlagWithOptions(h,T,O??null,null)}catch(xe){return g.warn(`Lease check: entitlement probe failed for flag ${o} (${xe}), falling back`),s()}let j=B.entitlement;if(!j||j.valueType!==Ia.Credit)return g.debug(`Lease check: flag ${o} matched a non-credit entitlement (valueType=${j?.valueType??"<none>"}), falling back to plain check \u2014 no reservation`),s();let F=j.creditId,A=j.consumptionRate??0,Z=w??j.eventSubtype;if(!F||A<=0||!Z)return g.debug(`Lease check: flag ${o} credit entitlement is incomplete (creditId=${F??"<none>"}, consumptionRate=${A}, subtype=${Z??"<none>"}), falling back`),s();let ne=U*A,Se=t.timeoutMs!==void 0?{timeoutInSeconds:t.timeoutMs/1e3}:void 0,D=xe=>u_({datastream:r,logger:g,mode:l,key:o,reason:xe,flag:h,company:T,user:O,creditId:F,options:t}).then(Ao=>jo(p,i,Ao,{companyId:T.id,userId:O?.id})),q=await y.acquireIfNeeded(T.id,F,Se);if(!q)return D("lease_acquire_failed");let Sr;try{Sr=await a.tryReserve(T.id,F,ne),Sr===null&&(await y.maybeExtendInBackground(T.id,F,ne,Se),Sr=await a.tryReserve(T.id,F,ne))}catch(xe){return g.error(`Lease check: reserve against ${T.id}/${F} failed: ${xe}`),D("lease_store_error")}if(Sr===null)return D("insufficient_lease_balance");let M=l_({leaseId:q.leaseId,companyId:T.id,creditTypeId:F,eventSubtype:Z,quantityReserved:U,creditsReserved:ne,consumptionRate:A,reservationTTL:s_(p,F),evalCtx:i});try{await d.add(M)}catch(xe){g.error(`Lease check: failed to persist reservation ${M.id}: ${xe}`);try{await d.consume(M.id,0)===null&&await a.refund(T.id,F,ne,q.leaseId)}catch(Ao){g.warn(`Lease check: could not undo local debit for ${M.id} (${Ao}); the slice is reclaimed at lease expiry`)}return D("lease_store_error")}let xr=Sr+ne,oz=Yb(T,F,xr),tz={creditCost:{[F]:ne}},Ve;try{Ve=await r.getRulesEngine().checkFlagWithOptions(h,oz,O??null,tz)}catch(xe){return g.error(`Lease check: WASM eval failed: ${xe}`),await Nb(d,M,g),jo(p,i,Aa(l,o,`wasm_error: ${xe}`,h),{companyId:T.id,userId:O?.id})}let Gs={companyId:Ve.companyId??T.id,userId:Ve.userId??O?.id,ruleId:Ve.ruleId};return Ve.value?(y.maybeExtendInBackground(T.id,F),jo(p,i,{allowed:!0,value:!0,reservation:M,reason:Ve.reason??"lease_reserved",entitlement:Ms(Ve.entitlement),flagKey:Ve.flagKey??o,flagId:Ve.flagId},Gs)):(await Nb(d,M,g),jo(p,i,{allowed:!1,value:!1,reason:Ve.reason??"denied_by_engine",entitlement:Ms(Ve.entitlement),flagKey:Ve.flagKey??o,flagId:Ve.flagId},Gs))}function s_(p,o){return p.manager.resolveConfig(o)}function c_(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function Is(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}function Yb(p,o,i){return{...p,creditBalances:{...p.creditBalances??{},[o]:i}}}function l_(p){return{id:(0,$b.randomUUID)(),leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:p.quantityReserved,creditsReserved:p.creditsReserved,consumptionRate:p.consumptionRate,expiresAt:new Date(Date.now()+p.reservationTTL.reservationTTL),evalCtx:p.evalCtx}}function Ms(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function Nb(p,o,i){try{await p.consume(o.id,0)}catch(t){i.warn(`Lease check: failed to cancel reservation ${o.id} (${t}); its hold is reclaimed by the sweeper or at lease expiry`)}}var p_=Number.MAX_SAFE_INTEGER;async function u_(p){let{datastream:o,logger:i,mode:t,key:s,reason:r,flag:a,company:d,user:y,creditId:g,options:l}=p;if(t==="fail-closed")return Aa(t,s,r,a);try{let h=Yb(d,g,p_),w=await o.getRulesEngine().checkFlagWithOptions(a,h,y,Is(l));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:Ms(w.entitlement),flagKey:w.flagKey??s,flagId:w.flagId??a.id,err:r}}catch(h){return i.warn(`Lease check: fail-open evaluation failed (${h}); allowing`),Aa(t,s,r,a)}}function Aa(p,o,i,t){return p==="fail-closed"?{allowed:!1,value:!1,reason:i,flagKey:o,flagId:t?.id,err:i}:{allowed:!0,value:!0,reason:`${i}_fail_open`,flagKey:o,flagId:t?.id,err:i}}async function Zb(p,o,i,t){let s=i*o.consumptionRate,r=await p.consume(o.id,s);return{track:Va(o,i,t),settledLocally:r!==null}}function Va(p,o,i){let t={event:p.eventSubtype,quantity:o,leaseId:p.leaseId};return p.evalCtx.company&&(t.company=p.evalCtx.company),p.evalCtx.user&&(t.user=p.evalCtx.user),i?.traits&&(t.traits=i.traits),t}var Qb="lease-reservation:",Da=class extends Oa{constructor(i){let{apiKey:t="",basePath:s,eventBufferInterval:r,eventCaptureBaseURL:a,flagDefaults:d={},logLevel:y,timeoutMs:g}=i??{},{offline:l=!1}=i??{},h=s&&s.trim()!==""?s:void 0,w=a&&a.trim()!==""?a:void 0,U=i?.logger??new li(y),T={};i?.environmentId&&(T["X-Schematic-Environment-Id"]=i.environmentId),i?.headers&&Object.assign(T,i.headers),l?t!==""&&U.debug("Offline mode enabled, ignoring API key"):t===""&&!l&&(U.warn("No API key was provided, running in offline mode"),l=!0);let O=l?Tb:vb(T);super({apiKey:t,environment:h,fetcher:O,timeoutInSeconds:g!==void 0?g/1e3:void 0});this.leaseBackendShared=!1;this.prewarmResolveTimeoutMs=5e3;this.logger=U;let B={},j=this._options?.headers;if(j)for(let[A,Z]of Object.entries(j))typeof Z=="string"&&(B[A]=Z);let F=new Ba({apiKey:t,fetcher:O,headers:B,baseUrl:w,timeoutMs:g});if(this.eventBuffer=new ka(F,{interval:r,logger:U,offline:l}),this.flagCheckCacheProviders=i?.cacheProviders?.flagChecks??[new or],this.flagDefaults=d,this.offline=l,i?.useDataStream&&!l){let Z=["workerd","edge-runtime","browser","web-worker"].includes(_e.type),ne=i.dataStream?.replicatorMode===!0;if(Z&&!ne)U.warn(`DataStream is not supported in ${_e.type} runtime and will be disabled. DataStream requires Node.js APIs (WebSocket) that are not available in edge/browser environments. Use replicatorMode for edge runtime compatibility.`);else{let Se={apiKey:t,baseURL:h,logger:U,cacheTTL:i.dataStream?.cacheTTL,redisClient:i.dataStream?.redisClient,redisKeyPrefix:i.dataStream?.redisKeyPrefix,replicatorMode:i.dataStream?.replicatorMode,replicatorHealthURL:i.dataStream?.replicatorHealthURL,replicatorHealthCheck:i.dataStream?.replicatorHealthCheck};this.datastreamClient=new Uo(Se),this.datastreamClient.start().catch(D=>{U.error(`Failed to start DataStream client: ${D}`),this.datastreamClient=void 0})}}if(i?.creditLeases&&l&&U.warn("creditLeases is configured but the client is in offline mode \u2014 lease-gated checks are disabled and check() will return flag defaults with no credit gating."),i?.creditLeases&&!l){this.datastreamClient||U.warn("creditLeases is configured but DataStream is not enabled \u2014 check() will fall back to plain flag checks with NO credit gating (usage is ignored). Set useDataStream: true (or replicatorMode) to enable lease-gated checks.");let A=i.creditLeases.sweepIntervalMs??1e3,Z=i.creditLeases.redisClient??i.dataStream?.redisClient,ne=i.creditLeases.redisKeyPrefix??i.dataStream?.redisKeyPrefix;Z?(this.leaseBackendShared=!0,this.leaseStore=new ko({client:Z,keyPrefix:ne,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new Bo({client:Z,leaseStore:this.leaseStore,sweepIntervalMs:A,keyPrefix:ne})):(U.warn("creditLeases is enabled without a shared Redis backend; lease and reservation state will be kept per-process. Configure dataStream.redisClient (or creditLeases.redisClient) so leases gate correctly across multiple SDK instances."),this.leaseStore=new vo,this.reservations=new To(this.leaseStore,A)),this.reservations.startSweep(),this.creditLeaseManager=new Oo({creditsClient:this.credits,leaseStore:this.leaseStore,logger:U,config:i.creditLeases}),this.prewarmResolveTimeoutMs=i.creditLeases.prewarmResolveTimeoutMs??5e3}}useDataStream(){return this.datastreamClient!==void 0}async checkFlag(i,t,s){return(await this.checkFlagWithEntitlement(i,t,s)).value}async checkFlagWithEntitlement(i,t,s){let r=()=>s?.defaultValue===void 0?this.getFlagDefault(t):typeof s.defaultValue=="function"?s.defaultValue():s.defaultValue;if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag value for flag ${t}`),{flagKey:t,reason:"flag default",value:r()};if(this.useDataStream())try{let a=await this.datastreamClient.checkFlag(i,t,s);return this.enqueueEvent(Do.FlagCheck,{flagKey:t,value:a?.value??!1,reason:a?.reason??"unknown",ruleId:a?.ruleId,companyId:a?.companyId,userId:a?.userId,flagId:a?.flagId,reqCompany:i.company,reqUser:i.user}),{companyId:a.companyId,entitlement:a.entitlement,err:a.err,flagKey:a.flagKey??t,flagId:a.flagId,reason:a.reason,ruleId:a.ruleId,ruleType:a.ruleType,userId:a.userId,value:a.value??this.getFlagDefault(t)}}catch(a){return this.logger.debug(`Datastream flag check failed (${a}), falling back to API`),this.checkFlagViaAPI(i,t,s,r)}return this.checkFlagViaAPI(i,t,s,r)}async checkFlagViaAPI(i,t,s,r){let a=r??(()=>this.getFlagDefault(t));try{let d=JSON.stringify({evalCtx:i,key:t});for(let l of this.flagCheckCacheProviders){let h=await l.get(d);if(h!=null)return this.logger.debug(`${l.constructor.name} cache hit for flag ${t}`),h}let y=await this.features.checkFlag(t,i,{timeoutInSeconds:s?.timeoutMs!==void 0?s.timeoutMs/1e3:void 0});if(y.data.value===void 0)return this.logger.debug(`No value returned from feature flag API for flag ${t}, falling back to default`),{flagKey:t,reason:"flag default",value:a()};this.logger.debug(`Feature flag API response for ${t}: ${JSON.stringify(y.data)}`);let g={companyId:y.data.companyId,entitlement:y.data.entitlement,err:y.data.error,flagKey:y.data.flag,flagId:y.data.flagId,reason:y.data.reason,ruleId:y.data.ruleId,ruleType:y.data.ruleType,userId:y.data.userId,value:y.data.value};try{for(let l of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${t} in ${l.constructor.name}`),await l.set(d,g)}catch(l){this.logger.warn(`Cache write failed for flag ${t}: ${l}`)}return g}catch(d){return this.logger.error(`Error checking flag ${t}: ${d}`),{flagKey:t,reason:"flag default",value:a()}}}async checkFlags(i,t){if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag values for flags ${t?t.join(", "):"all"}`),t&&t.length>0?t.map(s=>({flag:s,value:this.getFlagDefault(s),reason:"Offline mode - using default value"})):[];try{if(this.useDataStream()&&this.datastreamClient.isConnected()&&t&&t.length>0){let w=await this.checkFlagsViaDataStream(i,t);if(w)return w}if(!t||t.length===0)return this.logger.debug("No specific flag keys provided, calling standard checkFlags API"),(await this.features.checkFlags(i)).data.flags;let s=new Map,r=[],a=await Promise.all(t.map(async w=>{let U=JSON.stringify({evalCtx:i,key:w});for(let T of this.flagCheckCacheProviders){let O=await T.get(U);if(O!=null)return this.logger.debug(`${T.constructor.name} cache hit for flag ${w}`),{key:w,cached:{flag:w,value:O.value,reason:O.reason}}}return{key:w,cached:null}}));for(let{key:w,cached:U}of a)U?s.set(w,U):r.push(w);if(r.length===0)return this.logger.debug(`All ${t.length} flags found in cache`),t.map(w=>s.get(w));this.logger.debug(`Cache miss for ${r.length} flags: ${r.join(", ")}, calling API`);let y=(await this.features.checkFlags(i)).data.flags,g=[],l=new Map(y.map(w=>[w.flag,w])),h=[];for(let w of t){let U=l.get(w);if(U){let T=JSON.stringify({evalCtx:i,key:w}),O={companyId:U.companyId,entitlement:U.entitlement,err:U.error,flagKey:U.flag,flagId:U.flagId,reason:U.reason,ruleId:U.ruleId,ruleType:U.ruleType,userId:U.userId,value:U.value};h.push({cacheKey:T,cacheEntry:O,key:w}),g.push(U)}else{let T=s.get(w);if(T)g.push(T);else{this.logger.debug(`Flag ${w} not found in API response or cache, using default value`);let O={flag:w,value:this.getFlagDefault(w),reason:"Flag not found - using default value"};g.push(O)}}}return await Promise.all(h.map(async({cacheKey:w,cacheEntry:U,key:T})=>{try{await Promise.all(this.flagCheckCacheProviders.map(O=>(this.logger.debug(`Caching value for flag ${w} in ${O.constructor.name}`),O.set(w,U))))}catch(O){this.logger.warn(`Cache write failed for flag ${T}: ${O}`)}})),this.logger.debug(`Checked ${t.length} flags: used fresh API values for consistency (${r.length} were cache misses)`),g}catch(s){return this.logger.error(`Error checking flags ${t?t.join(", "):"all"}: ${s}`),t&&t.length>0?t.map(r=>({flag:r,value:this.getFlagDefault(r),reason:`Error occurred - using default value: ${s}`})):[]}}async checkFlagsViaDataStream(i,t){let s=[];for(let r of t)try{let a=await this.datastreamClient.checkFlag(i,r);s.push({flag:a.flagKey??r,value:a.value??this.getFlagDefault(r),reason:a.reason,flagId:a.flagId,ruleId:a.ruleId,ruleType:a.ruleType,companyId:a.companyId,userId:a.userId,entitlement:a.entitlement,error:a.err})}catch(a){return this.logger.debug(`Datastream checkFlags falling back to API (${a})`),null}return this.logger.debug(`All ${t.length} flags evaluated via DataStream`),s}async close(){return this.reservations&&this.reservations.stop(),this.creditLeaseManager&&!this.leaseBackendShared&&await this.creditLeaseManager.releaseAllLocalLeases(),this.datastreamClient&&this.datastreamClient.close(),this.eventBuffer.stop()}async prewarm(i,t){if(!this.creditLeaseManager||!this.leaseStore){this.logger.debug("prewarm called but creditLeases is not configured");return}if(!i.company||Object.keys(i.company).length===0){this.logger.debug("prewarm requires a company on evalCtx");return}let s=await this.resolveCompanyIdWithWait(i);if(!s){this.logger.debug(`prewarm: company not resolved within ${this.prewarmResolveTimeoutMs}ms for keys ${JSON.stringify(i.company)} (first check() will acquire)`);return}await Promise.all(t.map(r=>this.creditLeaseManager.acquireIfNeeded(s,r).catch(a=>this.logger.warn(`prewarm: failed to acquire lease for ${r}: ${a}`))))}async resolveCompanyIdWithWait(i){if(!i.company)return;if(i.company.id)return i.company.id;let t=this.datastreamClient;if(!t||this.prewarmResolveTimeoutMs<=0)return this.resolveCompanyId(i);let s=i.company,r=await t.getCachedCompany(s);if(r?.id)return r.id;let a=Date.now()+this.prewarmResolveTimeoutMs;for(;;){try{let d=await t.getCompany(s);if(d?.id)return d.id}catch(d){this.logger.debug(`prewarm: datastream company fetch failed (${d})`)}if(Date.now()>=a)return;await new Promise(d=>setTimeout(d,100))}}async check(i,t,s){let r=async()=>{let d=await this.checkFlagWithEntitlement(i,t,{defaultValue:s?.defaultValue,timeoutMs:s?.timeoutMs,...s?Is(s):void 0});return{allowed:d.value,value:d.value,reason:d.reason,entitlement:d.entitlement,flagKey:d.flagKey,flagId:d.flagId,err:d.err}};return!(s?.usage!==void 0)||!this.creditLeaseManager||!this.leaseStore||!this.reservations?r():Jb({leaseStore:this.leaseStore,reservations:this.reservations,manager:this.creditLeaseManager,datastream:this.datastreamClient,logger:this.logger,enqueueFlagCheckEvent:d=>this.enqueueEvent(Do.FlagCheck,d)},t,i,s,r)}async trackWithReservation(i,t,s){if(this.offline)return;if(!Number.isFinite(t)||t<0){this.logger.error(`trackWithReservation: invalid actualQuantity ${t} for reservation ${i.id} \u2014 must be a finite, non-negative number; skipping settle (the hold is refunded at its TTL)`);return}if(!this.reservations){this.logger.warn("trackWithReservation called but creditLeases is not configured \u2014 emitting unsettled track"),await this.track(Va(i,t,s),{idempotencyKey:`${Qb}${i.id}`});return}let r,a;try{({track:r,settledLocally:a}=await Zb(this.reservations,i,t,s))}catch(d){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${d}) \u2014 emitting track anyway`),r=Va(i,t,s),a=!1}a||this.logger.debug(`trackWithReservation: reservation ${i.id} was not settled locally (expired/swept, already settled, or store unreachable) \u2014 emitting track keyed for idempotent server-side dedupe`),await this.track(r,{idempotencyKey:`${Qb}${i.id}`})}async resolveCompanyId(i){if(i.company){if(i.company.id)return i.company.id;if(this.datastreamClient)return(await this.datastreamClient.getCachedCompany(i.company))?.id}}async identify(i,t){if(!this.offline){try{await this.enqueueEvent("identify",i,t)}catch(s){this.logger.error(`Error sending identify event: ${s}`)}if(t?.prewarm&&t.prewarm.length>0){let s={company:i.company?.keys,user:i.keys};this.eventBuffer.flush().catch(r=>{this.logger.debug(`identify flush before prewarm failed: ${r}`)}),this.prewarm(s,t.prewarm).catch(r=>{this.logger.warn(`identify prewarm failed: ${r}`)})}}}async track(i,t){if(!this.offline)try{if(await this.enqueueEvent("track",i,t),i.company&&this.useDataStream()&&this.datastreamClient.isConnected())try{await this.datastreamClient.updateCompanyMetrics(i.company,i.event,i.quantity||1)}catch(s){this.logger.error(`Failed to update company metrics: ${s}`)}}catch(s){this.logger.error(`Error sending track event: ${s}`)}}setFlagDefault(i,t){this.flagDefaults[i]=t}setFlagDefaults(i){Object.assign(this.flagDefaults,i)}getFlagDefault(i){return this.flagDefaults[i]??!1}async enqueueEvent(i,t,s){try{let r={eventType:i,body:t,sentAt:new Date};s&&(s.idempotencyKey!==void 0&&(r.idempotencyKey=s.idempotencyKey),"sentAt"in s&&s.sentAt!==void 0&&(r.sentAt=s.sentAt),"trustedClientClock"in s&&s.trustedClientClock!==void 0&&(r.trustedClientClock=s.trustedClientClock),"backfill"in s&&s.backfill!==void 0&&(r.backfill=s.backfill)),this.eventBuffer.push(r)}catch(r){this.logger.error(`Error enqueueing ${i} event: ${r}`)}}};var qa=mo(require("crypto")),Fs="X-Schematic-Webhook-Signature",Ks="X-Schematic-Webhook-Timestamp",_r=class p extends Error{constructor(o){super(o),Object.setPrototypeOf(this,p.prototype),this.name="WebhookSignatureError"}static missingSignature(){return new p("Missing webhook signature header")}static missingTimestamp(){return new p("Missing webhook timestamp header")}static invalidSignature(){return new p("Invalid webhook signature")}};function Ma(p,o,i){let t=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([t,Buffer.from(`+${o}`)]),r=qa.createHmac("sha256",i);return r.update(s),r.digest()}function rz(p,o,i){return Ma(p,o,i).toString("hex")}function Ls(p,o,i,t){if(!o)throw _r.missingSignature();if(!i)throw _r.missingTimestamp();let s;try{s=Buffer.from(o,"hex")}catch(a){throw new _r(`Invalid signature format: ${a?.message||"Unknown error"}`)}let r=Ma(p,i,t);if(s.length!==r.length||!qa.timingSafeEqual(s,r))throw _r.invalidSignature()}function iz(p,o,i,t={}){let s=p.headers,r=t.signatureHeader||Fs,a=t.timestampHeader||Ks,d=ez(s,r),y=ez(s,a),g;if(i!==void 0)g=i;else if("rawBody"in p&&p.rawBody)g=p.rawBody;else throw new _r("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");Ls(g,d,y,o)}function ez(p,o){let i=p[o]||p[o.toLowerCase()];return Array.isArray(i)?i[0]||"":i||""}0&&(module.exports={ConsoleLogger,LocalCache,LogLevel,RedisCacheProvider,RulesEngineClient,Schematic,SchematicClient,SchematicEnvironment,SchematicError,SchematicTimeoutError,WEBHOOK_SIGNATURE_HEADER,WEBHOOK_TIMESTAMP_HEADER,WebhookSignatureError,computeHexSignature,computeSignature,verifySignature,verifyWebhookSignature});
|
|
85
|
+
`;function Qb(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function h_(p){let o=p.split("|");if(o.length===3)return{companyId:o[0],creditTypeId:o[1],id:o[2]}}var ez=256,g_=16,Bo=class{constructor(o){this.sweepInterval=null;this.stopped=!1;this.client=o.client,this.leaseStore=o.leaseStore,this.sweepIntervalMs=o.sweepIntervalMs??1e3,this.keyPrefix=o.keyPrefix??l_}hashKey(o){return`${this.keyPrefix}${p_}${o}`}indexKey(){return`${this.keyPrefix}${u_}`}byCreditKey(o,i){return`${this.keyPrefix}${d_}${o}:${i}`}async add(o){let i=o.expiresAt.getTime(),t=this.hashKey(o.id);await this.client.hSet(t,{id:o.id,leaseId:o.leaseId,companyId:o.companyId,creditTypeId:o.creditTypeId,eventSubtype:o.eventSubtype,quantityReserved:String(o.quantityReserved),creditsReserved:String(o.creditsReserved),consumptionRate:String(o.consumptionRate),expiresAt:String(i),evalCtx:JSON.stringify(o.evalCtx)}),await Promise.all([this.client.pExpireAt(t,i+3e4),this.client.zAdd(this.indexKey(),{score:i,value:Qb(o)}),this.client.hSet(this.byCreditKey(o.companyId,o.creditTypeId),o.id,String(o.creditsReserved))])}async get(o){let i=await this.client.hGetAll(this.hashKey(o));if(!(!i||!i.id))return w_(i)}async reservedCredits(o,i){let t=await this.client.hGetAll(this.byCreditKey(o,i)).catch(()=>({})),s=0;for(let r of Object.values(t))s+=Number(r)||0;return s}async consume(o,i){let t=await this.client.eval(m_,{keys:[this.hashKey(o)],arguments:[]}),s=y_(t);if(!s||!s.id)return null;let r=s.companyId,a=s.creditTypeId,d=Number(s.creditsReserved)||0;await this.client.zRem(this.indexKey(),Qb({companyId:r,creditTypeId:a,id:o})).catch(()=>{}),await this.client.hDel(this.byCreditKey(r,a),o).catch(()=>{});let y=i;y<0&&(y=0),y>d&&(y=d);let g=d-y;return g>0&&await this.leaseStore.refund(r,a,g,s.leaseId),y}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=o.getTime(),t=0;for(let s=0;s<g_;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:ez}});if(r.length===0)break;for(let a of r){let d=h_(a);if(!d){await this.client.zRem(this.indexKey(),a).catch(()=>{});continue}let y=await this.consume(d.id,0);if(await this.client.zRem(this.indexKey(),a).catch(()=>{}),y!==null){t++;continue}await this.client.hDel(this.byCreditKey(d.companyId,d.creditTypeId),d.id).catch(()=>{})}if(r.length<ez)break}return t}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}async size(){return this.client.zCard(this.indexKey()).catch(()=>0)}};function y_(p){if(!Array.isArray(p)||p.length===0)return;let o={};for(let i=0;i+1<p.length;i+=2)o[String(p[i])]=String(p[i+1]);return o}function w_(p){return{id:p.id,leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:Number(p.quantityReserved),creditsReserved:Number(p.creditsReserved),consumptionRate:Number(p.consumptionRate),expiresAt:new Date(Number(p.expiresAt)),evalCtx:p.evalCtx?JSON.parse(p.evalCtx):{}}}var iz=require("crypto");function jo(p,o,i,t){return p.enqueueFlagCheckEvent({flagKey:i.flagKey,value:i.value,reason:i.reason,error:i.err,flagId:i.flagId,companyId:t?.companyId,userId:t?.userId,ruleId:t?.ruleId,reqCompany:o.company,reqUser:o.user}),i}async function oz(p,o,i,t,s){let{datastream:r,leaseStore:a,reservations:d,manager:y,logger:g}=p,l=t.onAcquireFailure??"fail-closed";if(t.usage===void 0||!Number.isFinite(t.usage)||t.usage<0)return g.error(`Lease check: invalid usage ${t.usage} for flag ${o} \u2014 must be a finite, non-negative number`),jo(p,i,Aa(l,o,"invalid_usage",null));if(t.usage===0)return g.debug(`Lease check: usage is 0 for flag ${o} \u2014 nothing to reserve, using plain check`),s();if(!r)return g.debug("Credit-lease check requested without datastream \u2014 falling back to plain check"),s();let h=null;try{h=await r.getFlag(o)}catch(xe){g.warn(`Lease check: failed to load flag ${o}: ${xe}`)}if(!h)return g.debug(`Lease check: no cached flag for ${o}, falling back`),s();let{eventSubtype:w,quantity:U}=z_(t);if(!i.company)return g.debug("Lease check: no company on evalCtx, falling back"),s();let T=null;try{T=await r.getCompany(i.company)}catch(xe){g.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${xe}), falling back`)}if(!T)return s();let O=null;if(i.user){try{O=await r.getUser(i.user)}catch(xe){g.debug(`Lease check: user fetch failed for keys ${JSON.stringify(i.user)} (${xe}), falling back`)}if(!O)return s()}let B;try{B=await r.getRulesEngine().checkFlagWithOptions(h,T,O??null,null)}catch(xe){return g.warn(`Lease check: entitlement probe failed for flag ${o} (${xe}), falling back`),s()}let j=B.entitlement;if(!j||j.valueType!==Ia.Credit)return g.debug(`Lease check: flag ${o} matched a non-credit entitlement (valueType=${j?.valueType??"<none>"}), falling back to plain check \u2014 no reservation`),s();let K=j.creditId,A=j.consumptionRate??0,Z=w??j.eventSubtype;if(!K||A<=0||!Z)return g.debug(`Lease check: flag ${o} credit entitlement is incomplete (creditId=${K??"<none>"}, consumptionRate=${A}, subtype=${Z??"<none>"}), falling back`),s();let ne=U*A,Se=t.timeoutMs!==void 0?{timeoutInSeconds:t.timeoutMs/1e3}:void 0,D=xe=>__({datastream:r,logger:g,mode:l,key:o,reason:xe,flag:h,company:T,user:O,creditId:K,options:t}).then(Ao=>jo(p,i,Ao,{companyId:T.id,userId:O?.id})),M=await y.acquireIfNeeded(T.id,K,Se);if(!M)return D("lease_acquire_failed");let _r;try{_r=await a.tryReserve(T.id,K,ne),_r===null&&(await y.maybeExtendInBackground(T.id,K,ne,Se),_r=await a.tryReserve(T.id,K,ne))}catch(xe){return g.error(`Lease check: reserve against ${T.id}/${K} failed: ${xe}`),D("lease_store_error")}if(_r===null)return D("insufficient_lease_balance");let I=R_({leaseId:M.leaseId,companyId:T.id,creditTypeId:K,eventSubtype:Z,quantityReserved:U,creditsReserved:ne,consumptionRate:A,reservationTTL:b_(p,K),evalCtx:i});try{await d.add(I)}catch(xe){g.error(`Lease check: failed to persist reservation ${I.id}: ${xe}`);try{await d.consume(I.id,0)===null&&await a.refund(T.id,K,ne,M.leaseId)}catch(Ao){g.warn(`Lease check: could not undo local debit for ${I.id} (${Ao}); the slice is reclaimed at lease expiry`)}return D("lease_store_error")}let Sr=_r+ne,uz=tz(T,K,Sr),dz={creditCost:{[K]:ne}},Ve;try{Ve=await r.getRulesEngine().checkFlagWithOptions(h,uz,O??null,dz)}catch(xe){return g.error(`Lease check: WASM eval failed: ${xe}`),await rz(d,I,g),jo(p,i,Aa(l,o,`wasm_error: ${xe}`,h),{companyId:T.id,userId:O?.id})}let Gs={companyId:Ve.companyId??T.id,userId:Ve.userId??O?.id,ruleId:Ve.ruleId};return Ve.value?(y.maybeExtendInBackground(T.id,K),jo(p,i,{allowed:!0,value:!0,reservation:I,reason:Ve.reason??"lease_reserved",entitlement:Ms(Ve.entitlement),flagKey:Ve.flagKey??o,flagId:Ve.flagId},Gs)):(await rz(d,I,g),jo(p,i,{allowed:!1,value:!1,reason:Ve.reason??"denied_by_engine",entitlement:Ms(Ve.entitlement),flagKey:Ve.flagKey??o,flagId:Ve.flagId},Gs))}function b_(p,o){return p.manager.resolveConfig(o)}function z_(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function Is(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}function tz(p,o,i){return{...p,creditBalances:{...p.creditBalances??{},[o]:i}}}function R_(p){return{id:(0,iz.randomUUID)(),leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:p.quantityReserved,creditsReserved:p.creditsReserved,consumptionRate:p.consumptionRate,expiresAt:new Date(Date.now()+p.reservationTTL.reservationTTL),evalCtx:p.evalCtx}}function Ms(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function rz(p,o,i){try{await p.consume(o.id,0)}catch(t){i.warn(`Lease check: failed to cancel reservation ${o.id} (${t}); its hold is reclaimed by the sweeper or at lease expiry`)}}var f_=Number.MAX_SAFE_INTEGER;async function __(p){let{datastream:o,logger:i,mode:t,key:s,reason:r,flag:a,company:d,user:y,creditId:g,options:l}=p;if(t==="fail-closed")return Aa(t,s,r,a);try{let h=tz(d,g,f_),w=await o.getRulesEngine().checkFlagWithOptions(a,h,y,Is(l));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:Ms(w.entitlement),flagKey:w.flagKey??s,flagId:w.flagId??a.id,err:r}}catch(h){return i.warn(`Lease check: fail-open evaluation failed (${h}); allowing`),Aa(t,s,r,a)}}function Aa(p,o,i,t){return p==="fail-closed"?{allowed:!1,value:!1,reason:i,flagKey:o,flagId:t?.id,err:i}:{allowed:!0,value:!0,reason:`${i}_fail_open`,flagKey:o,flagId:t?.id,err:i}}async function az(p,o,i,t){let s=i*o.consumptionRate,r=await p.consume(o.id,s);return{track:Va(o,i,t),settledLocally:r!==null}}function Va(p,o,i){let t={event:p.eventSubtype,quantity:o,leaseId:p.leaseId};return p.evalCtx.company&&(t.company=p.evalCtx.company),p.evalCtx.user&&(t.user=p.evalCtx.user),i?.traits&&(t.traits=i.traits),t}var sz="lease-reservation:",Da=class extends Oa{constructor(i){let{apiKey:t="",basePath:s,eventBufferInterval:r,eventCaptureBaseURL:a,flagDefaults:d={},logLevel:y,timeoutMs:g}=i??{},{offline:l=!1}=i??{},h=s&&s.trim()!==""?s:void 0,w=a&&a.trim()!==""?a:void 0,U=i?.logger??new li(y),T={};i?.environmentId&&(T["X-Schematic-Environment-Id"]=i.environmentId),i?.headers&&Object.assign(T,i.headers),l?t!==""&&U.debug("Offline mode enabled, ignoring API key"):t===""&&!l&&(U.warn("No API key was provided, running in offline mode"),l=!0);let O=l?qb:Db(T);super({apiKey:t,environment:h,fetcher:O,timeoutInSeconds:g!==void 0?g/1e3:void 0});this.leaseBackendShared=!1;this.prewarmResolveTimeoutMs=5e3;this.logger=U;let B={},j=this._options?.headers;if(j)for(let[A,Z]of Object.entries(j))typeof Z=="string"&&(B[A]=Z);let K=new Ba({apiKey:t,fetcher:O,headers:B,baseUrl:w,timeoutMs:g});if(this.eventBuffer=new ka(K,{interval:r,logger:U,offline:l}),this.flagCheckCacheProviders=i?.cacheProviders?.flagChecks??[new or],this.flagDefaults=d,this.offline=l,i?.useDataStream&&!l){let Z=["workerd","edge-runtime","browser","web-worker"].includes(_e.type),ne=i.dataStream?.replicatorMode===!0;if(Z&&!ne)U.warn(`DataStream is not supported in ${_e.type} runtime and will be disabled. DataStream requires Node.js APIs (WebSocket) that are not available in edge/browser environments. Use replicatorMode for edge runtime compatibility.`);else{let Se={apiKey:t,baseURL:h,logger:U,cacheTTL:i.dataStream?.cacheTTL,redisClient:i.dataStream?.redisClient,redisKeyPrefix:i.dataStream?.redisKeyPrefix,replicatorMode:i.dataStream?.replicatorMode,replicatorHealthURL:i.dataStream?.replicatorHealthURL,replicatorHealthCheck:i.dataStream?.replicatorHealthCheck};this.datastreamClient=new Uo(Se),this.datastreamClient.start().catch(D=>{U.error(`Failed to start DataStream client: ${D}`),this.datastreamClient=void 0})}}if(i?.creditLeases&&l&&U.warn("creditLeases is configured but the client is in offline mode \u2014 lease-gated checks are disabled and check() will return flag defaults with no credit gating."),i?.creditLeases&&!l){this.datastreamClient||U.warn("creditLeases is configured but DataStream is not enabled \u2014 check() will fall back to plain flag checks with NO credit gating (usage is ignored). Set useDataStream: true (or replicatorMode) to enable lease-gated checks.");let A=i.creditLeases.sweepIntervalMs??1e3,Z=i.creditLeases.redisClient??i.dataStream?.redisClient,ne=i.creditLeases.redisKeyPrefix??i.dataStream?.redisKeyPrefix;Z?(this.leaseBackendShared=!0,this.leaseStore=new ko({client:Z,keyPrefix:ne,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new Bo({client:Z,leaseStore:this.leaseStore,sweepIntervalMs:A,keyPrefix:ne})):(U.warn("creditLeases is enabled without a shared Redis backend; lease and reservation state will be kept per-process. Configure dataStream.redisClient (or creditLeases.redisClient) so leases gate correctly across multiple SDK instances."),this.leaseStore=new vo,this.reservations=new To(this.leaseStore,A)),this.reservations.startSweep(),this.creditLeaseManager=new Oo({creditsClient:this.credits,leaseStore:this.leaseStore,logger:U,config:i.creditLeases}),this.prewarmResolveTimeoutMs=i.creditLeases.prewarmResolveTimeoutMs??5e3}}useDataStream(){return this.datastreamClient!==void 0}async checkFlag(i,t,s){return(await this.checkFlagWithEntitlement(i,t,s)).value}async checkFlagWithEntitlement(i,t,s){let r=()=>s?.defaultValue===void 0?this.getFlagDefault(t):typeof s.defaultValue=="function"?s.defaultValue():s.defaultValue;if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag value for flag ${t}`),{flagKey:t,reason:"flag default",value:r()};if(this.useDataStream())try{let a=await this.datastreamClient.checkFlag(i,t,s);return this.enqueueEvent(Do.FlagCheck,{flagKey:t,value:a?.value??!1,reason:a?.reason??"unknown",ruleId:a?.ruleId,companyId:a?.companyId,userId:a?.userId,flagId:a?.flagId,reqCompany:i.company,reqUser:i.user}),{companyId:a.companyId,entitlement:a.entitlement,err:a.err,flagKey:a.flagKey??t,flagId:a.flagId,reason:a.reason,ruleId:a.ruleId,ruleType:a.ruleType,userId:a.userId,value:a.value??this.getFlagDefault(t)}}catch(a){return this.logger.debug(`Datastream flag check failed (${a}), falling back to API`),this.checkFlagViaAPI(i,t,s,r)}return this.checkFlagViaAPI(i,t,s,r)}async checkFlagViaAPI(i,t,s,r){let a=r??(()=>this.getFlagDefault(t));try{let d=JSON.stringify({evalCtx:i,key:t});for(let l of this.flagCheckCacheProviders){let h=await l.get(d);if(h!=null)return this.logger.debug(`${l.constructor.name} cache hit for flag ${t}`),h}let y=await this.features.checkFlag(t,i,{timeoutInSeconds:s?.timeoutMs!==void 0?s.timeoutMs/1e3:void 0});if(y.data.value===void 0)return this.logger.debug(`No value returned from feature flag API for flag ${t}, falling back to default`),{flagKey:t,reason:"flag default",value:a()};this.logger.debug(`Feature flag API response for ${t}: ${JSON.stringify(y.data)}`);let g={companyId:y.data.companyId,entitlement:y.data.entitlement,err:y.data.error,flagKey:y.data.flag,flagId:y.data.flagId,reason:y.data.reason,ruleId:y.data.ruleId,ruleType:y.data.ruleType,userId:y.data.userId,value:y.data.value};try{for(let l of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${t} in ${l.constructor.name}`),await l.set(d,g)}catch(l){this.logger.warn(`Cache write failed for flag ${t}: ${l}`)}return g}catch(d){return this.logger.error(`Error checking flag ${t}: ${d}`),{flagKey:t,reason:"flag default",value:a()}}}async checkFlags(i,t){if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag values for flags ${t?t.join(", "):"all"}`),t&&t.length>0?t.map(s=>({flag:s,value:this.getFlagDefault(s),reason:"Offline mode - using default value"})):[];try{if(this.useDataStream()&&this.datastreamClient.isConnected()&&t&&t.length>0){let w=await this.checkFlagsViaDataStream(i,t);if(w)return w}if(!t||t.length===0)return this.logger.debug("No specific flag keys provided, calling standard checkFlags API"),(await this.features.checkFlags(i)).data.flags;let s=new Map,r=[],a=await Promise.all(t.map(async w=>{let U=JSON.stringify({evalCtx:i,key:w});for(let T of this.flagCheckCacheProviders){let O=await T.get(U);if(O!=null)return this.logger.debug(`${T.constructor.name} cache hit for flag ${w}`),{key:w,cached:{flag:w,value:O.value,reason:O.reason}}}return{key:w,cached:null}}));for(let{key:w,cached:U}of a)U?s.set(w,U):r.push(w);if(r.length===0)return this.logger.debug(`All ${t.length} flags found in cache`),t.map(w=>s.get(w));this.logger.debug(`Cache miss for ${r.length} flags: ${r.join(", ")}, calling API`);let y=(await this.features.checkFlags(i)).data.flags,g=[],l=new Map(y.map(w=>[w.flag,w])),h=[];for(let w of t){let U=l.get(w);if(U){let T=JSON.stringify({evalCtx:i,key:w}),O={companyId:U.companyId,entitlement:U.entitlement,err:U.error,flagKey:U.flag,flagId:U.flagId,reason:U.reason,ruleId:U.ruleId,ruleType:U.ruleType,userId:U.userId,value:U.value};h.push({cacheKey:T,cacheEntry:O,key:w}),g.push(U)}else{let T=s.get(w);if(T)g.push(T);else{this.logger.debug(`Flag ${w} not found in API response or cache, using default value`);let O={flag:w,value:this.getFlagDefault(w),reason:"Flag not found - using default value"};g.push(O)}}}return await Promise.all(h.map(async({cacheKey:w,cacheEntry:U,key:T})=>{try{await Promise.all(this.flagCheckCacheProviders.map(O=>(this.logger.debug(`Caching value for flag ${w} in ${O.constructor.name}`),O.set(w,U))))}catch(O){this.logger.warn(`Cache write failed for flag ${T}: ${O}`)}})),this.logger.debug(`Checked ${t.length} flags: used fresh API values for consistency (${r.length} were cache misses)`),g}catch(s){return this.logger.error(`Error checking flags ${t?t.join(", "):"all"}: ${s}`),t&&t.length>0?t.map(r=>({flag:r,value:this.getFlagDefault(r),reason:`Error occurred - using default value: ${s}`})):[]}}async checkFlagsViaDataStream(i,t){let s=[];for(let r of t)try{let a=await this.datastreamClient.checkFlag(i,r);s.push({flag:a.flagKey??r,value:a.value??this.getFlagDefault(r),reason:a.reason,flagId:a.flagId,ruleId:a.ruleId,ruleType:a.ruleType,companyId:a.companyId,userId:a.userId,entitlement:a.entitlement,error:a.err})}catch(a){return this.logger.debug(`Datastream checkFlags falling back to API (${a})`),null}return this.logger.debug(`All ${t.length} flags evaluated via DataStream`),s}async close(){return this.reservations&&this.reservations.stop(),this.creditLeaseManager&&!this.leaseBackendShared&&await this.creditLeaseManager.releaseAllLocalLeases(),this.datastreamClient&&this.datastreamClient.close(),this.eventBuffer.stop()}async prewarm(i,t){if(!this.creditLeaseManager||!this.leaseStore){this.logger.debug("prewarm called but creditLeases is not configured");return}if(!i.company||Object.keys(i.company).length===0){this.logger.debug("prewarm requires a company on evalCtx");return}let s=await this.resolveCompanyIdWithWait(i);if(!s){this.logger.debug(`prewarm: company not resolved within ${this.prewarmResolveTimeoutMs}ms for keys ${JSON.stringify(i.company)} (first check() will acquire)`);return}await Promise.all(t.map(r=>this.creditLeaseManager.acquireIfNeeded(s,r).catch(a=>this.logger.warn(`prewarm: failed to acquire lease for ${r}: ${a}`))))}async resolveCompanyIdWithWait(i){if(!i.company)return;if(i.company.id)return i.company.id;let t=this.datastreamClient;if(!t||this.prewarmResolveTimeoutMs<=0)return this.resolveCompanyId(i);let s=i.company,r=await t.getCachedCompany(s);if(r?.id)return r.id;let a=Date.now()+this.prewarmResolveTimeoutMs;for(;;){try{let d=await t.getCompany(s);if(d?.id)return d.id}catch(d){this.logger.debug(`prewarm: datastream company fetch failed (${d})`)}if(Date.now()>=a)return;await new Promise(d=>setTimeout(d,100))}}async check(i,t,s){let r=async()=>{let d=await this.checkFlagWithEntitlement(i,t,{defaultValue:s?.defaultValue,timeoutMs:s?.timeoutMs,...s?Is(s):void 0});return{allowed:d.value,value:d.value,reason:d.reason,entitlement:d.entitlement,flagKey:d.flagKey,flagId:d.flagId,err:d.err}};return!(s?.usage!==void 0)||!this.creditLeaseManager||!this.leaseStore||!this.reservations?r():oz({leaseStore:this.leaseStore,reservations:this.reservations,manager:this.creditLeaseManager,datastream:this.datastreamClient,logger:this.logger,enqueueFlagCheckEvent:d=>this.enqueueEvent(Do.FlagCheck,d)},t,i,s,r)}async trackWithReservation(i,t,s){if(this.offline)return;if(!Number.isFinite(t)||t<0){this.logger.error(`trackWithReservation: invalid actualQuantity ${t} for reservation ${i.id} \u2014 must be a finite, non-negative number; skipping settle (the hold is refunded at its TTL)`);return}if(!this.reservations){this.logger.warn("trackWithReservation called but creditLeases is not configured \u2014 emitting unsettled track"),await this.track(Va(i,t,s),{idempotencyKey:`${sz}${i.id}`});return}let r,a;try{({track:r,settledLocally:a}=await az(this.reservations,i,t,s))}catch(d){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${d}) \u2014 emitting track anyway`),r=Va(i,t,s),a=!1}a||this.logger.debug(`trackWithReservation: reservation ${i.id} was not settled locally (expired/swept, already settled, or store unreachable) \u2014 emitting track keyed for idempotent server-side dedupe`),await this.track(r,{idempotencyKey:`${sz}${i.id}`})}async resolveCompanyId(i){if(i.company){if(i.company.id)return i.company.id;if(this.datastreamClient)return(await this.datastreamClient.getCachedCompany(i.company))?.id}}async identify(i,t){if(!this.offline){try{await this.enqueueEvent("identify",i,t)}catch(s){this.logger.error(`Error sending identify event: ${s}`)}if(t?.prewarm&&t.prewarm.length>0){let s={company:i.company?.keys,user:i.keys};this.eventBuffer.flush().catch(r=>{this.logger.debug(`identify flush before prewarm failed: ${r}`)}),this.prewarm(s,t.prewarm).catch(r=>{this.logger.warn(`identify prewarm failed: ${r}`)})}}}async track(i,t){if(!this.offline)try{if(await this.enqueueEvent("track",i,t),i.company&&this.useDataStream()&&this.datastreamClient.isConnected())try{await this.datastreamClient.updateCompanyMetrics(i.company,i.event,i.quantity||1)}catch(s){this.logger.error(`Failed to update company metrics: ${s}`)}}catch(s){this.logger.error(`Error sending track event: ${s}`)}}setFlagDefault(i,t){this.flagDefaults[i]=t}setFlagDefaults(i){Object.assign(this.flagDefaults,i)}getFlagDefault(i){return this.flagDefaults[i]??!1}async enqueueEvent(i,t,s){try{let r={eventType:i,body:t,sentAt:new Date};s&&(s.idempotencyKey!==void 0&&(r.idempotencyKey=s.idempotencyKey),"sentAt"in s&&s.sentAt!==void 0&&(r.sentAt=s.sentAt),"trustedClientClock"in s&&s.trustedClientClock!==void 0&&(r.trustedClientClock=s.trustedClientClock),"backfill"in s&&s.backfill!==void 0&&(r.backfill=s.backfill)),this.eventBuffer.push(r)}catch(r){this.logger.error(`Error enqueueing ${i} event: ${r}`)}}};var qa=mo(require("crypto")),Fs="X-Schematic-Webhook-Signature",Ks="X-Schematic-Webhook-Timestamp",fr=class p extends Error{constructor(o){super(o),Object.setPrototypeOf(this,p.prototype),this.name="WebhookSignatureError"}static missingSignature(){return new p("Missing webhook signature header")}static missingTimestamp(){return new p("Missing webhook timestamp header")}static invalidSignature(){return new p("Invalid webhook signature")}};function Ma(p,o,i){let t=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([t,Buffer.from(`+${o}`)]),r=qa.createHmac("sha256",i);return r.update(s),r.digest()}function lz(p,o,i){return Ma(p,o,i).toString("hex")}function Ls(p,o,i,t){if(!o)throw fr.missingSignature();if(!i)throw fr.missingTimestamp();let s;try{s=Buffer.from(o,"hex")}catch(a){throw new fr(`Invalid signature format: ${a?.message||"Unknown error"}`)}let r=Ma(p,i,t);if(s.length!==r.length||!qa.timingSafeEqual(s,r))throw fr.invalidSignature()}function pz(p,o,i,t={}){let s=p.headers,r=t.signatureHeader||Fs,a=t.timestampHeader||Ks,d=cz(s,r),y=cz(s,a),g;if(i!==void 0)g=i;else if("rawBody"in p&&p.rawBody)g=p.rawBody;else throw new fr("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");Ls(g,d,y,o)}function cz(p,o){let i=p[o]||p[o.toLowerCase()];return Array.isArray(i)?i[0]||"":i||""}0&&(module.exports={ConsoleLogger,LocalCache,LogLevel,RedisCacheProvider,RulesEngineClient,Schematic,SchematicClient,SchematicEnvironment,SchematicError,SchematicTimeoutError,WEBHOOK_SIGNATURE_HEADER,WEBHOOK_TIMESTAMP_HEADER,WebhookSignatureError,computeHexSignature,computeSignature,verifySignature,verifyWebhookSignature});
|