import{m,n as f}from"../chunk-HWE3WYGL.js";import{Canister as u,createServices as w}from"@dfinity/utils";import{assertNever as l,jsonReplacer as C}from"@dfinity/utils";var n=class extends Error{},o=class extends Error{},c=class extends Error{},p=class extends Error{},a=class extends Error{},s=({Err:t})=>{if("Refunded"in t)throw new n(t.Refunded.reason);if("InvalidTransaction"in t)throw new o(t.InvalidTransaction);if("Processing"in t)throw new p;if("TransactionTooOld"in t)throw new a;if("Other"in t)throw new c(`Error in CMC with code ${t.Other.error_code}: ${t.Other.error_message}`);l(t,`Unsupported error type ${JSON.stringify(t,C)}`)};var y=class t extends u{static create(r){let{service:i,certifiedService:e,canisterId:d}=w({options:r,idlFactory:f,certifiedIdlFactory:m});return new t(d,i,e)}getIcpToCyclesConversionRate=async({certified:r}={})=>{let{data:i}=await this.caller({certified:r}).get_icp_xdr_conversion_rate();return i.xdr_permyriad_per_icp};notifyCreateCanister=async r=>{let{notify_create_canister:i}=this.service,e=await i(r);if("Err"in e&&s(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyCreateCanister ${JSON.stringify(e)}`)};notifyTopUp=async r=>{let{notify_top_up:i}=this.service,e=await i(r);if("Err"in e&&s(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyTopUp ${JSON.stringify(e)}`)};notifyMintCycles=async r=>{let{notify_mint_cycles:i}=this.service,e=await i(r);if("Err"in e&&s(e),"Ok"in e)return e.Ok;throw new Error(`Unsupported response type in notifyMintCycles ${JSON.stringify(e)}`)};getDefaultSubnets=({certified:r}={})=>{let{get_default_subnets:i}=this.caller({certified:r});return i()};getSubnetTypesToSubnets=({certified:r}={})=>{let{get_subnet_types_to_subnets:i}=this.caller({certified:r});return i()}};export{y as CmcCanister,c as CmcError,o as InvalidaTransactionError,p as ProcessingError,n as RefundedError,a as TransactionTooOldError,s as throwNotifyError};
//# sourceMappingURL=index.js.map
