@qonto/embed-sdk 0.43.0 → 0.44.0
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/errors/EmbedUIElementError.d.ts +11 -0
- package/dist/errors/EmbedUIElementError.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/organizations/organizations.types.d.ts +3 -1
- package/dist/organizations/organizations.types.d.ts.map +1 -1
- package/dist/src/errors/EmbedUIElementError.js +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/organizations/organizations.api.js +1 -1
- package/dist/src/organizations/organizations.js +1 -1
- package/dist/src/ui/index.js +1 -1
- package/dist/src/ui/ui-elements.js +1 -0
- package/dist/src/ui/ui-elements.public-api.js +1 -0
- package/dist/ui/index.d.ts +15 -3
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/ui-elements.d.ts +19 -0
- package/dist/ui/ui-elements.d.ts.map +1 -0
- package/dist/ui/ui-elements.public-api.d.ts +4 -0
- package/dist/ui/ui-elements.public-api.d.ts.map +1 -0
- package/dist/ui/ui-elements.types.d.ts +39 -2
- package/dist/ui/ui-elements.types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { QontoEmbedSdkError } from './QontoEmbedSdkError';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a UI element operation fails
|
|
4
|
+
*/
|
|
5
|
+
export declare class EmbedUIElementError extends QontoEmbedSdkError {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new EmbedUIElementError
|
|
8
|
+
*/
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=EmbedUIElementError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedUIElementError.d.ts","sourceRoot":"","sources":["../../src/errors/EmbedUIElementError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD;;OAEG;gBACS,OAAO,EAAE,MAAM;CAK5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { paymentLinks } from '@payment-links';
|
|
|
6
6
|
import { organizations } from '@organizations';
|
|
7
7
|
import { transactions } from '@transactions';
|
|
8
8
|
import { authLinks } from '@auth-links';
|
|
9
|
+
import { ui } from '@ui';
|
|
9
10
|
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, Transaction, Item, CreatePaymentLinkSettings, PaymentLinkParams, AuthLinkRequestParams, AuthLinkRequestResult, AuthLinkRequestSettings, PostAuthAction } from '@types';
|
|
10
|
-
|
|
11
|
-
export { initialize, logout, cards, sepaTransfers, beneficiaries, constants, paymentLinks, organizations, transactions, authLinks, createUIElement, };
|
|
11
|
+
export { initialize, logout, cards, sepaTransfers, beneficiaries, constants, paymentLinks, organizations, transactions, authLinks, ui, };
|
|
12
12
|
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, Transaction, Item, CreatePaymentLinkSettings, PaymentLinkParams, AuthLinkRequestParams, AuthLinkRequestResult, AuthLinkRequestSettings, PostAuthAction, };
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACf,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACf,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,SAAS,EACT,EAAE,GACH,CAAC;AACF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,GACf,CAAC"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class a extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class r extends a{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function o(){if(!n.hasAccessToken())throw new r;return n.getAccessToken()}class i extends a{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const s={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},l={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},u={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},g={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"},f={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},p=3e4,h={ACCEPT:"ACCEPT",REJECT:"REJECT"},m={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"};var b=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},AMOUNT_REQUIRING_ATTACHMENTS:p,AUTH_LINK_ACTIONS:m,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:l,ENVIRONMENTS:d,IFRAME_EVENTS:s,LOCALES:u,MFA_METHODS:f,TRANSACTION_STATUSES:{PENDING:"pending",DECLINED:"declined",COMPLETED:"completed"},TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:g,VOP_CHECK_RESULTS:{MATCH_RESULT_MATCH:"MATCH_RESULT_MATCH",MATCH_RESULT_NO_MATCH:"MATCH_RESULT_NO_MATCH",MATCH_RESULT_CLOSE_MATCH:"MATCH_RESULT_CLOSE_MATCH",MATCH_RESULT_NOT_POSSIBLE:"MATCH_RESULT_NOT_POSSIBLE",MATCH_RESULT_UNSPECIFIED:"MATCH_RESULT_UNSPECIFIED"},VOP_DECISIONS:h});class y{constructor(){this.mfaPreference=f.PASSKEY,this.debugMode=!1}static getInstance(){return y.instance||(y.instance=new y),y.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=f.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const v=y.getInstance(),_="https://embed.qonto.com",w="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",k={[d.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:w,IFRAME_URL:`${w}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class E{constructor(){this.environment=d.PRODUCTION,this.branch=l.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(l).includes(t)?t:l.SANDBOX}static getInstance(){return E.instance||(E.instance=new E),E.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=l.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return k.production;{const e=k[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const A=E.getInstance(),S={requiresUI:!1};function I(e,{requiresUI:t}=S){const n=e?.uiParentElementId||v.getUIParentElementId();if(t&&!n)throw new i("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const a=e?.mfaPreference||v.getMFAPreference();if(a){const e=(r=Object.values(f),A.isProductionEnvironment()?r.filter((e=>e!==f.MOCK)):r);if(!e.includes(a))throw new i(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(A.isProductionEnvironment()&&a===f.MOCK)throw new i("operationSettings.mfaPreference cannot be set to mock in production environment.")}var r;const o=e?.debugMode||v.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new i("operationSettings.debugMode must be a boolean.");const s=e?.proxyRequestFunction||v.getProxyRequestFunction();if(s&&"function"!=typeof s)throw new i("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:n,mfaPreference:a,debugMode:o,proxyRequestFunction:s}}const $=Object.values(u);function R(e){if(!function(e){return $.includes(e)}(e))throw new i(`Unsupported locale: ${e}. The locale must be one of: ${$.join(", ")}.`);return e}function P(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new i("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&I(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new i('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new i('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&R(e.locale),e}class C{constructor(){this.currentLocale="en"}static getInstance(){return C.instance||(C.instance=new C),C.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=C.getInstance();const N={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:r,environment:o,branch:i,locale:s}=P(e);t&&n.setAccessToken(t),a&&n.setStagingToken(a),s&&L.setLocale(s),r&&v.setSettings(r),o&&(A.setEnvironment(o),i&&A.setBranch(i))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),L.setDefaultLocale(),v.clearSettings()},constants:b},{initialize:q,logout:O,constants:D}=N;class U extends a{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function x(){return"undefined"!=typeof window&&"undefined"!=typeof document}function M(){return!x()}function z({accessToken:e,stagingToken:t,idempotencyKey:a,mfaPreference:r}){const o=new Headers;o.append("Authorization",`Bearer ${e}`);const i=t||n.getStagingToken();i&&o.append("X-Qonto-Staging-Token",i),a&&o.append("X-Qonto-Idempotency-Key",a);const s=r||v.getMFAPreference();return s&&o.append("X-Qonto-2fa-Preference",s),o.append("Content-Type","application/json"),o.append("Accept-Language",L.getLocale()),o}async function j({path:e,options:t}){const n=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,a=await fetch(n,{...t,headers:z(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===a.status)return;const r=await a.json();if(!a.ok)throw r.errors?new U(r.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${r.code}: ${r.detail}`);return r}function F(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return a=n,M()?Buffer.from(a).toString("base64"):btoa(a);var a}function B(e){return JSON.parse((t=e,M()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function H({accessToken:e,stagingToken:t,action:n,callbackUrl:a}){const r={post_authn_action:n};return a&&(r.callback_url=a),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:r}}}}function G({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function K({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Y({accessToken:e,stagingToken:t}){return H({accessToken:e,stagingToken:t,action:m.CARD_DISPLAY})}var V;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(V||(V={}));const W={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var Z,J;function Q(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new i(n.map((e=>`Missing required parameter: ${e}`)))}function X(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function ee(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function te(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(Z||(Z={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(J||(J={}));const ne=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],ae=[...ne,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function re(e){if(!e)throw new i("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Q(e,ne),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(g),p=X({membershipId:t,organizationId:n,bankAccountId:a}),h=ee({hasDailyLimit:r,hasTransactionLimit:o}),m=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d}),b=oe(l),y=ie(u),v=[...f,...p,...h,...m,...b,...y];if(v.length>0)throw new i(v)}(e),e}(e):function(e){Q(e,ae),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,shipToBusiness:m,hasAtmOption:b,hasAtmDailyLimit:y,atmDailyLimit:v,atmMonthlyLimit:_,address:w,cardDesign:T,typeOfPrint:k}=e,E=function(e){return Object.values(J).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(g),A=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(k),S=X({membershipId:t,organizationId:n,bankAccountId:a}),I=ee({hasDailyLimit:r,hasTransactionLimit:o,hasAtmOption:b,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,hasAtmDailyLimit:y,shipToBusiness:m}),$=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d,atmDailyLimit:v,atmMonthlyLimit:_}),R=oe(l),P=ie(u),C=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(T),L=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(w,m),N=[...E,...S,...I,...$,...R,...P,...A,...C,...L];if(N.length>0)throw new i(N)}(e)}(e)}function oe(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function ie(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class se extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));let de;const le=new Uint8Array(16);var ue={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(e,t,n){if(ue.randomUUID&&!e)return ue.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!de){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");de=crypto.getRandomValues.bind(crypto)}return de(le)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=15&a[6]|64,a[8]=63&a[8]|128,function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(a)}function fe({actionId:e,actionData:t}){const n=v.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||ge()}}}class pe{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new se(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",r),t(new se(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),r=t=>{t.data.eventId===s.READY&&(clearTimeout(a),window.removeEventListener("message",r),e(this))};window.addEventListener("message",r),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new se("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=fe(e);return new Promise(((e,n)=>{const a=r=>{if(r.data?.actionId===t.actionId){if("error"===r.data.status)return this.removeMessageListener(t.actionId,a),n(new se(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(r.data.payload)}`));this.removeMessageListener(t.actionId,a),e(r.data.payload)}};this.addMessageListener(t.actionId,a),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function he({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const r=a||!1,o=n||L.getLocale(),i=A.getEnvironmentUrls().IFRAME_URL,s=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${i}?debug=${r}&lang=${encodeURIComponent(o)}#access_token=${encodeURIComponent(e)}${s}`}function me({parentElementId:e,iframeUrl:t}){return new pe({parentElementId:e,iframeUrl:t}).initialize()}function be(e){return"virtual"===e.cardLevel?function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ye(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function ve(e){const t=Object.values(W);return(e||[]).filter((e=>t.includes(e)))}const _e="--qonto-embed";function we(e){return!e.href||e.href.startsWith(window.location.origin)}function Te(e){return"CSSStyleRule"===e.constructor.name}function ke(e=_e){return x()?function(e,t){return[...e].filter(we).reduce(((e,n)=>[...n.cssRules].filter(Te).reduce(((e,n)=>{if("style"in n){const a=[...n.style].map((e=>[e.trim(),n.style.getPropertyValue(e).trim()])).filter((([e])=>e.startsWith(t))).reduce(((e,[n,a])=>({...e,[n.replace(`${t}-`,"")]:a})),{});return{...e,...a}}return e}),e)),{})}(document.styleSheets,e):{}}async function Ee({decorationParams:e,operationSettings:t,cardIframeUrl:n}){const{cardId:a,allowPinReveal:r,allowBlocking:o}=e,{uiParentElementId:i,debugMode:s}=t,c=function(e,t){const n=new URL(e);n.searchParams.set("cardId",t.cardId),"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const a=ke(_e);return Object.keys(a).length>0&&n.searchParams.set("customization",JSON.stringify(a)),n.toString()}(n,{cardId:a,allowPinReveal:r,allowBlocking:o,debugMode:s}),d=await me({iframeUrl:c,parentElementId:i});return{destroyEmbedUI:()=>{d.destroy()}}}const Ae={getCards:async function(e){try{const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new i("membershipId must be a string");const{proxyRequestFunction:n,stagingToken:a}=I(e?.operationSettings||{});if(n){const e=F(G({membershipId:t,stagingToken:a})),r=await n(e);return B(r).body.cards.map((e=>ye(e)))}{const n=e?.operationSettings?.accessToken||o(),r=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a=G({membershipId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r}({membershipId:t,accessToken:n,stagingToken:a});return r.map((e=>ye(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:t}){try{!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId parameter is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e);const n=e.cardId,{proxyRequestFunction:a,stagingToken:r}=I(t||{});if(a){const e=F(K({cardId:n,stagingToken:r})),t=await a(e),o=B(t).body.cards;if(Array.isArray(o)&&o.length>0)return ye(o[0]);throw new i("Unable to retrieve card data")}{const e=t?.accessToken||o(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const a=K({cardId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r[0]}({cardId:n,accessToken:e,stagingToken:r});return ye(a)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});re(e.cardSettings);const i=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),s=await me({iframeUrl:i,parentElementId:a}),c=be(e.cardSettings),d=await s.postMessage(c);return s.destroy(),ye(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e.cardSettings);const s=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),d=await me({iframeUrl:s,parentElementId:a}),l=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),u=await d.postMessage(l);return d.destroy(),ye(u)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:a,debugMode:r,mfaPreference:s,proxyRequestFunction:c}=I(e.operationSettings,{requiresUI:!0});if(function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=ee(n);if(a.length>0)throw new i(a)}(e.cardSettings),c){const n=F(Y({stagingToken:a})),o=await c(n),i=B(o).body;return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r},cardIframeUrl:i.url})}{const i=n||o(),c=await async function(e){const t=Y(e),{embed_auth_link:n}=await j(t);return n}({...e.cardSettings,accessToken:i,stagingToken:a});return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r,mfaPreference:s},cardIframeUrl:c.url})}}catch(e){return Promise.reject(e)}}},Se=Ae;function Ie(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function $e({endpointUrl:e,paginationSettings:t}){return function({url:e,searchParams:t}){const n=new URL(e.toString());for(const[e,a]of t.entries())n.searchParams.append(e,a);return n}({url:new URL(e),searchParams:Ie(t)})}function Re(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function Pe(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function Ce(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const Le="/v2/sepa/beneficiaries";function Ne({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Le}${o}`,options:a}}function qe({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${Le}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Oe({accessToken:e,stagingToken:t,beneficiaryId:n}){const a=qe({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:r}=await j(a);return r}function De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){return{path:Le,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:a},body:{beneficiary:Ce(e)}}}}function Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${Le}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}function xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const{name:o,email:i,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r},body:{beneficiary:{name:o,email:i,activity_tag:s}}};return{path:`${Le}/${e.id}`,options:c}}const Me=[{name:"name"},{name:"iban"}];const ze={getBeneficiaries:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(Ne({paginationSettings:r})),t=B(await n(e)),a=t.body.beneficiaries.map((e=>Pe(e))),o=Re(t.body.meta);return{beneficiaries:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a=Ne({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:r,meta:o}=await j(a);return{beneficiaries:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.beneficiaries.map((e=>Pe(e))),s=Re(n.meta);return{beneficiaries:i,...s?{meta:s}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(qe({beneficiaryId:n}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o();return Pe(await Oe({beneficiaryId:n,accessToken:e,stagingToken:s}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new i("beneficiary must be an object");Q(e,Me);const t=X({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new i(t);return e}(e),{proxyRequestFunction:a,accessToken:r,stagingToken:s,idempotencyKey:c}=I(t||{});if(a){const e=F(De({beneficiary:n,idempotencyKey:c}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o(),t=await async function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){const r=De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a}),{beneficiary:o}=await j(r);return o}({beneficiary:n,accessToken:e,stagingToken:s,idempotencyKey:c});return Pe(t)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:a,activityTag:r}=e||{};if(!t)throw new i("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!r)throw new i("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=X({name:n,email:a,activityTag:r});if(o.length>0)throw new i(o);return{id:t,name:n,email:a,activityTag:r}}(e),{stagingToken:a,idempotencyKey:r,mfaPreference:s,proxyRequestFunction:c}=I(t),d={beneficiaryParamsBeingEdited:n,idempotencyKey:r,mfaPreference:s};if(c){const e=F(xe(d));return Pe(B(await c(e)).body.beneficiary)}{const e=t?.accessToken||o(),n=await async function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const o=xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}),{beneficiary:i}=await j(o);return i}({...d,accessToken:e,stagingToken:a});return Pe(n)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new i("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ue({beneficiaryIds:n}));return B(await a(e)).body.beneficiaries.map(Pe)}{const e=r||o(),t=await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const a=Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:r}=await j(a);return r}({beneficiaryIds:n,accessToken:e,stagingToken:s});return t.map(Pe)}}},je=ze;function Fe(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Be(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}function He(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function Ge(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}function Ke(e){return{name:e.name,iban:e.iban}}const Ye="/v2/sepa",Ve=`${Ye}/transfers`;function We({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Ve}${o}`,options:a}}function Ze({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Je({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}async function Qe({sepaPayee:e,accessToken:t,stagingToken:n}){const a=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await j(a)}const Xe="/v2/sepa/bulk_transfers";async function et({sepaPayees:e,accessToken:t,stagingToken:n}){const a=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Ke)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await j(a)}function tt(e){if(!e)throw new i("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new i("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new i("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new i("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new i(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new i(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=X({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),a=te({amount:e.amount}),r=[...n,...a].flat();if(r.length>0)throw new i(r);if(e.amount>p&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new i(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const nt="browser",at="server";class rt extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case nt:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case at:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const ot=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function it(e,t){const n=t?.locale||L.getLocale(),a=new URL(e);return n&&a.searchParams.append("lang",n),t?.mfaPreference&&a.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&a.searchParams.append("idempotencyKey",t.idempotencyKey),a.toString()}function st(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}const ct={request:async function({requestSettings:e,operationSettings:t}){!function(e){if(!e||"object"!=typeof e)throw new i("requestSettings must be an object");const t=e,{action:n,callbackUrl:a}=e;Q(t,[{name:"action"}]);const r=X(t),o=Object.values(m);if(o.includes(n)||r.push(`action must be one of ${o.join(", ")}`),r.length>0)throw new i(r);if(void 0!==a&&""===a.trim())throw new i("callbackUrl cannot be empty")}(e);const{proxyRequestFunction:n,stagingToken:a}=I(t||{});if(n){const t=F(H({stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}));return st(B(await n(t)).body)}{const n=t?.accessToken||o();return st(await async function(e){const t=H({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await j(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}({accessToken:n,stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}))}}};async function dt(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(We({paginationSettings:r})),t=B(await n(e)),a=t.body.transfers.map(He),o=Re(t.body.meta);return{transfers:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a=We({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:r,meta:o}=await j(a);return{transfers:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.transfers.map(He),s=Re(n.meta);return{transfers:i,...s?{meta:s}:{}}}}const lt={getSepaTransfers:dt,getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ze({sepaTransferId:n}));return He(B(await a(e)).body.transfer)}{const e=r||o(),t=await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a=Ze({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:r}=await j(a);return r}({sepaTransferId:n,accessToken:e,stagingToken:s});return He(t)}},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),s=t?.idempotencyKey||ge();let d;!function(e){if(!e)throw new i("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new i("sepaTransferSettings must be an object");if(Q(e,ot),!e.beneficiaryId&&!e.beneficiary)throw new i("Either beneficiaryId or beneficiary must be provided");const t=[...X({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...te({amount:e.amount})].flat();if(t.length>0)throw new i(t);if(e.amount>p&&(!e.attachmentIds||0===e.attachmentIds.length))throw new i("Attachments are required for transfers over €30,000")}(e);const l=await async function({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:Pe(await Oe({beneficiaryId:e?.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}({sepaTransferSettings:e,operationSettings:{accessToken:a,stagingToken:r||void 0}}),u={name:l.name,iban:l.iban},g=await Qe({sepaPayee:u,accessToken:a,stagingToken:r||void 0});var f;if((yield(f=g,{matchResult:f.match_result,matchedName:f.matched_name}))===h.REJECT)return;const m={...e,beneficiary:l};if(m.beneficiary?.trusted)d=await async function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:a,idempotencyKey:r}){const o=Ge(e),i={method:"POST",headers:z({accessToken:n,stagingToken:a,idempotencyKey:r}),body:JSON.stringify({transfer:o,vop_proof_token:t})},s=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ve}`,c=await fetch(s,i),d=await c.json();if(d.errors)throw new U(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.transfer}({transfer:m,vopProofToken:g.proof_token.token,accessToken:a,stagingToken:r||void 0,idempotencyKey:s});else{if(!x())throw new rt(nt);const{uiParentElementId:e,debugMode:n}=I(t,{requiresUI:!0});let o;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:n});o=await me({iframeUrl:t,parentElementId:e});const i=Ge(m);d=await o.postMessage(fe({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...i}},idempotencyKey:s}}))}finally{o?.destroy()}}return He(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Je({sepaTransferId:n}));B(await a(e))}else{const e=r||o();await async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a=Je({sepaTransferId:e,accessToken:t,stagingToken:n});await j(a)}({sepaTransferId:n,accessToken:e,stagingToken:s})}},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new i("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new i("callbackUrl must be a string");return e.callbackUrl}(e),{proxyRequestFunction:a,stagingToken:r,accessToken:s}=I(t||{}),c=a?{proxyRequestFunction:a}:{stagingToken:r,accessToken:s||o()},d=await ct.request({requestSettings:{action:m.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:c});return{...d,url:it(d.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:t}=e||{},n=t?.accessToken||o(),{stagingToken:a,paginationSettings:r}=I(t||{}),i=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=$e({endpointUrl:new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}`),paginationSettings:n}),o=await fetch(r,a);if(!o.ok)throw new U("Failed to fetch SEPA bulk transfers");const i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:i.bulk_transfers,meta:i.meta}}({accessToken:n,stagingToken:a,paginationSettings:r}),s=i.bulkTransfers?.map(Fe),c=Re(i.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||o(),{stagingToken:a}=I(t||{}),r=function(e){if(!e)throw new i("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new i("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Fe(await async function({accessToken:e,stagingToken:t,bulkTransferId:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}/${n}`),o=await fetch(r,a),i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return i.bulk_transfer}({accessToken:n,stagingToken:a,bulkTransferId:r}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),i=t?.idempotencyKey||ge();tt(e);const{uiParentElementId:s,debugMode:d}=I(t,{requiresUI:!0});if(!x())throw new rt(nt);const l=new Map;for(const t of e.bulkTransfers){const e=t.beneficiary.iban;e&&!l.has(e)&&l.set(e,{name:t.beneficiary.name,iban:e})}const u=Array.from(l.values()),g=await et({sepaPayees:u,accessToken:a,stagingToken:r||void 0});if((yield g.requests.map(Be))===h.REJECT)return;let f,p;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:d});p=await me({iframeUrl:t,parentElementId:s});const n={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};f=await p.postMessage(fe({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:n,idempotencyKey:i}}))}finally{p?.destroy()}return Fe(f)}}},ut={GOOD:"good",SERVICE:"service"},gt={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},ft=e=>{if(!(e=>Object.values(gt).includes(e))(e))throw new i(`currency ${e} is not valid, valid currencies are ${Object.values(gt).join(", ")}`)},pt={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},ht=e=>{if(!(e=>Object.values(pt).includes(e))(e))throw new i(`unit ${e} is not valid, valid units are ${Object.values(pt).join(", ")}`)},mt=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],bt=[{name:"currency"},{name:"value"}];const yt=e=>{if(!Object.values(ut).includes(e))throw new i(`type ${e} is not valid, valid types are ${Object.values(ut).join(", ")}`)},vt={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e})=>{const{items:t,authUrl:n}=e;!function(e){if(!e)throw new i("authUrl is required for the called function");const t=X({authUrl:e});if(t.length>0)throw new i(t);try{new URL(e)}catch{throw new i("authUrl is not a valid URL")}}(n),function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{Q(e,mt),Q(e.unitPrice,bt);const t=[...X({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...te({quantity:e.quantity})].flat();if(t.length>0)throw new i(t);yt(e.type),ft(e.unitPrice.currency),ht(e.measureUnit)}))}(t);const a=new URLSearchParams({...t?{items:JSON.stringify(t)}:{}});return a.toString()?`${n}?${a.toString()}`:n}},_t=({accessToken:e,stagingToken:t})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}),wt=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),Tt={getBankAccounts:async e=>{const{stagingToken:t,proxyRequestFunction:n}=I(e);if(n){const e=_t({stagingToken:t}),a=await n(F(e)),{body:r}=B(a);return r.bank_accounts.map(wt)}{const n=e.accessToken||o(),a=await(async({accessToken:e,stagingToken:t})=>{const n=_t({accessToken:e,stagingToken:t});return await j(n)})({accessToken:n,stagingToken:t});return a.bank_accounts.map(wt)}}},kt="/v2/transactions";function Et({bankAccountId:e,iban:t,status:n,updatedAtFrom:a,updatedAtTo:r,emittedAtFrom:o,emittedAtTo:i,settledAtFrom:s,settledAtTo:c,side:d,operationType:l,withAttachments:u,paginationSettings:g,accessToken:f,stagingToken:p}){const h={method:"GET",headers:{accessToken:f,stagingToken:p}},m=new URLSearchParams;e&&m.append("bank_account_id",e),t&&m.append("iban",t),n&&m.append("status",n),a&&m.append("updated_at_from",a),r&&m.append("updated_at_to",r),o&&m.append("emitted_at_from",o),i&&m.append("emitted_at_to",i),s&&m.append("settled_at_from",s),c&&m.append("settled_at_to",c),d&&m.append("side",d),l&&m.append("operation_type",l),void 0!==u&&m.append("with_attachments",String(u));const b=Ie(g);for(const[e,t]of b)m.append(e,t);const y=m.toString();return{path:`${kt}${y?`?${y}`:""}`,options:h}}function At({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${kt}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function St(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const It={getTransactions:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{}),i={...e?.transactionSettings||{},paginationSettings:r};if(n){const e=F(Et(i)),t=B(await n(e));return{transactions:t.body.transactions.map(St),meta:t.body.meta}}{const e=a||o(),n=await async function(e){const t=Et(e),{transactions:n,meta:a}=await j(t);return{transactions:n,meta:a}}({...i,accessToken:e,stagingToken:t});return{transactions:n.transactions.map(St),meta:n.meta}}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{proxyRequestFunction:n,accessToken:a,stagingToken:r}=I(t||{}),{transactionId:s}=function(e){if(!e)throw new i("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new i("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new i("transactionSettings.transactionId must be a string.");return e}(e);if(n){const e=F(At({transactionId:s}));return St(B(await n(e)).body.transaction)}{const e=a||o();return St(await async function(e){const t=At(e),{transaction:n}=await j(t);return n}({transactionId:s,accessToken:e,stagingToken:r}))}}},$t=It;function Rt(e,t,n,a){var r,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(i=(o<3?r(i):o>3?r(t,n,i):r(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}"function"==typeof SuppressedError&&SuppressedError;
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class a extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class r extends a{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function o(){if(!n.hasAccessToken())throw new r;return n.getAccessToken()}class i extends a{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const s={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},l={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},u={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},g={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"},f={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},p=3e4,h={ACCEPT:"ACCEPT",REJECT:"REJECT"},m={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"};var b=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},AMOUNT_REQUIRING_ATTACHMENTS:p,AUTH_LINK_ACTIONS:m,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:l,ENVIRONMENTS:d,IFRAME_EVENTS:s,LOCALES:u,MFA_METHODS:f,TRANSACTION_STATUSES:{PENDING:"pending",DECLINED:"declined",COMPLETED:"completed"},TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:g,VOP_CHECK_RESULTS:{MATCH_RESULT_MATCH:"MATCH_RESULT_MATCH",MATCH_RESULT_NO_MATCH:"MATCH_RESULT_NO_MATCH",MATCH_RESULT_CLOSE_MATCH:"MATCH_RESULT_CLOSE_MATCH",MATCH_RESULT_NOT_POSSIBLE:"MATCH_RESULT_NOT_POSSIBLE",MATCH_RESULT_UNSPECIFIED:"MATCH_RESULT_UNSPECIFIED"},VOP_DECISIONS:h});class y{constructor(){this.mfaPreference=f.PASSKEY,this.debugMode=!1}static getInstance(){return y.instance||(y.instance=new y),y.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=f.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const v=y.getInstance(),_="https://embed.qonto.com",w="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",k={[d.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:w,IFRAME_URL:`${w}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class E{constructor(){this.environment=d.PRODUCTION,this.branch=l.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(l).includes(t)?t:l.SANDBOX}static getInstance(){return E.instance||(E.instance=new E),E.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=l.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return k.production;{const e=k[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const A=E.getInstance(),S={requiresUI:!1};function I(e,{requiresUI:t}=S){const n=e?.uiParentElementId||v.getUIParentElementId();if(t&&!n)throw new i("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const a=e?.mfaPreference||v.getMFAPreference();if(a){const e=(r=Object.values(f),A.isProductionEnvironment()?r.filter((e=>e!==f.MOCK)):r);if(!e.includes(a))throw new i(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(A.isProductionEnvironment()&&a===f.MOCK)throw new i("operationSettings.mfaPreference cannot be set to mock in production environment.")}var r;const o=e?.debugMode||v.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new i("operationSettings.debugMode must be a boolean.");const s=e?.proxyRequestFunction||v.getProxyRequestFunction();if(s&&"function"!=typeof s)throw new i("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:n,mfaPreference:a,debugMode:o,proxyRequestFunction:s}}const $=Object.values(u);function R(e){if(!function(e){return $.includes(e)}(e))throw new i(`Unsupported locale: ${e}. The locale must be one of: ${$.join(", ")}.`);return e}function P(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new i("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&I(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new i('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new i('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&R(e.locale),e}class C{constructor(){this.currentLocale="en"}static getInstance(){return C.instance||(C.instance=new C),C.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=C.getInstance();const N={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:r,environment:o,branch:i,locale:s}=P(e);t&&n.setAccessToken(t),a&&n.setStagingToken(a),s&&L.setLocale(s),r&&v.setSettings(r),o&&(A.setEnvironment(o),i&&A.setBranch(i))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),L.setDefaultLocale(),v.clearSettings()},constants:b},{initialize:q,logout:O,constants:D}=N;class U extends a{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function x(){return"undefined"!=typeof window&&"undefined"!=typeof document}function M(){return!x()}function z({accessToken:e,stagingToken:t,idempotencyKey:a,mfaPreference:r}){const o=new Headers;o.append("Authorization",`Bearer ${e}`);const i=t||n.getStagingToken();i&&o.append("X-Qonto-Staging-Token",i),a&&o.append("X-Qonto-Idempotency-Key",a);const s=r||v.getMFAPreference();return s&&o.append("X-Qonto-2fa-Preference",s),o.append("Content-Type","application/json"),o.append("Accept-Language",L.getLocale()),o}async function j({path:e,options:t}){const n=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,a=await fetch(n,{...t,headers:z(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===a.status)return;const r=await a.json();if(!a.ok)throw r.errors?new U(r.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${r.code}: ${r.detail}`);return r}function F(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return a=n,M()?Buffer.from(a).toString("base64"):btoa(a);var a}function B(e){return JSON.parse((t=e,M()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function H({accessToken:e,stagingToken:t,action:n,callbackUrl:a}){const r={post_authn_action:n};return a&&(r.callback_url=a),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:r}}}}function G({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function K({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Y({accessToken:e,stagingToken:t}){return H({accessToken:e,stagingToken:t,action:m.CARD_DISPLAY})}var V;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(V||(V={}));const W={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var Z,J;function Q(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new i(n.map((e=>`Missing required parameter: ${e}`)))}function X(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function ee(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function te(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(Z||(Z={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(J||(J={}));const ne=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],ae=[...ne,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function re(e){if(!e)throw new i("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Q(e,ne),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(g),p=X({membershipId:t,organizationId:n,bankAccountId:a}),h=ee({hasDailyLimit:r,hasTransactionLimit:o}),m=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d}),b=oe(l),y=ie(u),v=[...f,...p,...h,...m,...b,...y];if(v.length>0)throw new i(v)}(e),e}(e):function(e){Q(e,ae),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,shipToBusiness:m,hasAtmOption:b,hasAtmDailyLimit:y,atmDailyLimit:v,atmMonthlyLimit:_,address:w,cardDesign:T,typeOfPrint:k}=e,E=function(e){return Object.values(J).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(g),A=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(k),S=X({membershipId:t,organizationId:n,bankAccountId:a}),I=ee({hasDailyLimit:r,hasTransactionLimit:o,hasAtmOption:b,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,hasAtmDailyLimit:y,shipToBusiness:m}),$=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d,atmDailyLimit:v,atmMonthlyLimit:_}),R=oe(l),P=ie(u),C=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(T),L=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(w,m),N=[...E,...S,...I,...$,...R,...P,...A,...C,...L];if(N.length>0)throw new i(N)}(e)}(e)}function oe(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function ie(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class se extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));let de;const le=new Uint8Array(16);var ue={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(e,t,n){if(ue.randomUUID&&!e)return ue.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!de){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");de=crypto.getRandomValues.bind(crypto)}return de(le)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=15&a[6]|64,a[8]=63&a[8]|128,function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(a)}function fe({actionId:e,actionData:t}){const n=v.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||ge()}}}class pe{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new se(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",r),t(new se(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),r=t=>{t.data.eventId===s.READY&&(clearTimeout(a),window.removeEventListener("message",r),e(this))};window.addEventListener("message",r),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new se("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=fe(e);return new Promise(((e,n)=>{const a=r=>{if(r.data?.actionId===t.actionId){if("error"===r.data.status)return this.removeMessageListener(t.actionId,a),n(new se(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(r.data.payload)}`));this.removeMessageListener(t.actionId,a),e(r.data.payload)}};this.addMessageListener(t.actionId,a),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function he({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const r=a||!1,o=n||L.getLocale(),i=A.getEnvironmentUrls().IFRAME_URL,s=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${i}?debug=${r}&lang=${encodeURIComponent(o)}#access_token=${encodeURIComponent(e)}${s}`}function me({parentElementId:e,iframeUrl:t}){return new pe({parentElementId:e,iframeUrl:t}).initialize()}function be(e){return"virtual"===e.cardLevel?function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ye(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function ve(e){const t=Object.values(W);return(e||[]).filter((e=>t.includes(e)))}const _e="--qonto-embed";function we(e){return!e.href||e.href.startsWith(window.location.origin)}function Te(e){return"CSSStyleRule"===e.constructor.name}function ke(e=_e){return x()?function(e,t){return[...e].filter(we).reduce(((e,n)=>[...n.cssRules].filter(Te).reduce(((e,n)=>{if("style"in n){const a=[...n.style].map((e=>[e.trim(),n.style.getPropertyValue(e).trim()])).filter((([e])=>e.startsWith(t))).reduce(((e,[n,a])=>({...e,[n.replace(`${t}-`,"")]:a})),{});return{...e,...a}}return e}),e)),{})}(document.styleSheets,e):{}}async function Ee({decorationParams:e,operationSettings:t,cardIframeUrl:n}){const{cardId:a,allowPinReveal:r,allowBlocking:o}=e,{uiParentElementId:i,debugMode:s}=t,c=function(e,t){const n=new URL(e);n.searchParams.set("cardId",t.cardId),"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const a=ke(_e);return Object.keys(a).length>0&&n.searchParams.set("customization",JSON.stringify(a)),n.toString()}(n,{cardId:a,allowPinReveal:r,allowBlocking:o,debugMode:s}),d=await me({iframeUrl:c,parentElementId:i});return{destroyEmbedUI:()=>{d.destroy()}}}const Ae={getCards:async function(e){try{const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new i("membershipId must be a string");const{proxyRequestFunction:n,stagingToken:a}=I(e?.operationSettings||{});if(n){const e=F(G({membershipId:t,stagingToken:a})),r=await n(e);return B(r).body.cards.map((e=>ye(e)))}{const n=e?.operationSettings?.accessToken||o(),r=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a=G({membershipId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r}({membershipId:t,accessToken:n,stagingToken:a});return r.map((e=>ye(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:t}){try{!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId parameter is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e);const n=e.cardId,{proxyRequestFunction:a,stagingToken:r}=I(t||{});if(a){const e=F(K({cardId:n,stagingToken:r})),t=await a(e),o=B(t).body.cards;if(Array.isArray(o)&&o.length>0)return ye(o[0]);throw new i("Unable to retrieve card data")}{const e=t?.accessToken||o(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const a=K({cardId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r[0]}({cardId:n,accessToken:e,stagingToken:r});return ye(a)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});re(e.cardSettings);const i=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),s=await me({iframeUrl:i,parentElementId:a}),c=be(e.cardSettings),d=await s.postMessage(c);return s.destroy(),ye(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e.cardSettings);const s=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),d=await me({iframeUrl:s,parentElementId:a}),l=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),u=await d.postMessage(l);return d.destroy(),ye(u)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:a,debugMode:r,mfaPreference:s,proxyRequestFunction:c}=I(e.operationSettings,{requiresUI:!0});if(function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=ee(n);if(a.length>0)throw new i(a)}(e.cardSettings),c){const n=F(Y({stagingToken:a})),o=await c(n),i=B(o).body;return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r},cardIframeUrl:i.url})}{const i=n||o(),c=await async function(e){const t=Y(e),{embed_auth_link:n}=await j(t);return n}({...e.cardSettings,accessToken:i,stagingToken:a});return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r,mfaPreference:s},cardIframeUrl:c.url})}}catch(e){return Promise.reject(e)}}},Se=Ae;function Ie(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function $e({endpointUrl:e,paginationSettings:t}){return function({url:e,searchParams:t}){const n=new URL(e.toString());for(const[e,a]of t.entries())n.searchParams.append(e,a);return n}({url:new URL(e),searchParams:Ie(t)})}function Re(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function Pe(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function Ce(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const Le="/v2/sepa/beneficiaries";function Ne({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Le}${o}`,options:a}}function qe({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${Le}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Oe({accessToken:e,stagingToken:t,beneficiaryId:n}){const a=qe({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:r}=await j(a);return r}function De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){return{path:Le,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:a},body:{beneficiary:Ce(e)}}}}function Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${Le}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}function xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const{name:o,email:i,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r},body:{beneficiary:{name:o,email:i,activity_tag:s}}};return{path:`${Le}/${e.id}`,options:c}}const Me=[{name:"name"},{name:"iban"}];const ze={getBeneficiaries:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(Ne({paginationSettings:r})),t=B(await n(e)),a=t.body.beneficiaries.map((e=>Pe(e))),o=Re(t.body.meta);return{beneficiaries:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a=Ne({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:r,meta:o}=await j(a);return{beneficiaries:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.beneficiaries.map((e=>Pe(e))),s=Re(n.meta);return{beneficiaries:i,...s?{meta:s}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(qe({beneficiaryId:n}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o();return Pe(await Oe({beneficiaryId:n,accessToken:e,stagingToken:s}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new i("beneficiary must be an object");Q(e,Me);const t=X({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new i(t);return e}(e),{proxyRequestFunction:a,accessToken:r,stagingToken:s,idempotencyKey:c}=I(t||{});if(a){const e=F(De({beneficiary:n,idempotencyKey:c}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o(),t=await async function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){const r=De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a}),{beneficiary:o}=await j(r);return o}({beneficiary:n,accessToken:e,stagingToken:s,idempotencyKey:c});return Pe(t)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:a,activityTag:r}=e||{};if(!t)throw new i("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!r)throw new i("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=X({name:n,email:a,activityTag:r});if(o.length>0)throw new i(o);return{id:t,name:n,email:a,activityTag:r}}(e),{stagingToken:a,idempotencyKey:r,mfaPreference:s,proxyRequestFunction:c}=I(t),d={beneficiaryParamsBeingEdited:n,idempotencyKey:r,mfaPreference:s};if(c){const e=F(xe(d));return Pe(B(await c(e)).body.beneficiary)}{const e=t?.accessToken||o(),n=await async function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const o=xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}),{beneficiary:i}=await j(o);return i}({...d,accessToken:e,stagingToken:a});return Pe(n)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new i("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ue({beneficiaryIds:n}));return B(await a(e)).body.beneficiaries.map(Pe)}{const e=r||o(),t=await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const a=Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:r}=await j(a);return r}({beneficiaryIds:n,accessToken:e,stagingToken:s});return t.map(Pe)}}},je=ze;function Fe(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Be(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}function He(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function Ge(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}function Ke(e){return{name:e.name,iban:e.iban}}const Ye="/v2/sepa",Ve=`${Ye}/transfers`;function We({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Ve}${o}`,options:a}}function Ze({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Je({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}async function Qe({sepaPayee:e,accessToken:t,stagingToken:n}){const a=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await j(a)}const Xe="/v2/sepa/bulk_transfers";async function et({sepaPayees:e,accessToken:t,stagingToken:n}){const a=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Ke)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await j(a)}function tt(e){if(!e)throw new i("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new i("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new i("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new i("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new i(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new i(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=X({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),a=te({amount:e.amount}),r=[...n,...a].flat();if(r.length>0)throw new i(r);if(e.amount>p&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new i(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const nt="browser",at="server";class rt extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case nt:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case at:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const ot=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function it(e,t){const n=t?.locale||L.getLocale(),a=new URL(e);return n&&a.searchParams.append("lang",n),t?.mfaPreference&&a.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&a.searchParams.append("idempotencyKey",t.idempotencyKey),a.toString()}function st(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}const ct={request:async function({requestSettings:e,operationSettings:t}){!function(e){if(!e||"object"!=typeof e)throw new i("requestSettings must be an object");const t=e,{action:n,callbackUrl:a}=e;Q(t,[{name:"action"}]);const r=X(t),o=Object.values(m);if(o.includes(n)||r.push(`action must be one of ${o.join(", ")}`),r.length>0)throw new i(r);if(void 0!==a&&""===a.trim())throw new i("callbackUrl cannot be empty")}(e);const{proxyRequestFunction:n,stagingToken:a}=I(t||{});if(n){const t=F(H({stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}));return st(B(await n(t)).body)}{const n=t?.accessToken||o();return st(await async function(e){const t=H({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await j(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}({accessToken:n,stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}))}}};async function dt(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(We({paginationSettings:r})),t=B(await n(e)),a=t.body.transfers.map(He),o=Re(t.body.meta);return{transfers:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a=We({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:r,meta:o}=await j(a);return{transfers:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.transfers.map(He),s=Re(n.meta);return{transfers:i,...s?{meta:s}:{}}}}const lt={getSepaTransfers:dt,getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ze({sepaTransferId:n}));return He(B(await a(e)).body.transfer)}{const e=r||o(),t=await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a=Ze({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:r}=await j(a);return r}({sepaTransferId:n,accessToken:e,stagingToken:s});return He(t)}},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),s=t?.idempotencyKey||ge();let d;!function(e){if(!e)throw new i("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new i("sepaTransferSettings must be an object");if(Q(e,ot),!e.beneficiaryId&&!e.beneficiary)throw new i("Either beneficiaryId or beneficiary must be provided");const t=[...X({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...te({amount:e.amount})].flat();if(t.length>0)throw new i(t);if(e.amount>p&&(!e.attachmentIds||0===e.attachmentIds.length))throw new i("Attachments are required for transfers over €30,000")}(e);const l=await async function({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:Pe(await Oe({beneficiaryId:e?.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}({sepaTransferSettings:e,operationSettings:{accessToken:a,stagingToken:r||void 0}}),u={name:l.name,iban:l.iban},g=await Qe({sepaPayee:u,accessToken:a,stagingToken:r||void 0});var f;if((yield(f=g,{matchResult:f.match_result,matchedName:f.matched_name}))===h.REJECT)return;const m={...e,beneficiary:l};if(m.beneficiary?.trusted)d=await async function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:a,idempotencyKey:r}){const o=Ge(e),i={method:"POST",headers:z({accessToken:n,stagingToken:a,idempotencyKey:r}),body:JSON.stringify({transfer:o,vop_proof_token:t})},s=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ve}`,c=await fetch(s,i),d=await c.json();if(d.errors)throw new U(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.transfer}({transfer:m,vopProofToken:g.proof_token.token,accessToken:a,stagingToken:r||void 0,idempotencyKey:s});else{if(!x())throw new rt(nt);const{uiParentElementId:e,debugMode:n}=I(t,{requiresUI:!0});let o;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:n});o=await me({iframeUrl:t,parentElementId:e});const i=Ge(m);d=await o.postMessage(fe({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...i}},idempotencyKey:s}}))}finally{o?.destroy()}}return He(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Je({sepaTransferId:n}));B(await a(e))}else{const e=r||o();await async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a=Je({sepaTransferId:e,accessToken:t,stagingToken:n});await j(a)}({sepaTransferId:n,accessToken:e,stagingToken:s})}},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new i("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new i("callbackUrl must be a string");return e.callbackUrl}(e),{proxyRequestFunction:a,stagingToken:r,accessToken:s}=I(t||{}),c=a?{proxyRequestFunction:a}:{stagingToken:r,accessToken:s||o()},d=await ct.request({requestSettings:{action:m.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:c});return{...d,url:it(d.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:t}=e||{},n=t?.accessToken||o(),{stagingToken:a,paginationSettings:r}=I(t||{}),i=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=$e({endpointUrl:new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}`),paginationSettings:n}),o=await fetch(r,a);if(!o.ok)throw new U("Failed to fetch SEPA bulk transfers");const i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:i.bulk_transfers,meta:i.meta}}({accessToken:n,stagingToken:a,paginationSettings:r}),s=i.bulkTransfers?.map(Fe),c=Re(i.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||o(),{stagingToken:a}=I(t||{}),r=function(e){if(!e)throw new i("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new i("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Fe(await async function({accessToken:e,stagingToken:t,bulkTransferId:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}/${n}`),o=await fetch(r,a),i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return i.bulk_transfer}({accessToken:n,stagingToken:a,bulkTransferId:r}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),i=t?.idempotencyKey||ge();tt(e);const{uiParentElementId:s,debugMode:d}=I(t,{requiresUI:!0});if(!x())throw new rt(nt);const l=new Map;for(const t of e.bulkTransfers){const e=t.beneficiary.iban;e&&!l.has(e)&&l.set(e,{name:t.beneficiary.name,iban:e})}const u=Array.from(l.values()),g=await et({sepaPayees:u,accessToken:a,stagingToken:r||void 0});if((yield g.requests.map(Be))===h.REJECT)return;let f,p;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:d});p=await me({iframeUrl:t,parentElementId:s});const n={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};f=await p.postMessage(fe({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:n,idempotencyKey:i}}))}finally{p?.destroy()}return Fe(f)}}},ut={GOOD:"good",SERVICE:"service"},gt={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},ft=e=>{if(!(e=>Object.values(gt).includes(e))(e))throw new i(`currency ${e} is not valid, valid currencies are ${Object.values(gt).join(", ")}`)},pt={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},ht=e=>{if(!(e=>Object.values(pt).includes(e))(e))throw new i(`unit ${e} is not valid, valid units are ${Object.values(pt).join(", ")}`)},mt=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],bt=[{name:"currency"},{name:"value"}];const yt=e=>{if(!Object.values(ut).includes(e))throw new i(`type ${e} is not valid, valid types are ${Object.values(ut).join(", ")}`)},vt={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e})=>{const{items:t,authUrl:n}=e;!function(e){if(!e)throw new i("authUrl is required for the called function");const t=X({authUrl:e});if(t.length>0)throw new i(t);try{new URL(e)}catch{throw new i("authUrl is not a valid URL")}}(n),function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{Q(e,mt),Q(e.unitPrice,bt);const t=[...X({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...te({quantity:e.quantity})].flat();if(t.length>0)throw new i(t);yt(e.type),ft(e.unitPrice.currency),ht(e.measureUnit)}))}(t);const a=new URLSearchParams({...t?{items:JSON.stringify(t)}:{}});return a.toString()?`${n}?${a.toString()}`:n}},_t=({accessToken:e,stagingToken:t})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}),wt=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),Tt={getBankAccounts:async e=>{const{stagingToken:t,proxyRequestFunction:n}=I(e);if(n){const e=_t({stagingToken:t}),a=await n(F(e)),{body:r}=B(a);return r.organization.bank_accounts.map(wt)}{const n=e.accessToken||o(),a=await(async({accessToken:e,stagingToken:t})=>{const n=_t({accessToken:e,stagingToken:t});return await j(n)})({accessToken:n,stagingToken:t});return a.organization.bank_accounts.map(wt)}}},kt="/v2/transactions";function Et({bankAccountId:e,iban:t,status:n,updatedAtFrom:a,updatedAtTo:r,emittedAtFrom:o,emittedAtTo:i,settledAtFrom:s,settledAtTo:c,side:d,operationType:l,withAttachments:u,paginationSettings:g,accessToken:f,stagingToken:p}){const h={method:"GET",headers:{accessToken:f,stagingToken:p}},m=new URLSearchParams;e&&m.append("bank_account_id",e),t&&m.append("iban",t),n&&m.append("status",n),a&&m.append("updated_at_from",a),r&&m.append("updated_at_to",r),o&&m.append("emitted_at_from",o),i&&m.append("emitted_at_to",i),s&&m.append("settled_at_from",s),c&&m.append("settled_at_to",c),d&&m.append("side",d),l&&m.append("operation_type",l),void 0!==u&&m.append("with_attachments",String(u));const b=Ie(g);for(const[e,t]of b)m.append(e,t);const y=m.toString();return{path:`${kt}${y?`?${y}`:""}`,options:h}}function At({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${kt}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function St(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const It={getTransactions:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{}),i={...e?.transactionSettings||{},paginationSettings:r};if(n){const e=F(Et(i)),t=B(await n(e));return{transactions:t.body.transactions.map(St),meta:t.body.meta}}{const e=a||o(),n=await async function(e){const t=Et(e),{transactions:n,meta:a}=await j(t);return{transactions:n,meta:a}}({...i,accessToken:e,stagingToken:t});return{transactions:n.transactions.map(St),meta:n.meta}}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{proxyRequestFunction:n,accessToken:a,stagingToken:r}=I(t||{}),{transactionId:s}=function(e){if(!e)throw new i("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new i("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new i("transactionSettings.transactionId must be a string.");return e}(e);if(n){const e=F(At({transactionId:s}));return St(B(await n(e)).body.transaction)}{const e=a||o();return St(await async function(e){const t=At(e),{transaction:n}=await j(t);return n}({transactionId:s,accessToken:e,stagingToken:r}))}}},$t=It;function Rt(e,t,n,a){var r,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(i=(o<3?r(i):o>3?r(t,n,i):r(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}"function"==typeof SuppressedError&&SuppressedError;
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2019 Google LLC
|
|
@@ -687,4 +687,4 @@ const Wa=2;class Za{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n)
|
|
|
687
687
|
>${Wn("Next")}</qonto-button
|
|
688
688
|
</div>
|
|
689
689
|
</div>`:""}
|
|
690
|
-
`}};pr.styles=ma,Rt([Bn({type:Object})],pr.prototype,"operationSettings",void 0),Rt([Bn({type:String})],pr.prototype,"locale",void 0),Rt([Hn()],pr.prototype,"transfers",void 0),Rt([Hn()],pr.prototype,"paginationState",void 0),Rt([Hn()],pr.prototype,"isLoading",void 0),Rt([Hn()],pr.prototype,"error",void 0),pr=Rt([(e,t)=>(e.addInitializer(Qn),e),zn("qonto-transfer-list")],pr);const hr={TRANSFER_LIST:"transfer-list"};e
|
|
690
|
+
`}};pr.styles=ma,Rt([Bn({type:Object})],pr.prototype,"operationSettings",void 0),Rt([Bn({type:String})],pr.prototype,"locale",void 0),Rt([Hn()],pr.prototype,"transfers",void 0),Rt([Hn()],pr.prototype,"paginationState",void 0),Rt([Hn()],pr.prototype,"isLoading",void 0),Rt([Hn()],pr.prototype,"error",void 0),pr=Rt([(e,t)=>(e.addInitializer(Qn),e),zn("qonto-transfer-list")],pr);const hr={TRANSFER_LIST:"transfer-list"};class mr extends a{constructor(e){super(),this.name="EmbedUIElementError",this.message=e}}const br={createUIElement:async e=>{if(M())return;const{uiElementSettings:t,operationSettings:n={}}=e,{uiElementName:a}=function(e){if(!e?.uiElementName)throw new i("uiElementSettings.uiElementName is required when calling createUIElement");const t=Object.values(hr);if(!t.includes(e?.uiElementName))throw new i(`uiElementSettings.uiElementName must be one of ${t.join(", ")}`);return{uiElementName:e.uiElementName}}(t),{uiParentElementId:r}=I(n,{requiresUI:!0}),o=document.getElementById(r);if(!o)throw new mr(`Could not find container element with id: ${r}`);if(a===hr.TRANSFER_LIST)return void function({containerElement:e,uiElementSettings:t,operationSettings:n}){const a=document.createElement("qonto-transfer-list");a.operationSettings=n,a.locale=n?.locale||L.getLocale(),a.addEventListener("transfer-selected",(e=>{t?.uiElementEventListener?.({eventName:"transfer-selected",eventDetail:e.detail})})),e.appendChild(a)}({containerElement:o,uiElementSettings:t,operationSettings:n});const s=document.createElement(`qonto-${a}`);o.appendChild(s)}};e.authLinks=ct,e.beneficiaries=je,e.cards=Se,e.constants=D,e.initialize=q,e.logout=O,e.organizations=Tt,e.paymentLinks=vt,e.sepaTransfers=lt,e.transactions=$t,e.ui=br}));
|
|
@@ -69,6 +69,8 @@ export declare const ACCOUNT_STATUS: {
|
|
|
69
69
|
readonly PENDING: "pending";
|
|
70
70
|
};
|
|
71
71
|
export type OrganizationDataObject = {
|
|
72
|
-
|
|
72
|
+
organization: {
|
|
73
|
+
bank_accounts: BankAccountDataObject[];
|
|
74
|
+
};
|
|
73
75
|
};
|
|
74
76
|
//# sourceMappingURL=organizations.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizations.types.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"organizations.types.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE;QACZ,aAAa,EAAE,qBAAqB,EAAE,CAAC;KACxC,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{QontoEmbedSdkError as r}from"./QontoEmbedSdkError.js";class e extends r{constructor(r){super(),this.name="EmbedUIElementError",this.message=r}}export{e as EmbedUIElementError};
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";export{sepaTransfers}from"./sepa-transfers/index.js";export{paymentLinks}from"./payment-links/index.js";export{organizations}from"./organizations/index.js";export{transactions}from"./transactions/index.js";export{authLinks}from"./auth-links/index.js";export{
|
|
1
|
+
export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";export{sepaTransfers}from"./sepa-transfers/index.js";export{paymentLinks}from"./payment-links/index.js";export{organizations}from"./organizations/index.js";export{transactions}from"./transactions/index.js";export{authLinks}from"./auth-links/index.js";export{ui}from"./ui/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeNetworkCall as n}from"../common/network/network.js";const o=({accessToken:n,stagingToken:o})=>({path:"/v2/
|
|
1
|
+
import{makeNetworkCall as n}from"../common/network/network.js";const o=({accessToken:n,stagingToken:o})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}),e=async({accessToken:e,stagingToken:s})=>{const t=o({accessToken:e,stagingToken:s});return await n(t)};export{e as getOrganization,o as prepareGetOrganization};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../common/auth/auth.js";import{validatePresenceOfAuthToken as o}from"../common/auth/auth.validate.js";import{prepareGetOrganization as
|
|
1
|
+
import"../common/auth/auth.js";import{validatePresenceOfAuthToken as o}from"../common/auth/auth.validate.js";import{prepareGetOrganization as n,getOrganization as t}from"./organizations.api.js";import{serializeBankAccount as a}from"./organizations.serializer.js";import{validateOperationSettingsParams as i}from"../validation/operation-settings-validation.js";import{encodeNetworkCall as r,decodeNetworkResponse as s}from"../common/network/network.js";const e=async e=>{const{stagingToken:m,proxyRequestFunction:c}=i(e);if(c){const o=n({stagingToken:m}),t=await c(r(o)),{body:i}=s(t);return i.organization.bank_accounts.map(a)}{const n=e.accessToken||o();return(await t({accessToken:n,stagingToken:m})).organization.bank_accounts.map(a)}};export{e as getBankAccounts};
|
package/dist/src/ui/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{ui as i}from"./ui-elements.public-api.js";const e=i;export{e as ui};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./customizable-components/transfer-list/transfer-list.js";import{isRunningInServer as t}from"../common/runtime/runtime.validation.js";import{validateCreateUIElementParams as e}from"./ui-elements.validation.js";import{validateOperationSettingsParams as n}from"../validation/operation-settings-validation.js";import{UI_ELEMENT_NAMES as i}from"./ui-elements.constants.js";import{createTransferListElement as o}from"./ui-elements/transfer-list.js";import{EmbedUIElementError as r}from"../errors/EmbedUIElementError.js";const m=async m=>{if(t())return;const{uiElementSettings:s,operationSettings:a={}}=m,{uiElementName:l}=e(s),{uiParentElementId:u}=n(a,{requiresUI:!0}),d=document.getElementById(u);if(!d)throw new r(`Could not find container element with id: ${u}`);if(l===i.TRANSFER_LIST)return void o({containerElement:d,uiElementSettings:s,operationSettings:a});const p=document.createElement(`qonto-${l}`);d.appendChild(p)};export{m as createUIElement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createUIElement as e}from"./ui-elements.js";const t={createUIElement:e};export{t as ui};
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The ui namespace contains all the functions related to UI Elements.
|
|
3
|
+
* It can be accessed like this:
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { ui } from '@qonto/embed-sdk/ui';
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Then, the ui object contains the functions to perform UI Element operations:
|
|
9
|
+
* ```ts
|
|
10
|
+
* await ui.createUIElement(/* params here *\/);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const ui: {
|
|
14
|
+
createUIElement: (createUIElementParams: import("./ui-elements.types").UIElementParams<unknown>) => Promise<void>;
|
|
15
|
+
};
|
|
4
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,EAAE;;CAAyB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './customizable-components';
|
|
2
|
+
import type { UIElementParams } from '@ui/ui-elements.types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a UI element based on the provided settings and appends it to the specified parent container.
|
|
5
|
+
* As the bare minimum, the `uiElementSettings` must include the `uiElementName`, and the `operationSettings`
|
|
6
|
+
* must include the `uiParentElementId` where the new element will be appended. This function requires
|
|
7
|
+
* authentication, which can be passed via the {@link OperationSettings} object.
|
|
8
|
+
* @param createUIElementParams - Parameters for creating the UI element, including settings for the element
|
|
9
|
+
* and operation:
|
|
10
|
+
* - `uiElementSettings` - Settings for the UI element to be created. Must include `uiElementName`, which
|
|
11
|
+
* determines the type of element to create. Example: `{ uiElementName: 'transfer-list' }`.
|
|
12
|
+
* - `operationSettings` - Settings for the operation, including the `uiParentElementId` where the new element
|
|
13
|
+
* will be appended. Must also include authentication details if required.
|
|
14
|
+
* @throws InvalidParametersError - Thrown if required parameters are missing or invalid in `uiElementSettings`
|
|
15
|
+
* or `operationSettings`.
|
|
16
|
+
* @throws EmbedUIElementError - Thrown if the specified parent container element cannot be found in the DOM.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createUIElement: (createUIElementParams: UIElementParams<unknown>) => Promise<void>;
|
|
19
|
+
//# sourceMappingURL=ui-elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-elements.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,uBAAuB,CAAC;AAMhF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAC1B,uBAAuB,eAAe,CAAC,OAAO,CAAC,KAC9C,OAAO,CAAC,IAAI,CA8Bd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-elements.public-api.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.public-api.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,EAAE;;CAEd,CAAC"}
|
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
import type { OperationSettings } from '@validation/operation-settings-validation';
|
|
2
2
|
import { UI_ELEMENT_NAMES } from '@ui/ui-elements.constants';
|
|
3
|
+
/**
|
|
4
|
+
* Type representing the valid names of UI elements.
|
|
5
|
+
*/
|
|
3
6
|
type UIElementNames = (typeof UI_ELEMENT_NAMES)[keyof typeof UI_ELEMENT_NAMES];
|
|
7
|
+
/**
|
|
8
|
+
* Common event format for UI elements. Consists of two properties:
|
|
9
|
+
* `eventName` and optional `eventDetail`.
|
|
10
|
+
* The `eventName` property is a string that identifies the type of event
|
|
11
|
+
* emitted by the UI element.
|
|
12
|
+
* The `eventDetail` property is an optional object that contains additional
|
|
13
|
+
* information about the event. The structure of this object will depend on
|
|
14
|
+
* the specific event being emitted.
|
|
15
|
+
*/
|
|
4
16
|
interface UIElementEvent {
|
|
5
17
|
eventName: string;
|
|
6
18
|
eventDetail?: Record<string, unknown>;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Common settings format for UI elements. Consists of three properties:
|
|
22
|
+
* `uiElementName`, `uiElementParams`, and `uiElementEventListener`.
|
|
23
|
+
* The `uiElementName` property is required and specifies the type of UI element
|
|
24
|
+
* to render.
|
|
25
|
+
* The `uiElementParams` property is a generic object that holds parameters that
|
|
26
|
+
* will depend on the specific UI element being created.
|
|
27
|
+
* The `uiElementEventListener` property is a callback function that will be
|
|
28
|
+
* invoked when the UI element emits events. It receives an event object
|
|
29
|
+
* containing the event name and optional event details. Each UI element
|
|
30
|
+
* will define its own set of events that can be listened to.
|
|
31
|
+
*/
|
|
8
32
|
export interface UIElementSettings<T> {
|
|
9
33
|
uiElementName: UIElementNames;
|
|
10
|
-
uiElementParams
|
|
11
|
-
uiElementEventListener
|
|
34
|
+
uiElementParams?: T;
|
|
35
|
+
uiElementEventListener?: (event: UIElementEvent) => void;
|
|
12
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Common parameter format for UI element operations. Consists of an object with
|
|
39
|
+
* two properties: `uiElementSettings` and `operationSettings`.
|
|
40
|
+
* The `uiElementSettings` property is required and contains settings specific
|
|
41
|
+
* to the UI element being operated on. As the bare minimum, it must include
|
|
42
|
+
* the `uiElementName` to identify the type of UI element to be rendered.
|
|
43
|
+
* The `operationSettings` property is optional (if it has been passed to the
|
|
44
|
+
* initialize function previously) and contains settings related
|
|
45
|
+
* to the overall operation. For UI elements, it has to include at least the
|
|
46
|
+
* `uiParentElementId`, which specifies the DOM element where the UI element
|
|
47
|
+
* will be appended. In addition, it may include authentication details, in which
|
|
48
|
+
* the preferred method is to provide a `proxyRequestFunction`.
|
|
49
|
+
*/
|
|
13
50
|
export interface UIElementParams<T> {
|
|
14
51
|
uiElementSettings: UIElementSettings<T>;
|
|
15
52
|
operationSettings?: OperationSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-elements.types.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE/E,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,aAAa,EAAE,cAAc,CAAC;IAC9B,eAAe,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ui-elements.types.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;GAEG;AACH,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE/E;;;;;;;;GAQG;AACH,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,aAAa,EAAE,cAAc,CAAC;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC;IACpB,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACxC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
|