@pybara/pybara-js 0.5.0 → 0.7.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/README.md CHANGED
@@ -75,6 +75,7 @@ The code above is all an AI builder needs. The one thing code can't do: the site
75
75
  | `platform` | `string` | | Your integration's slug in the payment log, `a-z 0-9 -` (default `'pybara-js'`) |
76
76
  | `pluginVersion` | `string` | | Set by plugins — skips the autonomous-embed terms gate |
77
77
  | `staging` / `debug` | `boolean` | | Staging canisters + wallet / console logging |
78
+ | `onAvailability(availability)` | `function` | | Whether a payment would go through right now, before any click — see [Availability](#availability) |
78
79
 
79
80
  ### `checkout.open(payment)` → `Promise<void>`
80
81
 
@@ -91,6 +92,27 @@ The code above is all an AI builder needs. The one thing code can't do: the site
91
92
  | `onSuccess(result)` | `function` | Payment confirmed — `result` carries block height, token, principals |
92
93
  | `onError(err)` `onClose()` | `function` | Checkout refusals (`EmbeddedError`, `err.code`) / modal closed |
93
94
 
95
+ ### Availability
96
+
97
+ With `onAvailability` set, Pybara tells the page — before any click — whether a payment would go through, so you show the option only when it works:
98
+
99
+ ```js
100
+ const pybara = Pybara.checkout({
101
+ recipientPrincipal, siteUrl, siteName, currency: 'EUR',
102
+ onAvailability: ({ status, message }) => {
103
+ payButton.hidden = status === 'unavailable'; // the site isn't set up, or the currency isn't served
104
+ payButton.disabled = status === 'below-minimum'; // message: "Minimum €0.70", in the payer's language
105
+ hint.textContent = status === 'below-minimum' ? message : '';
106
+ },
107
+ });
108
+ amountInput.addEventListener('input', () => pybara.precheck({ amount: amountInput.value }));
109
+ ```
110
+
111
+ - **Called once on its own** when the checkout is ready (the site and its currency), then after each `checkout.precheck({ amount, currency })`. Call `precheck()` whenever the amount or currency changes; only the latest is answered.
112
+ - **Act on `status`:** `available`; `unavailable` (hide Pybara: nothing on the page can fix it); `below-minimum` (keep it, disable the button, show `message`; `minimum` is `{ amount, currency }`); `retry-later` (keep it: the click tries again).
113
+ - **`message`** is in the payer's language, ready to show. **`detail`**, in English, says what's missing and who fixes it — e.g. the site owner's DNS record or terms — and is printed to the console. **`reason`** is for debugging only: never branch on it.
114
+ - Without `onAvailability`, nothing changes: `open()` checks everything at the click, as always.
115
+
94
116
  ### Errors
95
117
 
96
118
  `open()` rejects with a `PybaraError` (`err.code`) when the checkout can't open:
@@ -55,6 +55,9 @@
55
55
  "type": "string",
56
56
  "description": "The checkout's language, a BCP 47 tag ('fr', 'de-DE', 'zh-CN'), usually the site's: shown when Pybara has it, otherwise the payer's own language."
57
57
  },
58
+ "onAvailability": {
59
+ "description": "function (Availability) => void — whether a payment would go through right now, before any click: called once the checkout is ready, then after each precheck({ amount, currency }). Act on availability.status: 'available' (show Pybara), 'unavailable' (hide it: nothing on the page can fix it), 'below-minimum' (disable the button and show availability.message, e.g. 'Minimum €0.70'), 'retry-later' (keep it). availability.detail, in English, says what is missing and who fixes it, and is also printed to the console. Never branch on availability.reason. Not expressible in JSON."
60
+ },
58
61
  "thankYouRedirectUrl": {
59
62
  "type": "string",
60
63
  "format": "uri",
@@ -142,6 +145,30 @@
142
145
  "onError": { "description": "function (Error) => void — called on frame-level errors; not expressible in JSON." },
143
146
  "onClose": { "description": "function () => void — called when the payer closes the checkout; not expressible in JSON." }
144
147
  }
148
+ },
149
+ "buttons": {
150
+ "title": "checkout.buttons(options)",
151
+ "description": "A 'Pybara' button, served by Pybara, that opens this checkout on the payer's click. Draw it with .render(element or selector), as often as wanted; .destroy() removes them. Its look follows availability by itself; call checkout.precheck({ amount, currency }) when the form changes.",
152
+ "type": "object",
153
+ "additionalProperties": false,
154
+ "required": ["createPayment"],
155
+ "properties": {
156
+ "style": {
157
+ "type": "object",
158
+ "description": "Passed to the button as given. Copy a PayPal button's style and the two match.",
159
+ "properties": {
160
+ "color": { "type": "string", "description": "'brand' | 'black' | 'white' (PayPal's names; its 'gold', 'blue', 'silver' read as 'brand'). Default 'brand'." },
161
+ "shape": { "type": "string", "description": "'pill' | 'rect' | 'sharp'. Default 'pill'." },
162
+ "height": { "type": "number", "minimum": 25, "maximum": 55, "description": "CSS pixels, PayPal's range. Default 45." }
163
+ }
164
+ },
165
+ "hideWhenUnavailable": { "type": "boolean", "description": "Collapse the button to no height when Pybara is unavailable here; by default its slot stays, empty." },
166
+ "createPayment": { "description": "function () => payment | Promise<payment> — called on the click: the payment from the form's current values, as open() takes it (amount, currency, frequency, donor fields), without callbacks; not expressible in JSON." },
167
+ "onStateChange": { "description": "function (Availability) => void — the checkout's availability answer, once per answer; e.g. show availability.message below the minimum. Not expressible in JSON." },
168
+ "onSuccess": { "description": "function (CheckoutResult) => void — the payment is confirmed on-chain; not expressible in JSON." },
169
+ "onError": { "description": "function (Error) => void — a refusal from createPayment(), open() or the checkout; not expressible in JSON." },
170
+ "onClose": { "description": "function () => void — the payer closed the checkout; not expressible in JSON." }
171
+ }
145
172
  }
146
173
  }
147
174
  }
@@ -0,0 +1,11 @@
1
+ import { Availability } from './modal/modal';
2
+ import { ButtonsOptions, PaymentParams, PybaraButtons } from './types';
3
+ /** What the loader needs from its checkout: the frame's origin, open(), and the availability answers. */
4
+ export interface ButtonsHost {
5
+ walletUrl: string;
6
+ open(payment: PaymentParams): Promise<void>;
7
+ /** Subscribes to every availability answer, first with the latest one if there is one; returns the unsubscribe. */
8
+ subscribeAvailability(listener: (availability: Availability) => void): () => void;
9
+ }
10
+ export declare function createButtons(host: ButtonsHost, options: ButtonsOptions): PybaraButtons;
11
+ //# sourceMappingURL=buttons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buttons.d.ts","sourceRoot":"","sources":["../src/buttons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEnG,yGAAyG;AACzG,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,mHAAmH;IACnH,qBAAqB,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnF;AAoBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAqFvF"}
@@ -1,5 +1,5 @@
1
1
  import { WidgetGate } from './gate';
2
- import { CheckoutConfig, PaymentParams } from './types';
2
+ import { ButtonsOptions, CheckoutConfig, PaymentParams, PybaraButtons } from './types';
3
3
  /**
4
4
  * A bound checkout — what Pybara.checkout() returns.
5
5
  *
@@ -18,7 +18,30 @@ export declare class PybaraCheckout {
18
18
  private activePayment;
19
19
  /** All async binding work — open() awaits it so the gate and the iframe prewarm are resolved first. */
20
20
  readonly ready: Promise<void>;
21
+ /** The latest precheck()'s amount and currency, sent again to each rebuilt checkout frame. */
22
+ private lastPrecheck;
23
+ /** Every listener for availability answers: the config's onAvailability, and each rendered button. */
24
+ private readonly availabilityListeners;
25
+ /** The latest answer, handed to a listener as it subscribes. */
26
+ private latestAvailability;
21
27
  constructor(userConfig: CheckoutConfig);
28
+ /**
29
+ * A "Pybara" button, served by Pybara, that opens this checkout on the payer's click with the payment createPayment() returns.
30
+ * Its look follows availability by itself (disabled below the minimum, hidden when Pybara can't be used here); call precheck({ amount }) as the form changes.
31
+ * Render it as often as wanted, e.g. a one-time and a monthly button side by side: they share this one checkout.
32
+ */
33
+ buttons(options: ButtonsOptions): PybaraButtons;
34
+ private emitAvailability;
35
+ /**
36
+ * Ask whether a payment of this amount would go through right now; the answer arrives on the config's onAvailability.
37
+ * Call it again whenever the form's amount or currency changes: only the latest is answered.
38
+ * It changes nothing open() does, which checks everything again at the click.
39
+ */
40
+ precheck(params?: {
41
+ amount?: string | number;
42
+ currency?: string;
43
+ }): void;
44
+ private sendPrecheck;
22
45
  /** The autonomous-embed gate outcome once `ready` resolves — null while pending or under plugin terms (a plugin's host checks its own). */
23
46
  get gate(): WidgetGate | null;
24
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,aAAa,EAEnB,MAAM,SAAS,CAAC;AAcjB;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,MAAM,CAAS;IACvB,gIAAgI;IAChI,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,aAAa,CAA8B;IACnD,uGAAuG;IACvG,SAAgB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEzB,UAAU,EAAE,cAAc;IAKtC,2IAA2I;IAC3I,IAAI,IAAI,IAAI,UAAU,GAAG,IAAI,CAE5B;IAED;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA8EjD,4EAA4E;IAC5E,KAAK,IAAI,IAAI;YAIC,IAAI;IA8ClB,OAAO,CAAC,iBAAiB;IAsDzB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAmCnB,6FAA6F;IAC7F,OAAO,CAAC,gBAAgB;CAOzB"}
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,aAAa,EAElB,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by a release that needs new terms, so most updates keep showing on sites that accepted older ones. */
8
8
  export declare const REQUIRED_WIDGET_TERMS_VERSION = "1-0";
9
+ /** A refusal's `cause`: the configuration could not be read (transient), Pybara switched embeds off, or the site's terms are missing or outdated (the owner fixes it in Pybara Wallet). */
9
10
  export type WidgetGate = {
10
11
  show: false;
11
12
  reason: string;
13
+ cause: 'unreadable' | 'switched-off' | 'terms';
12
14
  } | {
13
15
  show: true;
14
16
  recurring: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,qKAAqK;AACrK,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAKnD,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAW9F,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAS1E;AAQD,mIAAmI;AACnI,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,UAAU,CAAC,CAkCrB"}
1
+ {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,qKAAqK;AACrK,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAKnD,2LAA2L;AAC3L,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,GAAG,cAAc,GAAG,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAW9I,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAS1E;AAQD,mIAAmI;AACnI,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,UAAU,CAAC,CAqCrB"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare const Pybara: {
9
9
  checkout: typeof checkout;
10
10
  };
11
11
  export { PybaraCheckout } from './checkout';
12
+ export { type Availability } from './modal/modal';
12
13
  export { type WidgetGate } from './gate';
13
- export { type CheckoutConfig, type CheckoutResult, type Frequency, type PaymentParams, PybaraError, type PybaraErrorCode, } from './types';
14
+ export { type ButtonPayment, type ButtonsOptions, type CheckoutConfig, type CheckoutResult, type Frequency, type PaymentParams, PybaraError, type PybaraButtons, type PybaraErrorCode, } from './types';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAE/D;AAID,eAAO,MAAM,MAAM;;CAAe,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAE/D;AAID,eAAO,MAAM,MAAM;;CAAe,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
@@ -11,5 +11,5 @@
11
11
  * This was `@pybara/pybara-ux` — absorbed into pybara-js so the SDK and its
12
12
  * modal kit version together.
13
13
  */
14
- export { CheckoutModal, EmbeddedError, type Checkout, type CheckoutModalConfig, type ModalData, type PaymentData, } from './modal.js';
14
+ export { CheckoutModal, EmbeddedError, type Availability, type Checkout, type CheckoutModalConfig, type ModalData, type PaymentData, type Precheck, } from './modal.js';
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,QAAQ,GACd,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- export { t as CheckoutModal, n as EmbeddedError } from "../modal-wfJS0oVP.js";
1
+ export { t as CheckoutModal, n as EmbeddedError } from "../modal-CvQ7qr5d.js";
@@ -35,6 +35,34 @@ export interface CheckoutModalConfig {
35
35
  onError?: (error: Error) => void;
36
36
  /** The modal has closed: a cancellation before any onSuccess, or the buyer leaving the success screen after one. */
37
37
  onClose?: () => void;
38
+ /** The frame's answer to each precheck(): whether a payment would go through right now. Called again after each new precheck(). */
39
+ onAvailability?: (availability: Availability) => void;
40
+ }
41
+ /**
42
+ * Whether a payment would go through right now, as the checkout frame answers a precheck().
43
+ * `status` is stable, and the one to act on: `available`; `unavailable`, which nothing on the page can fix (hide the option); `below-minimum`, with `minimum` in the precheck's currency (keep the option, disable its button, show the minimum); `retry-later`, transient (keep the option).
44
+ * `reason` is a code for debugging, which may be added to or renamed at any time: never branch on it.
45
+ * `message` is for the payer, in the checkout's language, ready to show as-is; `detail` is for the integrator, in English, and is also printed to the console.
46
+ */
47
+ export interface Availability {
48
+ status: 'available' | 'unavailable' | 'below-minimum' | 'retry-later';
49
+ reason?: string;
50
+ message?: string;
51
+ detail?: string;
52
+ minimum?: {
53
+ amount: string;
54
+ currency: string;
55
+ };
56
+ }
57
+ /** What a precheck() asks about. The site is always the page's own origin, as the browser reports it. */
58
+ export interface Precheck {
59
+ beneficiary: string;
60
+ /** The site URL the checkout will declare, which must sit on the page's origin. */
61
+ siteUrl?: string;
62
+ /** A decimal string in the currency's major units, as the checkout's amount. Without one, the minimum is not checked. */
63
+ amount?: string;
64
+ /** ISO 4217. Without one, neither the currency nor the minimum is checked. */
65
+ currency?: string;
38
66
  }
39
67
  /** What show() needs that only exists once the order or donation does — unlike CheckoutModalConfig, known at construction. */
40
68
  export interface PaymentData {
@@ -176,9 +204,18 @@ export declare class CheckoutModal {
176
204
  private iframeLoaded;
177
205
  /** Held by show() when it runs before `load`; the `load` handler sends it. */
178
206
  private pendingPaymentData;
207
+ /** Held by precheck() when it runs before `load`; the `load` handler sends the latest. */
208
+ private pendingPrecheck;
179
209
  constructor(config: CheckoutModalConfig);
180
210
  /** Backdrop and iframe, built at construction and hidden until open() — see the file header for why. */
181
211
  private createIframe;
212
+ /**
213
+ * Ask the frame whether a payment would go through right now; the answer arrives on onAvailability.
214
+ * Send it again whenever the amount changes: the frame answers the latest, at a rate it sets.
215
+ * It authorises nothing and changes nothing the checkout does: show() is checked again in full.
216
+ */
217
+ precheck(precheck: Precheck): void;
218
+ private sendPrecheck;
182
219
  private sendInitMessage;
183
220
  /**
184
221
  * Show the backdrop and its spinner now, before the payment data exists: a platform calls it on the buyer's click, while it still creates the order, so one overlay covers the whole sequence.
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,MAAM,WAAW,SAAS;IACtB,sJAAsJ;IACtJ,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,+JAA+J;IAC/J,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAChC,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB,6HAA6H;IAC7H,OAAO,EAAE,SAAS,GAAG,UAAU,CAAC;IAChC,2JAA2J;IAC3J,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kJAAkJ;IAClJ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qLAAqL;IACrL,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS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CAAC,kBAAkB,CAA4B;IACtD,0FAA0F;IAC1F,OAAO,CAAC,eAAe,CAAyB;gBAEpC,MAAM,EAAE,mBAAmB;IAMvC,wGAAwG;IACxG,OAAO,CAAC,YAAY;IA4IpB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAKlC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAevB;;;OAGG;IACH,IAAI,IAAI,IAAI;IASZ,uIAAuI;IACvI,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAS7B;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA2C1C;;;OAGG;IACH,KAAK,IAAI,IAAI;CAqChB"}
@@ -62,7 +62,7 @@ function h(e) {
62
62
  }
63
63
  var g = class {
64
64
  constructor(e) {
65
- this.overlay = null, this.iframe = null, this.spinner = null, this.handleMessage = null, this.handleEscapeKey = null, this.closable = !0, this.iframeLoaded = !1, this.pendingPaymentData = null, this.config = e, this.walletOrigin = new URL(e.walletUrl).origin, this.createIframe();
65
+ this.overlay = null, this.iframe = null, this.spinner = null, this.handleMessage = null, this.handleEscapeKey = null, this.closable = !0, this.iframeLoaded = !1, this.pendingPaymentData = null, this.pendingPrecheck = null, this.config = e, this.walletOrigin = new URL(e.walletUrl).origin, this.createIframe();
66
66
  }
67
67
  createIframe() {
68
68
  let n = document.createElement("div");
@@ -87,7 +87,7 @@ var g = class {
87
87
  duration: 1e3,
88
88
  iterations: Infinity
89
89
  }), r.addEventListener("load", () => {
90
- this.iframeLoaded = !0, this.pendingPaymentData &&= (this.sendInitMessage(this.pendingPaymentData), null);
90
+ this.iframeLoaded = !0, this.pendingPrecheck &&= (this.sendPrecheck(this.pendingPrecheck), null), this.pendingPaymentData &&= (this.sendInitMessage(this.pendingPaymentData), null);
91
91
  }, { once: !0 }), this.handleMessage = (e) => {
92
92
  if (e.origin === this.walletOrigin && e.source === r.contentWindow && h(e.data)) switch (e.data.type) {
93
93
  case "pybara_embedded_result":
@@ -116,12 +116,30 @@ var g = class {
116
116
  easing: "ease"
117
117
  }));
118
118
  break;
119
- case "pybara_embedded_closable": this.closable = e.data.closable;
119
+ case "pybara_embedded_closable":
120
+ this.closable = e.data.closable;
121
+ break;
122
+ case "pybara_embedded_availability": {
123
+ let { type: t, v: n, ...r } = e.data;
124
+ r.status !== "available" && r.detail && console.warn(r.detail), this.config.onAvailability?.(r);
125
+ break;
126
+ }
120
127
  }
121
128
  }, window.addEventListener("message", this.handleMessage), this.handleEscapeKey = (e) => {
122
129
  e.key === "Escape" && this.closable && (this.close(), this.config.onClose?.());
123
130
  }, document.addEventListener("keydown", this.handleEscapeKey), n.appendChild(i), n.appendChild(r), document.body.appendChild(n), this.overlay = n, this.iframe = r, this.spinner = i;
124
131
  }
132
+ precheck(e) {
133
+ this.iframeLoaded ? this.sendPrecheck(e) : this.pendingPrecheck = e;
134
+ }
135
+ sendPrecheck(e) {
136
+ this.iframe?.contentWindow?.postMessage({
137
+ type: "pybara_embedded_precheck",
138
+ v: 1,
139
+ context: this.config.context,
140
+ ...e
141
+ }, this.walletOrigin);
142
+ }
125
143
  sendInitMessage(e) {
126
144
  let t = {
127
145
  type: "pybara_embedded_init",
@@ -169,7 +187,7 @@ var g = class {
169
187
  close() {
170
188
  this.handleMessage &&= (window.removeEventListener("message", this.handleMessage), null), this.handleEscapeKey &&= (document.removeEventListener("keydown", this.handleEscapeKey), null), u();
171
189
  let e = this.overlay, n = this.iframe;
172
- this.overlay = null, this.iframe = null, this.spinner = null, this.iframeLoaded = !1, this.pendingPaymentData = null, this.closable = !0, e && (e.style.display === "none" || d() ? e.remove() : (e.style.pointerEvents = "none", n?.animate([{
190
+ this.overlay = null, this.iframe = null, this.spinner = null, this.iframeLoaded = !1, this.pendingPaymentData = null, this.pendingPrecheck = null, this.closable = !0, e && (e.style.display === "none" || d() ? e.remove() : (e.style.pointerEvents = "none", n?.animate([{
173
191
  transform: "scale(1)",
174
192
  opacity: 1
175
193
  }, {