"use strict";var e,_=require("ofetch");class r extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,_,r){super(e),_ instanceof Error&&(this.cause=_),this.privyErrorCode=r}}class t extends r{constructor(e,_,r,t,o,s){super(r,t,o),this.type=e,this.status=_,this.data=s}}class o extends r{constructor(e,_,r){super(e,_,r),this.type="client_error"}}class s extends r{constructor(e,_,r){super(e,_,r),this.type="connector_error"}}const n=e=>e instanceof r?e:e instanceof Error?new o(e.message,e):new o(`Internal error: ${e}`);var E=((e={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",e.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",e.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",e.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",e.INVALID_DATA="invalid_data",e.INVALID_CAPTCHA="invalid_captcha",e.LINKED_TO_ANOTHER_USER="linked_to_another_user",e.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",e.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",e.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",e.USER_EXITED_UPDATE_FLOW="exited_update_flow",e.ALLOWLIST_REJECTED="allowlist_rejected",e.OAUTH_USER_DENIED="oauth_user_denied",e.OAUTH_UNEXPECTED="oauth_unexpected",e.UNKNOWN_AUTH_ERROR="unknown_auth_error",e.USER_EXITED_AUTH_FLOW="exited_auth_flow",e.USER_EXITED_LINK_FLOW="exited_link_flow",e.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",e.MUST_BE_AUTHENTICATED="must_be_authenticated",e.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",e.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",e.CLIENT_REQUEST_TIMEOUT="client_request_timeout",e.INVALID_CREDENTIALS="invalid_credentials",e.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",e.UNKNOWN_MFA_ERROR="unknown_mfa_error",e.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",e.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",e.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",e.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",e.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",e.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",e.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",e.TRANSACTION_FAILURE="transaction_failure",e.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",e.NOT_SUPPORTED="not_supported",e.CAPTCHA_TIMEOUT="captcha_timeout",e.INVALID_MESSAGE="invalid_message",e.UNABLE_TO_SIGN="unable_to_sign",e.CAPTCHA_FAILURE="captcha_failure",e.CAPTCHA_DISABLED="captcha_disabled",e.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",e.TOO_MANY_REQUESTS="too_many_requests",e.USER_LIMIT_REACHED="max_accounts_reached",e.DISALLOWED_LOGIN_METHOD="disallowed_login_method",e.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",e.PASSKEY_NOT_ALLOWED="passkey_not_allowed",e.USER_DOES_NOT_EXIST="user_does_not_exist",e.INSUFFICIENT_BALANCE="insufficient_balance",e.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",e.BUFFER_NOT_DEFINED="buffer_not_defined",e.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",e.NO_SOLANA_ACCOUNTS="no_solana_accounts",e.UNKNOWN_FUNDING_ERROR="unknown_funding_error",e);exports.PrivyApiError=t,exports.PrivyClientError=o,exports.PrivyConnectorError=s,exports.PrivyEmbeddedWalletError=class extends o{constructor(e="Embedded wallet error",_){super(e,_,"unknown_embedded_wallet_error")}},exports.PrivyError=r,exports.PrivyErrorCode=E,exports.PrivyNoSolanaAccountsError=class extends s{constructor(){super("No Solana accounts found in wallet",void 0,"no_solana_accounts")}},exports.PrivyNotReadyError=class extends o{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},exports.PrivyTimeoutError=class extends o{constructor(){super("Request timed out",void 0,"client_request_timeout")}},exports.PrivyUnauthenticatedError=class extends o{constructor(e="User must be authenticated"){super(e,void 0,"must_be_authenticated")}},exports.PrivyUserLimitReachedError=class extends o{constructor(e){super("This application is in development mode and must be upgraded to production to log in new users.",e,"max_accounts_reached")}},exports.formatApiError=e=>{if(e instanceof r)return e;if(!(e instanceof _.FetchError))return n(e);if(!e.response)return new t("api_error",null,e.message,e);let{type:o,message:s,error:E,code:a}=e.data;return new t(o||"ApiError",e.response.status,s||E,e,a,e.data)},exports.formatPrivyError=n;
//# sourceMappingURL=errors-CBapWvRs.js.map
