@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260713051007 → 0.8.1-dev.20260713054521

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.
@@ -0,0 +1,766 @@
1
+ "use client";
2
+ import {
3
+ AssetUtility_default,
4
+ BooleanSelect_default,
5
+ CheckboxInput_default,
6
+ ColorInput_default,
7
+ DateTimeInput_default,
8
+ EmailInput_default,
9
+ LineTextInput_default,
10
+ MoneyInput_default,
11
+ MultilineTextInput_default,
12
+ NumberInput_default,
13
+ OtpInput_default,
14
+ PercentageInput_default,
15
+ PhoneInput_default,
16
+ SelectWithSearchInput_default,
17
+ TimeInput_default,
18
+ VideoView_default
19
+ } from "./chunk-NT56SZOV.mjs";
20
+ import {
21
+ Hyperlink,
22
+ Icon_default,
23
+ InputControlType_default
24
+ } from "./chunk-DBHUCH4B.mjs";
25
+ import {
26
+ Button_default,
27
+ ClientButton_default
28
+ } from "./chunk-YL6E76X2.mjs";
29
+ import "./chunk-56HSDML5.mjs";
30
+
31
+ // src/components/controls/edit/InputControlClient.tsx
32
+ import React5 from "react";
33
+
34
+ // src/components/controls/edit/Select.tsx
35
+ import { useState, useEffect } from "react";
36
+ import { jsx, jsxs } from "react/jsx-runtime";
37
+ var Select = (props) => {
38
+ const [list, setList] = useState([]);
39
+ const getSafeValue = (val) => {
40
+ if (val === null || val === void 0) return "";
41
+ if (typeof val === "boolean") return val ? "1" : "0";
42
+ return val;
43
+ };
44
+ const textChangeHandler = (event) => {
45
+ let rawValue = event.target.value;
46
+ if (rawValue === "") rawValue = null;
47
+ let finalValue = rawValue;
48
+ if (list && props.dataKeyFieldName) {
49
+ const key = props.dataKeyFieldName;
50
+ const selectedItem = list.find(
51
+ (item) => String(item[key]) === String(rawValue)
52
+ );
53
+ if (selectedItem) {
54
+ const keyValue = selectedItem[key];
55
+ if (typeof keyValue === "number") {
56
+ finalValue = Number(rawValue);
57
+ }
58
+ }
59
+ }
60
+ props.callback?.({
61
+ name: props.name,
62
+ value: finalValue,
63
+ index: props.index,
64
+ groupKey: props.groupKey
65
+ });
66
+ };
67
+ useEffect(() => {
68
+ async function fetchData() {
69
+ if (props.dataset) {
70
+ setList(props.dataset);
71
+ return;
72
+ }
73
+ if (props.dataSource && props.serviceClient) {
74
+ let dataSource = props.dataSource;
75
+ let response;
76
+ if (props.dataSourceDependsOn && props.dependentValue) {
77
+ dataSource = dataSource.replace(
78
+ `{${props.dataSourceDependsOn}}`,
79
+ props.dependentValue
80
+ );
81
+ }
82
+ response = await props.serviceClient.get(dataSource);
83
+ setList(response.result ?? []);
84
+ }
85
+ }
86
+ fetchData();
87
+ }, [
88
+ props.dataset,
89
+ props.dataSource,
90
+ props.dependentValue,
91
+ props.dataSourceDependsOn
92
+ ]);
93
+ const value = getSafeValue(props.value);
94
+ return /* @__PURE__ */ jsxs("label", { className: "block", children: [
95
+ props.attributes?.label && /* @__PURE__ */ jsx("span", { className: "text-sm font-medium inline-block pb-1", children: props.attributes?.label }),
96
+ " ",
97
+ props.attributes?.label && props.attributes?.required && /* @__PURE__ */ jsx("span", { className: "bg-error-weak", children: "*" }),
98
+ /* @__PURE__ */ jsxs(
99
+ "select",
100
+ {
101
+ name: props.name,
102
+ id: props.name,
103
+ value,
104
+ onChange: textChangeHandler,
105
+ required: props.attributes?.required,
106
+ disabled: props.attributes?.readOnly,
107
+ className: "peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none",
108
+ children: [
109
+ /* @__PURE__ */ jsx("option", { value: "", children: props.attributes?.placeholder || "Select" }),
110
+ list.map((item, index) => {
111
+ const keyField = props.dataKeyFieldName;
112
+ const textField = props.dataTextFieldName;
113
+ return /* @__PURE__ */ jsx("option", { value: item[keyField], children: item[textField] }, index);
114
+ })
115
+ ]
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsx("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: props.attributes?.errorMessage || "" })
119
+ ] });
120
+ };
121
+ var Select_default = Select;
122
+
123
+ // src/components/controls/edit/SelectWithSearchPanel.tsx
124
+ import React2, {
125
+ useEffect as useEffect2,
126
+ useRef,
127
+ useState as useState2,
128
+ useCallback
129
+ } from "react";
130
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
131
+ var SelectWithSearchPanel = (props) => {
132
+ const [isOpen, setIsOpen] = useState2(false);
133
+ const [searchTerm, setSearchTerm] = useState2("");
134
+ const [highlightedIndex, setHighlightedIndex] = useState2(0);
135
+ const [list, setList] = useState2([]);
136
+ const listRef = useRef(null);
137
+ const [isError, setIsError] = useState2(false);
138
+ const containerRef = useRef(null);
139
+ const [isCreateOpen, setIsCreateOpen] = useState2(false);
140
+ const [formData, setFormData] = useState2({});
141
+ const getNestedValue = (obj, path) => {
142
+ return path.split(".").reduce((acc, key) => acc?.[key], obj);
143
+ };
144
+ useEffect2(() => {
145
+ const handleClickOutside = (event) => {
146
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
147
+ setIsOpen(false);
148
+ }
149
+ };
150
+ document.addEventListener("mousedown", handleClickOutside);
151
+ return () => {
152
+ document.removeEventListener("mousedown", handleClickOutside);
153
+ };
154
+ }, []);
155
+ useEffect2(() => {
156
+ async function fetchData() {
157
+ if (props.dataset) {
158
+ setList(props.dataset);
159
+ } else if (props.dataSource && props.serviceClient) {
160
+ let dataSource = props.dataSource;
161
+ if (props.dataSourceDependsOn && props.dependentValue) {
162
+ dataSource = dataSource.replace(
163
+ `{${props.dataSourceDependsOn}}`,
164
+ props.dependentValue
165
+ );
166
+ }
167
+ const response = await props.serviceClient.get(dataSource);
168
+ if (response?.result) setList(response.result);
169
+ }
170
+ }
171
+ fetchData();
172
+ }, [
173
+ props.dataSource,
174
+ props.dependentValue,
175
+ props.dataset,
176
+ props.dataSourceDependsOn
177
+ ]);
178
+ const filteredItems = list?.filter((item) => {
179
+ const value = getNestedValue(item, props.dataTextFieldName);
180
+ return value?.toLowerCase().includes(searchTerm?.toLowerCase());
181
+ });
182
+ const playBeep = () => {
183
+ const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
184
+ const oscillator = audioCtx.createOscillator();
185
+ const gainNode = audioCtx.createGain();
186
+ oscillator.type = "square";
187
+ oscillator.frequency.setValueAtTime(300, audioCtx.currentTime);
188
+ gainNode.gain.setValueAtTime(0.02, audioCtx.currentTime);
189
+ oscillator.connect(gainNode);
190
+ gainNode.connect(audioCtx.destination);
191
+ oscillator.start();
192
+ setTimeout(() => {
193
+ oscillator.stop();
194
+ audioCtx.close();
195
+ }, 250);
196
+ };
197
+ useEffect2(() => {
198
+ const filteredItems2 = list?.filter(
199
+ (item) => item[props?.dataTextFieldName]?.toLowerCase().includes(searchTerm?.toLowerCase())
200
+ );
201
+ if (searchTerm.length > 0 && filteredItems2.length === 0) {
202
+ playBeep();
203
+ setIsError(true);
204
+ } else {
205
+ setIsError(false);
206
+ }
207
+ }, [searchTerm]);
208
+ const handleSelect = (event, item) => {
209
+ event.preventDefault();
210
+ setSearchTerm(getNestedValue(item, props.dataTextFieldName));
211
+ if (props.callback) {
212
+ const val = {};
213
+ props.callback({
214
+ name: props.name,
215
+ value: item[props.dataKeyFieldName],
216
+ index: props.index,
217
+ groupKey: props.groupKey
218
+ });
219
+ }
220
+ setHighlightedIndex(0);
221
+ setIsOpen(false);
222
+ };
223
+ const handleKeyDown = (e) => {
224
+ if (e.key === "Escape") {
225
+ setIsOpen(false);
226
+ setHighlightedIndex(-1);
227
+ } else if (e.key === "ArrowDown") {
228
+ e.preventDefault();
229
+ setHighlightedIndex((prev) => {
230
+ const nextIndex = prev < filteredItems.length - 1 ? prev + 1 : prev;
231
+ scrollIntoView(nextIndex);
232
+ return nextIndex;
233
+ });
234
+ } else if (e.key === "ArrowUp") {
235
+ e.preventDefault();
236
+ setHighlightedIndex((prev) => {
237
+ const prevIndex = prev > 0 ? prev - 1 : prev;
238
+ scrollIntoView(prevIndex);
239
+ return prevIndex;
240
+ });
241
+ } else if (e.key === "Enter" && highlightedIndex >= 0) {
242
+ handleSelect(e, filteredItems[highlightedIndex]);
243
+ }
244
+ };
245
+ const scrollIntoView = (index) => {
246
+ if (listRef.current) {
247
+ const item = listRef.current.children[index];
248
+ if (item) {
249
+ item.scrollIntoView();
250
+ }
251
+ }
252
+ };
253
+ const textChangeHandler = (event) => {
254
+ const newSearchTerm = event.target.value;
255
+ setSearchTerm(newSearchTerm);
256
+ setIsOpen(true);
257
+ setHighlightedIndex(0);
258
+ };
259
+ const handleInputChange = (event, field) => {
260
+ setFormData((prev) => ({ ...prev, [field]: event.target.value }));
261
+ };
262
+ const handleSaveModal = useCallback(async () => {
263
+ console.log("Form Data:", formData);
264
+ return formData;
265
+ }, []);
266
+ return /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
267
+ /* @__PURE__ */ jsxs2("label", { className: "text-sm mb-1 font-medium", children: [
268
+ props.attributes?.label,
269
+ " ",
270
+ " ",
271
+ props?.attributes?.required && /* @__PURE__ */ jsx2("span", { className: "bg-error-weak", children: "*" })
272
+ ] }),
273
+ /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(
274
+ "input",
275
+ {
276
+ type: "text",
277
+ value: searchTerm,
278
+ onChange: textChangeHandler,
279
+ onFocus: () => setIsOpen(true),
280
+ onKeyDown: handleKeyDown,
281
+ placeholder: props.attributes?.placeholder,
282
+ className: `peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
283
+ ${isError ? "focus:border-red-300 focus:ring focus:ring-red-200 focus:ring-opacity-50" : "focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"}
284
+ disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none`
285
+ }
286
+ ) }),
287
+ /* @__PURE__ */ jsx2("div", { ref: containerRef, children: isOpen && /* @__PURE__ */ jsxs2(React2.Fragment, { children: [
288
+ /* @__PURE__ */ jsxs2("div", { className: "fixed z-50 right-0 bg-white top-[62px] w-1/4 border-l border-gray-200", children: [
289
+ /* @__PURE__ */ jsx2("div", { className: "flex flex-col p-2 bg-accent-950 text-white", children: /* @__PURE__ */ jsxs2("h5", { className: "text-md text-white font-medium", children: [
290
+ "Select a",
291
+ " ",
292
+ props.attributes?.label || props.attributes?.heading
293
+ ] }) }),
294
+ /* @__PURE__ */ jsx2("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200 h-10", children: props.createFields && props.createFields.length > 0 && /* @__PURE__ */ jsx2(
295
+ "button",
296
+ {
297
+ type: "button",
298
+ className: "text-primary hover:text-primary-800",
299
+ onMouseDown: (e) => {
300
+ e.preventDefault();
301
+ setIsCreateOpen(true);
302
+ },
303
+ children: "Create"
304
+ }
305
+ ) })
306
+ ] }),
307
+ isCreateOpen && /* @__PURE__ */ jsxs2("div", { className: "fixed right-0 w-1/4 h-full top-[62px] bg-white shadow-lg border-l border-gray-200 z-50", children: [
308
+ /* @__PURE__ */ jsx2("div", { className: "flex flex-col p-2 bg-accent-950", children: /* @__PURE__ */ jsxs2("h5", { className: "text-md font-medium text-white", children: [
309
+ "Create New ",
310
+ props.attributes?.label
311
+ ] }) }),
312
+ /* @__PURE__ */ jsx2("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200", children: /* @__PURE__ */ jsx2(
313
+ "button",
314
+ {
315
+ type: "button",
316
+ onClick: () => setIsCreateOpen(false),
317
+ className: "text-red-600 hover:text-red-800",
318
+ children: "Close"
319
+ }
320
+ ) }),
321
+ /* @__PURE__ */ jsxs2("div", { className: "p-4", children: [
322
+ props.createFields?.map((field) => /* @__PURE__ */ jsxs2("div", { className: "mb-4", children: [
323
+ /* @__PURE__ */ jsx2("label", { className: "text-sm mb-1 font-medium block", children: field.label }),
324
+ /* @__PURE__ */ jsx2(
325
+ "input",
326
+ {
327
+ type: field.type,
328
+ value: formData[field.name] || "",
329
+ onChange: (e) => handleInputChange(e, field.name),
330
+ placeholder: field.placeholder,
331
+ required: field.required,
332
+ disabled: field.disabled,
333
+ pattern: field.pattern,
334
+ minLength: field.minLength,
335
+ maxLength: field.maxLength,
336
+ className: "peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
337
+ }
338
+ )
339
+ ] }, field.name)),
340
+ /* @__PURE__ */ jsxs2(Button_default, { onClick: async () => {
341
+ handleSaveModal();
342
+ return { isSuccessful: true };
343
+ }, className: "w-full", children: [
344
+ "Save ",
345
+ props.attributes?.label
346
+ ] })
347
+ ] })
348
+ ] }),
349
+ /* @__PURE__ */ jsx2(
350
+ "div",
351
+ {
352
+ ref: listRef,
353
+ className: "fixed z-10 right-0 mt-[130px] top-0 w-1/4 bg-white border-l border-gray-200 shadow-lg overflow-y-auto",
354
+ style: { height: "calc(100vh - 130px)" },
355
+ children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(
356
+ "button",
357
+ {
358
+ onClick: (e) => {
359
+ handleSelect(e, item);
360
+ },
361
+ className: `w-full px-4 py-2 flex items-center space-x-2 text-left border-b border-gray-200 ${index === highlightedIndex ? "bg-gray-200" : "hover:bg-gray-100"}`,
362
+ role: "option",
363
+ tabIndex: -1,
364
+ onMouseEnter: () => setHighlightedIndex(index),
365
+ children: /* @__PURE__ */ jsx2("span", { children: getNestedValue(item, props.dataTextFieldName) })
366
+ }
367
+ ) }, item[props.dataKeyFieldName])) : /* @__PURE__ */ jsx2("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
368
+ }
369
+ )
370
+ ] }) })
371
+ ] });
372
+ };
373
+ var SelectWithSearchPanel_default = SelectWithSearchPanel;
374
+
375
+ // src/components/controls/edit/AssetUpload.tsx
376
+ import React3, { useEffect as useEffect3 } from "react";
377
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
378
+ var AssetUpload = (props) => {
379
+ const isDisabled = props.attributes?.disable ?? false;
380
+ let allValues = [];
381
+ if (props.value !== void 0 && props.value !== null && props.value !== "") {
382
+ try {
383
+ allValues = JSON.parse(props.value.toString());
384
+ } catch (error) {
385
+ }
386
+ }
387
+ const getInitialTab = () => {
388
+ if (allValues.length > 0) {
389
+ const asset = allValues[0];
390
+ if (asset.posterUrl) {
391
+ return "video";
392
+ } else if (asset.assetUrl) {
393
+ return "image";
394
+ }
395
+ }
396
+ return "image";
397
+ };
398
+ const [assetType, setAssetType] = React3.useState(getInitialTab);
399
+ useEffect3(() => {
400
+ setAssetType(getInitialTab());
401
+ }, [props.value]);
402
+ const assetUploadCallback = (newAsset) => {
403
+ if (isDisabled) return;
404
+ let updated = [];
405
+ updated.push({
406
+ assetUrl: newAsset.assetUrl,
407
+ title: newAsset.title,
408
+ posterUrl: newAsset.posterUrl,
409
+ intrinsicHeight: newAsset.intrinsicHeight,
410
+ intrinsicWidth: newAsset.intrinsicWidth
411
+ });
412
+ props.callback?.({
413
+ name: props.name,
414
+ value: JSON.stringify(updated),
415
+ index: props.index,
416
+ groupKey: props.groupKey
417
+ });
418
+ };
419
+ const deleteFile = (index) => {
420
+ if (isDisabled) return;
421
+ let existingValue = [];
422
+ if (props.value) {
423
+ try {
424
+ existingValue = JSON.parse(props.value.toString());
425
+ } catch (error) {
426
+ }
427
+ }
428
+ if (existingValue.length > index) {
429
+ existingValue.splice(index, 1);
430
+ props.callback?.({
431
+ name: props.name,
432
+ value: JSON.stringify(existingValue),
433
+ index: props.index,
434
+ groupKey: props.groupKey
435
+ });
436
+ }
437
+ };
438
+ const textChangeHandler = (index, event) => {
439
+ if (isDisabled) return;
440
+ let existingValue = [];
441
+ if (props.value) {
442
+ try {
443
+ existingValue = JSON.parse(props.value.toString());
444
+ } catch (error) {
445
+ }
446
+ }
447
+ const text = event.target.value;
448
+ if (existingValue.length > index) {
449
+ const updatedArray = [...existingValue];
450
+ updatedArray[index] = { ...updatedArray[index], title: text };
451
+ props.callback?.({
452
+ name: props.name,
453
+ value: JSON.stringify(updatedArray),
454
+ index: props.index,
455
+ groupKey: props.groupKey
456
+ });
457
+ }
458
+ };
459
+ const getAssetType = (asset) => {
460
+ if (asset.assetUrl?.endsWith(".m3u8") || asset.posterUrl) return "video";
461
+ return "image";
462
+ };
463
+ const shouldShowDetails = () => {
464
+ if (allValues.length === 0) return false;
465
+ const asset = allValues[0];
466
+ if (assetType === "video") {
467
+ return Boolean(asset.posterUrl && asset.assetUrl && asset.assetUrl.endsWith(".m3u8"));
468
+ }
469
+ if (assetType === "image") {
470
+ return Boolean(asset.assetUrl && !asset.assetUrl.endsWith(".m3u8"));
471
+ }
472
+ return false;
473
+ };
474
+ return /* @__PURE__ */ jsxs3(React3.Fragment, { children: [
475
+ /* @__PURE__ */ jsx3("label", { className: "block mb-1", children: /* @__PURE__ */ jsx3("span", { className: "text-sm font-medium", children: props?.attributes?.label }) }),
476
+ /* @__PURE__ */ jsxs3("div", { className: "flex gap-6 bg-neutral-100 rounded p-2", children: [
477
+ /* @__PURE__ */ jsx3(
478
+ ClientButton_default,
479
+ {
480
+ className: assetType === "image" ? "px-2 py-1 rounded bg-body-200 scale-95" : "text-neutral-700",
481
+ ButtonType: "Link" /* Link */,
482
+ onClick: () => setAssetType("image"),
483
+ disabled: isDisabled,
484
+ children: "Image Upload"
485
+ }
486
+ ),
487
+ /* @__PURE__ */ jsx3(
488
+ ClientButton_default,
489
+ {
490
+ className: assetType === "video" ? "bg-body-200 px-2 py-1 rounded-md scale-95" : "text-neutral-700",
491
+ ButtonType: "Link" /* Link */,
492
+ onClick: () => setAssetType("video"),
493
+ disabled: isDisabled,
494
+ children: "Video Upload"
495
+ }
496
+ )
497
+ ] }),
498
+ shouldShowDetails() && /* @__PURE__ */ jsxs3("div", { className: "relative mt-4 rounded-md p-4 border-2 border-dotted border-gray-300 bg-gray-50", children: [
499
+ /* @__PURE__ */ jsx3("span", { className: "absolute -top-2.5 left-3 bg-primary-600 text-white text-xs px-2 py-0.5 rounded-full", children: getAssetType(allValues[0]) === "video" ? "Video" : "Image" }),
500
+ /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-3", children: allValues.map((digitalAsset, index) => /* @__PURE__ */ jsxs3("div", { className: "flex justify-between items-start gap-5", children: [
501
+ /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-2 gap-x-8 gap-y-3 text-sm w-full", children: [
502
+ /* @__PURE__ */ jsxs3("div", { children: [
503
+ /* @__PURE__ */ jsx3("p", { className: "text-gray-500", children: "Title" }),
504
+ /* @__PURE__ */ jsx3(
505
+ "input",
506
+ {
507
+ type: "text",
508
+ value: digitalAsset.title,
509
+ onChange: (event) => textChangeHandler(index, event),
510
+ placeholder: "title",
511
+ disabled: isDisabled,
512
+ className: "w-full mt-1 py-1.5 block rounded border-gray-300 shadow-sm bg-white\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\n disabled:bg-gray-100 disabled:text-gray-400 disabled:cursor-not-allowed"
513
+ }
514
+ )
515
+ ] }),
516
+ digitalAsset.intrinsicWidth && digitalAsset.intrinsicHeight && /* @__PURE__ */ jsxs3("div", { children: [
517
+ /* @__PURE__ */ jsx3("p", { className: "text-gray-500", children: "Resolution" }),
518
+ /* @__PURE__ */ jsxs3("p", { className: "font-medium text-gray-900 mt-3", children: [
519
+ digitalAsset.intrinsicWidth,
520
+ "\xD7",
521
+ digitalAsset.intrinsicHeight
522
+ ] })
523
+ ] }),
524
+ (digitalAsset.assetUrl || digitalAsset.posterUrl) && /* @__PURE__ */ jsxs3("div", { children: [
525
+ /* @__PURE__ */ jsx3("p", { className: "text-gray-500", children: "Image / Poster" }),
526
+ /* @__PURE__ */ jsxs3("div", { className: "flex-shrink-0 flex flex-col gap-3 mt-1", children: [
527
+ getAssetType(digitalAsset) === "video" && digitalAsset.posterUrl && /* @__PURE__ */ jsx3(
528
+ "img",
529
+ {
530
+ src: AssetUtility_default.resolveUrl(props.serviceClient?.baseUrl, digitalAsset.posterUrl),
531
+ alt: digitalAsset.title || "Video poster",
532
+ className: "w-32 h-auto object-cover rounded border p-1"
533
+ }
534
+ ),
535
+ getAssetType(digitalAsset) === "image" && digitalAsset.assetUrl && /* @__PURE__ */ jsx3(
536
+ "img",
537
+ {
538
+ src: AssetUtility_default.resolveUrl(props.serviceClient?.baseUrl, digitalAsset.assetUrl),
539
+ alt: digitalAsset.title || "Uploaded image",
540
+ className: "w-32 h-auto object-cover rounded border p-1"
541
+ }
542
+ )
543
+ ] })
544
+ ] }),
545
+ digitalAsset.assetUrl?.endsWith(".m3u8") && /* @__PURE__ */ jsxs3("div", { className: "col-span-2", children: [
546
+ /* @__PURE__ */ jsx3("p", { className: "text-gray-500", children: "HLS Link" }),
547
+ /* @__PURE__ */ jsx3(
548
+ Hyperlink,
549
+ {
550
+ href: digitalAsset.assetUrl,
551
+ className: "text-primary-600 underline mt-1 break-all",
552
+ title: digitalAsset.assetUrl,
553
+ children: digitalAsset.assetUrl
554
+ }
555
+ )
556
+ ] })
557
+ ] }),
558
+ /* @__PURE__ */ jsx3(
559
+ "span",
560
+ {
561
+ onClick: () => !isDisabled && deleteFile(index),
562
+ className: isDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer",
563
+ children: /* @__PURE__ */ jsx3(Icon_default, { className: "w-4 h-4 text-primary", name: "delete" })
564
+ }
565
+ )
566
+ ] }, index)) })
567
+ ] })
568
+ ] });
569
+ };
570
+ var AssetUpload_default = AssetUpload;
571
+
572
+ // src/components/controls/edit/SwitchInput.tsx
573
+ import React4 from "react";
574
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
575
+ var SwitchInput = (props) => {
576
+ const textChangeHandler = (event) => {
577
+ let text = event.target.checked;
578
+ if (props.callback !== void 0) {
579
+ props.callback({
580
+ name: props.name,
581
+ value: text,
582
+ index: props.index,
583
+ groupKey: props.groupKey
584
+ });
585
+ }
586
+ };
587
+ let value = false;
588
+ if (props.value != void 0 && props.value != null && props.value != "" && (props.value == "true" || props.value.toString() == "true")) {
589
+ value = true;
590
+ }
591
+ return /* @__PURE__ */ jsx4(React4.Fragment, { children: /* @__PURE__ */ jsxs4("div", { className: "flex items-start justify-between gap-4 py-3", children: [
592
+ /* @__PURE__ */ jsxs4("div", { className: "min-w-0", children: [
593
+ props?.attributes?.label && /* @__PURE__ */ jsxs4(
594
+ "label",
595
+ {
596
+ htmlFor: props.name,
597
+ className: "inline-block text-sm font-semibold text-slate-800",
598
+ children: [
599
+ props.attributes.label,
600
+ props?.attributes?.required && /* @__PURE__ */ jsx4("span", { className: "bg-error-weak", children: "*" })
601
+ ]
602
+ }
603
+ ),
604
+ /* @__PURE__ */ jsx4("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage || "" })
605
+ ] }),
606
+ /* @__PURE__ */ jsxs4(
607
+ "label",
608
+ {
609
+ htmlFor: props.name,
610
+ className: "relative inline-flex shrink-0 cursor-pointer items-center peer-disabled:cursor-not-allowed",
611
+ children: [
612
+ /* @__PURE__ */ jsx4(
613
+ "input",
614
+ {
615
+ type: "checkbox",
616
+ name: props.name,
617
+ id: props.name,
618
+ checked: value,
619
+ onChange: textChangeHandler,
620
+ required: props?.attributes?.required,
621
+ disabled: props?.attributes?.readOnly,
622
+ className: "peer sr-only"
623
+ }
624
+ ),
625
+ /* @__PURE__ */ jsx4(
626
+ "div",
627
+ {
628
+ className: "h-6 w-11 rounded-full bg-slate-200 shadow-inner\n transition-colors duration-200 ease-in-out\n peer-checked:bg-blue-600\n peer-focus-visible:ring-2 peer-focus-visible:ring-blue-300 peer-focus-visible:ring-offset-2\n peer-disabled:bg-slate-100"
629
+ }
630
+ ),
631
+ /* @__PURE__ */ jsx4(
632
+ "div",
633
+ {
634
+ className: "absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-default shadow\n transition-transform duration-200 ease-in-out\n peer-checked:translate-x-5\n peer-disabled:bg-slate-50"
635
+ }
636
+ )
637
+ ]
638
+ }
639
+ )
640
+ ] }) });
641
+ };
642
+ var SwitchInput_default = SwitchInput;
643
+
644
+ // src/components/controls/edit/VideoInput.tsx
645
+ import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
646
+ var normalizeVideoValue = (value) => {
647
+ if (typeof value === "string") {
648
+ const trimmed = value.trim();
649
+ if (!trimmed) return void 0;
650
+ try {
651
+ const parsed = JSON.parse(trimmed);
652
+ if (typeof parsed === "string") {
653
+ return parsed;
654
+ }
655
+ if (parsed && typeof parsed === "object") {
656
+ const candidate = parsed;
657
+ if (typeof candidate.assetUrl === "string") return candidate.assetUrl;
658
+ if (typeof candidate.url === "string") return candidate.url;
659
+ if (typeof candidate.src === "string") return candidate.src;
660
+ }
661
+ } catch {
662
+ return trimmed;
663
+ }
664
+ return trimmed;
665
+ }
666
+ if (value && typeof value === "object") {
667
+ const candidate = value;
668
+ if (typeof candidate.assetUrl === "string") return candidate.assetUrl;
669
+ if (typeof candidate.url === "string") return candidate.url;
670
+ if (typeof candidate.src === "string") return candidate.src;
671
+ }
672
+ return void 0;
673
+ };
674
+ var VideoInput = (props) => {
675
+ const isReadOnly = Boolean(
676
+ props.attributes?.readOnly || props.disable || props.attributes?.disable
677
+ );
678
+ const videoUrl = normalizeVideoValue(props.value ?? props.defaultValue);
679
+ const handleChange = (event) => {
680
+ const text = event.target.value;
681
+ props.callback?.({
682
+ name: props.name,
683
+ value: text,
684
+ index: props.index,
685
+ groupKey: props.groupKey
686
+ });
687
+ };
688
+ return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-2", children: [
689
+ "ayush testing",
690
+ props.attributes?.label ? /* @__PURE__ */ jsxs5("label", { className: "text-sm font-medium", children: [
691
+ props.attributes.label,
692
+ props.attributes?.required ? /* @__PURE__ */ jsx5("span", { className: "ml-1 text-red-500", children: "*" }) : null
693
+ ] }) : null,
694
+ isReadOnly ? /* @__PURE__ */ jsxs5(Fragment, { children: [
695
+ "called video view",
696
+ console.log(props.value, "vkjbvbvbvsdjkvdfn"),
697
+ /* @__PURE__ */ jsx5(
698
+ VideoView_default,
699
+ {
700
+ ...props,
701
+ value: props.value ?? props.defaultValue,
702
+ assetBaseUrl: props.serviceClient?.baseUrl
703
+ }
704
+ )
705
+ ] }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
706
+ /* @__PURE__ */ jsx5(
707
+ "input",
708
+ {
709
+ type: "text",
710
+ name: props.name,
711
+ id: props.name,
712
+ value: videoUrl ?? "",
713
+ onChange: handleChange,
714
+ onBlur: props.onBlur,
715
+ placeholder: props.attributes?.placeholder || "Paste a video URL or blob URL",
716
+ disabled: isReadOnly,
717
+ className: "peer input mt-1 block w-full rounded shadow-sm"
718
+ }
719
+ ),
720
+ videoUrl ? /* @__PURE__ */ jsx5(
721
+ VideoView_default,
722
+ {
723
+ ...props,
724
+ value: props.value ?? props.defaultValue,
725
+ assetBaseUrl: props.serviceClient?.baseUrl
726
+ }
727
+ ) : null
728
+ ] })
729
+ ] });
730
+ };
731
+ var VideoInput_default = VideoInput;
732
+
733
+ // src/components/controls/edit/InputControlClient.tsx
734
+ import { jsx as jsx6 } from "react/jsx-runtime";
735
+ var InputControl = React5.forwardRef(
736
+ (props, ref) => {
737
+ const ControlComponents = {
738
+ [InputControlType_default.lineTextInput]: LineTextInput_default,
739
+ [InputControlType_default.emailInput]: EmailInput_default,
740
+ [InputControlType_default.multilineTextInput]: MultilineTextInput_default,
741
+ [InputControlType_default.moneyInput]: MoneyInput_default,
742
+ [InputControlType_default.select]: Select_default,
743
+ [InputControlType_default.percentageInput]: PercentageInput_default,
744
+ [InputControlType_default.phoneInput]: PhoneInput_default,
745
+ [InputControlType_default.numberInput]: NumberInput_default,
746
+ [InputControlType_default.checkboxInput]: CheckboxInput_default,
747
+ [InputControlType_default.otpInput]: OtpInput_default,
748
+ [InputControlType_default.datetimeInput]: DateTimeInput_default,
749
+ [InputControlType_default.colorInput]: ColorInput_default,
750
+ [InputControlType_default.selectWithSearchInput]: SelectWithSearchInput_default,
751
+ [InputControlType_default.selectWithSearchPanel]: SelectWithSearchPanel_default,
752
+ [InputControlType_default.booleanSelect]: BooleanSelect_default,
753
+ [InputControlType_default.timeInput]: TimeInput_default,
754
+ [InputControlType_default.asset]: AssetUpload_default,
755
+ [InputControlType_default.switchInput]: SwitchInput_default,
756
+ [InputControlType_default.videoInput]: VideoInput_default
757
+ };
758
+ const SelectedControlComponent = ControlComponents[props.controlType];
759
+ return /* @__PURE__ */ jsx6(React5.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ jsx6(SelectedControlComponent, { ...props }) : "Control not found" });
760
+ }
761
+ );
762
+ InputControl.displayName = "InputControl";
763
+ var InputControlClient_default = InputControl;
764
+ export {
765
+ InputControlClient_default as default
766
+ };