@simple-builder/react 1.2.8 → 1.2.10

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