@simple-builder/react 1.2.7 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/build-container-client-56IGH4EB.mjs +6 -0
  2. package/dist/build-container-client-6D4M5MV6.mjs +6 -0
  3. package/dist/build-container-client-7UASGAWO.mjs +2264 -0
  4. package/dist/build-container-client-FP6NTFZ7.js +2298 -0
  5. package/dist/build-container-client-IC4ZMQPB.js +2300 -0
  6. package/dist/build-container-client-JR4HENF4.mjs +6 -0
  7. package/dist/build-container-client-JS3CR4W3.js +6 -0
  8. package/dist/build-container-client-JXYQOZHZ.js +6 -0
  9. package/dist/build-container-client-O3HCUDB7.js +2289 -0
  10. package/dist/build-container-client-OANZW6DH.mjs +6 -0
  11. package/dist/build-container-client-QBXLJYQD.js +6 -0
  12. package/dist/build-container-client-QOFTIHCU.js +6 -0
  13. package/dist/build-container-client-VF3DTHKE.mjs +2253 -0
  14. package/dist/build-container-client-XNI5DVSE.mjs +6 -0
  15. package/dist/build-container-client-YSPLIQZC.mjs +2262 -0
  16. package/dist/build-container-client-YTZ4C67E.mjs +6 -0
  17. package/dist/build-container-client-Z34EUPR3.js +6 -0
  18. package/dist/build-container-client-ZXB5JG67.js +6 -0
  19. package/dist/builder-content-325KIPAU.mjs +20 -0
  20. package/dist/builder-content-7CYIKIWQ.mjs +20 -0
  21. package/dist/builder-content-CUJJ3KBR.js +42 -0
  22. package/dist/builder-content-QFRPA4VE.js +42 -0
  23. package/dist/builder-content-WJFD3ACD.mjs +20 -0
  24. package/dist/builder-content-ZHXFSCT7.js +42 -0
  25. package/dist/chunk-2GRDEACJ.js +153 -0
  26. package/dist/chunk-2UYKRF3Y.js +263 -0
  27. package/dist/chunk-7DFHZYGR.js +263 -0
  28. package/dist/chunk-GVPZDUDM.js +42 -0
  29. package/dist/chunk-KC4V2ZJN.mjs +123 -0
  30. package/dist/chunk-KS4VUS45.mjs +238 -0
  31. package/dist/chunk-LNSOKXFY.mjs +20 -0
  32. package/dist/chunk-LPZDTDBB.js +153 -0
  33. package/dist/chunk-PFSFBCPI.mjs +123 -0
  34. package/dist/chunk-QEQT2EER.mjs +238 -0
  35. package/dist/chunk-RFPQNWBX.mjs +123 -0
  36. package/dist/chunk-S4IIRN4J.mjs +20 -0
  37. package/dist/chunk-TPRY6DEO.js +153 -0
  38. package/dist/chunk-TSIU64AJ.mjs +238 -0
  39. package/dist/chunk-UYVCZD2U.mjs +20 -0
  40. package/dist/chunk-WQ376VV2.js +263 -0
  41. package/dist/chunk-WUYG7TZ5.js +42 -0
  42. package/dist/chunk-YMC3DDLP.js +42 -0
  43. package/dist/index.js +6 -6
  44. package/dist/index.mjs +2 -2
  45. package/package.json +2 -2
@@ -0,0 +1,2253 @@
1
+ 'use client';
2
+ import './chunk-UYVCZD2U.mjs';
3
+ import { buttonVariants, Button, useBuilder } from './chunk-TSIU64AJ.mjs';
4
+ import { cn, tv, DesignWrapper, builder, Image } from './chunk-KC4V2ZJN.mjs';
5
+ import * as React25 from 'react';
6
+ import { useCallback } from 'react';
7
+ import { ChevronRight, Check, Circle, X, ChevronDown, ChevronUp, PlusIcon, ArrowUp, ArrowDown, Edit2Icon, Trash2Icon, ImageIcon, XIcon, PlusCircleIcon, CalendarIcon, MonitorIcon, SmartphoneIcon, ChevronLeftIcon, ChevronRightIcon, PaintbrushIcon, Loader2Icon, AlignHorizontalSpaceAroundIcon, AlignHorizontalJustifyStartIcon, ScanIcon } from 'lucide-react';
8
+ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
9
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
10
+ import { mergeAttributes, getMarkRange, EditorContent, useEditor } from '@tiptap/react';
11
+ import { Color } from '@tiptap/extension-color';
12
+ import { TextStyle } from '@tiptap/extension-text-style';
13
+ import { Underline } from '@tiptap/extension-underline';
14
+ import { StarterKit } from '@tiptap/starter-kit';
15
+ import TiptapLink from '@tiptap/extension-link';
16
+ import { Plugin, TextSelection } from '@tiptap/pm/state';
17
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
18
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
19
+ import * as TogglePrimitive from '@radix-ui/react-toggle';
20
+ import { cva } from 'class-variance-authority';
21
+ import { LuChevronDown, LuCheck, LuHeading, LuLink2, LuEllipsis, LuBold, LuItalic, LuUnderline, LuStrikethrough, LuCode, LuRemoveFormatting, LuQuote, LuMinus, LuListOrdered, LuList } from 'react-icons/lu';
22
+ import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
23
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
24
+ import { Slot } from '@radix-ui/react-slot';
25
+ import { useFormContext, useForm, useFieldArray, FormProvider, Controller } from 'react-hook-form';
26
+ import * as LabelPrimitive from '@radix-ui/react-label';
27
+ import * as SwitchPrimitives from '@radix-ui/react-switch';
28
+ import { zodResolver } from '@hookform/resolvers/zod';
29
+ import { z } from 'zod';
30
+ import { format } from 'date-fns';
31
+ import { DayPicker } from 'react-day-picker';
32
+ import * as SelectPrimitive from '@radix-ui/react-select';
33
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
34
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
35
+
36
+ var AlertDialog = AlertDialogPrimitive.Root;
37
+ var AlertDialogTrigger = AlertDialogPrimitive.Trigger;
38
+ var AlertDialogPortal = AlertDialogPrimitive.Portal;
39
+ var AlertDialogOverlay = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
40
+ AlertDialogPrimitive.Overlay,
41
+ {
42
+ className: cn(
43
+ "sb-fixed sb-inset-0 sb-z-50 sb-bg-background/80 sb-backdrop-blur-sm data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0",
44
+ className
45
+ ),
46
+ ...props,
47
+ ref
48
+ }
49
+ ));
50
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
51
+ var AlertDialogContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(AlertDialogPortal, null, /* @__PURE__ */ React25.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React25.createElement(
52
+ AlertDialogPrimitive.Content,
53
+ {
54
+ ref,
55
+ className: cn(
56
+ "sb-fixed sb-font-roboto sb-left-[50%] sb-top-[50%] sb-z-50 sb-grid sb-w-full sb-max-w-lg sb-translate-x-[-50%] sb-translate-y-[-50%] sb-gap-4 sb-border sb-bg-background sb-p-6 sb-shadow-lg sb-duration-200 data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[state=closed]:sb-slide-out-to-left-1/2 data-[state=closed]:sb-slide-out-to-top-[48%] data-[state=open]:sb-slide-in-from-left-1/2 data-[state=open]:sb-slide-in-from-top-[48%] sm:sb-rounded-lg",
57
+ className
58
+ ),
59
+ ...props
60
+ }
61
+ )));
62
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
63
+ var AlertDialogFooter = ({
64
+ className,
65
+ ...props
66
+ }) => /* @__PURE__ */ React25.createElement(
67
+ "div",
68
+ {
69
+ className: cn(
70
+ "sb-flex sb-flex-col-reverse sm:sb-flex-row sm:sb-justify-end sm:sb-space-x-2",
71
+ className
72
+ ),
73
+ ...props
74
+ }
75
+ );
76
+ AlertDialogFooter.displayName = "AlertDialogFooter";
77
+ var AlertDialogTitle = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
78
+ AlertDialogPrimitive.Title,
79
+ {
80
+ ref,
81
+ className: cn("sb-text-lg sb-font-semibold", className),
82
+ ...props
83
+ }
84
+ ));
85
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
86
+ var AlertDialogDescription = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
87
+ AlertDialogPrimitive.Description,
88
+ {
89
+ ref,
90
+ className: cn("sb-text-sm sb-text-muted-foreground", className),
91
+ ...props
92
+ }
93
+ ));
94
+ AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
95
+ var AlertDialogAction = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
96
+ AlertDialogPrimitive.Action,
97
+ {
98
+ ref,
99
+ className: cn(buttonVariants(), className),
100
+ ...props
101
+ }
102
+ ));
103
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
104
+ var AlertDialogCancel = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
105
+ AlertDialogPrimitive.Cancel,
106
+ {
107
+ ref,
108
+ className: cn(
109
+ buttonVariants({ variant: "outline" }),
110
+ "sb-mt-2 sm:sb-mt-0",
111
+ className
112
+ ),
113
+ ...props
114
+ }
115
+ ));
116
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
117
+ var Popover = PopoverPrimitive.Root;
118
+ var PopoverTrigger = PopoverPrimitive.Trigger;
119
+ var PopoverClose = PopoverPrimitive.Close;
120
+ var PopoverContent = React25.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
121
+ PopoverPrimitive.Content,
122
+ {
123
+ ref,
124
+ align,
125
+ sideOffset,
126
+ className: cn(
127
+ "sb-z-50 sb-w-72 sb-rounded-md sb-border sb-bg-popover sb-p-4 sb-text-popover-foreground sb-shadow-md sb-outline-none data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2 sb-origin-[--radix-popover-content-transform-origin]",
128
+ className
129
+ ),
130
+ ...props
131
+ }
132
+ )));
133
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
134
+ var Link = TiptapLink.extend({
135
+ inclusive: false,
136
+ parseHTML() {
137
+ return [{ tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])' }];
138
+ },
139
+ renderHTML({ HTMLAttributes }) {
140
+ return ["a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
141
+ },
142
+ addOptions() {
143
+ return {
144
+ ...this.parent?.(),
145
+ openOnClick: false
146
+ };
147
+ },
148
+ addProseMirrorPlugins() {
149
+ return [
150
+ ...this.parent?.() || [],
151
+ new Plugin({
152
+ props: {
153
+ handleClick(view, pos) {
154
+ const { schema: schema2, doc, tr } = view.state;
155
+ const range = getMarkRange(doc.resolve(pos), schema2.marks.link);
156
+ if (!range) {
157
+ return;
158
+ }
159
+ const { from, to } = range;
160
+ const start = Math.min(from, to);
161
+ const end = Math.max(from, to);
162
+ if (pos < start || pos > end) {
163
+ return;
164
+ }
165
+ const $start = doc.resolve(start);
166
+ const $end = doc.resolve(end);
167
+ const transaction = tr.setSelection(new TextSelection($start, $end));
168
+ view.dispatch(transaction);
169
+ }
170
+ }
171
+ })
172
+ ];
173
+ }
174
+ });
175
+
176
+ // src/features/rich-text-editor/utils/get-output.ts
177
+ var getOutput = (editor, format2) => {
178
+ switch (format2) {
179
+ case "json":
180
+ return editor.getJSON();
181
+ case "html":
182
+ return editor.isEmpty ? "" : editor.getHTML();
183
+ default:
184
+ return editor.getText();
185
+ }
186
+ };
187
+
188
+ // src/features/rich-text-editor/hooks/useRichTextEditor.ts
189
+ var useRichTextEditor = ({
190
+ value,
191
+ output = "html",
192
+ editorClassName,
193
+ onUpdate,
194
+ onBlur,
195
+ ...options
196
+ }) => {
197
+ const handleCreate = useCallback(
198
+ (editor2) => {
199
+ console.count("useRichTextEditor:handleCreate");
200
+ if (value && editor2.isEmpty) {
201
+ editor2.commands.setContent(value);
202
+ }
203
+ },
204
+ [value]
205
+ );
206
+ const handleUpdate = useCallback(
207
+ (editor2) => {
208
+ console.count("useRichTextEditor:handleUpdate");
209
+ onUpdate?.(getOutput(editor2, output));
210
+ },
211
+ [output, onUpdate]
212
+ );
213
+ const handleBlur = useCallback(
214
+ (editor2) => {
215
+ console.count("useRichTextEditor:handleBlur");
216
+ onBlur?.(getOutput(editor2, output));
217
+ },
218
+ [output, onBlur]
219
+ );
220
+ const editor = useEditor({
221
+ extensions: [StarterKit, Underline, Color, TextStyle, Link],
222
+ editorProps: {
223
+ attributes: {
224
+ autocomplete: "off",
225
+ autocorrect: "off",
226
+ autocapitalize: "off",
227
+ class: cn("sb-focus:outline-none", editorClassName)
228
+ }
229
+ },
230
+ onCreate: ({ editor: editor2 }) => handleCreate(editor2),
231
+ onUpdate: ({ editor: editor2 }) => handleUpdate(editor2),
232
+ onBlur: ({ editor: editor2 }) => handleBlur(editor2),
233
+ ...options
234
+ });
235
+ console.count("useRichTextEditor");
236
+ return editor;
237
+ };
238
+ var DropdownMenu = DropdownMenuPrimitive.Root;
239
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
240
+ var DropdownMenuSubTrigger = React25.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
241
+ DropdownMenuPrimitive.SubTrigger,
242
+ {
243
+ ref,
244
+ className: cn(
245
+ "sb-flex sb-cursor-default sb-select-none sb-items-center sb-gap-2 sb-rounded-sm sb-px-2 sb-py-1.5 sb-text-sm sb-outline-none focus:sb-bg-accent data-[state=open]:sb-bg-accent [&_svg]:sb-pointer-events-none [&_svg]:sb-size-4 [&_svg]:sb-shrink-0",
246
+ inset && "sb-pl-8",
247
+ className
248
+ ),
249
+ ...props
250
+ },
251
+ children,
252
+ /* @__PURE__ */ React25.createElement(ChevronRight, { className: "sb-ml-auto" })
253
+ ));
254
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
255
+ var DropdownMenuSubContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
256
+ DropdownMenuPrimitive.SubContent,
257
+ {
258
+ ref,
259
+ className: cn(
260
+ "sb-z-50 sb-min-w-[8rem] sb-overflow-hidden sb-rounded-md sb-border sb-bg-popover sb-p-1 sb-text-popover-foreground sb-shadow-lg data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2 sb-origin-[--radix-dropdown-menu-content-transform-origin]",
261
+ className
262
+ ),
263
+ ...props
264
+ }
265
+ ));
266
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
267
+ var DropdownMenuContent = React25.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
268
+ DropdownMenuPrimitive.Content,
269
+ {
270
+ ref,
271
+ sideOffset,
272
+ className: cn(
273
+ "sb-z-50 sb-max-h-[var(--radix-dropdown-menu-content-available-height)] sb-min-w-[8rem] sb-overflow-y-auto sb-overflow-x-hidden sb-rounded-md sb-border sb-bg-popover sb-p-1 sb-text-popover-foreground sb-shadow-md",
274
+ "data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2 sb-origin-[--radix-dropdown-menu-content-transform-origin]",
275
+ className
276
+ ),
277
+ ...props
278
+ }
279
+ )));
280
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
281
+ var DropdownMenuItem = React25.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25.createElement(
282
+ DropdownMenuPrimitive.Item,
283
+ {
284
+ ref,
285
+ className: cn(
286
+ "sb-relative sb-flex sb-cursor-default sb-select-none sb-items-center sb-gap-2 sb-rounded-sm sb-px-2 sb-py-1.5 sb-text-sm sb-outline-none sb-transition-colors focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50 [&>svg]:sb-size-4 [&>svg]:sb-shrink-0",
287
+ inset && "sb-pl-8",
288
+ className
289
+ ),
290
+ ...props
291
+ }
292
+ ));
293
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
294
+ var DropdownMenuCheckboxItem = React25.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ React25.createElement(
295
+ DropdownMenuPrimitive.CheckboxItem,
296
+ {
297
+ ref,
298
+ className: cn(
299
+ "sb-relative sb-flex sb-cursor-default sb-select-none sb-items-center sb-rounded-sm sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-outline-none sb-transition-colors focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50",
300
+ className
301
+ ),
302
+ checked,
303
+ ...props
304
+ },
305
+ /* @__PURE__ */ React25.createElement("span", { className: "sb-absolute sb-left-2 sb-flex sb-h-3.5 sb-w-3.5 sb-items-center sb-justify-center" }, /* @__PURE__ */ React25.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React25.createElement(Check, { className: "sb-h-4 sb-w-4" }))),
306
+ children
307
+ ));
308
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
309
+ var DropdownMenuRadioItem = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
310
+ DropdownMenuPrimitive.RadioItem,
311
+ {
312
+ ref,
313
+ className: cn(
314
+ "sb-relative sb-flex sb-cursor-default sb-select-none sb-items-center sb-rounded-sm sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-outline-none sb-transition-colors focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50",
315
+ className
316
+ ),
317
+ ...props
318
+ },
319
+ /* @__PURE__ */ React25.createElement("span", { className: "sb-absolute sb-left-2 sb-flex sb-h-3.5 sb-w-3.5 sb-items-center sb-justify-center" }, /* @__PURE__ */ React25.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React25.createElement(Circle, { className: "sb-h-2 sb-w-2 sb-fill-current" }))),
320
+ children
321
+ ));
322
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
323
+ var DropdownMenuLabel = React25.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25.createElement(
324
+ DropdownMenuPrimitive.Label,
325
+ {
326
+ ref,
327
+ className: cn(
328
+ "sb-px-2 sb-py-1.5 sb-text-sm sb-font-semibold",
329
+ inset && "sb-pl-8",
330
+ className
331
+ ),
332
+ ...props
333
+ }
334
+ ));
335
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
336
+ var DropdownMenuSeparator = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
337
+ DropdownMenuPrimitive.Separator,
338
+ {
339
+ ref,
340
+ className: cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
341
+ ...props
342
+ }
343
+ ));
344
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
345
+ var Separator2 = React25.forwardRef(
346
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ React25.createElement(
347
+ SeparatorPrimitive.Root,
348
+ {
349
+ ref,
350
+ decorative,
351
+ orientation,
352
+ className: cn(
353
+ "sb-shrink-0 sb-bg-border",
354
+ orientation === "horizontal" ? "sb-h-[1px] sb-w-full" : "sb-h-full sb-w-[1px]",
355
+ className
356
+ ),
357
+ ...props
358
+ }
359
+ )
360
+ );
361
+ Separator2.displayName = SeparatorPrimitive.Root.displayName;
362
+ var toggleVariants = cva(
363
+ "sb-inline-flex sb-items-center sb-justify-center sb-gap-2 sb-rounded-md sb-text-sm sb-font-medium sb-transition-colors hover:sb-bg-muted hover:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:sb-ring-ring disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=on]:sb-bg-accent data-[state=on]:sb-text-accent-foreground [&_svg]:sb-pointer-events-none [&_svg]:sb-size-4 [&_svg]:sb-shrink-0",
364
+ {
365
+ variants: {
366
+ variant: {
367
+ default: "sb-bg-transparent",
368
+ outline: "sb-border sb-border-input sb-bg-transparent sb-shadow-sm hover:sb-bg-accent hover:sb-text-accent-foreground"
369
+ },
370
+ size: {
371
+ default: "sb-h-9 sb-px-2 sb-min-w-9",
372
+ sm: "sb-h-8 sb-px-1.5 sb-min-w-8",
373
+ lg: "sb-h-10 sb-px-2.5 sb-min-w-10"
374
+ }
375
+ },
376
+ defaultVariants: {
377
+ variant: "default",
378
+ size: "default"
379
+ }
380
+ }
381
+ );
382
+ var Toggle = React25.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React25.createElement(
383
+ TogglePrimitive.Root,
384
+ {
385
+ ref,
386
+ className: cn(toggleVariants({ variant, size, className })),
387
+ ...props
388
+ }
389
+ ));
390
+ Toggle.displayName = TogglePrimitive.Root.displayName;
391
+ var ToggleGroupContext = React25.createContext({
392
+ size: "default",
393
+ variant: "default"
394
+ });
395
+ var ToggleGroup = React25.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
396
+ ToggleGroupPrimitive.Root,
397
+ {
398
+ ref,
399
+ className: cn("sb-flex sb-items-center sb-justify-center sb-gap-1", className),
400
+ ...props
401
+ },
402
+ /* @__PURE__ */ React25.createElement(ToggleGroupContext.Provider, { value: { variant, size } }, children)
403
+ ));
404
+ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
405
+ var ToggleGroupItem = React25.forwardRef(({ className, children, variant, size, ...props }, ref) => {
406
+ const context = React25.useContext(ToggleGroupContext);
407
+ return /* @__PURE__ */ React25.createElement(
408
+ ToggleGroupPrimitive.Item,
409
+ {
410
+ ref,
411
+ className: cn(
412
+ toggleVariants({
413
+ variant: context.variant || variant,
414
+ size: context.size || size
415
+ }),
416
+ className
417
+ ),
418
+ ...props
419
+ },
420
+ children
421
+ );
422
+ });
423
+ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
424
+ var PALETTES = [
425
+ {
426
+ inverse: "hsl(var(--background))",
427
+ colors: [
428
+ { cssVar: "hsl(var(--foreground))" },
429
+ { cssVar: "hsl(var(--primary-foreground))" },
430
+ { cssVar: "hsl(var(--secondary-foreground))" },
431
+ { cssVar: "hsl(var(--tertiary-foreground))" },
432
+ { cssVar: "hsl(var(--muted-foreground))" },
433
+ { cssVar: "hsl(var(--accent-foreground))" },
434
+ { cssVar: "hsl(var(--destructive-foreground))" }
435
+ ]
436
+ },
437
+ {
438
+ inverse: "hsl(var(--foreground))",
439
+ colors: [
440
+ { cssVar: "hsl(var(--background))" },
441
+ { cssVar: "hsl(var(--primary))" },
442
+ { cssVar: "hsl(var(--secondary))" },
443
+ { cssVar: "hsl(var(--tertiary))" },
444
+ { cssVar: "hsl(var(--muted))" },
445
+ { cssVar: "hsl(var(--accent))" },
446
+ { cssVar: "hsl(var(--destructive))" }
447
+ ]
448
+ }
449
+ ];
450
+ var ColorTool = ({ editor }) => {
451
+ const color = editor.getAttributes("textStyle")?.color || "hsl(var(--foreground))";
452
+ const [selectedColor, setSelectedColor] = React25.useState(color);
453
+ React25.useEffect(() => {
454
+ setSelectedColor(color);
455
+ }, [color]);
456
+ const handleColorChange = React25.useCallback(
457
+ (value) => {
458
+ setSelectedColor(value);
459
+ editor.chain().focus().setColor(value).run();
460
+ },
461
+ [editor]
462
+ );
463
+ return /* @__PURE__ */ React25.createElement(Popover, { modal: true }, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(ToolbarButton, { className: "sb-w-12" }, /* @__PURE__ */ React25.createElement(
464
+ "svg",
465
+ {
466
+ xmlns: "http://www.w3.org/2000/svg",
467
+ width: "24",
468
+ height: "24",
469
+ viewBox: "0 0 24 24",
470
+ fill: "none",
471
+ stroke: "currentColor",
472
+ strokeWidth: "2",
473
+ strokeLinecap: "round",
474
+ strokeLinejoin: "round",
475
+ className: "sb-size-5",
476
+ style: { color: selectedColor }
477
+ },
478
+ /* @__PURE__ */ React25.createElement("path", { d: "M4 20h16" }),
479
+ /* @__PURE__ */ React25.createElement("path", { d: "m6 16 6-12 6 12" }),
480
+ /* @__PURE__ */ React25.createElement("path", { d: "M8 12h8" })
481
+ ), /* @__PURE__ */ React25.createElement(LuChevronDown, { className: "sb-size-5" }))), /* @__PURE__ */ React25.createElement(PopoverContent, { align: "start", className: "sb-w-full" }, /* @__PURE__ */ React25.createElement(
482
+ ToggleGroup,
483
+ {
484
+ type: "single",
485
+ value: selectedColor,
486
+ onValueChange: handleColorChange,
487
+ className: "sb-flex-col sb-gap-1.5"
488
+ },
489
+ PALETTES.map((pallete, i) => /* @__PURE__ */ React25.createElement("div", { key: i, className: "sb-flex sb-gap-1.5" }, pallete.colors.map((color2, j) => /* @__PURE__ */ React25.createElement(
490
+ ToggleGroupItem,
491
+ {
492
+ tabIndex: 0,
493
+ key: j,
494
+ className: "sb-relative sb-size-7 sb-rounded-md sb-border sb-p-0",
495
+ value: color2.cssVar,
496
+ style: { backgroundColor: color2.cssVar }
497
+ },
498
+ selectedColor === color2.cssVar && /* @__PURE__ */ React25.createElement(
499
+ LuCheck,
500
+ {
501
+ className: "sb-absolute sb-inset-0 sb-m-auto sb-size-6",
502
+ style: { color: pallete.inverse }
503
+ }
504
+ )
505
+ ))))
506
+ )));
507
+ };
508
+ var formatActions = [
509
+ {
510
+ label: "Normal Text",
511
+ element: "span",
512
+ className: "sb-grow"
513
+ },
514
+ {
515
+ label: "Heading 1",
516
+ element: "h1",
517
+ level: 1,
518
+ className: "sb-m-0 sb-grow sb-text-3xl sb-font-extrabold"
519
+ },
520
+ {
521
+ label: "Heading 2",
522
+ element: "h2",
523
+ level: 2,
524
+ className: "sb-m-0 sb-grow sb-text-xl sb-font-bold"
525
+ },
526
+ {
527
+ label: "Heading 3",
528
+ element: "h3",
529
+ level: 3,
530
+ className: "sb-m-0 sb-grow sb-text-lg sb-font-semibold"
531
+ },
532
+ {
533
+ label: "Heading 4",
534
+ element: "h4",
535
+ level: 4,
536
+ className: "sb-m-0 sb-grow sb-text-base sb-font-semibold"
537
+ }
538
+ ];
539
+ var ElementTool = ({ editor }) => {
540
+ const isActive = editor.isActive("heading");
541
+ const handleFormatChange = React25.useCallback(
542
+ (level) => {
543
+ if (level) {
544
+ editor.chain().focus().toggleHeading({ level }).run();
545
+ } else {
546
+ editor.chain().focus().setParagraph().run();
547
+ }
548
+ },
549
+ [editor]
550
+ );
551
+ return /* @__PURE__ */ React25.createElement(DropdownMenu, null, /* @__PURE__ */ React25.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
552
+ ToolbarButton,
553
+ {
554
+ className: "sb-w-12 data-[state=open]:sb-bg-accent",
555
+ pressed: isActive
556
+ },
557
+ /* @__PURE__ */ React25.createElement(LuHeading, { className: "sb-size-5" }),
558
+ /* @__PURE__ */ React25.createElement(LuChevronDown, { className: "sb-size-5" })
559
+ )), /* @__PURE__ */ React25.createElement(DropdownMenuContent, { align: "start" }, formatActions.map(({ element: Element, ...action }) => /* @__PURE__ */ React25.createElement(
560
+ DropdownMenuItem,
561
+ {
562
+ key: action.label,
563
+ className: cn({
564
+ "sb-bg-accent": action.level ? editor.isActive("heading", { level: action.level }) : editor.isActive("paragraph")
565
+ }),
566
+ onClick: () => handleFormatChange(action.level)
567
+ },
568
+ /* @__PURE__ */ React25.createElement(Element, { className: action.className }, action.label)
569
+ ))));
570
+ };
571
+ var actions = [
572
+ {
573
+ value: "bold",
574
+ label: "Bold",
575
+ icon: LuBold,
576
+ action: (editor) => editor.chain().focus().toggleBold().run(),
577
+ isActive: (editor) => editor.isActive("bold"),
578
+ canExecute: (editor) => editor.can().chain().focus().toggleBold().run() && !editor.isActive("codeBlock")
579
+ },
580
+ {
581
+ value: "italic",
582
+ label: "Italic",
583
+ icon: LuItalic,
584
+ action: (editor) => editor.chain().focus().toggleItalic().run(),
585
+ isActive: (editor) => editor.isActive("italic"),
586
+ canExecute: (editor) => editor.can().chain().focus().toggleItalic().run() && !editor.isActive("codeBlock")
587
+ },
588
+ {
589
+ value: "underline",
590
+ label: "Underline",
591
+ icon: LuUnderline,
592
+ action: (editor) => editor.chain().focus().toggleUnderline().run(),
593
+ isActive: (editor) => editor.isActive("underline"),
594
+ canExecute: (editor) => editor.can().chain().focus().toggleUnderline().run() && !editor.isActive("codeBlock")
595
+ },
596
+ {
597
+ value: "strikethrough",
598
+ label: "Strikethrough",
599
+ icon: LuStrikethrough,
600
+ action: (editor) => editor.chain().focus().toggleStrike().run(),
601
+ isActive: (editor) => editor.isActive("strike"),
602
+ canExecute: (editor) => editor.can().chain().focus().toggleStrike().run() && !editor.isActive("codeBlock")
603
+ },
604
+ {
605
+ value: "code",
606
+ label: "Code",
607
+ icon: LuCode,
608
+ action: (editor) => editor.chain().focus().toggleCode().run(),
609
+ isActive: (editor) => editor.isActive("code"),
610
+ canExecute: (editor) => editor.can().chain().focus().toggleCode().run() && !editor.isActive("codeBlock")
611
+ },
612
+ {
613
+ value: "clearFormatting",
614
+ label: "Clear formatting",
615
+ icon: LuRemoveFormatting,
616
+ action: (editor) => editor.chain().focus().unsetAllMarks().run(),
617
+ isActive: () => false,
618
+ canExecute: (editor) => editor.can().chain().focus().unsetAllMarks().run() && !editor.isActive("codeBlock")
619
+ }
620
+ ];
621
+ var FormatTool = ({ editor }) => {
622
+ return /* @__PURE__ */ React25.createElement(ToolbarSection, { editor, actions, mainActionCount: 1 });
623
+ };
624
+ var actions2 = [
625
+ {
626
+ value: "codeBlock",
627
+ label: "Code block",
628
+ icon: LuCode,
629
+ action: (editor) => editor.chain().focus().toggleCodeBlock().run(),
630
+ isActive: (editor) => editor.isActive("codeBlock"),
631
+ canExecute: (editor) => editor.can().chain().focus().toggleCodeBlock().run()
632
+ },
633
+ {
634
+ value: "blockquote",
635
+ label: "Blockquote",
636
+ icon: LuQuote,
637
+ action: (editor) => editor.chain().focus().toggleBlockquote().run(),
638
+ isActive: (editor) => editor.isActive("blockquote"),
639
+ canExecute: (editor) => editor.can().chain().focus().toggleBlockquote().run()
640
+ },
641
+ {
642
+ value: "horizontalRule",
643
+ label: "Divider",
644
+ icon: LuMinus,
645
+ action: (editor) => editor.chain().focus().setHorizontalRule().run(),
646
+ isActive: () => false,
647
+ canExecute: (editor) => editor.can().chain().focus().setHorizontalRule().run()
648
+ }
649
+ ];
650
+ var InsertTool = ({ editor }) => {
651
+ return /* @__PURE__ */ React25.createElement(ToolbarSection, { editor, actions: actions2, mainActionCount: 0 });
652
+ };
653
+ var Dialog = DialogPrimitive.Root;
654
+ var DialogTrigger = DialogPrimitive.Trigger;
655
+ var DialogPortal = DialogPrimitive.Portal;
656
+ var DialogOverlay = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
657
+ DialogPrimitive.Overlay,
658
+ {
659
+ ref,
660
+ className: cn(
661
+ "sb-fixed sb-inset-0 sb-z-50 sb-bg-black/80 sb- data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0",
662
+ className
663
+ ),
664
+ ...props
665
+ }
666
+ ));
667
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
668
+ var DialogContent = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(DialogPortal, null, /* @__PURE__ */ React25.createElement(DialogOverlay, null), /* @__PURE__ */ React25.createElement(
669
+ DialogPrimitive.Content,
670
+ {
671
+ ref,
672
+ className: cn(
673
+ "sb-fixed sb-left-[50%] sb-top-[50%] sb-z-50 sb-grid sb-w-full sb-max-w-lg sb-translate-x-[-50%] sb-translate-y-[-50%] sb-gap-4 sb-border sb-bg-background sb-p-6 sb-shadow-lg sb-duration-200 data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[state=closed]:sb-slide-out-to-left-1/2 data-[state=closed]:sb-slide-out-to-top-[48%] data-[state=open]:sb-slide-in-from-left-1/2 data-[state=open]:sb-slide-in-from-top-[48%] sm:sb-rounded-lg",
674
+ className
675
+ ),
676
+ ...props
677
+ },
678
+ children,
679
+ /* @__PURE__ */ React25.createElement(DialogPrimitive.Close, { className: "sb-absolute sb-right-4 sb-top-4 sb-rounded-sm sb-opacity-70 sb-ring-offset-background sb-transition-opacity hover:sb-opacity-100 focus:sb-outline-none focus:sb-ring-2 focus:sb-ring-ring focus:sb-ring-offset-2 disabled:sb-pointer-events-none data-[state=open]:sb-bg-accent data-[state=open]:sb-text-muted-foreground" }, /* @__PURE__ */ React25.createElement(X, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React25.createElement("span", { className: "sb-sr-only" }, "Close"))
680
+ )));
681
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
682
+ var DialogHeader = ({
683
+ className,
684
+ ...props
685
+ }) => /* @__PURE__ */ React25.createElement(
686
+ "div",
687
+ {
688
+ className: cn(
689
+ "sb-flex sb-flex-col sb-space-y-1.5 sb-text-center sm:sb-text-left",
690
+ className
691
+ ),
692
+ ...props
693
+ }
694
+ );
695
+ DialogHeader.displayName = "DialogHeader";
696
+ var DialogTitle = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
697
+ DialogPrimitive.Title,
698
+ {
699
+ ref,
700
+ className: cn(
701
+ "sb-text-lg sb-font-semibold sb-leading-none sb-tracking-tight",
702
+ className
703
+ ),
704
+ ...props
705
+ }
706
+ ));
707
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
708
+ var DialogDescription = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
709
+ DialogPrimitive.Description,
710
+ {
711
+ ref,
712
+ className: cn("sb-text-sm sb-text-muted-foreground", className),
713
+ ...props
714
+ }
715
+ ));
716
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
717
+ var labelVariants = cva(
718
+ "sb-text-sm sb-font-medium sb-leading-none peer-disabled:sb-cursor-not-allowed peer-disabled:sb-opacity-70"
719
+ );
720
+ var Label2 = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
721
+ LabelPrimitive.Root,
722
+ {
723
+ ref,
724
+ className: cn(labelVariants(), className),
725
+ ...props
726
+ }
727
+ ));
728
+ Label2.displayName = LabelPrimitive.Root.displayName;
729
+
730
+ // src/components/ui/form.tsx
731
+ var Form = FormProvider;
732
+ var FormFieldContext = React25.createContext(
733
+ {}
734
+ );
735
+ var FormField = ({
736
+ ...props
737
+ }) => {
738
+ return /* @__PURE__ */ React25.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React25.createElement(Controller, { ...props }));
739
+ };
740
+ var useFormField = () => {
741
+ const fieldContext = React25.useContext(FormFieldContext);
742
+ const itemContext = React25.useContext(FormItemContext);
743
+ const { getFieldState, formState } = useFormContext();
744
+ const fieldState = getFieldState(fieldContext.name, formState);
745
+ if (!fieldContext) {
746
+ throw new Error("useFormField should be used within <FormField>");
747
+ }
748
+ const { id } = itemContext;
749
+ return {
750
+ id,
751
+ name: fieldContext.name,
752
+ formItemId: `${id}-form-item`,
753
+ formDescriptionId: `${id}-form-item-description`,
754
+ formMessageId: `${id}-form-item-message`,
755
+ ...fieldState
756
+ };
757
+ };
758
+ var FormItemContext = React25.createContext(
759
+ {}
760
+ );
761
+ var FormItem = React25.forwardRef(({ className, ...props }, ref) => {
762
+ const id = React25.useId();
763
+ return /* @__PURE__ */ React25.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React25.createElement("div", { ref, className: cn("sb-space-y-2", className), ...props }));
764
+ });
765
+ FormItem.displayName = "FormItem";
766
+ var FormLabel = React25.forwardRef(({ className, ...props }, ref) => {
767
+ const { error, formItemId } = useFormField();
768
+ return /* @__PURE__ */ React25.createElement(
769
+ Label2,
770
+ {
771
+ ref,
772
+ className: cn(error && "sb-text-destructive", className),
773
+ htmlFor: formItemId,
774
+ ...props
775
+ }
776
+ );
777
+ });
778
+ FormLabel.displayName = "FormLabel";
779
+ var FormControl = React25.forwardRef(({ ...props }, ref) => {
780
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
781
+ return /* @__PURE__ */ React25.createElement(
782
+ Slot,
783
+ {
784
+ ref,
785
+ id: formItemId,
786
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
787
+ "aria-invalid": !!error,
788
+ ...props
789
+ }
790
+ );
791
+ });
792
+ FormControl.displayName = "FormControl";
793
+ var FormDescription = React25.forwardRef(({ className, ...props }, ref) => {
794
+ const { formDescriptionId } = useFormField();
795
+ return /* @__PURE__ */ React25.createElement(
796
+ "p",
797
+ {
798
+ ref,
799
+ id: formDescriptionId,
800
+ className: cn("sb-text-[0.8rem] sb-text-muted-foreground", className),
801
+ ...props
802
+ }
803
+ );
804
+ });
805
+ FormDescription.displayName = "FormDescription";
806
+ var FormMessage = React25.forwardRef(({ className, children, ...props }, ref) => {
807
+ const { error, formMessageId } = useFormField();
808
+ const body = error ? String(error?.message ?? "") : children;
809
+ if (!body) {
810
+ return null;
811
+ }
812
+ return /* @__PURE__ */ React25.createElement(
813
+ "p",
814
+ {
815
+ ref,
816
+ id: formMessageId,
817
+ className: cn("sb-text-[0.8rem] sb-font-medium sb-text-destructive", className),
818
+ ...props
819
+ },
820
+ body
821
+ );
822
+ });
823
+ FormMessage.displayName = "FormMessage";
824
+ var Input = React25.forwardRef(
825
+ ({ className, type, ...props }, ref) => {
826
+ return /* @__PURE__ */ React25.createElement(
827
+ "input",
828
+ {
829
+ type,
830
+ className: cn(
831
+ "sb-flex sb-h-9 sb-w-full sb-rounded-md sb-border sb-border-input sb-bg-transparent sb-px-3 sb-py-1 sb-text-base sb-shadow-sm sb-transition-colors file:sb-border-0 file:sb-bg-transparent file:sb-text-sm file:sb-font-medium file:sb-text-foreground placeholder:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:sb-ring-ring disabled:sb-cursor-not-allowed disabled:sb-opacity-50 md:sb-text-sm",
832
+ className
833
+ ),
834
+ ref,
835
+ ...props
836
+ }
837
+ );
838
+ }
839
+ );
840
+ Input.displayName = "Input";
841
+ var AdvancedInput = React25.forwardRef(
842
+ ({ prepend, append, ...props }, ref) => {
843
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-relative" }, /* @__PURE__ */ React25.createElement(Input, { ref, className: "sb-pl-9 sb-pr-7 sb-text-right", ...props }), prepend && /* @__PURE__ */ React25.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-left-3 sb--translate-y-1/2" }, prepend), append && /* @__PURE__ */ React25.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-right-3 sb--translate-y-1/2" }, append));
844
+ }
845
+ );
846
+ AdvancedInput.displayName = "AdvancedInput";
847
+ var Switch = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
848
+ SwitchPrimitives.Root,
849
+ {
850
+ className: cn(
851
+ "sb-peer sb-inline-flex sb-h-5 sb-w-9 sb-shrink-0 sb-cursor-pointer sb-items-center sb-rounded-full sb-border-2 sb-border-transparent sb-shadow-sm sb-transition-colors focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2 focus-visible:sb-ring-offset-background disabled:sb-cursor-not-allowed disabled:sb-opacity-50 data-[state=checked]:sb-bg-primary data-[state=unchecked]:sb-bg-input",
852
+ className
853
+ ),
854
+ ...props,
855
+ ref
856
+ },
857
+ /* @__PURE__ */ React25.createElement(
858
+ SwitchPrimitives.Thumb,
859
+ {
860
+ className: cn(
861
+ "sb-pointer-events-none sb-block sb-h-4 sb-w-4 sb-rounded-full sb-bg-background sb-shadow-lg sb-ring-0 sb-transition-transform data-[state=checked]:sb-translate-x-4 data-[state=unchecked]:sb-translate-x-0"
862
+ )
863
+ }
864
+ )
865
+ ));
866
+ Switch.displayName = SwitchPrimitives.Root.displayName;
867
+ var LinkTool = ({ editor }) => {
868
+ const [open, setOpen] = React25.useState(false);
869
+ const { from, to } = editor.state.selection;
870
+ const text = editor.state.doc.textBetween(from, to, " ");
871
+ const handleSetLink = React25.useCallback(
872
+ (url, text2, openInNewTab) => {
873
+ editor.chain().focus().extendMarkRange("link").insertContent({
874
+ type: "text",
875
+ text: text2 || url,
876
+ marks: [
877
+ {
878
+ type: "link",
879
+ attrs: {
880
+ href: url,
881
+ target: openInNewTab ? "_blank" : ""
882
+ }
883
+ }
884
+ ]
885
+ }).setLink({ href: url }).run();
886
+ editor.commands.enter();
887
+ setOpen(false);
888
+ },
889
+ [editor]
890
+ );
891
+ return /* @__PURE__ */ React25.createElement(Dialog, { open, onOpenChange: setOpen }, /* @__PURE__ */ React25.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
892
+ ToolbarButton,
893
+ {
894
+ pressed: editor.isActive("link"),
895
+ disabled: editor.isActive("codeBlock")
896
+ },
897
+ /* @__PURE__ */ React25.createElement(LuLink2, { className: "sb-size-5" })
898
+ )), /* @__PURE__ */ React25.createElement(DialogContent, { className: "sb-w-full sb-min-w-80" }, /* @__PURE__ */ React25.createElement(LinkForm, { onSave: handleSetLink, defaultText: text })));
899
+ };
900
+ var schema = z.object({
901
+ url: z.string().min(0),
902
+ text: z.string().optional(),
903
+ isNewTab: z.boolean().optional()
904
+ });
905
+ var LinkForm = ({
906
+ onSave,
907
+ defaultIsNewTab,
908
+ defaultUrl,
909
+ defaultText
910
+ }) => {
911
+ const form = useForm({
912
+ resolver: zodResolver(schema),
913
+ defaultValues: {
914
+ url: defaultUrl || "",
915
+ text: defaultText || "",
916
+ isNewTab: defaultIsNewTab || false
917
+ }
918
+ });
919
+ const handleSubmit = (values) => {
920
+ onSave(values.url, values.text, values.isNewTab);
921
+ };
922
+ return /* @__PURE__ */ React25.createElement(Form, { ...form }, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-6" }, /* @__PURE__ */ React25.createElement(
923
+ FormField,
924
+ {
925
+ control: form.control,
926
+ name: "url",
927
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "URL"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(Input, { type: "url", ...field, autoFocus: true })), /* @__PURE__ */ React25.createElement(FormMessage, null))
928
+ }
929
+ ), /* @__PURE__ */ React25.createElement(
930
+ FormField,
931
+ {
932
+ control: form.control,
933
+ name: "text",
934
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Text"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(Input, { ...field })), /* @__PURE__ */ React25.createElement(FormMessage, null))
935
+ }
936
+ ), /* @__PURE__ */ React25.createElement(
937
+ FormField,
938
+ {
939
+ control: form.control,
940
+ name: "isNewTab",
941
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-space-x-2" }, /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
942
+ Switch,
943
+ {
944
+ checked: field.value,
945
+ onCheckedChange: field.onChange
946
+ }
947
+ )), /* @__PURE__ */ React25.createElement(FormLabel, null, "Open in new tab")), /* @__PURE__ */ React25.createElement(FormMessage, null))
948
+ }
949
+ ), /* @__PURE__ */ React25.createElement(Button, { type: "button", onClick: form.handleSubmit(handleSubmit) }, "Save")));
950
+ };
951
+ var actions3 = [
952
+ {
953
+ value: "orderedList",
954
+ label: "Numbered list",
955
+ icon: LuListOrdered,
956
+ action: (editor) => editor.chain().focus().toggleOrderedList().run(),
957
+ isActive: (editor) => editor.isActive("orderedList"),
958
+ canExecute: (editor) => editor.can().chain().focus().toggleOrderedList().run()
959
+ },
960
+ {
961
+ value: "bulletList",
962
+ label: "Bullet list",
963
+ icon: LuList,
964
+ action: (editor) => editor.chain().focus().toggleBulletList().run(),
965
+ isActive: (editor) => editor.isActive("bulletList"),
966
+ canExecute: (editor) => editor.can().chain().focus().toggleBulletList().run()
967
+ }
968
+ ];
969
+ var ListTool = ({ editor }) => {
970
+ return /* @__PURE__ */ React25.createElement(ToolbarSection, { editor, actions: actions3, mainActionCount: 2 });
971
+ };
972
+
973
+ // src/features/rich-text-editor/components/toolbar.tsx
974
+ var Toolbar = ({ editor }) => {
975
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-shrink-0 sb-overflow-x-auto sb-border-b sb-border-border sb-p-2" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-w-max sb-items-center sb-gap-px" }, /* @__PURE__ */ React25.createElement(ElementTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(FormatTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(ColorTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(ListTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(LinkTool, { editor }), /* @__PURE__ */ React25.createElement(InsertTool, { editor })));
976
+ };
977
+ var ToolbarSection = ({
978
+ editor,
979
+ actions: actions4,
980
+ mainActionCount = 0
981
+ }) => {
982
+ const { mainActions, dropdownActions } = React25.useMemo(() => {
983
+ return {
984
+ mainActions: actions4.slice(0, mainActionCount),
985
+ dropdownActions: actions4.slice(mainActionCount)
986
+ };
987
+ }, [actions4, mainActionCount]);
988
+ const isDropdownActive = React25.useMemo(() => {
989
+ return dropdownActions.some((action) => action.isActive(editor));
990
+ }, [dropdownActions, editor]);
991
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, null, mainActions.map((action) => /* @__PURE__ */ React25.createElement(
992
+ ToolbarButton,
993
+ {
994
+ key: action.label,
995
+ onClick: () => action.action(editor),
996
+ disabled: !action.canExecute(editor),
997
+ pressed: action.isActive(editor)
998
+ },
999
+ /* @__PURE__ */ React25.createElement(action.icon, { className: "sb-size-5" })
1000
+ )), dropdownActions.length > 0 && /* @__PURE__ */ React25.createElement(DropdownMenu, null, /* @__PURE__ */ React25.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(ToolbarButton, { pressed: isDropdownActive }, /* @__PURE__ */ React25.createElement(LuEllipsis, { className: "sb-size-5" }))), /* @__PURE__ */ React25.createElement(DropdownMenuContent, { align: "start" }, dropdownActions.map((action) => /* @__PURE__ */ React25.createElement(
1001
+ DropdownMenuItem,
1002
+ {
1003
+ key: action.label,
1004
+ className: cn("sb-flex sb-flex-row sb-items-center sb-gap-2", {
1005
+ "sb-bg-accent": action.isActive(editor)
1006
+ }),
1007
+ onClick: () => action.action(editor),
1008
+ disabled: !action.canExecute(editor)
1009
+ },
1010
+ /* @__PURE__ */ React25.createElement(action.icon, { className: "sb-size-4" }),
1011
+ /* @__PURE__ */ React25.createElement("span", null, action.label)
1012
+ )))));
1013
+ };
1014
+ var ToolbarButton = React25.forwardRef(({ className, ...props }, ref) => {
1015
+ return /* @__PURE__ */ React25.createElement(
1016
+ Toggle,
1017
+ {
1018
+ size: "sm",
1019
+ className: cn(
1020
+ "sb-size-8 sb-p-0 data-[state=on]:sb-bg-accent",
1021
+ { "sb-bg-accent": props.pressed },
1022
+ className
1023
+ ),
1024
+ ref,
1025
+ ...props
1026
+ }
1027
+ );
1028
+ });
1029
+ ToolbarButton.displayName = "ToolbarButton";
1030
+
1031
+ // src/features/rich-text-editor/components/rich-text-editor.tsx
1032
+ var RichTextEditor = ({
1033
+ value,
1034
+ onChange,
1035
+ className,
1036
+ editorClassName,
1037
+ editorContentClassName,
1038
+ ...props
1039
+ }) => {
1040
+ console.count("re-render RichTextEditor");
1041
+ const editor = useRichTextEditor({
1042
+ value,
1043
+ onUpdate: onChange,
1044
+ editorClassName: cn("sb-flex-1 sb-px-3 sb-py-1", editorClassName),
1045
+ ...props
1046
+ });
1047
+ if (!editor) {
1048
+ return null;
1049
+ }
1050
+ return /* @__PURE__ */ React25.createElement(
1051
+ "div",
1052
+ {
1053
+ className: cn(
1054
+ "sb-flex sb-h-auto sb-min-h-72 sb-w-full sb-flex-col sb-rounded-md sb-border sb-border-input sb-shadow-sm focus-within:sb-border-primary",
1055
+ className
1056
+ )
1057
+ },
1058
+ /* @__PURE__ */ React25.createElement(Toolbar, { editor }),
1059
+ /* @__PURE__ */ React25.createElement(
1060
+ EditorContent,
1061
+ {
1062
+ editor,
1063
+ className: cn(
1064
+ "sb-editflow prose sb-flex sb-flex-1",
1065
+ editorContentClassName
1066
+ )
1067
+ }
1068
+ )
1069
+ );
1070
+ };
1071
+ function Calendar({
1072
+ className,
1073
+ classNames,
1074
+ showOutsideDays = true,
1075
+ ...props
1076
+ }) {
1077
+ return /* @__PURE__ */ React25.createElement(
1078
+ DayPicker,
1079
+ {
1080
+ showOutsideDays,
1081
+ className: cn("sb-p-3 sb-font-roboto", className),
1082
+ classNames: {
1083
+ months: "sb-flex sb-flex-col sm:sb-flex-row sb-space-y-4 sm:sb-space-x-4 sm:sb-space-y-0",
1084
+ month: "sb-space-y-4",
1085
+ caption: "sb-flex sb-justify-center sb-pt-1 sb-relative sb-items-center",
1086
+ caption_label: "sb-text-sm sb-font-medium",
1087
+ nav: "sb-space-x-1 sb-flex sb-items-center",
1088
+ nav_button: cn(
1089
+ buttonVariants({ variant: "outline" }),
1090
+ "sb-h-7 sb-w-7 sb-bg-transparent sb-p-0 sb-opacity-50 hover:sb-opacity-100"
1091
+ ),
1092
+ nav_button_previous: "sb-absolute sb-left-1",
1093
+ nav_button_next: "sb-absolute sb-right-1",
1094
+ table: "sb-w-full sb-border-collapse sb-space-y-1",
1095
+ head_row: "sb-flex",
1096
+ head_cell: "sb-text-muted-foreground sb-rounded-md sb-w-8 sb-font-normal sb-text-[0.8rem]",
1097
+ row: "sb-flex sb-w-full sb-mt-2",
1098
+ cell: cn(
1099
+ "sb-relative sb-p-0 sb-text-center sb-text-sm focus-within:sb-relative focus-within:sb-z-20 [&:has([aria-selected])]:sb-bg-accent [&:has([aria-selected].day-outside)]:sb-bg-accent/50 [&:has([aria-selected].day-range-end)]:sb-rounded-r-md",
1100
+ props.mode === "range" ? "[&:has(>.day-range-end)]:sb-rounded-r-md [&:has(>.day-range-start)]:sb-rounded-l-md first:[&:has([aria-selected])]:sb-rounded-l-md last:[&:has([aria-selected])]:sb-rounded-r-md" : "[&:has([aria-selected])]:sb-rounded-md"
1101
+ ),
1102
+ day: cn(
1103
+ buttonVariants({ variant: "ghost" }),
1104
+ "sb-h-8 sb-w-8 sb-p-0 sb-font-normal aria-selected:sb-opacity-100"
1105
+ ),
1106
+ day_range_start: "day-range-start",
1107
+ day_range_end: "day-range-end",
1108
+ day_selected: "sb-bg-primary sb-text-primary-foreground hover:sb-bg-primary hover:sb-text-primary-foreground focus:sb-bg-primary focus:sb-text-primary-foreground",
1109
+ day_today: "sb-bg-accent sb-text-accent-foreground",
1110
+ day_outside: "day-outside sb-text-muted-foreground sb-opacity-50 aria-selected:sb-bg-accent/50 aria-selected:sb-text-muted-foreground aria-selected:sb-opacity-30",
1111
+ day_disabled: "sb-text-muted-foreground sb-opacity-50",
1112
+ day_range_middle: "aria-selected:sb-bg-accent aria-selected:sb-text-accent-foreground",
1113
+ day_hidden: "invisible",
1114
+ ...classNames
1115
+ },
1116
+ components: {
1117
+ IconLeft: () => /* @__PURE__ */ React25.createElement(ChevronLeftIcon, { className: "sb-h-4 sb-w-4" }),
1118
+ IconRight: () => /* @__PURE__ */ React25.createElement(ChevronRightIcon, { className: "sb-h-4 sb-w-4" })
1119
+ },
1120
+ ...props
1121
+ }
1122
+ );
1123
+ }
1124
+ Calendar.displayName = "Calendar";
1125
+ var ColorPicker = (props) => {
1126
+ const { color, onColorChange, className } = props;
1127
+ const colors = props.colors ?? [
1128
+ "#000000",
1129
+ "#ffffff",
1130
+ "#0f172a",
1131
+ "#F1F5F9",
1132
+ "#64748B",
1133
+ "#E6007E",
1134
+ "#F8FAFC",
1135
+ "#009DD1",
1136
+ "#FF0000"
1137
+ ];
1138
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1139
+ Button,
1140
+ {
1141
+ variant: "outline",
1142
+ size: "sm",
1143
+ className: cn(
1144
+ "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
1145
+ !color && "sb-text-muted-foreground",
1146
+ className
1147
+ )
1148
+ },
1149
+ /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, color ? /* @__PURE__ */ React25.createElement(
1150
+ "div",
1151
+ {
1152
+ className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
1153
+ style: { background: color }
1154
+ }
1155
+ ) : /* @__PURE__ */ React25.createElement(PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React25.createElement("div", { className: "sb-truncate sb-flex-1" }, color ? color : "Kies een kleur"))
1156
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-64 sb-p-4 sb-flex sb-flex-wrap sb-gap-1" }, colors.map((s) => /* @__PURE__ */ React25.createElement(
1157
+ "div",
1158
+ {
1159
+ key: s,
1160
+ style: { background: s },
1161
+ className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
1162
+ onClick: () => onColorChange(s)
1163
+ }
1164
+ ))));
1165
+ };
1166
+ var MediaInput = (props) => {
1167
+ const { onFilesChange, limit = 32, multiple = false, onError } = props;
1168
+ const id = React25.useId();
1169
+ const [queue, setQueue] = React25.useState([]);
1170
+ const [sources, setSources] = React25.useState(props.files ?? []);
1171
+ const maxConcurrentUploads = 3;
1172
+ const uploadingCountRef = React25.useRef(0);
1173
+ const handleFilesAdd = async (e) => {
1174
+ const files = e.target.files;
1175
+ if (!files || files.length === 0) {
1176
+ return;
1177
+ }
1178
+ if (files.length + sources.length > (multiple ? limit : 1)) {
1179
+ onError?.(
1180
+ new MediaInputError(
1181
+ `Maximaal ${limit} bestanden.`,
1182
+ `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
1183
+ )
1184
+ );
1185
+ return;
1186
+ }
1187
+ const queue2 = Array.from(files);
1188
+ setQueue(queue2);
1189
+ for (const file of queue2) {
1190
+ try {
1191
+ while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
1192
+ await new Promise((resolve) => setTimeout(resolve, 300));
1193
+ }
1194
+ uploadingCountRef.current++;
1195
+ const formData = new FormData();
1196
+ formData.append("file", file);
1197
+ const res = await fetch("/api/simple-builder/file/upload", {
1198
+ method: "POST",
1199
+ body: formData
1200
+ });
1201
+ if (res === void 0 || !res.ok) {
1202
+ onError?.(
1203
+ new MediaInputError(
1204
+ "Bestand uploaden misulukt",
1205
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1206
+ )
1207
+ );
1208
+ continue;
1209
+ }
1210
+ const { data: url } = await res.json();
1211
+ if (!url) {
1212
+ onError?.(
1213
+ new MediaInputError(
1214
+ "Bestand uploaden misulukt",
1215
+ `De URL van bestand ${file.name} kon niet worden opgehaald.`
1216
+ )
1217
+ );
1218
+ continue;
1219
+ }
1220
+ setSources((prev) => [...prev, url]);
1221
+ onFilesChange?.([...sources, url]);
1222
+ } catch (e2) {
1223
+ onError?.(
1224
+ new MediaInputError(
1225
+ "Bestand uploaden misulukt",
1226
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1227
+ )
1228
+ );
1229
+ } finally {
1230
+ setQueue((prev) => prev.filter((f) => f !== file));
1231
+ uploadingCountRef.current--;
1232
+ }
1233
+ }
1234
+ };
1235
+ const handleSourceDelete = async (src) => {
1236
+ setSources((prev) => prev.filter((s) => s !== src));
1237
+ onFilesChange?.(sources.filter((s) => s !== src));
1238
+ await fetch("/api/uploadthing/delete", {
1239
+ method: "POST",
1240
+ body: JSON.stringify({ src })
1241
+ });
1242
+ };
1243
+ return /* @__PURE__ */ React25.createElement("div", { className: cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React25.createElement(MediaInputItem, { key: src, className: cn("group", props.itemClassName) }, /* @__PURE__ */ React25.createElement(
1244
+ Image,
1245
+ {
1246
+ src,
1247
+ alt: "",
1248
+ fill: true,
1249
+ className: "sb-absolute sb-inset-0 sb-object-cover sb-pointer-events-none"
1250
+ }
1251
+ ), /* @__PURE__ */ React25.createElement("div", { className: "sb-absolute sb-right-1 sb-top-1 sb-z-30 sb-flex sb-items-center sb-justify-end sb-gap-3 sb-opacity-0 sb-transition-opacity group-hover:sb-opacity-100" }, /* @__PURE__ */ React25.createElement(
1252
+ "button",
1253
+ {
1254
+ className: "sb-flex sb-h-8 sb-w-8 sb-items-center sb-justify-center sb-rounded-full sb-border sb-bg-secondary sb-text-secondary-foreground sb-opacity-90 sb-shadow sb-transition-opacity hover:sb-opacity-100",
1255
+ onClick: () => handleSourceDelete(src)
1256
+ },
1257
+ /* @__PURE__ */ React25.createElement(Trash2Icon, { className: "sb-h-4 sb-w-4" })
1258
+ )))), queue.map((_, i) => /* @__PURE__ */ React25.createElement(
1259
+ MediaInputItem,
1260
+ {
1261
+ key: i,
1262
+ className: cn(
1263
+ "sb-flex sb-h-28 sb-w-28 sb-items-center sb-justify-center",
1264
+ props.itemClassName
1265
+ )
1266
+ },
1267
+ /* @__PURE__ */ React25.createElement(Loader2Icon, { className: "sb-h-6 sb-w-6 sb-animate-spin" })
1268
+ )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React25.createElement(
1269
+ "label",
1270
+ {
1271
+ htmlFor: id,
1272
+ className: cn(
1273
+ "sb-flex sb-h-28 sb-w-28 sb-cursor-pointer sb-items-center sb-justify-center sb-rounded-lg sb-border",
1274
+ props.itemClassName
1275
+ )
1276
+ },
1277
+ /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-h-6 sb-w-6" }),
1278
+ /* @__PURE__ */ React25.createElement(
1279
+ "input",
1280
+ {
1281
+ id,
1282
+ type: "file",
1283
+ onChange: handleFilesAdd,
1284
+ multiple,
1285
+ accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
1286
+ className: "sb-hidden"
1287
+ }
1288
+ )
1289
+ ) : null);
1290
+ };
1291
+ var MediaInputItem = (props) => {
1292
+ return /* @__PURE__ */ React25.createElement(
1293
+ "div",
1294
+ {
1295
+ className: cn(
1296
+ "sb-relative sb-h-28 sb-w-28 sb-overflow-hidden sb-rounded-lg sb-border",
1297
+ props.className
1298
+ )
1299
+ },
1300
+ props.children
1301
+ );
1302
+ };
1303
+ var MediaInputError = class extends Error {
1304
+ title;
1305
+ description;
1306
+ constructor(message, description) {
1307
+ super(message);
1308
+ this.title = message;
1309
+ this.description = description;
1310
+ }
1311
+ };
1312
+ var Select = SelectPrimitive.Root;
1313
+ var SelectValue = SelectPrimitive.Value;
1314
+ var SelectTrigger = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1315
+ SelectPrimitive.Trigger,
1316
+ {
1317
+ ref,
1318
+ className: cn(
1319
+ "sb-flex sb-h-10 sb-w-full sb-items-center sb-justify-between sb-rounded-md sb-border sb-border-input sb-bg-background sb-px-3 sb-py-2 sb-text-sm sb-ring-offset-background placeholder:sb-text-muted-foreground focus:sb-outline-none focus:sb-ring-2 focus:sb-ring-ring focus:sb-ring-offset-2 disabled:sb-cursor-not-allowed disabled:sb-opacity-50 [&>span]:sb-line-clamp-1",
1320
+ className
1321
+ ),
1322
+ ...props
1323
+ },
1324
+ children,
1325
+ /* @__PURE__ */ React25.createElement(SelectPrimitive.Icon, { asChild: true }, /* @__PURE__ */ React25.createElement(ChevronDown, { className: "sb-h-4 sb-w-4 sb-opacity-50" }))
1326
+ ));
1327
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
1328
+ var SelectScrollUpButton = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1329
+ SelectPrimitive.ScrollUpButton,
1330
+ {
1331
+ ref,
1332
+ className: cn(
1333
+ "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
1334
+ className
1335
+ ),
1336
+ ...props
1337
+ },
1338
+ /* @__PURE__ */ React25.createElement(ChevronUp, { className: "sb-h-4 sb-w-4" })
1339
+ ));
1340
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
1341
+ var SelectScrollDownButton = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1342
+ SelectPrimitive.ScrollDownButton,
1343
+ {
1344
+ ref,
1345
+ className: cn(
1346
+ "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
1347
+ className
1348
+ ),
1349
+ ...props
1350
+ },
1351
+ /* @__PURE__ */ React25.createElement(ChevronDown, { className: "sb-h-4 sb-w-4" })
1352
+ ));
1353
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
1354
+ var SelectContent = React25.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ React25.createElement(SelectPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
1355
+ SelectPrimitive.Content,
1356
+ {
1357
+ ref,
1358
+ className: cn(
1359
+ "sb-relative sb-z-50 sb-max-h-96 sb-min-w-[8rem] sb-overflow-hidden sb-rounded-md sb-border sb-bg-popover sb-text-popover-foreground sb-shadow-md data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2",
1360
+ position === "popper" && "data-[side=bottom]:sb-translate-y-1 data-[side=left]:sb--translate-x-1 data-[side=right]:sb-translate-x-1 data-[side=top]:sb--translate-y-1",
1361
+ className
1362
+ ),
1363
+ position,
1364
+ ...props
1365
+ },
1366
+ /* @__PURE__ */ React25.createElement(SelectScrollUpButton, null),
1367
+ /* @__PURE__ */ React25.createElement(
1368
+ SelectPrimitive.Viewport,
1369
+ {
1370
+ className: cn(
1371
+ "sb-p-1",
1372
+ position === "popper" && "sb-h-[var(--radix-select-trigger-height)] sb-w-full sb-min-w-[var(--radix-select-trigger-width)]"
1373
+ )
1374
+ },
1375
+ children
1376
+ ),
1377
+ /* @__PURE__ */ React25.createElement(SelectScrollDownButton, null)
1378
+ )));
1379
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
1380
+ var SelectLabel = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1381
+ SelectPrimitive.Label,
1382
+ {
1383
+ ref,
1384
+ className: cn(
1385
+ "sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-font-semibold",
1386
+ className
1387
+ ),
1388
+ ...props
1389
+ }
1390
+ ));
1391
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
1392
+ var SelectItem = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1393
+ SelectPrimitive.Item,
1394
+ {
1395
+ ref,
1396
+ className: cn(
1397
+ "sb-relative sb-flex sb-w-full sb-cursor-default sb-select-none sb-items-center sb-rounded-sm sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-outline-none focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50",
1398
+ className
1399
+ ),
1400
+ ...props
1401
+ },
1402
+ /* @__PURE__ */ React25.createElement("span", { className: "sb-absolute sb-left-2 sb-flex sb-h-3.5 sb-w-3.5 sb-items-center sb-justify-center" }, /* @__PURE__ */ React25.createElement(SelectPrimitive.ItemIndicator, null, /* @__PURE__ */ React25.createElement(Check, { className: "sb-h-4 sb-w-4" }))),
1403
+ /* @__PURE__ */ React25.createElement(SelectPrimitive.ItemText, null, children)
1404
+ ));
1405
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
1406
+ var SelectSeparator = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1407
+ SelectPrimitive.Separator,
1408
+ {
1409
+ ref,
1410
+ className: cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
1411
+ ...props
1412
+ }
1413
+ ));
1414
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
1415
+ var Textarea = React25.forwardRef(
1416
+ ({ className, ...props }, ref) => {
1417
+ return /* @__PURE__ */ React25.createElement(
1418
+ "textarea",
1419
+ {
1420
+ className: cn(
1421
+ "sb-flex sb-min-h-[60px] sb-font-roboto sb-w-full sb-rounded-md sb-border sb-border-input sb-bg-transparent sb-px-3 sb-py-2 sb-text-sm sb-shadow-sm placeholder:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:sb-ring-ring disabled:sb-cursor-not-allowed disabled:sb-opacity-50",
1422
+ className
1423
+ ),
1424
+ ref,
1425
+ ...props
1426
+ }
1427
+ );
1428
+ }
1429
+ );
1430
+ Textarea.displayName = "Textarea";
1431
+
1432
+ // src/components/container-item-form.tsx
1433
+ var ContainerItemForm = (props) => {
1434
+ const { item } = props;
1435
+ const { patchItem } = useBuilder();
1436
+ const component = builder.getComponent(item.component);
1437
+ if (!component) {
1438
+ throw new Error(
1439
+ `[simple-builder]: Component with id ${item.component} not found in container item form component`
1440
+ );
1441
+ }
1442
+ const form = useForm({
1443
+ defaultValues: (component.inputs || []).reduce(
1444
+ (acc, input) => ({
1445
+ ...acc,
1446
+ [input.name]: item?.props?.[input.name] ?? input.defaultValue
1447
+ }),
1448
+ {}
1449
+ )
1450
+ });
1451
+ const onSubmit = React25.useCallback(
1452
+ (values) => {
1453
+ patchItem(item.id, {
1454
+ props: values
1455
+ });
1456
+ },
1457
+ [patchItem, item.id]
1458
+ );
1459
+ return /* @__PURE__ */ React25.createElement(Form, { ...form }, /* @__PURE__ */ React25.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4 sb-p-4" }, (component.inputs || []).map((input) => /* @__PURE__ */ React25.createElement(
1460
+ RenderFormField,
1461
+ {
1462
+ key: input.name,
1463
+ type: input.type,
1464
+ input,
1465
+ form
1466
+ }
1467
+ )), /* @__PURE__ */ React25.createElement(Button, { type: "submit", className: "w-full" }, "Opslaan"))));
1468
+ };
1469
+ var RenderFormField = (props) => {
1470
+ const { type, input, form } = props;
1471
+ const fieldArray = useFieldArray({
1472
+ control: form.control,
1473
+ name: input.name
1474
+ });
1475
+ if (input.multiple) {
1476
+ return /* @__PURE__ */ React25.createElement("fieldset", { className: "sb-space-y-2" }, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4" }, fieldArray.fields.map(
1477
+ (field, i) => type !== "grouped" ? /* @__PURE__ */ React25.createElement(
1478
+ FormField,
1479
+ {
1480
+ key: field.id,
1481
+ control: form.control,
1482
+ name: `${input.name}.${i}`,
1483
+ render: ({ field: field2 }) => /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-gap-3" }, /* @__PURE__ */ React25.createElement(RenderInput, { field: field2, type: input.type }), /* @__PURE__ */ React25.createElement("button", { type: "button", onClick: () => fieldArray.remove(i) }, /* @__PURE__ */ React25.createElement(XIcon, { className: "sb-h-4 sb-w-4" })))
1484
+ }
1485
+ ) : /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-relative" }, /* @__PURE__ */ React25.createElement(
1486
+ RenderFormField,
1487
+ {
1488
+ key: field.id,
1489
+ form,
1490
+ type,
1491
+ input: {
1492
+ ...input,
1493
+ name: `${input.name}.${i}`,
1494
+ multiple: false,
1495
+ friendlyName: ""
1496
+ }
1497
+ }
1498
+ ), /* @__PURE__ */ React25.createElement(
1499
+ "button",
1500
+ {
1501
+ type: "button",
1502
+ onClick: () => fieldArray.remove(i),
1503
+ className: "sb-absolute sb-top-2 sb-right-2 sb-text-foreground/70 hover:sb-text-foreground"
1504
+ },
1505
+ /* @__PURE__ */ React25.createElement(XIcon, { className: "sb-h-4 sb-w-4" })
1506
+ ))
1507
+ ), /* @__PURE__ */ React25.createElement(
1508
+ Button,
1509
+ {
1510
+ type: "button",
1511
+ variant: "outline",
1512
+ size: "sm",
1513
+ className: cn(
1514
+ "sb-w-[89%] sb-border-2 sb-border-dashed sb-text-muted-foreground",
1515
+ type === "grouped" && "sb-w-full"
1516
+ ),
1517
+ onClick: () => fieldArray.append(void 0)
1518
+ },
1519
+ /* @__PURE__ */ React25.createElement(PlusCircleIcon, { className: "sb-h-4 sb-w-4" })
1520
+ )));
1521
+ }
1522
+ switch (type) {
1523
+ case "string":
1524
+ case "number":
1525
+ case "longText":
1526
+ case "color":
1527
+ case "date":
1528
+ case "file":
1529
+ return /* @__PURE__ */ React25.createElement(
1530
+ FormField,
1531
+ {
1532
+ key: input.name,
1533
+ control: form.control,
1534
+ name: input.name,
1535
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(RenderInput, { type, field, options: input?.enum })), input.helperText && /* @__PURE__ */ React25.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25.createElement(FormMessage, null))
1536
+ }
1537
+ );
1538
+ case "richText":
1539
+ return /* @__PURE__ */ React25.createElement(Dialog, null, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-2" }, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(Button, { variant: "outline", className: "sb-w-full", type: "button" }, input.friendlyName || input.name, " bewerken"))), /* @__PURE__ */ React25.createElement(DialogContent, { className: "sb-max-w-3xl sb-p-0" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-h-full sb-max-h-svh sb-w-full sb-flex-col sm:sb-max-h-[90svh]" }, /* @__PURE__ */ React25.createElement(DialogHeader, { className: "sb-flex-none sb-border-b sb-p-6" }, /* @__PURE__ */ React25.createElement(DialogTitle, null, input.friendlyName || input.name, " editor")), /* @__PURE__ */ React25.createElement("div", { className: "sb-flex-1 sb-overflow-y-auto" }, /* @__PURE__ */ React25.createElement(
1540
+ FormField,
1541
+ {
1542
+ key: input.name,
1543
+ control: form.control,
1544
+ name: input.name,
1545
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React25.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25.createElement(FormMessage, null))
1546
+ }
1547
+ )))));
1548
+ case "boolean":
1549
+ return /* @__PURE__ */ React25.createElement(
1550
+ FormField,
1551
+ {
1552
+ key: input.name,
1553
+ control: form.control,
1554
+ name: input.name,
1555
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React25.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25.createElement(FormMessage, null))
1556
+ }
1557
+ );
1558
+ case "grouped":
1559
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-2 sb-w-full" }, input.friendlyName !== "" && /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-2 sb-p-3 sb-w-full sb-border sb-rounded-lg" }, input.inputs.map((sub) => /* @__PURE__ */ React25.createElement(
1560
+ RenderFormField,
1561
+ {
1562
+ key: `${input.name}.${sub.name}`,
1563
+ type: sub.type,
1564
+ input: {
1565
+ ...sub,
1566
+ name: `${input.name}.${sub.name}`
1567
+ },
1568
+ form
1569
+ }
1570
+ ))));
1571
+ default:
1572
+ throw new Error(
1573
+ `[simple-builder]: Input type "${props.type}" not supported in render form field.`
1574
+ );
1575
+ }
1576
+ };
1577
+ var RenderInput = (props) => {
1578
+ const { type, options, field } = props;
1579
+ switch (type) {
1580
+ case "string":
1581
+ if (!options)
1582
+ return /* @__PURE__ */ React25.createElement(Input, { ...field });
1583
+ return /* @__PURE__ */ React25.createElement(Select, { onValueChange: field.onChange, defaultValue: field.value }, /* @__PURE__ */ React25.createElement(SelectTrigger, null, /* @__PURE__ */ React25.createElement(SelectValue, null)), /* @__PURE__ */ React25.createElement(SelectContent, null, options.map((option) => /* @__PURE__ */ React25.createElement(SelectItem, { key: option, value: option }, option))));
1584
+ case "longText":
1585
+ return /* @__PURE__ */ React25.createElement(Textarea, { ...field });
1586
+ case "richText":
1587
+ return /* @__PURE__ */ React25.createElement(RichTextEditor, { ...field });
1588
+ case "number":
1589
+ return /* @__PURE__ */ React25.createElement(Input, { type: "number", ...field });
1590
+ case "color":
1591
+ return /* @__PURE__ */ React25.createElement(ColorPicker, { color: field.value, onColorChange: field.onChange });
1592
+ case "date":
1593
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1594
+ Button,
1595
+ {
1596
+ variant: "outline",
1597
+ size: "sm",
1598
+ className: cn(
1599
+ "sb-w-full sb-flex sb-justify-start sb-text-left sb-font-normal",
1600
+ !field.value && "sb-text-muted-foreground"
1601
+ )
1602
+ },
1603
+ /* @__PURE__ */ React25.createElement(CalendarIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
1604
+ field.value && !Array.isArray(field.value) ? format(field.value, "PPP") : /* @__PURE__ */ React25.createElement("span", null, "Pick a date")
1605
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-auto sb-p-0", align: "start" }, /* @__PURE__ */ React25.createElement(
1606
+ Calendar,
1607
+ {
1608
+ mode: "single",
1609
+ selected: field.value,
1610
+ onSelect: field.onChange,
1611
+ initialFocus: true
1612
+ }
1613
+ )));
1614
+ case "boolean":
1615
+ return /* @__PURE__ */ React25.createElement(Switch, { checked: field.value, onCheckedChange: field.onChange });
1616
+ case "file":
1617
+ return /* @__PURE__ */ React25.createElement(
1618
+ MediaInput,
1619
+ {
1620
+ className: "sb-grid sb-grid-cols-2 sb-gap-1",
1621
+ itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
1622
+ multiple: false,
1623
+ files: field.value ? [field.value] : [],
1624
+ onFilesChange: (files) => field.onChange(files[0]),
1625
+ onError: (e) => console.error(
1626
+ "[media-input]: Title: " + e?.title,
1627
+ "media-input: Error: " + e?.description
1628
+ )
1629
+ }
1630
+ );
1631
+ default:
1632
+ throw new Error(
1633
+ `[simple-builder]: Input type "${props.type}" not supported in render input.`
1634
+ );
1635
+ }
1636
+ };
1637
+ var Tabs = TabsPrimitive.Root;
1638
+ var tabsListVariants = tv({
1639
+ variants: {
1640
+ variant: {
1641
+ contained: "sb-inline-flex sb-h-10 sb-items-center sb-justify-center sb-rounded-md sb-bg-muted sb-p-1 sb-text-muted-foreground",
1642
+ text: "sb-flex sb-items-center sb-border-b sb-px-4 sb-space-x-6"
1643
+ }
1644
+ },
1645
+ defaultVariants: {
1646
+ variant: "contained"
1647
+ }
1648
+ });
1649
+ var TabsList = React25.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1650
+ TabsPrimitive.List,
1651
+ {
1652
+ ref,
1653
+ className: tabsListVariants({ variant, className }),
1654
+ ...props
1655
+ }
1656
+ ));
1657
+ TabsList.displayName = TabsPrimitive.List.displayName;
1658
+ var tabsTriggerVariants = tv({
1659
+ variants: {
1660
+ variant: {
1661
+ contained: "sb-inline-flex sb-items-center sb-justify-center sb-whitespace-nowrap sb-rounded-sm sb-px-3 sb-py-1.5 sb-text-sm sb-font-medium sb-ring-offset-background sb-transition-all focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2 disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=active]:sb-bg-background data-[state=active]:sb-text-foreground data-[state=active]:sb-shadow-sm",
1662
+ text: "sb-inline-flex sb-font-roboto sb-items-center sb-justify-center sb-whitespace-nowrap sb-py-3 sb-text-sm sb-font-medium sb-transition-all focus-visible:sb-outline-none disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=active]:sb-border-black sb-border-b-2 sb-border-transparent data-[state=active]:sb-text-foreground sb-text-muted-foreground"
1663
+ }
1664
+ },
1665
+ defaultVariants: {
1666
+ variant: "contained"
1667
+ }
1668
+ });
1669
+ var TabsTrigger = React25.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1670
+ TabsPrimitive.Trigger,
1671
+ {
1672
+ ref,
1673
+ className: tabsTriggerVariants({ variant, className }),
1674
+ ...props
1675
+ }
1676
+ ));
1677
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
1678
+ var TabsContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1679
+ TabsPrimitive.Content,
1680
+ {
1681
+ ref,
1682
+ className: cn(
1683
+ "sb-ring-offset-background sb-font-roboto focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2",
1684
+ className
1685
+ ),
1686
+ ...props
1687
+ }
1688
+ ));
1689
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
1690
+
1691
+ // src/components/ui/background-picker.tsx
1692
+ var BackgroundPicker = (props) => {
1693
+ const { background, onBackgroundChange, className } = props;
1694
+ const solids = props.solids ?? [
1695
+ "#000000",
1696
+ "#ffffff",
1697
+ "#0f172a",
1698
+ "#F1F5F9",
1699
+ "#64748B",
1700
+ "#E6007E",
1701
+ "#F8FAFC",
1702
+ "#009DD1",
1703
+ "#FF0000"
1704
+ ];
1705
+ const gradients = props.gradients ?? [
1706
+ "linear-gradient(to top left,#accbee,#e7f0fd)",
1707
+ "linear-gradient(to top left,#d5d4d0,#d5d4d0,#eeeeec)"
1708
+ ];
1709
+ const images = props.images ?? [
1710
+ "url(https://images.unsplash.com/photo-1688822863426-8c5f9b257090?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2532&q=90)",
1711
+ "url(https://images.unsplash.com/photo-1691225850735-6e4e51834cad?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2532&q=90)"
1712
+ ];
1713
+ const defaultTab = React25.useMemo(() => {
1714
+ if (background.includes("url"))
1715
+ return "image";
1716
+ if (background.includes("gradient"))
1717
+ return "gradient";
1718
+ return "solid";
1719
+ }, [background]);
1720
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1721
+ Button,
1722
+ {
1723
+ variant: "outline",
1724
+ size: "sm",
1725
+ className: cn(
1726
+ "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
1727
+ !background && "sb-text-muted-foreground",
1728
+ className
1729
+ )
1730
+ },
1731
+ /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, background ? /* @__PURE__ */ React25.createElement(
1732
+ "div",
1733
+ {
1734
+ className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
1735
+ style: { background }
1736
+ }
1737
+ ) : /* @__PURE__ */ React25.createElement(PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React25.createElement("div", { className: "sb-truncate sb-flex-1" }, background ? background : "Kies een achtergrond"))
1738
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-64 sb-p-0" }, /* @__PURE__ */ React25.createElement(Tabs, { defaultValue: defaultTab }, /* @__PURE__ */ React25.createElement(TabsList, { className: "sb-w-full" }, /* @__PURE__ */ React25.createElement(TabsTrigger, { className: "sb-flex-1", value: "solid" }, "Solid"), /* @__PURE__ */ React25.createElement(TabsTrigger, { className: "sb-flex-1", value: "gradient" }, "Gradient"), /* @__PURE__ */ React25.createElement(TabsTrigger, { className: "sb-flex-1", value: "image" }, "Image")), /* @__PURE__ */ React25.createElement(
1739
+ TabsContent,
1740
+ {
1741
+ value: "solid",
1742
+ className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
1743
+ },
1744
+ solids.map((s) => /* @__PURE__ */ React25.createElement(
1745
+ "div",
1746
+ {
1747
+ key: s,
1748
+ style: { background: s },
1749
+ className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
1750
+ onClick: () => onBackgroundChange(s)
1751
+ }
1752
+ ))
1753
+ ), /* @__PURE__ */ React25.createElement(
1754
+ TabsContent,
1755
+ {
1756
+ value: "gradient",
1757
+ className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
1758
+ },
1759
+ gradients.map((s) => /* @__PURE__ */ React25.createElement(
1760
+ "div",
1761
+ {
1762
+ key: s,
1763
+ style: { background: s },
1764
+ className: "rounded-md h-6 w-6 cursor-pointer active:scale-105 border",
1765
+ onClick: () => onBackgroundChange(s)
1766
+ }
1767
+ ))
1768
+ ), /* @__PURE__ */ React25.createElement(TabsContent, { value: "image" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-p-4 sb-border-b" }, /* @__PURE__ */ React25.createElement(
1769
+ MediaInput,
1770
+ {
1771
+ className: "sb-grid sb-grid-cols-2 sb-gap-1",
1772
+ itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
1773
+ multiple: false,
1774
+ onFilesChange: (files) => {
1775
+ if (!files.length)
1776
+ return;
1777
+ onBackgroundChange(`url(${files[0]})`);
1778
+ },
1779
+ onError: (e) => console.error(
1780
+ "[media-input]: Title: " + e?.title,
1781
+ "media-input: Error: " + e?.description
1782
+ )
1783
+ }
1784
+ )), /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-1 sb-p-4" }, images.map((s) => /* @__PURE__ */ React25.createElement(
1785
+ "div",
1786
+ {
1787
+ key: s,
1788
+ style: { backgroundImage: s },
1789
+ className: "sb-rounded-md sb-bg-cover sb-bg-center sb-aspect-video sb-w-full sb-cursor-pointer sb-border active:sb-scale-105",
1790
+ onClick: () => onBackgroundChange(s)
1791
+ }
1792
+ )))))));
1793
+ };
1794
+ var SpacingInput = (props) => {
1795
+ const [value, setValue] = React25.useState(parse(props.value || "0px"));
1796
+ const [indipendent, setIndipendent] = React25.useState(
1797
+ isIndipendent(parse(props.value || "0px"))
1798
+ );
1799
+ React25.useEffect(() => {
1800
+ if (!props.onChange)
1801
+ return;
1802
+ props.onChange(stringify(value));
1803
+ }, [value, props.onChange]);
1804
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-[1fr,auto] sb-gap-3" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-items-center sb-gap-3" }, !indipendent ? /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
1805
+ AdvancedInput,
1806
+ {
1807
+ value: value.left,
1808
+ pattern: "\\d+",
1809
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2, right: +value2 })),
1810
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4" }),
1811
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1812
+ }
1813
+ ), /* @__PURE__ */ React25.createElement(
1814
+ AdvancedInput,
1815
+ {
1816
+ value: value.top,
1817
+ pattern: "\\d+",
1818
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2, bottom: +value2 })),
1819
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1820
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1821
+ }
1822
+ )) : /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
1823
+ AdvancedInput,
1824
+ {
1825
+ value: value.left,
1826
+ pattern: "\\d+",
1827
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2 })),
1828
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4" }),
1829
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1830
+ }
1831
+ ), /* @__PURE__ */ React25.createElement(
1832
+ AdvancedInput,
1833
+ {
1834
+ value: value.top,
1835
+ pattern: "\\d+",
1836
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2 })),
1837
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1838
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1839
+ }
1840
+ ), /* @__PURE__ */ React25.createElement(
1841
+ AdvancedInput,
1842
+ {
1843
+ value: value.right,
1844
+ pattern: "\\d+",
1845
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, right: +value2 })),
1846
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-180" }),
1847
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1848
+ }
1849
+ ), /* @__PURE__ */ React25.createElement(
1850
+ AdvancedInput,
1851
+ {
1852
+ value: value.bottom,
1853
+ pattern: "\\d+",
1854
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, bottom: +value2 })),
1855
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb--rotate-90" }),
1856
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1857
+ }
1858
+ ))), /* @__PURE__ */ React25.createElement("div", { className: "sb-shrink-0" }, /* @__PURE__ */ React25.createElement(
1859
+ Toggle,
1860
+ {
1861
+ className: "sb-shrink-0 sb-flex sb-w-8 sb-h-8 sb-p-0",
1862
+ variant: "outline",
1863
+ size: "sm",
1864
+ pressed: indipendent,
1865
+ onPressedChange: setIndipendent
1866
+ },
1867
+ /* @__PURE__ */ React25.createElement(ScanIcon, { className: "sb-h-4 sb-w-4" })
1868
+ )));
1869
+ };
1870
+ var isIndipendent = (value) => {
1871
+ const { top, right, bottom, left } = value;
1872
+ return top !== bottom || right !== left;
1873
+ };
1874
+ var parse = (value) => {
1875
+ const matches = value.match(/(\d+)/gm);
1876
+ const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
1877
+ switch (matches?.length) {
1878
+ case 1:
1879
+ return { top, right: top, bottom: top, left: top };
1880
+ case 2:
1881
+ return { top, bottom: top, left: right, right };
1882
+ case 3:
1883
+ return { top, right, left: right, bottom };
1884
+ default:
1885
+ return { top, right, bottom, left };
1886
+ }
1887
+ };
1888
+ var stringify = (value) => {
1889
+ const { top, right, bottom, left } = value;
1890
+ if (top === right && top === bottom && top === left) {
1891
+ return `${top}px`;
1892
+ }
1893
+ if (top === bottom && right === left) {
1894
+ return `${top}px ${right}px`;
1895
+ }
1896
+ if (right === left) {
1897
+ return `${top}px ${right}px ${bottom}px`;
1898
+ }
1899
+ return `${top}px ${right}px ${bottom}px ${left}px`;
1900
+ };
1901
+
1902
+ // src/components/item-design-form.tsx
1903
+ var designSchema = z.object({
1904
+ container: z.coerce.boolean(),
1905
+ hidden: z.enum(["always", "mobile", "desktop", "never"]),
1906
+ desktop: z.object({
1907
+ background: z.string(),
1908
+ color: z.string(),
1909
+ padding: z.string(),
1910
+ margin: z.string()
1911
+ }),
1912
+ mobile: z.object({
1913
+ background: z.string(),
1914
+ color: z.string(),
1915
+ padding: z.string(),
1916
+ margin: z.string()
1917
+ })
1918
+ });
1919
+ var ItemDesignForm = (props) => {
1920
+ const { item } = props;
1921
+ const component = builder.getComponent(item.component);
1922
+ if (!component) {
1923
+ throw new Error(
1924
+ `[simple-builder]: Component "${item.component}" not found`
1925
+ );
1926
+ }
1927
+ const getDefaultDeviceValue = (params) => {
1928
+ const { device: device2 = "desktop", key, fallback = "" } = params;
1929
+ if (item.styles?.[device2]?.[key] !== void 0) {
1930
+ return item.styles[device2][key];
1931
+ }
1932
+ if (component.defaultStyles?.[device2]?.[key] !== void 0) {
1933
+ return component.defaultStyles[device2][key];
1934
+ }
1935
+ if (device2 === "mobile") {
1936
+ const desktopValue = getDefaultDeviceValue({
1937
+ ...params,
1938
+ device: "desktop"
1939
+ });
1940
+ if (desktopValue !== void 0) {
1941
+ return desktopValue;
1942
+ }
1943
+ }
1944
+ return fallback;
1945
+ };
1946
+ const getDefaultDeviceValues = (device2) => {
1947
+ return {
1948
+ background: getDefaultDeviceValue({ device: device2, key: "background" }),
1949
+ color: getDefaultDeviceValue({ device: device2, key: "color" }),
1950
+ padding: getDefaultDeviceValue({ device: device2, key: "padding" }),
1951
+ margin: getDefaultDeviceValue({ device: device2, key: "margin" })
1952
+ };
1953
+ };
1954
+ const form = useForm({
1955
+ resolver: zodResolver(designSchema),
1956
+ values: {
1957
+ container: item.styles?.container ?? true,
1958
+ hidden: item.styles?.hidden ?? "never",
1959
+ desktop: getDefaultDeviceValues("desktop"),
1960
+ mobile: getDefaultDeviceValues("mobile")
1961
+ }
1962
+ });
1963
+ const { patchItem } = useBuilder();
1964
+ const onSubmit = React25.useCallback(
1965
+ (values) => {
1966
+ const { container, hidden, desktop, mobile } = values;
1967
+ const dirtyFields = form.formState.dirtyFields;
1968
+ const desktopPatch = Object.entries(desktop).reduce(
1969
+ (acc, [key, value]) => ({
1970
+ ...acc,
1971
+ ...value && { [key]: value }
1972
+ }),
1973
+ { ...item.styles?.desktop }
1974
+ );
1975
+ const mobilePatch = Object.entries(mobile).reduce(
1976
+ (acc, [key, value]) => {
1977
+ const desktopValue = desktop[key];
1978
+ const isDirty = dirtyFields.desktop?.[key];
1979
+ if (value === desktopValue || isDirty) {
1980
+ return acc;
1981
+ }
1982
+ if (["padding", "margin"].includes(key)) {
1983
+ if (value === "0px" && desktopValue === "0px") {
1984
+ return acc;
1985
+ }
1986
+ }
1987
+ return {
1988
+ ...acc,
1989
+ ...value && { [key]: value }
1990
+ };
1991
+ },
1992
+ { ...item.styles?.mobile }
1993
+ );
1994
+ patchItem(item.id, {
1995
+ styles: {
1996
+ ...container === false && { container },
1997
+ ...hidden !== "never" && { hidden },
1998
+ ...Object.keys(desktopPatch).length && { desktop: desktopPatch },
1999
+ ...Object.keys(mobilePatch).length && { mobile: mobilePatch }
2000
+ }
2001
+ });
2002
+ },
2003
+ [patchItem, item.id, form.formState.dirtyFields]
2004
+ );
2005
+ const [device, setDevice] = React25.useState("desktop");
2006
+ return /* @__PURE__ */ React25.createElement(Form, { ...form }, /* @__PURE__ */ React25.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4 sb-p-4" }, /* @__PURE__ */ React25.createElement(
2007
+ Tabs,
2008
+ {
2009
+ defaultValue: device,
2010
+ onValueChange: (device2) => setDevice(device2)
2011
+ },
2012
+ /* @__PURE__ */ React25.createElement(TabsList, { className: "sb-h-9 sb-grid sb-w-full sb-grid-cols-2" }, /* @__PURE__ */ React25.createElement(TabsTrigger, { value: "desktop", className: "sb-text-xs" }, /* @__PURE__ */ React25.createElement(MonitorIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React25.createElement("span", null, "Desktop")), /* @__PURE__ */ React25.createElement(TabsTrigger, { value: "mobile", className: "sb-text-xs" }, /* @__PURE__ */ React25.createElement(SmartphoneIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React25.createElement("span", null, "Mobiel")))
2013
+ ), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4" }, /* @__PURE__ */ React25.createElement(
2014
+ FormField,
2015
+ {
2016
+ control: form.control,
2017
+ key: `${device}.background`,
2018
+ name: `${device}.background`,
2019
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2020
+ BackgroundPicker,
2021
+ {
2022
+ background: field.value,
2023
+ onBackgroundChange: field.onChange
2024
+ }
2025
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2026
+ }
2027
+ ), /* @__PURE__ */ React25.createElement(
2028
+ FormField,
2029
+ {
2030
+ control: form.control,
2031
+ key: `${device}.color`,
2032
+ name: `${device}.color`,
2033
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2034
+ ColorPicker,
2035
+ {
2036
+ color: field.value,
2037
+ onColorChange: field.onChange
2038
+ }
2039
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2040
+ }
2041
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2042
+ FormField,
2043
+ {
2044
+ control: form.control,
2045
+ name: "hidden",
2046
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Verbergen"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(Select, { value: field.value, onValueChange: field.onChange }, /* @__PURE__ */ React25.createElement(SelectTrigger, null, /* @__PURE__ */ React25.createElement(SelectValue, null)), /* @__PURE__ */ React25.createElement(SelectContent, null, /* @__PURE__ */ React25.createElement(SelectItem, { value: "never" }, "Nooit"), /* @__PURE__ */ React25.createElement(SelectItem, { value: "desktop" }, "Op desktop"), /* @__PURE__ */ React25.createElement(SelectItem, { value: "mobile" }, "Op mobiel"), /* @__PURE__ */ React25.createElement(SelectItem, { value: "always" }, "Altijd")))), /* @__PURE__ */ React25.createElement(FormMessage, null))
2047
+ }
2048
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2049
+ FormField,
2050
+ {
2051
+ control: form.control,
2052
+ name: "container",
2053
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React25.createElement(FormLabel, null, "Volledige breedte"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2054
+ Switch,
2055
+ {
2056
+ checked: !field.value,
2057
+ onCheckedChange: (v) => field.onChange(!v)
2058
+ }
2059
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2060
+ }
2061
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2062
+ FormField,
2063
+ {
2064
+ control: form.control,
2065
+ key: `${device}.padding`,
2066
+ name: `${device}.padding`,
2067
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2068
+ SpacingInput,
2069
+ {
2070
+ value: field.value,
2071
+ onChange: field.onChange
2072
+ }
2073
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2074
+ }
2075
+ ), /* @__PURE__ */ React25.createElement(
2076
+ FormField,
2077
+ {
2078
+ control: form.control,
2079
+ key: `${device}.margin`,
2080
+ name: `${device}.margin`,
2081
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2082
+ SpacingInput,
2083
+ {
2084
+ value: field.value,
2085
+ onChange: field.onChange
2086
+ }
2087
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2088
+ }
2089
+ )), /* @__PURE__ */ React25.createElement(Button, { type: "submit", className: "w-full" }, "Opslaan"))));
2090
+ };
2091
+ var ScrollArea = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
2092
+ ScrollAreaPrimitive.Root,
2093
+ {
2094
+ ref,
2095
+ className: cn("sb-relative sb-overflow-hidden", className),
2096
+ ...props
2097
+ },
2098
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.Viewport, { className: "sb-h-full sb-max-h-[80vh] sb-w-full sb-rounded-[inherit]" }, children),
2099
+ /* @__PURE__ */ React25.createElement(ScrollBar, null),
2100
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.Corner, null)
2101
+ ));
2102
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
2103
+ var ScrollBar = React25.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React25.createElement(
2104
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
2105
+ {
2106
+ ref,
2107
+ orientation,
2108
+ className: cn(
2109
+ "sb-flex sb-touch-none sb-select-none sb-transition-colors",
2110
+ orientation === "vertical" && "sb-h-full sb-w-2.5 sb-border-l sb-border-l-transparent sb-p-[1px]",
2111
+ orientation === "horizontal" && "sb-h-2.5 sb-flex-col sb-border-t sb-border-t-transparent sb-p-[1px]",
2112
+ className
2113
+ ),
2114
+ ...props
2115
+ },
2116
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.ScrollAreaThumb, { className: "sb-relative sb-flex-1 sb-rounded-full sb-bg-border" })
2117
+ ));
2118
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
2119
+
2120
+ // src/components/container-item-toolbar.tsx
2121
+ var ContainerItemToolbar = (props) => {
2122
+ const { contentId, canBringUp = false, canBringDown = false } = props;
2123
+ const { bringUp, bringDown } = useBuilder();
2124
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-absolute sb-z-20 sb-top-1 sb-right-1 sb-rounded-md sb-shadow sb-flex sb-flex-col sb-gap-1 sb-p-1 sb-bg-card sb-text-card-foreground sb-item-toolbar sb-opacity-0 sb-transition-opacity" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-h-10 sb-p-1 sb-border sb-border-input sb-bg-background sb-rounded-md sb-text-sm sb-font-medium sb-flex sb-gap-1 sb-items-center sb-justify-start" }, /* @__PURE__ */ React25.createElement(EditButton, { id: contentId }), /* @__PURE__ */ React25.createElement(
2125
+ Button,
2126
+ {
2127
+ variant: "ghost",
2128
+ className: "sb-w-8 sb-h-8 sb-p-0",
2129
+ onClick: () => bringUp(contentId),
2130
+ disabled: !canBringUp
2131
+ },
2132
+ /* @__PURE__ */ React25.createElement(ArrowUp, { className: "sb-h-5 sb-w-5" })
2133
+ ), /* @__PURE__ */ React25.createElement(
2134
+ Button,
2135
+ {
2136
+ variant: "ghost",
2137
+ className: "sb-w-8 sb-h-8 sb-p-0",
2138
+ onClick: () => bringDown(contentId),
2139
+ disabled: !canBringDown
2140
+ },
2141
+ /* @__PURE__ */ React25.createElement(ArrowDown, { className: "sb-h-5 sb-w-5" })
2142
+ ), /* @__PURE__ */ React25.createElement(DeleteButton, { contentId })));
2143
+ };
2144
+ var EditButton = ({ id }) => {
2145
+ return /* @__PURE__ */ React25.createElement(Popover, { modal: true }, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(Button, { variant: "ghost", className: "sb-w-8 sb-h-8 sb-p-0" }, /* @__PURE__ */ React25.createElement(Edit2Icon, { className: "sb-h-5 sb-w-5" }))), /* @__PURE__ */ React25.createElement(
2146
+ PopoverContent,
2147
+ {
2148
+ side: "left",
2149
+ align: "start",
2150
+ sideOffset: 16,
2151
+ alignOffset: -8,
2152
+ className: "sb-p-0 sb-relative",
2153
+ collisionPadding: 16
2154
+ },
2155
+ /* @__PURE__ */ React25.createElement(EditPopoverInner, { id })
2156
+ ));
2157
+ };
2158
+ var EditPopoverInner = (props) => {
2159
+ const { id } = props;
2160
+ const { getItem } = useBuilder();
2161
+ const item = getItem(id);
2162
+ if (!item) {
2163
+ throw new Error(
2164
+ `[simple-builder]: Item with id ${id} not found in container item form component`
2165
+ );
2166
+ }
2167
+ return /* @__PURE__ */ React25.createElement(Tabs, null, /* @__PURE__ */ React25.createElement(TabsList, { variant: "text", defaultValue: "content" }, /* @__PURE__ */ React25.createElement(TabsTrigger, { variant: "text", value: "content" }, "Inhoud"), /* @__PURE__ */ React25.createElement(TabsTrigger, { variant: "text", value: "design" }, "Design")), /* @__PURE__ */ React25.createElement(TabsContent, { value: "content" }, /* @__PURE__ */ React25.createElement(ScrollArea, null, /* @__PURE__ */ React25.createElement(ContainerItemForm, { item }))), /* @__PURE__ */ React25.createElement(TabsContent, { value: "design" }, /* @__PURE__ */ React25.createElement(ItemDesignForm, { item })));
2168
+ };
2169
+ var DeleteButton = ({ contentId }) => {
2170
+ const { deleteContent } = useBuilder();
2171
+ return /* @__PURE__ */ React25.createElement(AlertDialog, null, /* @__PURE__ */ React25.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
2172
+ Button,
2173
+ {
2174
+ variant: "ghost",
2175
+ className: "sb-w-8 sb-h-8 sb-p-0 sb-text-destructive"
2176
+ },
2177
+ /* @__PURE__ */ React25.createElement(Trash2Icon, { className: "sb-h-5 sb-w-5" })
2178
+ )), /* @__PURE__ */ React25.createElement(AlertDialogContent, null, /* @__PURE__ */ React25.createElement(AlertDialogDescription, null, "Weet je zeker dat je dit blok wilt verwijderen?"), /* @__PURE__ */ React25.createElement(AlertDialogFooter, null, /* @__PURE__ */ React25.createElement(AlertDialogCancel, null, "Annuleren"), /* @__PURE__ */ React25.createElement(
2179
+ AlertDialogAction,
2180
+ {
2181
+ className: buttonVariants({ variant: "destructive" }),
2182
+ onClick: () => deleteContent(contentId)
2183
+ },
2184
+ "Verwijderen"
2185
+ ))));
2186
+ };
2187
+
2188
+ // src/components/build-container-client.tsx
2189
+ var BuildContainerInner = (props) => {
2190
+ const { id, name, content, multiple = false } = props;
2191
+ const items = Array.isArray(content) ? content : content?.[name] || [];
2192
+ if (!multiple && items.length > 1) {
2193
+ console.error(
2194
+ "[simple-builder]: Multiple content blocks detected when using property multiple false."
2195
+ );
2196
+ }
2197
+ return /* @__PURE__ */ React25.createElement("div", null, items.length <= 0 ? /* @__PURE__ */ React25.createElement(AddContentPlaceholder, { parent: id, container: name, index: 0 }) : multiple && /* @__PURE__ */ React25.createElement(AddContentDividerButton, { parent: id, container: name, index: 0 }), items.map((item, i) => /* @__PURE__ */ React25.createElement(React25.Fragment, { key: item.id }, /* @__PURE__ */ React25.createElement("div", { className: "sb-relative sb-container-item" }, /* @__PURE__ */ React25.createElement(DesignWrapper, { building: true, styles: item.styles }, builder.bindComponent(item, true)), /* @__PURE__ */ React25.createElement(
2198
+ ContainerItemToolbar,
2199
+ {
2200
+ contentId: item.id,
2201
+ canBringUp: i > 0,
2202
+ canBringDown: i < items.length - 1
2203
+ }
2204
+ )), multiple && /* @__PURE__ */ React25.createElement(
2205
+ AddContentDividerButton,
2206
+ {
2207
+ parent: id,
2208
+ container: name,
2209
+ index: i + 1
2210
+ }
2211
+ ))));
2212
+ };
2213
+ var build_container_client_default = BuildContainerInner;
2214
+ var AddContentButton = (props) => {
2215
+ const components = builder.getComponents();
2216
+ const { addContent } = useBuilder();
2217
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-p-1" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-2" }, components.map((component) => {
2218
+ const Icon2 = component.icon ?? ImageIcon;
2219
+ return /* @__PURE__ */ React25.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React25.createElement(
2220
+ Button,
2221
+ {
2222
+ variant: "ghost",
2223
+ className: "sb-justify-start",
2224
+ onClick: () => {
2225
+ addContent(
2226
+ component.name,
2227
+ props.container,
2228
+ props.parent,
2229
+ props.index
2230
+ );
2231
+ }
2232
+ },
2233
+ /* @__PURE__ */ React25.createElement(Icon2, { className: "sb-mr-2 sb-h-4 sb-w-4 sb-shrink-0" }),
2234
+ component.friendlyName ?? component.name
2235
+ ));
2236
+ }))));
2237
+ };
2238
+ var AddContentPlaceholder = (props) => {
2239
+ return /* @__PURE__ */ React25.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-justify-center sb-bg-primary/50 p-4" }, /* @__PURE__ */ React25.createElement(Button, { size: "sm" }, /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }), "Blok Toevoegen")));
2240
+ };
2241
+ var AddContentDividerButton = (props) => {
2242
+ return /* @__PURE__ */ React25.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-h-1 sb--my-[2px] sb-bg-primary sb-relative sb-z-20 sb-opacity-0 add-content-divider-button sb-transition-opacity" }, /* @__PURE__ */ React25.createElement(
2243
+ Button,
2244
+ {
2245
+ size: "sm",
2246
+ className: "sb-absolute sb-left-1/2 sb-top-1/2 sb--translate-y-1/2 sb--translate-x-1/2 sb-shadow"
2247
+ },
2248
+ /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
2249
+ "Blok Toevoegen"
2250
+ )));
2251
+ };
2252
+
2253
+ export { build_container_client_default as default };