eddyter 1.3.62 → 1.3.64

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 (36) hide show
  1. package/LICENSE +24 -24
  2. package/README.md +493 -493
  3. package/dist/ImageResizer-CbtUYHip.js +199 -0
  4. package/dist/api/auth.d.ts +4 -2
  5. package/dist/assets/style.css +1 -0
  6. package/dist/{babel-B9hn44Wo.js → babel-CCPWkrf4.js} +1302 -726
  7. package/dist/components/LockedFeature/LockedFeature.d.ts +23 -0
  8. package/dist/components/LockedFeature/index.d.ts +2 -0
  9. package/dist/components/UnifiedColorPicker/UnifiedColorPicker.d.ts +14 -0
  10. package/dist/components/VideoView/index.d.ts +13 -0
  11. package/dist/constants.d.ts +3 -1
  12. package/dist/editorConfig.d.ts +2 -3
  13. package/dist/{estree-CocPn_Md.js → estree-CxUPh9wa.js} +917 -529
  14. package/dist/{html-CxCicOef.js → html-CmniStvG.js} +589 -350
  15. package/dist/{html2pdf.bundle-DNyY_rJA.js → html2pdf.bundle-C1B1lr_T.js} +3796 -2777
  16. package/dist/{html2pdf.bundle.min-GfQzEXnM.js → html2pdf.bundle.min-kPviTsNx.js} +5223 -3407
  17. package/dist/index-BL8HWCRw.js +816 -0
  18. package/dist/index-BpsoOKOs.js +274 -0
  19. package/dist/{index-YHNm3bIK.js → index-DHKx5grA.js} +4 -4
  20. package/dist/{index-CIBuU2Zv.js → index-FZVNbwSO.js} +12356 -11290
  21. package/dist/index.js +3 -3
  22. package/dist/{markdown-BUjgWFLu.js → markdown-B0mEGGfQ.js} +1015 -578
  23. package/dist/nodes/UploadingVideoNode.d.ts +30 -0
  24. package/dist/nodes/VideoNode.d.ts +47 -0
  25. package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +2 -1
  26. package/dist/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +1 -1
  27. package/dist/plugins/VideoPlugin.d.ts +17 -0
  28. package/dist/{postcss-CGIcwj_g.js → postcss-B0bxXf7u.js} +1065 -615
  29. package/dist/{standalone-C0qguT38.js → standalone-DmuJV5rn.js} +596 -350
  30. package/dist/types.d.ts +4 -6
  31. package/dist/{typescript-BM7wk6k-.js → typescript-DZlC_9M8.js} +1805 -1113
  32. package/dist/ui/Icons.d.ts +2 -1
  33. package/dist/utils/uploadManager.d.ts +17 -0
  34. package/package.json +151 -151
  35. package/dist/assets/index.css +0 -1
  36. package/dist/index-BoOSmKss.js +0 -985
@@ -1,985 +0,0 @@
1
- import { jsx as t, jsxs as h, Fragment as ot } from "react/jsx-runtime";
2
- import { CodeNode as Ee } from "@lexical/code";
3
- import { LinkNode as ke } from "@lexical/link";
4
- import { AutoFocusPlugin as nt } from "@lexical/react/LexicalAutoFocusPlugin";
5
- import { useCollaborationContext as ct } from "@lexical/react/LexicalCollaborationContext";
6
- import { useLexicalComposerContext as at } from "@lexical/react/LexicalComposerContext";
7
- import { ContentEditable as Ie } from "@lexical/react/LexicalContentEditable";
8
- import { LexicalErrorBoundary as Pe } from "@lexical/react/LexicalErrorBoundary";
9
- import { HistoryPlugin as Re } from "@lexical/react/LexicalHistoryPlugin";
10
- import { LexicalNestedComposer as De } from "@lexical/react/LexicalNestedComposer";
11
- import { OnChangePlugin as ze } from "@lexical/react/LexicalOnChangePlugin";
12
- import { RichTextPlugin as Se } from "@lexical/react/LexicalRichTextPlugin";
13
- import { useLexicalEditable as st } from "@lexical/react/useLexicalEditable";
14
- import { useLexicalNodeSelection as dt } from "@lexical/react/useLexicalNodeSelection";
15
- import { calculateZoomLevel as we, mergeRegister as lt } from "@lexical/utils";
16
- import { RootNode as Le, TextNode as We, LineBreakNode as Ae, ParagraphNode as Me, $getSelection as V, $isNodeSelection as K, $isParagraphNode as Ce, $setSelection as ae, $isRangeSelection as ut, SELECTION_CHANGE_COMMAND as mt, COMMAND_PRIORITY_LOW as $, CLICK_COMMAND as gt, DRAGSTART_COMMAND as ht, KEY_DELETE_COMMAND as ft, KEY_BACKSPACE_COMMAND as pt, KEY_ENTER_COMMAND as bt, KEY_ESCAPE_COMMAND as yt, createCommand as xt, $getNodeByKey as J } from "lexical";
17
- import { useRef as H, useState as R, useEffect as se, useCallback as A, Suspense as wt } from "react";
18
- import { a as Ct, D as Nt, b as vt, d as Et, e as kt, f as It, h as Pt, B as Ne, L as $e, i as _e, $ as X, W as Rt, j as Dt, A as zt, k as St, l as Lt, T as Wt, m as At, S as Mt, E as $t, n as _t, t as _, o as Ot, p as Ht, C as Tt } from "./index-CIBuU2Zv.js";
19
- const jt = Ct("Link2", [
20
- ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
21
- ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
22
- ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
23
- ]), Bt = ({
24
- open: u,
25
- onOpenChange: p,
26
- oldImageUrl: b,
27
- newImageUrl: N,
28
- onReplace: S,
29
- onCancel: E
30
- }) => /* @__PURE__ */ t(Nt, { open: u, onOpenChange: p, children: /* @__PURE__ */ h(vt, { className: "sm:max-w-[800px] max-h-[90vh] overflow-y-auto", children: [
31
- /* @__PURE__ */ h(Et, { children: [
32
- /* @__PURE__ */ h(kt, { className: "flex items-center gap-2 text-xl", children: [
33
- /* @__PURE__ */ t("span", { className: "text-2xl", children: "🔄" }),
34
- "Compare Images"
35
- ] }),
36
- /* @__PURE__ */ t(It, { className: "text-sm pt-1", children: "Choose whether to replace the original image with the refined version." })
37
- ] }),
38
- /* @__PURE__ */ h("div", { className: "space-y-4 py-4", children: [
39
- /* @__PURE__ */ t("div", { className: "grid grid-cols-2 gap-4", children: /* @__PURE__ */ h("div", { className: "space-y-2", children: [
40
- /* @__PURE__ */ h("div", { className: "flex items-center justify-between", children: [
41
- /* @__PURE__ */ t("span", { className: "text-sm font-semibold text-gray-700 dark:text-gray-300", children: "Refined Image" }),
42
- /* @__PURE__ */ t("span", { className: "text-xs px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-950/30 text-blue-600 dark:text-blue-400", children: "New" })
43
- ] }),
44
- /* @__PURE__ */ t("div", { className: "relative aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border-2 border-blue-500 dark:border-blue-600", children: /* @__PURE__ */ t(
45
- "img",
46
- {
47
- src: N,
48
- alt: "Refined",
49
- className: "w-full h-full object-contain"
50
- }
51
- ) })
52
- ] }) }),
53
- /* @__PURE__ */ t("div", { className: "p-3 rounded-lg bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ h("p", { className: "text-sm text-blue-800 dark:text-blue-200", children: [
54
- /* @__PURE__ */ t("span", { className: "font-semibold", children: "Note:" }),
55
- ' Clicking "Replace" will update the image in your document. This action cannot be undone.'
56
- ] }) })
57
- ] }),
58
- /* @__PURE__ */ h(Pt, { className: "gap-2", children: [
59
- /* @__PURE__ */ t(
60
- Ne,
61
- {
62
- variant: "outline",
63
- onClick: E,
64
- children: "Keep Original"
65
- }
66
- ),
67
- /* @__PURE__ */ h(
68
- Ne,
69
- {
70
- onClick: S,
71
- className: "bg-blue-500 hover:bg-blue-600 text-white",
72
- children: [
73
- /* @__PURE__ */ t("span", { className: "mr-2", children: "✓" }),
74
- "Replace Image"
75
- ]
76
- }
77
- )
78
- ] })
79
- ] }) });
80
- function Yt({
81
- caption: u
82
- }) {
83
- return /* @__PURE__ */ t("div", { className: "signature-caption-container", children: /* @__PURE__ */ h(
84
- De,
85
- {
86
- initialEditor: u,
87
- initialNodes: [
88
- Le,
89
- We,
90
- Ae,
91
- Me,
92
- ke,
93
- Ee
94
- ],
95
- children: [
96
- /* @__PURE__ */ t(
97
- Se,
98
- {
99
- contentEditable: /* @__PURE__ */ t(
100
- Ie,
101
- {
102
- "aria-placeholder": "Enter signature name...",
103
- placeholder: /* @__PURE__ */ t("div", { style: {
104
- position: "absolute",
105
- top: "4px",
106
- left: "8px",
107
- right: "8px",
108
- textAlign: "center",
109
- pointerEvents: "none",
110
- color: "hsla(var(--cteditorf47ac10b-foreground) / 0.4)",
111
- fontStyle: "italic"
112
- }, children: "Enter signature name..." }),
113
- className: "signature-caption-editable"
114
- }
115
- ),
116
- ErrorBoundary: Pe
117
- }
118
- ),
119
- /* @__PURE__ */ t(ze, { onChange: () => {
120
- } }),
121
- /* @__PURE__ */ t(Re, {}),
122
- /* @__PURE__ */ t($e, { namespace: _e.namespace })
123
- ]
124
- }
125
- ) });
126
- }
127
- function de(u, p, b) {
128
- return Math.min(Math.max(u, p), b);
129
- }
130
- const c = {
131
- east: 1,
132
- north: 8,
133
- south: 2,
134
- west: 4
135
- };
136
- function Kt({
137
- onResizeStart: u,
138
- onResizeEnd: p,
139
- buttonRef: b,
140
- imageRef: N,
141
- maxWidth: S,
142
- editor: E,
143
- showCaption: F,
144
- setShowCaption: M,
145
- captionsEnabled: L
146
- }) {
147
- const T = H(null), k = H({
148
- priority: "",
149
- value: "default"
150
- }), l = H({
151
- currentHeight: 0,
152
- currentWidth: 0,
153
- direction: 0,
154
- isResizing: !1,
155
- ratio: 0,
156
- startHeight: 0,
157
- startWidth: 0,
158
- startX: 0,
159
- startY: 0
160
- }), f = E.getRootElement(), x = f !== null ? f.getBoundingClientRect().width - 20 : 100, G = f !== null ? f.getBoundingClientRect().height - 20 : 100, m = 100, I = 100, O = (i) => {
161
- const a = i === c.east || i === c.west, o = i === c.north || i === c.south, v = i & c.north && i & c.west || i & c.south && i & c.east, C = a ? "ew" : o ? "ns" : v ? "nwse" : "nesw";
162
- f !== null && f.style.setProperty(
163
- "cursor",
164
- `${C}-resize`,
165
- "important"
166
- ), document.body !== null && (document.body.style.setProperty(
167
- "cursor",
168
- `${C}-resize`,
169
- "important"
170
- ), k.current.value = document.body.style.getPropertyValue(
171
- "-webkit-user-select"
172
- ), k.current.priority = document.body.style.getPropertyPriority(
173
- "-webkit-user-select"
174
- ), document.body.style.setProperty(
175
- "-webkit-user-select",
176
- "none",
177
- "important"
178
- ));
179
- }, W = () => {
180
- f !== null && f.style.setProperty("cursor", "text"), document.body !== null && (document.body.style.setProperty("cursor", "default"), document.body.style.setProperty(
181
- "-webkit-user-select",
182
- k.current.value,
183
- k.current.priority
184
- ));
185
- }, P = (i, a) => {
186
- if (!E.isEditable())
187
- return;
188
- const o = N.current, v = T.current;
189
- if (o !== null && v !== null) {
190
- i.preventDefault();
191
- const { width: C, height: D } = o.getBoundingClientRect(), g = we(o), d = l.current;
192
- d.startWidth = C, d.startHeight = D, d.ratio = C / D, d.currentWidth = C, d.currentHeight = D, d.startX = i.clientX / g, d.startY = i.clientY / g, d.isResizing = !0, d.direction = a, O(a), u(), v.classList.add("image-control-wrapper--resizing"), o.style.height = `${D}px`, o.style.width = `${C}px`, document.addEventListener("pointermove", Q), document.addEventListener("pointerup", n);
193
- }
194
- }, Q = (i) => {
195
- const a = N.current, o = l.current, v = o.direction & (c.east | c.west), C = o.direction & (c.south | c.north);
196
- if (a !== null && o.isResizing) {
197
- const D = we(a);
198
- if (v && C) {
199
- let g = Math.floor(o.startX - i.clientX / D);
200
- g = o.direction & c.east ? -g : g;
201
- const d = de(
202
- o.startWidth + g,
203
- m,
204
- x
205
- ), z = d / o.ratio;
206
- a.style.width = `${d}px`, a.style.height = `${z}px`, o.currentHeight = z, o.currentWidth = d;
207
- } else if (C) {
208
- let g = Math.floor(o.startY - i.clientY / D);
209
- g = o.direction & c.south ? -g : g;
210
- const d = de(
211
- o.startHeight + g,
212
- I,
213
- G
214
- );
215
- a.style.height = `${d}px`, o.currentHeight = d;
216
- } else {
217
- let g = Math.floor(o.startX - i.clientX / D);
218
- g = o.direction & c.east ? -g : g;
219
- const d = de(
220
- o.startWidth + g,
221
- m,
222
- x
223
- );
224
- a.style.width = `${d}px`, o.currentWidth = d;
225
- }
226
- }
227
- }, n = () => {
228
- const i = N.current, a = l.current, o = T.current;
229
- if (i !== null && o !== null && a.isResizing) {
230
- const v = a.currentWidth, C = a.currentHeight;
231
- a.startWidth = 0, a.startHeight = 0, a.ratio = 0, a.startX = 0, a.startY = 0, a.currentWidth = 0, a.currentHeight = 0, a.isResizing = !1, o.classList.remove("image-control-wrapper--resizing"), W(), p(v, C), document.removeEventListener("pointermove", Q), document.removeEventListener("pointerup", n);
232
- }
233
- };
234
- return /* @__PURE__ */ h("div", { ref: T, children: [
235
- !F && L && /* @__PURE__ */ t(
236
- "button",
237
- {
238
- className: "image-caption-button",
239
- ref: b,
240
- onClick: () => {
241
- M(!F);
242
- },
243
- children: "Add Caption"
244
- }
245
- ),
246
- /* @__PURE__ */ t(
247
- "div",
248
- {
249
- className: "image-resizer image-resizer-n",
250
- onPointerDown: (i) => {
251
- P(i, c.north);
252
- }
253
- }
254
- ),
255
- /* @__PURE__ */ t(
256
- "div",
257
- {
258
- className: "image-resizer image-resizer-ne",
259
- onPointerDown: (i) => {
260
- P(i, c.north | c.east);
261
- }
262
- }
263
- ),
264
- /* @__PURE__ */ t(
265
- "div",
266
- {
267
- className: "image-resizer image-resizer-e",
268
- onPointerDown: (i) => {
269
- P(i, c.east);
270
- }
271
- }
272
- ),
273
- /* @__PURE__ */ t(
274
- "div",
275
- {
276
- className: "image-resizer image-resizer-se",
277
- onPointerDown: (i) => {
278
- P(i, c.south | c.east);
279
- }
280
- }
281
- ),
282
- /* @__PURE__ */ t(
283
- "div",
284
- {
285
- className: "image-resizer image-resizer-s",
286
- onPointerDown: (i) => {
287
- P(i, c.south);
288
- }
289
- }
290
- ),
291
- /* @__PURE__ */ t(
292
- "div",
293
- {
294
- className: "image-resizer image-resizer-sw",
295
- onPointerDown: (i) => {
296
- P(i, c.south | c.west);
297
- }
298
- }
299
- ),
300
- /* @__PURE__ */ t(
301
- "div",
302
- {
303
- className: "image-resizer image-resizer-w",
304
- onPointerDown: (i) => {
305
- P(i, c.west);
306
- }
307
- }
308
- ),
309
- /* @__PURE__ */ t(
310
- "div",
311
- {
312
- className: "image-resizer image-resizer-nw",
313
- onPointerDown: (i) => {
314
- P(i, c.north | c.west);
315
- }
316
- }
317
- )
318
- ] });
319
- }
320
- const le = /* @__PURE__ */ new Set(), ve = xt("RIGHT_CLICK_IMAGE_COMMAND");
321
- function Xt(u) {
322
- if (!le.has(u))
323
- throw new Promise((p) => {
324
- const b = new Image();
325
- b.src = u, b.onload = () => {
326
- le.add(u), p(null);
327
- }, b.onerror = () => {
328
- le.add(u);
329
- };
330
- });
331
- }
332
- function Ft({
333
- altText: u,
334
- className: p,
335
- imageRef: b,
336
- src: N,
337
- width: S,
338
- height: E,
339
- maxWidth: F,
340
- onError: M
341
- }) {
342
- return Xt(N), /* @__PURE__ */ t(
343
- "img",
344
- {
345
- className: p || void 0,
346
- src: N,
347
- alt: u,
348
- ref: b,
349
- style: typeof S == "number" && typeof E == "number" ? {
350
- // User has set a numeric size or original dimensions are provided
351
- width: typeof S == "number" ? S : "auto",
352
- height: typeof E == "number" ? E : "auto",
353
- maxWidth: "100%"
354
- } : {
355
- // No dimensions specified - use original image size
356
- maxWidth: "100%",
357
- height: "auto"
358
- },
359
- onError: M,
360
- draggable: "false"
361
- }
362
- );
363
- }
364
- function Gt() {
365
- return /* @__PURE__ */ t(
366
- "img",
367
- {
368
- src: "",
369
- style: {
370
- height: 200,
371
- opacity: 0.2,
372
- width: 200
373
- },
374
- draggable: "false"
375
- }
376
- );
377
- }
378
- function gr({
379
- src: u,
380
- altText: p,
381
- nodeKey: b,
382
- width: N,
383
- height: S,
384
- maxWidth: E,
385
- resizable: F,
386
- showCaption: M,
387
- caption: L,
388
- captionsEnabled: T,
389
- originalPrompt: k,
390
- position: l = "none",
391
- linkUrl: f
392
- }) {
393
- const x = H(null), G = H(null), [m, I, O] = dt(b), [W, P] = R(!1), { isCollabActive: Q } = ct(), [n] = at(), [i, a] = R(null), o = H(null), [v, C] = R(!1), D = st(), [g, d] = R(!1), [z, U] = R(""), [j, ue] = R(!1), [Oe, Z] = R(!1), [me, ee] = R(""), [He, te] = R(""), [Te, ge] = R(!1), B = H(null), [he, je] = R(0), Be = he > 0 && he < 350;
394
- se(() => {
395
- if (x.current) {
396
- const e = () => {
397
- x.current && je(x.current.offsetWidth);
398
- };
399
- e();
400
- const r = new ResizeObserver(e);
401
- return r.observe(x.current), () => r.disconnect();
402
- }
403
- }, [N, S, m]);
404
- const re = A(
405
- (e) => {
406
- const r = V();
407
- return m && K(r) && (e.preventDefault(), n.update(() => {
408
- r.getNodes().forEach((y) => {
409
- if (X(y)) {
410
- const w = y.getParent();
411
- y.remove(), w && Ce(w) && w.getChildrenSize() === 0 && w.setFormat("left");
412
- }
413
- });
414
- })), !1;
415
- },
416
- [n, m]
417
- ), fe = A(
418
- (e) => {
419
- const r = V(), s = G.current;
420
- if (m && K(r) && r.getNodes().length === 1) {
421
- if (M)
422
- return ae(null), e.preventDefault(), L.focus(), !0;
423
- if (s !== null && s !== document.activeElement)
424
- return e.preventDefault(), s.focus(), !0;
425
- }
426
- return !1;
427
- },
428
- [L, m, M]
429
- ), pe = A(
430
- (e) => o.current === L || G.current === e.target ? (ae(null), n.update(() => {
431
- I(!0);
432
- const r = n.getRootElement();
433
- r !== null && r.focus();
434
- }), !0) : !1,
435
- [L, n, I]
436
- ), ie = A(
437
- (e) => {
438
- const r = e;
439
- if (W)
440
- return !0;
441
- const y = r.target === x.current;
442
- let w = !1;
443
- if (!y && x.current) {
444
- const q = x.current.getBoundingClientRect();
445
- w = r.clientX >= q.left && r.clientX <= q.right && r.clientY >= q.top && r.clientY <= q.bottom;
446
- }
447
- return y || w ? (r.shiftKey ? I(!m) : (O(), I(!0)), !0) : !1;
448
- },
449
- [W, m, I, O]
450
- ), oe = A(
451
- (e) => {
452
- n.getEditorState().read(() => {
453
- const r = V();
454
- e.target.tagName === "IMG" && ut(r) && r.getNodes().length === 1 && n.dispatchCommand(
455
- ve,
456
- e
457
- );
458
- });
459
- },
460
- [n]
461
- );
462
- se(() => {
463
- let e = !0;
464
- const r = n.getRootElement(), s = lt(
465
- n.registerUpdateListener(({ editorState: y }) => {
466
- e && a(y.read(() => V()));
467
- }),
468
- n.registerCommand(
469
- mt,
470
- (y, w) => (o.current = w, !1),
471
- $
472
- ),
473
- n.registerCommand(
474
- gt,
475
- ie,
476
- $
477
- ),
478
- n.registerCommand(
479
- ve,
480
- ie,
481
- $
482
- ),
483
- n.registerCommand(
484
- ht,
485
- (y) => y.target === x.current ? (y.preventDefault(), !0) : !1,
486
- $
487
- ),
488
- n.registerCommand(
489
- ft,
490
- re,
491
- $
492
- ),
493
- n.registerCommand(
494
- pt,
495
- re,
496
- $
497
- ),
498
- n.registerCommand(bt, fe, $),
499
- n.registerCommand(
500
- yt,
501
- pe,
502
- $
503
- )
504
- );
505
- return r?.addEventListener("contextmenu", oe), () => {
506
- e = !1, s(), r?.removeEventListener("contextmenu", oe);
507
- };
508
- }, [
509
- O,
510
- n,
511
- W,
512
- m,
513
- b,
514
- re,
515
- fe,
516
- pe,
517
- ie,
518
- oe,
519
- I
520
- ]);
521
- const Ye = () => {
522
- n.update(() => {
523
- const e = J(b);
524
- X(e) && e.setShowCaption(!0);
525
- });
526
- }, Ke = (e, r) => {
527
- setTimeout(() => {
528
- P(!1);
529
- }, 200), n.update(() => {
530
- const s = J(b);
531
- X(s) && s.setWidthAndHeight(e, r);
532
- });
533
- }, Xe = () => {
534
- P(!0);
535
- }, Fe = (e) => {
536
- if (e.preventDefault(), e.stopPropagation(), u.startsWith("data:")) {
537
- const r = window.open("", "_blank");
538
- r && (r.document.write(`
539
- <!DOCTYPE html>
540
- <html>
541
- <head>
542
- <title>${p || "Image"}</title>
543
- <style>
544
- body {
545
- margin: 0;
546
- display: flex;
547
- justify-content: center;
548
- align-items: center;
549
- min-height: 100vh;
550
- background-color: #1a1a1a;
551
- }
552
- img {
553
- max-width: 100%;
554
- max-height: 100vh;
555
- object-fit: contain;
556
- }
557
- </style>
558
- </head>
559
- <body>
560
- <img src="${u}" alt="${p || "Image"}" />
561
- </body>
562
- </html>
563
- `), r.document.close());
564
- } else
565
- window.open(u, "_blank");
566
- }, Ge = (e) => {
567
- e.preventDefault(), e.stopPropagation(), n.update(() => {
568
- const r = J(b);
569
- if (X(r)) {
570
- const s = r.getParent();
571
- r.remove(), s && Ce(s) && s.getChildrenSize() === 0 && s.setFormat("left");
572
- }
573
- });
574
- }, Y = (e, r) => {
575
- e.preventDefault(), e.stopPropagation(), n.update(() => {
576
- const s = J(b);
577
- X(s) && s.setPosition(r);
578
- });
579
- }, qe = (e) => {
580
- e.preventDefault(), e.stopPropagation(), d(!g);
581
- }, Ve = A(() => {
582
- f && !m && (B.current = setTimeout(() => {
583
- ge(!0);
584
- }, 300));
585
- }, [f, m]), Je = A(() => {
586
- B.current && (clearTimeout(B.current), B.current = null), ge(!1);
587
- }, []), be = A((e) => {
588
- e.preventDefault(), e.stopPropagation(), f && window.open(f, "_blank", "noopener,noreferrer");
589
- }, [f]);
590
- se(() => () => {
591
- B.current && clearTimeout(B.current);
592
- }, []);
593
- const ye = async () => {
594
- if (!z.trim() || j) return;
595
- ue(!0);
596
- const e = _.loading("Refining image...", {
597
- description: "This may take 10-30 seconds. Please wait."
598
- });
599
- try {
600
- let r = z.trim();
601
- if (k && k.trim()) {
602
- const ce = k.trim(), it = z.trim().replace(/^(add|also add|include|with|and)\s+(some|a|an)\s+/gi, "").replace(/^(add|also add|include|with|and)\s+/gi, "").trim();
603
- r = `${ce} with ${it}`;
604
- } else if (p && p !== "Generated image" && p.trim()) {
605
- const ce = z.trim().replace(/^(add|also add|include|with|and)\s+(some|a|an)\s+/gi, "").replace(/^(add|also add|include|with|and)\s+/gi, "").trim();
606
- r = `${p} with ${ce}`;
607
- }
608
- const y = (await Ot({
609
- content: `Generate Image: ${r}`
610
- }))?.data;
611
- if (!y)
612
- throw new Error("Failed to generate image - empty response");
613
- const ne = new DOMParser().parseFromString(y, "text/html").querySelector("img");
614
- if (!ne || !ne.src)
615
- throw new Error("No image found in response");
616
- const rt = ne.src;
617
- _.dismiss(e), _.success("Image refined successfully!", {
618
- description: "Compare the images and choose which to keep."
619
- }), ee(rt), te(r), Z(!0), U(""), d(!1);
620
- } catch (r) {
621
- if (_.dismiss(e), r instanceof Ht) {
622
- const s = r.code === "API_KEYS_DISABLED" ? "API Keys Disabled" : "API Key Required";
623
- _.error(s, {
624
- description: r.message,
625
- duration: 8e3
626
- });
627
- } else r instanceof Tt ? _.error("Credits Issue", {
628
- description: r.message,
629
- duration: 8e3
630
- }) : _.error("Failed to refine image", {
631
- description: r instanceof Error ? r.message : "Unknown error. Please try again."
632
- });
633
- } finally {
634
- ue(!1);
635
- }
636
- }, Ue = () => {
637
- n.update(() => {
638
- const e = J(b);
639
- if (X(e)) {
640
- e.setSrc(me), e.setOriginalPrompt(He);
641
- const r = V();
642
- r && ae(r.clone());
643
- }
644
- }), Z(!1), ee(""), te(""), _.success("Image replaced successfully!", {
645
- description: "The image has been updated with the refined version."
646
- });
647
- }, Ze = () => {
648
- Z(!1), ee(""), te("");
649
- }, Qe = m && K(i) && !W, xe = (m || W) && D, et = () => l === "left" || l === "right" ? {
650
- position: "relative",
651
- display: "block",
652
- width: "100%"
653
- // Fill the floated container
654
- } : l === "full" ? {
655
- position: "relative",
656
- display: "inline-block"
657
- // Use inline-block to respect text-align: center from parent
658
- } : l === "inline-left" || l === "inline-center" || l === "inline-right" ? {
659
- position: "relative",
660
- display: "inline-block"
661
- // Use inline-block to respect text-align from parent
662
- } : {
663
- position: "relative",
664
- display: "inline-block"
665
- }, tt = A(
666
- (e) => {
667
- if (W || e.target.closest("button"))
668
- return;
669
- const s = e.target === x.current;
670
- let y = !1;
671
- if (!s && x.current) {
672
- const w = x.current.getBoundingClientRect();
673
- y = e.clientX >= w.left && e.clientX <= w.right && e.clientY >= w.top && e.clientY <= w.bottom;
674
- }
675
- !s && !y || (e.stopPropagation(), e.shiftKey ? I(!m) : (O(), I(!0)));
676
- },
677
- [W, m, I, O]
678
- );
679
- return /* @__PURE__ */ t(wt, { fallback: null, children: /* @__PURE__ */ h(ot, { children: [
680
- /* @__PURE__ */ h(
681
- "div",
682
- {
683
- draggable: Qe,
684
- style: et(),
685
- onClick: tt,
686
- onMouseEnter: Ve,
687
- onMouseLeave: Je,
688
- children: [
689
- v ? /* @__PURE__ */ t(Gt, {}) : /* @__PURE__ */ t(
690
- Ft,
691
- {
692
- className: xe ? `focused ${K(i) ? "draggable" : ""}` : f ? "cteditor-cursor-pointer" : null,
693
- src: u,
694
- altText: p,
695
- imageRef: x,
696
- width: N,
697
- height: S,
698
- maxWidth: E,
699
- onError: () => C(!0)
700
- }
701
- ),
702
- Te && f && !m && /* @__PURE__ */ h(
703
- "div",
704
- {
705
- className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-lg cteditor-border cteditor-border-border cteditor-p-2 cteditor-flex cteditor-items-center cteditor-gap-2",
706
- style: { zIndex: 10 },
707
- children: [
708
- /* @__PURE__ */ t(jt, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground cteditor-flex-shrink-0" }),
709
- /* @__PURE__ */ t("span", { className: "cteditor-text-sm cteditor-text-foreground cteditor-truncate cteditor-flex-1", children: f }),
710
- /* @__PURE__ */ t(
711
- "button",
712
- {
713
- onClick: be,
714
- className: "cteditor-px-2 cteditor-py-1.5 cteditor-text-xs cteditor-rounded cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors cteditor-flex-shrink-0",
715
- children: "Open"
716
- }
717
- )
718
- ]
719
- }
720
- ),
721
- m && K(i) && !v && /* @__PURE__ */ h(
722
- "div",
723
- {
724
- className: `cteditor-absolute cteditor-flex cteditor-gap-1 z-10 ${Be ? "cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-bottom-0 cteditor-translate-y-full cteditor-mt-1" : "cteditor-top-2 cteditor-right-2"}`,
725
- children: [
726
- /* @__PURE__ */ h("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-0.5 cteditor-bg-background/80 cteditor-rounded-md cteditor-shadow-md cteditor-border cteditor-border-border cteditor-p-0.5", children: [
727
- /* @__PURE__ */ t(
728
- "button",
729
- {
730
- onClick: (e) => Y(e, "left"),
731
- className: ` cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${l === "left" ? "cteditor-bg-accent" : ""}`,
732
- "aria-label": "Wrap text left",
733
- title: "Wrap text left",
734
- children: /* @__PURE__ */ t(Rt, {})
735
- }
736
- ),
737
- /* @__PURE__ */ t(
738
- "button",
739
- {
740
- onClick: (e) => Y(e, "right"),
741
- className: ` cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${l === "right" ? "cteditor-bg-accent" : ""}`,
742
- "aria-label": "Wrap text right",
743
- title: "Wrap text right",
744
- children: /* @__PURE__ */ t(Dt, {})
745
- }
746
- ),
747
- /* @__PURE__ */ t("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
748
- /* @__PURE__ */ t(
749
- "button",
750
- {
751
- onClick: (e) => Y(e, "inline-left"),
752
- className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${l === "inline-left" ? "cteditor-bg-accent" : ""}`,
753
- "aria-label": "Align left",
754
- title: "Align left (no text wrap)",
755
- children: /* @__PURE__ */ t(zt, {})
756
- }
757
- ),
758
- /* @__PURE__ */ t(
759
- "button",
760
- {
761
- onClick: (e) => Y(e, "inline-center"),
762
- className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${l === "inline-center" || l === "full" ? "cteditor-bg-accent" : ""}`,
763
- "aria-label": "Align center",
764
- title: "Align center (no text wrap)",
765
- children: /* @__PURE__ */ t(St, {})
766
- }
767
- ),
768
- /* @__PURE__ */ t(
769
- "button",
770
- {
771
- onClick: (e) => Y(e, "inline-right"),
772
- className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${l === "inline-right" ? "cteditor-bg-accent" : ""}`,
773
- "aria-label": "Align right",
774
- title: "Align right (no text wrap)",
775
- children: /* @__PURE__ */ t(Lt, {})
776
- }
777
- ),
778
- /* @__PURE__ */ t("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
779
- /* @__PURE__ */ t(
780
- "button",
781
- {
782
- onClick: (e) => Y(e, "none"),
783
- className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${l === "none" ? "cteditor-bg-accent" : ""}`,
784
- "aria-label": "Inline",
785
- title: "Inline with text",
786
- children: /* @__PURE__ */ t(Wt, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
787
- }
788
- )
789
- ] }),
790
- f && /* @__PURE__ */ t(
791
- "button",
792
- {
793
- onClick: be,
794
- className: " cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
795
- "aria-label": "Visit link",
796
- title: `Visit: ${f}`,
797
- children: /* @__PURE__ */ t(At, {})
798
- }
799
- ),
800
- k && /* @__PURE__ */ t(
801
- "button",
802
- {
803
- onClick: (e) => {
804
- e.stopPropagation(), qe(e);
805
- },
806
- className: " cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
807
- "aria-label": "Refine image",
808
- title: "Refine image",
809
- children: /* @__PURE__ */ t(Mt, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
810
- }
811
- ),
812
- /* @__PURE__ */ t(
813
- "button",
814
- {
815
- onClick: (e) => {
816
- e.stopPropagation(), Fe(e);
817
- },
818
- className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
819
- "aria-label": "Open image in new tab",
820
- title: "Open in new tab",
821
- children: /* @__PURE__ */ t($t, {})
822
- }
823
- ),
824
- /* @__PURE__ */ t(
825
- "button",
826
- {
827
- onClick: (e) => {
828
- e.stopPropagation(), Ge(e);
829
- },
830
- className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
831
- "aria-label": "Delete image",
832
- title: "Delete image",
833
- children: /* @__PURE__ */ t(_t, {})
834
- }
835
- )
836
- ]
837
- }
838
- ),
839
- g && m && !v && k && /* @__PURE__ */ t(
840
- "div",
841
- {
842
- className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-xl cteditor-border cteditor-border-border cteditor-p-3",
843
- style: { zIndex: 10 },
844
- onClick: (e) => e.stopPropagation(),
845
- onKeyDown: (e) => e.stopPropagation(),
846
- onKeyUp: (e) => e.stopPropagation(),
847
- children: /* @__PURE__ */ h("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-2", children: [
848
- /* @__PURE__ */ t("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "What else do you want in this scene?" }),
849
- /* @__PURE__ */ t(
850
- "input",
851
- {
852
- type: "text",
853
- value: z,
854
- onChange: (e) => U(e.target.value),
855
- onKeyDown: (e) => {
856
- e.stopPropagation(), e.key === "Enter" && z.trim() && !j && ye(), e.key === "Escape" && (d(!1), U(""));
857
- },
858
- onKeyUp: (e) => {
859
- e.stopPropagation();
860
- },
861
- onClick: (e) => {
862
- e.stopPropagation();
863
- },
864
- placeholder: "e.g., flying birds, golden sunset, stormy clouds...",
865
- className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-border cteditor-border-border cteditor-rounded-md cteditor-bg-background cteditor-text-foreground focus:cteditor-outline-none focus:cteditor-ring-2 focus:cteditor-ring-blue-500",
866
- disabled: j,
867
- autoFocus: !0
868
- }
869
- ),
870
- /* @__PURE__ */ h("div", { className: "cteditor-flex cteditor-gap-2", children: [
871
- /* @__PURE__ */ t(
872
- "button",
873
- {
874
- onClick: (e) => {
875
- e.stopPropagation(), ye();
876
- },
877
- disabled: j || !z.trim(),
878
- className: "cteditor-flex-1 cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-blue-500 cteditor-text-white hover:cteditor-bg-blue-600 disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors",
879
- children: j ? /* @__PURE__ */ h("span", { className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-2", children: [
880
- /* @__PURE__ */ t("span", { className: "cteditor-inline-block cteditor-w-4 cteditor-h-4 cteditor-border-2 cteditor-border-white cteditor-border-t-transparent cteditor-rounded-full cteditor-animate-spin" }),
881
- "Refining..."
882
- ] }) : "Refine Image"
883
- }
884
- ),
885
- /* @__PURE__ */ t(
886
- "button",
887
- {
888
- onClick: (e) => {
889
- e.stopPropagation(), d(!1), U("");
890
- },
891
- disabled: j,
892
- className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors",
893
- children: "Cancel"
894
- }
895
- )
896
- ] })
897
- ] })
898
- }
899
- ),
900
- F && K(i) && xe && /* @__PURE__ */ t(
901
- Kt,
902
- {
903
- showCaption: M,
904
- setShowCaption: Ye,
905
- editor: n,
906
- buttonRef: G,
907
- imageRef: x,
908
- maxWidth: E,
909
- onResizeStart: Xe,
910
- onResizeEnd: Ke,
911
- captionsEnabled: !v && T
912
- }
913
- )
914
- ]
915
- }
916
- ),
917
- M && (p.startsWith("Signature by") ? /* @__PURE__ */ t(Yt, { caption: L }) : /* @__PURE__ */ t(
918
- "div",
919
- {
920
- className: "image-caption-container",
921
- style: {
922
- width: typeof N == "number" ? `${N}px` : "100%",
923
- maxWidth: "100%",
924
- // Match the image's alignment
925
- ...l === "inline-center" || l === "full" ? { margin: "0 auto" } : l === "inline-right" ? { marginLeft: "auto" } : l === "left" ? { float: "left", clear: "left" } : l === "right" ? { float: "right", clear: "right" } : {}
926
- },
927
- children: /* @__PURE__ */ h(
928
- De,
929
- {
930
- initialEditor: L,
931
- initialNodes: [
932
- Le,
933
- We,
934
- Ae,
935
- Me,
936
- ke,
937
- Ee
938
- ],
939
- children: [
940
- /* @__PURE__ */ t(nt, {}),
941
- /* @__PURE__ */ t(
942
- Se,
943
- {
944
- contentEditable: /* @__PURE__ */ t(
945
- Ie,
946
- {
947
- "aria-placeholder": "Enter a caption...",
948
- placeholder: () => /* @__PURE__ */ t("span", { className: "cteditor-text-xs", children: "Enter a caption..." }),
949
- className: "ImageNode__contentEditable"
950
- }
951
- ),
952
- ErrorBoundary: Pe
953
- }
954
- ),
955
- /* @__PURE__ */ t(
956
- ze,
957
- {
958
- onChange: () => {
959
- }
960
- }
961
- ),
962
- /* @__PURE__ */ t(Re, {}),
963
- /* @__PURE__ */ t($e, { namespace: _e.namespace })
964
- ]
965
- }
966
- )
967
- }
968
- )),
969
- /* @__PURE__ */ t(
970
- Bt,
971
- {
972
- open: Oe,
973
- onOpenChange: Z,
974
- oldImageUrl: u,
975
- newImageUrl: me,
976
- onReplace: Ue,
977
- onCancel: Ze
978
- }
979
- )
980
- ] }) });
981
- }
982
- export {
983
- ve as RIGHT_CLICK_IMAGE_COMMAND,
984
- gr as default
985
- };