@nookuio/iframe 0.9.8 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export const EDITOR_PAGE_PATH="/__nooku__/editor",COMPONENT_PREVIEW_PAGE_PATH="/__nooku__/component-preview",VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH="/__nooku__/virtual-sfc-editor",IFRAME_SOURCE_NAME="nooku-frame",EDITOR_SOURCE_NAME="nooku-editor";
1
+ export const EDITOR_PAGE_PATH = "/__nooku__/editor", COMPONENT_PREVIEW_PAGE_PATH = "/__nooku__/component-preview", VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH = "/__nooku__/virtual-sfc-editor", IFRAME_SOURCE_NAME = "nooku-frame", EDITOR_SOURCE_NAME = "nooku-editor";
@@ -0,0 +1,101 @@
1
+ import type { DragDropContext } from './types';
2
+ /**
3
+ * Drag and drop manager for iframe
4
+ * Manages drag state and provides methods for RPC communication
5
+ */
6
+ export declare class DragDropManager {
7
+ private activeDrags;
8
+ private dropIndicator;
9
+ private onDragStartCallback?;
10
+ private onDragEndCallback?;
11
+ constructor();
12
+ /**
13
+ * Set event callbacks
14
+ */
15
+ setCallbacks(callbacks: {
16
+ onDragStart?: (data: {
17
+ elementId: string;
18
+ path: string;
19
+ }) => void;
20
+ onDragEnd?: (data: {
21
+ dropped: boolean;
22
+ targetId?: string;
23
+ }) => void;
24
+ }): void;
25
+ /**
26
+ * Start dragging an element
27
+ */
28
+ startDrag(options: {
29
+ elementId: string;
30
+ path: string;
31
+ x: number;
32
+ y: number;
33
+ }): Promise<{
34
+ dragId: string;
35
+ }>;
36
+ /**
37
+ * Update drag position
38
+ */
39
+ updateDragPosition(options: {
40
+ dragId: string;
41
+ x: number;
42
+ y: number;
43
+ }): Promise<void>;
44
+ /**
45
+ * End drag operation
46
+ */
47
+ endDrag(options: {
48
+ dragId: string;
49
+ canceled?: boolean;
50
+ }): Promise<{
51
+ dropped: boolean;
52
+ targetId?: string;
53
+ targetPath?: string;
54
+ insertIndex?: number;
55
+ }>;
56
+ /**
57
+ * Get drop zones at position
58
+ */
59
+ getDropZones(options: {
60
+ x: number;
61
+ y: number;
62
+ }): Promise<Array<{
63
+ elementId: string;
64
+ path: string;
65
+ rect: {
66
+ top: number;
67
+ left: number;
68
+ width: number;
69
+ height: number;
70
+ };
71
+ canDrop: boolean;
72
+ }>>;
73
+ /**
74
+ * Highlight drop zone
75
+ */
76
+ highlightDropZone(options: {
77
+ elementId?: string;
78
+ path?: string;
79
+ clear?: boolean;
80
+ }): Promise<void>;
81
+ /**
82
+ * Find drop zone at position
83
+ */
84
+ private findDropZoneAtPosition;
85
+ /**
86
+ * Show drop indicator
87
+ */
88
+ private showDropIndicator;
89
+ /**
90
+ * Hide drop indicator
91
+ */
92
+ private hideDropIndicator;
93
+ /**
94
+ * Clean up
95
+ */
96
+ destroy(): void;
97
+ }
98
+ /**
99
+ * Create drag-drop context for iframe client
100
+ */
101
+ export declare function createDragDropContext(): DragDropContext;
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DragDropManager = void 0;
7
+ exports.createDragDropContext = createDragDropContext;
8
+ var _utils = require("./utils");
9
+ class DragDropManager {
10
+ activeDrags = new Map();
11
+ dropIndicator = null;
12
+ onDragStartCallback;
13
+ onDragEndCallback;
14
+ constructor() {
15
+ this.dropIndicator = (0, _utils.createDropIndicator)();
16
+ }
17
+ setCallbacks(r) {
18
+ this.onDragStartCallback = r.onDragStart, this.onDragEndCallback = r.onDragEnd;
19
+ }
20
+ async startDrag(r) {
21
+ const {
22
+ elementId: o,
23
+ path: i,
24
+ x: n,
25
+ y: t
26
+ } = r,
27
+ e = (0, _utils.getElement)(o, i);
28
+ if (!e) throw new Error(`Element not found: ${o} at ${i}`);
29
+ const a = `drag-${Date.now()}-${Math.random()}`,
30
+ d = {
31
+ dragId: a,
32
+ elementId: o,
33
+ path: i,
34
+ startX: n,
35
+ startY: t,
36
+ currentX: n,
37
+ currentY: t,
38
+ element: e
39
+ };
40
+ return this.activeDrags.set(a, d), e.classList.add("__nooku-dragging"), e.style.opacity = "0.5", this.onDragStartCallback?.({
41
+ elementId: o,
42
+ path: i
43
+ }), {
44
+ dragId: a
45
+ };
46
+ }
47
+ async updateDragPosition(r) {
48
+ const {
49
+ dragId: o,
50
+ x: i,
51
+ y: n
52
+ } = r,
53
+ t = this.activeDrags.get(o);
54
+ if (!t) throw new Error(`Drag not found: ${o}`);
55
+ t.currentX = i, t.currentY = n;
56
+ const e = this.findDropZoneAtPosition(i, n, t.path);
57
+ e !== t.currentDropZone ? (t.currentDropZone && t.currentDropZone.classList.remove("__nooku-drop-zone-active"), t.currentDropZone = e, e ? (e.classList.add("__nooku-drop-zone-active"), this.showDropIndicator(e, i, n)) : this.hideDropIndicator()) : e && this.showDropIndicator(e, i, n);
58
+ }
59
+ async endDrag(r) {
60
+ const {
61
+ dragId: o,
62
+ canceled: i = !1
63
+ } = r,
64
+ n = this.activeDrags.get(o);
65
+ if (!n) throw new Error(`Drag not found: ${o}`);
66
+ n.element.classList.remove("__nooku-dragging"), n.element.style.opacity = "", n.currentDropZone && n.currentDropZone.classList.remove("__nooku-drop-zone-active"), this.hideDropIndicator();
67
+ let t;
68
+ if (i || !n.currentDropZone) t = {
69
+ dropped: !1
70
+ };else {
71
+ const e = n.currentDropZone.getAttribute("data-node-id") || void 0,
72
+ a = n.currentDropZone.getAttribute("data-node-path") || void 0,
73
+ {
74
+ index: d
75
+ } = (0, _utils.calculateInsertIndex)(n.currentDropZone, n.currentX, n.currentY);
76
+ t = {
77
+ dropped: !0,
78
+ targetId: e,
79
+ targetPath: a,
80
+ insertIndex: d
81
+ };
82
+ }
83
+ return this.activeDrags.delete(o), this.onDragEndCallback?.(t), t;
84
+ }
85
+ async getDropZones(r) {
86
+ const {
87
+ x: o,
88
+ y: i
89
+ } = r;
90
+ return (0, _utils.getDropZones)().map(t => {
91
+ const e = t.getBoundingClientRect(),
92
+ a = t.getAttribute("data-node-id") || "",
93
+ d = t.getAttribute("data-node-path") || "",
94
+ u = o >= e.left && o <= e.right && i >= e.top && i <= e.bottom;
95
+ return {
96
+ elementId: a,
97
+ path: d,
98
+ rect: {
99
+ top: e.top,
100
+ left: e.left,
101
+ width: e.width,
102
+ height: e.height
103
+ },
104
+ canDrop: u && (0, _utils.canAcceptDrop)(t)
105
+ };
106
+ }).filter(t => t.canDrop);
107
+ }
108
+ async highlightDropZone(r) {
109
+ const {
110
+ elementId: o,
111
+ path: i,
112
+ clear: n = !1
113
+ } = r;
114
+ if (document.querySelectorAll(".__nooku-drop-zone-highlight").forEach(e => {
115
+ e.classList.remove("__nooku-drop-zone-highlight");
116
+ }), n || !o || !i) {
117
+ this.hideDropIndicator();
118
+ return;
119
+ }
120
+ const t = (0, _utils.getElement)(o, i);
121
+ t && t.classList.add("__nooku-drop-zone-highlight");
122
+ }
123
+ findDropZoneAtPosition(r, o, i) {
124
+ const n = (0, _utils.getElementAtPosition)(r, o, i);
125
+ if (!n) return;
126
+ let t = n;
127
+ for (; t;) {
128
+ if (t.hasAttribute("data-node-id") && (0, _utils.canAcceptDrop)(t)) return t;
129
+ t = t.parentElement;
130
+ }
131
+ }
132
+ showDropIndicator(r, o, i) {
133
+ this.dropIndicator || (this.dropIndicator = (0, _utils.createDropIndicator)()), this.dropIndicator.parentElement || document.body.appendChild(this.dropIndicator);
134
+ const {
135
+ index: n,
136
+ before: t
137
+ } = (0, _utils.calculateInsertIndex)(r, o, i),
138
+ e = Array.from(r.children).filter(a => a.hasAttribute("data-node-id"));
139
+ if (e.length === 0) {
140
+ const a = r.getBoundingClientRect();
141
+ (0, _utils.positionDropIndicator)(this.dropIndicator, a, "block");
142
+ } else if (n < e.length) {
143
+ const d = e[n].getBoundingClientRect();
144
+ (0, _utils.positionDropIndicator)(this.dropIndicator, {
145
+ ...d,
146
+ height: 3
147
+ }, "block");
148
+ } else {
149
+ const d = e[e.length - 1].getBoundingClientRect();
150
+ (0, _utils.positionDropIndicator)(this.dropIndicator, {
151
+ ...d,
152
+ top: d.bottom,
153
+ height: 3
154
+ }, "block");
155
+ }
156
+ this.dropIndicator.style.display = "block";
157
+ }
158
+ hideDropIndicator() {
159
+ this.dropIndicator && (this.dropIndicator.style.display = "none");
160
+ }
161
+ destroy() {
162
+ this.activeDrags.clear(), this.dropIndicator?.remove(), this.dropIndicator = null;
163
+ }
164
+ }
165
+ exports.DragDropManager = DragDropManager;
166
+ function createDragDropContext() {
167
+ const s = new DragDropManager();
168
+ return {
169
+ startDrag: r => s.startDrag(r),
170
+ updateDragPosition: r => s.updateDragPosition(r),
171
+ endDrag: r => s.endDrag(r),
172
+ getDropZones: r => s.getDropZones(r),
173
+ highlightDropZone: r => s.highlightDropZone(r)
174
+ };
175
+ }
@@ -0,0 +1,163 @@
1
+ import {
2
+ getElement as g,
3
+ getDropZones as D,
4
+ canAcceptDrop as l,
5
+ getElementAtPosition as m,
6
+ calculateInsertIndex as p,
7
+ createDropIndicator as h,
8
+ positionDropIndicator as c
9
+ } from "./utils.mjs";
10
+ export class DragDropManager {
11
+ activeDrags = /* @__PURE__ */ new Map();
12
+ dropIndicator = null;
13
+ onDragStartCallback;
14
+ onDragEndCallback;
15
+ constructor() {
16
+ this.dropIndicator = h();
17
+ }
18
+ /**
19
+ * Set event callbacks
20
+ */
21
+ setCallbacks(r) {
22
+ this.onDragStartCallback = r.onDragStart, this.onDragEndCallback = r.onDragEnd;
23
+ }
24
+ /**
25
+ * Start dragging an element
26
+ */
27
+ async startDrag(r) {
28
+ const { elementId: o, path: i, x: n, y: t } = r, e = g(o, i);
29
+ if (!e)
30
+ throw new Error(`Element not found: ${o} at ${i}`);
31
+ const a = `drag-${Date.now()}-${Math.random()}`, d = {
32
+ dragId: a,
33
+ elementId: o,
34
+ path: i,
35
+ startX: n,
36
+ startY: t,
37
+ currentX: n,
38
+ currentY: t,
39
+ element: e
40
+ };
41
+ return this.activeDrags.set(a, d), e.classList.add("__nooku-dragging"), e.style.opacity = "0.5", this.onDragStartCallback?.({ elementId: o, path: i }), { dragId: a };
42
+ }
43
+ /**
44
+ * Update drag position
45
+ */
46
+ async updateDragPosition(r) {
47
+ const { dragId: o, x: i, y: n } = r, t = this.activeDrags.get(o);
48
+ if (!t)
49
+ throw new Error(`Drag not found: ${o}`);
50
+ t.currentX = i, t.currentY = n;
51
+ const e = this.findDropZoneAtPosition(i, n, t.path);
52
+ e !== t.currentDropZone ? (t.currentDropZone && t.currentDropZone.classList.remove("__nooku-drop-zone-active"), t.currentDropZone = e, e ? (e.classList.add("__nooku-drop-zone-active"), this.showDropIndicator(e, i, n)) : this.hideDropIndicator()) : e && this.showDropIndicator(e, i, n);
53
+ }
54
+ /**
55
+ * End drag operation
56
+ */
57
+ async endDrag(r) {
58
+ const { dragId: o, canceled: i = !1 } = r, n = this.activeDrags.get(o);
59
+ if (!n)
60
+ throw new Error(`Drag not found: ${o}`);
61
+ n.element.classList.remove("__nooku-dragging"), n.element.style.opacity = "", n.currentDropZone && n.currentDropZone.classList.remove("__nooku-drop-zone-active"), this.hideDropIndicator();
62
+ let t;
63
+ if (i || !n.currentDropZone)
64
+ t = { dropped: !1 };
65
+ else {
66
+ const e = n.currentDropZone.getAttribute("data-node-id") || void 0, a = n.currentDropZone.getAttribute("data-node-path") || void 0, { index: d } = p(n.currentDropZone, n.currentX, n.currentY);
67
+ t = {
68
+ dropped: !0,
69
+ targetId: e,
70
+ targetPath: a,
71
+ insertIndex: d
72
+ };
73
+ }
74
+ return this.activeDrags.delete(o), this.onDragEndCallback?.(t), t;
75
+ }
76
+ /**
77
+ * Get drop zones at position
78
+ */
79
+ async getDropZones(r) {
80
+ const { x: o, y: i } = r;
81
+ return D().map((t) => {
82
+ const e = t.getBoundingClientRect(), a = t.getAttribute("data-node-id") || "", d = t.getAttribute("data-node-path") || "", u = o >= e.left && o <= e.right && i >= e.top && i <= e.bottom;
83
+ return {
84
+ elementId: a,
85
+ path: d,
86
+ rect: {
87
+ top: e.top,
88
+ left: e.left,
89
+ width: e.width,
90
+ height: e.height
91
+ },
92
+ canDrop: u && l(t)
93
+ };
94
+ }).filter((t) => t.canDrop);
95
+ }
96
+ /**
97
+ * Highlight drop zone
98
+ */
99
+ async highlightDropZone(r) {
100
+ const { elementId: o, path: i, clear: n = !1 } = r;
101
+ if (document.querySelectorAll(".__nooku-drop-zone-highlight").forEach((e) => {
102
+ e.classList.remove("__nooku-drop-zone-highlight");
103
+ }), n || !o || !i) {
104
+ this.hideDropIndicator();
105
+ return;
106
+ }
107
+ const t = g(o, i);
108
+ t && t.classList.add("__nooku-drop-zone-highlight");
109
+ }
110
+ /**
111
+ * Find drop zone at position
112
+ */
113
+ findDropZoneAtPosition(r, o, i) {
114
+ const n = m(r, o, i);
115
+ if (!n) return;
116
+ let t = n;
117
+ for (; t; ) {
118
+ if (t.hasAttribute("data-node-id") && l(t))
119
+ return t;
120
+ t = t.parentElement;
121
+ }
122
+ }
123
+ /**
124
+ * Show drop indicator
125
+ */
126
+ showDropIndicator(r, o, i) {
127
+ this.dropIndicator || (this.dropIndicator = h()), this.dropIndicator.parentElement || document.body.appendChild(this.dropIndicator);
128
+ const { index: n, before: t } = p(r, o, i), e = Array.from(r.children).filter((a) => a.hasAttribute("data-node-id"));
129
+ if (e.length === 0) {
130
+ const a = r.getBoundingClientRect();
131
+ c(this.dropIndicator, a, "block");
132
+ } else if (n < e.length) {
133
+ const d = e[n].getBoundingClientRect();
134
+ c(this.dropIndicator, { ...d, height: 3 }, "block");
135
+ } else {
136
+ const d = e[e.length - 1].getBoundingClientRect();
137
+ c(this.dropIndicator, { ...d, top: d.bottom, height: 3 }, "block");
138
+ }
139
+ this.dropIndicator.style.display = "block";
140
+ }
141
+ /**
142
+ * Hide drop indicator
143
+ */
144
+ hideDropIndicator() {
145
+ this.dropIndicator && (this.dropIndicator.style.display = "none");
146
+ }
147
+ /**
148
+ * Clean up
149
+ */
150
+ destroy() {
151
+ this.activeDrags.clear(), this.dropIndicator?.remove(), this.dropIndicator = null;
152
+ }
153
+ }
154
+ export function createDragDropContext() {
155
+ const s = new DragDropManager();
156
+ return {
157
+ startDrag: (r) => s.startDrag(r),
158
+ updateDragPosition: (r) => s.updateDragPosition(r),
159
+ endDrag: (r) => s.endDrag(r),
160
+ getDropZones: (r) => s.getDropZones(r),
161
+ highlightDropZone: (r) => s.highlightDropZone(r)
162
+ };
163
+ }
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './utils';
3
+ export * from './dragDropManager';
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _types = require("./types");
7
+ Object.keys(_types).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _types[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _types[key];
14
+ }
15
+ });
16
+ });
17
+ var _utils = require("./utils");
18
+ Object.keys(_utils).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _utils[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _utils[key];
25
+ }
26
+ });
27
+ });
28
+ var _dragDropManager = require("./dragDropManager");
29
+ Object.keys(_dragDropManager).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _dragDropManager[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _dragDropManager[key];
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./types.mjs";
2
+ export * from "./utils.mjs";
3
+ export * from "./dragDropManager.mjs";
@@ -0,0 +1,80 @@
1
+ export interface DragDropContext {
2
+ /**
3
+ * Start dragging an element
4
+ */
5
+ startDrag: (options: {
6
+ elementId: string;
7
+ path: string;
8
+ x: number;
9
+ y: number;
10
+ }) => Promise<{
11
+ dragId: string;
12
+ }>;
13
+ /**
14
+ * Update drag position
15
+ */
16
+ updateDragPosition: (options: {
17
+ dragId: string;
18
+ x: number;
19
+ y: number;
20
+ }) => Promise<void>;
21
+ /**
22
+ * End drag operation
23
+ */
24
+ endDrag: (options: {
25
+ dragId: string;
26
+ canceled?: boolean;
27
+ }) => Promise<{
28
+ dropped: boolean;
29
+ targetId?: string;
30
+ targetPath?: string;
31
+ insertIndex?: number;
32
+ }>;
33
+ /**
34
+ * Get drop zones at current position
35
+ */
36
+ getDropZones: (options: {
37
+ x: number;
38
+ y: number;
39
+ }) => Promise<Array<{
40
+ elementId: string;
41
+ path: string;
42
+ rect: {
43
+ top: number;
44
+ left: number;
45
+ width: number;
46
+ height: number;
47
+ };
48
+ canDrop: boolean;
49
+ }>>;
50
+ /**
51
+ * Highlight drop zone
52
+ */
53
+ highlightDropZone: (options: {
54
+ elementId?: string;
55
+ path?: string;
56
+ clear?: boolean;
57
+ }) => Promise<void>;
58
+ }
59
+ export interface DragDropEvents {
60
+ 'drag-start': (data: {
61
+ elementId: string;
62
+ path: string;
63
+ }) => void;
64
+ 'drag-move': (data: {
65
+ x: number;
66
+ y: number;
67
+ }) => void;
68
+ 'drag-end': (data: {
69
+ dropped: boolean;
70
+ targetId?: string;
71
+ }) => void;
72
+ 'drop-zone-enter': (data: {
73
+ elementId: string;
74
+ path: string;
75
+ }) => void;
76
+ 'drop-zone-leave': (data: {
77
+ elementId: string;
78
+ path: string;
79
+ }) => void;
80
+ }
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Get element by data attributes (Nooku uses data-node-id and data-node-path)
3
+ */
4
+ export declare function getElement(id: string, path: string): HTMLElement | null;
5
+ /**
6
+ * Get all potential drop zones (elements that can accept drops)
7
+ */
8
+ export declare function getDropZones(): HTMLElement[];
9
+ /**
10
+ * Check if element can accept drops
11
+ */
12
+ export declare function canAcceptDrop(element: HTMLElement): boolean;
13
+ /**
14
+ * Get element at position
15
+ */
16
+ export declare function getElementAtPosition(x: number, y: number, path: string): HTMLElement | null;
17
+ /**
18
+ * Calculate insert index based on cursor position
19
+ */
20
+ export declare function calculateInsertIndex(container: HTMLElement, x: number, y: number): {
21
+ index: number;
22
+ before: boolean;
23
+ };
24
+ /**
25
+ * Create drop indicator element
26
+ */
27
+ export declare function createDropIndicator(color?: string): HTMLElement;
28
+ /**
29
+ * Position drop indicator
30
+ */
31
+ export declare function positionDropIndicator(indicator: HTMLElement, rect: {
32
+ top: number;
33
+ left: number;
34
+ width: number;
35
+ height: number;
36
+ }, layout?: 'block' | 'inline'): void;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.calculateInsertIndex = calculateInsertIndex;
7
+ exports.canAcceptDrop = canAcceptDrop;
8
+ exports.createDropIndicator = createDropIndicator;
9
+ exports.getDropZones = getDropZones;
10
+ exports.getElement = getElement;
11
+ exports.getElementAtPosition = getElementAtPosition;
12
+ exports.positionDropIndicator = positionDropIndicator;
13
+ function getElement(e, t) {
14
+ return document.querySelector(`[data-node-id="${e}"][data-node-path="${t}"]`);
15
+ }
16
+ function getDropZones() {
17
+ return Array.from(document.querySelectorAll('[data-node-id]:not([data-node-id=""])'));
18
+ }
19
+ function canAcceptDrop(e) {
20
+ return e.getAttribute("data-node-type") !== "text";
21
+ }
22
+ function getElementAtPosition(e, t, l) {
23
+ let n = document.elementFromPoint(e, t);
24
+ if (!n) return null;
25
+ let u = n.getAttribute("data-node-path");
26
+ for (; n && u !== l;) {
27
+ if (n = n.parentElement, !n) return null;
28
+ u = n.getAttribute("data-node-path");
29
+ }
30
+ return n;
31
+ }
32
+ function calculateInsertIndex(e, t, l) {
33
+ const n = Array.from(e.children).filter(o => o.hasAttribute("data-node-id"));
34
+ if (n.length === 0) return {
35
+ index: 0,
36
+ before: !0
37
+ };
38
+ const u = e.getBoundingClientRect(),
39
+ c = n.every((o, d) => {
40
+ if (d === 0) return !0;
41
+ const r = n[d - 1].getBoundingClientRect(),
42
+ i = o.getBoundingClientRect();
43
+ return r.bottom <= i.top;
44
+ });
45
+ for (let o = 0; o < n.length; o++) {
46
+ const r = n[o].getBoundingClientRect();
47
+ if (c) {
48
+ const i = r.top + r.height / 2;
49
+ if (l < i) return {
50
+ index: o,
51
+ before: !0
52
+ };
53
+ } else {
54
+ const i = r.left + r.width / 2;
55
+ if (t < i) return {
56
+ index: o,
57
+ before: !0
58
+ };
59
+ }
60
+ }
61
+ return {
62
+ index: n.length,
63
+ before: !1
64
+ };
65
+ }
66
+ function createDropIndicator(e = "2563EB") {
67
+ const t = document.createElement("div");
68
+ return t.className = "__nooku-drop-indicator", t.style.cssText = `
69
+ position: fixed;
70
+ pointer-events: none;
71
+ z-index: 9999;
72
+ background: #${e};
73
+ opacity: 0.5;
74
+ transition: all 0.15s ease;
75
+ `, t;
76
+ }
77
+ function positionDropIndicator(e, t, l = "block") {
78
+ l === "block" ? (e.style.left = `${t.left}px`, e.style.top = `${t.top}px`, e.style.width = `${t.width}px`, e.style.height = "3px") : (e.style.left = `${t.left}px`, e.style.top = `${t.top}px`, e.style.width = "3px", e.style.height = `${t.height}px`);
79
+ }