@byeolnaerim/flex-layout 0.0.2 → 0.0.4

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 (61) hide show
  1. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.cts +31 -0
  2. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.ts +31 -0
  3. package/dist/chunk-3EDKZTM3.js +3 -0
  4. package/dist/chunk-3EDKZTM3.js.map +1 -0
  5. package/dist/chunk-5HWEFTNQ.js +176 -0
  6. package/dist/chunk-5HWEFTNQ.js.map +1 -0
  7. package/dist/chunk-7J5JUVZK.js +3 -0
  8. package/dist/chunk-7J5JUVZK.js.map +1 -0
  9. package/dist/chunk-CFQQ6ZDC.js +182 -0
  10. package/dist/chunk-CFQQ6ZDC.js.map +1 -0
  11. package/dist/chunk-JM3CZ5DU.js +238 -0
  12. package/dist/chunk-JM3CZ5DU.js.map +1 -0
  13. package/dist/chunk-PMTZFSP4.js +219 -0
  14. package/dist/chunk-PMTZFSP4.js.map +1 -0
  15. package/dist/chunk-UYI4Z27V.js +2432 -0
  16. package/dist/chunk-UYI4Z27V.js.map +1 -0
  17. package/dist/chunk-W4CNFJTK.js +197 -0
  18. package/dist/chunk-W4CNFJTK.js.map +1 -0
  19. package/dist/chunk-YIHCWXKY.js +3 -0
  20. package/dist/chunk-YIHCWXKY.js.map +1 -0
  21. package/dist/components.cjs +3048 -0
  22. package/dist/components.cjs.map +1 -0
  23. package/dist/components.css +471 -0
  24. package/dist/components.css.map +1 -0
  25. package/dist/components.d.cts +122 -0
  26. package/dist/components.d.ts +122 -0
  27. package/dist/components.js +7 -0
  28. package/dist/components.js.map +1 -0
  29. package/dist/hooks.cjs +425 -0
  30. package/dist/hooks.cjs.map +1 -0
  31. package/dist/hooks.d.cts +37 -0
  32. package/dist/hooks.d.ts +37 -0
  33. package/dist/hooks.js +5 -0
  34. package/dist/hooks.js.map +1 -0
  35. package/dist/index.cjs +2600 -1
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +10 -287
  38. package/dist/index.d.ts +10 -287
  39. package/dist/index.js +9 -814
  40. package/dist/index.js.map +1 -1
  41. package/dist/providers.cjs +411 -0
  42. package/dist/providers.cjs.map +1 -0
  43. package/dist/providers.d.cts +54 -0
  44. package/dist/providers.d.ts +54 -0
  45. package/dist/providers.js +6 -0
  46. package/dist/providers.js.map +1 -0
  47. package/dist/store.cjs +204 -0
  48. package/dist/store.cjs.map +1 -0
  49. package/dist/store.d.cts +67 -0
  50. package/dist/store.d.ts +67 -0
  51. package/dist/store.js +4 -0
  52. package/dist/store.js.map +1 -0
  53. package/dist/useDrag-CYQnhUFk.d.cts +108 -0
  54. package/dist/useDrag-DR01Ob3s.d.ts +108 -0
  55. package/dist/utils.cjs +209 -0
  56. package/dist/utils.cjs.map +1 -0
  57. package/dist/utils.d.cts +28 -0
  58. package/dist/utils.d.ts +28 -0
  59. package/dist/utils.js +4 -0
  60. package/dist/utils.js.map +1 -0
  61. package/package.json +25 -5
@@ -0,0 +1,3048 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var equal = require('fast-deep-equal');
5
+ var rxjs = require('rxjs');
6
+ var operators = require('rxjs/operators');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var equal__default = /*#__PURE__*/_interopDefault(equal);
12
+
13
+ // src/flex-layout/components/FlexLayout.tsx
14
+ function updateScrollStore(subject, newValue) {
15
+ const currentValue = subject.getValue();
16
+ if (!equal__default.default(currentValue, newValue)) {
17
+ subject.next(newValue);
18
+ }
19
+ }
20
+ function updateRefStore(store, newState) {
21
+ const prevState = store.getValue();
22
+ if (!equal__default.default(prevState, newState)) {
23
+ store.next(newState);
24
+ }
25
+ }
26
+ function updateSplitScreenStore(newValue) {
27
+ const prevValue = layoutSplitScreenStore.getValue();
28
+ if (!equal__default.default(prevValue, newValue)) {
29
+ layoutSplitScreenStore.next(newValue);
30
+ }
31
+ }
32
+ var scrollPositions = {};
33
+ var scrollPositionsSubject = new rxjs.BehaviorSubject(scrollPositions);
34
+ var setScrollPosition = (layoutName, position) => {
35
+ const current = scrollPositionsSubject.getValue();
36
+ const prevPos = current[layoutName];
37
+ if (prevPos && prevPos.x === position.x && prevPos.y === position.y) {
38
+ return;
39
+ }
40
+ const newPositions = {
41
+ ...current,
42
+ [layoutName]: position
43
+ };
44
+ updateScrollStore(scrollPositionsSubject, newPositions);
45
+ };
46
+ var getScrollPosition = (layoutName) => {
47
+ return scrollPositionsSubject.pipe(
48
+ // 해당 layoutName이 정의되지 않았을 때는 제외
49
+ operators.filter((e) => e[layoutName] !== void 0),
50
+ operators.map((positions) => positions[layoutName]),
51
+ operators.distinctUntilChanged(
52
+ (prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y
53
+ )
54
+ );
55
+ };
56
+ var removeScrollPosition = (layoutName) => {
57
+ const current = scrollPositionsSubject.getValue();
58
+ delete current[layoutName];
59
+ const newPositions = { ...current };
60
+ updateScrollStore(scrollPositionsSubject, newPositions);
61
+ };
62
+ var layoutSplitScreenStore = new rxjs.BehaviorSubject({});
63
+ var setSplitScreen = (rootName, layoutName, newComponents) => {
64
+ const current = layoutSplitScreenStore.getValue();
65
+ const updatedLayout = { ...current[rootName] || {} };
66
+ updatedLayout[layoutName] = newComponents;
67
+ const newStoreValue = {
68
+ ...current,
69
+ [rootName]: updatedLayout
70
+ };
71
+ updateSplitScreenStore(newStoreValue);
72
+ };
73
+ var resetRootSplitScreen = (rootName) => {
74
+ const current = layoutSplitScreenStore.getValue();
75
+ const newStoreValue = {
76
+ ...current,
77
+ [rootName]: {}
78
+ };
79
+ updateSplitScreenStore(newStoreValue);
80
+ };
81
+ var removeSplitScreenChild = (rootName, layoutName) => {
82
+ const current = layoutSplitScreenStore.getValue();
83
+ if (!current[rootName]) return;
84
+ const updatedLayout = { ...current[rootName] };
85
+ delete updatedLayout[layoutName];
86
+ const newStoreValue = {
87
+ ...current,
88
+ [rootName]: updatedLayout
89
+ };
90
+ updateSplitScreenStore(newStoreValue);
91
+ };
92
+ var getCurrentSplitScreenComponents = (rootName, layoutName) => {
93
+ const current = layoutSplitScreenStore.getValue();
94
+ if (!current[rootName]) return;
95
+ return current[rootName][layoutName];
96
+ };
97
+ var getSplitScreen = (rootName, layoutName) => {
98
+ return layoutSplitScreenStore.pipe(
99
+ operators.map((splitScreen) => splitScreen[rootName][layoutName]),
100
+ operators.distinctUntilChanged((prev, curr) => {
101
+ const filterChildren2 = (obj) => {
102
+ const { children, component, targetComponent, x, y, ...rest } = obj || {};
103
+ return rest;
104
+ };
105
+ return equal__default.default(filterChildren2(prev), filterChildren2(curr));
106
+ })
107
+ );
108
+ };
109
+ var flexContainerStore = new rxjs.BehaviorSubject({});
110
+ var flexResizePanelStore = new rxjs.BehaviorSubject({});
111
+ var setContainerRef = (layoutName, containerName, ref) => {
112
+ const currentRefs = flexContainerStore.getValue();
113
+ const updatedLayoutRefs = { ...currentRefs[layoutName] || {} };
114
+ if (ref === null) {
115
+ delete updatedLayoutRefs[containerName];
116
+ } else {
117
+ updatedLayoutRefs[containerName] = ref;
118
+ }
119
+ const newRefs = {
120
+ ...currentRefs,
121
+ [layoutName]: updatedLayoutRefs
122
+ };
123
+ updateRefStore(flexContainerStore, newRefs);
124
+ };
125
+ var setResizePanelRef = (layoutName, containerName, ref) => {
126
+ const currentRefs = flexResizePanelStore.getValue();
127
+ const updatedLayoutRefs = { ...currentRefs[layoutName] || {} };
128
+ if (ref === null) {
129
+ delete updatedLayoutRefs[containerName];
130
+ } else {
131
+ updatedLayoutRefs[containerName] = ref;
132
+ }
133
+ const newRefs = {
134
+ ...currentRefs,
135
+ [layoutName]: updatedLayoutRefs
136
+ };
137
+ updateRefStore(flexResizePanelStore, newRefs);
138
+ };
139
+ var getLayoutInfos = (layoutName) => {
140
+ return rxjs.combineLatest([flexContainerStore, flexResizePanelStore]).pipe(
141
+ operators.map(([containerRefs, resizePanelRefs]) => {
142
+ const containerData = containerRefs[layoutName] || {};
143
+ const resizePanelData = resizePanelRefs[layoutName] || {};
144
+ return {
145
+ container: containerData,
146
+ resizePanel: resizePanelData
147
+ };
148
+ }),
149
+ operators.filter((result) => result.container !== null)
150
+ // 빈 객체 제외
151
+ );
152
+ };
153
+
154
+ // src/flex-layout/utils/FlexLayoutUtils.ts
155
+ function isDocumentOut({ x, y }) {
156
+ if (typeof window == "undefined") return;
157
+ const { innerWidth, innerHeight, scrollX, scrollY } = window;
158
+ return x < 0 || y < 0 || x > innerWidth + scrollX || y > innerHeight + scrollY;
159
+ }
160
+ var lastTouchEvent;
161
+ function getClientXy(event) {
162
+ let clientX;
163
+ let clientY;
164
+ if (window.MouseEvent && event instanceof window.MouseEvent) {
165
+ clientX = event.clientX;
166
+ clientY = event.clientY;
167
+ } else if (window.TouchEvent && event instanceof window.TouchEvent) {
168
+ const _event = event.touches.length == 0 ? lastTouchEvent : event;
169
+ clientX = _event.touches[0].clientX;
170
+ clientY = _event.touches[0].clientY;
171
+ lastTouchEvent = event;
172
+ } else {
173
+ return;
174
+ }
175
+ return { clientX, clientY };
176
+ }
177
+ function isOverMove(elementSize, elementMinSize) {
178
+ return Math.floor(elementSize) <= 0 || (isNaN(elementMinSize) ? false : elementMinSize >= Math.floor(elementSize));
179
+ }
180
+ function findNotCloseFlexContent(target, direction) {
181
+ if (!target) return target;
182
+ let _target = target;
183
+ const isCloseCheck = () => {
184
+ let grow = parseFloat(window.getComputedStyle(_target).flex.split(" ")[0]) || 0;
185
+ if (grow == 0) {
186
+ return true;
187
+ } else {
188
+ return false;
189
+ }
190
+ };
191
+ while (isCloseCheck()) {
192
+ let nextTarget = _target[direction]?.[direction];
193
+ _target = nextTarget;
194
+ if (!_target) {
195
+ break;
196
+ }
197
+ }
198
+ return _target;
199
+ }
200
+ function resize(list, totalGrow) {
201
+ return new Promise((resolve) => {
202
+ let resizeWeight = totalGrow / list.length;
203
+ list.forEach((e) => {
204
+ e.dataset.grow = resizeWeight.toString();
205
+ e.style.flex = `${resizeWeight} 1 0%`;
206
+ });
207
+ resolve(resizeWeight);
208
+ });
209
+ }
210
+ function mathWeight(totalCount, totalGrow) {
211
+ return 1 + (totalGrow - totalCount) / totalCount;
212
+ }
213
+ function mathGrow(childSize, parentSize, containerCount) {
214
+ return containerCount * (childSize / parentSize);
215
+ }
216
+ function getGrow(growTarget) {
217
+ const target = growTarget instanceof Element ? growTarget : growTarget;
218
+ return parseFloat(target.style.flex.split(" ")[0]) || parseFloat(target.dataset.grow || "");
219
+ }
220
+ function closeFlex(resizeTarget, containers, {
221
+ isResize = false,
222
+ isDsiabledResizePanel = false,
223
+ sizeName
224
+ }) {
225
+ return new Promise((resolve) => {
226
+ if (!resizeTarget.hasAttribute("data-is_resize_panel")) ; else if (isDsiabledResizePanel) {
227
+ resizeTarget.dataset.is_resize_panel = "false";
228
+ }
229
+ resizeTarget.dataset.prev_grow = getGrow(resizeTarget).toString();
230
+ let notCloseList = containers.filter(
231
+ (e) => e.style.flex != "0 1 0%" && e != resizeTarget
232
+ );
233
+ let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];
234
+ notCloseAndOpenTargetList.forEach((e) => {
235
+ e.style.transition = "flex 0.5s";
236
+ e.ontransitionend = (event) => {
237
+ if (event.propertyName != "flex-grow") {
238
+ return;
239
+ }
240
+ notCloseAndOpenTargetList.forEach(
241
+ (e2) => e2.style.transition = ""
242
+ );
243
+ e.ontransitionend = () => {
244
+ };
245
+ };
246
+ if (e == resizeTarget) {
247
+ e.dataset.grow = "0";
248
+ e.style.flex = `0 1 0%`;
249
+ return;
250
+ }
251
+ if (isResize) {
252
+ return;
253
+ }
254
+ let percent = getGrow(e) / containers.length;
255
+ if (notCloseList.length == 1) {
256
+ e.dataset.grow = containers.length.toString();
257
+ e.style.flex = `${containers.length} 1 0%`;
258
+ return;
259
+ }
260
+ e.dataset.grow = (containers.length * percent).toString();
261
+ e.style.flex = `${containers.length * percent} 1 0%`;
262
+ });
263
+ if (isResize) {
264
+ resize(notCloseList, containers.length);
265
+ }
266
+ resolve(resizeTarget);
267
+ });
268
+ }
269
+ function openFlex(resizeTarget, containers, {
270
+ isPrevSizeOpen = false,
271
+ isResize = false,
272
+ openGrowImportant = 0,
273
+ sizeName
274
+ }) {
275
+ return new Promise((resolve) => {
276
+ if (!resizeTarget.hasAttribute("data-is_resize_panel")) ; else if (resizeTarget.hasAttribute("data-is_resize_panel") && resizeTarget.dataset.is_resize_panel == "false") {
277
+ resizeTarget.dataset.is_resize_panel = "true";
278
+ }
279
+ let notCloseList = containers.filter(
280
+ (e) => e.style.flex != "0 1 0%" && e != resizeTarget
281
+ );
282
+ let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];
283
+ let openTargetGrow = 1;
284
+ const sizeStyleName = "client" + sizeName.charAt(0).toUpperCase() + sizeName.substring(1);
285
+ const parentSize = sizeName && resizeTarget.parentElement && resizeTarget.parentElement[sizeStyleName] || 0;
286
+ if (isPrevSizeOpen && resizeTarget.hasAttribute("data-prev_grow")) {
287
+ openTargetGrow = parseFloat(resizeTarget.dataset.prev_grow || "1") || 1;
288
+ } else if (parentSize && parentSize !== 0) {
289
+ openTargetGrow = parentSize / notCloseList.length / (parentSize - 1) * containers.length;
290
+ } else {
291
+ openTargetGrow = 1;
292
+ }
293
+ if (openGrowImportant) {
294
+ openTargetGrow = openGrowImportant;
295
+ }
296
+ openTargetGrow = openTargetGrow === Infinity ? 1 : openTargetGrow;
297
+ notCloseAndOpenTargetList.forEach((e) => {
298
+ e.style.transition = "flex 0.5s";
299
+ e.ontransitionend = (event) => {
300
+ if (event.propertyName != "flex-grow") {
301
+ return;
302
+ }
303
+ notCloseAndOpenTargetList.forEach(
304
+ (e2) => e2.style.transition = ""
305
+ );
306
+ e.ontransitionend = () => {
307
+ };
308
+ };
309
+ if (e == resizeTarget) {
310
+ resizeTarget.dataset.grow = openTargetGrow.toString();
311
+ resizeTarget.style.flex = `${openTargetGrow} 1 0%`;
312
+ return;
313
+ }
314
+ if (isResize) {
315
+ return;
316
+ }
317
+ let grow = parentSize / notCloseList.length / (parentSize - 1) * (containers.length - openTargetGrow);
318
+ grow = grow === Infinity ? 1 : grow;
319
+ e.dataset.grow = grow.toString();
320
+ e.style.flex = `${grow} 1 0%`;
321
+ });
322
+ if (isResize) {
323
+ resize(notCloseAndOpenTargetList, containers.length);
324
+ }
325
+ resolve(openTargetGrow);
326
+ });
327
+ }
328
+ var g = globalThis;
329
+ g.__FLEX_SUBJECTS__ ?? (g.__FLEX_SUBJECTS__ = { openClose: {}, spread: {} });
330
+ var containerOpenCloseSubjectMap = g.__FLEX_SUBJECTS__.openClose;
331
+ var containerSpreadSubjectMap = g.__FLEX_SUBJECTS__.spread;
332
+ var ContainerOpenCloseProvider = ({
333
+ layoutName,
334
+ containerName,
335
+ sizeName
336
+ }) => {
337
+ if (!containerOpenCloseSubjectMap[containerName]) {
338
+ containerOpenCloseSubjectMap[containerName] = new rxjs.Subject();
339
+ }
340
+ if (!containerSpreadSubjectMap[containerName]) {
341
+ containerSpreadSubjectMap[containerName] = new rxjs.Subject();
342
+ }
343
+ const [containers, setContainers] = react.useState([]);
344
+ const [container, setContainer] = react.useState();
345
+ react.useEffect(() => {
346
+ const subscription = getLayoutInfos(layoutName).subscribe(
347
+ (layout) => {
348
+ if (!layout || !layout.container[containerName] || !layout.container[containerName].current)
349
+ return;
350
+ setContainers(
351
+ Object.values(layout.container).filter(
352
+ (e) => e.current !== null
353
+ ).map((e) => e.current)
354
+ );
355
+ setContainer(layout.container[containerName].current);
356
+ }
357
+ );
358
+ return () => subscription.unsubscribe();
359
+ }, [containerName, layoutName]);
360
+ react.useEffect(() => {
361
+ const styleName = `${sizeName.charAt(0).toUpperCase() + sizeName.substring(1)}`;
362
+ const clientSize = "client" + styleName;
363
+ const outerSize = "outer" + styleName;
364
+ const maxSize = "max" + styleName;
365
+ const subscribe = containerOpenCloseSubjectMap[containerName].subscribe(
366
+ ({
367
+ mode,
368
+ initOpenState: isOpenState,
369
+ onClose,
370
+ onOpen,
371
+ openOption = {},
372
+ closeOption = {}
373
+ }) => {
374
+ if (!container || containers.length === 0) return;
375
+ const currentGrow = getGrow(container);
376
+ const styleMap = window.getComputedStyle(container);
377
+ const maxSizeGrow = mathGrow(
378
+ parseInt(styleMap[maxSize]),
379
+ container.parentElement && container.parentElement[clientSize] || window[outerSize],
380
+ containers.length
381
+ );
382
+ const open = () => openFlex(container, containers, {
383
+ sizeName,
384
+ ...isNaN(maxSizeGrow) ? {} : {
385
+ openGrowImportant: maxSizeGrow
386
+ },
387
+ ...openOption
388
+ }).then((openTargetGrow) => {
389
+ if (onOpen) onOpen();
390
+ containerSpreadSubjectMap[containerName].next({
391
+ isOpen: true,
392
+ grow: openTargetGrow,
393
+ targetContainer: container
394
+ });
395
+ });
396
+ const close = () => closeFlex(container, containers, {
397
+ sizeName,
398
+ ...closeOption
399
+ }).then(() => {
400
+ if (onClose) onClose();
401
+ containerSpreadSubjectMap[containerName].next({
402
+ isOpen: false,
403
+ grow: 0,
404
+ targetContainer: container
405
+ });
406
+ });
407
+ if (mode === "toggle") {
408
+ if (currentGrow === 0) {
409
+ open();
410
+ } else {
411
+ close();
412
+ }
413
+ } else if (mode === "open") {
414
+ if (currentGrow === 0) {
415
+ open();
416
+ }
417
+ } else if (mode === "close") {
418
+ if (currentGrow !== 0) {
419
+ close();
420
+ }
421
+ }
422
+ }
423
+ );
424
+ return () => {
425
+ subscribe.unsubscribe();
426
+ };
427
+ }, [containerName, container, containers, sizeName]);
428
+ return null;
429
+ };
430
+
431
+ // src/flex-layout/styles/FlexLayout.module.css
432
+ var FlexLayout_default = {};
433
+ var FlexLayoutContext = react.createContext(null);
434
+ function useFlexLayoutContext() {
435
+ const context = react.useContext(FlexLayoutContext);
436
+ if (!context) {
437
+ throw new Error(
438
+ "useFlexLayoutContext must be used within FlexLayoutContext.Provider"
439
+ );
440
+ }
441
+ return context;
442
+ }
443
+ function FlexLayoutProvider({
444
+ value,
445
+ children
446
+ }) {
447
+ return /* @__PURE__ */ jsxRuntime.jsx(FlexLayoutContext.Provider, { value, children });
448
+ }
449
+ var FlexLayout = ({
450
+ layoutName,
451
+ direction,
452
+ children,
453
+ ref,
454
+ className,
455
+ panelClassName,
456
+ panelMovementMode = "divorce",
457
+ ...props
458
+ }) => {
459
+ const containerCount = react.Children.count(children);
460
+ const fitContent = direction === "row" ? "width" : "height";
461
+ const isFragmentElement = (node) => react.isValidElement(node) && node.type === react.Fragment;
462
+ const nodes = react.Children.toArray(children).flatMap(
463
+ (node) => isFragmentElement(node) ? react.Children.toArray(node.props.children) : [node]
464
+ );
465
+ const flattenedChildren = nodes.filter(
466
+ react.isValidElement
467
+ );
468
+ if (flattenedChildren.length === 0) {
469
+ return null;
470
+ }
471
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
472
+ FlexLayoutProvider,
473
+ {
474
+ value: {
475
+ layoutName,
476
+ direction,
477
+ panelMovementMode,
478
+ panelClassName,
479
+ containerCount,
480
+ fitContent
481
+ },
482
+ children: /* @__PURE__ */ jsxRuntime.jsx(
483
+ "div",
484
+ {
485
+ className: `${FlexLayout_default["flex-layout"]} ${className && className !== "" ? className : ""}`,
486
+ ...ref ? { ref } : {},
487
+ ...props,
488
+ "data-layout_name": layoutName,
489
+ "data-direction": direction,
490
+ children: flattenedChildren.map((child, index) => {
491
+ if (!child || !react.isValidElement(child)) return null;
492
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
493
+ child,
494
+ /* @__PURE__ */ jsxRuntime.jsx(
495
+ ContainerOpenCloseProvider,
496
+ {
497
+ layoutName,
498
+ containerName: child.props.containerName,
499
+ sizeName: fitContent
500
+ }
501
+ )
502
+ ] }, index);
503
+ })
504
+ }
505
+ )
506
+ }
507
+ ) });
508
+ };
509
+ var FlexLayout_default2 = FlexLayout;
510
+ var useSize = (sizeName) => {
511
+ const ref = react.useRef(null);
512
+ const [size, setSize] = react.useState(void 0);
513
+ react.useLayoutEffect(() => {
514
+ if (!ref.current) return;
515
+ const handleResize = () => {
516
+ if (ref.current) {
517
+ const newSize = ref.current.getBoundingClientRect()[sizeName];
518
+ setSize(newSize);
519
+ }
520
+ };
521
+ handleResize();
522
+ const resizeObserver = new ResizeObserver(() => {
523
+ handleResize();
524
+ });
525
+ resizeObserver.observe(ref.current);
526
+ window.addEventListener("resize", handleResize);
527
+ return () => {
528
+ resizeObserver.disconnect();
529
+ window.removeEventListener("resize", handleResize);
530
+ };
531
+ }, [sizeName]);
532
+ return { ref, size };
533
+ };
534
+ var flexDirectionModel = {
535
+ row: {
536
+ xy: "x",
537
+ targetDirection: "left",
538
+ nextDirection: "right",
539
+ sizeName: "width",
540
+ resizeCursor: "ew-resize"
541
+ },
542
+ column: {
543
+ xy: "y",
544
+ targetDirection: "top",
545
+ nextDirection: "bottom",
546
+ sizeName: "height",
547
+ resizeCursor: "ns-resize"
548
+ }
549
+ };
550
+ var FlexLayoutResizePanel = ({
551
+ direction,
552
+ containerCount,
553
+ panelMode = "default",
554
+ containerName,
555
+ layoutName,
556
+ panelClassName,
557
+ panelMovementMode
558
+ }) => {
559
+ let isResizePanelClickRef = react.useRef(false);
560
+ let prevTouchEvent = null;
561
+ let parentSizeRef = react.useRef(0);
562
+ let totalMovementRef = react.useRef(0);
563
+ const containerCountRef = react.useRef(containerCount);
564
+ react.useEffect(() => {
565
+ return () => {
566
+ document.body.style.cursor = "";
567
+ };
568
+ }, []);
569
+ react.useEffect(() => {
570
+ containerCountRef.current = containerCount;
571
+ }, [containerCount]);
572
+ const panelRef = react.useRef(null);
573
+ const panelMouseDownEvent = (event) => {
574
+ if (!panelRef.current || !panelRef.current.parentElement) return;
575
+ isResizePanelClickRef.current = true;
576
+ containerCountRef.current = [
577
+ ...panelRef.current.parentElement.children
578
+ ].filter((e) => e.hasAttribute("data-container_name")).length;
579
+ const sizeName = flexDirectionModel[direction].sizeName;
580
+ parentSizeRef.current = panelRef.current.parentElement.getBoundingClientRect()[sizeName];
581
+ prevTouchEvent = null;
582
+ totalMovementRef.current = 0;
583
+ if (!parentSizeRef.current) return;
584
+ document.body.style.cursor = flexDirectionModel[direction].resizeCursor;
585
+ };
586
+ const panelMouseUpEvent = () => {
587
+ isResizePanelClickRef.current = false;
588
+ parentSizeRef.current = 0;
589
+ prevTouchEvent = null;
590
+ totalMovementRef.current = 0;
591
+ document.body.style.cursor = "";
592
+ };
593
+ function moveMouseFlex(originTarget, resizePanel, moveEvent) {
594
+ const model = flexDirectionModel[direction];
595
+ const movement = moveEvent["movement" + model.xy.toUpperCase()];
596
+ totalMovementRef.current += movement;
597
+ const minSizeName = "min-" + model.sizeName;
598
+ const maxSizeName = "max-" + model.sizeName;
599
+ let targetElement = findNotCloseFlexContent(
600
+ originTarget,
601
+ "previousElementSibling"
602
+ );
603
+ if (panelMovementMode === "divorce" && totalMovementRef.current > 0 || panelMovementMode === "bulldozer" && movement > 0 || !targetElement)
604
+ targetElement = originTarget;
605
+ let nextElement = findNotCloseFlexContent(
606
+ resizePanel.nextElementSibling,
607
+ "nextElementSibling"
608
+ );
609
+ if (panelMovementMode === "divorce" && totalMovementRef.current < 0 || panelMovementMode === "bulldozer" && movement < 0 || !nextElement)
610
+ nextElement = resizePanel.nextElementSibling;
611
+ if (!targetElement || !nextElement) return;
612
+ const targetRect = targetElement.getBoundingClientRect();
613
+ const targetStyle = window.getComputedStyle(targetElement);
614
+ const targetMinSize = parseFloat(targetStyle.getPropertyValue(minSizeName)) || 0;
615
+ const targetMaxSize = parseFloat(targetStyle.getPropertyValue(maxSizeName)) || 0;
616
+ const nextRect = nextElement.getBoundingClientRect();
617
+ const nextStyle = window.getComputedStyle(nextElement);
618
+ const nextMinSize = parseFloat(nextStyle.getPropertyValue(minSizeName)) || 0;
619
+ const nextMaxSize = parseFloat(nextStyle.getPropertyValue(maxSizeName)) || 0;
620
+ let targetSize = targetRect[model.sizeName] + movement;
621
+ let nextElementSize = nextRect[model.sizeName] - movement;
622
+ if (targetMaxSize > 0 && targetSize > targetMaxSize) {
623
+ return;
624
+ }
625
+ if (nextMaxSize > 0 && nextElementSize > nextMaxSize) {
626
+ return;
627
+ }
628
+ if (isOverMove(targetSize, targetMinSize)) {
629
+ targetSize = 0;
630
+ nextElementSize = nextRect[model.sizeName];
631
+ } else if (isOverMove(nextElementSize, nextMinSize)) {
632
+ nextElementSize = 0;
633
+ targetSize = targetRect[model.sizeName];
634
+ }
635
+ const targetFlexGrow = targetSize / (parentSizeRef.current - 1) * containerCountRef.current;
636
+ const nextElementFlexGrow = nextElementSize / (parentSizeRef.current - 1) * containerCountRef.current;
637
+ targetElement.style.flex = `${targetFlexGrow} 1 0%`;
638
+ nextElement.style.flex = `${nextElementFlexGrow} 1 0%`;
639
+ }
640
+ react.useEffect(() => {
641
+ const addGlobalMoveEvent = (event) => {
642
+ if (!isResizePanelClickRef.current || !panelRef.current) {
643
+ return;
644
+ }
645
+ event.preventDefault();
646
+ const targetElement = panelRef.current.previousElementSibling;
647
+ const targetPanel = panelRef.current;
648
+ if (!targetElement || !targetPanel) return;
649
+ let move = { movementX: 0, movementY: 0 };
650
+ if (window.TouchEvent && event instanceof window.TouchEvent) {
651
+ if (!prevTouchEvent) {
652
+ prevTouchEvent = event;
653
+ return;
654
+ }
655
+ move.movementX = (prevTouchEvent.touches[0].pageX - event.touches[0].pageX) * -2;
656
+ move.movementY = (prevTouchEvent.touches[0].pageY - event.touches[0].pageY) * -2;
657
+ prevTouchEvent = event;
658
+ } else {
659
+ move.movementX = event.movementX;
660
+ move.movementY = event.movementY;
661
+ }
662
+ moveMouseFlex(targetElement, targetPanel, move);
663
+ };
664
+ ["mousemove", "touchmove"].forEach((eventName) => {
665
+ window.addEventListener(eventName, addGlobalMoveEvent, {
666
+ passive: false
667
+ });
668
+ });
669
+ ["mouseup", "touchend"].forEach((eventName) => {
670
+ window.addEventListener(eventName, panelMouseUpEvent);
671
+ });
672
+ return () => {
673
+ ["mousemove", "touchmove"].forEach((eventName) => {
674
+ window.removeEventListener(eventName, addGlobalMoveEvent);
675
+ });
676
+ ["mouseup", "touchend"].forEach((eventName) => {
677
+ window.removeEventListener(eventName, panelMouseUpEvent);
678
+ });
679
+ };
680
+ }, []);
681
+ react.useEffect(() => {
682
+ if (!panelRef.current) return;
683
+ setResizePanelRef(layoutName, containerName, panelRef);
684
+ }, [containerName, layoutName]);
685
+ return /* @__PURE__ */ jsxRuntime.jsx(
686
+ "div",
687
+ {
688
+ id: containerName + "_resize_panel",
689
+ className: `${FlexLayout_default["flex-resize-panel"]} ${FlexLayout_default[panelMode]} ${panelClassName && panelClassName !== "" ? panelClassName : ""}`,
690
+ ref: panelRef,
691
+ onMouseDown: panelMouseDownEvent,
692
+ onTouchStart: panelMouseDownEvent,
693
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: FlexLayout_default.hover })
694
+ }
695
+ );
696
+ };
697
+ var FlexLayoutResizePanel_default = FlexLayoutResizePanel;
698
+ var FlexLayoutContainer = ({
699
+ isFitContent,
700
+ isFitResize,
701
+ // fitContent,
702
+ // containerCount,
703
+ // layoutName,
704
+ containerName,
705
+ grow: initialGrow,
706
+ prevGrow: initialPrevGrow,
707
+ isInitialResizable,
708
+ isResizePanel,
709
+ children,
710
+ className,
711
+ panelMode
712
+ }) => {
713
+ const {
714
+ direction,
715
+ panelMovementMode,
716
+ panelClassName,
717
+ layoutName,
718
+ fitContent,
719
+ containerCount
720
+ } = useFlexLayoutContext();
721
+ const { ref, size } = (
722
+ // isFitContent && fitContent
723
+ //?
724
+ useSize(fitContent)
725
+ );
726
+ const flexContainerNodeRef = react.useRef(null);
727
+ const flexContainerRef = react.useCallback(
728
+ (node) => {
729
+ flexContainerNodeRef.current = node;
730
+ if (node !== null) {
731
+ setContainerRef(layoutName, containerName, { current: node });
732
+ }
733
+ },
734
+ [layoutName, containerName]
735
+ );
736
+ const [growState, setGrowState] = react.useState(initialGrow);
737
+ react.useEffect(() => {
738
+ setGrowState(initialGrow);
739
+ }, [initialGrow]);
740
+ const [prevGrowState, setPrevGrowState] = react.useState(
741
+ initialPrevGrow
742
+ );
743
+ const [isFirstLoad, setIsFirstLoad] = react.useState(true);
744
+ react.useEffect(() => {
745
+ if (!flexContainerNodeRef.current) return;
746
+ setContainerRef(layoutName, containerName, flexContainerNodeRef);
747
+ return () => {
748
+ setContainerRef(layoutName, containerName, {
749
+ current: null
750
+ });
751
+ };
752
+ }, [containerName, layoutName]);
753
+ react.useEffect(() => {
754
+ if (typeof window == "undefined" || flexContainerNodeRef.current === null)
755
+ return;
756
+ const storedGrow = sessionStorage.getItem(containerName);
757
+ if (storedGrow !== null) {
758
+ const parsed = parseFloat(storedGrow);
759
+ if (!isNaN(parsed)) {
760
+ flexContainerNodeRef.current.style.flex = `${parsed} 1 0%`;
761
+ setGrowState(parsed);
762
+ }
763
+ }
764
+ }, [containerName]);
765
+ react.useEffect(() => {
766
+ if (!flexContainerNodeRef.current) return;
767
+ const targetNode = flexContainerNodeRef.current;
768
+ const observer = new MutationObserver((mutations) => {
769
+ for (const mutation of mutations) {
770
+ if (mutation.type === "attributes" && mutation.attributeName === "style" && targetNode.style.flex) {
771
+ const flexValue = targetNode.style.flex;
772
+ const parsedGrow = parseFloat(flexValue.split(" ")[0]);
773
+ if (!isNaN(parsedGrow)) {
774
+ setGrowState(parsedGrow);
775
+ }
776
+ }
777
+ }
778
+ });
779
+ observer.observe(targetNode, {
780
+ attributes: true,
781
+ attributeFilter: ["style"],
782
+ attributeOldValue: true
783
+ });
784
+ return () => {
785
+ observer.disconnect();
786
+ };
787
+ }, [containerName]);
788
+ react.useEffect(() => {
789
+ if (!flexContainerNodeRef.current || !ref || !ref.current || !size || !fitContent)
790
+ return;
791
+ requestAnimationFrame(() => {
792
+ if (!flexContainerNodeRef.current) return;
793
+ const sizeName = `${fitContent.charAt(0).toUpperCase() + fitContent.substring(1)}`;
794
+ const parentSize = flexContainerNodeRef.current.parentElement && flexContainerNodeRef.current.parentElement["client" + sizeName] || 0;
795
+ if (isFitContent) {
796
+ flexContainerNodeRef.current.style["max" + sizeName] = size + "px";
797
+ }
798
+ if (!isFitResize && isFirstLoad) {
799
+ setIsFirstLoad(false);
800
+ return;
801
+ }
802
+ if (getGrow(flexContainerNodeRef.current) != 0 && isFitResize) {
803
+ const newGrow = mathGrow(size, parentSize, containerCount);
804
+ setPrevGrowState(growState);
805
+ setGrowState(newGrow);
806
+ }
807
+ });
808
+ }, [size, containerCount, isFitResize, children]);
809
+ react.useEffect(() => {
810
+ if (!flexContainerNodeRef.current) return;
811
+ let notGrowList = [];
812
+ let containerList = [
813
+ ...flexContainerNodeRef.current.parentElement?.children || []
814
+ ].filter((e) => e.hasAttribute("data-container_name"));
815
+ let remainingGrow = containerList.reduce((t, e, i) => {
816
+ let item = e;
817
+ if (item.classList.contains(FlexLayout_default["flex-resize-panel"])) return t;
818
+ if (e.hasAttribute("data-grow") == false || e.getAttribute("data-is_resize") === "true") {
819
+ notGrowList.push(item);
820
+ return t;
821
+ }
822
+ let grow = parseFloat(item.dataset.grow || "");
823
+ item.style.flex = `${grow} 1 0%`;
824
+ t -= grow;
825
+ return t;
826
+ }, containerList.length);
827
+ if (notGrowList.length != 0) {
828
+ let resizeWeight = mathWeight(notGrowList.length, remainingGrow);
829
+ notGrowList.forEach((e) => {
830
+ e.dataset.grow = resizeWeight.toString();
831
+ e.style.flex = `${resizeWeight} 1 0%`;
832
+ });
833
+ }
834
+ }, []);
835
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
836
+ /* @__PURE__ */ jsxRuntime.jsx(
837
+ "div",
838
+ {
839
+ id: containerName,
840
+ "data-container_name": containerName,
841
+ ref: flexContainerRef,
842
+ className: `${FlexLayout_default["flex-container"]} ${className && className !== "" ? className : ""}`,
843
+ ...growState !== void 0 ? { ["data-grow"]: growState } : {},
844
+ ...prevGrowState != void 0 ? { ["data-prev_grow"]: prevGrowState } : {},
845
+ "data-is_resize": isInitialResizable,
846
+ "data-is_resize_panel": isResizePanel,
847
+ style: growState !== void 0 && {
848
+ flex: `${growState} 1 0%`
849
+ } || {},
850
+ children: isFitContent && /* @__PURE__ */ jsxRuntime.jsx(
851
+ "div",
852
+ {
853
+ className: `${FlexLayout_default["flex-content-fit-wrapper"]}`,
854
+ ref,
855
+ children
856
+ }
857
+ ) || children
858
+ }
859
+ ),
860
+ isResizePanel && /* @__PURE__ */ jsxRuntime.jsx(
861
+ FlexLayoutResizePanel_default,
862
+ {
863
+ containerName,
864
+ layoutName,
865
+ direction,
866
+ containerCount,
867
+ panelMode,
868
+ panelClassName,
869
+ panelMovementMode
870
+ }
871
+ )
872
+ ] });
873
+ };
874
+ var FlexLayoutContainer_default = FlexLayoutContainer;
875
+ var dragState = new rxjs.Subject();
876
+ var filterChildren = (obj) => {
877
+ const { children, ...rest } = obj || {};
878
+ return rest;
879
+ };
880
+ var useDragCapture = (targetRef) => {
881
+ const stateRef = react.useRef(null);
882
+ const forceUpdate = react.useRef(0);
883
+ react.useEffect(() => {
884
+ const subscription = dragState.pipe(
885
+ rxjs.map((value) => {
886
+ if (!targetRef || !targetRef.current) return null;
887
+ const { x, y } = value;
888
+ const rect = targetRef.current.getBoundingClientRect();
889
+ const {
890
+ width,
891
+ height,
892
+ x: rectX,
893
+ y: rectY,
894
+ right,
895
+ bottom
896
+ } = rect;
897
+ let isOver = false;
898
+ if (x < rectX || x > right || y < rectY || y > bottom) {
899
+ isOver = true;
900
+ }
901
+ const leftBoundary = rectX + width * 0.2;
902
+ const rightBoundary = right - width * 0.2;
903
+ const topBoundary = rectY + height * 0.2;
904
+ const bottomBoundary = bottom - height * 0.2;
905
+ let position = "centerBoundary";
906
+ if (x < leftBoundary) {
907
+ position = "leftBoundary";
908
+ } else if (x > rightBoundary) {
909
+ position = "rightBoundary";
910
+ } else if (y < topBoundary) {
911
+ position = "topBoundary";
912
+ } else if (y > bottomBoundary) {
913
+ position = "bottomBoundary";
914
+ }
915
+ return {
916
+ positionName: position,
917
+ isOver,
918
+ ...value
919
+ };
920
+ }),
921
+ rxjs.distinctUntilChanged(
922
+ (prev, curr) => equal__default.default(filterChildren(prev), filterChildren(curr))
923
+ )
924
+ ).subscribe({
925
+ next: (value) => {
926
+ if (value && !equal__default.default(
927
+ filterChildren(stateRef.current),
928
+ filterChildren(value)
929
+ )) {
930
+ stateRef.current = value;
931
+ forceUpdate.current++;
932
+ }
933
+ },
934
+ error: (err) => console.error(err)
935
+ });
936
+ return () => subscription.unsubscribe();
937
+ }, [targetRef]);
938
+ const [, rerender] = react.useState({});
939
+ react.useEffect(() => {
940
+ const interval = setInterval(() => {
941
+ rerender({});
942
+ }, 50);
943
+ return () => clearInterval(interval);
944
+ }, []);
945
+ return stateRef.current;
946
+ };
947
+ var dropMovementEventSubject = new rxjs.Subject();
948
+ var allSplitScreenCount = new rxjs.BehaviorSubject(0);
949
+ var useDragEvents = ({
950
+ isBlockingActiveInput = false
951
+ }) => {
952
+ const dragResumeTimer = react.useRef(null);
953
+ const scrollThreshold = 10;
954
+ const isScrolling = react.useRef(false);
955
+ const isPending = react.useRef(false);
956
+ const isMouseDown = react.useRef(false);
957
+ const isDragging = react.useRef(false);
958
+ const touchStartX = react.useRef(0);
959
+ const touchStartY = react.useRef(0);
960
+ const handleStart = react.useCallback(
961
+ ({
962
+ event: _event,
963
+ dragStartCallback
964
+ }) => {
965
+ const event = _event instanceof Event ? _event : _event.nativeEvent;
966
+ if (dragResumeTimer.current) {
967
+ clearTimeout(dragResumeTimer.current);
968
+ dragResumeTimer.current = null;
969
+ }
970
+ if (event.target.contentEditable === "true" || isBlockingActiveInput && document.activeElement === event.target) {
971
+ return;
972
+ }
973
+ if (event.cancelable) {
974
+ event.preventDefault();
975
+ }
976
+ isPending.current = true;
977
+ isMouseDown.current = true;
978
+ if (event instanceof globalThis.TouchEvent) {
979
+ const touch = event.touches[0];
980
+ touchStartX.current = touch.clientX;
981
+ touchStartY.current = touch.clientY;
982
+ } else if (event instanceof globalThis.MouseEvent) {
983
+ touchStartX.current = event.clientX;
984
+ touchStartY.current = event.clientY;
985
+ }
986
+ setTimeout(() => {
987
+ if (!isPending.current || isScrolling.current) return;
988
+ isPending.current = false;
989
+ isDragging.current = true;
990
+ const xy = getClientXy(event);
991
+ if (!xy) return;
992
+ const { clientX, clientY } = xy;
993
+ dragStartCallback({ x: clientX, y: clientY });
994
+ }, 300);
995
+ },
996
+ [isBlockingActiveInput]
997
+ );
998
+ const handleMove = react.useCallback(
999
+ ({
1000
+ event: _event,
1001
+ notDragCallback,
1002
+ dragStartCallback,
1003
+ moveingCallback
1004
+ }) => {
1005
+ if (!isMouseDown.current) return;
1006
+ const event = _event instanceof Event ? _event : _event.nativeEvent;
1007
+ const xy = getClientXy(event);
1008
+ if (!xy) return;
1009
+ const { clientX, clientY } = xy;
1010
+ const deltaX = Math.abs(clientX - touchStartX.current);
1011
+ const deltaY = Math.abs(clientY - touchStartY.current);
1012
+ if (isPending.current && (deltaX > scrollThreshold || deltaY > scrollThreshold)) {
1013
+ isScrolling.current = true;
1014
+ isPending.current = false;
1015
+ isDragging.current = false;
1016
+ if (notDragCallback)
1017
+ notDragCallback({ x: clientX, y: clientY });
1018
+ if (dragResumeTimer.current) {
1019
+ clearTimeout(dragResumeTimer.current);
1020
+ dragResumeTimer.current = null;
1021
+ }
1022
+ dragResumeTimer.current = setTimeout(() => {
1023
+ if (!isMouseDown.current) return;
1024
+ if (dragStartCallback)
1025
+ dragStartCallback({ x: clientX, y: clientY });
1026
+ isPending.current = true;
1027
+ isScrolling.current = false;
1028
+ handleStart({ event: _event, dragStartCallback });
1029
+ }, 400);
1030
+ return;
1031
+ }
1032
+ if (!isDragging.current || isPending.current) return;
1033
+ moveingCallback({ x: clientX, y: clientY });
1034
+ },
1035
+ [isBlockingActiveInput]
1036
+ );
1037
+ const handleEnd = react.useCallback(
1038
+ ({
1039
+ event: _event,
1040
+ dragEndCallback
1041
+ }) => {
1042
+ isScrolling.current = false;
1043
+ isMouseDown.current = false;
1044
+ if (isPending.current) {
1045
+ isPending.current = false;
1046
+ return;
1047
+ }
1048
+ const event = _event instanceof Event ? _event : _event.nativeEvent;
1049
+ if (!isDragging.current) return;
1050
+ isDragging.current = false;
1051
+ const xy = getClientXy(event);
1052
+ if (!xy) return;
1053
+ const { clientX, clientY } = xy;
1054
+ dragEndCallback({ x: clientX, y: clientY });
1055
+ },
1056
+ [isBlockingActiveInput]
1057
+ );
1058
+ return {
1059
+ handleStart,
1060
+ handleMove,
1061
+ handleEnd
1062
+ };
1063
+ };
1064
+ new rxjs.Subject();
1065
+ function useFlexLayoutSplitScreen({
1066
+ isSplitInitial = false,
1067
+ parentDirection,
1068
+ directionInitial = "row",
1069
+ selfContainerName,
1070
+ parentLayoutName,
1071
+ layoutName
1072
+ }) {
1073
+ const [direction, setDirection] = react.useState(
1074
+ directionInitial
1075
+ );
1076
+ const [isSplit, setIsSplit] = react.useState(isSplitInitial);
1077
+ const [boundaryContainerSize, setBoundaryContainerSize] = react.useState(null);
1078
+ const [centerDropTargetComponent, setCenterDropTargetComponent] = react.useState([]);
1079
+ const [afterDropTargetComponent, setAfterDropTargetComponent] = react.useState([]);
1080
+ const [beforeDropTargetComponent, setBeforeDropTargetComponent] = react.useState([]);
1081
+ const layoutRef = react.useRef(null);
1082
+ const dragState2 = useDragCapture(layoutRef);
1083
+ react.useEffect(() => {
1084
+ if (!dragState2) {
1085
+ setBoundaryContainerSize(null);
1086
+ return;
1087
+ }
1088
+ const {
1089
+ isDrop,
1090
+ isDragging,
1091
+ positionName,
1092
+ containerName,
1093
+ children: dropComponent,
1094
+ isOver,
1095
+ navigationTitle,
1096
+ dropEndCallback,
1097
+ x,
1098
+ y,
1099
+ screenKey
1100
+ } = dragState2;
1101
+ const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
1102
+ if ((isOver || isDrop) && boundaryContainerSize) {
1103
+ setBoundaryContainerSize(null);
1104
+ }
1105
+ if (selfContainerName.startsWith(containerName)) {
1106
+ return;
1107
+ }
1108
+ if (isDrop && screenKey) {
1109
+ const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
1110
+ if (!isSplit && !isOver) {
1111
+ if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
1112
+ setIsSplit(true);
1113
+ setDirection(dropDirection);
1114
+ }
1115
+ dropMovementEventSubject.next({
1116
+ state: "append",
1117
+ targetContainerName: containerName,
1118
+ targetParentLayoutName: parentLayoutName,
1119
+ targetLayoutName: layoutName,
1120
+ targetComponent: dropComponent,
1121
+ orderName,
1122
+ x,
1123
+ y,
1124
+ dropEndCallback,
1125
+ dropTargetComponentEvent: {
1126
+ navigationTitle,
1127
+ dropDocumentOutsideOption: dragState2?.dropDocumentOutsideOption,
1128
+ direction: dropDirection,
1129
+ screenKey
1130
+ }
1131
+ });
1132
+ }
1133
+ }
1134
+ if (isDragging && !isSplit && !isOver) {
1135
+ const newSize = {
1136
+ left: positionName === "rightBoundary" ? "50%" : "0",
1137
+ top: positionName === "bottomBoundary" ? "50%" : "0",
1138
+ width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
1139
+ height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
1140
+ };
1141
+ if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
1142
+ setBoundaryContainerSize(newSize);
1143
+ }
1144
+ }
1145
+ }, [
1146
+ dragState2,
1147
+ isSplit,
1148
+ boundaryContainerSize,
1149
+ parentLayoutName,
1150
+ layoutName,
1151
+ selfContainerName,
1152
+ direction
1153
+ ]);
1154
+ return {
1155
+ direction,
1156
+ setDirection,
1157
+ isSplit,
1158
+ setIsSplit,
1159
+ boundaryContainerSize,
1160
+ //setBoundaryContainerSize,
1161
+ centerDropTargetComponent,
1162
+ afterDropTargetComponent,
1163
+ beforeDropTargetComponent,
1164
+ setAfterDropTargetComponent,
1165
+ setBeforeDropTargetComponent,
1166
+ setCenterDropTargetComponent,
1167
+ //dropTargetComponent,
1168
+ //setDropTargetComponent,
1169
+ //setDropPosition,
1170
+ isOver: dragState2?.isOver,
1171
+ layoutRef
1172
+ };
1173
+ }
1174
+ var MAX_STEP = 18;
1175
+ function edgeVelocity(x, y) {
1176
+ const w = window.innerWidth, h = window.innerHeight;
1177
+ const mx = w * 0.15, my = h * 0.15;
1178
+ let vx = 0;
1179
+ if (x < mx)
1180
+ vx = -((mx - x) / mx) * MAX_STEP;
1181
+ else if (x > w - mx)
1182
+ vx = (x - (w - mx)) / mx * MAX_STEP;
1183
+ let vy = 0;
1184
+ if (y < my)
1185
+ vy = -((my - y) / my) * MAX_STEP;
1186
+ else if (y > h - my)
1187
+ vy = (y - (h - my)) / my * MAX_STEP;
1188
+ return { vx, vy };
1189
+ }
1190
+ function FlexLayoutSplitScreenDragBox({
1191
+ onMouseDown,
1192
+ onTouchStart,
1193
+ dropEndCallback,
1194
+ style,
1195
+ navigationTitle,
1196
+ targetComponent,
1197
+ containerName,
1198
+ children,
1199
+ className,
1200
+ dropDocumentOutsideOption,
1201
+ screenKey = Array.from(
1202
+ window.crypto.getRandomValues(new Uint32Array(16)),
1203
+ (e) => e.toString(32).padStart(2, "0")
1204
+ ).join(""),
1205
+ isBlockingActiveInput = false,
1206
+ customData = {},
1207
+ scrollTargetRef,
1208
+ ...props
1209
+ }) {
1210
+ const scrollRAF = react.useRef(null);
1211
+ const velocity = react.useRef({ vx: 0, vy: 0 });
1212
+ const ref = react.useRef(null);
1213
+ const clonedNodeRef = react.useRef(null);
1214
+ const clonedWidth = react.useRef(null);
1215
+ const clonedHeight = react.useRef(null);
1216
+ const hrefUrlRef = react.useRef("");
1217
+ const { handleStart, handleMove, handleEnd } = useDragEvents({
1218
+ isBlockingActiveInput
1219
+ });
1220
+ const handleMoveWrapper = (event) => {
1221
+ let x = 0;
1222
+ let y = 0;
1223
+ if (event.type === "touchmove") {
1224
+ const t = event.touches[0];
1225
+ x = t.clientX;
1226
+ y = t.clientY;
1227
+ } else {
1228
+ const m = event;
1229
+ x = m.clientX;
1230
+ y = m.clientY;
1231
+ }
1232
+ const { vx, vy } = edgeVelocity(x, y);
1233
+ const inEdge = vx !== 0 || vy !== 0;
1234
+ if (clonedNodeRef.current?.isConnected && !inEdge) {
1235
+ event.preventDefault();
1236
+ if (scrollRAF.current) {
1237
+ cancelAnimationFrame(scrollRAF.current);
1238
+ scrollRAF.current = null;
1239
+ }
1240
+ }
1241
+ if (clonedNodeRef.current?.isConnected && inEdge) {
1242
+ event.preventDefault();
1243
+ velocity.current = { vx, vy };
1244
+ if (!scrollRAF.current) {
1245
+ const step = () => {
1246
+ scrollTargetRef?.current?.scrollBy(
1247
+ velocity.current.vx,
1248
+ velocity.current.vy
1249
+ );
1250
+ if (velocity.current.vx === 0 && velocity.current.vy === 0) {
1251
+ scrollRAF.current = null;
1252
+ return;
1253
+ }
1254
+ scrollRAF.current = requestAnimationFrame(step);
1255
+ };
1256
+ scrollRAF.current = requestAnimationFrame(step);
1257
+ }
1258
+ }
1259
+ if (event.type !== "touchmove") {
1260
+ event.preventDefault();
1261
+ }
1262
+ handleMove({
1263
+ event,
1264
+ notDragCallback: ({ x: x2, y: y2 }) => {
1265
+ if (clonedNodeRef.current) clonedNodeRef.current.remove();
1266
+ },
1267
+ dragStartCallback: ({ x: x2, y: y2 }) => {
1268
+ if (!clonedNodeRef.current) return;
1269
+ navigator.vibrate(100);
1270
+ clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
1271
+ clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
1272
+ },
1273
+ moveingCallback: ({ x: x2, y: y2 }) => {
1274
+ if (clonedNodeRef.current?.isConnected) {
1275
+ clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
1276
+ clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
1277
+ }
1278
+ dragState.next({
1279
+ isDragging: true,
1280
+ isDrop: false,
1281
+ navigationTitle,
1282
+ children: targetComponent,
1283
+ x: x2,
1284
+ y: y2,
1285
+ containerName,
1286
+ dropDocumentOutsideOption,
1287
+ customData
1288
+ });
1289
+ }
1290
+ });
1291
+ };
1292
+ const handleEndWrapper = (event) => {
1293
+ if (scrollRAF.current !== null) {
1294
+ cancelAnimationFrame(scrollRAF.current);
1295
+ scrollRAF.current = null;
1296
+ }
1297
+ velocity.current = { vx: 0, vy: 0 };
1298
+ handleEnd({
1299
+ event,
1300
+ dragEndCallback: ({ x, y }) => {
1301
+ const href = hrefUrlRef.current;
1302
+ if (clonedNodeRef.current) clonedNodeRef.current.remove();
1303
+ if (dropDocumentOutsideOption && isDocumentOut({ x, y })) {
1304
+ if (dropDocumentOutsideOption.isNewTap || !dropDocumentOutsideOption.widthRatio && !dropDocumentOutsideOption.heightRatio) {
1305
+ window.open(href, "_blank");
1306
+ } else {
1307
+ const width = window.innerWidth * (dropDocumentOutsideOption.widthRatio || 1);
1308
+ const height = window.innerHeight * (dropDocumentOutsideOption.heightRatio || 1);
1309
+ window.open(
1310
+ href,
1311
+ "_blank",
1312
+ `width=${width},height=${height},left=${window.screenLeft - x * -1 - width},top=${window.screenTop + y}`
1313
+ );
1314
+ }
1315
+ }
1316
+ dragState.next({
1317
+ isDragging: false,
1318
+ isDrop: true,
1319
+ navigationTitle,
1320
+ children: targetComponent,
1321
+ x,
1322
+ y,
1323
+ containerName,
1324
+ dropDocumentOutsideOption,
1325
+ dropEndCallback,
1326
+ screenKey,
1327
+ customData
1328
+ });
1329
+ }
1330
+ });
1331
+ };
1332
+ react.useEffect(() => {
1333
+ if (ref.current) {
1334
+ const clone = ref.current.cloneNode(true);
1335
+ const originRect = ref.current.getBoundingClientRect();
1336
+ clone.style.width = originRect.width + "px";
1337
+ clone.style.height = originRect.height + "px";
1338
+ clone.style.opacity = "0.3";
1339
+ clone.style.backdropFilter = "blur(6px)";
1340
+ clonedWidth.current = originRect.width;
1341
+ clonedHeight.current = originRect.height;
1342
+ if (dropDocumentOutsideOption?.openUrl) {
1343
+ hrefUrlRef.current = dropDocumentOutsideOption.openUrl;
1344
+ const href = document.createElement("span");
1345
+ href.textContent = hrefUrlRef.current;
1346
+ clone.prepend(href);
1347
+ }
1348
+ if (navigationTitle) {
1349
+ const title = document.createElement("span");
1350
+ title.textContent = navigationTitle;
1351
+ clone.prepend(title);
1352
+ }
1353
+ clone.style.position = "fixed";
1354
+ clonedNodeRef.current = clone;
1355
+ clonedNodeRef.current.classList.add(
1356
+ FlexLayout_default["flex-split-screen-drag-box-clone"]
1357
+ );
1358
+ }
1359
+ }, []);
1360
+ react.useEffect(() => {
1361
+ const moveEvents = [
1362
+ "mousemove",
1363
+ "touchmove"
1364
+ ];
1365
+ const endEvents = ["mouseup", "touchend"];
1366
+ moveEvents.forEach((eventName) => {
1367
+ window.addEventListener(eventName, handleMoveWrapper, {
1368
+ passive: false
1369
+ });
1370
+ });
1371
+ endEvents.forEach((eventName) => {
1372
+ window.addEventListener(eventName, handleEndWrapper);
1373
+ });
1374
+ return () => {
1375
+ moveEvents.forEach((eventName) => {
1376
+ window.removeEventListener(eventName, handleMoveWrapper);
1377
+ });
1378
+ endEvents.forEach((eventName) => {
1379
+ window.removeEventListener(eventName, handleEndWrapper);
1380
+ });
1381
+ };
1382
+ }, [
1383
+ customData,
1384
+ targetComponent,
1385
+ dropDocumentOutsideOption,
1386
+ screenKey,
1387
+ isBlockingActiveInput,
1388
+ containerName,
1389
+ navigationTitle,
1390
+ dropEndCallback
1391
+ ]);
1392
+ react.useEffect(() => {
1393
+ const el = ref.current;
1394
+ if (!el) return;
1395
+ const onCtx = (e) => e.preventDefault();
1396
+ el.addEventListener("contextmenu", onCtx);
1397
+ return () => {
1398
+ el.removeEventListener("contextmenu", onCtx);
1399
+ };
1400
+ }, []);
1401
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
1402
+ "div",
1403
+ {
1404
+ className: `${className || ""} ${FlexLayout_default["flex-split-screen-drag-box"]}`,
1405
+ ref,
1406
+ onContextMenu: (e) => e.preventDefault(),
1407
+ onMouseDown: (ev) => {
1408
+ if (onMouseDown) {
1409
+ Promise.resolve().then(() => onMouseDown(ev));
1410
+ }
1411
+ handleStart({
1412
+ event: ev,
1413
+ dragStartCallback: ({ x, y }) => {
1414
+ if (clonedNodeRef.current) {
1415
+ document.body.appendChild(
1416
+ clonedNodeRef.current
1417
+ );
1418
+ if (ref.current) {
1419
+ const originRect = ref.current.getBoundingClientRect();
1420
+ clonedNodeRef.current.style.width = originRect.width + "px";
1421
+ clonedNodeRef.current.style.height = originRect.height + "px";
1422
+ clonedWidth.current = originRect.width;
1423
+ clonedHeight.current = originRect.height;
1424
+ }
1425
+ }
1426
+ if (clonedNodeRef.current?.isConnected) {
1427
+ navigator.vibrate(100);
1428
+ clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
1429
+ clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
1430
+ }
1431
+ dragState.next({
1432
+ isDragging: true,
1433
+ isDrop: false,
1434
+ navigationTitle,
1435
+ children: targetComponent,
1436
+ x,
1437
+ y,
1438
+ containerName,
1439
+ dropDocumentOutsideOption,
1440
+ customData
1441
+ });
1442
+ }
1443
+ });
1444
+ },
1445
+ onTouchStart: (ev) => {
1446
+ if (onTouchStart) {
1447
+ Promise.resolve().then(() => onTouchStart(ev));
1448
+ }
1449
+ handleStart({
1450
+ event: ev,
1451
+ dragStartCallback: ({ x, y }) => {
1452
+ if (clonedNodeRef.current) {
1453
+ document.body.appendChild(
1454
+ clonedNodeRef.current
1455
+ );
1456
+ if (ref.current) {
1457
+ const originRect = ref.current.getBoundingClientRect();
1458
+ clonedNodeRef.current.style.width = originRect.width + "px";
1459
+ clonedNodeRef.current.style.height = originRect.height + "px";
1460
+ clonedWidth.current = originRect.width;
1461
+ clonedHeight.current = originRect.height;
1462
+ }
1463
+ }
1464
+ if (clonedNodeRef.current?.isConnected) {
1465
+ navigator.vibrate(100);
1466
+ clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
1467
+ clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
1468
+ }
1469
+ dragState.next({
1470
+ isDragging: true,
1471
+ isDrop: false,
1472
+ navigationTitle,
1473
+ children: targetComponent,
1474
+ x,
1475
+ y,
1476
+ containerName,
1477
+ dropDocumentOutsideOption,
1478
+ customData
1479
+ });
1480
+ }
1481
+ });
1482
+ },
1483
+ style: { ...style },
1484
+ ...props,
1485
+ children
1486
+ }
1487
+ ) });
1488
+ }
1489
+
1490
+ // src/flex-layout/styles/listScroll.module.css
1491
+ var listScroll_default = {};
1492
+ var FlexLayoutSplitScreenScrollBox = ({
1493
+ className,
1494
+ children,
1495
+ keyName,
1496
+ direction,
1497
+ isDefaultScrollStyle = false,
1498
+ ...props
1499
+ }) => {
1500
+ const scrollRef = react.useRef(null);
1501
+ const [isMouseDown, setIsMouseDown] = react.useState(false);
1502
+ const scrollEventSubject = react.useRef(new rxjs.Subject());
1503
+ react.useEffect(() => {
1504
+ const mouseUpSubscribe = rxjs.fromEvent(
1505
+ window,
1506
+ "mouseup"
1507
+ ).subscribe(() => {
1508
+ setIsMouseDown(false);
1509
+ });
1510
+ const scrollEventSubscribe = scrollEventSubject.current.pipe(operators.throttleTime(70)).subscribe((position) => {
1511
+ setScrollPosition(keyName, position);
1512
+ });
1513
+ const scrollSubscribe = getScrollPosition(keyName).pipe(operators.take(1)).subscribe((position) => {
1514
+ if (scrollRef.current && position) {
1515
+ scrollRef.current.scrollLeft = position.x;
1516
+ scrollRef.current.scrollTop = position.y;
1517
+ }
1518
+ });
1519
+ return () => {
1520
+ removeScrollPosition(keyName);
1521
+ mouseUpSubscribe.unsubscribe();
1522
+ scrollSubscribe.unsubscribe();
1523
+ scrollEventSubscribe.unsubscribe();
1524
+ };
1525
+ }, [keyName]);
1526
+ react.useEffect(() => {
1527
+ if (!scrollRef.current) return;
1528
+ let animationFrameId = null;
1529
+ const handleWheel = (event) => {
1530
+ if (!scrollRef.current || direction !== "x") return;
1531
+ if (scrollRef.current.matches(":hover")) {
1532
+ event.preventDefault();
1533
+ const { deltaY } = event;
1534
+ const newScrollLeft = scrollRef.current.scrollLeft + deltaY;
1535
+ if (animationFrameId) {
1536
+ cancelAnimationFrame(animationFrameId);
1537
+ }
1538
+ animationFrameId = requestAnimationFrame(() => {
1539
+ scrollRef.current.scrollLeft = newScrollLeft;
1540
+ scrollEventSubject.current.next({
1541
+ x: newScrollLeft,
1542
+ y: scrollRef.current.scrollTop
1543
+ });
1544
+ animationFrameId = null;
1545
+ });
1546
+ }
1547
+ };
1548
+ scrollRef.current.addEventListener("wheel", handleWheel, {
1549
+ passive: false
1550
+ });
1551
+ return () => {
1552
+ scrollRef.current?.removeEventListener("wheel", handleWheel);
1553
+ };
1554
+ }, []);
1555
+ return /* @__PURE__ */ jsxRuntime.jsx(
1556
+ "div",
1557
+ {
1558
+ ref: scrollRef,
1559
+ onMouseUp: () => setIsMouseDown(false),
1560
+ onMouseDown: () => setIsMouseDown(true),
1561
+ onMouseMove: (event) => {
1562
+ if (!scrollRef.current || !isMouseDown || direction !== "x")
1563
+ return;
1564
+ scrollRef.current.scrollLeft += event.movementX * -1;
1565
+ scrollEventSubject.current.next({
1566
+ x: scrollRef.current.scrollLeft,
1567
+ y: scrollRef.current.scrollTop
1568
+ });
1569
+ },
1570
+ onScroll: () => {
1571
+ if (!scrollRef.current) return;
1572
+ scrollEventSubject.current.next({
1573
+ x: scrollRef.current.scrollLeft,
1574
+ y: scrollRef.current.scrollTop
1575
+ });
1576
+ },
1577
+ className: `${className || ""} ${isDefaultScrollStyle ? listScroll_default["default-scroll"] : listScroll_default["list-scroll"]} ${direction ? listScroll_default[direction] : ""}`,
1578
+ ...props,
1579
+ children
1580
+ }
1581
+ );
1582
+ };
1583
+ var FlexLayoutSplitScreenScrollBox_default = react.memo(FlexLayoutSplitScreenScrollBox);
1584
+ function FlexLayoutSplitScreenDragBoxContainer({
1585
+ className,
1586
+ children,
1587
+ layoutName,
1588
+ ...props
1589
+ }) {
1590
+ return /* @__PURE__ */ jsxRuntime.jsx(
1591
+ FlexLayoutSplitScreenScrollBox_default,
1592
+ {
1593
+ keyName: layoutName,
1594
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-container"]} ${className && className !== "" && className || ""}`,
1595
+ direction: "x",
1596
+ ...props,
1597
+ children
1598
+ }
1599
+ );
1600
+ }
1601
+ function FlexLayoutSplitScreenDragBoxItem({
1602
+ children,
1603
+ onClose,
1604
+ isActive,
1605
+ ...props
1606
+ }) {
1607
+ react.useEffect(() => {
1608
+ allSplitScreenCount.next(allSplitScreenCount.value + 1);
1609
+ return () => {
1610
+ if (allSplitScreenCount.value <= 1) return;
1611
+ allSplitScreenCount.next(allSplitScreenCount.value - 1);
1612
+ };
1613
+ }, []);
1614
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1615
+ "div",
1616
+ {
1617
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-item"]} ${isActive ? FlexLayout_default["active"] : ""}`,
1618
+ ...props,
1619
+ children: [
1620
+ children,
1621
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: (ev) => onClose(ev), children: "X" })
1622
+ ]
1623
+ }
1624
+ );
1625
+ }
1626
+ function FlexLayoutSplitScreenDragBoxTitleMore({
1627
+ className,
1628
+ ...props
1629
+ }) {
1630
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1631
+ "button",
1632
+ {
1633
+ ...props,
1634
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-more"]} ${className || ""}`,
1635
+ children: [
1636
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "." }),
1637
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "." }),
1638
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "." })
1639
+ ]
1640
+ }
1641
+ );
1642
+ }
1643
+ function isOverDrop({
1644
+ x,
1645
+ y,
1646
+ element
1647
+ }) {
1648
+ const {
1649
+ x: elementX,
1650
+ y: elementY,
1651
+ right: elementRight,
1652
+ bottom: elementBottom
1653
+ } = element.getBoundingClientRect();
1654
+ const isElementOver = x < elementX || x > elementRight || y < elementY || y > elementBottom;
1655
+ return isElementOver;
1656
+ }
1657
+ function isInnerDrop({
1658
+ x,
1659
+ y,
1660
+ element
1661
+ }) {
1662
+ const {
1663
+ x: elementX,
1664
+ y: elementY,
1665
+ right: elementRight,
1666
+ bottom: elementBottom
1667
+ } = element.getBoundingClientRect();
1668
+ const isElementInner = x >= elementX && x <= elementRight && y >= elementY && y <= elementBottom;
1669
+ return isElementInner;
1670
+ }
1671
+ var handleUpdateDropTargetComponents = ({
1672
+ orderName,
1673
+ parentOrderName,
1674
+ containerName,
1675
+ parentLayoutName,
1676
+ layoutName,
1677
+ dropComponent,
1678
+ navigationTitle,
1679
+ nextContainerName,
1680
+ isUsePrefix = true,
1681
+ beforeDropTargetComponent,
1682
+ afterDropTargetComponent,
1683
+ centerDropTargetComponent,
1684
+ dropDocumentOutsideOption,
1685
+ screenKey = Array.from(
1686
+ window.crypto.getRandomValues(new Uint32Array(16)),
1687
+ (e) => e.toString(32).padStart(2, "0")
1688
+ ).join("")
1689
+ }) => {
1690
+ const nextContainerNameOrderName = parentOrderName ? parentOrderName : orderName;
1691
+ let listMap;
1692
+ let list;
1693
+ let key;
1694
+ if (nextContainerNameOrderName === orderName || nextContainerNameOrderName === "center") {
1695
+ listMap = orderName === "before" ? { beforeDropTargetComponent } : orderName === "after" ? { afterDropTargetComponent } : {
1696
+ centerDropTargetComponent: centerDropTargetComponent.filter(
1697
+ (e) => !e.containerName.split("_").at(0).startsWith(
1698
+ containerName.split("_").at(0)
1699
+ )
1700
+ )
1701
+ };
1702
+ } else {
1703
+ listMap = nextContainerNameOrderName === "before" ? { beforeDropTargetComponent } : { afterDropTargetComponent };
1704
+ }
1705
+ const entries = Object.entries(listMap)[0];
1706
+ key = entries[0];
1707
+ list = entries[1];
1708
+ const newComponent = {
1709
+ containerName: `${containerName + "_" + layoutName}${isUsePrefix ? "_" + orderName + "-" + list.length : ""}`,
1710
+ component: react.cloneElement(
1711
+ dropComponent,
1712
+ { key: screenKey, screenKey }
1713
+ ),
1714
+ navigationTitle,
1715
+ dropDocumentOutsideOption,
1716
+ screenKey: screenKey || Array.from(
1717
+ window.crypto.getRandomValues(new Uint32Array(16)),
1718
+ (e) => e.toString(32).padStart(2, "0")
1719
+ ).join("")
1720
+ };
1721
+ let allComponents;
1722
+ if (nextContainerName) {
1723
+ const index = list.findIndex(
1724
+ (item) => item.containerName === nextContainerName
1725
+ );
1726
+ if (index !== -1) {
1727
+ if (nextContainerNameOrderName === orderName) {
1728
+ if (orderName === "before") {
1729
+ allComponents = [
1730
+ ...list.slice(0, index),
1731
+ newComponent,
1732
+ ...list.slice(index)
1733
+ ];
1734
+ } else {
1735
+ allComponents = [
1736
+ ...list.slice(0, index + 1),
1737
+ newComponent,
1738
+ ...list.slice(index + 1)
1739
+ ];
1740
+ }
1741
+ } else {
1742
+ if (nextContainerNameOrderName === "after" && orderName === "before") {
1743
+ allComponents = [
1744
+ ...list.slice(0, index),
1745
+ newComponent,
1746
+ ...list.slice(index)
1747
+ ];
1748
+ } else if (nextContainerNameOrderName === "before" && orderName === "after") {
1749
+ allComponents = [
1750
+ ...list.slice(0, index + 1),
1751
+ newComponent,
1752
+ ...list.slice(index + 1)
1753
+ ];
1754
+ } else {
1755
+ if (orderName === "before") {
1756
+ allComponents = [
1757
+ ...list.slice(0, index),
1758
+ newComponent,
1759
+ ...list.slice(index)
1760
+ ];
1761
+ } else {
1762
+ allComponents = [
1763
+ ...list.slice(0, index + 1),
1764
+ newComponent,
1765
+ ...list.slice(index + 1)
1766
+ ];
1767
+ }
1768
+ }
1769
+ }
1770
+ } else {
1771
+ if (nextContainerNameOrderName === "center" && orderName === "after") {
1772
+ allComponents = [newComponent, ...list];
1773
+ } else if (nextContainerNameOrderName === "center" && orderName === "before") {
1774
+ allComponents = [...list, newComponent];
1775
+ } else {
1776
+ allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1777
+ }
1778
+ }
1779
+ } else {
1780
+ allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1781
+ }
1782
+ const seen = /* @__PURE__ */ new Set();
1783
+ const result = allComponents.filter((item) => {
1784
+ if (seen.has(item.containerName)) {
1785
+ return false;
1786
+ }
1787
+ seen.add(item.containerName);
1788
+ return true;
1789
+ });
1790
+ dropMovementEventSubject.next({
1791
+ state: "append",
1792
+ targetParentLayoutName: parentLayoutName,
1793
+ targetLayoutName: layoutName,
1794
+ targetContainerName: containerName,
1795
+ orderName
1796
+ });
1797
+ return { [key]: result };
1798
+ };
1799
+ var handleRemove = (list, targetContainerName, orderNameSetter) => {
1800
+ const result = list.filter((e) => e.containerName !== targetContainerName);
1801
+ if (result.length != list.length)
1802
+ orderNameSetter(list.length - result.length);
1803
+ return result;
1804
+ };
1805
+ function getAdjacentItem(items, currentIndex) {
1806
+ if (currentIndex + 1 < items.length) {
1807
+ return {
1808
+ adjacentItem: items[currentIndex + 1],
1809
+ adjacentIndex: currentIndex + 1
1810
+ };
1811
+ } else if (currentIndex - 1 >= 0) {
1812
+ return {
1813
+ adjacentItem: items[currentIndex - 1],
1814
+ adjacentIndex: currentIndex - 1
1815
+ };
1816
+ }
1817
+ return { adjacentItem: null, adjacentIndex: currentIndex };
1818
+ }
1819
+ var getSelfOrderName = (containerName) => {
1820
+ const result = containerName.split("_").at(-1)?.split("-").at(0)?.split("=").at(0);
1821
+ if (["before", "center", "after"].some((e) => e === result)) {
1822
+ return result;
1823
+ } else {
1824
+ return;
1825
+ }
1826
+ };
1827
+ function FlexLayoutSplitScreen({
1828
+ children,
1829
+ containerName,
1830
+ layoutName,
1831
+ navigationTitle,
1832
+ dropDocumentOutsideOption,
1833
+ screenKey
1834
+ }) {
1835
+ const {
1836
+ direction,
1837
+ isSplit,
1838
+ boundaryContainerSize,
1839
+ afterDropTargetComponent,
1840
+ beforeDropTargetComponent,
1841
+ centerDropTargetComponent,
1842
+ setAfterDropTargetComponent,
1843
+ setBeforeDropTargetComponent,
1844
+ setCenterDropTargetComponent,
1845
+ layoutRef,
1846
+ setIsSplit,
1847
+ setDirection
1848
+ } = useFlexLayoutSplitScreen({
1849
+ isSplitInitial: false,
1850
+ directionInitial: "row",
1851
+ selfContainerName: containerName,
1852
+ parentLayoutName: "",
1853
+ layoutName
1854
+ });
1855
+ react.useEffect(() => {
1856
+ resetRootSplitScreen(layoutName);
1857
+ const subscribe = getSplitScreen(layoutName, layoutName).subscribe((layoutInfo) => {
1858
+ if (layoutInfo) {
1859
+ setBeforeDropTargetComponent([
1860
+ ...layoutInfo.beforeDropTargetComponent
1861
+ ]);
1862
+ setAfterDropTargetComponent([
1863
+ ...layoutInfo.afterDropTargetComponent
1864
+ ]);
1865
+ setCenterDropTargetComponent([
1866
+ ...layoutInfo.centerDropTargetComponent
1867
+ ]);
1868
+ setDirection(layoutInfo.direction);
1869
+ if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
1870
+ setIsSplit(true);
1871
+ }
1872
+ } else {
1873
+ setSplitScreen(layoutName, layoutName, {
1874
+ afterDropTargetComponent: [],
1875
+ beforeDropTargetComponent: [],
1876
+ centerDropTargetComponent: [
1877
+ {
1878
+ containerName,
1879
+ component: children,
1880
+ navigationTitle,
1881
+ dropDocumentOutsideOption,
1882
+ screenKey: screenKey ? screenKey : Array.from(
1883
+ window.crypto.getRandomValues(
1884
+ new Uint32Array(16)
1885
+ ),
1886
+ (e) => e.toString(32).padStart(2, "0")
1887
+ ).join("")
1888
+ }
1889
+ ],
1890
+ direction
1891
+ });
1892
+ }
1893
+ });
1894
+ return () => {
1895
+ subscribe.unsubscribe();
1896
+ resetRootSplitScreen(layoutName);
1897
+ };
1898
+ }, [layoutName]);
1899
+ react.useEffect(() => {
1900
+ const subscribe = dropMovementEventSubject.pipe(
1901
+ rxjs.distinctUntilChanged((prev, curr) => {
1902
+ const filterChildren2 = (obj) => {
1903
+ const {
1904
+ children: children2,
1905
+ component,
1906
+ targetComponent,
1907
+ x,
1908
+ y,
1909
+ ...rest
1910
+ } = obj || {};
1911
+ return rest;
1912
+ };
1913
+ return equal__default.default(filterChildren2(prev), filterChildren2(curr));
1914
+ })
1915
+ ).subscribe((event) => {
1916
+ if (event.state === "remove") {
1917
+ if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
1918
+ requestAnimationFrame(() => {
1919
+ let removeCallback = (removeOrderName) => {
1920
+ if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
1921
+ const targetComponentsMap = handleUpdateDropTargetComponents({
1922
+ orderName: removeOrderName,
1923
+ containerName: event.nextContainerName,
1924
+ parentLayoutName: "",
1925
+ layoutName,
1926
+ dropComponent: event.targetComponent,
1927
+ navigationTitle: event.dropTargetComponentEvent.navigationTitle,
1928
+ isUsePrefix: true,
1929
+ afterDropTargetComponent,
1930
+ beforeDropTargetComponent,
1931
+ centerDropTargetComponent,
1932
+ dropDocumentOutsideOption,
1933
+ screenKey: event.dropTargetComponentEvent.screenKey
1934
+ });
1935
+ setSplitScreen(layoutName, layoutName, {
1936
+ ...getCurrentSplitScreenComponents(
1937
+ layoutName,
1938
+ layoutName
1939
+ ) || {
1940
+ afterDropTargetComponent,
1941
+ beforeDropTargetComponent,
1942
+ centerDropTargetComponent,
1943
+ direction
1944
+ },
1945
+ ...targetComponentsMap
1946
+ });
1947
+ Promise.resolve().then(
1948
+ () => event.dropEndCallback && event.dropEndCallback({
1949
+ x: event.x,
1950
+ y: event.y,
1951
+ containerName
1952
+ })
1953
+ );
1954
+ }
1955
+ };
1956
+ const currentComponents = getCurrentSplitScreenComponents(
1957
+ layoutName,
1958
+ layoutName
1959
+ );
1960
+ const afterList = handleRemove(
1961
+ currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
1962
+ event.targetContainerName,
1963
+ () => removeCallback("after")
1964
+ );
1965
+ const beforList = handleRemove(
1966
+ currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
1967
+ event.targetContainerName,
1968
+ () => removeCallback("before")
1969
+ );
1970
+ const centerList = handleRemove(
1971
+ currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
1972
+ event.targetContainerName,
1973
+ () => removeCallback("center")
1974
+ );
1975
+ setSplitScreen(layoutName, layoutName, {
1976
+ afterDropTargetComponent: afterList,
1977
+ beforeDropTargetComponent: beforList,
1978
+ centerDropTargetComponent: centerList,
1979
+ direction
1980
+ });
1981
+ });
1982
+ }
1983
+ } else if (event.state === "append") {
1984
+ const {
1985
+ x,
1986
+ y,
1987
+ dropEndCallback,
1988
+ dropTargetComponentEvent,
1989
+ orderName,
1990
+ parentOrderName,
1991
+ targetLayoutName,
1992
+ targetParentLayoutName,
1993
+ targetContainerName,
1994
+ targetComponent,
1995
+ nextContainerName
1996
+ } = event;
1997
+ if (layoutRef.current && orderName && x && y && targetComponent && dropTargetComponentEvent && targetLayoutName === layoutName && isInnerDrop({ x, y, element: layoutRef.current })) {
1998
+ const {
1999
+ direction: dropDirection,
2000
+ navigationTitle: navigationTitle2,
2001
+ dropDocumentOutsideOption: dropDocumentOutsideOption2
2002
+ } = dropTargetComponentEvent;
2003
+ const isOrderNameNotCenter = orderName !== "center";
2004
+ const isOrderNameCenterAndFirstScreen = orderName === "center" && centerDropTargetComponent.length <= 1;
2005
+ if (isOrderNameNotCenter || isOrderNameCenterAndFirstScreen) {
2006
+ setIsSplit(true);
2007
+ if (isOrderNameNotCenter) {
2008
+ setDirection(dropDirection);
2009
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2010
+ orderName,
2011
+ parentOrderName,
2012
+ containerName: targetContainerName,
2013
+ nextContainerName,
2014
+ dropComponent: targetComponent,
2015
+ parentLayoutName: "",
2016
+ layoutName,
2017
+ navigationTitle: navigationTitle2,
2018
+ isUsePrefix: true,
2019
+ afterDropTargetComponent,
2020
+ beforeDropTargetComponent,
2021
+ centerDropTargetComponent,
2022
+ dropDocumentOutsideOption: dropDocumentOutsideOption2
2023
+ });
2024
+ setSplitScreen(layoutName, layoutName, {
2025
+ ...{
2026
+ afterDropTargetComponent,
2027
+ beforeDropTargetComponent,
2028
+ centerDropTargetComponent,
2029
+ direction: dropDirection
2030
+ },
2031
+ ...targetComponentsMap,
2032
+ ...{ direction: dropDirection }
2033
+ });
2034
+ Promise.resolve().then(
2035
+ () => dropEndCallback && dropEndCallback({
2036
+ x: event.x,
2037
+ y: event.y,
2038
+ containerName
2039
+ })
2040
+ );
2041
+ } else {
2042
+ const childScreenInfo = getCurrentSplitScreenComponents(
2043
+ layoutName,
2044
+ `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`
2045
+ ) || {
2046
+ afterDropTargetComponent: [],
2047
+ beforeDropTargetComponent: [],
2048
+ centerDropTargetComponent: [],
2049
+ direction
2050
+ };
2051
+ setSplitScreen(
2052
+ layoutName,
2053
+ `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`,
2054
+ {
2055
+ ...childScreenInfo,
2056
+ ...{
2057
+ centerDropTargetComponent: [
2058
+ centerDropTargetComponent[0],
2059
+ {
2060
+ containerName: `${targetContainerName}_${layoutName}_${orderName}`,
2061
+ component: targetComponent,
2062
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2063
+ screenKey: centerDropTargetComponent[0].screenKey,
2064
+ navigationTitle: navigationTitle2
2065
+ }
2066
+ ]
2067
+ }
2068
+ }
2069
+ );
2070
+ }
2071
+ }
2072
+ }
2073
+ }
2074
+ });
2075
+ return () => {
2076
+ subscribe.unsubscribe();
2077
+ };
2078
+ }, [
2079
+ direction,
2080
+ layoutName,
2081
+ isSplit,
2082
+ beforeDropTargetComponent,
2083
+ afterDropTargetComponent,
2084
+ centerDropTargetComponent
2085
+ ]);
2086
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${FlexLayout_default["flex-split-screen"]}`, ref: layoutRef, children: [
2087
+ /* @__PURE__ */ jsxRuntime.jsxs(
2088
+ FlexLayout_default2,
2089
+ {
2090
+ direction,
2091
+ layoutName,
2092
+ "data-is_split": isSplit,
2093
+ panelMovementMode: "bulldozer",
2094
+ children: [
2095
+ beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: beforeDropTargetComponent.map(
2096
+ ({
2097
+ containerName: cName,
2098
+ component,
2099
+ navigationTitle: navigationTitle2,
2100
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2101
+ screenKey: screenKey2
2102
+ }, i) => /* @__PURE__ */ jsxRuntime.jsx(
2103
+ FlexLayoutContainer_default,
2104
+ {
2105
+ containerName: cName,
2106
+ isInitialResizable: true,
2107
+ isResizePanel: true,
2108
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2109
+ FlexLayoutSplitScreenChild,
2110
+ {
2111
+ parentDirection: direction,
2112
+ layoutName: `${layoutName}_before`,
2113
+ parentLayoutName: layoutName,
2114
+ containerName: cName,
2115
+ depth: 1,
2116
+ rootRef: layoutRef,
2117
+ screenKey: screenKey2,
2118
+ initialCenterComponents: [
2119
+ {
2120
+ navigationTitle: navigationTitle2,
2121
+ component,
2122
+ containerName: cName,
2123
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2124
+ screenKey: screenKey2
2125
+ }
2126
+ ],
2127
+ rootName: layoutName
2128
+ }
2129
+ )
2130
+ },
2131
+ cName
2132
+ )
2133
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", {}),
2134
+ centerDropTargetComponent.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", {}) : /* @__PURE__ */ jsxRuntime.jsx(
2135
+ FlexLayoutContainer_default,
2136
+ {
2137
+ containerName: `${centerDropTargetComponent[0].containerName}`,
2138
+ isInitialResizable: true,
2139
+ isResizePanel: isSplit,
2140
+ children: isSplit ? /* @__PURE__ */ jsxRuntime.jsx(
2141
+ FlexLayoutSplitScreenChild,
2142
+ {
2143
+ parentDirection: direction,
2144
+ layoutName: `${layoutName}_center`,
2145
+ parentLayoutName: layoutName,
2146
+ containerName: `${centerDropTargetComponent[0].containerName}`,
2147
+ depth: 0,
2148
+ rootRef: layoutRef,
2149
+ screenKey: centerDropTargetComponent[0].screenKey,
2150
+ initialCenterComponents: [
2151
+ {
2152
+ navigationTitle: centerDropTargetComponent[0].navigationTitle,
2153
+ component: centerDropTargetComponent[0].component,
2154
+ containerName: centerDropTargetComponent[0].containerName,
2155
+ dropDocumentOutsideOption: centerDropTargetComponent[0].dropDocumentOutsideOption,
2156
+ screenKey: centerDropTargetComponent[0].screenKey
2157
+ }
2158
+ ],
2159
+ rootName: layoutName
2160
+ }
2161
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
2162
+ FlexLayoutSplitScreenScrollBox_default,
2163
+ {
2164
+ keyName: centerDropTargetComponent[0].containerName,
2165
+ isDefaultScrollStyle: true,
2166
+ children: centerDropTargetComponent[0].component
2167
+ }
2168
+ )
2169
+ }
2170
+ ),
2171
+ afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: afterDropTargetComponent.map(
2172
+ ({
2173
+ containerName: cName,
2174
+ component,
2175
+ navigationTitle: navigationTitle2,
2176
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2177
+ screenKey: screenKey2
2178
+ }, i) => /* @__PURE__ */ jsxRuntime.jsx(
2179
+ FlexLayoutContainer_default,
2180
+ {
2181
+ containerName: cName,
2182
+ isInitialResizable: true,
2183
+ isResizePanel: afterDropTargetComponent.length - 1 !== i,
2184
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2185
+ FlexLayoutSplitScreenChild,
2186
+ {
2187
+ parentDirection: direction,
2188
+ layoutName: `${layoutName}_after`,
2189
+ parentLayoutName: layoutName,
2190
+ containerName: cName,
2191
+ depth: 1,
2192
+ rootRef: layoutRef,
2193
+ screenKey: screenKey2,
2194
+ initialCenterComponents: [
2195
+ {
2196
+ navigationTitle: navigationTitle2,
2197
+ component,
2198
+ containerName: cName,
2199
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2200
+ screenKey: screenKey2
2201
+ }
2202
+ ],
2203
+ rootName: layoutName
2204
+ }
2205
+ )
2206
+ },
2207
+ cName
2208
+ )
2209
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", {})
2210
+ ]
2211
+ }
2212
+ ),
2213
+ boundaryContainerSize && /* @__PURE__ */ jsxRuntime.jsx(
2214
+ "div",
2215
+ {
2216
+ className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
2217
+ style: { ...boundaryContainerSize },
2218
+ children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
2219
+ }
2220
+ )
2221
+ ] });
2222
+ }
2223
+ function FlexLayoutSplitScreenChild({
2224
+ containerName,
2225
+ layoutName,
2226
+ parentLayoutName,
2227
+ parentDirection,
2228
+ depth,
2229
+ //isSplit: isSplitInitial,
2230
+ rootRef,
2231
+ rootName,
2232
+ initialCenterComponents,
2233
+ screenKey
2234
+ }) {
2235
+ const {
2236
+ direction,
2237
+ isSplit,
2238
+ boundaryContainerSize,
2239
+ afterDropTargetComponent,
2240
+ beforeDropTargetComponent,
2241
+ centerDropTargetComponent,
2242
+ setAfterDropTargetComponent,
2243
+ setBeforeDropTargetComponent,
2244
+ setCenterDropTargetComponent,
2245
+ layoutRef,
2246
+ setIsSplit,
2247
+ setDirection
2248
+ } = useFlexLayoutSplitScreen({
2249
+ isSplitInitial: false,
2250
+ directionInitial: "row",
2251
+ parentDirection,
2252
+ selfContainerName: containerName,
2253
+ parentLayoutName,
2254
+ layoutName
2255
+ });
2256
+ const [isEmptyContent, setIsEmptyContent] = react.useState(false);
2257
+ const [activeIndex, setActiveIndex] = react.useState(0);
2258
+ const centerDropTargetComponentRef = react.useRef(centerDropTargetComponent);
2259
+ const activeIndexRef = react.useRef(activeIndex);
2260
+ react.useEffect(() => {
2261
+ const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).pipe(rxjs.take(1)).subscribe((layoutInfo) => {
2262
+ setSplitScreen(rootName, `${layoutName}=${screenKey}`, {
2263
+ afterDropTargetComponent: layoutInfo?.afterDropTargetComponent || [],
2264
+ beforeDropTargetComponent: layoutInfo?.beforeDropTargetComponent || [],
2265
+ centerDropTargetComponent: layoutInfo?.centerDropTargetComponent || initialCenterComponents || [],
2266
+ direction: layoutInfo?.direction || direction
2267
+ });
2268
+ });
2269
+ return () => {
2270
+ removeSplitScreenChild(rootName, layoutName);
2271
+ subscribe.unsubscribe();
2272
+ };
2273
+ }, [rootName, layoutName, initialCenterComponents]);
2274
+ react.useEffect(() => {
2275
+ const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).subscribe((layoutInfo) => {
2276
+ if (layoutInfo) {
2277
+ setBeforeDropTargetComponent([
2278
+ ...layoutInfo.beforeDropTargetComponent
2279
+ ]);
2280
+ setAfterDropTargetComponent([
2281
+ ...layoutInfo.afterDropTargetComponent
2282
+ ]);
2283
+ setCenterDropTargetComponent([
2284
+ ...layoutInfo.centerDropTargetComponent
2285
+ ]);
2286
+ setDirection(layoutInfo.direction);
2287
+ if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
2288
+ setIsSplit(true);
2289
+ } else if (layoutInfo.beforeDropTargetComponent.length === 0 && layoutInfo.centerDropTargetComponent.length === 0 && layoutInfo.afterDropTargetComponent.length === 0) {
2290
+ dropMovementEventSubject.next({
2291
+ state: "remove",
2292
+ targetContainerName: containerName,
2293
+ targetParentLayoutName: "",
2294
+ targetLayoutName: parentLayoutName
2295
+ });
2296
+ setIsEmptyContent(true);
2297
+ }
2298
+ }
2299
+ });
2300
+ return () => {
2301
+ subscribe.unsubscribe();
2302
+ };
2303
+ }, [rootName, layoutName]);
2304
+ react.useEffect(() => {
2305
+ const subscribe = dropMovementEventSubject.pipe(
2306
+ rxjs.distinctUntilChanged((prev, curr) => {
2307
+ const filterChildren2 = (obj) => {
2308
+ const {
2309
+ children,
2310
+ component,
2311
+ targetComponent,
2312
+ x,
2313
+ y,
2314
+ ...rest
2315
+ } = obj || {};
2316
+ return rest;
2317
+ };
2318
+ return equal__default.default(filterChildren2(prev), filterChildren2(curr));
2319
+ })
2320
+ ).subscribe((event) => {
2321
+ if (event.state === "remove") {
2322
+ if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
2323
+ requestAnimationFrame(() => {
2324
+ let removeCallback = (removeOrderName) => {
2325
+ if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
2326
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2327
+ orderName: removeOrderName,
2328
+ containerName: event.nextContainerName,
2329
+ parentLayoutName,
2330
+ layoutName,
2331
+ dropComponent: event.targetComponent,
2332
+ navigationTitle: event.dropTargetComponentEvent.navigationTitle,
2333
+ isUsePrefix: true,
2334
+ afterDropTargetComponent,
2335
+ beforeDropTargetComponent,
2336
+ centerDropTargetComponent,
2337
+ dropDocumentOutsideOption: event.dropTargetComponentEvent?.dropDocumentOutsideOption,
2338
+ screenKey: event.dropTargetComponentEvent.screenKey
2339
+ });
2340
+ setSplitScreen(
2341
+ rootName,
2342
+ `${layoutName}=${screenKey}`,
2343
+ {
2344
+ ...getCurrentSplitScreenComponents(
2345
+ rootName,
2346
+ `${layoutName}=${screenKey}`
2347
+ ) || {
2348
+ afterDropTargetComponent,
2349
+ beforeDropTargetComponent,
2350
+ centerDropTargetComponent,
2351
+ direction
2352
+ },
2353
+ ...targetComponentsMap
2354
+ }
2355
+ );
2356
+ Promise.resolve().then(
2357
+ () => event.dropEndCallback && event.dropEndCallback({
2358
+ x: event.x,
2359
+ y: event.y,
2360
+ containerName
2361
+ })
2362
+ );
2363
+ }
2364
+ };
2365
+ const currentComponents = getCurrentSplitScreenComponents(
2366
+ rootName,
2367
+ `${layoutName}=${screenKey}`
2368
+ );
2369
+ const afterList = handleRemove(
2370
+ currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
2371
+ event.targetContainerName,
2372
+ () => removeCallback("after")
2373
+ );
2374
+ const beforList = handleRemove(
2375
+ currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
2376
+ event.targetContainerName,
2377
+ () => removeCallback("before")
2378
+ );
2379
+ const centerList = handleRemove(
2380
+ currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
2381
+ event.targetContainerName,
2382
+ () => removeCallback("center")
2383
+ );
2384
+ setSplitScreen(
2385
+ rootName,
2386
+ `${layoutName}=${screenKey}`,
2387
+ {
2388
+ afterDropTargetComponent: afterList,
2389
+ beforeDropTargetComponent: beforList,
2390
+ centerDropTargetComponent: centerList,
2391
+ direction
2392
+ }
2393
+ );
2394
+ });
2395
+ }
2396
+ } else if (event.state === "append") {
2397
+ const {
2398
+ x,
2399
+ y,
2400
+ dropEndCallback,
2401
+ dropTargetComponentEvent,
2402
+ orderName,
2403
+ targetLayoutName,
2404
+ targetParentLayoutName,
2405
+ targetContainerName,
2406
+ targetComponent,
2407
+ nextContainerName,
2408
+ parentOrderName
2409
+ } = event;
2410
+ if (layoutRef.current && orderName && x && y && dropTargetComponentEvent && isInnerDrop({ x, y, element: layoutRef.current })) {
2411
+ const {
2412
+ direction: dropDirection,
2413
+ navigationTitle,
2414
+ dropDocumentOutsideOption,
2415
+ screenKey: containerScreenKey
2416
+ } = dropTargetComponentEvent;
2417
+ if (
2418
+ //orderName !== 'center' &&
2419
+ targetLayoutName === layoutName && targetComponent
2420
+ ) {
2421
+ if (dropDirection === parentDirection && orderName !== "center") {
2422
+ dropMovementEventSubject.next({
2423
+ state: "append",
2424
+ targetContainerName,
2425
+ targetParentLayoutName: "",
2426
+ targetLayoutName: parentLayoutName,
2427
+ targetComponent,
2428
+ nextContainerName: containerName,
2429
+ parentOrderName: getSelfOrderName(layoutName) || orderName,
2430
+ orderName,
2431
+ x,
2432
+ y,
2433
+ dropEndCallback,
2434
+ dropTargetComponentEvent: {
2435
+ navigationTitle,
2436
+ dropDocumentOutsideOption,
2437
+ direction: parentDirection,
2438
+ screenKey
2439
+ }
2440
+ });
2441
+ } else {
2442
+ if (orderName !== "center") {
2443
+ setDirection(dropDirection);
2444
+ setIsSplit(true);
2445
+ }
2446
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2447
+ orderName,
2448
+ parentOrderName,
2449
+ containerName: targetContainerName,
2450
+ nextContainerName,
2451
+ parentLayoutName,
2452
+ layoutName,
2453
+ dropComponent: targetComponent,
2454
+ navigationTitle,
2455
+ isUsePrefix: orderName !== "center",
2456
+ afterDropTargetComponent,
2457
+ beforeDropTargetComponent,
2458
+ centerDropTargetComponent,
2459
+ dropDocumentOutsideOption
2460
+ });
2461
+ setSplitScreen(
2462
+ rootName,
2463
+ `${layoutName}=${screenKey}`,
2464
+ {
2465
+ ...getCurrentSplitScreenComponents(
2466
+ rootName,
2467
+ `${layoutName}=${screenKey}`
2468
+ ) || {
2469
+ afterDropTargetComponent,
2470
+ beforeDropTargetComponent,
2471
+ centerDropTargetComponent,
2472
+ direction
2473
+ },
2474
+ ...targetComponentsMap,
2475
+ ...{ direction: dropDirection }
2476
+ }
2477
+ );
2478
+ Promise.resolve().then(
2479
+ () => event.dropEndCallback && event.dropEndCallback({
2480
+ x: event.x,
2481
+ y: event.y,
2482
+ containerName
2483
+ })
2484
+ );
2485
+ }
2486
+ }
2487
+ }
2488
+ }
2489
+ });
2490
+ return () => {
2491
+ subscribe.unsubscribe();
2492
+ };
2493
+ }, [
2494
+ direction,
2495
+ parentDirection,
2496
+ parentLayoutName,
2497
+ layoutName,
2498
+ beforeDropTargetComponent,
2499
+ afterDropTargetComponent,
2500
+ centerDropTargetComponent
2501
+ ]);
2502
+ react.useEffect(() => {
2503
+ centerDropTargetComponentRef.current = centerDropTargetComponent;
2504
+ }, [centerDropTargetComponent]);
2505
+ react.useEffect(() => {
2506
+ activeIndexRef.current = activeIndex;
2507
+ }, [activeIndex]);
2508
+ const [isOnlyOneScreen, setIsOnlyOneScreen] = react.useState(false);
2509
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isEmptyContent && /* @__PURE__ */ jsxRuntime.jsxs(
2510
+ "div",
2511
+ {
2512
+ className: `${FlexLayout_default["flex-split-screen"]}`,
2513
+ ref: layoutRef,
2514
+ children: [
2515
+ /* @__PURE__ */ jsxRuntime.jsxs(
2516
+ FlexLayout_default2,
2517
+ {
2518
+ direction,
2519
+ layoutName: `${layoutName}`,
2520
+ panelMovementMode: "bulldozer",
2521
+ children: [
2522
+ beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: beforeDropTargetComponent.map(
2523
+ ({
2524
+ containerName: cName,
2525
+ component,
2526
+ navigationTitle,
2527
+ dropDocumentOutsideOption,
2528
+ screenKey: screenKey2
2529
+ }, i) => /* @__PURE__ */ jsxRuntime.jsx(
2530
+ FlexLayoutContainer_default,
2531
+ {
2532
+ containerName: cName,
2533
+ isInitialResizable: true,
2534
+ isResizePanel: true,
2535
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2536
+ FlexLayoutSplitScreenChild,
2537
+ {
2538
+ parentDirection: direction,
2539
+ layoutName: `${layoutName}_before-${depth}`,
2540
+ parentLayoutName: layoutName,
2541
+ containerName: cName,
2542
+ depth: depth + 1,
2543
+ rootRef,
2544
+ screenKey: screenKey2,
2545
+ initialCenterComponents: [
2546
+ {
2547
+ navigationTitle,
2548
+ component,
2549
+ containerName: cName,
2550
+ dropDocumentOutsideOption,
2551
+ screenKey: screenKey2
2552
+ }
2553
+ ],
2554
+ rootName
2555
+ }
2556
+ )
2557
+ },
2558
+ cName
2559
+ )
2560
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", {}),
2561
+ centerDropTargetComponent.length != 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
2562
+ FlexLayoutContainer_default,
2563
+ {
2564
+ containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2565
+ isInitialResizable: true,
2566
+ isResizePanel: isSplit,
2567
+ children: isSplit ? /* @__PURE__ */ jsxRuntime.jsx("div", { "data-key": screenKey, children: /* @__PURE__ */ jsxRuntime.jsx(
2568
+ FlexLayoutSplitScreenChild,
2569
+ {
2570
+ parentDirection: direction,
2571
+ layoutName: `${layoutName}_center-${depth}`,
2572
+ parentLayoutName: layoutName,
2573
+ containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2574
+ depth: depth + 1,
2575
+ rootRef,
2576
+ initialCenterComponents: centerDropTargetComponent.map(
2577
+ ({
2578
+ navigationTitle,
2579
+ component,
2580
+ containerName: cName,
2581
+ dropDocumentOutsideOption,
2582
+ screenKey: centerScreenKey
2583
+ }) => ({
2584
+ navigationTitle,
2585
+ component,
2586
+ containerName: cName,
2587
+ dropDocumentOutsideOption,
2588
+ screenKey: centerScreenKey
2589
+ })
2590
+ ),
2591
+ screenKey,
2592
+ rootName
2593
+ }
2594
+ ) }) : /* @__PURE__ */ jsxRuntime.jsxs(
2595
+ FlexLayoutSplitScreenScrollBox_default,
2596
+ {
2597
+ keyName: (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName,
2598
+ isDefaultScrollStyle: true,
2599
+ children: [
2600
+ !isOnlyOneScreen && /* @__PURE__ */ jsxRuntime.jsx(
2601
+ "div",
2602
+ {
2603
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper-sticky"]}`,
2604
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2605
+ "div",
2606
+ {
2607
+ "data-is_split": isSplit,
2608
+ "data-layout_name": layoutName,
2609
+ "data-parent_layout_name": parentLayoutName,
2610
+ "data-container_name": `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2611
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper"]}`,
2612
+ children: [
2613
+ /* @__PURE__ */ jsxRuntime.jsx(
2614
+ FlexLayoutSplitScreenDragBoxContainer,
2615
+ {
2616
+ "data-layout_name": layoutName,
2617
+ layoutName,
2618
+ children: centerDropTargetComponent.map(
2619
+ (item, index) => /* @__PURE__ */ jsxRuntime.jsx(
2620
+ FlexLayoutSplitScreenDragBoxItem,
2621
+ {
2622
+ onClose: (ev) => {
2623
+ if (activeIndexRef.current === index && centerDropTargetComponent.length === 1) {
2624
+ dropMovementEventSubject.next(
2625
+ {
2626
+ state: "remove",
2627
+ targetContainerName: containerName,
2628
+ targetParentLayoutName: parentLayoutName,
2629
+ targetLayoutName: layoutName
2630
+ }
2631
+ );
2632
+ } else {
2633
+ if (centerDropTargetComponent.length === activeIndexRef.current + 1) {
2634
+ setActiveIndex(
2635
+ activeIndexRef.current - 1
2636
+ );
2637
+ }
2638
+ setCenterDropTargetComponent(
2639
+ (prev) => {
2640
+ const result = handleRemove(
2641
+ prev,
2642
+ item.containerName,
2643
+ () => {
2644
+ }
2645
+ );
2646
+ return result;
2647
+ }
2648
+ );
2649
+ }
2650
+ },
2651
+ isActive: activeIndex === index,
2652
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2653
+ FlexLayoutSplitScreenDragBox,
2654
+ {
2655
+ onClick: () => {
2656
+ setActiveIndex(
2657
+ index
2658
+ );
2659
+ },
2660
+ containerName: item.containerName,
2661
+ dropDocumentOutsideOption: item.dropDocumentOutsideOption,
2662
+ targetComponent: item.component,
2663
+ navigationTitle: item.navigationTitle,
2664
+ "data-container-name": item.containerName,
2665
+ "data-layout-name": layoutName,
2666
+ "data-parent-layout-name": parentLayoutName,
2667
+ dropEndCallback: ({
2668
+ x,
2669
+ y,
2670
+ containerName: appendContainerName
2671
+ }) => {
2672
+ if (!rootRef.current || !layoutRef.current)
2673
+ return;
2674
+ const isRootOver = isOverDrop(
2675
+ {
2676
+ x,
2677
+ y,
2678
+ element: rootRef.current
2679
+ }
2680
+ );
2681
+ const isLayoutInner = isInnerDrop(
2682
+ {
2683
+ x,
2684
+ y,
2685
+ element: layoutRef.current
2686
+ }
2687
+ );
2688
+ if (!isRootOver && !isLayoutInner || !isRootOver && isLayoutInner && centerDropTargetComponentRef.current.length > 1) {
2689
+ const option = {};
2690
+ if (centerDropTargetComponentRef.current.length > 1) {
2691
+ const {
2692
+ adjacentItem,
2693
+ adjacentIndex
2694
+ } = getAdjacentItem(
2695
+ centerDropTargetComponentRef.current,
2696
+ activeIndexRef.current
2697
+ );
2698
+ if (adjacentItem && activeIndexRef.current === index) {
2699
+ Object.assign(
2700
+ option,
2701
+ {
2702
+ x,
2703
+ y,
2704
+ targetComponent: adjacentItem.component,
2705
+ nextContainerName: adjacentItem.containerName,
2706
+ orderName: "center",
2707
+ dropTargetComponentEvent: {
2708
+ navigationTitle: adjacentItem.navigationTitle,
2709
+ dropDocumentOutsideOption: adjacentItem.dropDocumentOutsideOption,
2710
+ direction,
2711
+ screenKey
2712
+ }
2713
+ }
2714
+ );
2715
+ }
2716
+ }
2717
+ if (index === 0) {
2718
+ dropMovementEventSubject.next(
2719
+ {
2720
+ state: "remove",
2721
+ targetContainerName: item.containerName,
2722
+ targetParentLayoutName: parentLayoutName,
2723
+ targetLayoutName: layoutName,
2724
+ ...option
2725
+ }
2726
+ );
2727
+ } else {
2728
+ dropMovementEventSubject.next(
2729
+ {
2730
+ state: "remove",
2731
+ targetContainerName: item.containerName,
2732
+ targetParentLayoutName: "",
2733
+ targetLayoutName: layoutName,
2734
+ ...option
2735
+ }
2736
+ );
2737
+ }
2738
+ }
2739
+ },
2740
+ children: item.navigationTitle
2741
+ }
2742
+ )
2743
+ },
2744
+ item.navigationTitle + layoutName + item.containerName
2745
+ )
2746
+ )
2747
+ },
2748
+ layoutName
2749
+ ),
2750
+ /* @__PURE__ */ jsxRuntime.jsx(FlexLayoutSplitScreenDragBoxTitleMore, {})
2751
+ ]
2752
+ }
2753
+ )
2754
+ }
2755
+ ),
2756
+ (() => {
2757
+ const target = centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0];
2758
+ return target.component;
2759
+ })()
2760
+ ]
2761
+ }
2762
+ )
2763
+ },
2764
+ (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName
2765
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", {}),
2766
+ afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: afterDropTargetComponent.map(
2767
+ ({
2768
+ containerName: cName,
2769
+ component,
2770
+ navigationTitle,
2771
+ dropDocumentOutsideOption,
2772
+ screenKey: screenKey2
2773
+ }, i) => /* @__PURE__ */ jsxRuntime.jsx(
2774
+ FlexLayoutContainer_default,
2775
+ {
2776
+ containerName: cName,
2777
+ isInitialResizable: true,
2778
+ isResizePanel: i !== afterDropTargetComponent.length - 1,
2779
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2780
+ FlexLayoutSplitScreenChild,
2781
+ {
2782
+ parentDirection: direction,
2783
+ layoutName: `${layoutName}_after-${depth}`,
2784
+ parentLayoutName: layoutName,
2785
+ containerName: cName,
2786
+ depth: depth + 1,
2787
+ rootRef,
2788
+ screenKey: screenKey2,
2789
+ initialCenterComponents: [
2790
+ {
2791
+ navigationTitle,
2792
+ component,
2793
+ containerName: cName,
2794
+ dropDocumentOutsideOption,
2795
+ screenKey: screenKey2
2796
+ }
2797
+ ],
2798
+ rootName
2799
+ }
2800
+ )
2801
+ },
2802
+ cName
2803
+ )
2804
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", {})
2805
+ ]
2806
+ }
2807
+ ),
2808
+ boundaryContainerSize && /* @__PURE__ */ jsxRuntime.jsx(
2809
+ "div",
2810
+ {
2811
+ className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
2812
+ style: { ...boundaryContainerSize },
2813
+ children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
2814
+ }
2815
+ )
2816
+ ]
2817
+ }
2818
+ ) });
2819
+ }
2820
+ FlexLayoutSplitScreen.displayName = "FlexLayoutSplitScreen";
2821
+ var FlexLayoutSplitScreen_default = FlexLayoutSplitScreen;
2822
+ function clamp(n, min, max) {
2823
+ return Math.max(min, Math.min(max, n));
2824
+ }
2825
+ function pickDefaultScrollRoot() {
2826
+ if (typeof document === "undefined") return null;
2827
+ let el = document.body;
2828
+ while (el && el !== document.documentElement && el !== document.body) {
2829
+ const style = getComputedStyle(el);
2830
+ const oy = style.overflowY;
2831
+ const ox = style.overflowX;
2832
+ const scrollable = oy === "auto" || oy === "scroll" || ox === "auto" || ox === "scroll";
2833
+ if (scrollable) return el;
2834
+ el = el.parentElement;
2835
+ }
2836
+ return null;
2837
+ }
2838
+ function isVerticalScroll(root) {
2839
+ if (typeof window == "undefined") return true;
2840
+ if (!root) {
2841
+ return document.documentElement.scrollHeight > window.innerHeight + 1;
2842
+ }
2843
+ const el = root;
2844
+ return el.scrollHeight > el.clientHeight + 1;
2845
+ }
2846
+ var dpr = typeof window != "undefined" ? window.devicePixelRatio || 1 : 1;
2847
+ function quantizeToDevicePixel(n) {
2848
+ return Math.round(n * dpr) / dpr;
2849
+ }
2850
+ var FlexLayoutStickyBox = ({
2851
+ edge = "auto",
2852
+ offset = 16,
2853
+ scrollRoot = null,
2854
+ debug = false,
2855
+ children,
2856
+ style,
2857
+ className,
2858
+ onTranslateChange = () => {
2859
+ },
2860
+ ...rest
2861
+ }) => {
2862
+ const offsetRef = react.useRef(offset);
2863
+ const rootRef = react.useRef(null);
2864
+ const contentRef = react.useRef(null);
2865
+ const mutatingRef = react.useRef(false);
2866
+ const lastOffsetRef = react.useRef(0);
2867
+ const [resolvedEdge, setResolvedEdge] = react.useState("top");
2868
+ const rafId = react.useRef(null);
2869
+ const [contentDynamicStyle, setContentDynamicStyle] = react.useState({});
2870
+ react.useEffect(() => {
2871
+ setContentDynamicStyle({
2872
+ willChange: "transform",
2873
+ transition: "transform 50ms linear"
2874
+ });
2875
+ }, []);
2876
+ react.useEffect(() => {
2877
+ offsetRef.current = offset;
2878
+ scheduleUpdate();
2879
+ }, [offset]);
2880
+ const [ioRoot, setIoRoot] = react.useState(null);
2881
+ react.useEffect(() => {
2882
+ const root = scrollRoot ?? pickDefaultScrollRoot();
2883
+ setResolvedEdge(
2884
+ edge === "auto" ? isVerticalScroll(root) ? "top" : "left" : edge
2885
+ );
2886
+ setIoRoot(root);
2887
+ }, [edge, scrollRoot]);
2888
+ react.useEffect(() => {
2889
+ if (edge !== "auto") {
2890
+ setResolvedEdge(edge);
2891
+ return;
2892
+ }
2893
+ const vertical = isVerticalScroll(ioRoot);
2894
+ setResolvedEdge(vertical ? "top" : "left");
2895
+ }, [edge, ioRoot]);
2896
+ react.useEffect(() => {
2897
+ }, []);
2898
+ const scheduleUpdate = () => {
2899
+ if (rafId.current != null) return;
2900
+ rafId.current = requestAnimationFrame(() => {
2901
+ rafId.current = null;
2902
+ doUpdate();
2903
+ });
2904
+ };
2905
+ const doUpdate = () => {
2906
+ if (mutatingRef.current) return;
2907
+ mutatingRef.current = true;
2908
+ const rootEl = rootRef.current;
2909
+ const contentEl = contentRef.current;
2910
+ if (!rootEl || !contentEl) {
2911
+ mutatingRef.current = false;
2912
+ return;
2913
+ }
2914
+ const parentEl = rootEl.parentElement;
2915
+ if (!parentEl) {
2916
+ mutatingRef.current = false;
2917
+ return;
2918
+ }
2919
+ const rootBounds = ioRoot && "getBoundingClientRect" in ioRoot ? ioRoot.getBoundingClientRect() : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
2920
+ const parentRect = parentEl.getBoundingClientRect();
2921
+ const contentRect = contentEl.getBoundingClientRect();
2922
+ let newOffset = 0;
2923
+ if (resolvedEdge === "top" || resolvedEdge === "bottom") {
2924
+ const maxTranslate = Math.max(
2925
+ 0,
2926
+ parentRect.height - contentRect.height
2927
+ );
2928
+ let desiredTop = 0;
2929
+ if (resolvedEdge === "top") {
2930
+ desiredTop = rootBounds.top + offsetRef.current - parentRect.top;
2931
+ } else {
2932
+ const targetBottomFromParentTop = Math.min(
2933
+ parentRect.bottom,
2934
+ rootBounds.bottom - offsetRef.current
2935
+ ) - parentRect.top;
2936
+ desiredTop = targetBottomFromParentTop - contentRect.height;
2937
+ }
2938
+ newOffset = clamp(desiredTop, 0, maxTranslate);
2939
+ } else {
2940
+ const maxTranslate = Math.max(
2941
+ 0,
2942
+ parentRect.width - contentRect.width
2943
+ );
2944
+ let desiredLeft = 0;
2945
+ if (resolvedEdge === "left") {
2946
+ desiredLeft = rootBounds.left + offsetRef.current - parentRect.left;
2947
+ } else {
2948
+ const targetRightFromParentLeft = Math.min(
2949
+ parentRect.right,
2950
+ rootBounds.right - offsetRef.current
2951
+ ) - parentRect.left;
2952
+ desiredLeft = targetRightFromParentLeft - contentRect.width;
2953
+ }
2954
+ newOffset = clamp(desiredLeft, 0, maxTranslate);
2955
+ }
2956
+ const nextOffset = quantizeToDevicePixel(newOffset);
2957
+ if (Math.abs(lastOffsetRef.current - nextOffset) > 0.5) {
2958
+ if (resolvedEdge === "top" || resolvedEdge === "bottom") {
2959
+ contentEl.style.transform = `translateY(${nextOffset}px)`;
2960
+ } else {
2961
+ contentEl.style.transform = `translateX(${nextOffset}px)`;
2962
+ }
2963
+ lastOffsetRef.current = nextOffset;
2964
+ onTranslateChange(nextOffset, rootRef, contentRef);
2965
+ }
2966
+ if (debug) {
2967
+ rootEl.style.outline = "1px dashed rgba(0,0,0,.2)";
2968
+ contentEl.style.outline = "1px solid rgba(0,128,255,.35)";
2969
+ }
2970
+ queueMicrotask(() => {
2971
+ mutatingRef.current = false;
2972
+ });
2973
+ };
2974
+ react.useEffect(() => {
2975
+ if (typeof window == "undefined") return;
2976
+ const rootEl = rootRef.current;
2977
+ if (!rootEl) return;
2978
+ const parentEl = rootEl.parentElement;
2979
+ console.log(parentEl);
2980
+ if (!parentEl) return;
2981
+ const targets = [parentEl];
2982
+ const observerCallback = () => {
2983
+ if (!mutatingRef.current) scheduleUpdate();
2984
+ };
2985
+ const io = new IntersectionObserver(observerCallback, {
2986
+ root: ioRoot instanceof Element ? ioRoot : null,
2987
+ threshold: 0,
2988
+ rootMargin: "1px"
2989
+ });
2990
+ const ro = new ResizeObserver(observerCallback);
2991
+ targets.forEach((t) => io.observe(t));
2992
+ ro.observe(parentEl);
2993
+ if (contentRef.current) {
2994
+ ro.observe(contentRef.current);
2995
+ }
2996
+ const scrollTarget = ioRoot || window;
2997
+ scrollTarget.addEventListener("scroll", scheduleUpdate, {
2998
+ passive: true
2999
+ });
3000
+ window.addEventListener("resize", scheduleUpdate);
3001
+ scheduleUpdate();
3002
+ return () => {
3003
+ io.disconnect();
3004
+ ro.disconnect();
3005
+ scrollTarget.removeEventListener("scroll", scheduleUpdate);
3006
+ window.removeEventListener("resize", scheduleUpdate);
3007
+ if (rafId.current != null) {
3008
+ cancelAnimationFrame(rafId.current);
3009
+ rafId.current = null;
3010
+ }
3011
+ };
3012
+ }, [ioRoot, resolvedEdge, offset, debug]);
3013
+ return /* @__PURE__ */ jsxRuntime.jsx(
3014
+ "div",
3015
+ {
3016
+ ref: rootRef,
3017
+ className,
3018
+ style: {
3019
+ display: "block",
3020
+ minWidth: 0,
3021
+ minHeight: 0,
3022
+ height: "100%",
3023
+ // 부모 높이를 채우도록 설정
3024
+ ...style
3025
+ },
3026
+ ...rest,
3027
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3028
+ "div",
3029
+ {
3030
+ ref: contentRef,
3031
+ style: contentDynamicStyle,
3032
+ children
3033
+ }
3034
+ )
3035
+ }
3036
+ );
3037
+ };
3038
+ var FlexLayoutStickyBox_default = FlexLayoutStickyBox;
3039
+
3040
+ exports.FlexLayout = FlexLayout_default2;
3041
+ exports.FlexLayoutContainer = FlexLayoutContainer_default;
3042
+ exports.FlexLayoutResizePanel = FlexLayoutResizePanel_default;
3043
+ exports.FlexLayoutSplitScreen = FlexLayoutSplitScreen_default;
3044
+ exports.FlexLayoutSplitScreenDragBox = FlexLayoutSplitScreenDragBox;
3045
+ exports.FlexLayoutSplitScreenScrollBox = FlexLayoutSplitScreenScrollBox_default;
3046
+ exports.FlexLayoutStickyBox = FlexLayoutStickyBox_default;
3047
+ //# sourceMappingURL=components.cjs.map
3048
+ //# sourceMappingURL=components.cjs.map