@pollinations/ui 0.1.0-alpha.0 → 0.1.0-alpha.3

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 (112) hide show
  1. package/README.md +151 -87
  2. package/dist/Button-CO3Dpbkj.d.cts +29 -0
  3. package/dist/Button-CO3Dpbkj.d.ts +29 -0
  4. package/dist/Chip-v-ADv6cz.d.cts +18 -0
  5. package/dist/Chip-v-ADv6cz.d.ts +18 -0
  6. package/dist/Dialog-yXzIFrDg.d.cts +63 -0
  7. package/dist/Dialog-yXzIFrDg.d.ts +63 -0
  8. package/dist/app-user-menu/sdk.cjs +893 -0
  9. package/dist/app-user-menu/sdk.cjs.map +1 -0
  10. package/dist/{compositions/app-user.d.cts → app-user-menu/sdk.d.cts} +6 -7
  11. package/dist/{compositions/app-user.d.ts → app-user-menu/sdk.d.ts} +6 -7
  12. package/dist/app-user-menu/sdk.js +872 -0
  13. package/dist/app-user-menu/sdk.js.map +1 -0
  14. package/dist/app.css +7 -32
  15. package/dist/auth/index.cjs +1346 -76
  16. package/dist/auth/index.cjs.map +1 -1
  17. package/dist/auth/index.d.cts +88 -6
  18. package/dist/auth/index.d.ts +88 -6
  19. package/dist/auth/index.js +1343 -75
  20. package/dist/auth/index.js.map +1 -1
  21. package/dist/auth/sdk.cjs +78 -60
  22. package/dist/auth/sdk.cjs.map +1 -1
  23. package/dist/auth/sdk.d.cts +2 -15
  24. package/dist/auth/sdk.d.ts +2 -15
  25. package/dist/auth/sdk.js +77 -57
  26. package/dist/auth/sdk.js.map +1 -1
  27. package/dist/brand/lockup-horizontal-black.png +0 -0
  28. package/dist/brand/lockup-horizontal-black.svg +4 -0
  29. package/dist/brand/lockup-horizontal-white.png +0 -0
  30. package/dist/brand/lockup-horizontal-white.svg +4 -0
  31. package/dist/brand/lockup-horizontal.svg +1 -0
  32. package/dist/brand/lockup-stacked-black.png +0 -0
  33. package/dist/brand/lockup-stacked-black.svg +4 -0
  34. package/dist/brand/lockup-stacked-white.png +0 -0
  35. package/dist/brand/lockup-stacked-white.svg +4 -0
  36. package/dist/brand/lockup-stacked.svg +4 -0
  37. package/dist/brand/mark-black.png +0 -0
  38. package/dist/brand/mark-black.svg +3 -0
  39. package/dist/brand/mark-white.png +0 -0
  40. package/dist/brand/mark-white.svg +3 -0
  41. package/dist/brand/mark.svg +1 -0
  42. package/dist/brand/polli/polli-lockup-horizontal-black.png +0 -0
  43. package/dist/brand/polli/polli-lockup-horizontal-white.png +0 -0
  44. package/dist/brand/polli/polli-lockup-stacked-black.png +0 -0
  45. package/dist/brand/polli/polli-lockup-stacked-white.png +0 -0
  46. package/dist/brand/polli/polli.png +0 -0
  47. package/dist/brand/wordmark-black.png +0 -0
  48. package/dist/brand/wordmark-black.svg +1 -0
  49. package/dist/brand/wordmark-white.png +0 -0
  50. package/dist/brand/wordmark-white.svg +1 -0
  51. package/dist/brand/wordmark.svg +1 -0
  52. package/dist/fonts/geist-pixel-square.woff2 +0 -0
  53. package/dist/gen/index.cjs +658 -0
  54. package/dist/gen/index.cjs.map +1 -0
  55. package/dist/gen/index.d.cts +80 -0
  56. package/dist/gen/index.d.ts +80 -0
  57. package/dist/gen/index.js +630 -0
  58. package/dist/gen/index.js.map +1 -0
  59. package/dist/index.browser.min.js +2 -0
  60. package/dist/index.browser.min.js.map +1 -0
  61. package/dist/index.cjs +3847 -1490
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.cts +632 -218
  64. package/dist/index.d.ts +632 -218
  65. package/dist/index.js +3744 -1450
  66. package/dist/index.js.map +1 -1
  67. package/dist/licenses/Geist-OFL.txt +93 -0
  68. package/dist/markdown.cjs +821 -0
  69. package/dist/markdown.cjs.map +1 -0
  70. package/dist/markdown.d.cts +16 -0
  71. package/dist/markdown.d.ts +16 -0
  72. package/dist/markdown.js +792 -0
  73. package/dist/markdown.js.map +1 -0
  74. package/dist/styles.css +1 -1
  75. package/dist/theme.css +92 -0
  76. package/dist/wallet/index.cjs +258 -45
  77. package/dist/wallet/index.cjs.map +1 -1
  78. package/dist/wallet/index.d.cts +29 -7
  79. package/dist/wallet/index.d.ts +29 -7
  80. package/dist/wallet/index.js +257 -45
  81. package/dist/wallet/index.js.map +1 -1
  82. package/package.json +104 -102
  83. package/dist/Button-BvLF_Km2.d.cts +0 -26
  84. package/dist/Button-DQAZzvyQ.d.ts +0 -26
  85. package/dist/Chip-C5impfYd.d.ts +0 -20
  86. package/dist/Chip-SM52sUbZ.d.cts +0 -20
  87. package/dist/assets/logo-wordmark.svg +0 -1
  88. package/dist/assets/logo.svg +0 -4
  89. package/dist/compositions/app-user.cjs +0 -497
  90. package/dist/compositions/app-user.cjs.map +0 -1
  91. package/dist/compositions/app-user.js +0 -469
  92. package/dist/compositions/app-user.js.map +0 -1
  93. package/dist/modality/index.cjs +0 -86
  94. package/dist/modality/index.cjs.map +0 -1
  95. package/dist/modality/index.d.cts +0 -26
  96. package/dist/modality/index.d.ts +0 -26
  97. package/dist/modality/index.js +0 -59
  98. package/dist/modality/index.js.map +0 -1
  99. package/dist/models/index.cjs +0 -508
  100. package/dist/models/index.cjs.map +0 -1
  101. package/dist/models/index.d.cts +0 -22
  102. package/dist/models/index.d.ts +0 -22
  103. package/dist/models/index.js +0 -486
  104. package/dist/models/index.js.map +0 -1
  105. package/dist/theme-VMRlhqST.d.cts +0 -9
  106. package/dist/theme-VMRlhqST.d.ts +0 -9
  107. package/dist/wallet/sdk.cjs +0 -206
  108. package/dist/wallet/sdk.cjs.map +0 -1
  109. package/dist/wallet/sdk.d.cts +0 -33
  110. package/dist/wallet/sdk.d.ts +0 -33
  111. package/dist/wallet/sdk.js +0 -175
  112. package/dist/wallet/sdk.js.map +0 -1
@@ -0,0 +1,821 @@
1
+ "use strict";
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
+
30
+ // src/markdown.ts
31
+ var markdown_exports = {};
32
+ __export(markdown_exports, {
33
+ Markdown: () => Markdown,
34
+ Prose: () => Prose
35
+ });
36
+ module.exports = __toCommonJS(markdown_exports);
37
+
38
+ // src/compositions/Markdown.tsx
39
+ var import_react3 = require("react");
40
+ var import_react_markdown = __toESM(require("react-markdown"), 1);
41
+ var import_remark_gfm = __toESM(require("remark-gfm"), 1);
42
+
43
+ // src/lib/cn.ts
44
+ var import_clsx = require("clsx");
45
+ var import_tailwind_merge = require("tailwind-merge");
46
+ var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({ prefix: "polli" });
47
+ function cn(...inputs) {
48
+ return twMerge((0, import_clsx.clsx)(...inputs));
49
+ }
50
+
51
+ // src/lib/link.ts
52
+ function isExternalHref(href, origin = globalThis.location?.origin) {
53
+ if (typeof href !== "string" || !/^(https?:)?\/\//i.test(href))
54
+ return false;
55
+ if (!origin) return true;
56
+ try {
57
+ return new URL(href, origin).origin !== origin;
58
+ } catch {
59
+ return false;
60
+ }
61
+ }
62
+
63
+ // src/primitives/icons/index.tsx
64
+ var import_jsx_runtime = require("react/jsx-runtime");
65
+ var strokeProps = {
66
+ fill: "none",
67
+ stroke: "currentColor",
68
+ strokeWidth: 2,
69
+ strokeLinecap: "round",
70
+ strokeLinejoin: "round"
71
+ };
72
+ function CheckIcon(props) {
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
+ "svg",
75
+ {
76
+ "aria-hidden": "true",
77
+ viewBox: "0 0 24 24",
78
+ ...strokeProps,
79
+ strokeWidth: 2.5,
80
+ ...props,
81
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "20 6 9 17 4 12" })
82
+ }
83
+ );
84
+ }
85
+ function ClipboardIcon(props) {
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", ...strokeProps, ...props, children: [
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
88
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
89
+ ] });
90
+ }
91
+ function ExternalLinkIcon(props) {
92
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", ...strokeProps, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M7 17 17 7M9 7h8v8" }) });
93
+ }
94
+
95
+ // src/primitives/InlineLink.tsx
96
+ var import_jsx_runtime2 = require("react/jsx-runtime");
97
+ function InlineLink({
98
+ as,
99
+ external,
100
+ showIcon = true,
101
+ size = "inherit",
102
+ tone = "accent",
103
+ className,
104
+ children,
105
+ ...linkProps
106
+ }) {
107
+ const Component = as || "a";
108
+ const isExternal = external ?? isExternalHref(linkProps.href);
109
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
110
+ Component,
111
+ {
112
+ target: isExternal && as !== "button" ? "_blank" : void 0,
113
+ rel: isExternal && as !== "button" ? "noopener noreferrer" : void 0,
114
+ className: ["polli-link", className].filter(Boolean).join(" "),
115
+ "data-size": size,
116
+ "data-tone": tone,
117
+ ...linkProps,
118
+ children: [
119
+ children,
120
+ showIcon && isExternal && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
121
+ ExternalLinkIcon,
122
+ {
123
+ "aria-hidden": "true",
124
+ className: "polli-link-external-icon"
125
+ }
126
+ )
127
+ ]
128
+ }
129
+ );
130
+ }
131
+
132
+ // src/compositions/CopyButton.tsx
133
+ var import_react2 = require("react");
134
+
135
+ // src/primitives/Button.tsx
136
+ var import_jsx_runtime3 = require("react/jsx-runtime");
137
+ var pillSizes = {
138
+ icon: "polli:h-12 polli:w-12 polli:p-0",
139
+ xs: "polli:h-5 polli:px-1.5 polli:py-0 polli:text-[11px] polli:leading-none",
140
+ sm: "polli:min-h-7 polli:px-2 polli:pt-0.5 polli:pb-1",
141
+ md: "polli:min-h-9 polli:px-4 polli:pt-1.5 polli:pb-2",
142
+ lg: "polli:min-h-12 polli:px-6 polli:py-3"
143
+ };
144
+ var raisedSizes = {
145
+ icon: "polli:h-12 polli:w-12 polli:p-0",
146
+ xs: "polli:px-2 polli:py-1 polli:text-xs",
147
+ sm: "polli:px-4 polli:py-2 polli:text-sm",
148
+ md: "polli:px-7 polli:py-3.5 polli:text-base",
149
+ lg: "polli:px-8 polli:py-4 polli:text-lg"
150
+ };
151
+ var appearanceClasses = {
152
+ pill: "polli:rounded-full",
153
+ raised: "polli:rounded-xl polli:border-r-[3px] polli:border-b-[3px] polli:border-solid polli:border-theme-text-strong/20 polli:hover:border-theme-text-strong/45"
154
+ };
155
+ var themeClasses = "polli:bg-theme-bg-active polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover polli:transition-colors";
156
+ var outlined = "polli:border polli:border-theme-text-soft polli:bg-surface-white polli:text-theme-text-strong polli:transition-colors polli:[.dark_&]:bg-transparent";
157
+ var intentClasses = {
158
+ brand: `${outlined} polli:hover:bg-theme-text-soft/10`,
159
+ commit: `${outlined} polli:hover:border-theme-bg-active polli:hover:bg-theme-bg-active polli:focus-visible:border-theme-bg-active polli:focus-visible:bg-theme-bg-active polli:[.dark_&]:hover:bg-theme-bg-active polli:[.dark_&]:focus-visible:bg-theme-bg-active`,
160
+ danger: "polli:border polli:border-intent-danger-text polli:bg-transparent polli:text-intent-danger-text polli:hover:bg-intent-danger-bg-hover polli:focus-visible:bg-intent-danger-bg-hover polli:transition-colors",
161
+ info: "polli:bg-intent-info-bg-light polli:text-intent-info-text polli:hover:bg-intent-info-bg-hover polli:transition-colors",
162
+ // Secondary actions never take the accent: one step stronger grey on hover.
163
+ neutral: "polli:bg-theme-bg-subtle polli:text-theme-text-base polli:hover:bg-theme-text-muted/25 polli:hover:text-theme-text-strong polli:transition-colors"
164
+ };
165
+ var buttonClasses = ({
166
+ intent,
167
+ appearance = "pill",
168
+ size,
169
+ className,
170
+ disabled
171
+ }) => {
172
+ const colorClasses = intent ? intentClasses[intent] : themeClasses;
173
+ const sizeClasses = appearance === "raised" ? raisedSizes : pillSizes;
174
+ return cn(
175
+ "polli-control polli:inline-flex polli:items-center polli:justify-center polli:self-center polli:font-body polli:text-sm polli:font-medium polli:leading-normal polli:box-border polli:border polli:border-transparent",
176
+ disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
177
+ colorClasses,
178
+ appearanceClasses[appearance],
179
+ sizeClasses[size || "md"],
180
+ className
181
+ );
182
+ };
183
+ function Button({
184
+ as,
185
+ children,
186
+ icon,
187
+ intent,
188
+ appearance,
189
+ size,
190
+ className,
191
+ disabled,
192
+ ...buttonProps
193
+ }) {
194
+ const Component = as || "button";
195
+ const isButton = Component === "button";
196
+ const isAnchor = Component === "a";
197
+ const buttonType = buttonProps.type;
198
+ const onClick = buttonProps.onClick;
199
+ const handleClick = disabled ? (event) => {
200
+ event.preventDefault();
201
+ event.stopPropagation();
202
+ } : onClick;
203
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
204
+ Component,
205
+ {
206
+ ...buttonProps,
207
+ "data-intent": intent,
208
+ ...isButton ? { type: buttonType ?? "button", disabled } : {},
209
+ ...!isButton && disabled ? { "aria-disabled": true, tabIndex: -1 } : {},
210
+ ...isAnchor && disabled ? { href: void 0 } : {},
211
+ onClick: handleClick,
212
+ className: buttonClasses({
213
+ intent,
214
+ appearance,
215
+ size,
216
+ className,
217
+ disabled
218
+ }),
219
+ children: [
220
+ icon && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
221
+ "span",
222
+ {
223
+ "aria-hidden": "true",
224
+ className: "polli:mr-2 polli:flex polli:size-4 polli:shrink-0 polli:[&>svg]:size-full",
225
+ children: icon
226
+ }
227
+ ),
228
+ children
229
+ ]
230
+ }
231
+ );
232
+ }
233
+
234
+ // src/primitives/Tooltip.tsx
235
+ var import_react = require("react");
236
+ var import_react_dom = require("react-dom");
237
+ var import_jsx_runtime4 = require("react/jsx-runtime");
238
+ var TOOLTIP_MAX_WIDTH = 288;
239
+ var TOOLTIP_VIEWPORT_MARGIN = 12;
240
+ var Tooltip = ({
241
+ children,
242
+ content,
243
+ align = "start",
244
+ ariaLabel,
245
+ clampToViewport = true,
246
+ className,
247
+ maxWidth = TOOLTIP_MAX_WIDTH,
248
+ onClick,
249
+ stopClickPropagation = true,
250
+ style,
251
+ tapEnabled = false,
252
+ triggerAs = "button",
253
+ displayContents = false
254
+ }) => {
255
+ const [showTooltip, setShowTooltip] = (0, import_react.useState)(false);
256
+ const [tooltipPosition, setTooltipPosition] = (0, import_react.useState)({
257
+ top: 0,
258
+ left: 0,
259
+ maxWidth
260
+ });
261
+ const triggerRef = (0, import_react.useRef)(null);
262
+ const tapPinnedRef = (0, import_react.useRef)(false);
263
+ const tooltipId = (0, import_react.useId)();
264
+ const closeTooltip = () => {
265
+ tapPinnedRef.current = false;
266
+ setShowTooltip(false);
267
+ };
268
+ (0, import_react.useEffect)(() => {
269
+ if (!showTooltip) return;
270
+ const dismissOnOutsideTap = (event) => {
271
+ if (triggerRef.current?.contains(event.target)) return;
272
+ tapPinnedRef.current = false;
273
+ setShowTooltip(false);
274
+ };
275
+ const dismissOnEscape = (event) => {
276
+ if (event.key !== "Escape") return;
277
+ tapPinnedRef.current = false;
278
+ setShowTooltip(false);
279
+ };
280
+ const dismissOnViewportChange = () => {
281
+ tapPinnedRef.current = false;
282
+ setShowTooltip(false);
283
+ };
284
+ document.addEventListener("pointerdown", dismissOnOutsideTap);
285
+ document.addEventListener("keydown", dismissOnEscape);
286
+ window.addEventListener("scroll", dismissOnViewportChange, {
287
+ capture: true,
288
+ passive: true
289
+ });
290
+ window.addEventListener("resize", dismissOnViewportChange);
291
+ return () => {
292
+ document.removeEventListener("pointerdown", dismissOnOutsideTap);
293
+ document.removeEventListener("keydown", dismissOnEscape);
294
+ window.removeEventListener("scroll", dismissOnViewportChange, true);
295
+ window.removeEventListener("resize", dismissOnViewportChange);
296
+ };
297
+ }, [showTooltip]);
298
+ const updateTooltipPosition = () => {
299
+ if (triggerRef.current) {
300
+ const rect = triggerRef.current.getBoundingClientRect();
301
+ const availableMaxWidth = Math.min(
302
+ maxWidth,
303
+ window.innerWidth - TOOLTIP_VIEWPORT_MARGIN * 2
304
+ );
305
+ let left = align === "center" ? rect.left + rect.width / 2 : rect.left;
306
+ let transform = align === "center" ? "translateX(-50%)" : void 0;
307
+ if (clampToViewport) {
308
+ left = Math.min(
309
+ Math.max(rect.left, TOOLTIP_VIEWPORT_MARGIN),
310
+ Math.max(
311
+ TOOLTIP_VIEWPORT_MARGIN,
312
+ window.innerWidth - availableMaxWidth - TOOLTIP_VIEWPORT_MARGIN
313
+ )
314
+ );
315
+ transform = void 0;
316
+ }
317
+ setTooltipPosition({
318
+ top: rect.bottom + 4,
319
+ left,
320
+ maxWidth: availableMaxWidth,
321
+ transform
322
+ });
323
+ }
324
+ };
325
+ const triggerClassName = cn(
326
+ "polli-control polli:relative polli:cursor-help polli:text-left polli:inline-flex polli:items-center",
327
+ className
328
+ );
329
+ const cursorClass = displayContents ? "polli:contents" : "polli:cursor-inherit";
330
+ const popupClasses = "polli:fixed polli:w-max polli:px-2 polli:py-1 polli:bg-surface-menu polli:text-theme-text-base polli:font-normal polli:leading-snug polli:tracking-normal polli:normal-case polli:not-italic polli:text-xs polli:rounded-md polli:shadow-md polli:z-[130] polli:pointer-events-none polli:transition-opacity polli:whitespace-pre-line polli:break-words";
331
+ const popupNode = content ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
332
+ "span",
333
+ {
334
+ id: tooltipId,
335
+ role: "tooltip",
336
+ "aria-hidden": !showTooltip,
337
+ style: {
338
+ top: tooltipPosition.top,
339
+ left: tooltipPosition.left,
340
+ maxWidth: tooltipPosition.maxWidth,
341
+ transform: tooltipPosition.transform
342
+ },
343
+ className: `${showTooltip ? "polli:visible polli:opacity-100" : "polli:invisible polli:opacity-0"} ${popupClasses}`,
344
+ children: content
345
+ }
346
+ ) : null;
347
+ const tooltipPopup = popupNode && typeof document !== "undefined" ? (0, import_react_dom.createPortal)(
348
+ popupNode,
349
+ triggerRef.current?.closest('[role="dialog"]') ?? document.body
350
+ ) : popupNode;
351
+ const contentNode = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
352
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: cursorClass, children }),
353
+ tooltipPopup
354
+ ] });
355
+ const sharedProps = {
356
+ "aria-label": ariaLabel,
357
+ "aria-describedby": content && showTooltip ? tooltipId : void 0,
358
+ className: triggerClassName,
359
+ onMouseEnter: () => {
360
+ updateTooltipPosition();
361
+ setShowTooltip(true);
362
+ },
363
+ onMouseLeave: () => {
364
+ if (!tapPinnedRef.current) setShowTooltip(false);
365
+ },
366
+ onClick: (e) => {
367
+ if (stopClickPropagation) e.stopPropagation();
368
+ if (onClick) {
369
+ onClick();
370
+ }
371
+ if (!tapEnabled || !content) return;
372
+ updateTooltipPosition();
373
+ if (tapPinnedRef.current) {
374
+ closeTooltip();
375
+ return;
376
+ }
377
+ tapPinnedRef.current = true;
378
+ setShowTooltip(true);
379
+ },
380
+ onFocus: () => {
381
+ updateTooltipPosition();
382
+ setShowTooltip(true);
383
+ },
384
+ onBlur: closeTooltip,
385
+ style
386
+ };
387
+ if (triggerAs === "span") {
388
+ const handleKeyDown = (event) => {
389
+ if (!tapEnabled || !content) return;
390
+ if (event.key !== "Enter" && event.key !== " ") return;
391
+ event.preventDefault();
392
+ updateTooltipPosition();
393
+ if (tapPinnedRef.current) {
394
+ closeTooltip();
395
+ return;
396
+ }
397
+ tapPinnedRef.current = true;
398
+ setShowTooltip(true);
399
+ };
400
+ const spanInteractionProps = {
401
+ ...sharedProps,
402
+ role: tapEnabled && content ? "button" : void 0,
403
+ tabIndex: tapEnabled && content ? 0 : void 0,
404
+ onKeyDown: tapEnabled && content ? handleKeyDown : void 0
405
+ };
406
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
407
+ "span",
408
+ {
409
+ ref: (node) => {
410
+ triggerRef.current = node;
411
+ },
412
+ ...spanInteractionProps,
413
+ children: contentNode
414
+ }
415
+ );
416
+ }
417
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
418
+ "button",
419
+ {
420
+ ref: (node) => {
421
+ triggerRef.current = node;
422
+ },
423
+ type: "button",
424
+ "aria-label": ariaLabel,
425
+ "aria-describedby": content && showTooltip ? tooltipId : void 0,
426
+ className: triggerClassName,
427
+ onMouseEnter: sharedProps.onMouseEnter,
428
+ onMouseLeave: sharedProps.onMouseLeave,
429
+ onClick: sharedProps.onClick,
430
+ onFocus: sharedProps.onFocus,
431
+ onBlur: sharedProps.onBlur,
432
+ style,
433
+ children: contentNode
434
+ }
435
+ );
436
+ };
437
+
438
+ // src/compositions/CopyButton.tsx
439
+ var import_jsx_runtime5 = require("react/jsx-runtime");
440
+ function CopyButton({
441
+ value,
442
+ children,
443
+ copiedTimeoutMs = 2e3,
444
+ tooltip = "\u{1F4CB} Click to copy",
445
+ tooltipAlign,
446
+ tooltipClampToViewport,
447
+ tooltipMaxWidth,
448
+ copiedTooltip = "\u2705 Copied!",
449
+ tooltipClassName,
450
+ className,
451
+ variant = "plain",
452
+ intent,
453
+ onCopied,
454
+ onCopyError,
455
+ ...buttonProps
456
+ }) {
457
+ const [copied, setCopied] = (0, import_react2.useState)(false);
458
+ const timeoutRef = (0, import_react2.useRef)(null);
459
+ (0, import_react2.useEffect)(
460
+ () => () => {
461
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
462
+ },
463
+ []
464
+ );
465
+ async function handleCopy(event) {
466
+ event.stopPropagation();
467
+ try {
468
+ const text = typeof value === "function" ? await value() : value;
469
+ await navigator.clipboard.writeText(text);
470
+ setCopied(true);
471
+ onCopied?.();
472
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
473
+ timeoutRef.current = setTimeout(
474
+ () => setCopied(false),
475
+ copiedTimeoutMs
476
+ );
477
+ } catch (error) {
478
+ onCopyError?.(error);
479
+ }
480
+ }
481
+ const Control = variant === "button" ? Button : "button";
482
+ const button = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
483
+ Control,
484
+ {
485
+ ...buttonProps,
486
+ ...variant === "button" && intent ? { intent } : {},
487
+ type: "button",
488
+ onClick: handleCopy,
489
+ className: cn(
490
+ "polli-control",
491
+ buttonProps.disabled ? "polli:cursor-not-allowed" : "polli:cursor-pointer",
492
+ typeof className === "function" ? className(copied) : className
493
+ ),
494
+ children: typeof children === "function" ? children(copied) : children
495
+ }
496
+ );
497
+ if (tooltip === null) {
498
+ return button;
499
+ }
500
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
501
+ Tooltip,
502
+ {
503
+ triggerAs: "span",
504
+ content: copied ? copiedTooltip : tooltip,
505
+ align: tooltipAlign,
506
+ clampToViewport: tooltipClampToViewport,
507
+ maxWidth: tooltipMaxWidth,
508
+ displayContents: true,
509
+ tapEnabled: false,
510
+ className: cn(
511
+ buttonProps.disabled ? "polli:cursor-not-allowed" : "polli:cursor-pointer",
512
+ tooltipClassName
513
+ ),
514
+ children: button
515
+ }
516
+ );
517
+ }
518
+
519
+ // src/compositions/CodeBlock.tsx
520
+ var import_jsx_runtime6 = require("react/jsx-runtime");
521
+ var CodeBlock = ({
522
+ code,
523
+ codeClassName,
524
+ language,
525
+ className,
526
+ ...rest
527
+ }) => {
528
+ const label = language || "Code";
529
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
530
+ "div",
531
+ {
532
+ ...rest,
533
+ className: cn(
534
+ "polli:min-w-0 polli:max-w-full polli:overflow-hidden polli:rounded-lg polli:border polli:border-theme-border polli:bg-theme-bg-pale",
535
+ className
536
+ ),
537
+ children: [
538
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "polli:flex polli:min-h-9 polli:items-center polli:justify-between polli:gap-3 polli:bg-theme-bg-subtle polli:px-3 polli:py-1.5", children: [
539
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "polli:truncate polli:font-mono polli:text-[11px] polli:font-medium polli:uppercase polli:tracking-wide polli:text-theme-text-muted", children: label }),
540
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
541
+ CopyButton,
542
+ {
543
+ value: code,
544
+ tooltip: null,
545
+ "aria-label": "Copy code",
546
+ className: "polli:flex polli:items-center polli:gap-1.5 polli:rounded-md polli:px-2 polli:py-1 polli:text-xs polli:font-medium polli:text-theme-text-base polli:transition-colors polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover",
547
+ children: (copied) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
548
+ copied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, { className: "polli:size-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClipboardIcon, { className: "polli:size-3.5" }),
549
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: copied ? "Copied" : "Copy" })
550
+ ] })
551
+ }
552
+ )
553
+ ] }),
554
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
555
+ "pre",
556
+ {
557
+ className: cn(
558
+ "polli:m-0 polli:min-w-0 polli:whitespace-pre-wrap polli:break-words polli:[overflow-wrap:anywhere] polli:[tab-size:4] polli:p-3 polli:font-mono polli:text-xs polli:leading-6 polli:text-theme-text-strong",
559
+ codeClassName
560
+ ),
561
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("code", { children: code })
562
+ }
563
+ )
564
+ ]
565
+ }
566
+ );
567
+ };
568
+
569
+ // src/compositions/Markdown.tsx
570
+ var import_jsx_runtime7 = require("react/jsx-runtime");
571
+ function textContent(value) {
572
+ if (typeof value === "string" || typeof value === "number") {
573
+ return String(value);
574
+ }
575
+ if (Array.isArray(value)) return value.map(textContent).join("");
576
+ if ((0, import_react3.isValidElement)(value)) {
577
+ return textContent(value.props.children);
578
+ }
579
+ return "";
580
+ }
581
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["m4v", "mov", "mp4", "webm"]);
582
+ var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set([
583
+ "aac",
584
+ "flac",
585
+ "m4a",
586
+ "mp3",
587
+ "ogg",
588
+ "opus",
589
+ "wav"
590
+ ]);
591
+ function urlExtension(src) {
592
+ const path = src.split(/[?#]/, 1)[0];
593
+ return path.split(".").pop()?.toLowerCase() ?? "";
594
+ }
595
+ function inlineMedia(src, label) {
596
+ if (!src) return null;
597
+ const extension = urlExtension(src);
598
+ const video = VIDEO_EXTENSIONS.has(extension) || label === "Generated video";
599
+ const audio = AUDIO_EXTENSIONS.has(extension) || label === "Generated audio";
600
+ if (!video && !audio) return null;
601
+ const Element = video ? "video" : "audio";
602
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
603
+ Element,
604
+ {
605
+ src,
606
+ "aria-label": label,
607
+ controls: true,
608
+ playsInline: video || void 0,
609
+ preload: "metadata",
610
+ className: "polli:max-w-full polli:rounded-lg"
611
+ }
612
+ );
613
+ }
614
+ function MarkdownCodeBlock({ children }) {
615
+ const child = (0, import_react3.isValidElement)(children) ? children : null;
616
+ const language = child?.props.className?.match(/language-([^\s]+)/)?.[1];
617
+ const code = textContent(child?.props.children ?? children).replace(
618
+ /\n$/,
619
+ ""
620
+ );
621
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CodeBlock, { code, language, className: "polli:my-3" });
622
+ }
623
+ var components = {
624
+ ul: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
625
+ "ul",
626
+ {
627
+ className: "polli:flex polli:min-w-0 polli:list-disc polli:flex-col polli:gap-1 polli:pl-5 polli:marker:text-theme-text-muted",
628
+ ...props
629
+ }
630
+ ),
631
+ ol: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
632
+ "ol",
633
+ {
634
+ className: "polli:flex polli:min-w-0 polli:list-decimal polli:flex-col polli:gap-1 polli:pl-5 polli:marker:text-theme-text-muted",
635
+ ...props
636
+ }
637
+ ),
638
+ p: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "polli:mb-2 polli:last:mb-0", ...props }),
639
+ strong: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
640
+ "strong",
641
+ {
642
+ className: "polli:font-semibold polli:text-theme-text-strong",
643
+ ...props
644
+ }
645
+ ),
646
+ code: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
647
+ "code",
648
+ {
649
+ className: "polli:break-words polli:rounded polli:bg-theme-bg-subtle polli:px-1 polli:py-0.5 polli:font-mono polli:text-xs",
650
+ ...props
651
+ }
652
+ ),
653
+ pre: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MarkdownCodeBlock, { children }),
654
+ img: ({ node, src, alt, ...props }) => {
655
+ const media = inlineMedia(
656
+ typeof src === "string" ? src : void 0,
657
+ alt
658
+ );
659
+ if (media) return media;
660
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
661
+ "img",
662
+ {
663
+ src,
664
+ alt,
665
+ loading: "lazy",
666
+ className: "polli:max-w-full polli:rounded-lg",
667
+ ...props
668
+ }
669
+ );
670
+ },
671
+ a: ({ node, href, ...props }) => {
672
+ const media = inlineMedia(href, textContent(props.children));
673
+ if (media) return media;
674
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InlineLink, { href, ...props });
675
+ }
676
+ };
677
+ function Markdown({ children, className }) {
678
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
679
+ "div",
680
+ {
681
+ className: cn(
682
+ "polli:min-w-0 polli:font-body polli:leading-relaxed",
683
+ className
684
+ ),
685
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], components, children })
686
+ }
687
+ );
688
+ }
689
+
690
+ // src/compositions/Prose.tsx
691
+ var import_react_markdown2 = __toESM(require("react-markdown"), 1);
692
+ var import_rehype_slug = __toESM(require("rehype-slug"), 1);
693
+ var import_remark_gfm2 = __toESM(require("remark-gfm"), 1);
694
+
695
+ // src/primitives/Typography.tsx
696
+ var import_jsx_runtime8 = require("react/jsx-runtime");
697
+ var headingSizeClasses = {
698
+ display: "polli:font-heading polli:text-5xl polli:leading-none",
699
+ title: "polli:font-heading polli:text-4xl polli:leading-none",
700
+ section: "polli:font-subheading polli:text-2xl polli:leading-tight",
701
+ subsection: "polli:font-subheading polli:text-xl polli:leading-tight",
702
+ card: "polli:font-subheading polli:text-lg polli:leading-tight"
703
+ };
704
+ function headingClassName(size, className) {
705
+ return cn(
706
+ "polli:break-words polli:text-theme-text-strong",
707
+ headingSizeClasses[size],
708
+ className
709
+ );
710
+ }
711
+
712
+ // src/compositions/Prose.tsx
713
+ var import_jsx_runtime9 = require("react/jsx-runtime");
714
+ var components2 = {
715
+ h1: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
716
+ "h1",
717
+ {
718
+ className: headingClassName("title", "polli:mt-0 polli:mb-5"),
719
+ ...props
720
+ }
721
+ ),
722
+ h2: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
723
+ "h2",
724
+ {
725
+ className: headingClassName("section", "polli:mt-8 polli:mb-3"),
726
+ ...props
727
+ }
728
+ ),
729
+ h3: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
730
+ "h3",
731
+ {
732
+ className: headingClassName("subsection", "polli:mt-6 polli:mb-2"),
733
+ ...props
734
+ }
735
+ ),
736
+ p: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "polli:my-4 polli:leading-relaxed", ...props }),
737
+ a: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InlineLink, { ...props }),
738
+ ul: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
739
+ "ul",
740
+ {
741
+ className: "polli:my-4 polli:list-disc polli:pl-6 polli:leading-relaxed",
742
+ ...props
743
+ }
744
+ ),
745
+ ol: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
746
+ "ol",
747
+ {
748
+ className: "polli:my-4 polli:list-decimal polli:pl-6 polli:leading-relaxed",
749
+ ...props
750
+ }
751
+ ),
752
+ blockquote: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
753
+ "blockquote",
754
+ {
755
+ className: "polli:my-4 polli:border-l-4 polli:border-theme-border polli:pl-4 polli:text-theme-text-soft",
756
+ ...props
757
+ }
758
+ ),
759
+ code: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
760
+ "code",
761
+ {
762
+ className: "polli:rounded polli:bg-theme-bg-active polli:px-1 polli:py-0.5 polli:font-pixel polli:text-sm",
763
+ ...props
764
+ }
765
+ ),
766
+ pre: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
767
+ "pre",
768
+ {
769
+ className: "polli:my-4 polli:overflow-x-auto polli:rounded-lg polli:bg-theme-bg-active polli:p-4",
770
+ ...props
771
+ }
772
+ ),
773
+ table: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
774
+ "table",
775
+ {
776
+ className: "polli:my-4 polli:w-full polli:border-collapse polli:text-sm",
777
+ ...props
778
+ }
779
+ ),
780
+ th: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
781
+ "th",
782
+ {
783
+ className: "polli:border polli:border-theme-border polli:px-3 polli:py-2 polli:text-left polli:font-semibold",
784
+ ...props
785
+ }
786
+ ),
787
+ td: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
788
+ "td",
789
+ {
790
+ className: "polli:border polli:border-theme-border polli:px-3 polli:py-2",
791
+ ...props
792
+ }
793
+ ),
794
+ hr: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { className: "polli:my-6 polli:border-theme-border", ...props })
795
+ };
796
+ function Prose({ children, className }) {
797
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
798
+ "div",
799
+ {
800
+ className: cn(
801
+ "polli:font-body polli:text-theme-text-base polli:leading-relaxed",
802
+ className
803
+ ),
804
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
805
+ import_react_markdown2.default,
806
+ {
807
+ remarkPlugins: [import_remark_gfm2.default],
808
+ rehypePlugins: [import_rehype_slug.default],
809
+ components: components2,
810
+ children
811
+ }
812
+ )
813
+ }
814
+ );
815
+ }
816
+ // Annotate the CommonJS export names for ESM import in node:
817
+ 0 && (module.exports = {
818
+ Markdown,
819
+ Prose
820
+ });
821
+ //# sourceMappingURL=markdown.cjs.map