@simple-builder/react 1.0.20 → 1.1.0

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