@drawbridge/components 0.1.13 → 0.1.15

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 (242) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +577 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +540 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +277 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +243 -0
  48. package/dist/dashboard/card-order.js +231 -29
  49. package/dist/dashboard/card-order.mjs +231 -29
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +205 -0
  55. package/dist/dashboard/connection-workflows.mjs +171 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-field-select.js +51 -5
  81. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  82. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  83. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  84. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  87. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  88. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  89. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  90. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  91. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  92. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  93. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  94. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  95. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  96. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  97. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  99. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  100. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  101. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  102. package/dist/dashboard/form-organization-campaign-section.js +243 -0
  103. package/dist/dashboard/form-organization-campaign-section.mjs +214 -0
  104. package/dist/dashboard/form-organization-campaign.js +114 -469
  105. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  106. package/dist/dashboard/form-organization-export.js +4 -7
  107. package/dist/dashboard/form-organization-export.mjs +4 -7
  108. package/dist/dashboard/form-organization-identity.js +46 -51
  109. package/dist/dashboard/form-organization-identity.mjs +46 -51
  110. package/dist/dashboard/form-organization-workflow.js +708 -687
  111. package/dist/dashboard/form-organization-workflow.mjs +704 -683
  112. package/dist/dashboard/form-organization.js +82 -110
  113. package/dist/dashboard/form-organization.mjs +81 -109
  114. package/dist/dashboard/form-otc.js +4 -5
  115. package/dist/dashboard/form-otc.mjs +4 -5
  116. package/dist/dashboard/form-payment-methods.js +20 -9
  117. package/dist/dashboard/form-payment-methods.mjs +20 -9
  118. package/dist/dashboard/form-stripe.js +30 -0
  119. package/dist/dashboard/form-stripe.mjs +26 -0
  120. package/dist/dashboard/input-array.js +4 -2
  121. package/dist/dashboard/input-array.mjs +4 -2
  122. package/dist/dashboard/input-combobox.js +7 -3
  123. package/dist/dashboard/input-combobox.mjs +7 -3
  124. package/dist/dashboard/input-date.js +7 -0
  125. package/dist/dashboard/input-date.mjs +7 -0
  126. package/dist/dashboard/input-fields.js +80 -20
  127. package/dist/dashboard/input-fields.mjs +80 -20
  128. package/dist/dashboard/input-file.js +21 -1
  129. package/dist/dashboard/input-file.mjs +21 -1
  130. package/dist/dashboard/input-font.js +10 -1
  131. package/dist/dashboard/input-font.mjs +10 -1
  132. package/dist/dashboard/lib/item-list.js +57 -0
  133. package/dist/dashboard/lib/item-list.mjs +33 -0
  134. package/dist/dashboard/lib/menu.js +50 -0
  135. package/dist/dashboard/lib/menu.mjs +26 -0
  136. package/dist/dashboard/locked.js +82 -0
  137. package/dist/dashboard/locked.mjs +53 -0
  138. package/dist/dashboard/menu.js +72 -19
  139. package/dist/dashboard/menu.mjs +72 -19
  140. package/dist/dashboard/note-ai.js +69 -0
  141. package/dist/dashboard/note-ai.mjs +36 -0
  142. package/dist/dashboard/preview.js +419 -0
  143. package/dist/dashboard/preview.mjs +384 -0
  144. package/dist/dashboard/steps.js +39 -13
  145. package/dist/dashboard/steps.mjs +37 -12
  146. package/dist/dashboard/table-contacts.js +136 -0
  147. package/dist/dashboard/table-contacts.mjs +103 -0
  148. package/dist/dashboard/template-not-found.js +4 -2
  149. package/dist/dashboard/template-not-found.mjs +4 -2
  150. package/dist/dashboard/template-socket.js +20 -7
  151. package/dist/dashboard/template-socket.mjs +20 -7
  152. package/dist/icons/desktop.js +46 -0
  153. package/dist/icons/desktop.mjs +27 -0
  154. package/dist/icons/phone.js +46 -0
  155. package/dist/icons/phone.mjs +27 -0
  156. package/dist/icons/puzzle-piece.js +46 -0
  157. package/dist/icons/puzzle-piece.mjs +27 -0
  158. package/dist/icons/tablet.js +46 -0
  159. package/dist/icons/tablet.mjs +27 -0
  160. package/dist/icons/users.js +46 -0
  161. package/dist/icons/users.mjs +27 -0
  162. package/dist/input-checkbox.js +1 -0
  163. package/dist/input-checkbox.mjs +1 -0
  164. package/dist/input-code.js +83 -0
  165. package/dist/input-code.mjs +50 -0
  166. package/dist/input-text.js +2 -1
  167. package/dist/input-text.mjs +2 -1
  168. package/dist/shared/button.js +1 -1
  169. package/dist/shared/button.mjs +1 -1
  170. package/dist/shared/input-checkbox-list.js +0 -1
  171. package/dist/shared/input-checkbox-list.mjs +0 -1
  172. package/dist/shared/input-switch.js +6 -1
  173. package/dist/shared/input-switch.mjs +6 -1
  174. package/dist/shared/lib/campaign.js +123 -0
  175. package/dist/shared/lib/campaign.mjs +96 -0
  176. package/dist/shared/lib/helpers.js +14 -2
  177. package/dist/shared/lib/helpers.mjs +13 -2
  178. package/package.json +133 -13
  179. package/types/bridge/form-subdomain-header.d.ts +2 -0
  180. package/types/bridge/form-subdomain-missions.d.ts +38 -0
  181. package/types/bridge/form-subdomain.d.ts +23 -1
  182. package/types/bridge/lib/entry.d.ts +26 -0
  183. package/types/bridge/lib/location.d.ts +13 -0
  184. package/types/bridge/lib/order.d.ts +30 -0
  185. package/types/bridge/lib/url.d.ts +19 -0
  186. package/types/bridge/template-modal.d.ts +1 -1
  187. package/types/bridge/template-preview.d.ts +10 -0
  188. package/types/bridge/template-subdomain-link.d.ts +2 -0
  189. package/types/dashboard/accordion.d.ts +2 -0
  190. package/types/dashboard/avatar.d.ts +18 -2
  191. package/types/dashboard/buttons-subscription.d.ts +22 -0
  192. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  193. package/types/dashboard/card-order.d.ts +25 -1
  194. package/types/dashboard/card-section.d.ts +2 -0
  195. package/types/dashboard/connection-workflows.d.ts +33 -0
  196. package/types/dashboard/device.d.ts +12 -0
  197. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  198. package/types/dashboard/form-ai.d.ts +2 -2
  199. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  200. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  201. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  202. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  203. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  204. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  205. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  206. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  207. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  208. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  209. package/types/dashboard/form-organization-campaign-section.d.ts +29 -0
  210. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  211. package/types/dashboard/form-organization-identity.d.ts +2 -0
  212. package/types/dashboard/form-organization-workflow.d.ts +56 -47
  213. package/types/dashboard/form-organization.d.ts +7 -2
  214. package/types/dashboard/form-stripe.d.ts +3 -0
  215. package/types/dashboard/input-combobox.d.ts +2 -0
  216. package/types/dashboard/input-date.d.ts +2 -0
  217. package/types/dashboard/input-fields.d.ts +3 -2
  218. package/types/dashboard/input-file.d.ts +4 -0
  219. package/types/dashboard/lib/item-list.d.ts +14 -0
  220. package/types/dashboard/lib/menu.d.ts +17 -0
  221. package/types/dashboard/locked.d.ts +10 -0
  222. package/types/dashboard/menu.d.ts +10 -2
  223. package/types/dashboard/note-ai.d.ts +15 -0
  224. package/types/dashboard/preview.d.ts +33 -0
  225. package/types/dashboard/steps.d.ts +19 -4
  226. package/types/dashboard/table-cell-title.d.ts +2 -2
  227. package/types/dashboard/table-contacts.d.ts +2 -0
  228. package/types/icons/desktop.d.ts +5 -0
  229. package/types/icons/phone.d.ts +5 -0
  230. package/types/icons/puzzle-piece.d.ts +5 -0
  231. package/types/icons/tablet.d.ts +5 -0
  232. package/types/icons/users.d.ts +5 -0
  233. package/types/input-code.d.ts +23 -0
  234. package/types/shared/input-switch.d.ts +2 -0
  235. package/types/shared/lib/campaign.d.ts +35 -0
  236. package/types/shared/lib/helpers.d.ts +3 -0
  237. package/dist/dashboard/card-integration.js +0 -187
  238. package/dist/dashboard/card-integration.mjs +0 -158
  239. package/dist/dashboard/iframe.js +0 -159
  240. package/dist/dashboard/iframe.mjs +0 -130
  241. package/types/dashboard/card-integration.d.ts +0 -24
  242. package/types/dashboard/iframe.d.ts +0 -18
@@ -20,43 +20,91 @@ import ProviderResource from "./provider-resource.mjs";
20
20
  import WrapperAI from "./wrapper-ai.mjs";
21
21
  import Button from "../shared/button.mjs";
22
22
  import External from "../icons/external.mjs";
23
+ import Chart from "../icons/chart.mjs";
24
+ import Document from "../icons/document.mjs";
25
+ import Flag from "../icons/flag.mjs";
26
+ import Home from "../icons/home.mjs";
27
+ import LinkIcon from "../icons/link.mjs";
28
+ import PuzzlePiece from "../icons/puzzle-piece.mjs";
29
+ import Queue from "../icons/queue.mjs";
30
+ import Share from "../icons/share.mjs";
31
+ import Star from "../icons/star.mjs";
32
+ import Users from "../icons/users.mjs";
33
+ import { menuRow } from "./lib/menu.mjs";
34
+ const icons = {
35
+ chart: Chart,
36
+ document: Document,
37
+ flag: Flag,
38
+ home: Home,
39
+ link: LinkIcon,
40
+ // Connections (Darren, Dulce Local walk, 2026-10-29).
41
+ "puzzle-piece": PuzzlePiece,
42
+ queue: Queue,
43
+ share: Share,
44
+ star: Star,
45
+ users: Users
46
+ };
23
47
  const MenuItem = ({
24
48
  active,
25
49
  badge,
26
50
  child,
27
- children,
51
+ children = [],
28
52
  disabled,
29
53
  element: Element = Link,
30
54
  error,
55
+ highlighted = active,
56
+ icon,
31
57
  locked,
32
58
  onClick = () => {
33
59
  },
60
+ open = active,
34
61
  title,
35
62
  ...rest
36
63
  }) => {
37
- const hasChildren = (children == null ? void 0 : children.length) > 0;
38
- const isActive = active || hasChildren && children.some((c) => c.active);
64
+ const Icon = icons[icon];
39
65
  const classes = {
40
66
  row: [
41
- "flex items-center justify-between transform duration-300 text-left py-1 px-2 rounded",
42
- child ? "w-auto ml-3" : "w-full",
43
- isActive ? child ? "" : "bg-gray-dark" : "hover:bg-gray-dark/50",
67
+ "flex items-center justify-between w-full transform duration-300 text-left py-1 rounded",
68
+ // A page under a row lines up with the row's name, past its icon.
69
+ child ? "pl-9 pr-2" : "px-2",
70
+ highlighted ? "bg-gray-dark" : "hover:bg-gray-dark/50",
44
71
  // A Button fades itself from its own disabled prop.
45
72
  disabled && Element !== "button" && "disabled"
46
73
  ],
47
74
  text: [
48
- "flex items-center space-x-2 w-full",
49
- isActive ? child ? "text-white/50" : "text-white" : "text-white"
75
+ "flex items-center gap-2 w-full min-w-0",
76
+ child && !highlighted ? "text-white/60" : "text-white",
77
+ // The open row stays bold while a page under it is highlighted.
78
+ open && "font-medium"
50
79
  ]
51
80
  };
52
81
  const content = /* @__PURE__ */ jsxs(Fragment, { children: [
53
- /* @__PURE__ */ jsx(
82
+ /* @__PURE__ */ jsxs(
54
83
  "span",
55
84
  {
56
85
  ...{
57
86
  className: classes.text.filter(Boolean).join(" ")
58
87
  },
59
- children: /* @__PURE__ */ jsx("span", { children: title })
88
+ children: [
89
+ Icon && /* @__PURE__ */ jsx(
90
+ Icon,
91
+ {
92
+ ...{
93
+ "aria-hidden": true,
94
+ className: "w-5 h-5 shrink-0"
95
+ }
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsx(
99
+ "span",
100
+ {
101
+ ...{
102
+ className: "truncate"
103
+ },
104
+ children: title
105
+ }
106
+ )
107
+ ]
60
108
  }
61
109
  ),
62
110
  /* @__PURE__ */ jsxs(
@@ -129,21 +177,22 @@ const MenuItem = ({
129
177
  children: content
130
178
  }
131
179
  ),
132
- hasChildren && isActive && /* @__PURE__ */ jsx(
180
+ open && children.length > 0 && /* @__PURE__ */ jsx(
133
181
  "div",
134
182
  {
135
183
  ...{
136
- className: "mb-4"
184
+ className: "mt-0.5 mb-2"
137
185
  },
138
- children: children.map((props, key) => /* @__PURE__ */ jsx(
186
+ children: children.map(({ key: childKey, exact, ...props }, key) => /* @__PURE__ */ jsx(
139
187
  MenuItem,
140
188
  {
141
189
  ...{
142
190
  ...props,
143
- child: true
191
+ child: true,
192
+ onClick
144
193
  }
145
194
  },
146
- key
195
+ childKey || key
147
196
  ))
148
197
  }
149
198
  )
@@ -181,17 +230,21 @@ const Menu = ({
181
230
  children: group.title
182
231
  }
183
232
  ),
184
- group.items.map(({ key: itemKey, exact, ...item }, index) => {
185
- const active = !item.href ? false : exact ? path === item.href : path === item.href || path.startsWith(item.href + "/");
233
+ group.items.map((item, index) => {
234
+ const { key: itemKey, exact, ...row } = menuRow(item, path);
186
235
  return /* @__PURE__ */ jsx(
187
236
  MenuItem,
188
237
  {
189
238
  ...{
190
- ...item,
239
+ ...row,
240
+ // An item with no href is not a destination, and MenuItem
241
+ // defaults its element to Link — which hands next/link an
242
+ // undefined href, and formatUrl then destructures `auth` off
243
+ // undefined and takes the WHOLE PAGE down. A menu row that
244
+ // forgot its href should be an inert row, not a white screen.
191
245
  ...!item.href && {
192
246
  element: "div"
193
247
  },
194
- active,
195
248
  onClick
196
249
  }
197
250
  },
@@ -0,0 +1,69 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var note_ai_exports = {};
29
+ __export(note_ai_exports, {
30
+ default: () => note_ai_default,
31
+ needsCredits: () => needsCredits
32
+ });
33
+ module.exports = __toCommonJS(note_ai_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_link = __toESM(require("./link"));
36
+ var import_button = __toESM(require("../shared/button"));
37
+ const needsCredits = (balance) => Boolean(balance) && !(Number(balance.ai) > 0);
38
+ const NoteAI = ({ balance, onClose }) => {
39
+ if (!needsCredits(balance)) return null;
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
41
+ "p",
42
+ {
43
+ ...{
44
+ className: "text-sm text-center"
45
+ },
46
+ children: [
47
+ "You need AI credits to generate.\xA0",
48
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ import_button.default,
50
+ {
51
+ ...{
52
+ element: import_link.default,
53
+ href: "/account",
54
+ inline: true,
55
+ onClick: onClose,
56
+ variant: "link"
57
+ },
58
+ children: "Add credits"
59
+ }
60
+ )
61
+ ]
62
+ }
63
+ );
64
+ };
65
+ var note_ai_default = NoteAI;
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ needsCredits
69
+ });
@@ -0,0 +1,36 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import Link from "./link.mjs";
3
+ import Button from "../shared/button.mjs";
4
+ const needsCredits = (balance) => Boolean(balance) && !(Number(balance.ai) > 0);
5
+ const NoteAI = ({ balance, onClose }) => {
6
+ if (!needsCredits(balance)) return null;
7
+ return /* @__PURE__ */ jsxs(
8
+ "p",
9
+ {
10
+ ...{
11
+ className: "text-sm text-center"
12
+ },
13
+ children: [
14
+ "You need AI credits to generate.\xA0",
15
+ /* @__PURE__ */ jsx(
16
+ Button,
17
+ {
18
+ ...{
19
+ element: Link,
20
+ href: "/account",
21
+ inline: true,
22
+ onClick: onClose,
23
+ variant: "link"
24
+ },
25
+ children: "Add credits"
26
+ }
27
+ )
28
+ ]
29
+ }
30
+ );
31
+ };
32
+ var note_ai_default = NoteAI;
33
+ export {
34
+ note_ai_default as default,
35
+ needsCredits
36
+ };
@@ -0,0 +1,419 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var preview_exports = {};
30
+ __export(preview_exports, {
31
+ PreviewPage: () => PreviewPage,
32
+ clamp: () => clamp,
33
+ default: () => preview_default,
34
+ fitScale: () => fitScale
35
+ });
36
+ module.exports = __toCommonJS(preview_exports);
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var import_react = require("react");
39
+ var import_react_dom = require("react-dom");
40
+ var import_button = __toESM(require("../shared/button"));
41
+ var import_loader = __toESM(require("../shared/loader"));
42
+ var import_input_combobox = __toESM(require("./input-combobox"));
43
+ var import_device = __toESM(require("./device"));
44
+ var import_desktop = __toESM(require("../icons/desktop"));
45
+ var import_phone = __toESM(require("../icons/phone"));
46
+ var import_tablet = __toESM(require("../icons/tablet"));
47
+ const DEVICES = {
48
+ desktop: { icon: import_desktop.default, label: "Desktop" },
49
+ tablet: { icon: import_tablet.default, label: "Tablet" },
50
+ phone: { icon: import_phone.default, label: "Phone" }
51
+ };
52
+ const HEIGHT = 520;
53
+ const GUTTER = 24;
54
+ const NARROW = 486;
55
+ const ZOOMS = [
56
+ { key: "Fit", value: "fit" },
57
+ { key: "25%", value: 0.25 },
58
+ { key: "50%", value: 0.5 },
59
+ { key: "100%", value: 1 },
60
+ { key: "150%", value: 1.5 },
61
+ { key: "200%", value: 2 }
62
+ ];
63
+ const clamp = (value, limit) => Math.min(limit, Math.max(-limit, value));
64
+ const fitScale = (space, size) => space.width && size.width ? Math.min(1, (space.width - GUTTER) / size.width, (space.height - GUTTER) / size.height) : 1;
65
+ const PreviewFrame = ({
66
+ children,
67
+ states
68
+ }) => {
69
+ var _a;
70
+ const [device, setDevice] = (0, import_react.useState)("phone");
71
+ const [zoom, setZoom] = (0, import_react.useState)("fit");
72
+ const [space, setSpace] = (0, import_react.useState)({ height: 0, width: 0 });
73
+ const [frameSize, setFrameSize] = (0, import_react.useState)({ device: null, height: 0, width: 0 });
74
+ const [offset, setOffset] = (0, import_react.useState)({ x: 0, y: 0 });
75
+ const [ease, setEase] = (0, import_react.useState)(false);
76
+ const [dragging, setDragging] = (0, import_react.useState)(false);
77
+ const area = (0, import_react.useRef)(null);
78
+ const frame = (0, import_react.useRef)(null);
79
+ const drag = (0, import_react.useRef)(null);
80
+ const scale = zoom === "fit" ? fitScale(space, frameSize) : zoom;
81
+ const reach = {
82
+ x: Math.max(0, (frameSize.width * scale - space.width) / 2),
83
+ y: Math.max(0, (frameSize.height * scale - space.height) / 2)
84
+ };
85
+ const larger = reach.x > 0 || reach.y > 0;
86
+ const narrow = space.width > 0 && space.width < NARROW;
87
+ const hasStates = ((_a = states == null ? void 0 : states.options) == null ? void 0 : _a.length) > 1;
88
+ const ready = space.width > 0 && frameSize.device === device;
89
+ const x = (space.width - frameSize.width * scale) / 2 + clamp(offset.x, reach.x);
90
+ const y = (space.height - frameSize.height * scale) / 2 + clamp(offset.y, reach.y);
91
+ (0, import_react.useLayoutEffect)(() => {
92
+ const measure = () => setSpace({ height: area.current.clientHeight, width: area.current.clientWidth });
93
+ const observer = new ResizeObserver(measure);
94
+ measure();
95
+ observer.observe(area.current);
96
+ return () => observer.disconnect();
97
+ }, []);
98
+ (0, import_react.useLayoutEffect)(() => {
99
+ const measure = () => setFrameSize({ device, height: frame.current.offsetHeight, width: frame.current.offsetWidth });
100
+ const observer = new ResizeObserver(measure);
101
+ measure();
102
+ observer.observe(frame.current);
103
+ return () => observer.disconnect();
104
+ }, [device]);
105
+ (0, import_react.useLayoutEffect)(() => {
106
+ setOffset({ x: 0, y: 0 });
107
+ }, [device, zoom]);
108
+ (0, import_react.useEffect)(() => {
109
+ if (!ease) return;
110
+ const timer = setTimeout(() => setEase(false), 200);
111
+ return () => clearTimeout(timer);
112
+ }, [ease]);
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
114
+ "div",
115
+ {
116
+ ...{
117
+ // A toolbar across the top, then the area the device sits in.
118
+ className: "flex flex-col w-full min-w-0 rounded border border-gray overflow-hidden"
119
+ },
120
+ children: [
121
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
122
+ "div",
123
+ {
124
+ ...{
125
+ // The states on the left, the zoom and the sizes on the right.
126
+ className: "flex flex-wrap items-center justify-between gap-2 px-3 py-2 bg-white border-b border-gray"
127
+ },
128
+ children: [
129
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
+ "div",
131
+ {
132
+ ...{
133
+ // Narrow with no states, the empty slot takes no line.
134
+ className: narrow ? hasStates ? "w-full" : "hidden" : "w-52 max-w-full"
135
+ },
136
+ children: hasStates && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ import_input_combobox.default,
138
+ {
139
+ ...{
140
+ onChange: states.onChange,
141
+ options: states.options,
142
+ size: "small",
143
+ value: states.value
144
+ }
145
+ }
146
+ )
147
+ }
148
+ ),
149
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
150
+ "div",
151
+ {
152
+ ...{
153
+ className: "flex items-center gap-2 " + (narrow ? "w-full" : "ml-auto")
154
+ },
155
+ children: [
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
+ "div",
158
+ {
159
+ ...{
160
+ className: narrow ? "flex-1 min-w-0" : "w-24"
161
+ },
162
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ import_input_combobox.default,
164
+ {
165
+ ...{
166
+ onChange: (value) => {
167
+ setEase(true);
168
+ setZoom(value);
169
+ },
170
+ options: ZOOMS,
171
+ size: "small",
172
+ value: zoom
173
+ }
174
+ }
175
+ )
176
+ }
177
+ ),
178
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
179
+ "div",
180
+ {
181
+ ...{
182
+ // The sizes, small icon buttons spaced as the dashboard's button
183
+ // groups are, the chosen one filled dark.
184
+ "aria-label": "Screen size",
185
+ className: "flex gap-2",
186
+ role: "group"
187
+ },
188
+ children: Object.entries(DEVICES).map(([key, { icon, label }]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
189
+ import_button.default,
190
+ {
191
+ ...{
192
+ "aria-label": label,
193
+ "aria-pressed": device === key,
194
+ icon,
195
+ inline: true,
196
+ // A new size starts fitted.
197
+ onClick: () => {
198
+ setEase(false);
199
+ setDevice(key);
200
+ setZoom("fit");
201
+ },
202
+ size: "small",
203
+ variant: device === key ? "primary" : "secondary"
204
+ }
205
+ },
206
+ key
207
+ ))
208
+ }
209
+ )
210
+ ]
211
+ }
212
+ )
213
+ ]
214
+ }
215
+ ),
216
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
217
+ "div",
218
+ {
219
+ ...{
220
+ className: "relative w-full overflow-hidden bg-gray-light touch-none select-none" + (larger ? dragging ? " cursor-grabbing" : " cursor-grab" : ""),
221
+ // Dragging moves the device only when it is larger than the area. The
222
+ // pointer is captured, so a drag that leaves the area still follows it
223
+ // and still ends on release.
224
+ onLostPointerCapture: () => {
225
+ drag.current = null;
226
+ setDragging(false);
227
+ },
228
+ onPointerDown: (event) => {
229
+ if (!larger || event.button !== 0) return;
230
+ const from = { x: clamp(offset.x, reach.x), y: clamp(offset.y, reach.y) };
231
+ setEase(false);
232
+ setOffset(from);
233
+ drag.current = { left: event.clientX - from.x, top: event.clientY - from.y };
234
+ event.currentTarget.setPointerCapture(event.pointerId);
235
+ setDragging(true);
236
+ },
237
+ onPointerMove: (event) => drag.current && setOffset({
238
+ x: clamp(event.clientX - drag.current.left, reach.x),
239
+ y: clamp(event.clientY - drag.current.top, reach.y)
240
+ }),
241
+ ref: area,
242
+ style: {
243
+ height: HEIGHT
244
+ }
245
+ },
246
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
247
+ "div",
248
+ {
249
+ ...{
250
+ // The device, measured for fitting, placed by one transform from the top
251
+ // left. pointer-events-none: a picture of the page, so nothing in it
252
+ // can be clicked.
253
+ className: "absolute top-0 left-0 w-max origin-top-left pointer-events-none",
254
+ "data-preview-stage": true,
255
+ ref: frame,
256
+ style: {
257
+ opacity: ready ? 1 : 0,
258
+ transform: "translate(" + x + "px, " + y + "px) scale(" + scale + ")",
259
+ // The fade in, once laid out; a zoom from the dropdown eases. Hidden at once.
260
+ transition: ready ? ["opacity 150ms ease", ease && "transform 150ms ease"].filter(Boolean).join(", ") : "none"
261
+ }
262
+ },
263
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
264
+ import_device.default,
265
+ {
266
+ ...{
267
+ type: device
268
+ },
269
+ children
270
+ }
271
+ )
272
+ }
273
+ )
274
+ }
275
+ )
276
+ ]
277
+ }
278
+ );
279
+ };
280
+ const STYLES = 'style, link[rel="stylesheet"]';
281
+ const mirrorStyles = (doc) => {
282
+ const copy = (node) => doc.head.appendChild(node.cloneNode(true));
283
+ document.querySelectorAll(STYLES).forEach(copy);
284
+ const base = doc.createElement("style");
285
+ base.textContent = "html, body { height : 100%; margin : 0; }";
286
+ doc.head.appendChild(base);
287
+ const observer = new MutationObserver((records) => records.forEach((record) => record.addedNodes.forEach((node) => {
288
+ var _a;
289
+ return ((_a = node.matches) == null ? void 0 : _a.call(node, STYLES)) && copy(node);
290
+ })));
291
+ observer.observe(document.head, { childList: true });
292
+ return () => observer.disconnect();
293
+ };
294
+ const Preview = ({
295
+ children,
296
+ loading = false,
297
+ states,
298
+ style
299
+ }) => {
300
+ var _a, _b, _c, _d;
301
+ const frame = (0, import_react.useRef)(null);
302
+ const [body, setBody] = (0, import_react.useState)(null);
303
+ const stop = (0, import_react.useRef)(null);
304
+ (0, import_react.useEffect)(() => () => {
305
+ var _a2;
306
+ return (_a2 = stop.current) == null ? void 0 : _a2.call(stop);
307
+ }, []);
308
+ (0, import_react.useEffect)(() => {
309
+ var _a2, _b2, _c2, _d2;
310
+ if (!body) return;
311
+ body.style.backgroundColor = ((_b2 = (_a2 = style == null ? void 0 : style.background) == null ? void 0 : _a2.color) == null ? void 0 : _b2.rgb) || "#FFFFFF";
312
+ body.style.color = ((_d2 = (_c2 = style == null ? void 0 : style.text) == null ? void 0 : _c2.color) == null ? void 0 : _d2.rgb) || "";
313
+ }, [body, (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb, (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb]);
314
+ const onLoad = () => {
315
+ var _a2;
316
+ const doc = frame.current.contentDocument;
317
+ (_a2 = stop.current) == null ? void 0 : _a2.call(stop);
318
+ stop.current = mirrorStyles(doc);
319
+ setBody(doc.body);
320
+ };
321
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
322
+ PreviewFrame,
323
+ {
324
+ ...{
325
+ states
326
+ },
327
+ children: [
328
+ loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
329
+ import_loader.default,
330
+ {
331
+ ...{
332
+ className: "bg-purple-light"
333
+ }
334
+ }
335
+ ),
336
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
337
+ "iframe",
338
+ {
339
+ ...{
340
+ className: "block w-full h-full border-0",
341
+ onLoad,
342
+ ref: frame,
343
+ srcDoc: '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>',
344
+ title: "Preview"
345
+ }
346
+ }
347
+ ),
348
+ body && !loading && (0, import_react_dom.createPortal)(children, body)
349
+ ]
350
+ }
351
+ );
352
+ };
353
+ const PreviewPage = ({
354
+ states,
355
+ update,
356
+ url
357
+ }) => {
358
+ const frame = (0, import_react.useRef)(null);
359
+ const [loading, setLoading] = (0, import_react.useState)(true);
360
+ const origin = url ? new URL(url).origin : null;
361
+ const message = JSON.stringify({ update });
362
+ const post = () => {
363
+ var _a, _b;
364
+ return origin && origin !== "null" && ((_b = (_a = frame.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(JSON.parse(message), origin));
365
+ };
366
+ (0, import_react.useEffect)(
367
+ () => {
368
+ post();
369
+ const onReady = (event) => {
370
+ var _a, _b;
371
+ if (event.source === ((_a = frame.current) == null ? void 0 : _a.contentWindow) && ((_b = event.data) == null ? void 0 : _b.ready)) post();
372
+ };
373
+ window.addEventListener("message", onReady);
374
+ return () => window.removeEventListener("message", onReady);
375
+ },
376
+ // eslint-disable-next-line react-hooks/exhaustive-deps
377
+ [message, origin]
378
+ );
379
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
380
+ PreviewFrame,
381
+ {
382
+ ...{
383
+ states
384
+ },
385
+ children: [
386
+ loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
387
+ import_loader.default,
388
+ {
389
+ ...{
390
+ className: "bg-purple-light"
391
+ }
392
+ }
393
+ ),
394
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
395
+ "iframe",
396
+ {
397
+ ...{
398
+ className: "absolute inset-0 w-full h-full border-0",
399
+ onLoad: () => {
400
+ setLoading(false);
401
+ post();
402
+ },
403
+ ref: frame,
404
+ src: url,
405
+ title: "Page preview"
406
+ }
407
+ }
408
+ )
409
+ ]
410
+ }
411
+ );
412
+ };
413
+ var preview_default = Preview;
414
+ // Annotate the CommonJS export names for ESM import in node:
415
+ 0 && (module.exports = {
416
+ PreviewPage,
417
+ clamp,
418
+ fitScale
419
+ });