@mrrocket/sdk 0.13.0 → 0.15.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/README.md +43 -3
  3. package/dist/api-client.d.ts +62 -1
  4. package/dist/api-client.js +28 -1
  5. package/dist/api-client.js.map +1 -1
  6. package/dist/browser/mrrocket-flows.js +11 -2
  7. package/dist/browser/mrrocket-messenger.js +304 -70
  8. package/dist/browser/mrrocket.js +1 -1
  9. package/dist/browser.d.ts +1 -1
  10. package/dist/browser.js +2 -1
  11. package/dist/browser.js.map +1 -1
  12. package/dist/client.d.ts +12 -0
  13. package/dist/client.js +22 -0
  14. package/dist/client.js.map +1 -1
  15. package/dist/context.d.ts +3 -0
  16. package/dist/context.js.map +1 -1
  17. package/dist/core.d.ts +4 -1
  18. package/dist/core.js +1 -1
  19. package/dist/core.js.map +1 -1
  20. package/dist/flows-ui.d.ts +6 -4
  21. package/dist/flows-ui.js +147 -5
  22. package/dist/flows-ui.js.map +1 -1
  23. package/dist/flows.d.ts +51 -1
  24. package/dist/flows.js +62 -21
  25. package/dist/flows.js.map +1 -1
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.js +4 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/messenger-ui.d.ts +37 -2
  30. package/dist/messenger-ui.js +597 -109
  31. package/dist/messenger-ui.js.map +1 -1
  32. package/dist/messenger.d.ts +11 -3
  33. package/dist/messenger.js +6 -3
  34. package/dist/messenger.js.map +1 -1
  35. package/dist/paywall.d.ts +123 -0
  36. package/dist/paywall.js +131 -0
  37. package/dist/paywall.js.map +1 -0
  38. package/dist/react-native/index.d.cts +235 -8
  39. package/dist/react-native/index.d.ts +235 -8
  40. package/dist/react-native/index.js +650 -184
  41. package/dist/react-native/index.js.map +1 -1
  42. package/dist/styles-css.d.ts +1 -1
  43. package/dist/styles-css.js +302 -68
  44. package/dist/styles-css.js.map +1 -1
  45. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -2,7 +2,14 @@
2
2
 
3
3
  All notable changes to this package. It follows semantic versioning; before 1.0 a minor version may change an API.
4
4
 
5
- ## 0.13.0 (not published yet)
5
+ ## 0.14.0 (not published yet)
6
+
7
+ - **Paywalls with pages:** a paywall from MRRocket › Conversion › Paywalls can have several pages (benefits, customer quotes, plans), served as the config's new `paywalls` per placement. `usePaywall().open(placement, { onPurchase, plans, onClose })` (Next.js and React Native, drawn by the provider), `mrrocket.paywall.open(…)` (script tag) show them one after another with Back and dots; the last page hands the chosen plan to `onPurchase`, where the app buys it (StoreKit/Play through RevenueCat or Adapty, Stripe Checkout). MRRocket never takes a payment; only after `onPurchase` resolves is the purchase recorded (`false`: the store sheet was cancelled, the paywall stays). Resolves with `{ outcome: "purchased" | "chosen" | "closed", plan, variant, index }`.
8
+ - **Tests per page:** a running paywall test gives each person their variant's pages (`assign`) and records `$exposure` when the paywall opens. New event `$paywall {paywall, placement, variant, page, index, action: "page" | "purchased" | "closed"}`: each page once per opening, so MRRocket shows drop-off between pages; a `purchased` counts as a test's purchase conversion.
9
+ - New module `paywall` with `createPaywallHost`, `paywallPages`, `PAYWALL_EVENT` and the types `PaywallConfig`, `PaywallPage`, `PaywallPlan`, `PaywallOptions`, `PaywallResult`; React Native `client.openPaywall`, `client.paywall`, `MRRocketFlows` takes `paywall`. The web dialog (`mountPaywall`) lives in `flows-ui` / `sdk-flows.js`; `sdk.js` stays within its 14.5 KB budget.
10
+ - Version reported in event batches: `0.14.0`.
11
+
12
+ ## 0.13.0
6
13
 
7
14
  - **Attack reports, from your server only** (`@mrrocket/sdk/next/server`, `watchRequest` and `reportSuspiciousRequest` also in `@mrrocket/sdk/next/proxy`): `reportFailedLogin({ userId, account, ip, reason })`, `reportAuthDenied({ status, path, ip, userId })`, `reportSuspiciousRequest({ path, query, ip, reason })` and `watchRequest(request)` for `proxy.ts`, which reads the path and query and reports only what looks like SQL injection, XSS, path traversal or a scanner's path (`/.env`, `/.git`, `/wp-admin`, `/phpmyadmin` …); an ordinary request sends nothing. They send `$login_failed`, `$auth_denied` and `$suspicious_request` with the product's server key (`MRROCKET_SERVER_KEY`); MRRocket hashes the IP and the account name on arrival (a daily hash) and its Build agent puts a possible attack into Needs you as Important. Every helper resolves to `true`/`false` and never throws. `attackIn(path, query)` and `ipOf(headers)` are exported too.
8
15
  - Nothing changes in the browser: the script tag and the client bundle stay as they were.
package/README.md CHANGED
@@ -406,6 +406,8 @@ const cancelFlow = useCancelFlow();
406
406
  const result = await cancelFlow.open({
407
407
  customer: account.isBusiness ? "business" : "consumer",
408
408
  price: { amount: 29, currency: "EUR" }, // optional: shows what the discount costs
409
+ plan: account.planId, // optional (0.15.0): for offers by plan, your billing's plan id or name
410
+ customerSince: account.paidSince, // optional (0.15.0): for offers by how long they have paid
409
411
  onCancel: (r) => api.cancelSubscription({ reason: r.reason, comment: r.comment }),
410
412
  onSave: (r) => api.applyOffer(r.offer), // { kind: "discount", percent, months } | { kind: "pause", months } | { kind: "downgrade", plan } | { kind: "contact" }
411
413
  });
@@ -416,6 +418,8 @@ const cancelFlow = useCancelFlow();
416
418
  </button>;
417
419
  ```
418
420
 
421
+ Since 0.15.0 an answer can ask one follow-up question, show a different offer by the follow-up's answer, the plan or how long the customer has paid (the first rule that fits wins; one about the plan or time needs `plan` / `customerSince`), and make a second offer once the first is declined. `result.answer` holds the follow-up's answer.
422
+
419
423
  MRRocket never changes a subscription (its payment key is read-only): `onCancel` and `onSave` are your code. Only after they succeed is the outcome recorded, and MRRocket shows it under Churn as a cancellation or a save with the customer's plan and monthly revenue (matched by your `identify()` id, or the email you passed with it). If one throws, the dialog stays open with "Something went wrong. Please try again." Script tag: `mrrocket.cancelFlow.open({ … })`.
420
424
 
421
425
  **Onboarding** (Conversion › Onboarding): the tour, checklist and modal steps of a live flow. A flow starts on its own when the person does its trigger: `track("Signed up")` (or `signup`, `sign_up`) for "Signed up", `track("first_export")` for "First export", and the first page or screen for "First launch" / "First visit", once per person. Automatic starts need a signed-in person (`identify`) or stored progress (`consent="cookies"` / `"persistent"`), so nobody gets the same tour on every page. `useCockpit().startOnboarding()` (script tag `mrrocket.onboarding.start()`, React Native `useOnboarding().start()`) starts one whenever you want; `onboarding={false}` on the provider switches the automatic start off. A tour step points at the element marked `data-ck-target="…"` (web); a checklist item with an event ticks itself when you track it. Emails of the flow go out from MRRocket.
@@ -483,9 +487,11 @@ const messenger = useMessenger();
483
487
  <a data-ck-messenger>Chat with us</a>;
484
488
  ```
485
489
 
486
- The look and texts (color, light or dark, side, title, greeting, button text, Help tab, sound, preview, asking for an email) are set per product in MRRocket › Support › Messenger and read by the messenger itself (`GET /api/sdk/messenger`), so they change without a deploy. What you pass in code wins.
490
+ The look and texts (color, light or dark, corners, Home's top, font, place, name, greeting, button text, Help tab, sound, preview, asking for an email, and "Powered by MRRocket", which Studio and Agency can switch off) are set per product in MRRocket › Support › Messenger and read by the messenger itself (`GET /api/sdk/messenger`), so they change without a deploy. What you pass in code wins.
491
+
492
+ Props: `title`, `greeting`, `launcher` (default true), `help` (the Help tab, default true; hidden while there is no published article), `sound` (default true), `preview` (default true), `askEmail` (default true), `position` ("bottom-right" default, "bottom-left", "bottom-center", "top-left", "top-center", "top-right", "middle-left", "middle-right"), `corners` ("round", "soft", "square"), `header` ("plain", "color"), `font` ("site", "system"), `label`, `theme`, `accent`. The panel is plain DOM, loaded with a dynamic import after the page rendered.
487
493
 
488
- Props: `title`, `greeting`, `launcher` (default true), `help` (the Help tab, default true; hidden while there is no published article), `sound` (default true), `preview` (default true), `askEmail` (default true), `position` ("bottom-right", "bottom-left"), `label`, `theme`, `accent`. The panel is plain DOM, loaded with a dynamic import after the page rendered.
494
+ Files (0.15): a paperclip in the message field attaches pictures (PNG, JPEG, WebP, GIF) and PDFs, pasting an image (Cmd/Ctrl+V) or dropping files onto the panel does too, and where the browser has `getDisplayMedia` (not on phones) the paperclip offers "Screenshot of this page": the tab is shared once (`preferCurrentTab`), the messenger hides for one frame, the stream stops. Each file uploads when picked (`POST /api/sdk/messages/attachments`, multipart `key`, `distinctId`, `file`; the server checks the bytes, never SVG, at most 10 MB) and answers a signed id; `sendChat({ body, attachments: [id, …] })` sends up to 4, and the body may then be empty. Sent files come back as `message.attachments` and are read with `api.attachmentUrl(id)` (the visitor's own chat only). Each message also sends `context: { viewport }`; the server adds browser and system from the user agent. In React Native the paperclip shows when `expo-image-picker` is installed (optional peer) and picks from the photo library; the app sends its system and screen size.
489
495
 
490
496
  Call `identify(user.id, { name, email })` and chats carry the person's name and email (they are not asked). While the panel is open it reads `GET /api/sdk/messages` every 4 seconds; while a visitor waits for an answer every 8 seconds for ten minutes, then every 30. Articles come from `GET /api/sdk/articles` as blocks, written with textContent, never HTML.
491
497
 
@@ -495,7 +501,7 @@ On sites with the script tag (Webflow, Framer, WordPress …) add `data-messenge
495
501
  <script async src="https://app.mrrocket.dev/sdk.js" data-key="mrr_pub_…" data-messenger="true" data-messenger-title="Acme"></script>
496
502
  ```
497
503
 
498
- Also `data-messenger-greeting`, `-label`, `-position="bottom-left"`, and "false" for `-help`, `-sound`, `-preview`, `-ask-email`. `mrrocket.messenger.open()` opens it from your code.
504
+ Also `data-messenger-greeting`, `-label`, `-position="top-right"`, `-corners="soft"`, `-header="color"`, `-font="system"`, and "false" for `-help`, `-sound`, `-preview`, `-ask-email`. `mrrocket.messenger.open()` opens it from your code.
499
505
 
500
506
  In React Native, `<MRRocketProvider messenger={{ launcher: true }}>` adds the bubble, `useMessenger().open()` opens it from your own button; a new answer shows as a banner at the top, with a light haptic when `expo-haptics` is installed. The provider also shows your live in-app survey (`surveys={false}` to switch off) and the feedback sheet (`useFeedback().open()`). With the person's consent (`replay`) and `react-native-view-shot` installed, the app also records sessions as screen pictures for Sessions: none while the keyboard is open, and `<MRRocketMask>` areas are painted black on the server before storing. Taps go to Heatmaps as clicks on the current screen; the provider then wraps the app in one `View` with `flex: 1` (`heatmaps={false}` to switch off).
501
507
 
@@ -545,6 +551,40 @@ await reportAuthDenied({ status: 403, path: url.pathname, ip: ipOf(request.heade
545
551
 
546
552
  They send `$login_failed`, `$auth_denied` and `$suspicious_request` to `/api/sdk/events` with `server: true`. MRRocket hashes the IP and the account name on arrival (a hash that changes every day) and never stores them as sent. Every helper resolves to `true` or `false` and never throws. Using WorkOS or Auth0 webhooks for sign-in? Their failed sign-ins (WorkOS `authentication.*_failed`, Auth0 log types `f`, `fp`, `fu`, `limit_wc`, `limit_mu`) are read without any code; subscribe the webhook to those events.
547
553
 
554
+ ## 21. Paywalls with pages (0.14.0)
555
+
556
+ A paywall built in MRRocket › Conversion › Paywalls can have several pages, for example **1** what you get, **2** what customers say, **3** the plans. The SDK shows them one after another; the last page's button hands the chosen plan to your `onPurchase`, where your code buys it. **MRRocket never takes a payment**: in apps you buy through StoreKit or Google Play (RevenueCat, Adapty), on the web through Stripe Checkout.
557
+
558
+ ```tsx
559
+ // React Native / Expo: the provider draws it
560
+ const paywall = usePaywall();
561
+ const result = await paywall.open("onboarding_end", {
562
+ plans: storePlans, // optional: [{ id: "annual", name: "Annual", price: "$49.99" }] with your store's local prices
563
+ onPurchase: async (plan) => {
564
+ const { customerInfo } = await Purchases.purchasePackage(packages[plan.id]);
565
+ return !!customerInfo.entitlements.active.pro; // false: the person cancelled the store sheet, the paywall stays
566
+ },
567
+ });
568
+ // result.outcome: "purchased" | "chosen" (no onPurchase: buy result.plan yourself) | "closed"
569
+ ```
570
+
571
+ ```tsx
572
+ // Next.js / React
573
+ const paywall = usePaywall();
574
+ <button onClick={() => paywall.open("feature_gate", { onPurchase: (plan) => startCheckout(plan.id) })}>Upgrade</button>
575
+ ```
576
+
577
+ ```js
578
+ // Script tag
579
+ mrrocket.paywall.open("pricing_page", { onPurchase: (plan) => fetch("/checkout", { method: "POST", body: plan.id }) });
580
+ ```
581
+
582
+ - **Plans:** each plan's `id` is what you buy (the store product id or the Stripe price), as set on the plan in MRRocket. Throwing in `onPurchase` keeps the paywall open with "The purchase did not go through".
583
+ - **Tests:** a running paywall test gives each person their variant's pages (the same stable split as every test) and records `$exposure` when the paywall opens. A purchase through the paywall counts as the test's conversion, and so does a store purchase RevenueCat or Adapty report for the same user id.
584
+ - **Drop-off:** each page records `$paywall {action: "page", page, index}` the first time it shows, `purchased` and `closed` too, so MRRocket shows how many reach page 2 and 3.
585
+ - **Without pages** a paywall keeps working as texts your own paywall marks (`paywall.<placement>.headline`, `.body`, `.cta`).
586
+ - The script tag loads the paywall dialog from `sdk-flows.js` on the first `open`; `sdk.js` stays within its budget.
587
+
548
588
  ## Privacy and consent
549
589
 
550
590
  ```tsx
@@ -76,6 +76,32 @@ export interface SurveyDefinition {
76
76
  questions: SurveyQuestion[];
77
77
  }
78
78
  export type SurveyAnswer = number | string | string[];
79
+ /** A file in the messenger's chat: a screenshot, a photo or a PDF the visitor sent (servers from SDK 0.15 on). */
80
+ export interface ChatFile {
81
+ /** From an upload: the signed id a message sends. In a message: the file's own id (`attachmentUrl` reads it). */
82
+ id: string;
83
+ name: string;
84
+ type: "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "application/pdf";
85
+ /** Bytes. */
86
+ size: number;
87
+ }
88
+ /** What the messenger can send: pictures and PDFs, at most 10 MB each, 4 per message. */
89
+ export declare const CHAT_FILE_TYPES: readonly ["image/png", "image/jpeg", "image/webp", "image/gif", "application/pdf"];
90
+ export declare const CHAT_FILE_MAX_BYTES: number;
91
+ export declare const CHAT_FILES_PER_MESSAGE = 4;
92
+ /** A file to upload: a Blob or File on the web, the image picker's `{ uri, name, type }` in React Native. */
93
+ export type ChatUpload = Blob | {
94
+ uri: string;
95
+ name: string;
96
+ type: string;
97
+ };
98
+ /** The bug context a visitor message carries; the server fills browser and system from the user agent when left out. */
99
+ export interface ChatContext {
100
+ browser?: string;
101
+ os?: string;
102
+ /** "1440×900". */
103
+ viewport?: string;
104
+ }
79
105
  /** One message of the messenger's chat. "visitor" is the person on the site; the rest come from the product's team. */
80
106
  export interface ChatMessage {
81
107
  id: string;
@@ -87,6 +113,8 @@ export interface ChatMessage {
87
113
  id: string;
88
114
  title: string;
89
115
  }[];
116
+ /** Files sent with it (servers from SDK 0.15 on). */
117
+ attachments?: ChatFile[];
90
118
  }
91
119
  /** A published help article in a list (the messenger's Help tab). */
92
120
  export interface ArticleSummary {
@@ -124,11 +152,25 @@ export interface Article {
124
152
  updatedAt: string;
125
153
  blocks: ArticleBlock[];
126
154
  }
155
+ /** Where the chat button sits: a corner, the middle of the top or bottom edge, or the middle of a side. */
156
+ export type MessengerPosition = "top-left" | "top-center" | "top-right" | "middle-left" | "middle-right" | "bottom-left" | "bottom-center" | "bottom-right";
157
+ /** How round the messenger is. */
158
+ export type MessengerCorners = "round" | "soft" | "square";
159
+ /** The radii per corner style, in px: the panel or sheet, message bubbles (and their tail), cards, fields and buttons. */
160
+ export declare const CORNERS: Record<MessengerCorners, {
161
+ panel: number;
162
+ bubble: number;
163
+ tail: number;
164
+ card: number;
165
+ field: number;
166
+ }>;
127
167
  /** The messenger's look and texts as set in MRRocket › Support › Messenger (servers from SDK 0.9 on). */
128
168
  export interface MessengerLook {
129
169
  accent: string;
170
+ /** Up to two more colors blended into Home's background glow (MRRocket from 0.16; older servers leave it out). */
171
+ glow?: string[];
130
172
  theme: "light" | "dark" | "auto";
131
- position: "bottom-right" | "bottom-left";
173
+ position: MessengerPosition;
132
174
  title: string;
133
175
  greeting: string;
134
176
  label: string;
@@ -140,7 +182,19 @@ export interface MessengerLook {
140
182
  sound: boolean;
141
183
  preview: boolean;
142
184
  askEmail: boolean;
185
+ /** How round panel, bubbles, cards and fields are (MRRocket from 0.15; older servers leave it out: round). */
186
+ corners?: MessengerCorners;
187
+ /** The site's own font (the default) or the system's (web only; from 0.15). */
188
+ font?: "site" | "system";
189
+ /** Home's top: plain like the rest, or in the accent color (from 0.15; older servers leave it out: plain). */
190
+ header?: "plain" | "color";
191
+ /** "Powered by MRRocket" at the bottom; the server sends false only on plans that may hide it (from 0.15). */
192
+ branding?: boolean;
193
+ /** The product's icon (its favicon) at the top left of Home; without it the title's first letter. */
194
+ logo?: string;
143
195
  }
196
+ /** The link behind "Powered by MRRocket". */
197
+ export declare const BRAND_URL = "https://mrrocket.dev/?utm_source=messenger&utm_medium=powered-by";
144
198
  /** The line under "Send us a message" and in the chat's head. */
145
199
  export declare const replyLine: (t: MessengerLook["replyTime"]) => "We usually reply in a few minutes" | "We usually reply within a day" | "We usually reply in a few hours";
146
200
  /** Black or white, whichever reads better on the accent (a light custom color gets dark text). */
@@ -203,11 +257,18 @@ export declare const createApi: (c: Conn) => {
203
257
  seconds: number;
204
258
  }) => Promise<unknown>;
205
259
  chat: (signal?: AbortSignal) => Promise<ChatThread>;
260
+ /** A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). */
206
261
  sendChat: (m: {
207
262
  body: string;
208
263
  email?: string;
209
264
  url?: string;
265
+ attachments?: string[];
266
+ context?: ChatContext;
210
267
  }) => Promise<ChatThread>;
268
+ /** Uploads one picked file for the next message (pictures and PDFs, at most 10 MB); answers its upload id. */
269
+ uploadChatFile: (file: ChatUpload, signal?: AbortSignal) => Promise<ChatFile>;
270
+ /** Where a sent file of this visitor's chat is read (an image's src, a PDF's link). */
271
+ attachmentUrl: (id: string) => string;
211
272
  articles: (q?: string, signal?: AbortSignal) => Promise<{
212
273
  articles: ArticleSummary[];
213
274
  }>;
@@ -5,6 +5,15 @@ var STATUS_LABEL = {
5
5
  progress: "In progress",
6
6
  shipped: "Shipped"
7
7
  };
8
+ var CHAT_FILE_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif", "application/pdf"];
9
+ var CHAT_FILE_MAX_BYTES = 10 * 1024 * 1024;
10
+ var CHAT_FILES_PER_MESSAGE = 4;
11
+ var CORNERS = {
12
+ round: { panel: 22, bubble: 18, tail: 6, card: 16, field: 20 },
13
+ soft: { panel: 14, bubble: 12, tail: 4, card: 10, field: 10 },
14
+ square: { panel: 6, bubble: 6, tail: 2, card: 4, field: 4 }
15
+ };
16
+ var BRAND_URL = "https://mrrocket.dev/?utm_source=messenger&utm_medium=powered-by";
8
17
  var replyLine = (t) => t === "minutes" ? "We usually reply in a few minutes" : t === "day" ? "We usually reply within a day" : "We usually reply in a few hours";
9
18
  var inkOn = (hex) => {
10
19
  const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);
@@ -29,7 +38,8 @@ var call = async (url, init, signal) => {
29
38
  res = await fetch(url, {
30
39
  ...init,
31
40
  signal,
32
- headers: init?.body ? { "content-type": "application/json" } : void 0
41
+ // A form (a file upload) sets its own multipart type with the boundary.
42
+ headers: typeof init?.body === "string" ? { "content-type": "application/json" } : void 0
33
43
  });
34
44
  } catch (e) {
35
45
  if (e.name === "AbortError") throw e;
@@ -62,7 +72,19 @@ var createApi = (c) => {
62
72
  seen: (id) => post(`/surveys/${encodeURIComponent(id)}/seen`, { user: void 0 }),
63
73
  respond: (id, r) => post(`/surveys/${encodeURIComponent(id)}/respond`, r),
64
74
  chat: (signal) => call(`${base}/messages?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, void 0, signal),
75
+ /** A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). */
65
76
  sendChat: (m) => post("/messages", m),
77
+ /** Uploads one picked file for the next message (pictures and PDFs, at most 10 MB); answers its upload id. */
78
+ uploadChatFile: (file, signal) => {
79
+ const form = new FormData();
80
+ form.append("key", c.apiKey);
81
+ form.append("distinctId", c.distinctId);
82
+ if ("uri" in file) form.append("file", file);
83
+ else form.append("file", file, file.name || "file");
84
+ return call(`${base}/messages/attachments`, { method: "POST", body: form }, signal);
85
+ },
86
+ /** Where a sent file of this visitor's chat is read (an image's src, a PDF's link). */
87
+ attachmentUrl: (id) => `${base}/messages/attachments/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`,
66
88
  articles: (q, signal) => call(`${base}/articles?${qs({ key: c.apiKey, q })}`, void 0, signal),
67
89
  article: (id, signal) => call(`${base}/articles/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, void 0, signal),
68
90
  messengerLook: (signal) => call(`${base}/messenger?${qs({ key: c.apiKey })}`, void 0, signal),
@@ -71,6 +93,11 @@ var createApi = (c) => {
71
93
  };
72
94
  export {
73
95
  ApiError,
96
+ BRAND_URL,
97
+ CHAT_FILES_PER_MESSAGE,
98
+ CHAT_FILE_MAX_BYTES,
99
+ CHAT_FILE_TYPES,
100
+ CORNERS,
74
101
  STATUS_LABEL,
75
102
  createApi,
76
103
  inkOn,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api-client.ts"],"sourcesContent":["/**\n * The SDK's fetch client and the shapes it reads, without React, so the script tag's widgets (src/script) use it too.\n * `./api` re-exports all of it with the `useApi` hook.\n */\nexport type PostStatus = \"review\" | \"planned\" | \"progress\" | \"shipped\";\n\nexport const STATUS_LABEL: Record<PostStatus, string> = {\n review: \"Under review\",\n planned: \"Planned\",\n progress: \"In progress\",\n shipped: \"Shipped\",\n};\n\nexport interface FeedbackBoardInfo {\n id: string;\n label: string;\n}\n\nexport interface FeedbackPost {\n id: string;\n title: string;\n body: string;\n board: string;\n status: PostStatus;\n votes: number;\n comments: number;\n voted: boolean;\n createdAt: string;\n /** \"Lena K.\", \"Anonymous\" or \"Team\". Missing from servers before SDK 0.6. */\n author?: string;\n}\n\n/** The product's public face for the board's header. */\nexport interface FeedbackProduct {\n name: string;\n logo: string | null;\n /** The domain's favicon, tried when `logo` does not load. Older servers leave it out. */\n logoFallback?: string | null;\n}\n\nexport interface FeedbackList {\n boards: FeedbackBoardInfo[];\n posts: FeedbackPost[];\n product?: FeedbackProduct;\n}\n\nexport interface FeedbackRoadmap {\n /** `review` (Backlog) comes from servers of SDK 0.6 on. */\n columns: { review?: FeedbackPost[]; planned: FeedbackPost[]; progress: FeedbackPost[]; shipped: FeedbackPost[] };\n}\n\nexport interface ChangelogEntry {\n id: string;\n title: string;\n body: string;\n publishedAt: string;\n}\n\nexport interface FeedbackComment {\n id: string;\n body: string;\n author: string;\n isTeam: boolean;\n postedAt: string;\n}\n\nexport type SurveyQuestionKind = \"nps\" | \"rating\" | \"single\" | \"multi\" | \"text\";\n\nexport interface SurveyQuestion {\n key: string;\n kind: SurveyQuestionKind;\n title: string;\n description?: string;\n required: boolean;\n options?: string[];\n scale?: number;\n low?: string;\n high?: string;\n placeholder?: string;\n}\n\nexport interface SurveyDefinition {\n id: string;\n name: string;\n type: string;\n thanks: string;\n questions: SurveyQuestion[];\n}\n\nexport type SurveyAnswer = number | string | string[];\n\n/** One message of the messenger's chat. \"visitor\" is the person on the site; the rest come from the product's team. */\nexport interface ChatMessage {\n id: string;\n from: \"visitor\" | \"team\" | \"ai\" | \"auto\";\n body: string;\n at: string;\n /** Help articles an answer drew on (servers from SDK 0.9 on). */\n articles?: { id: string; title: string }[];\n}\n\n/** A published help article in a list (the messenger's Help tab). */\nexport interface ArticleSummary {\n id: string;\n title: string;\n collection: string;\n excerpt: string;\n updatedAt: string;\n}\n\n/** A run of text inside an article block. Links are http(s), mailto or tel only. */\nexport interface ArticleSpan {\n text: string;\n href?: string;\n bold?: boolean;\n italic?: boolean;\n code?: boolean;\n}\n\n/** An article's content as blocks, written with textContent (never parsed as HTML). */\nexport type ArticleBlock =\n | { type: \"h2\" | \"h3\" | \"p\" | \"quote\"; spans: ArticleSpan[] }\n | { type: \"ul\" | \"ol\"; items: ArticleSpan[][] }\n | { type: \"code\"; text: string }\n | { type: \"hr\" };\n\nexport interface Article {\n id: string;\n title: string;\n collection: string;\n updatedAt: string;\n blocks: ArticleBlock[];\n}\n\n/** The messenger's look and texts as set in MRRocket › Support › Messenger (servers from SDK 0.9 on). */\nexport interface MessengerLook {\n accent: string;\n theme: \"light\" | \"dark\" | \"auto\";\n position: \"bottom-right\" | \"bottom-left\";\n title: string;\n greeting: string;\n label: string;\n /** How soon the team usually answers (MRRocket from 0.10; older servers leave it out). */\n replyTime?: \"minutes\" | \"hours\" | \"day\";\n /** A round chat button in the app (React Native) too. */\n appLauncher?: boolean;\n help: boolean;\n sound: boolean;\n preview: boolean;\n askEmail: boolean;\n}\n\n/** The line under \"Send us a message\" and in the chat's head. */\nexport const replyLine = (t: MessengerLook[\"replyTime\"]) =>\n t === \"minutes\" ? \"We usually reply in a few minutes\" : t === \"day\" ? \"We usually reply within a day\" : \"We usually reply in a few hours\";\n\n/** Black or white, whichever reads better on the accent (a light custom color gets dark text). */\nexport const inkOn = (hex: string) => {\n const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);\n if (!m) return \"#ffffff\";\n const [r, g, b] = [m[1], m[2], m[3]].map((x) => {\n const c = parseInt(x, 16) / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.45 ? \"#111214\" : \"#ffffff\";\n};\n\n/** The visitor's newest chat (open or closed) and its messages. */\nexport interface ChatThread {\n conversation: { id: string; status: \"open\" | \"solved\" } | null;\n messages: ChatMessage[];\n /** The visitor gave an email already: the messenger stops asking. */\n hasEmail: boolean;\n}\n\nexport class ApiError extends Error {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n }\n}\n\ninterface Conn {\n host: string;\n apiKey: string;\n distinctId: string;\n user?: { id?: string; [key: string]: unknown };\n}\n\n// Not URLSearchParams: React Native's lacks `set` in older versions, and the apps use this client too.\nconst qs = (params: Record<string, string | undefined>) =>\n Object.entries(params)\n .filter((e): e is [string, string] => !!e[1])\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n\nconst call = async <T>(url: string, init: RequestInit | undefined, signal?: AbortSignal): Promise<T> => {\n let res: Response;\n try {\n res = await fetch(url, {\n ...init,\n signal,\n headers: init?.body ? { \"content-type\": \"application/json\" } : undefined,\n });\n } catch (e) {\n if ((e as Error).name === \"AbortError\") throw e;\n throw new ApiError(\"Could not reach the server. Check your connection and try again.\", 0);\n }\n if (!res.ok) {\n let detail = \"\";\n try {\n detail = ((await res.json()) as { error?: string }).error ?? \"\";\n } catch {\n // Not JSON; the status is enough.\n }\n throw new ApiError(detail || (res.status === 429 ? \"Too many requests. Try again in a minute.\" : \"Something went wrong. Please try again.\"), res.status);\n }\n return (await res.json()) as T;\n};\n\n/** The small fetch client behind the widgets. Every read takes an AbortSignal so unmounting cancels it. */\nexport const createApi = (c: Conn) => {\n const base = `${c.host}/api/sdk`;\n const who = { key: c.apiKey, distinctId: c.distinctId, user: c.user };\n const post = <T>(path: string, body: Record<string, unknown>, signal?: AbortSignal) =>\n call<T>(`${base}${path}`, { method: \"POST\", body: JSON.stringify({ ...who, ...body }) }, signal);\n return {\n list: (o: { board?: string; sort?: \"top\" | \"new\"; q?: string }, signal?: AbortSignal) =>\n call<FeedbackList>(`${base}/feedback?${qs({ key: c.apiKey, distinctId: c.distinctId, board: o.board, sort: o.sort, q: o.q })}`, undefined, signal),\n post: (id: string, signal?: AbortSignal) =>\n call<FeedbackPost>(`${base}/feedback/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n roadmap: (signal?: AbortSignal) => call<FeedbackRoadmap>(`${base}/feedback/roadmap?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n changelog: (signal?: AbortSignal) => call<{ entries: ChangelogEntry[] }>(`${base}/feedback/changelog?${qs({ key: c.apiKey })}`, undefined, signal),\n submit: (p: { title: string; body?: string; board: string }) => post<FeedbackPost>(\"/feedback\", p),\n vote: (id: string) => post<{ voted: boolean; votes: number }>(`/feedback/${encodeURIComponent(id)}/vote`, {}),\n comments: (id: string, signal?: AbortSignal) =>\n call<{ comments: FeedbackComment[] }>(`${base}/feedback/${encodeURIComponent(id)}/comments?${qs({ key: c.apiKey })}`, undefined, signal),\n comment: (id: string, body: string) => post<FeedbackComment>(`/feedback/${encodeURIComponent(id)}/comments`, { body }),\n survey: (url: string, signal?: AbortSignal) =>\n call<{ survey: SurveyDefinition | null }>(`${base}/surveys?${qs({ key: c.apiKey, distinctId: c.distinctId, url })}`, undefined, signal),\n seen: (id: string) => post<unknown>(`/surveys/${encodeURIComponent(id)}/seen`, { user: undefined }),\n respond: (id: string, r: { answers: Record<string, SurveyAnswer>; completed: boolean; seconds: number }) =>\n post<unknown>(`/surveys/${encodeURIComponent(id)}/respond`, r),\n chat: (signal?: AbortSignal) => call<ChatThread>(`${base}/messages?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n sendChat: (m: { body: string; email?: string; url?: string }) => post<ChatThread>(\"/messages\", m),\n articles: (q?: string, signal?: AbortSignal) => call<{ articles: ArticleSummary[] }>(`${base}/articles?${qs({ key: c.apiKey, q })}`, undefined, signal),\n article: (id: string, signal?: AbortSignal) =>\n call<Article>(`${base}/articles/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n messengerLook: (signal?: AbortSignal) => call<MessengerLook>(`${base}/messenger?${qs({ key: c.apiKey })}`, undefined, signal),\n rateArticle: (id: string, helpful: boolean) => post<{ counted: boolean }>(`/articles/${encodeURIComponent(id)}/rate`, { helpful }),\n };\n};\n\nexport type Api = ReturnType<typeof createApi>;\n"],"mappings":";AAMO,IAAM,eAA2C;AAAA,EACpD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS;AACb;AA8IO,IAAM,YAAY,CAAC,MACtB,MAAM,YAAY,sCAAsC,MAAM,QAAQ,kCAAkC;AAGrG,IAAM,QAAQ,CAAC,QAAgB;AAClC,QAAM,IAAI,8CAA8C,KAAK,GAAG;AAChE,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM;AAC5C,UAAM,IAAI,SAAS,GAAG,EAAE,IAAI;AAC5B,WAAO,KAAK,UAAU,IAAI,UAAU,IA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AY,IAAI,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IAC1I,MAAM,CAAC,OAAe,KAAc,YAAY,mBAAmB,EAAE,CAAC,SAAS,EAAE,MAAM,OAAU,CAAC;AAAA,IAClG,SAAS,CAAC,IAAY,MAClB,KAAc,YAAY,mBAAmB,EAAE,CAAC,YAAY,CAAC;AAAA,IACjE,MAAM,CAAC,WAAyB,KAAiB,GAAG,IAAI,aAAa,GAAG,EAAE,KAAK,EAAE,QAAQ,YAAY,EAAE,WAAW,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IACzI,UAAU,CAAC,MAAsD,KAAiB,aAAa,CAAC;AAAA,IAChG,UAAU,CAAC,GAAY,WAAyB,KAAqC,GAAG,IAAI,aAAa,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IACtJ,SAAS,CAAC,IAAY,WAClB,KAAc,GAAG,IAAI,aAAa,mBAAmB,EAAE,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,QAAQ,YAAY,EAAE,WAAW,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IACpI,eAAe,CAAC,WAAyB,KAAoB,GAAG,IAAI,cAAc,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IAC5H,aAAa,CAAC,IAAY,YAAqB,KAA2B,aAAa,mBAAmB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;AAAA,EACrI;AACJ;","names":[]}
1
+ {"version":3,"sources":["../src/api-client.ts"],"sourcesContent":["/**\n * The SDK's fetch client and the shapes it reads, without React, so the script tag's widgets (src/script) use it too.\n * `./api` re-exports all of it with the `useApi` hook.\n */\nexport type PostStatus = \"review\" | \"planned\" | \"progress\" | \"shipped\";\n\nexport const STATUS_LABEL: Record<PostStatus, string> = {\n review: \"Under review\",\n planned: \"Planned\",\n progress: \"In progress\",\n shipped: \"Shipped\",\n};\n\nexport interface FeedbackBoardInfo {\n id: string;\n label: string;\n}\n\nexport interface FeedbackPost {\n id: string;\n title: string;\n body: string;\n board: string;\n status: PostStatus;\n votes: number;\n comments: number;\n voted: boolean;\n createdAt: string;\n /** \"Lena K.\", \"Anonymous\" or \"Team\". Missing from servers before SDK 0.6. */\n author?: string;\n}\n\n/** The product's public face for the board's header. */\nexport interface FeedbackProduct {\n name: string;\n logo: string | null;\n /** The domain's favicon, tried when `logo` does not load. Older servers leave it out. */\n logoFallback?: string | null;\n}\n\nexport interface FeedbackList {\n boards: FeedbackBoardInfo[];\n posts: FeedbackPost[];\n product?: FeedbackProduct;\n}\n\nexport interface FeedbackRoadmap {\n /** `review` (Backlog) comes from servers of SDK 0.6 on. */\n columns: { review?: FeedbackPost[]; planned: FeedbackPost[]; progress: FeedbackPost[]; shipped: FeedbackPost[] };\n}\n\nexport interface ChangelogEntry {\n id: string;\n title: string;\n body: string;\n publishedAt: string;\n}\n\nexport interface FeedbackComment {\n id: string;\n body: string;\n author: string;\n isTeam: boolean;\n postedAt: string;\n}\n\nexport type SurveyQuestionKind = \"nps\" | \"rating\" | \"single\" | \"multi\" | \"text\";\n\nexport interface SurveyQuestion {\n key: string;\n kind: SurveyQuestionKind;\n title: string;\n description?: string;\n required: boolean;\n options?: string[];\n scale?: number;\n low?: string;\n high?: string;\n placeholder?: string;\n}\n\nexport interface SurveyDefinition {\n id: string;\n name: string;\n type: string;\n thanks: string;\n questions: SurveyQuestion[];\n}\n\nexport type SurveyAnswer = number | string | string[];\n\n/** A file in the messenger's chat: a screenshot, a photo or a PDF the visitor sent (servers from SDK 0.15 on). */\nexport interface ChatFile {\n /** From an upload: the signed id a message sends. In a message: the file's own id (`attachmentUrl` reads it). */\n id: string;\n name: string;\n type: \"image/png\" | \"image/jpeg\" | \"image/webp\" | \"image/gif\" | \"application/pdf\";\n /** Bytes. */\n size: number;\n}\n\n/** What the messenger can send: pictures and PDFs, at most 10 MB each, 4 per message. */\nexport const CHAT_FILE_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\", \"application/pdf\"] as const;\nexport const CHAT_FILE_MAX_BYTES = 10 * 1024 * 1024;\nexport const CHAT_FILES_PER_MESSAGE = 4;\n\n/** A file to upload: a Blob or File on the web, the image picker's `{ uri, name, type }` in React Native. */\nexport type ChatUpload = Blob | { uri: string; name: string; type: string };\n\n/** The bug context a visitor message carries; the server fills browser and system from the user agent when left out. */\nexport interface ChatContext {\n browser?: string;\n os?: string;\n /** \"1440×900\". */\n viewport?: string;\n}\n\n/** One message of the messenger's chat. \"visitor\" is the person on the site; the rest come from the product's team. */\nexport interface ChatMessage {\n id: string;\n from: \"visitor\" | \"team\" | \"ai\" | \"auto\";\n body: string;\n at: string;\n /** Help articles an answer drew on (servers from SDK 0.9 on). */\n articles?: { id: string; title: string }[];\n /** Files sent with it (servers from SDK 0.15 on). */\n attachments?: ChatFile[];\n}\n\n/** A published help article in a list (the messenger's Help tab). */\nexport interface ArticleSummary {\n id: string;\n title: string;\n collection: string;\n excerpt: string;\n updatedAt: string;\n}\n\n/** A run of text inside an article block. Links are http(s), mailto or tel only. */\nexport interface ArticleSpan {\n text: string;\n href?: string;\n bold?: boolean;\n italic?: boolean;\n code?: boolean;\n}\n\n/** An article's content as blocks, written with textContent (never parsed as HTML). */\nexport type ArticleBlock =\n | { type: \"h2\" | \"h3\" | \"p\" | \"quote\"; spans: ArticleSpan[] }\n | { type: \"ul\" | \"ol\"; items: ArticleSpan[][] }\n | { type: \"code\"; text: string }\n | { type: \"hr\" };\n\nexport interface Article {\n id: string;\n title: string;\n collection: string;\n updatedAt: string;\n blocks: ArticleBlock[];\n}\n\n/** Where the chat button sits: a corner, the middle of the top or bottom edge, or the middle of a side. */\nexport type MessengerPosition = \"top-left\" | \"top-center\" | \"top-right\" | \"middle-left\" | \"middle-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\";\n\n/** How round the messenger is. */\nexport type MessengerCorners = \"round\" | \"soft\" | \"square\";\n\n/** The radii per corner style, in px: the panel or sheet, message bubbles (and their tail), cards, fields and buttons. */\nexport const CORNERS: Record<MessengerCorners, { panel: number; bubble: number; tail: number; card: number; field: number }> = {\n round: { panel: 22, bubble: 18, tail: 6, card: 16, field: 20 },\n soft: { panel: 14, bubble: 12, tail: 4, card: 10, field: 10 },\n square: { panel: 6, bubble: 6, tail: 2, card: 4, field: 4 },\n};\n\n/** The messenger's look and texts as set in MRRocket › Support › Messenger (servers from SDK 0.9 on). */\nexport interface MessengerLook {\n accent: string;\n /** Up to two more colors blended into Home's background glow (MRRocket from 0.16; older servers leave it out). */\n glow?: string[];\n theme: \"light\" | \"dark\" | \"auto\";\n position: MessengerPosition;\n title: string;\n greeting: string;\n label: string;\n /** How soon the team usually answers (MRRocket from 0.10; older servers leave it out). */\n replyTime?: \"minutes\" | \"hours\" | \"day\";\n /** A round chat button in the app (React Native) too. */\n appLauncher?: boolean;\n help: boolean;\n sound: boolean;\n preview: boolean;\n askEmail: boolean;\n /** How round panel, bubbles, cards and fields are (MRRocket from 0.15; older servers leave it out: round). */\n corners?: MessengerCorners;\n /** The site's own font (the default) or the system's (web only; from 0.15). */\n font?: \"site\" | \"system\";\n /** Home's top: plain like the rest, or in the accent color (from 0.15; older servers leave it out: plain). */\n header?: \"plain\" | \"color\";\n /** \"Powered by MRRocket\" at the bottom; the server sends false only on plans that may hide it (from 0.15). */\n branding?: boolean;\n /** The product's icon (its favicon) at the top left of Home; without it the title's first letter. */\n logo?: string;\n}\n\n/** The link behind \"Powered by MRRocket\". */\nexport const BRAND_URL = \"https://mrrocket.dev/?utm_source=messenger&utm_medium=powered-by\";\n\n/** The line under \"Send us a message\" and in the chat's head. */\nexport const replyLine = (t: MessengerLook[\"replyTime\"]) =>\n t === \"minutes\" ? \"We usually reply in a few minutes\" : t === \"day\" ? \"We usually reply within a day\" : \"We usually reply in a few hours\";\n\n/** Black or white, whichever reads better on the accent (a light custom color gets dark text). */\nexport const inkOn = (hex: string) => {\n const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);\n if (!m) return \"#ffffff\";\n const [r, g, b] = [m[1], m[2], m[3]].map((x) => {\n const c = parseInt(x, 16) / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.45 ? \"#111214\" : \"#ffffff\";\n};\n\n/** The visitor's newest chat (open or closed) and its messages. */\nexport interface ChatThread {\n conversation: { id: string; status: \"open\" | \"solved\" } | null;\n messages: ChatMessage[];\n /** The visitor gave an email already: the messenger stops asking. */\n hasEmail: boolean;\n}\n\nexport class ApiError extends Error {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n }\n}\n\ninterface Conn {\n host: string;\n apiKey: string;\n distinctId: string;\n user?: { id?: string; [key: string]: unknown };\n}\n\n// Not URLSearchParams: React Native's lacks `set` in older versions, and the apps use this client too.\nconst qs = (params: Record<string, string | undefined>) =>\n Object.entries(params)\n .filter((e): e is [string, string] => !!e[1])\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n\nconst call = async <T>(url: string, init: RequestInit | undefined, signal?: AbortSignal): Promise<T> => {\n let res: Response;\n try {\n res = await fetch(url, {\n ...init,\n signal,\n // A form (a file upload) sets its own multipart type with the boundary.\n headers: typeof init?.body === \"string\" ? { \"content-type\": \"application/json\" } : undefined,\n });\n } catch (e) {\n if ((e as Error).name === \"AbortError\") throw e;\n throw new ApiError(\"Could not reach the server. Check your connection and try again.\", 0);\n }\n if (!res.ok) {\n let detail = \"\";\n try {\n detail = ((await res.json()) as { error?: string }).error ?? \"\";\n } catch {\n // Not JSON; the status is enough.\n }\n throw new ApiError(detail || (res.status === 429 ? \"Too many requests. Try again in a minute.\" : \"Something went wrong. Please try again.\"), res.status);\n }\n return (await res.json()) as T;\n};\n\n/** The small fetch client behind the widgets. Every read takes an AbortSignal so unmounting cancels it. */\nexport const createApi = (c: Conn) => {\n const base = `${c.host}/api/sdk`;\n const who = { key: c.apiKey, distinctId: c.distinctId, user: c.user };\n const post = <T>(path: string, body: Record<string, unknown>, signal?: AbortSignal) =>\n call<T>(`${base}${path}`, { method: \"POST\", body: JSON.stringify({ ...who, ...body }) }, signal);\n return {\n list: (o: { board?: string; sort?: \"top\" | \"new\"; q?: string }, signal?: AbortSignal) =>\n call<FeedbackList>(`${base}/feedback?${qs({ key: c.apiKey, distinctId: c.distinctId, board: o.board, sort: o.sort, q: o.q })}`, undefined, signal),\n post: (id: string, signal?: AbortSignal) =>\n call<FeedbackPost>(`${base}/feedback/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n roadmap: (signal?: AbortSignal) => call<FeedbackRoadmap>(`${base}/feedback/roadmap?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n changelog: (signal?: AbortSignal) => call<{ entries: ChangelogEntry[] }>(`${base}/feedback/changelog?${qs({ key: c.apiKey })}`, undefined, signal),\n submit: (p: { title: string; body?: string; board: string }) => post<FeedbackPost>(\"/feedback\", p),\n vote: (id: string) => post<{ voted: boolean; votes: number }>(`/feedback/${encodeURIComponent(id)}/vote`, {}),\n comments: (id: string, signal?: AbortSignal) =>\n call<{ comments: FeedbackComment[] }>(`${base}/feedback/${encodeURIComponent(id)}/comments?${qs({ key: c.apiKey })}`, undefined, signal),\n comment: (id: string, body: string) => post<FeedbackComment>(`/feedback/${encodeURIComponent(id)}/comments`, { body }),\n survey: (url: string, signal?: AbortSignal) =>\n call<{ survey: SurveyDefinition | null }>(`${base}/surveys?${qs({ key: c.apiKey, distinctId: c.distinctId, url })}`, undefined, signal),\n seen: (id: string) => post<unknown>(`/surveys/${encodeURIComponent(id)}/seen`, { user: undefined }),\n respond: (id: string, r: { answers: Record<string, SurveyAnswer>; completed: boolean; seconds: number }) =>\n post<unknown>(`/surveys/${encodeURIComponent(id)}/respond`, r),\n chat: (signal?: AbortSignal) => call<ChatThread>(`${base}/messages?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n /** A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). */\n sendChat: (m: { body: string; email?: string; url?: string; attachments?: string[]; context?: ChatContext }) => post<ChatThread>(\"/messages\", m),\n /** Uploads one picked file for the next message (pictures and PDFs, at most 10 MB); answers its upload id. */\n uploadChatFile: (file: ChatUpload, signal?: AbortSignal) => {\n const form = new FormData();\n form.append(\"key\", c.apiKey);\n form.append(\"distinctId\", c.distinctId);\n if (\"uri\" in file) form.append(\"file\", file as unknown as Blob);\n else form.append(\"file\", file, (file as Blob & { name?: string }).name || \"file\");\n return call<ChatFile>(`${base}/messages/attachments`, { method: \"POST\", body: form }, signal);\n },\n /** Where a sent file of this visitor's chat is read (an image's src, a PDF's link). */\n attachmentUrl: (id: string) => `${base}/messages/attachments/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`,\n articles: (q?: string, signal?: AbortSignal) => call<{ articles: ArticleSummary[] }>(`${base}/articles?${qs({ key: c.apiKey, q })}`, undefined, signal),\n article: (id: string, signal?: AbortSignal) =>\n call<Article>(`${base}/articles/${encodeURIComponent(id)}?${qs({ key: c.apiKey, distinctId: c.distinctId })}`, undefined, signal),\n messengerLook: (signal?: AbortSignal) => call<MessengerLook>(`${base}/messenger?${qs({ key: c.apiKey })}`, undefined, signal),\n rateArticle: (id: string, helpful: boolean) => post<{ counted: boolean }>(`/articles/${encodeURIComponent(id)}/rate`, { helpful }),\n };\n};\n\nexport type Api = ReturnType<typeof createApi>;\n"],"mappings":";AAMO,IAAM,eAA2C;AAAA,EACpD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS;AACb;AA2FO,IAAM,kBAAkB,CAAC,aAAa,cAAc,cAAc,aAAa,iBAAiB;AAChG,IAAM,sBAAsB,KAAK,OAAO;AACxC,IAAM,yBAAyB;AAiE/B,IAAM,UAAkH;AAAA,EAC3H,OAAO,EAAE,O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AAI,SAAS,KAAM,MAAK,OAAO,QAAQ,IAAuB;AAAA,UACzD,MAAK,OAAO,QAAQ,MAAO,KAAkC,QAAQ,MAAM;AAChF,aAAO,KAAe,GAAG,IAAI,yBAAyB,EAAE,QAAQ,QAAQ,MAAM,KAAK,GAAG,MAAM;AAAA,IAChG;AAAA;AAAA,IAEA,eAAe,CAAC,OAAe,GAAG,IAAI,yBAAyB,mBAAmB,EAAE,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,QAAQ,YAAY,EAAE,WAAW,CAAC,CAAC;AAAA,IACxI,UAAU,CAAC,GAAY,WAAyB,KAAqC,GAAG,IAAI,aAAa,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IACtJ,SAAS,CAAC,IAAY,WAClB,KAAc,GAAG,IAAI,aAAa,mBAAmB,EAAE,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,QAAQ,YAAY,EAAE,WAAW,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IACpI,eAAe,CAAC,WAAyB,KAAoB,GAAG,IAAI,cAAc,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IAC5H,aAAa,CAAC,IAAY,YAAqB,KAA2B,aAAa,mBAAmB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;AAAA,EACrI;AACJ;","names":[]}
@@ -1,4 +1,4 @@
1
- (function(){'use strict';var $=(o,a)=>Math.round(o*(1-a/100)*100)/100,v=(o,a)=>{try{return new Intl.NumberFormat(void 0,{style:"currency",currency:a}).format(o)}catch(u){return `${o.toFixed(2)} ${a}`}},E=o=>o.kind==="contact"?"Send to the team":o.kind==="pause"?"Pause instead":o.kind==="downgrade"?"Switch plan":"Accept offer";var S="ckf-styles",j=`
1
+ (function(){'use strict';var L=(n,e)=>Math.round(n*(1-e/100)*100)/100,T=(n,e)=>{try{return new Intl.NumberFormat(void 0,{style:"currency",currency:e}).format(n)}catch(c){return `${n.toFixed(2)} ${e}`}},A=n=>n.kind==="contact"?"Send to the team":n.kind==="pause"?"Pause instead":n.kind==="downgrade"?"Switch plan":"Accept offer";var U="ckf-styles",D=`
2
2
  .ckf-root{--ckf-accent:#3f76ff;--ckf-accent-ink:#fff;--ckf-bg:#fff;--ckf-fg:#1c1d20;--ckf-muted:#5d6068;--ckf-soft:#f4f5f7;--ckf-line:#e4e5e8;--ckf-danger:#d92d20;--ckf-radius:14px;--ckf-font:inherit;--ckf-shadow:0 16px 40px -12px rgba(16,18,24,.28),0 0 0 1px rgba(16,18,24,.07)}
3
3
  .ckf-root[data-theme=dark]{--ckf-bg:#17181b;--ckf-fg:#f1f2f4;--ckf-muted:#a9acb3;--ckf-soft:#232428;--ckf-line:#2e2f35;--ckf-shadow:0 16px 40px -12px rgba(0,0,0,.6),0 0 0 1px rgba(255,255,255,.08)}
4
4
  @media (prefers-color-scheme:dark){.ckf-root[data-theme=auto]{--ckf-bg:#17181b;--ckf-fg:#f1f2f4;--ckf-muted:#a9acb3;--ckf-soft:#232428;--ckf-line:#2e2f35;--ckf-shadow:0 16px 40px -12px rgba(0,0,0,.6),0 0 0 1px rgba(255,255,255,.08)}}
@@ -56,9 +56,18 @@
56
56
  .ckf-banner{position:fixed;z-index:2147483001;left:50%;top:12px;transform:translateX(-50%);width:min(640px,calc(100vw - 24px));background:var(--ckf-bg);border-radius:12px;box-shadow:var(--ckf-shadow);padding:10px 10px 10px 16px;display:flex;align-items:center;gap:12px;animation:ckf-in .18s ease-out}
57
57
  .ckf-banner>span{flex:1;min-width:0;display:flex;flex-direction:column}
58
58
  .ckf-banner .ckf-btn{height:32px}
59
+ .ckf-pw{max-width:420px;gap:14px}
60
+ .ckf-root[data-still] :is(.ckf-scrim,.ckf-card){animation:none}
61
+ .ckf-li{display:flex;gap:10px;align-items:flex-start;margin:0}
62
+ .ckf-li::before{content:"\u2713";flex:none;width:20px;height:20px;border-radius:50%;background:color-mix(in srgb,var(--ckf-accent) 14%,var(--ckf-bg));color:var(--ckf-accent);font-size:12px;font-weight:700;display:inline-flex;align-items:center;justify-content:center}
63
+ .ckf-quote{margin:0;padding:12px 14px;border-radius:12px;background:var(--ckf-soft)}
64
+ .ckf-quote cite{display:block;margin-top:6px;font-style:normal;font-size:12px;color:var(--ckf-muted)}
65
+ .ckf-plan{justify-content:space-between;min-height:52px}
66
+ .ckf-plan span:nth-child(2){display:flex;flex-direction:column;margin-right:auto}
67
+ .ckf-plan b{font-variant-numeric:tabular-nums}
59
68
  @keyframes ckf-fade{from{opacity:0}}
60
69
  @keyframes ckf-in{from{opacity:0;transform:translateY(6px)}}
61
70
  .ckf-banner{animation-name:ckf-fade}
62
71
  @media (max-width:520px){.ckf-scrim{align-items:flex-end;padding:0}.ckf-scrim .ckf-card{max-width:none;border-radius:var(--ckf-radius) var(--ckf-radius) 0 0;max-height:92dvh}.ckf-float{right:12px;bottom:12px}}
63
72
  @media (prefers-reduced-motion:reduce){.ckf-root *{animation:none!important;transition:none!important}}
64
- `,e=(o,a={},...u)=>{let d=document.createElement(o);for(let[f,c]of Object.entries(a))c===void 0||c===false||(typeof c=="function"?d.addEventListener(f.slice(2).toLowerCase(),c):f==="className"?d.className=String(c):d.setAttribute(f,c===true?"":c));for(let f of u)(f||f==="")&&d.append(typeof f=="string"?document.createTextNode(f):f);return d},b=(o,a,u,d={})=>e("button",{type:"button",className:`ckf-btn${a==="secondary"?"":` ckf-${a}`}`,disabled:!!d.disabled,"data-ckf-id":d.id,onClick:()=>u()},o),w=(o,a)=>e("button",{type:"button",className:"ckf-x","aria-label":o,"data-ckf-id":"x",onClick:()=>a()},"\xD7"),H=(o,a)=>a>1?e("span",{className:"ckf-dots",role:"img","aria-label":`Step ${o} of ${a}`},...Array.from({length:a},(u,d)=>e("span",{className:"ckf-dot","data-on":d<o}))):e("span"),z=o=>o.type==="cancel"?`c:${o.screen}`:o.type==="step"?`s:${o.step.id}`:o.type==="checklist"?`l:${o.flow.id}`:`m:${o.message.id}`,M=(o,a={})=>{var F;if(typeof document=="undefined")return ()=>{};if(!document.getElementById(S)){let n=document.createElement("style");n.id=S,n.textContent=j,document.head.appendChild(n);}let u=e("div",{className:`ckf-root${a.className?` ${a.className}`:""}`,"data-theme":(F=a.theme)!=null?F:"auto"});a.accent&&u.style.setProperty("--ckf-accent",a.accent),document.body.appendChild(u);let d="",f=null,c="",h=null,L=n=>{var l,p;let t="ckf-title",s=n.busy,i=[];if(n.screen==="survey")i.push(e("h2",{className:"ckf-h",id:t},n.flow.question||"Why are you leaving?"),e("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":t},...n.flow.reasons.map(r=>e("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(n.reason===r.id),"data-ckf-id":`r:${r.id}`,onClick:()=>o.cancel.pick(r.id)},e("span",{className:"ckf-radio"}),r.label))),e("div",{className:"ckf-btns"},b("Continue","primary",o.cancel.next,{disabled:!n.reason,id:"go"}),b("Never mind, keep my plan","quiet",o.cancel.close)));else if(n.screen==="offer"&&n.offer){let r=n.offer,g=(l=n.flow.reasons.find(y=>y.id===n.reason))==null?void 0:l.label,m=false;r.kind==="discount"&&r.percent&&(m=n.price?e("div",{className:"ckf-box"},e("span",{className:"ckf-big"},v($(n.price.amount,r.percent),n.price.currency)),e("span",{className:"ckf-strike"},v(n.price.amount,n.price.currency)),e("span",{className:"ckf-small"},`/${(p=n.price.interval)!=null?p:"month"}${r.months?` for ${r.months} ${r.months===1?"month":"months"}`:""}`)):e("div",{className:"ckf-box"},e("span",{className:"ckf-big"},`${r.percent}% off`),r.months?e("span",{className:"ckf-small"},`for ${r.months} ${r.months===1?"month":"months"}`):false)),r.kind==="pause"&&r.months&&(m=e("div",{className:"ckf-box"},e("span",{},`Pause for up to ${r.months} ${r.months===1?"month":"months"}. Your data stays.`))),r.kind==="downgrade"&&r.planName&&(m=e("div",{className:"ckf-box"},e("b",{},r.planName)));let k=r.kind==="contact"?e("textarea",{className:"ckf-text",placeholder:"What would make you stay?","aria-label":"Your message",maxlength:"500","data-ckf-id":"comment",onInput:y=>c=y.target.value}):null;k&&(k.value=c),i.push(g?e("p",{className:"ckf-small"},`You said: ${g}`):false,e("h2",{className:"ckf-h",id:t},r.headline),m,k!=null?k:false,e("div",{className:"ckf-btns"},b(s?"One moment\u2026":E(r),"primary",()=>o.cancel.accept(c),{disabled:s,id:"go"}),b("No thanks, continue cancelling","quiet",o.cancel.decline,{disabled:s})));}else {let g=n.steps===1?null:e("textarea",{className:"ckf-text",placeholder:"Anything else we should know? (optional)","aria-label":"Anything else we should know? (optional)",maxlength:"500","data-ckf-id":"comment",onInput:m=>c=m.target.value});g&&(g.value=c),i.push(e("h2",{className:"ckf-h",id:t},n.flow.confirm.title),n.flow.confirm.body?e("p",{className:"ckf-p"},n.flow.confirm.body):false,g!=null?g:false,e("div",{className:"ckf-btns"},b(s?"One moment\u2026":n.flow.confirm.button,"danger",()=>o.cancel.confirm(c),{disabled:s,id:"go"}),b("Keep my plan","secondary",o.cancel.close,{disabled:s})));}return e("div",{className:"ckf-scrim",onClick:r=>r.target===r.currentTarget&&!s&&o.cancel.close()},e("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":t},e("div",{className:"ckf-top"},H(n.step,n.steps),w("Close",o.cancel.close)),...i,n.error?e("p",{className:"ckf-err",role:"alert"},n.error):false))},T=n=>{let t=n.step,s=e("div",{className:"ckf-card",role:"dialog","aria-modal":t.kind==="modal"?"true":void 0,"aria-labelledby":"ckf-title"},e("div",{className:"ckf-top"},n.total>1?e("p",{className:"ckf-small"},`Step ${n.index+1} of ${n.total}`):e("span"),w("Close the tour",o.onboarding.dismiss)),e("h2",{className:"ckf-h",id:"ckf-title"},t.title),t.body?e("p",{className:"ckf-p"},t.body):false,e("div",{className:"ckf-row"},b(t.button||(n.last?"Done":"Next"),"primary",o.onboarding.next,{id:"go"})));if(t.kind==="modal")return e("div",{className:"ckf-scrim"},s);let i=t.target?I(t.target):null,l=e("div",{className:"ckf-float"},s);if(i){let p=e("div",{className:"ckf-ring","aria-hidden":"true"});return h={float:l,ring:p,target:i},N(l,p,i),e("div",{},p,l)}return l},I=n=>{var s;let t=()=>document.querySelector(`[data-ck-target="${CSS.escape(n)}"]`);return /^[#.[]|[\s>:=]/.test(n)&&(s=R(n))!=null?s:t()},R=n=>{try{return document.querySelector(n)}catch(t){return null}},N=(n,t,s)=>{let i=s.getBoundingClientRect();Object.assign(t.style,{left:`${i.left-4}px`,top:`${i.top-4}px`,width:`${i.width+8}px`,height:`${i.height+8}px`});let l=Math.min(340,window.innerWidth-24),p=Math.max(12,Math.min(i.left,window.innerWidth-l-12)),r=i.bottom+12;Object.assign(n.style,{left:`${p}px`,right:"auto",width:`${l}px`}),r+200<window.innerHeight?Object.assign(n.style,{top:`${r}px`,bottom:"auto"}):Object.assign(n.style,{top:"auto",bottom:`${Math.max(12,window.innerHeight-i.top+12)}px`});},A=n=>{let t=n.items.filter(s=>s.done).length;return e("div",{className:"ckf-float"},e("div",{className:"ckf-card",role:"region","aria-labelledby":"ckf-title"},e("div",{className:"ckf-top"},e("h2",{className:"ckf-h",id:"ckf-title"},n.flow.name),w("Hide the checklist",o.onboarding.dismiss)),e("p",{className:"ckf-small"},`${t} of ${n.items.length} done`),e("div",{className:"ckf-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(n.items.length),"aria-valuenow":String(t)},e("i",{style:`width:${t/n.items.length*100}%`})),e("div",{className:"ckf-opts"},...n.items.map(({step:s,done:i})=>{let l=[e("span",{className:"ckf-tick","aria-hidden":"true"},i?"\u2713":""),e("span",{},e("b",{},s.title),s.body?e("span",{className:"ckf-small"},s.body):false)];return i||s.event?e("div",{className:"ckf-check","data-done":i,role:"listitem"},...l):e("button",{type:"button",className:"ckf-check","aria-label":`Mark \u201C${s.title}\u201D done`,"data-ckf-id":`i:${s.id}`,onClick:()=>o.onboarding.check(s.id)},...l)}))))},_=n=>{let t=n.message,s=t.button?b(t.button,"primary",o.message.click,{id:"go"}):false;return t.style==="banner"?e("div",{className:"ckf-banner",role:"status"},e("span",{},e("b",{},t.title),t.body?e("span",{className:"ckf-small"},t.body):false),s,w("Dismiss",o.message.dismiss)):e("div",{className:"ckf-scrim",onClick:i=>i.target===i.currentTarget&&o.message.dismiss()},e("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},e("div",{className:"ckf-top"},e("span"),w("Dismiss",o.message.dismiss)),e("h2",{className:"ckf-h",id:"ckf-title"},t.title),t.body?e("p",{className:"ckf-p"},t.body):false,s?e("div",{className:"ckf-row"},s):false))},C=()=>{var i,l,p,r,g;let n=o.view(),t=n?z(n):"",s=(l=(i=document.activeElement)==null?void 0:i.closest)!=null&&l.call(i,".ckf-root")?(p=document.activeElement)==null?void 0:p.getAttribute("data-ckf-id"):null;if(t&&!d&&document.activeElement instanceof HTMLElement&&!document.activeElement.closest(".ckf-root")&&(f=document.activeElement),t!==d&&!t.startsWith("c:")&&(c=""),t||(c=""),h=null,u.replaceChildren(...n?[n.type==="cancel"?L(n):n.type==="step"?T(n):n.type==="checklist"?A(n):_(n)]:[]),t!==d){let m=u.querySelector("[aria-modal=true]"),k=(r=m==null?void 0:m.querySelector("[role=radio], [data-ckf-id=go], textarea"))!=null?r:null;k==null||k.focus(),!t&&f&&(f.focus(),f=null);}else s&&((g=u.querySelector(`[data-ckf-id="${CSS.escape(s)}"]`))==null||g.focus());d=t;},O=n=>{if(n.key!=="Escape")return;let t=o.view();(t==null?void 0:t.type)==="cancel"?o.cancel.close():(t==null?void 0:t.type)==="message"?o.message.dismiss():(t==null?void 0:t.type)==="step"&&t.step.kind==="modal"&&o.onboarding.dismiss();},x=()=>{h&&N(h.float,h.ring,h.target);};document.addEventListener("keydown",O),window.addEventListener("resize",x),window.addEventListener("scroll",x,{passive:true,capture:true});let P=o.subscribe(C);return C(),()=>{P(),document.removeEventListener("keydown",O),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,{capture:true}),u.remove();}};window.__mrrocketFlows={mountFlows:M};})();
73
+ `,t=(n,e={},...c)=>{let s=document.createElement(n);for(let[g,u]of Object.entries(e))u===void 0||u===false||(typeof u=="function"?s.addEventListener(g.slice(2).toLowerCase(),u):g==="className"?s.className=String(u):s.setAttribute(g,u===true?"":u));for(let g of c)(g||g==="")&&s.append(typeof g=="string"?document.createTextNode(g):g);return s},P=(n,e,c,s={})=>t("button",{type:"button",className:`ckf-btn${e==="secondary"?"":` ckf-${e}`}`,disabled:!!s.disabled,"data-ckf-id":s.id,onClick:()=>c()},n),$=(n,e)=>t("button",{type:"button",className:"ckf-x","aria-label":n,"data-ckf-id":"x",onClick:()=>e()},"\xD7"),V=(n,e)=>e>1?t("span",{className:"ckf-dots",role:"img","aria-label":`Step ${n} of ${e}`},...Array.from({length:e},(c,s)=>t("span",{className:"ckf-dot","data-on":s<n}))):t("span"),W=n=>{var e;return n.type==="cancel"?`c:${n.screen}:${(e=n.round)!=null?e:1}`:n.type==="step"?`s:${n.step.id}`:n.type==="checklist"?`l:${n.flow.id}`:`m:${n.message.id}`},H=n=>{var c;if(!document.getElementById(U)){let s=document.createElement("style");s.id=U,s.textContent=D,document.head.appendChild(s);}let e=t("div",{className:`ckf-root${n.className?` ${n.className}`:""}`,"data-theme":(c=n.theme)!=null?c:"auto"});return n.accent&&e.style.setProperty("--ckf-accent",n.accent),document.body.appendChild(e),e},j=(n,e={})=>{if(typeof document=="undefined")return ()=>{};let c=H(e),s="",g=null,u="",w=null,C=r=>{var m,y,E,M;let o="ckf-title",l=r.busy,d=[];if(r.screen==="survey")d.push(t("h2",{className:"ckf-h",id:o},r.flow.question||"Why are you leaving?"),t("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":o},...r.flow.reasons.map(a=>t("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(r.reason===a.id),"data-ckf-id":`r:${a.id}`,onClick:()=>n.cancel.pick(a.id)},t("span",{className:"ckf-radio"}),a.label))),t("div",{className:"ckf-btns"},P("Continue","primary",n.cancel.next,{disabled:!r.reason,id:"go"}),P("Never mind, keep my plan","quiet",n.cancel.close)));else if(r.screen==="followup"&&r.followUp){let a=r.followUp,x;if(a.answers.length)x=t("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":o},...a.answers.map((v,S)=>t("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(r.answer===v),"data-ckf-id":`a:${S}`,onClick:()=>n.cancel.answer(v)},t("span",{className:"ckf-radio"}),v)));else {let v=t("textarea",{className:"ckf-text",placeholder:"Your answer (optional)","aria-labelledby":o,maxlength:"500","data-ckf-id":"answer",onInput:S=>n.cancel.answer(S.target.value)});v.value=(m=r.answer)!=null?m:"",x=v;}let O=(y=r.flow.reasons.find(v=>v.id===r.reason))==null?void 0:y.label;d.push(O?t("p",{className:"ckf-small"},`You said: ${O}`):false,t("h2",{className:"ckf-h",id:o},a.question),x,t("div",{className:"ckf-btns"},P("Continue","primary",n.cancel.next,{id:"go"}),P("Never mind, keep my plan","quiet",n.cancel.close)));}else if(r.screen==="offer"&&r.offer){let a=r.offer,x=(E=r.flow.reasons.find(S=>S.id===r.reason))==null?void 0:E.label,O=false;a.kind==="discount"&&a.percent&&(O=r.price?t("div",{className:"ckf-box"},t("span",{className:"ckf-big"},T(L(r.price.amount,a.percent),r.price.currency)),t("span",{className:"ckf-strike"},T(r.price.amount,r.price.currency)),t("span",{className:"ckf-small"},`/${(M=r.price.interval)!=null?M:"month"}${a.months?` for ${a.months} ${a.months===1?"month":"months"}`:""}`)):t("div",{className:"ckf-box"},t("span",{className:"ckf-big"},`${a.percent}% off`),a.months?t("span",{className:"ckf-small"},`for ${a.months} ${a.months===1?"month":"months"}`):false)),a.kind==="pause"&&a.months&&(O=t("div",{className:"ckf-box"},t("span",{},`Pause for up to ${a.months} ${a.months===1?"month":"months"}. Your data stays.`))),a.kind==="downgrade"&&a.planName&&(O=t("div",{className:"ckf-box"},t("b",{},a.planName)));let v=a.kind==="contact"?t("textarea",{className:"ckf-text",placeholder:"What would make you stay?","aria-label":"Your message",maxlength:"500","data-ckf-id":"comment",onInput:S=>u=S.target.value}):null;v&&(v.value=u),d.push(x?t("p",{className:"ckf-small"},`You said: ${x}`):false,t("h2",{className:"ckf-h",id:o},a.headline),O,v!=null?v:false,t("div",{className:"ckf-btns"},P(l?"One moment\u2026":A(a),"primary",()=>n.cancel.accept(u),{disabled:l,id:"go"}),P("No thanks, continue cancelling","quiet",n.cancel.decline,{disabled:l})));}else {let x=r.steps===1?null:t("textarea",{className:"ckf-text",placeholder:"Anything else we should know? (optional)","aria-label":"Anything else we should know? (optional)",maxlength:"500","data-ckf-id":"comment",onInput:O=>u=O.target.value});x&&(x.value=u),d.push(t("h2",{className:"ckf-h",id:o},r.flow.confirm.title),r.flow.confirm.body?t("p",{className:"ckf-p"},r.flow.confirm.body):false,x!=null?x:false,t("div",{className:"ckf-btns"},P(l?"One moment\u2026":r.flow.confirm.button,"danger",()=>n.cancel.confirm(u),{disabled:l,id:"go"}),P("Keep my plan","secondary",n.cancel.close,{disabled:l})));}return t("div",{className:"ckf-scrim",onClick:a=>a.target===a.currentTarget&&!l&&n.cancel.close()},t("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":o},t("div",{className:"ckf-top"},V(r.step,r.steps),$("Close",n.cancel.close)),...d,r.error?t("p",{className:"ckf-err",role:"alert"},r.error):false))},p=r=>{let o=r.step,l=t("div",{className:"ckf-card",role:"dialog","aria-modal":o.kind==="modal"?"true":void 0,"aria-labelledby":"ckf-title"},t("div",{className:"ckf-top"},r.total>1?t("p",{className:"ckf-small"},`Step ${r.index+1} of ${r.total}`):t("span"),$("Close the tour",n.onboarding.dismiss)),t("h2",{className:"ckf-h",id:"ckf-title"},o.title),o.body?t("p",{className:"ckf-p"},o.body):false,t("div",{className:"ckf-row"},P(o.button||(r.last?"Done":"Next"),"primary",n.onboarding.next,{id:"go"})));if(o.kind==="modal")return t("div",{className:"ckf-scrim"},l);let d=o.target?i(o.target):null,m=t("div",{className:"ckf-float"},l);if(d){let y=t("div",{className:"ckf-ring","aria-hidden":"true"});return w={float:m,ring:y,target:d},b(m,y,d),t("div",{},y,m)}return m},i=r=>{var l;let o=()=>document.querySelector(`[data-ck-target="${CSS.escape(r)}"]`);return /^[#.[]|[\s>:=]/.test(r)&&(l=f(r))!=null?l:o()},f=r=>{try{return document.querySelector(r)}catch(o){return null}},b=(r,o,l)=>{let d=l.getBoundingClientRect();Object.assign(o.style,{left:`${d.left-4}px`,top:`${d.top-4}px`,width:`${d.width+8}px`,height:`${d.height+8}px`});let m=Math.min(340,window.innerWidth-24),y=Math.max(12,Math.min(d.left,window.innerWidth-m-12)),E=d.bottom+12;Object.assign(r.style,{left:`${y}px`,right:"auto",width:`${m}px`}),E+200<window.innerHeight?Object.assign(r.style,{top:`${E}px`,bottom:"auto"}):Object.assign(r.style,{top:"auto",bottom:`${Math.max(12,window.innerHeight-d.top+12)}px`});},h=r=>{let o=r.items.filter(l=>l.done).length;return t("div",{className:"ckf-float"},t("div",{className:"ckf-card",role:"region","aria-labelledby":"ckf-title"},t("div",{className:"ckf-top"},t("h2",{className:"ckf-h",id:"ckf-title"},r.flow.name),$("Hide the checklist",n.onboarding.dismiss)),t("p",{className:"ckf-small"},`${o} of ${r.items.length} done`),t("div",{className:"ckf-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r.items.length),"aria-valuenow":String(o)},t("i",{style:`width:${o/r.items.length*100}%`})),t("div",{className:"ckf-opts"},...r.items.map(({step:l,done:d})=>{let m=[t("span",{className:"ckf-tick","aria-hidden":"true"},d?"\u2713":""),t("span",{},t("b",{},l.title),l.body?t("span",{className:"ckf-small"},l.body):false)];return d||l.event?t("div",{className:"ckf-check","data-done":d,role:"listitem"},...m):t("button",{type:"button",className:"ckf-check","aria-label":`Mark \u201C${l.title}\u201D done`,"data-ckf-id":`i:${l.id}`,onClick:()=>n.onboarding.check(l.id)},...m)}))))},N=r=>{let o=r.message,l=o.button?P(o.button,"primary",n.message.click,{id:"go"}):false;return o.style==="banner"?t("div",{className:"ckf-banner",role:"status"},t("span",{},t("b",{},o.title),o.body?t("span",{className:"ckf-small"},o.body):false),l,$("Dismiss",n.message.dismiss)):t("div",{className:"ckf-scrim",onClick:d=>d.target===d.currentTarget&&n.message.dismiss()},t("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},t("div",{className:"ckf-top"},t("span"),$("Dismiss",n.message.dismiss)),t("h2",{className:"ckf-h",id:"ckf-title"},o.title),o.body?t("p",{className:"ckf-p"},o.body):false,l?t("div",{className:"ckf-row"},l):false))},F=()=>{var d,m,y,E,M;let r=n.view(),o=r?W(r):"",l=(m=(d=document.activeElement)==null?void 0:d.closest)!=null&&m.call(d,".ckf-root")?(y=document.activeElement)==null?void 0:y.getAttribute("data-ckf-id"):null;if(o&&!s&&document.activeElement instanceof HTMLElement&&!document.activeElement.closest(".ckf-root")&&(g=document.activeElement),o!==s&&!o.startsWith("c:")&&(u=""),o||(u=""),w=null,c.replaceChildren(...r?[r.type==="cancel"?C(r):r.type==="step"?p(r):r.type==="checklist"?h(r):N(r)]:[]),o!==s){let a=c.querySelector("[aria-modal=true]"),x=(E=a==null?void 0:a.querySelector("[role=radio], [data-ckf-id=go], textarea"))!=null?E:null;x==null||x.focus(),!o&&g&&(g.focus(),g=null);}else l&&((M=c.querySelector(`[data-ckf-id="${CSS.escape(l)}"]`))==null||M.focus());s=o;},k=r=>{if(r.key!=="Escape")return;let o=n.view();(o==null?void 0:o.type)==="cancel"?n.cancel.close():(o==null?void 0:o.type)==="message"?n.message.dismiss():(o==null?void 0:o.type)==="step"&&o.step.kind==="modal"&&n.onboarding.dismiss();},R=()=>{w&&b(w.float,w.ring,w.target);};document.addEventListener("keydown",k),window.addEventListener("resize",R),window.addEventListener("scroll",R,{passive:true,capture:true});let I=n.subscribe(F);return F(),()=>{I(),document.removeEventListener("keydown",k),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,{capture:true}),c.remove();}},K=(n,e={})=>{if(typeof document=="undefined")return ()=>{};let c=H(e),s="",g=null,u=()=>{var h,N,F;let p=n.view(),i=p?`${p.paywall.id}:${p.index}`:"";if(i&&!s&&document.activeElement instanceof HTMLElement&&(g=document.activeElement),!p){c.replaceChildren(),c.removeAttribute("data-still"),s&&(g==null||g.focus()),s="";return}s&&c.setAttribute("data-still","");let f=p.page,b=f.kind==="plans"?t("div",{className:"ckf-opts",role:"radiogroup","aria-label":"Plans"},...p.plans.map(k=>t("button",{type:"button",role:"radio",className:"ckf-opt ckf-plan","aria-checked":String(p.plan===k.id),"data-ckf-id":`p:${k.id}`,onClick:()=>n.pick(k.id)},t("span",{className:"ckf-radio"}),t("span",{},k.name,k.note?t("span",{className:"ckf-small"},k.note):false),t("b",{},k.price)))):false;c.replaceChildren(t("div",{className:"ckf-scrim",onClick:k=>k.target===k.currentTarget&&n.close()},t("div",{className:"ckf-card ckf-pw",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},t("div",{className:"ckf-top"},V(p.index+1,p.total),$("Close",n.close)),t("h2",{className:"ckf-h",id:"ckf-title"},f.title),f.body?t("p",{className:"ckf-p"},f.body):false,f.kind==="benefits"&&((h=f.items)!=null&&h.length)?t("div",{className:"ckf-opts"},...f.items.map(k=>t("p",{className:"ckf-li"},k))):false,f.kind==="proof"&&((N=f.quotes)!=null&&N.length)?t("div",{className:"ckf-opts"},...f.quotes.map(k=>t("blockquote",{className:"ckf-quote"},k.text,k.by?t("cite",{},k.by):false))):false,b,p.error?t("p",{className:"ckf-err",role:"alert"},p.error):false,t("div",{className:"ckf-btns"},P(p.busy?"One moment\u2026":f.button||"Continue","primary",n.next,{disabled:p.busy||f.kind==="plans"&&!p.plan,id:"go"}),p.index?P("Back","quiet",n.back,{disabled:p.busy}):false)))),i!==s&&((F=c.querySelector("[data-ckf-id=go]"))==null||F.focus()),s=i;},w=p=>{n.view()&&p.key==="Escape"&&n.close();};document.addEventListener("keydown",w);let C=n.subscribe(u);return u(),()=>{C(),document.removeEventListener("keydown",w),c.remove();}};var Y=n=>{let e=2166136261;for(let c=0;c<n.length;c++)e^=n.charCodeAt(c),e=Math.imul(e,16777619);return (e>>>0)/4294967296};var q=(n,e)=>{var u,w,C,p;let c=(w=(u=n.variants[0])==null?void 0:u.id)!=null?w:"control";if(n.winner)return n.winner;if(n.status!=="running")return c;let s=Y(`${n.key}:${e}`),g=0;for(let i of n.variants)if(g+=i.weight,s<g)return i.id;return (p=(C=n.variants[n.variants.length-1])==null?void 0:C.id)!=null?p:c};var _="$paywall",B=(n,e,c)=>{var w,C;let s=e.experiment?n==null?void 0:n.experiments.find(p=>p.key===e.experiment):void 0,g=s?q(s,c):(w=e.variants[0])==null?void 0:w.id,u=(C=e.variants.find(p=>p.id===g))!=null?C:e.variants[0];return u?{variant:u.id,pages:u.pages,test:(s==null?void 0:s.status)==="running"&&!s.winner?s.key:void 0}:null},z=n=>{let e=null,c=new Set,s=()=>{for(let i of [...c])try{i();}catch(f){}},g=()=>e?{paywall:e.w.id,placement:e.w.placement,variant:e.variant}:{},u=()=>{e&&!e.seen.has(e.index)&&(e.seen.add(e.index),n.track(_,{...g(),page:e.pages[e.index].id,index:e.index,action:"page"})),s();},w=i=>{var b,h;let f=e;f&&(e=null,i.outcome==="closed"&&((h=(b=f.options).onClose)==null||h.call(b,i)),f.resolve(i),s());},C=i=>{var f;return {outcome:i,index:(f=e==null?void 0:e.index)!=null?f:0,...e?{paywall:e.w.id,variant:e.variant}:{},...i!=="closed"&&e?{plan:e.plans.find(b=>b.id===e.plan)}:{}}},p=()=>{let i=e,f=i==null?void 0:i.plans.find(b=>b.id===i.plan);if(!(!i||!f||i.busy)){if(!i.options.onPurchase)return w(C("chosen"));i.busy=true,i.error=void 0,s(),Promise.resolve().then(()=>{var b,h;return (h=(b=i.options).onPurchase)==null?void 0:h.call(b,f)}).then(b=>{if(i.busy=false,e===i){if(b===false)return s();n.track(_,{...g(),page:i.pages[i.index].id,index:i.index,plan:f.id,action:"purchased"}),w(C("purchased"));}},()=>{i.busy=false,i.error="The purchase did not go through. Please try again.",s();});}};return {open:(i,f={})=>{var o,l,d;if(e)return e.promise;let b=n.config(),h=(o=b==null?void 0:b.paywalls)==null?void 0:o.find(m=>m.placement===i),N=h?B(b,h,n.distinctId()):null;if(!h||!(N!=null&&N.pages.length))return Promise.resolve({outcome:"closed",index:0});let F=new Map(((l=f.plans)!=null?l:[]).map(m=>[m.id,m])),k=h.plans.map(m=>{var y;return (y=F.get(m.id))!=null?y:m}),R=()=>{},I=new Promise(m=>R=m),r=k.some(m=>m.id===h.highlight)?h.highlight:(d=k[0])==null?void 0:d.id;return e={w:h,variant:N.variant,pages:N.pages,plans:k,index:0,plan:r,busy:false,seen:new Set,options:f,resolve:R,promise:I},N.test&&n.track("$exposure",{experiment:N.test,variant:N.variant}),u(),I},view:()=>e?{paywall:e.w,variant:e.variant,page:e.pages[e.index],index:e.index,total:e.pages.length,last:e.index===e.pages.length-1,plans:e.plans,plan:e.plan,busy:e.busy,error:e.error}:null,subscribe:i=>(c.add(i),()=>c.delete(i)),next:()=>{if(!(!e||e.busy)){if(e.pages[e.index].kind==="plans"||e.index===e.pages.length-1)return p();e.index++,e.error=void 0,u();}},back:()=>{!e||e.busy||!e.index||(e.index--,e.error=void 0,s());},pick:i=>{!e||e.busy||!e.plans.some(f=>f.id===i)||(e.plan=i,e.error=void 0,s());},close:()=>{!e||e.busy||(n.track(_,{...g(),index:e.index,action:"closed"}),w(C("closed")));}}};var J=(n,e)=>{let c=z(n);return K(c,e),c};window.__mrrocketFlows={mountFlows:j,paywallHost:J};})();