@pollinations/ui 0.1.0-alpha.1 → 0.1.0-alpha.4

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