docxodus 9.2.0 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  var DocxodusEditor = (() => {
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ try {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ } catch (e) {
13
+ throw mod = 0, e;
14
+ }
15
+ };
7
16
  var __export = (target, all) => {
8
17
  for (var name in all)
9
18
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,8 +25,101 @@ var DocxodusEditor = (() => {
16
25
  }
17
26
  return to;
18
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
19
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
37
 
38
+ // node_modules/bind-event-listener/dist/bind.js
39
+ var require_bind = __commonJS({
40
+ "node_modules/bind-event-listener/dist/bind.js"(exports) {
41
+ "use strict";
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.bind = void 0;
44
+ function bind3(target, _a) {
45
+ var type = _a.type, listener = _a.listener, options = _a.options;
46
+ target.addEventListener(type, listener, options);
47
+ return function unbind() {
48
+ target.removeEventListener(type, listener, options);
49
+ };
50
+ }
51
+ exports.bind = bind3;
52
+ }
53
+ });
54
+
55
+ // node_modules/bind-event-listener/dist/bind-all.js
56
+ var require_bind_all = __commonJS({
57
+ "node_modules/bind-event-listener/dist/bind-all.js"(exports) {
58
+ "use strict";
59
+ var __assign = exports && exports.__assign || function() {
60
+ __assign = Object.assign || function(t) {
61
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
62
+ s = arguments[i];
63
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
64
+ t[p] = s[p];
65
+ }
66
+ return t;
67
+ };
68
+ return __assign.apply(this, arguments);
69
+ };
70
+ Object.defineProperty(exports, "__esModule", { value: true });
71
+ exports.bindAll = void 0;
72
+ var bind_1 = require_bind();
73
+ function toOptions(value) {
74
+ if (typeof value === "undefined") {
75
+ return void 0;
76
+ }
77
+ if (typeof value === "boolean") {
78
+ return {
79
+ capture: value
80
+ };
81
+ }
82
+ return value;
83
+ }
84
+ function getBinding(original, sharedOptions) {
85
+ if (sharedOptions == null) {
86
+ return original;
87
+ }
88
+ var binding = __assign(__assign({}, original), { options: __assign(__assign({}, toOptions(sharedOptions)), toOptions(original.options)) });
89
+ return binding;
90
+ }
91
+ function bindAll4(target, bindings, sharedOptions) {
92
+ var unbinds = bindings.map(function(original) {
93
+ var binding = getBinding(original, sharedOptions);
94
+ return (0, bind_1.bind)(target, binding);
95
+ });
96
+ return function unbindAll() {
97
+ unbinds.forEach(function(unbind) {
98
+ return unbind();
99
+ });
100
+ };
101
+ }
102
+ exports.bindAll = bindAll4;
103
+ }
104
+ });
105
+
106
+ // node_modules/bind-event-listener/dist/index.js
107
+ var require_dist = __commonJS({
108
+ "node_modules/bind-event-listener/dist/index.js"(exports) {
109
+ "use strict";
110
+ Object.defineProperty(exports, "__esModule", { value: true });
111
+ exports.bindAll = exports.bind = void 0;
112
+ var bind_1 = require_bind();
113
+ Object.defineProperty(exports, "bind", { enumerable: true, get: function() {
114
+ return bind_1.bind;
115
+ } });
116
+ var bind_all_1 = require_bind_all();
117
+ Object.defineProperty(exports, "bindAll", { enumerable: true, get: function() {
118
+ return bind_all_1.bindAll;
119
+ } });
120
+ }
121
+ });
122
+
21
123
  // src/ribbon.ts
22
124
  var ribbon_exports = {};
23
125
  __export(ribbon_exports, {
@@ -162,9 +264,9 @@ var DocxodusEditor = (() => {
162
264
  for (const section of Array.from(sections)) {
163
265
  const index = parseInt(section.dataset.sectionIndex || "0", 10);
164
266
  const rawStart = section.dataset.pageNumStart;
165
- const start = rawStart === void 0 ? void 0 : parseInt(rawStart, 10);
267
+ const start2 = rawStart === void 0 ? void 0 : parseInt(rawStart, 10);
166
268
  map.set(index, {
167
- start: start !== void 0 && Number.isFinite(start) ? start : void 0,
269
+ start: start2 !== void 0 && Number.isFinite(start2) ? start2 : void 0,
168
270
  format: section.dataset.pageNumFmt
169
271
  });
170
272
  }
@@ -389,16 +491,16 @@ var DocxodusEditor = (() => {
389
491
  return null;
390
492
  }
391
493
  const groups = [];
392
- let start = 0;
393
- while (start < rows.length) {
394
- let end = start;
494
+ let start2 = 0;
495
+ while (start2 < rows.length) {
496
+ let end = start2;
395
497
  while (end < rows.length) {
396
498
  const candidate = this.createSimpleTableFragment(
397
499
  wrapper,
398
500
  table,
399
501
  body,
400
- rows.slice(start, end + 1),
401
- start === 0
502
+ rows.slice(start2, end + 1),
503
+ start2 === 0
402
504
  );
403
505
  const measured = this.measureElement(candidate, dims);
404
506
  if (measured.heightPt > maximumFragmentHeight) {
@@ -406,11 +508,11 @@ var DocxodusEditor = (() => {
406
508
  }
407
509
  end++;
408
510
  }
409
- if (end === start) {
511
+ if (end === start2) {
410
512
  return null;
411
513
  }
412
- groups.push(rows.slice(start, end));
413
- start = end;
514
+ groups.push(rows.slice(start2, end));
515
+ start2 = end;
414
516
  }
415
517
  if (groups.length < 2) {
416
518
  return null;
@@ -1725,9 +1827,9 @@ var DocxodusEditor = (() => {
1725
1827
  const commitStart = () => {
1726
1828
  const raw = pageStart.value.trim();
1727
1829
  if (raw === "") return;
1728
- const start = Number(raw);
1729
- if (!Number.isInteger(start) || start < 0) return;
1730
- this.setPageNumbering({ start });
1830
+ const start2 = Number(raw);
1831
+ if (!Number.isInteger(start2) || start2 < 0) return;
1832
+ this.setPageNumbering({ start: start2 });
1731
1833
  };
1732
1834
  pageStart.addEventListener("blur", commitStart);
1733
1835
  pageStart.addEventListener("keydown", (e) => {
@@ -1778,8 +1880,8 @@ var DocxodusEditor = (() => {
1778
1880
  if (pageFmt) pageFmt.value = this.sectionInfo?.pageNumberFormat ?? "";
1779
1881
  const pageStart = band.querySelector("[data-hf-pagestart]");
1780
1882
  if (pageStart && document.activeElement !== pageStart) {
1781
- const start = this.sectionInfo?.pageNumberStart;
1782
- pageStart.value = start === void 0 ? "" : String(start);
1883
+ const start2 = this.sectionInfo?.pageNumberStart;
1884
+ pageStart.value = start2 === void 0 ? "" : String(start2);
1783
1885
  }
1784
1886
  const inherited = this.refFor(which, kind)?.inherited === true;
1785
1887
  band.toggleAttribute("data-hf-inherited", inherited);
@@ -1802,90 +1904,2491 @@ var DocxodusEditor = (() => {
1802
1904
  body.appendChild(this.placeholder(which, kind));
1803
1905
  return;
1804
1906
  }
1805
- for (const anchorId of anchors) {
1806
- const el = this.renderStoryBlock(anchorId);
1807
- if (!el) continue;
1808
- body.appendChild(el);
1809
- this.adoptBlock(el, anchorId);
1810
- this.callbacks.wireBlock(el);
1907
+ for (const anchorId of anchors) {
1908
+ const el = this.renderStoryBlock(anchorId);
1909
+ if (!el) continue;
1910
+ body.appendChild(el);
1911
+ this.adoptBlock(el, anchorId);
1912
+ this.callbacks.wireBlock(el);
1913
+ }
1914
+ }
1915
+ /**
1916
+ * Mark a story paragraph as belonging to this region. The full anchor id is stamped alongside
1917
+ * `data-anchor` (which carries only the bare unid, matching the body's convention) so band
1918
+ * chrome can address the block without going through the editor's unid map. Called on first
1919
+ * render AND after an incremental swap, which replaces the DOM node.
1920
+ */
1921
+ adoptBlock(el, anchorId) {
1922
+ const body = this.blockRootOf(el);
1923
+ if (!body) return;
1924
+ el.setAttribute("data-hf-anchor", anchorId);
1925
+ if (el.dataset.hfAdopted === "true") return;
1926
+ el.dataset.hfAdopted = "true";
1927
+ el.addEventListener("focus", () => {
1928
+ body.querySelectorAll("[data-hf-focused]").forEach((sib) => sib.removeAttribute("data-hf-focused"));
1929
+ el.setAttribute("data-hf-focused", "true");
1930
+ });
1931
+ }
1932
+ renderStoryBlock(anchorId) {
1933
+ const html = this.bridge.RenderBlockHtml(
1934
+ this.handle,
1935
+ anchorId,
1936
+ this.options.cssPrefix,
1937
+ this.options.fabricateClasses
1938
+ );
1939
+ if (html.charCodeAt(0) === 123) return null;
1940
+ return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
1941
+ }
1942
+ placeholder(which, kind) {
1943
+ const el = document.createElement("div");
1944
+ el.className = "docx-hf-placeholder";
1945
+ el.setAttribute("data-hf-placeholder", "");
1946
+ const label = KIND_LABELS.find((k) => k.value === kind)?.label ?? kind;
1947
+ el.textContent = `No ${label.toLowerCase()} ${which} \u2014 pick a kind to create one.`;
1948
+ return el;
1949
+ }
1950
+ /**
1951
+ * Surface the caveat that comes with the selected kind. Turning on first/even means those pages
1952
+ * stop using the Default stories entirely, which bites hardest on the OTHER band: enabling an
1953
+ * even header with no even footer leaves even pages footer-less, and enabling a first-page
1954
+ * header with an empty first-page footer leaves page 1 footer-less. The note is shown whenever
1955
+ * first/even is selected (the behavior change is real either way); the fix button appears only
1956
+ * when the counterpart story is missing entirely, which is what a user almost always wants next.
1957
+ */
1958
+ renderKindWarning(which) {
1959
+ const band = this.bandFor(which);
1960
+ const warning = band.querySelector("[data-hf-warning]");
1961
+ if (!warning) return;
1962
+ const kind = this.kinds[which];
1963
+ if (kind === "default") {
1964
+ warning.hidden = true;
1965
+ warning.textContent = "";
1966
+ return;
1967
+ }
1968
+ const other = which === "header" ? "footer" : "header";
1969
+ warning.hidden = false;
1970
+ warning.textContent = `${kind === "even" ? EVEN_WARNING : FIRST_WARNING} `;
1971
+ if (this.partUriFor(other, kind)) return;
1972
+ const fix = document.createElement("button");
1973
+ fix.type = "button";
1974
+ fix.setAttribute("data-hf-fix-counterpart", "");
1975
+ fix.textContent = `Also create a ${kind === "even" ? "matching even" : "first-page"} ${other}`;
1976
+ fix.addEventListener("click", () => {
1977
+ this.setKind(other, kind);
1978
+ this.renderKindWarning(which);
1979
+ });
1980
+ warning.appendChild(fix);
1981
+ }
1982
+ };
1983
+ function parseResult(json) {
1984
+ try {
1985
+ return JSON.parse(json);
1986
+ } catch {
1987
+ return { success: false };
1988
+ }
1989
+ }
1990
+
1991
+ // node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
1992
+ function _arrayWithHoles(r) {
1993
+ if (Array.isArray(r)) return r;
1994
+ }
1995
+
1996
+ // node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
1997
+ function _iterableToArrayLimit(r, l) {
1998
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
1999
+ if (null != t) {
2000
+ var e, n, i, u, a = [], f = true, o = false;
2001
+ try {
2002
+ if (i = (t = t.call(r)).next, 0 === l) {
2003
+ if (Object(t) !== t) return;
2004
+ f = false;
2005
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
2006
+ } catch (r2) {
2007
+ o = true, n = r2;
2008
+ } finally {
2009
+ try {
2010
+ if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
2011
+ } finally {
2012
+ if (o) throw n;
2013
+ }
2014
+ }
2015
+ return a;
2016
+ }
2017
+ }
2018
+
2019
+ // node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
2020
+ function _arrayLikeToArray(r, a) {
2021
+ (null == a || a > r.length) && (a = r.length);
2022
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
2023
+ return n;
2024
+ }
2025
+
2026
+ // node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
2027
+ function _unsupportedIterableToArray(r, a) {
2028
+ if (r) {
2029
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2030
+ var t = {}.toString.call(r).slice(8, -1);
2031
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
2032
+ }
2033
+ }
2034
+
2035
+ // node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
2036
+ function _nonIterableRest() {
2037
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2038
+ }
2039
+
2040
+ // node_modules/@babel/runtime/helpers/esm/slicedToArray.js
2041
+ function _slicedToArray(r, e) {
2042
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2043
+ }
2044
+
2045
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter.js
2046
+ var import_bind_event_listener4 = __toESM(require_dist());
2047
+
2048
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/honey-pot-data-attribute.js
2049
+ var honeyPotDataAttribute = "data-pdnd-honey-pot";
2050
+
2051
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/is-honey-pot-element.js
2052
+ function isHoneyPotElement(target) {
2053
+ return target instanceof Element && target.hasAttribute(honeyPotDataAttribute);
2054
+ }
2055
+
2056
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/get-element-from-point-without-honey-pot.js
2057
+ function getElementFromPointWithoutHoneypot(client) {
2058
+ var _document$elementsFro = document.elementsFromPoint(client.x, client.y), _document$elementsFro2 = _slicedToArray(_document$elementsFro, 2), top2 = _document$elementsFro2[0], second = _document$elementsFro2[1];
2059
+ if (!top2) {
2060
+ return null;
2061
+ }
2062
+ if (isHoneyPotElement(top2)) {
2063
+ return second !== null && second !== void 0 ? second : null;
2064
+ }
2065
+ return top2;
2066
+ }
2067
+
2068
+ // node_modules/@babel/runtime/helpers/esm/typeof.js
2069
+ function _typeof(o) {
2070
+ "@babel/helpers - typeof";
2071
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
2072
+ return typeof o2;
2073
+ } : function(o2) {
2074
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
2075
+ }, _typeof(o);
2076
+ }
2077
+
2078
+ // node_modules/@babel/runtime/helpers/esm/toPrimitive.js
2079
+ function toPrimitive(t, r) {
2080
+ if ("object" != _typeof(t) || !t) return t;
2081
+ var e = t[Symbol.toPrimitive];
2082
+ if (void 0 !== e) {
2083
+ var i = e.call(t, r || "default");
2084
+ if ("object" != _typeof(i)) return i;
2085
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2086
+ }
2087
+ return ("string" === r ? String : Number)(t);
2088
+ }
2089
+
2090
+ // node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
2091
+ function toPropertyKey(t) {
2092
+ var i = toPrimitive(t, "string");
2093
+ return "symbol" == _typeof(i) ? i : i + "";
2094
+ }
2095
+
2096
+ // node_modules/@babel/runtime/helpers/esm/defineProperty.js
2097
+ function _defineProperty(e, r, t) {
2098
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
2099
+ value: t,
2100
+ enumerable: true,
2101
+ configurable: true,
2102
+ writable: true
2103
+ }) : e[r] = t, e;
2104
+ }
2105
+
2106
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/make-honey-pot-fix.js
2107
+ var import_bind_event_listener = __toESM(require_dist());
2108
+
2109
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/max-z-index.js
2110
+ var maxZIndex = 2147483647;
2111
+
2112
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/popover-reset-styles.js
2113
+ var popoverResetUserAgentStyles = {
2114
+ inset: "unset",
2115
+ border: "none",
2116
+ padding: 0,
2117
+ margin: 0,
2118
+ overflow: "visible",
2119
+ color: "inherit",
2120
+ background: "transparent",
2121
+ width: "auto",
2122
+ height: "auto"
2123
+ };
2124
+
2125
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/public-utils/once.js
2126
+ function once(fn) {
2127
+ var cache = null;
2128
+ return function wrapped() {
2129
+ if (!cache) {
2130
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2131
+ args[_key] = arguments[_key];
2132
+ }
2133
+ var result = fn.apply(this, args);
2134
+ cache = {
2135
+ result
2136
+ };
2137
+ }
2138
+ return cache.result;
2139
+ };
2140
+ }
2141
+
2142
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/supports-popover.js
2143
+ var supportsPopover = once(function supportsPopover2() {
2144
+ return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.showPopover === "function";
2145
+ });
2146
+
2147
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/make-honey-pot-fix.js
2148
+ function ownKeys(e, r) {
2149
+ var t = Object.keys(e);
2150
+ if (Object.getOwnPropertySymbols) {
2151
+ var o = Object.getOwnPropertySymbols(e);
2152
+ r && (o = o.filter(function(r2) {
2153
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
2154
+ })), t.push.apply(t, o);
2155
+ }
2156
+ return t;
2157
+ }
2158
+ function _objectSpread(e) {
2159
+ for (var r = 1; r < arguments.length; r++) {
2160
+ var t = null != arguments[r] ? arguments[r] : {};
2161
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
2162
+ _defineProperty(e, r2, t[r2]);
2163
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
2164
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
2165
+ });
2166
+ }
2167
+ return e;
2168
+ }
2169
+ var honeyPotSize = 2;
2170
+ var halfHoneyPotSize = honeyPotSize / 2;
2171
+ function floorToClosestPixel(point) {
2172
+ return {
2173
+ x: Math.floor(point.x),
2174
+ y: Math.floor(point.y)
2175
+ };
2176
+ }
2177
+ function pullBackByHalfHoneyPotSize(point) {
2178
+ return {
2179
+ x: point.x - halfHoneyPotSize,
2180
+ y: point.y - halfHoneyPotSize
2181
+ };
2182
+ }
2183
+ function preventGoingBackwardsOffScreen(point) {
2184
+ return {
2185
+ x: Math.max(point.x, 0),
2186
+ y: Math.max(point.y, 0)
2187
+ };
2188
+ }
2189
+ function preventGoingForwardsOffScreen(point) {
2190
+ return {
2191
+ x: Math.min(point.x, window.innerWidth - honeyPotSize),
2192
+ y: Math.min(point.y, window.innerHeight - honeyPotSize)
2193
+ };
2194
+ }
2195
+ function getHoneyPotRectFor(_ref) {
2196
+ var client = _ref.client;
2197
+ var point = preventGoingForwardsOffScreen(preventGoingBackwardsOffScreen(pullBackByHalfHoneyPotSize(floorToClosestPixel(client))));
2198
+ return DOMRect.fromRect({
2199
+ x: point.x,
2200
+ y: point.y,
2201
+ width: honeyPotSize,
2202
+ height: honeyPotSize
2203
+ });
2204
+ }
2205
+ function getRectStyles(_ref2) {
2206
+ var clientRect = _ref2.clientRect;
2207
+ return {
2208
+ left: "".concat(clientRect.left, "px"),
2209
+ top: "".concat(clientRect.top, "px"),
2210
+ width: "".concat(clientRect.width, "px"),
2211
+ height: "".concat(clientRect.height, "px")
2212
+ };
2213
+ }
2214
+ function isWithin(_ref3) {
2215
+ var client = _ref3.client, clientRect = _ref3.clientRect;
2216
+ return (
2217
+ // is within horizontal bounds
2218
+ client.x >= clientRect.x && client.x <= clientRect.x + clientRect.width && // is within vertical bounds
2219
+ client.y >= clientRect.y && client.y <= clientRect.y + clientRect.height
2220
+ );
2221
+ }
2222
+ function mountHoneyPot(_ref4) {
2223
+ var initial = _ref4.initial;
2224
+ var element = document.createElement("div");
2225
+ element.setAttribute(honeyPotDataAttribute, "true");
2226
+ if (supportsPopover()) {
2227
+ element.setAttribute("popover", "manual");
2228
+ }
2229
+ var clientRect = getHoneyPotRectFor({
2230
+ client: initial
2231
+ });
2232
+ Object.assign(element.style, _objectSpread(_objectSpread({
2233
+ position: "fixed"
2234
+ }, supportsPopover() ? (
2235
+ // needs to come first as it has 'inset: unset' which
2236
+ // needs to be overridden by our top / left values
2237
+ popoverResetUserAgentStyles
2238
+ ) : {
2239
+ // Fallback: using maximum possible z-index so that this element
2240
+ // will always be on top of other positioned content.
2241
+ zIndex: maxZIndex
2242
+ }), {}, {
2243
+ // Setting a background color explicitly to avoid any inherited styles.
2244
+ // Looks like this could be `opacity: 0`, but worried that _might_
2245
+ // cause the element to be ignored on some platforms.
2246
+ // When debugging, set backgroundColor to something like "red".
2247
+ backgroundColor: "transparent",
2248
+ // Being explicit to avoid inheriting styles
2249
+ padding: 0,
2250
+ margin: 0,
2251
+ boxSizing: "border-box",
2252
+ // We want this element to absorb pointer events,
2253
+ // it's kind of the whole point 😉
2254
+ pointerEvents: "auto"
2255
+ }, getRectStyles({
2256
+ clientRect
2257
+ })));
2258
+ document.body.appendChild(element);
2259
+ if (supportsPopover()) {
2260
+ element.showPopover();
2261
+ }
2262
+ var unbindPointerMove = (0, import_bind_event_listener.bind)(window, {
2263
+ type: "pointermove",
2264
+ listener: function listener(event) {
2265
+ var client = {
2266
+ x: event.clientX,
2267
+ y: event.clientY
2268
+ };
2269
+ clientRect = getHoneyPotRectFor({
2270
+ client
2271
+ });
2272
+ Object.assign(element.style, getRectStyles({
2273
+ clientRect
2274
+ }));
2275
+ },
2276
+ // using capture so we are less likely to be impacted by event stopping
2277
+ options: {
2278
+ capture: true
2279
+ }
2280
+ });
2281
+ return function finish(_ref5) {
2282
+ var current = _ref5.current;
2283
+ unbindPointerMove();
2284
+ if (isWithin({
2285
+ client: current,
2286
+ clientRect
2287
+ })) {
2288
+ element.remove();
2289
+ return;
2290
+ }
2291
+ function cleanup() {
2292
+ unbindPostDragEvents();
2293
+ element.remove();
2294
+ }
2295
+ var unbindPostDragEvents = (0, import_bind_event_listener.bindAll)(window, [
2296
+ {
2297
+ type: "pointerdown",
2298
+ listener: cleanup
2299
+ },
2300
+ {
2301
+ type: "pointermove",
2302
+ listener: cleanup
2303
+ },
2304
+ {
2305
+ type: "focusin",
2306
+ listener: cleanup
2307
+ },
2308
+ {
2309
+ type: "focusout",
2310
+ listener: cleanup
2311
+ },
2312
+ // a 'pointerdown' should happen before 'dragstart', but just being super safe
2313
+ {
2314
+ type: "dragstart",
2315
+ listener: cleanup
2316
+ },
2317
+ // if the user has dragged something out of the window
2318
+ // and then is dragging something back into the window
2319
+ // the first events we will see are "dragenter" (and then "dragover").
2320
+ // So if we see any of these we need to clear the post drag fix.
2321
+ {
2322
+ type: "dragenter",
2323
+ listener: cleanup
2324
+ },
2325
+ {
2326
+ type: "dragover",
2327
+ listener: cleanup
2328
+ }
2329
+ // Not adding a "wheel" event listener, as "wheel" by itself does not
2330
+ // resolve the bug.
2331
+ ], {
2332
+ // Using `capture` so less likely to be impacted by other code stopping events
2333
+ capture: true
2334
+ });
2335
+ };
2336
+ }
2337
+ function makeHoneyPotFix() {
2338
+ var latestPointerMove = null;
2339
+ function bindEvents() {
2340
+ latestPointerMove = null;
2341
+ return (0, import_bind_event_listener.bind)(window, {
2342
+ type: "pointermove",
2343
+ listener: function listener(event) {
2344
+ latestPointerMove = {
2345
+ x: event.clientX,
2346
+ y: event.clientY
2347
+ };
2348
+ },
2349
+ // listening for pointer move in capture phase
2350
+ // so we are less likely to be impacted by events being stopped.
2351
+ options: {
2352
+ capture: true
2353
+ }
2354
+ });
2355
+ }
2356
+ function getOnPostDispatch() {
2357
+ var finish = null;
2358
+ return function onPostEvent(_ref6) {
2359
+ var eventName = _ref6.eventName, payload = _ref6.payload;
2360
+ if (eventName === "onDragStart") {
2361
+ var input = payload.location.initial.input;
2362
+ var initial = latestPointerMove !== null && latestPointerMove !== void 0 ? latestPointerMove : {
2363
+ x: input.clientX,
2364
+ y: input.clientY
2365
+ };
2366
+ finish = mountHoneyPot({
2367
+ initial
2368
+ });
2369
+ }
2370
+ if (eventName === "onDrop") {
2371
+ var _finish;
2372
+ var _input = payload.location.current.input;
2373
+ (_finish = finish) === null || _finish === void 0 || _finish({
2374
+ current: {
2375
+ x: _input.clientX,
2376
+ y: _input.clientY
2377
+ }
2378
+ });
2379
+ finish = null;
2380
+ latestPointerMove = null;
2381
+ }
2382
+ };
2383
+ }
2384
+ return {
2385
+ bindEvents,
2386
+ getOnPostDispatch
2387
+ };
2388
+ }
2389
+
2390
+ // node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
2391
+ function _arrayWithoutHoles(r) {
2392
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
2393
+ }
2394
+
2395
+ // node_modules/@babel/runtime/helpers/esm/iterableToArray.js
2396
+ function _iterableToArray(r) {
2397
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
2398
+ }
2399
+
2400
+ // node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
2401
+ function _nonIterableSpread() {
2402
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2403
+ }
2404
+
2405
+ // node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
2406
+ function _toConsumableArray(r) {
2407
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
2408
+ }
2409
+
2410
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/lifecycle-manager.js
2411
+ var import_bind_event_listener3 = __toESM(require_dist());
2412
+
2413
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/is-firefox.js
2414
+ var isFirefox = once(function isFirefox2() {
2415
+ if (false) {
2416
+ return false;
2417
+ }
2418
+ return navigator.userAgent.includes("Firefox");
2419
+ });
2420
+
2421
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/is-safari.js
2422
+ var isSafari = once(function isSafari2() {
2423
+ if (false) {
2424
+ return false;
2425
+ }
2426
+ var _navigator = navigator, userAgent = _navigator.userAgent;
2427
+ return userAgent.includes("AppleWebKit") && !userAgent.includes("Chrome");
2428
+ });
2429
+
2430
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/changing-window/count-events-for-safari.js
2431
+ var import_bind_event_listener2 = __toESM(require_dist());
2432
+ var symbols = {
2433
+ isLeavingWindow: /* @__PURE__ */ Symbol("leaving"),
2434
+ isEnteringWindow: /* @__PURE__ */ Symbol("entering")
2435
+ };
2436
+ function isLeavingWindowInSafari(_ref2) {
2437
+ var dragLeave = _ref2.dragLeave;
2438
+ if (!isSafari()) {
2439
+ return false;
2440
+ }
2441
+ return dragLeave.hasOwnProperty(symbols.isLeavingWindow);
2442
+ }
2443
+ (function fixSafari() {
2444
+ if (typeof window === "undefined") {
2445
+ return;
2446
+ }
2447
+ if (false) {
2448
+ return;
2449
+ }
2450
+ if (!isSafari()) {
2451
+ return;
2452
+ }
2453
+ function getInitialState() {
2454
+ return {
2455
+ enterCount: 0,
2456
+ isOverWindow: false
2457
+ };
2458
+ }
2459
+ var state = getInitialState();
2460
+ function resetState() {
2461
+ state = getInitialState();
2462
+ }
2463
+ (0, import_bind_event_listener2.bindAll)(
2464
+ window,
2465
+ [{
2466
+ type: "dragstart",
2467
+ listener: function listener() {
2468
+ state.enterCount = 0;
2469
+ state.isOverWindow = true;
2470
+ }
2471
+ }, {
2472
+ type: "drop",
2473
+ listener: resetState
2474
+ }, {
2475
+ type: "dragend",
2476
+ listener: resetState
2477
+ }, {
2478
+ type: "dragenter",
2479
+ listener: function listener(event) {
2480
+ if (!state.isOverWindow && state.enterCount === 0) {
2481
+ event[symbols.isEnteringWindow] = true;
2482
+ }
2483
+ state.isOverWindow = true;
2484
+ state.enterCount++;
2485
+ }
2486
+ }, {
2487
+ type: "dragleave",
2488
+ listener: function listener(event) {
2489
+ state.enterCount--;
2490
+ if (state.isOverWindow && state.enterCount === 0) {
2491
+ event[symbols.isLeavingWindow] = true;
2492
+ state.isOverWindow = false;
2493
+ }
2494
+ }
2495
+ }],
2496
+ // using `capture: true` so that adding event listeners
2497
+ // in bubble phase will have the correct symbols
2498
+ {
2499
+ capture: true
2500
+ }
2501
+ );
2502
+ })();
2503
+
2504
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/changing-window/is-from-another-window.js
2505
+ function isNodeLike(target) {
2506
+ return "nodeName" in target;
2507
+ }
2508
+ function isFromAnotherWindow(eventTarget) {
2509
+ return isNodeLike(eventTarget) && eventTarget.ownerDocument !== document;
2510
+ }
2511
+
2512
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/changing-window/is-leaving-window.js
2513
+ function isLeavingWindow(_ref) {
2514
+ var dragLeave = _ref.dragLeave;
2515
+ var type = dragLeave.type, relatedTarget = dragLeave.relatedTarget;
2516
+ if (type !== "dragleave") {
2517
+ return false;
2518
+ }
2519
+ if (isSafari()) {
2520
+ return isLeavingWindowInSafari({
2521
+ dragLeave
2522
+ });
2523
+ }
2524
+ if (relatedTarget == null) {
2525
+ return true;
2526
+ }
2527
+ if (isFirefox()) {
2528
+ return isFromAnotherWindow(relatedTarget);
2529
+ }
2530
+ return relatedTarget instanceof HTMLIFrameElement;
2531
+ }
2532
+
2533
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/detect-broken-drag.js
2534
+ function getBindingsForBrokenDrags(_ref) {
2535
+ var onDragEnd = _ref.onDragEnd;
2536
+ return [
2537
+ // ## Detecting drag ending for removed draggables
2538
+ //
2539
+ // If a draggable element is removed during a drag and the user drops:
2540
+ // 1. if over a valid drop target: we get a "drop" event to know the drag is finished
2541
+ // 2. if not over a valid drop target (or cancelled): we get nothing
2542
+ // The "dragend" event will not fire on the source draggable if it has been
2543
+ // removed from the DOM.
2544
+ // So we need to figure out if a drag operation has finished by looking at other events
2545
+ // We can do this by looking at other events
2546
+ // ### First detection: "pointermove" events
2547
+ // 1. "pointermove" events cannot fire during a drag and drop operation
2548
+ // according to the spec. So if we get a "pointermove" it means that
2549
+ // the drag and drop operations has finished. So if we get a "pointermove"
2550
+ // we know that the drag is over
2551
+ // 2. 🦊😤 Drag and drop operations are _supposed_ to suppress
2552
+ // other pointer events. However, firefox will allow a few
2553
+ // pointer event to get through after a drag starts.
2554
+ // The most I've seen is 3
2555
+ {
2556
+ type: "pointermove",
2557
+ listener: /* @__PURE__ */ (function() {
2558
+ var callCount = 0;
2559
+ return function listener() {
2560
+ if (callCount < 20) {
2561
+ callCount++;
2562
+ return;
2563
+ }
2564
+ onDragEnd();
2565
+ };
2566
+ })()
2567
+ },
2568
+ // ### Second detection: "pointerdown" events
2569
+ // If we receive this event then we know that a drag operation has finished
2570
+ // and potentially another one is about to start.
2571
+ // Note: `pointerdown` fires on all browsers / platforms before "dragstart"
2572
+ {
2573
+ type: "pointerdown",
2574
+ listener: onDragEnd
2575
+ }
2576
+ ];
2577
+ }
2578
+
2579
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/get-input.js
2580
+ function getInput(event) {
2581
+ return {
2582
+ altKey: event.altKey,
2583
+ button: event.button,
2584
+ buttons: event.buttons,
2585
+ ctrlKey: event.ctrlKey,
2586
+ metaKey: event.metaKey,
2587
+ shiftKey: event.shiftKey,
2588
+ clientX: event.clientX,
2589
+ clientY: event.clientY,
2590
+ pageX: event.pageX,
2591
+ pageY: event.pageY
2592
+ };
2593
+ }
2594
+
2595
+ // node_modules/raf-schd/dist/raf-schd.esm.js
2596
+ var rafSchd = function rafSchd2(fn) {
2597
+ var lastArgs = [];
2598
+ var frameId = null;
2599
+ var wrapperFn = function wrapperFn2() {
2600
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2601
+ args[_key] = arguments[_key];
2602
+ }
2603
+ lastArgs = args;
2604
+ if (frameId) {
2605
+ return;
2606
+ }
2607
+ frameId = requestAnimationFrame(function() {
2608
+ frameId = null;
2609
+ fn.apply(void 0, lastArgs);
2610
+ });
2611
+ };
2612
+ wrapperFn.cancel = function() {
2613
+ if (!frameId) {
2614
+ return;
2615
+ }
2616
+ cancelAnimationFrame(frameId);
2617
+ frameId = null;
2618
+ };
2619
+ return wrapperFn;
2620
+ };
2621
+ var raf_schd_esm_default = rafSchd;
2622
+
2623
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/dispatch-consumer-event.js
2624
+ var scheduleOnDrag = raf_schd_esm_default(function(fn) {
2625
+ return fn();
2626
+ });
2627
+ var dragStart = /* @__PURE__ */ (function() {
2628
+ var scheduled = null;
2629
+ function schedule(fn) {
2630
+ var frameId = requestAnimationFrame(function() {
2631
+ scheduled = null;
2632
+ fn();
2633
+ });
2634
+ scheduled = {
2635
+ frameId,
2636
+ fn
2637
+ };
2638
+ }
2639
+ function flush() {
2640
+ if (scheduled) {
2641
+ cancelAnimationFrame(scheduled.frameId);
2642
+ scheduled.fn();
2643
+ scheduled = null;
2644
+ }
2645
+ }
2646
+ return {
2647
+ schedule,
2648
+ flush
2649
+ };
2650
+ })();
2651
+ function makeDispatch(_ref) {
2652
+ var source = _ref.source, initial = _ref.initial, dispatchEvent = _ref.dispatchEvent;
2653
+ var previous = {
2654
+ dropTargets: []
2655
+ };
2656
+ function safeDispatch(args) {
2657
+ dispatchEvent(args);
2658
+ previous = {
2659
+ dropTargets: args.payload.location.current.dropTargets
2660
+ };
2661
+ }
2662
+ var dispatch = {
2663
+ start: function start2(_ref2) {
2664
+ var nativeSetDragImage = _ref2.nativeSetDragImage;
2665
+ var location2 = {
2666
+ current: initial,
2667
+ previous,
2668
+ initial
2669
+ };
2670
+ safeDispatch({
2671
+ eventName: "onGenerateDragPreview",
2672
+ payload: {
2673
+ source,
2674
+ location: location2,
2675
+ nativeSetDragImage
2676
+ }
2677
+ });
2678
+ dragStart.schedule(function() {
2679
+ safeDispatch({
2680
+ eventName: "onDragStart",
2681
+ payload: {
2682
+ source,
2683
+ location: location2
2684
+ }
2685
+ });
2686
+ });
2687
+ },
2688
+ dragUpdate: function dragUpdate(_ref3) {
2689
+ var current = _ref3.current;
2690
+ dragStart.flush();
2691
+ scheduleOnDrag.cancel();
2692
+ safeDispatch({
2693
+ eventName: "onDropTargetChange",
2694
+ payload: {
2695
+ source,
2696
+ location: {
2697
+ initial,
2698
+ previous,
2699
+ current
2700
+ }
2701
+ }
2702
+ });
2703
+ },
2704
+ drag: function drag(_ref4) {
2705
+ var current = _ref4.current;
2706
+ scheduleOnDrag(function() {
2707
+ dragStart.flush();
2708
+ var location2 = {
2709
+ initial,
2710
+ previous,
2711
+ current
2712
+ };
2713
+ safeDispatch({
2714
+ eventName: "onDrag",
2715
+ payload: {
2716
+ source,
2717
+ location: location2
2718
+ }
2719
+ });
2720
+ });
2721
+ },
2722
+ drop: function drop(_ref5) {
2723
+ var current = _ref5.current, updatedSourcePayload = _ref5.updatedSourcePayload;
2724
+ dragStart.flush();
2725
+ scheduleOnDrag.cancel();
2726
+ safeDispatch({
2727
+ eventName: "onDrop",
2728
+ payload: {
2729
+ source: updatedSourcePayload !== null && updatedSourcePayload !== void 0 ? updatedSourcePayload : source,
2730
+ location: {
2731
+ current,
2732
+ previous,
2733
+ initial
2734
+ }
2735
+ }
2736
+ });
2737
+ }
2738
+ };
2739
+ return dispatch;
2740
+ }
2741
+
2742
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/lifecycle-manager.js
2743
+ var globalState = {
2744
+ isActive: false
2745
+ };
2746
+ function canStart() {
2747
+ return !globalState.isActive;
2748
+ }
2749
+ function getNativeSetDragImage(event) {
2750
+ if (event.dataTransfer) {
2751
+ return event.dataTransfer.setDragImage.bind(event.dataTransfer);
2752
+ }
2753
+ return null;
2754
+ }
2755
+ function hasHierarchyChanged(_ref) {
2756
+ var current = _ref.current, next = _ref.next;
2757
+ if (current.length !== next.length) {
2758
+ return true;
2759
+ }
2760
+ for (var i = 0; i < current.length; i++) {
2761
+ if (current[i].element !== next[i].element) {
2762
+ return true;
2763
+ }
2764
+ }
2765
+ return false;
2766
+ }
2767
+ function start(_ref2) {
2768
+ var event = _ref2.event, dragType = _ref2.dragType, getDropTargetsOver = _ref2.getDropTargetsOver, dispatchEvent = _ref2.dispatchEvent;
2769
+ if (!canStart()) {
2770
+ return;
2771
+ }
2772
+ var initial = getStartLocation({
2773
+ event,
2774
+ dragType,
2775
+ getDropTargetsOver
2776
+ });
2777
+ globalState.isActive = true;
2778
+ var state = {
2779
+ current: initial
2780
+ };
2781
+ setDropEffectOnEvent({
2782
+ event,
2783
+ current: initial.dropTargets
2784
+ });
2785
+ var dispatch = makeDispatch({
2786
+ source: dragType.payload,
2787
+ dispatchEvent,
2788
+ initial
2789
+ });
2790
+ function updateState(next) {
2791
+ var hasChanged = hasHierarchyChanged({
2792
+ current: state.current.dropTargets,
2793
+ next: next.dropTargets
2794
+ });
2795
+ state.current = next;
2796
+ if (hasChanged) {
2797
+ dispatch.dragUpdate({
2798
+ current: state.current
2799
+ });
2800
+ }
2801
+ }
2802
+ function onUpdateEvent(event2) {
2803
+ var input = getInput(event2);
2804
+ var target = isHoneyPotElement(event2.target) ? getElementFromPointWithoutHoneypot({
2805
+ x: input.clientX,
2806
+ y: input.clientY
2807
+ }) : event2.target;
2808
+ var nextDropTargets = getDropTargetsOver({
2809
+ target,
2810
+ input,
2811
+ source: dragType.payload,
2812
+ current: state.current.dropTargets
2813
+ });
2814
+ if (nextDropTargets.length) {
2815
+ event2.preventDefault();
2816
+ setDropEffectOnEvent({
2817
+ event: event2,
2818
+ current: nextDropTargets
2819
+ });
2820
+ }
2821
+ updateState({
2822
+ dropTargets: nextDropTargets,
2823
+ input
2824
+ });
2825
+ }
2826
+ function cancel() {
2827
+ if (state.current.dropTargets.length) {
2828
+ updateState({
2829
+ dropTargets: [],
2830
+ input: state.current.input
2831
+ });
2832
+ }
2833
+ dispatch.drop({
2834
+ current: state.current,
2835
+ updatedSourcePayload: null
2836
+ });
2837
+ finish();
2838
+ }
2839
+ function finish() {
2840
+ globalState.isActive = false;
2841
+ unbindEvents();
2842
+ }
2843
+ var unbindEvents = (0, import_bind_event_listener3.bindAll)(
2844
+ window,
2845
+ [{
2846
+ // 👋 Note: we are repurposing the `dragover` event as our `drag` event
2847
+ // this is because firefox does not publish pointer coordinates during
2848
+ // a `drag` event, but does for every other type of drag event
2849
+ // `dragover` fires on all elements that are being dragged over
2850
+ // Because we are binding to `window` - our `dragover` is effectively the same as a `drag`
2851
+ // 🦊😤
2852
+ type: "dragover",
2853
+ listener: function listener(event2) {
2854
+ onUpdateEvent(event2);
2855
+ dispatch.drag({
2856
+ current: state.current
2857
+ });
2858
+ }
2859
+ }, {
2860
+ type: "dragenter",
2861
+ listener: onUpdateEvent
2862
+ }, {
2863
+ type: "dragleave",
2864
+ listener: function listener(event2) {
2865
+ if (!isLeavingWindow({
2866
+ dragLeave: event2
2867
+ })) {
2868
+ return;
2869
+ }
2870
+ updateState({
2871
+ input: state.current.input,
2872
+ dropTargets: []
2873
+ });
2874
+ if (dragType.startedFrom === "external") {
2875
+ cancel();
2876
+ }
2877
+ }
2878
+ }, {
2879
+ // A "drop" can only happen if the browser allowed the drop
2880
+ type: "drop",
2881
+ listener: function listener(event2) {
2882
+ state.current = {
2883
+ dropTargets: state.current.dropTargets,
2884
+ input: getInput(event2)
2885
+ };
2886
+ if (!state.current.dropTargets.length) {
2887
+ cancel();
2888
+ return;
2889
+ }
2890
+ event2.preventDefault();
2891
+ setDropEffectOnEvent({
2892
+ event: event2,
2893
+ current: state.current.dropTargets
2894
+ });
2895
+ dispatch.drop({
2896
+ current: state.current,
2897
+ // When dropping something native, we need to extract the latest
2898
+ // `.items` from the "drop" event as it is now accessible
2899
+ updatedSourcePayload: dragType.type === "external" ? dragType.getDropPayload(event2) : null
2900
+ });
2901
+ finish();
2902
+ }
2903
+ }, {
2904
+ // "dragend" fires when on the drag source (eg a draggable element)
2905
+ // when the drag is finished.
2906
+ // "dragend" will fire after "drop" (if there was a successful drop)
2907
+ // "dragend" does not fire if the draggable source has been removed during the drag
2908
+ // or for external drag sources (eg files)
2909
+ // This "dragend" listener will not fire if there was a successful drop
2910
+ // as we will have already removed the event listener
2911
+ type: "dragend",
2912
+ listener: function listener(event2) {
2913
+ state.current = {
2914
+ dropTargets: state.current.dropTargets,
2915
+ input: getInput(event2)
2916
+ };
2917
+ cancel();
2918
+ }
2919
+ }].concat(_toConsumableArray(getBindingsForBrokenDrags({
2920
+ onDragEnd: cancel
2921
+ }))),
2922
+ // Once we have started a managed drag operation it is important that we see / own all drag events
2923
+ // We got one adoption bug pop up where some code was stopping (`event.stopPropagation()`)
2924
+ // all "drop" events in the bubble phase on the `document.body`.
2925
+ // This meant that we never saw the "drop" event.
2926
+ {
2927
+ capture: true
2928
+ }
2929
+ );
2930
+ dispatch.start({
2931
+ nativeSetDragImage: getNativeSetDragImage(event)
2932
+ });
2933
+ }
2934
+ function setDropEffectOnEvent(_ref3) {
2935
+ var _current$;
2936
+ var event = _ref3.event, current = _ref3.current;
2937
+ var innerMost = (_current$ = current[0]) === null || _current$ === void 0 ? void 0 : _current$.dropEffect;
2938
+ if (innerMost != null && event.dataTransfer) {
2939
+ event.dataTransfer.dropEffect = innerMost;
2940
+ }
2941
+ }
2942
+ function getStartLocation(_ref4) {
2943
+ var event = _ref4.event, dragType = _ref4.dragType, getDropTargetsOver = _ref4.getDropTargetsOver;
2944
+ var input = getInput(event);
2945
+ if (dragType.startedFrom === "external") {
2946
+ return {
2947
+ input,
2948
+ dropTargets: []
2949
+ };
2950
+ }
2951
+ var dropTargets = getDropTargetsOver({
2952
+ input,
2953
+ source: dragType.payload,
2954
+ target: event.target,
2955
+ current: []
2956
+ });
2957
+ return {
2958
+ input,
2959
+ dropTargets
2960
+ };
2961
+ }
2962
+ var lifecycle = {
2963
+ canStart,
2964
+ start
2965
+ };
2966
+
2967
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/usage-ledger.js
2968
+ var ledger = /* @__PURE__ */ new Map();
2969
+ function registerUsage(_ref) {
2970
+ var typeKey = _ref.typeKey, mount2 = _ref.mount;
2971
+ var entry = ledger.get(typeKey);
2972
+ if (entry) {
2973
+ entry.usageCount++;
2974
+ return entry;
2975
+ }
2976
+ var initial = {
2977
+ typeKey,
2978
+ unmount: mount2(),
2979
+ usageCount: 1
2980
+ };
2981
+ ledger.set(typeKey, initial);
2982
+ return initial;
2983
+ }
2984
+ function register(args) {
2985
+ var entry = registerUsage(args);
2986
+ return function unregister() {
2987
+ entry.usageCount--;
2988
+ if (entry.usageCount > 0) {
2989
+ return;
2990
+ }
2991
+ entry.unmount();
2992
+ ledger.delete(args.typeKey);
2993
+ };
2994
+ }
2995
+
2996
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/public-utils/combine.js
2997
+ function combine() {
2998
+ for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
2999
+ fns[_key] = arguments[_key];
3000
+ }
3001
+ return function cleanup() {
3002
+ fns.forEach(function(fn) {
3003
+ return fn();
3004
+ });
3005
+ };
3006
+ }
3007
+
3008
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/add-attribute.js
3009
+ function addAttribute(element, _ref) {
3010
+ var attribute = _ref.attribute, value = _ref.value;
3011
+ element.setAttribute(attribute, value);
3012
+ return function() {
3013
+ return element.removeAttribute(attribute);
3014
+ };
3015
+ }
3016
+
3017
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/make-adapter/make-drop-target.js
3018
+ function ownKeys2(e, r) {
3019
+ var t = Object.keys(e);
3020
+ if (Object.getOwnPropertySymbols) {
3021
+ var o = Object.getOwnPropertySymbols(e);
3022
+ r && (o = o.filter(function(r2) {
3023
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
3024
+ })), t.push.apply(t, o);
3025
+ }
3026
+ return t;
3027
+ }
3028
+ function _objectSpread2(e) {
3029
+ for (var r = 1; r < arguments.length; r++) {
3030
+ var t = null != arguments[r] ? arguments[r] : {};
3031
+ r % 2 ? ownKeys2(Object(t), true).forEach(function(r2) {
3032
+ _defineProperty(e, r2, t[r2]);
3033
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r2) {
3034
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
3035
+ });
3036
+ }
3037
+ return e;
3038
+ }
3039
+ function _createForOfIteratorHelper(r, e) {
3040
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
3041
+ if (!t) {
3042
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray2(r)) || e && r && "number" == typeof r.length) {
3043
+ t && (r = t);
3044
+ var _n = 0, F = function F2() {
3045
+ };
3046
+ return { s: F, n: function n() {
3047
+ return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
3048
+ }, e: function e2(r2) {
3049
+ throw r2;
3050
+ }, f: F };
3051
+ }
3052
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3053
+ }
3054
+ var o, a = true, u = false;
3055
+ return { s: function s() {
3056
+ t = t.call(r);
3057
+ }, n: function n() {
3058
+ var r2 = t.next();
3059
+ return a = r2.done, r2;
3060
+ }, e: function e2(r2) {
3061
+ u = true, o = r2;
3062
+ }, f: function f() {
3063
+ try {
3064
+ a || null == t.return || t.return();
3065
+ } finally {
3066
+ if (u) throw o;
3067
+ }
3068
+ } };
3069
+ }
3070
+ function _unsupportedIterableToArray2(r, a) {
3071
+ if (r) {
3072
+ if ("string" == typeof r) return _arrayLikeToArray2(r, a);
3073
+ var t = {}.toString.call(r).slice(8, -1);
3074
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0;
3075
+ }
3076
+ }
3077
+ function _arrayLikeToArray2(r, a) {
3078
+ (null == a || a > r.length) && (a = r.length);
3079
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
3080
+ return n;
3081
+ }
3082
+ function copyReverse(array) {
3083
+ return array.slice(0).reverse();
3084
+ }
3085
+ function makeDropTarget(_ref) {
3086
+ var typeKey = _ref.typeKey, defaultDropEffect = _ref.defaultDropEffect;
3087
+ var registry = /* @__PURE__ */ new WeakMap();
3088
+ var dropTargetDataAtt = "data-drop-target-for-".concat(typeKey);
3089
+ var dropTargetSelector = "[".concat(dropTargetDataAtt, "]");
3090
+ function addToRegistry2(args) {
3091
+ registry.set(args.element, args);
3092
+ return function() {
3093
+ return registry.delete(args.element);
3094
+ };
3095
+ }
3096
+ function dropTargetForConsumers(args) {
3097
+ if (true) {
3098
+ var existing = registry.get(args.element);
3099
+ if (existing) {
3100
+ console.warn("You have already registered a [".concat(typeKey, "] dropTarget on the same element"), {
3101
+ existing,
3102
+ proposed: args
3103
+ });
3104
+ }
3105
+ if (args.element instanceof HTMLIFrameElement) {
3106
+ console.warn("\n We recommend not registering <iframe> elements as drop targets\n as it can result in some strange browser event ordering.\n ".replace(/\s{2,}/g, " ").trim());
3107
+ }
3108
+ }
3109
+ var cleanup = combine(addAttribute(args.element, {
3110
+ attribute: dropTargetDataAtt,
3111
+ value: "true"
3112
+ }), addToRegistry2(args));
3113
+ return once(cleanup);
3114
+ }
3115
+ function getActualDropTargets(_ref2) {
3116
+ var _args$getData, _args$getData2, _args$getDropEffect, _args$getDropEffect2;
3117
+ var source = _ref2.source, target = _ref2.target, input = _ref2.input, _ref2$result = _ref2.result, result = _ref2$result === void 0 ? [] : _ref2$result;
3118
+ if (target == null) {
3119
+ return result;
3120
+ }
3121
+ if (!(target instanceof Element)) {
3122
+ if (target instanceof Node) {
3123
+ return getActualDropTargets({
3124
+ source,
3125
+ target: target.parentElement,
3126
+ input,
3127
+ result
3128
+ });
3129
+ }
3130
+ return result;
3131
+ }
3132
+ var closest = target.closest(dropTargetSelector);
3133
+ if (closest == null) {
3134
+ return result;
3135
+ }
3136
+ var args = registry.get(closest);
3137
+ if (args == null) {
3138
+ return result;
3139
+ }
3140
+ var feedback = {
3141
+ input,
3142
+ source,
3143
+ element: args.element
3144
+ };
3145
+ if (args.canDrop && !args.canDrop(feedback)) {
3146
+ return getActualDropTargets({
3147
+ source,
3148
+ target: args.element.parentElement,
3149
+ input,
3150
+ result
3151
+ });
3152
+ }
3153
+ var data = (_args$getData = (_args$getData2 = args.getData) === null || _args$getData2 === void 0 ? void 0 : _args$getData2.call(args, feedback)) !== null && _args$getData !== void 0 ? _args$getData : {};
3154
+ var dropEffect = (_args$getDropEffect = (_args$getDropEffect2 = args.getDropEffect) === null || _args$getDropEffect2 === void 0 ? void 0 : _args$getDropEffect2.call(args, feedback)) !== null && _args$getDropEffect !== void 0 ? _args$getDropEffect : defaultDropEffect;
3155
+ var record = {
3156
+ data,
3157
+ element: args.element,
3158
+ dropEffect,
3159
+ // we are collecting _actual_ drop targets, so these are
3160
+ // being applied _not_ due to stickiness
3161
+ isActiveDueToStickiness: false
3162
+ };
3163
+ return getActualDropTargets({
3164
+ source,
3165
+ target: args.element.parentElement,
3166
+ input,
3167
+ // Using bubble ordering. Same ordering as `event.getPath()`
3168
+ result: [].concat(_toConsumableArray(result), [record])
3169
+ });
3170
+ }
3171
+ function notifyCurrent(_ref3) {
3172
+ var eventName = _ref3.eventName, payload = _ref3.payload;
3173
+ var _iterator = _createForOfIteratorHelper(payload.location.current.dropTargets), _step;
3174
+ try {
3175
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
3176
+ var _entry$eventName;
3177
+ var record = _step.value;
3178
+ var entry = registry.get(record.element);
3179
+ var args = _objectSpread2(_objectSpread2({}, payload), {}, {
3180
+ self: record
3181
+ });
3182
+ entry === null || entry === void 0 || (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 || _entry$eventName.call(
3183
+ entry,
3184
+ // I cannot seem to get the types right here.
3185
+ // TS doesn't seem to like that one event can need `nativeSetDragImage`
3186
+ // @ts-expect-error
3187
+ args
3188
+ );
3189
+ }
3190
+ } catch (err) {
3191
+ _iterator.e(err);
3192
+ } finally {
3193
+ _iterator.f();
3194
+ }
3195
+ }
3196
+ var actions = {
3197
+ onGenerateDragPreview: notifyCurrent,
3198
+ onDrag: notifyCurrent,
3199
+ onDragStart: notifyCurrent,
3200
+ onDrop: notifyCurrent,
3201
+ onDropTargetChange: function onDropTargetChange(_ref4) {
3202
+ var payload = _ref4.payload;
3203
+ var isCurrent = new Set(payload.location.current.dropTargets.map(function(record2) {
3204
+ return record2.element;
3205
+ }));
3206
+ var visited = /* @__PURE__ */ new Set();
3207
+ var _iterator2 = _createForOfIteratorHelper(payload.location.previous.dropTargets), _step2;
3208
+ try {
3209
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
3210
+ var _entry$onDropTargetCh;
3211
+ var record = _step2.value;
3212
+ visited.add(record.element);
3213
+ var entry = registry.get(record.element);
3214
+ var isOver = isCurrent.has(record.element);
3215
+ var args = _objectSpread2(_objectSpread2({}, payload), {}, {
3216
+ self: record
3217
+ });
3218
+ entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry, args);
3219
+ if (!isOver) {
3220
+ var _entry$onDragLeave;
3221
+ entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry, args);
3222
+ }
3223
+ }
3224
+ } catch (err) {
3225
+ _iterator2.e(err);
3226
+ } finally {
3227
+ _iterator2.f();
3228
+ }
3229
+ var _iterator3 = _createForOfIteratorHelper(payload.location.current.dropTargets), _step3;
3230
+ try {
3231
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
3232
+ var _entry$onDropTargetCh2, _entry$onDragEnter;
3233
+ var _record = _step3.value;
3234
+ if (visited.has(_record.element)) {
3235
+ continue;
3236
+ }
3237
+ var _args = _objectSpread2(_objectSpread2({}, payload), {}, {
3238
+ self: _record
3239
+ });
3240
+ var _entry = registry.get(_record.element);
3241
+ _entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry, _args);
3242
+ _entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args);
3243
+ }
3244
+ } catch (err) {
3245
+ _iterator3.e(err);
3246
+ } finally {
3247
+ _iterator3.f();
3248
+ }
3249
+ }
3250
+ };
3251
+ function dispatchEvent(args) {
3252
+ actions[args.eventName](args);
3253
+ }
3254
+ function getIsOver(_ref5) {
3255
+ var source = _ref5.source, target = _ref5.target, input = _ref5.input, current = _ref5.current;
3256
+ var actual = getActualDropTargets({
3257
+ source,
3258
+ target,
3259
+ input
3260
+ });
3261
+ if (actual.length >= current.length) {
3262
+ return actual;
3263
+ }
3264
+ var lastCaptureOrdered = copyReverse(current);
3265
+ var actualCaptureOrdered = copyReverse(actual);
3266
+ var resultCaptureOrdered = [];
3267
+ for (var index = 0; index < lastCaptureOrdered.length; index++) {
3268
+ var _argsForLast$getIsSti;
3269
+ var last = lastCaptureOrdered[index];
3270
+ var fresh = actualCaptureOrdered[index];
3271
+ if (fresh != null) {
3272
+ resultCaptureOrdered.push(fresh);
3273
+ continue;
3274
+ }
3275
+ var parent = resultCaptureOrdered[index - 1];
3276
+ var lastParent = lastCaptureOrdered[index - 1];
3277
+ if ((parent === null || parent === void 0 ? void 0 : parent.element) !== (lastParent === null || lastParent === void 0 ? void 0 : lastParent.element)) {
3278
+ break;
3279
+ }
3280
+ var argsForLast = registry.get(last.element);
3281
+ if (!argsForLast) {
3282
+ break;
3283
+ }
3284
+ var feedback = {
3285
+ input,
3286
+ source,
3287
+ element: argsForLast.element
3288
+ };
3289
+ if (argsForLast.canDrop && !argsForLast.canDrop(feedback)) {
3290
+ break;
3291
+ }
3292
+ if (!((_argsForLast$getIsSti = argsForLast.getIsSticky) !== null && _argsForLast$getIsSti !== void 0 && _argsForLast$getIsSti.call(argsForLast, feedback))) {
3293
+ break;
3294
+ }
3295
+ resultCaptureOrdered.push(_objectSpread2(_objectSpread2({}, last), {}, {
3296
+ // making it clear to consumers this drop target is active due to stickiness
3297
+ isActiveDueToStickiness: true
3298
+ }));
3299
+ }
3300
+ return copyReverse(resultCaptureOrdered);
3301
+ }
3302
+ return {
3303
+ dropTargetForConsumers,
3304
+ getIsOver,
3305
+ dispatchEvent
3306
+ };
3307
+ }
3308
+
3309
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/make-adapter/make-monitor.js
3310
+ function _createForOfIteratorHelper2(r, e) {
3311
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
3312
+ if (!t) {
3313
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray3(r)) || e && r && "number" == typeof r.length) {
3314
+ t && (r = t);
3315
+ var _n = 0, F = function F2() {
3316
+ };
3317
+ return { s: F, n: function n() {
3318
+ return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
3319
+ }, e: function e2(r2) {
3320
+ throw r2;
3321
+ }, f: F };
3322
+ }
3323
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3324
+ }
3325
+ var o, a = true, u = false;
3326
+ return { s: function s() {
3327
+ t = t.call(r);
3328
+ }, n: function n() {
3329
+ var r2 = t.next();
3330
+ return a = r2.done, r2;
3331
+ }, e: function e2(r2) {
3332
+ u = true, o = r2;
3333
+ }, f: function f() {
3334
+ try {
3335
+ a || null == t.return || t.return();
3336
+ } finally {
3337
+ if (u) throw o;
3338
+ }
3339
+ } };
3340
+ }
3341
+ function _unsupportedIterableToArray3(r, a) {
3342
+ if (r) {
3343
+ if ("string" == typeof r) return _arrayLikeToArray3(r, a);
3344
+ var t = {}.toString.call(r).slice(8, -1);
3345
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray3(r, a) : void 0;
3346
+ }
3347
+ }
3348
+ function _arrayLikeToArray3(r, a) {
3349
+ (null == a || a > r.length) && (a = r.length);
3350
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
3351
+ return n;
3352
+ }
3353
+ function ownKeys3(e, r) {
3354
+ var t = Object.keys(e);
3355
+ if (Object.getOwnPropertySymbols) {
3356
+ var o = Object.getOwnPropertySymbols(e);
3357
+ r && (o = o.filter(function(r2) {
3358
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
3359
+ })), t.push.apply(t, o);
3360
+ }
3361
+ return t;
3362
+ }
3363
+ function _objectSpread3(e) {
3364
+ for (var r = 1; r < arguments.length; r++) {
3365
+ var t = null != arguments[r] ? arguments[r] : {};
3366
+ r % 2 ? ownKeys3(Object(t), true).forEach(function(r2) {
3367
+ _defineProperty(e, r2, t[r2]);
3368
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys3(Object(t)).forEach(function(r2) {
3369
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
3370
+ });
3371
+ }
3372
+ return e;
3373
+ }
3374
+ function makeMonitor() {
3375
+ var registry = /* @__PURE__ */ new Set();
3376
+ var dragging = null;
3377
+ function tryAddToActive(monitor) {
3378
+ if (!dragging) {
3379
+ return;
3380
+ }
3381
+ if (!monitor.canMonitor || monitor.canMonitor(dragging.canMonitorArgs)) {
3382
+ dragging.active.add(monitor);
3383
+ }
3384
+ }
3385
+ function monitorForConsumers(args) {
3386
+ var entry = _objectSpread3({}, args);
3387
+ registry.add(entry);
3388
+ tryAddToActive(entry);
3389
+ function cleanup() {
3390
+ registry.delete(entry);
3391
+ if (dragging) {
3392
+ dragging.active.delete(entry);
3393
+ }
3394
+ }
3395
+ return once(cleanup);
3396
+ }
3397
+ function dispatchEvent(_ref) {
3398
+ var eventName = _ref.eventName, payload = _ref.payload;
3399
+ if (eventName === "onGenerateDragPreview") {
3400
+ dragging = {
3401
+ canMonitorArgs: {
3402
+ initial: payload.location.initial,
3403
+ source: payload.source
3404
+ },
3405
+ active: /* @__PURE__ */ new Set()
3406
+ };
3407
+ var _iterator = _createForOfIteratorHelper2(registry), _step;
3408
+ try {
3409
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
3410
+ var monitor = _step.value;
3411
+ tryAddToActive(monitor);
3412
+ }
3413
+ } catch (err) {
3414
+ _iterator.e(err);
3415
+ } finally {
3416
+ _iterator.f();
3417
+ }
3418
+ }
3419
+ if (!dragging) {
3420
+ return;
3421
+ }
3422
+ var active = Array.from(dragging.active);
3423
+ for (var _i = 0, _active = active; _i < _active.length; _i++) {
3424
+ var _monitor = _active[_i];
3425
+ if (dragging.active.has(_monitor)) {
3426
+ var _monitor$eventName;
3427
+ (_monitor$eventName = _monitor[eventName]) === null || _monitor$eventName === void 0 || _monitor$eventName.call(_monitor, payload);
3428
+ }
3429
+ }
3430
+ if (eventName === "onDrop") {
3431
+ dragging.active.clear();
3432
+ dragging = null;
3433
+ }
3434
+ }
3435
+ return {
3436
+ dispatchEvent,
3437
+ monitorForConsumers
3438
+ };
3439
+ }
3440
+
3441
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/make-adapter/make-adapter.js
3442
+ function makeAdapter(_ref) {
3443
+ var typeKey = _ref.typeKey, mount2 = _ref.mount, dispatchEventToSource2 = _ref.dispatchEventToSource, onPostDispatch = _ref.onPostDispatch, defaultDropEffect = _ref.defaultDropEffect;
3444
+ var monitorAPI = makeMonitor();
3445
+ var dropTargetAPI = makeDropTarget({
3446
+ typeKey,
3447
+ defaultDropEffect
3448
+ });
3449
+ function dispatchEvent(args) {
3450
+ dispatchEventToSource2 === null || dispatchEventToSource2 === void 0 || dispatchEventToSource2(args);
3451
+ dropTargetAPI.dispatchEvent(args);
3452
+ monitorAPI.dispatchEvent(args);
3453
+ onPostDispatch === null || onPostDispatch === void 0 || onPostDispatch(args);
3454
+ }
3455
+ function start2(_ref2) {
3456
+ var event = _ref2.event, dragType = _ref2.dragType;
3457
+ lifecycle.start({
3458
+ event,
3459
+ dragType,
3460
+ getDropTargetsOver: dropTargetAPI.getIsOver,
3461
+ dispatchEvent
3462
+ });
3463
+ }
3464
+ function registerUsage2() {
3465
+ function mountAdapter() {
3466
+ var api2 = {
3467
+ canStart: lifecycle.canStart,
3468
+ start: start2
3469
+ };
3470
+ return mount2(api2);
3471
+ }
3472
+ return register({
3473
+ typeKey,
3474
+ mount: mountAdapter
3475
+ });
3476
+ }
3477
+ return {
3478
+ registerUsage: registerUsage2,
3479
+ dropTarget: dropTargetAPI.dropTargetForConsumers,
3480
+ monitor: monitorAPI.monitorForConsumers
3481
+ };
3482
+ }
3483
+
3484
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/android.js
3485
+ var isAndroid = once(function isAndroid2() {
3486
+ return navigator.userAgent.toLocaleLowerCase().includes("android");
3487
+ });
3488
+ var androidFallbackText = "pdnd:android-fallback";
3489
+
3490
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/media-types/text-media-type.js
3491
+ var textMediaType = "text/plain";
3492
+
3493
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/media-types/url-media-type.js
3494
+ var URLMediaType = "text/uri-list";
3495
+
3496
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter-native-data-key.js
3497
+ var elementAdapterNativeDataKey = "application/vnd.pdnd";
3498
+
3499
+ // node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter.js
3500
+ var draggableRegistry = /* @__PURE__ */ new WeakMap();
3501
+ function addToRegistry(args) {
3502
+ draggableRegistry.set(args.element, args);
3503
+ return function cleanup() {
3504
+ draggableRegistry.delete(args.element);
3505
+ };
3506
+ }
3507
+ var honeyPotFix = makeHoneyPotFix();
3508
+ var adapter = makeAdapter({
3509
+ typeKey: "element",
3510
+ defaultDropEffect: "move",
3511
+ mount: function mount(api2) {
3512
+ return combine(honeyPotFix.bindEvents(), (0, import_bind_event_listener4.bind)(document, {
3513
+ type: "dragstart",
3514
+ listener: function listener(event) {
3515
+ var _entry$dragHandle, _entry$getInitialData, _entry$getInitialData2, _entry$dragHandle2, _entry$getInitialData3, _entry$getInitialData4;
3516
+ if (!api2.canStart(event)) {
3517
+ return;
3518
+ }
3519
+ if (event.defaultPrevented) {
3520
+ return;
3521
+ }
3522
+ if (!event.dataTransfer) {
3523
+ if (true) {
3524
+ console.warn("\n It appears as though you have are not testing DragEvents correctly.\n\n - If you are unit testing, ensure you have polyfilled DragEvent.\n - If you are browser testing, ensure you are dispatching drag events correctly.\n\n Please see our testing guides for more information:\n https://atlassian.design/components/pragmatic-drag-and-drop/core-package/testing\n ".replace(/ {2}/g, ""));
3525
+ }
3526
+ return;
3527
+ }
3528
+ var target = event.target;
3529
+ if (!(target instanceof HTMLElement)) {
3530
+ return;
3531
+ }
3532
+ var entry = draggableRegistry.get(target);
3533
+ if (!entry) {
3534
+ return;
3535
+ }
3536
+ var input = getInput(event);
3537
+ var feedback = {
3538
+ element: entry.element,
3539
+ dragHandle: (_entry$dragHandle = entry.dragHandle) !== null && _entry$dragHandle !== void 0 ? _entry$dragHandle : null,
3540
+ input
3541
+ };
3542
+ if (entry.canDrag && !entry.canDrag(feedback)) {
3543
+ event.preventDefault();
3544
+ return;
3545
+ }
3546
+ if (entry.dragHandle) {
3547
+ var over = getElementFromPointWithoutHoneypot({
3548
+ x: input.clientX,
3549
+ y: input.clientY
3550
+ });
3551
+ if (!entry.dragHandle.contains(over)) {
3552
+ event.preventDefault();
3553
+ return;
3554
+ }
3555
+ }
3556
+ var nativeData = (_entry$getInitialData = (_entry$getInitialData2 = entry.getInitialDataForExternal) === null || _entry$getInitialData2 === void 0 ? void 0 : _entry$getInitialData2.call(entry, feedback)) !== null && _entry$getInitialData !== void 0 ? _entry$getInitialData : null;
3557
+ if (nativeData) {
3558
+ for (var _i = 0, _Object$entries = Object.entries(nativeData); _i < _Object$entries.length; _i++) {
3559
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], data = _Object$entries$_i[1];
3560
+ event.dataTransfer.setData(key, data !== null && data !== void 0 ? data : "");
3561
+ }
3562
+ }
3563
+ if (isAndroid() && !event.dataTransfer.types.includes(textMediaType) && !event.dataTransfer.types.includes(URLMediaType)) {
3564
+ event.dataTransfer.setData(textMediaType, androidFallbackText);
3565
+ }
3566
+ event.dataTransfer.setData(elementAdapterNativeDataKey, "");
3567
+ var payload = {
3568
+ element: entry.element,
3569
+ dragHandle: (_entry$dragHandle2 = entry.dragHandle) !== null && _entry$dragHandle2 !== void 0 ? _entry$dragHandle2 : null,
3570
+ data: (_entry$getInitialData3 = (_entry$getInitialData4 = entry.getInitialData) === null || _entry$getInitialData4 === void 0 ? void 0 : _entry$getInitialData4.call(entry, feedback)) !== null && _entry$getInitialData3 !== void 0 ? _entry$getInitialData3 : {}
3571
+ };
3572
+ var dragType = {
3573
+ type: "element",
3574
+ payload,
3575
+ startedFrom: "internal"
3576
+ };
3577
+ api2.start({
3578
+ event,
3579
+ dragType
3580
+ });
3581
+ }
3582
+ }));
3583
+ },
3584
+ dispatchEventToSource: function dispatchEventToSource(_ref) {
3585
+ var _draggableRegistry$ge, _draggableRegistry$ge2;
3586
+ var eventName = _ref.eventName, payload = _ref.payload;
3587
+ (_draggableRegistry$ge = draggableRegistry.get(payload.source.element)) === null || _draggableRegistry$ge === void 0 || (_draggableRegistry$ge2 = _draggableRegistry$ge[eventName]) === null || _draggableRegistry$ge2 === void 0 || _draggableRegistry$ge2.call(
3588
+ _draggableRegistry$ge,
3589
+ // I cannot seem to get the types right here.
3590
+ // TS doesn't seem to like that one event can need `nativeSetDragImage`
3591
+ // @ts-expect-error
3592
+ payload
3593
+ );
3594
+ },
3595
+ onPostDispatch: honeyPotFix.getOnPostDispatch()
3596
+ });
3597
+ var dropTargetForElements = adapter.dropTarget;
3598
+ var monitorForElements = adapter.monitor;
3599
+ function draggable(args) {
3600
+ if (true) {
3601
+ if (args.dragHandle && !args.element.contains(args.dragHandle)) {
3602
+ console.warn("Drag handle element must be contained in draggable element", {
3603
+ element: args.element,
3604
+ dragHandle: args.dragHandle
3605
+ });
3606
+ }
3607
+ }
3608
+ if (true) {
3609
+ var existing = draggableRegistry.get(args.element);
3610
+ if (existing) {
3611
+ console.warn("You have already registered a `draggable` on the same element", {
3612
+ existing,
3613
+ proposed: args
3614
+ });
3615
+ }
3616
+ }
3617
+ var cleanup = combine(
3618
+ // making the draggable register the adapter rather than drop targets
3619
+ // this is because you *must* have a draggable element to start a drag
3620
+ // but you _might_ not have any drop targets immediately
3621
+ // (You might create drop targets async)
3622
+ adapter.registerUsage(),
3623
+ addToRegistry(args),
3624
+ addAttribute(args.element, {
3625
+ attribute: "draggable",
3626
+ value: "true"
3627
+ })
3628
+ );
3629
+ return once(cleanup);
3630
+ }
3631
+
3632
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/engagement-history.js
3633
+ var ledger2 = /* @__PURE__ */ new Map();
3634
+ var requested = /* @__PURE__ */ new Set();
3635
+ function markAndGetEngagement(element) {
3636
+ markEngagement(element);
3637
+ var entry = ledger2.get(element);
3638
+ if (entry) {
3639
+ return entry;
3640
+ }
3641
+ var fresh = {
3642
+ timeOfEngagementStart: Date.now()
3643
+ };
3644
+ ledger2.set(element, fresh);
3645
+ return fresh;
3646
+ }
3647
+ function markEngagement(element) {
3648
+ requested.add(element);
3649
+ }
3650
+ function clearUnusedEngagements(fn) {
3651
+ requested.clear();
3652
+ fn();
3653
+ ledger2.forEach(function(_, element) {
3654
+ if (!requested.has(element)) {
3655
+ ledger2.delete(element);
3656
+ }
3657
+ });
3658
+ requested.clear();
3659
+ }
3660
+ function clearEngagementHistory() {
3661
+ ledger2.clear();
3662
+ }
3663
+
3664
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/scheduler.js
3665
+ var schedulers = /* @__PURE__ */ new Map();
3666
+ function getScheduler(monitor) {
3667
+ var scheduler = schedulers.get(monitor);
3668
+ if (scheduler) {
3669
+ return scheduler;
3670
+ }
3671
+ var created = makeScheduler(monitor);
3672
+ schedulers.set(monitor, created);
3673
+ return created;
3674
+ }
3675
+ function makeScheduler(monitor) {
3676
+ var state = {
3677
+ type: "idle"
3678
+ };
3679
+ var callbacks = [];
3680
+ function loop(timeLastFrameFinished) {
3681
+ if (state.type !== "running") {
3682
+ return;
3683
+ }
3684
+ var timeSinceLastFrame = timeLastFrameFinished - state.timeLastFrameFinished;
3685
+ var _state = state, latestArgs = _state.latestArgs;
3686
+ var underUsersPointer = getElementFromPointWithoutHoneypot({
3687
+ x: latestArgs.location.current.input.clientX,
3688
+ y: latestArgs.location.current.input.clientY
3689
+ });
3690
+ clearUnusedEngagements(function() {
3691
+ callbacks.forEach(function(onFrame) {
3692
+ return onFrame({
3693
+ underUsersPointer,
3694
+ latestArgs,
3695
+ timeSinceLastFrame
3696
+ });
3697
+ });
3698
+ });
3699
+ state.timeLastFrameFinished = timeLastFrameFinished;
3700
+ state.frameId = requestAnimationFrame(loop);
3701
+ }
3702
+ function reset() {
3703
+ if (state.type === "idle") {
3704
+ return;
3705
+ }
3706
+ cancelAnimationFrame(state.frameId);
3707
+ clearEngagementHistory();
3708
+ state = {
3709
+ type: "idle"
3710
+ };
3711
+ }
3712
+ function start2(args) {
3713
+ if (state.type !== "idle") {
3714
+ return;
3715
+ }
3716
+ state = {
3717
+ // Waiting a frame so we can accurately determine `timeSinceLastFrame`.
3718
+ type: "initializing",
3719
+ latestArgs: args,
3720
+ frameId: requestAnimationFrame(function(timeLastFrameFinished) {
3721
+ if (state.type !== "initializing") {
3722
+ return;
3723
+ }
3724
+ state = {
3725
+ type: "running",
3726
+ timeLastFrameFinished,
3727
+ latestArgs: state.latestArgs,
3728
+ frameId: requestAnimationFrame(loop)
3729
+ };
3730
+ })
3731
+ };
3732
+ }
3733
+ function update(args) {
3734
+ if (state.type === "idle") {
3735
+ start2(args);
3736
+ return;
3737
+ }
3738
+ state.latestArgs = args;
3739
+ }
3740
+ monitor({
3741
+ onDragStart: start2,
3742
+ onDropTargetChange: update,
3743
+ onDrag: update,
3744
+ onDrop: reset
3745
+ });
3746
+ var api2 = {
3747
+ onFrame: function onFrame(fn) {
3748
+ callbacks.push(fn);
3749
+ }
3750
+ };
3751
+ return api2;
3752
+ }
3753
+
3754
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/data-attributes.js
3755
+ var dataAttribute = "data-auto-scrollable";
3756
+ var selector = "[".concat(dataAttribute, '="true"]');
3757
+ function addScrollableAttribute(element) {
3758
+ element.setAttribute(dataAttribute, "true");
3759
+ return function() {
3760
+ return element.removeAttribute(dataAttribute);
3761
+ };
3762
+ }
3763
+
3764
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/configuration.js
3765
+ function ownKeys4(e, r) {
3766
+ var t = Object.keys(e);
3767
+ if (Object.getOwnPropertySymbols) {
3768
+ var o = Object.getOwnPropertySymbols(e);
3769
+ r && (o = o.filter(function(r2) {
3770
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
3771
+ })), t.push.apply(t, o);
3772
+ }
3773
+ return t;
3774
+ }
3775
+ function _objectSpread4(e) {
3776
+ for (var r = 1; r < arguments.length; r++) {
3777
+ var t = null != arguments[r] ? arguments[r] : {};
3778
+ r % 2 ? ownKeys4(Object(t), true).forEach(function(r2) {
3779
+ _defineProperty(e, r2, t[r2]);
3780
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys4(Object(t)).forEach(function(r2) {
3781
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
3782
+ });
3783
+ }
3784
+ return e;
3785
+ }
3786
+ var baseConfig = {
3787
+ startHitboxAtPercentageRemainingOfElement: {
3788
+ top: 0.25,
3789
+ right: 0.25,
3790
+ bottom: 0.25,
3791
+ left: 0.25
3792
+ },
3793
+ maxScrollAtPercentageRemainingOfHitbox: {
3794
+ top: 0.5,
3795
+ right: 0.5,
3796
+ bottom: 0.5,
3797
+ left: 0.5
3798
+ },
3799
+ timeDampeningDurationMs: 400,
3800
+ // Too big and it's too easy to trigger auto scrolling
3801
+ // Too small and it's too hard 😅
3802
+ maxMainAxisHitboxSize: 180
3803
+ };
3804
+ var maxPixelScrollPerSecond = {
3805
+ // What the value would be if we were scrolling at 15px per frame at 60fps.
3806
+ // This is the default as it works well for most experiences.
3807
+ // In certain scenarios though it can feel a bit slow.
3808
+ standard: 15 * 60,
3809
+ // What the value would be if we were scrolling at 25px per frame at 60fps.
3810
+ // This is not the default as it feels too fast for a lot of experiences.
3811
+ fast: 25 * 60
3812
+ };
3813
+ function getInternalConfig(provided) {
3814
+ var _provided$maxScrollSp;
3815
+ return _objectSpread4(_objectSpread4({}, baseConfig), {}, {
3816
+ // only allowing limited control over the config at this stage
3817
+ maxPixelScrollPerSecond: maxPixelScrollPerSecond[(_provided$maxScrollSp = provided === null || provided === void 0 ? void 0 : provided.maxScrollSpeed) !== null && _provided$maxScrollSp !== void 0 ? _provided$maxScrollSp : "standard"]
3818
+ });
3819
+ }
3820
+
3821
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/can-scroll-on-edge.js
3822
+ var canScrollOnEdge = {
3823
+ // Notes:
3824
+ //
3825
+ // 🌏 Chrome 115.0: uses fractional units for `scrollLeft` and `scrollTop`
3826
+ // (and fractional units don't reach true integer maximum when zoomed in / out)
3827
+ // 🍎 Safari 16.5.2: no fractional units
3828
+ // 🦊 Firefox 115.0: no fractional units
3829
+ // we have some scroll we can move backwards into
3830
+ top: function top(element) {
3831
+ return element.scrollTop > 0;
3832
+ },
3833
+ // We have some scroll we can move forward into
3834
+ right: function right(element) {
3835
+ return Math.ceil(element.scrollLeft) + element.clientWidth < element.scrollWidth;
3836
+ },
3837
+ // We have some scroll we can move forwards into
3838
+ bottom: function bottom(element) {
3839
+ return Math.ceil(element.scrollTop) + element.clientHeight < element.scrollHeight;
3840
+ },
3841
+ // we have some scroll we can move back into.
3842
+ left: function left(element) {
3843
+ return element.scrollLeft > 0;
3844
+ }
3845
+ };
3846
+
3847
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/edges.js
3848
+ var edges = ["top", "right", "bottom", "left"];
3849
+ var edgeAxisLookup = {
3850
+ top: "vertical",
3851
+ right: "horizontal",
3852
+ bottom: "vertical",
3853
+ left: "horizontal"
3854
+ };
3855
+
3856
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/axis.js
3857
+ var vertical = {
3858
+ start: "top",
3859
+ end: "bottom",
3860
+ point: "y",
3861
+ size: "height"
3862
+ };
3863
+ var horizontal = {
3864
+ start: "left",
3865
+ end: "right",
3866
+ point: "x",
3867
+ size: "width"
3868
+ };
3869
+ var axisLookup = {
3870
+ vertical: {
3871
+ mainAxis: vertical,
3872
+ crossAxis: horizontal
3873
+ },
3874
+ horizontal: {
3875
+ mainAxis: horizontal,
3876
+ crossAxis: vertical
3877
+ }
3878
+ };
3879
+
3880
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/side.js
3881
+ var mainAxisSideLookup = {
3882
+ top: "start",
3883
+ right: "end",
3884
+ bottom: "end",
3885
+ left: "start"
3886
+ };
3887
+
3888
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/get-over-element-hitbox.js
3889
+ function makeGetHitbox(_ref) {
3890
+ var edge = _ref.edge, axis = _ref.axis;
3891
+ return function hitbox(_ref2) {
3892
+ var clientRect = _ref2.clientRect, config = _ref2.config;
3893
+ var _axisLookup$axis = axisLookup[axis], mainAxis = _axisLookup$axis.mainAxis, crossAxis = _axisLookup$axis.crossAxis;
3894
+ var side = mainAxisSideLookup[edge];
3895
+ var mainAxisHitboxSize = Math.min(
3896
+ // scale the size of the hitbox down for smaller elements
3897
+ config.startHitboxAtPercentageRemainingOfElement[edge] * clientRect[mainAxis.size],
3898
+ // Don't let the hitbox grow too big for big elements
3899
+ config.maxMainAxisHitboxSize
3900
+ );
3901
+ return DOMRect.fromRect(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, mainAxis.point, side === "start" ? (
3902
+ // begin from the start edge and grow inwards
3903
+ clientRect[mainAxis.point]
3904
+ ) : (
3905
+ // begin from inside the end edge and grow towards the end edge
3906
+ clientRect[mainAxis.point] + clientRect[mainAxis.size] - mainAxisHitboxSize
3907
+ )), crossAxis.point, clientRect[crossAxis.point]), mainAxis.size, mainAxisHitboxSize), crossAxis.size, clientRect[crossAxis.size]));
3908
+ };
3909
+ }
3910
+ var getOverElementHitbox = {
3911
+ top: makeGetHitbox({
3912
+ axis: "vertical",
3913
+ edge: "top"
3914
+ }),
3915
+ right: makeGetHitbox({
3916
+ axis: "horizontal",
3917
+ edge: "right"
3918
+ }),
3919
+ bottom: makeGetHitbox({
3920
+ axis: "vertical",
3921
+ edge: "bottom"
3922
+ }),
3923
+ left: makeGetHitbox({
3924
+ axis: "horizontal",
3925
+ edge: "left"
3926
+ })
3927
+ };
3928
+
3929
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/get-percentage-in-range.js
3930
+ function getPercentageInRange(_ref) {
3931
+ var startOfRange = _ref.startOfRange, endOfRange = _ref.endOfRange, value = _ref.value;
3932
+ var isValid = startOfRange < endOfRange;
3933
+ if (!isValid) {
3934
+ return 0;
3935
+ }
3936
+ if (value < startOfRange) {
3937
+ return 0;
3938
+ }
3939
+ if (value > endOfRange) {
3940
+ return 1;
3941
+ }
3942
+ var range = endOfRange - startOfRange;
3943
+ return (value - startOfRange) / range;
3944
+ }
3945
+
3946
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/get-scroll-change.js
3947
+ function getMaxScrollChange(_ref) {
3948
+ var timeSinceLastFrame = _ref.timeSinceLastFrame, config = _ref.config;
3949
+ var targetScrollPerMs = config.maxPixelScrollPerSecond / 1e3;
3950
+ var proposed = Math.ceil(targetScrollPerMs * timeSinceLastFrame);
3951
+ var maximum = config.maxPixelScrollPerSecond / 60;
3952
+ return Math.min(proposed, maximum);
3953
+ }
3954
+ function getDistanceDampening(_ref2) {
3955
+ var client = _ref2.client, axis = _ref2.axis, edge = _ref2.edge, hitbox = _ref2.hitbox, config = _ref2.config;
3956
+ var mainAxis = axisLookup[axis].mainAxis;
3957
+ var side = mainAxisSideLookup[edge];
3958
+ var maxSpeedBuffer = hitbox[mainAxis.size] * config.maxScrollAtPercentageRemainingOfHitbox[edge];
3959
+ if (side === "end") {
3960
+ return getPercentageInRange({
3961
+ startOfRange: hitbox[mainAxis.start],
3962
+ endOfRange: hitbox[mainAxis.end] - maxSpeedBuffer,
3963
+ value: client[mainAxis.point]
3964
+ });
3965
+ }
3966
+ var raw = getPercentageInRange({
3967
+ startOfRange: hitbox[mainAxis.start] + maxSpeedBuffer,
3968
+ endOfRange: hitbox[mainAxis.end],
3969
+ value: client[mainAxis.point]
3970
+ });
3971
+ return 1 - raw;
3972
+ }
3973
+ function getScrollChange(_ref3) {
3974
+ var client = _ref3.client, timeSinceLastFrame = _ref3.timeSinceLastFrame, engagement = _ref3.engagement, axis = _ref3.axis, hitbox = _ref3.hitbox, edge = _ref3.edge, isDistanceDampeningEnabled = _ref3.isDistanceDampeningEnabled, config = _ref3.config;
3975
+ var maxScroll = getMaxScrollChange({
3976
+ timeSinceLastFrame,
3977
+ config
3978
+ });
3979
+ var percentageDistanceDampening = isDistanceDampeningEnabled ? getDistanceDampening({
3980
+ client,
3981
+ edge,
3982
+ hitbox,
3983
+ axis,
3984
+ config
3985
+ }) : 1;
3986
+ var percentageThroughTimeDampening = getPercentageInRange({
3987
+ startOfRange: engagement.timeOfEngagementStart,
3988
+ endOfRange: engagement.timeOfEngagementStart + config.timeDampeningDurationMs,
3989
+ value: Date.now()
3990
+ });
3991
+ var percentageOfMaxScroll = percentageDistanceDampening * percentageThroughTimeDampening;
3992
+ var scroll = Math.max(maxScroll * percentageOfMaxScroll, 1);
3993
+ var side = mainAxisSideLookup[edge];
3994
+ return side === "end" ? scroll : -1 * scroll;
3995
+ }
3996
+
3997
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/is-axis-allowed.js
3998
+ function isAxisAllowed(axis, allowedAxis) {
3999
+ return allowedAxis === "all" || axis === allowedAxis;
4000
+ }
4001
+
4002
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/is-within.js
4003
+ function isWithin2(_ref) {
4004
+ var client = _ref.client, clientRect = _ref.clientRect;
4005
+ return (
4006
+ // is within horizontal bounds
4007
+ client.x >= clientRect.x && client.x <= clientRect.x + clientRect.width && // is within vertical bounds
4008
+ client.y >= clientRect.y && client.y <= clientRect.y + clientRect.height
4009
+ );
4010
+ }
4011
+
4012
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/get-scroll-by.js
4013
+ function getRectDefault(element) {
4014
+ return element.getBoundingClientRect();
4015
+ }
4016
+ function getScrollBy(_ref) {
4017
+ var element = _ref.element, input = _ref.input, timeSinceLastFrame = _ref.timeSinceLastFrame, engagement = _ref.engagement, config = _ref.config, allowedAxis = _ref.allowedAxis, _ref$getRect = _ref.getRect, getRect = _ref$getRect === void 0 ? getRectDefault : _ref$getRect;
4018
+ var client = {
4019
+ x: input.clientX,
4020
+ y: input.clientY
4021
+ };
4022
+ var clientRect = getRect(element);
4023
+ var scrollableEdges = edges.reduce(function(map, edge) {
4024
+ var hitbox = getOverElementHitbox[edge]({
4025
+ clientRect,
4026
+ config
4027
+ });
4028
+ var axis = edgeAxisLookup[edge];
4029
+ if (!isAxisAllowed(axis, allowedAxis)) {
4030
+ return map;
4031
+ }
4032
+ if (!isWithin2({
4033
+ client,
4034
+ clientRect: hitbox
4035
+ })) {
4036
+ return map;
4037
+ }
4038
+ if (!canScrollOnEdge[edge](element)) {
4039
+ return map;
4040
+ }
4041
+ map.set(edge, {
4042
+ edge,
4043
+ hitbox
4044
+ });
4045
+ return map;
4046
+ }, /* @__PURE__ */ new Map());
4047
+ var left2 = (function() {
4048
+ var axis = "horizontal";
4049
+ var leftEdge = scrollableEdges.get("left");
4050
+ if (leftEdge) {
4051
+ return getScrollChange({
4052
+ client,
4053
+ edge: leftEdge.edge,
4054
+ hitbox: leftEdge.hitbox,
4055
+ axis,
4056
+ timeSinceLastFrame,
4057
+ engagement,
4058
+ isDistanceDampeningEnabled: true,
4059
+ config
4060
+ });
4061
+ }
4062
+ var rightEdge = scrollableEdges.get("right");
4063
+ if (rightEdge) {
4064
+ return getScrollChange({
4065
+ client,
4066
+ edge: rightEdge.edge,
4067
+ hitbox: rightEdge.hitbox,
4068
+ axis,
4069
+ timeSinceLastFrame,
4070
+ engagement,
4071
+ isDistanceDampeningEnabled: true,
4072
+ config
4073
+ });
4074
+ }
4075
+ return 0;
4076
+ })();
4077
+ var top2 = (function() {
4078
+ var axis = "vertical";
4079
+ var bottomEdge = scrollableEdges.get("bottom");
4080
+ if (bottomEdge) {
4081
+ return getScrollChange({
4082
+ client,
4083
+ edge: bottomEdge.edge,
4084
+ hitbox: bottomEdge.hitbox,
4085
+ axis,
4086
+ timeSinceLastFrame,
4087
+ engagement,
4088
+ isDistanceDampeningEnabled: true,
4089
+ config
4090
+ });
4091
+ }
4092
+ var topEdge = scrollableEdges.get("top");
4093
+ if (topEdge) {
4094
+ return getScrollChange({
4095
+ client,
4096
+ edge: topEdge.edge,
4097
+ hitbox: topEdge.hitbox,
4098
+ axis,
4099
+ timeSinceLastFrame,
4100
+ engagement,
4101
+ isDistanceDampeningEnabled: true,
4102
+ config
4103
+ });
4104
+ }
4105
+ return 0;
4106
+ })();
4107
+ return {
4108
+ left: left2,
4109
+ top: top2
4110
+ };
4111
+ }
4112
+
4113
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/try-scroll.js
4114
+ function _createForOfIteratorHelper3(r, e) {
4115
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
4116
+ if (!t) {
4117
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray4(r)) || e && r && "number" == typeof r.length) {
4118
+ t && (r = t);
4119
+ var _n = 0, F = function F2() {
4120
+ };
4121
+ return { s: F, n: function n() {
4122
+ return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
4123
+ }, e: function e2(r2) {
4124
+ throw r2;
4125
+ }, f: F };
4126
+ }
4127
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4128
+ }
4129
+ var o, a = true, u = false;
4130
+ return { s: function s() {
4131
+ t = t.call(r);
4132
+ }, n: function n() {
4133
+ var r2 = t.next();
4134
+ return a = r2.done, r2;
4135
+ }, e: function e2(r2) {
4136
+ u = true, o = r2;
4137
+ }, f: function f() {
4138
+ try {
4139
+ a || null == t.return || t.return();
4140
+ } finally {
4141
+ if (u) throw o;
1811
4142
  }
4143
+ } };
4144
+ }
4145
+ function _unsupportedIterableToArray4(r, a) {
4146
+ if (r) {
4147
+ if ("string" == typeof r) return _arrayLikeToArray4(r, a);
4148
+ var t = {}.toString.call(r).slice(8, -1);
4149
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray4(r, a) : void 0;
1812
4150
  }
1813
- /**
1814
- * Mark a story paragraph as belonging to this region. The full anchor id is stamped alongside
1815
- * `data-anchor` (which carries only the bare unid, matching the body's convention) so band
1816
- * chrome can address the block without going through the editor's unid map. Called on first
1817
- * render AND after an incremental swap, which replaces the DOM node.
1818
- */
1819
- adoptBlock(el, anchorId) {
1820
- const body = this.blockRootOf(el);
1821
- if (!body) return;
1822
- el.setAttribute("data-hf-anchor", anchorId);
1823
- if (el.dataset.hfAdopted === "true") return;
1824
- el.dataset.hfAdopted = "true";
1825
- el.addEventListener("focus", () => {
1826
- body.querySelectorAll("[data-hf-focused]").forEach((sib) => sib.removeAttribute("data-hf-focused"));
1827
- el.setAttribute("data-hf-focused", "true");
4151
+ }
4152
+ function _arrayLikeToArray4(r, a) {
4153
+ (null == a || a > r.length) && (a = r.length);
4154
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4155
+ return n;
4156
+ }
4157
+ function isScrollingAvailable(value) {
4158
+ return Boolean(value.top || value.left);
4159
+ }
4160
+ function tryScrollElements(_ref) {
4161
+ var _container$getConfigu, _container$getAllowed, _container$getAllowed2;
4162
+ var target = _ref.target, input = _ref.input, source = _ref.source, findEntry = _ref.findEntry, timeSinceLastFrame = _ref.timeSinceLastFrame, _ref$available = _ref.available, available = _ref$available === void 0 ? {
4163
+ top: true,
4164
+ left: true
4165
+ } : _ref$available;
4166
+ if (!isScrollingAvailable(available)) {
4167
+ return available;
4168
+ }
4169
+ if (!target) {
4170
+ return available;
4171
+ }
4172
+ var element = target.closest(selector);
4173
+ if (!element) {
4174
+ return available;
4175
+ }
4176
+ var container = findEntry(element);
4177
+ if (!container) {
4178
+ return available;
4179
+ }
4180
+ function continueSearchUp() {
4181
+ var _element$parentElemen;
4182
+ return tryScrollElements({
4183
+ target: (_element$parentElemen = element === null || element === void 0 ? void 0 : element.parentElement) !== null && _element$parentElemen !== void 0 ? _element$parentElemen : null,
4184
+ findEntry,
4185
+ source,
4186
+ timeSinceLastFrame,
4187
+ input,
4188
+ available
1828
4189
  });
1829
4190
  }
1830
- renderStoryBlock(anchorId) {
1831
- const html = this.bridge.RenderBlockHtml(
1832
- this.handle,
1833
- anchorId,
1834
- this.options.cssPrefix,
1835
- this.options.fabricateClasses
1836
- );
1837
- if (html.charCodeAt(0) === 123) return null;
1838
- return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
4191
+ var feedback = {
4192
+ input,
4193
+ source,
4194
+ element
4195
+ };
4196
+ if (container.canScroll && !container.canScroll(feedback)) {
4197
+ return continueSearchUp();
4198
+ }
4199
+ var engagement = markAndGetEngagement(element);
4200
+ var config = getInternalConfig((_container$getConfigu = container.getConfiguration) === null || _container$getConfigu === void 0 ? void 0 : _container$getConfigu.call(container, feedback));
4201
+ var allowedAxis = (_container$getAllowed = (_container$getAllowed2 = container.getAllowedAxis) === null || _container$getAllowed2 === void 0 ? void 0 : _container$getAllowed2.call(container, feedback)) !== null && _container$getAllowed !== void 0 ? _container$getAllowed : "all";
4202
+ var scrollBy = getScrollBy({
4203
+ element,
4204
+ engagement,
4205
+ input,
4206
+ timeSinceLastFrame,
4207
+ allowedAxis,
4208
+ config
4209
+ });
4210
+ var scroll = {
4211
+ top: 0,
4212
+ left: 0
4213
+ };
4214
+ if (available.top && scrollBy.top !== 0) {
4215
+ scroll.top = scrollBy.top;
4216
+ available.top = false;
1839
4217
  }
1840
- placeholder(which, kind) {
1841
- const el = document.createElement("div");
1842
- el.className = "docx-hf-placeholder";
1843
- el.setAttribute("data-hf-placeholder", "");
1844
- const label = KIND_LABELS.find((k) => k.value === kind)?.label ?? kind;
1845
- el.textContent = `No ${label.toLowerCase()} ${which} \u2014 pick a kind to create one.`;
1846
- return el;
4218
+ if (available.left && scrollBy.left !== 0) {
4219
+ scroll.left = scrollBy.left;
4220
+ available.left = false;
1847
4221
  }
1848
- /**
1849
- * Surface the caveat that comes with the selected kind. Turning on first/even means those pages
1850
- * stop using the Default stories entirely, which bites hardest on the OTHER band: enabling an
1851
- * even header with no even footer leaves even pages footer-less, and enabling a first-page
1852
- * header with an empty first-page footer leaves page 1 footer-less. The note is shown whenever
1853
- * first/even is selected (the behavior change is real either way); the fix button appears only
1854
- * when the counterpart story is missing entirely, which is what a user almost always wants next.
1855
- */
1856
- renderKindWarning(which) {
1857
- const band = this.bandFor(which);
1858
- const warning = band.querySelector("[data-hf-warning]");
1859
- if (!warning) return;
1860
- const kind = this.kinds[which];
1861
- if (kind === "default") {
1862
- warning.hidden = true;
1863
- warning.textContent = "";
1864
- return;
4222
+ if (scroll.top !== 0 || scroll.left !== 0) {
4223
+ element.scrollBy(scroll);
4224
+ }
4225
+ return continueSearchUp();
4226
+ }
4227
+ function tryScrollWindow(_ref2) {
4228
+ var input = _ref2.input, timeSinceLastFrame = _ref2.timeSinceLastFrame, available = _ref2.available, source = _ref2.source, entries = _ref2.entries;
4229
+ var element = document.documentElement;
4230
+ var feedback = {
4231
+ input,
4232
+ source,
4233
+ element
4234
+ };
4235
+ var _iterator = _createForOfIteratorHelper3(entries), _step;
4236
+ try {
4237
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
4238
+ var _entry$getConfigurati, _entry$getAllowedAxis, _entry$getAllowedAxis2;
4239
+ var entry = _step.value;
4240
+ if (entry.canScroll && !entry.canScroll(feedback)) {
4241
+ continue;
4242
+ }
4243
+ var engagement = markAndGetEngagement(element);
4244
+ var config = getInternalConfig((_entry$getConfigurati = entry.getConfiguration) === null || _entry$getConfigurati === void 0 ? void 0 : _entry$getConfigurati.call(entry, feedback));
4245
+ var allowedAxis = (_entry$getAllowedAxis = (_entry$getAllowedAxis2 = entry.getAllowedAxis) === null || _entry$getAllowedAxis2 === void 0 ? void 0 : _entry$getAllowedAxis2.call(entry, feedback)) !== null && _entry$getAllowedAxis !== void 0 ? _entry$getAllowedAxis : "all";
4246
+ var scrollBy = getScrollBy({
4247
+ element,
4248
+ engagement,
4249
+ input,
4250
+ config,
4251
+ allowedAxis,
4252
+ getRect: function getRect(element2) {
4253
+ return DOMRect.fromRect({
4254
+ y: 0,
4255
+ x: 0,
4256
+ width: element2.clientWidth,
4257
+ height: element2.clientHeight
4258
+ });
4259
+ },
4260
+ timeSinceLastFrame
4261
+ });
4262
+ var scroll = {
4263
+ top: available.top ? scrollBy.top : 0,
4264
+ left: available.left ? scrollBy.left : 0
4265
+ };
4266
+ if (scroll.top !== 0 || scroll.left !== 0) {
4267
+ element.scrollBy(scroll);
4268
+ }
4269
+ break;
1865
4270
  }
1866
- const other = which === "header" ? "footer" : "header";
1867
- warning.hidden = false;
1868
- warning.textContent = `${kind === "even" ? EVEN_WARNING : FIRST_WARNING} `;
1869
- if (this.partUriFor(other, kind)) return;
1870
- const fix = document.createElement("button");
1871
- fix.type = "button";
1872
- fix.setAttribute("data-hf-fix-counterpart", "");
1873
- fix.textContent = `Also create a ${kind === "even" ? "matching even" : "first-page"} ${other}`;
1874
- fix.addEventListener("click", () => {
1875
- this.setKind(other, kind);
1876
- this.renderKindWarning(which);
4271
+ } catch (err) {
4272
+ _iterator.e(err);
4273
+ } finally {
4274
+ _iterator.f();
4275
+ }
4276
+ }
4277
+ function tryScroll(_ref3) {
4278
+ var input = _ref3.input, findEntry = _ref3.findEntry, timeSinceLastFrame = _ref3.timeSinceLastFrame, source = _ref3.source, getWindowScrollEntries = _ref3.getWindowScrollEntries, underUsersPointer = _ref3.underUsersPointer;
4279
+ var remainder = tryScrollElements({
4280
+ target: underUsersPointer,
4281
+ timeSinceLastFrame,
4282
+ input,
4283
+ source,
4284
+ findEntry
4285
+ });
4286
+ if (!isScrollingAvailable(remainder)) {
4287
+ return;
4288
+ }
4289
+ tryScrollWindow({
4290
+ input,
4291
+ source,
4292
+ entries: getWindowScrollEntries(),
4293
+ timeSinceLastFrame,
4294
+ available: remainder
4295
+ });
4296
+ }
4297
+
4298
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/make-api.js
4299
+ function ownKeys5(e, r) {
4300
+ var t = Object.keys(e);
4301
+ if (Object.getOwnPropertySymbols) {
4302
+ var o = Object.getOwnPropertySymbols(e);
4303
+ r && (o = o.filter(function(r2) {
4304
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
4305
+ })), t.push.apply(t, o);
4306
+ }
4307
+ return t;
4308
+ }
4309
+ function _objectSpread5(e) {
4310
+ for (var r = 1; r < arguments.length; r++) {
4311
+ var t = null != arguments[r] ? arguments[r] : {};
4312
+ r % 2 ? ownKeys5(Object(t), true).forEach(function(r2) {
4313
+ _defineProperty(e, r2, t[r2]);
4314
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys5(Object(t)).forEach(function(r2) {
4315
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
1877
4316
  });
1878
- warning.appendChild(fix);
1879
4317
  }
1880
- };
1881
- function parseResult(json) {
1882
- try {
1883
- return JSON.parse(json);
1884
- } catch {
1885
- return { success: false };
4318
+ return e;
4319
+ }
4320
+ function makeApi(_ref) {
4321
+ var monitor = _ref.monitor;
4322
+ var elementRegistry = /* @__PURE__ */ new Map();
4323
+ var windowRegistry = /* @__PURE__ */ new Set();
4324
+ function autoScroll(args) {
4325
+ if (true) {
4326
+ var _window$getComputedSt = window.getComputedStyle(args.element), overflowX = _window$getComputedSt.overflowX, overflowY = _window$getComputedSt.overflowY;
4327
+ var isScrollable = overflowX === "auto" || overflowX === "scroll" || overflowY === "auto" || overflowY === "scroll";
4328
+ if (!isScrollable) {
4329
+ console.warn("Auto scrolling has been attached to an element that appears not to be scrollable", {
4330
+ element: args.element,
4331
+ overflowX,
4332
+ overflowY
4333
+ });
4334
+ }
4335
+ }
4336
+ if (true) {
4337
+ var existing = elementRegistry.get(args.element);
4338
+ if (existing) {
4339
+ console.warn("You have already registered autoScrolling on the same element", {
4340
+ existing,
4341
+ proposed: args
4342
+ });
4343
+ }
4344
+ }
4345
+ elementRegistry.set(args.element, args);
4346
+ var cleanup = combine(addScrollableAttribute(args.element), function() {
4347
+ return elementRegistry.delete(args.element);
4348
+ });
4349
+ return once(cleanup);
4350
+ }
4351
+ function autoScrollWindow() {
4352
+ var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
4353
+ var unique = _objectSpread5({}, args);
4354
+ windowRegistry.add(unique);
4355
+ function cleanup() {
4356
+ windowRegistry.delete(unique);
4357
+ }
4358
+ return once(cleanup);
4359
+ }
4360
+ function findEntry(element) {
4361
+ var _elementRegistry$get;
4362
+ return (_elementRegistry$get = elementRegistry.get(element)) !== null && _elementRegistry$get !== void 0 ? _elementRegistry$get : null;
4363
+ }
4364
+ function getWindowScrollEntries() {
4365
+ return Array.from(windowRegistry);
4366
+ }
4367
+ function onFrame(_ref2) {
4368
+ var latestArgs = _ref2.latestArgs, underUsersPointer = _ref2.underUsersPointer, timeSinceLastFrame = _ref2.timeSinceLastFrame;
4369
+ tryScroll({
4370
+ input: latestArgs.location.current.input,
4371
+ source: latestArgs.source,
4372
+ findEntry,
4373
+ underUsersPointer,
4374
+ timeSinceLastFrame,
4375
+ getWindowScrollEntries
4376
+ });
1886
4377
  }
4378
+ getScheduler(monitor).onFrame(onFrame);
4379
+ return {
4380
+ autoScroll,
4381
+ autoScrollWindow
4382
+ };
1887
4383
  }
1888
4384
 
4385
+ // node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/entry-point/element.js
4386
+ var api = makeApi({
4387
+ monitor: monitorForElements
4388
+ });
4389
+ var autoScrollForElements = api.autoScroll;
4390
+ var autoScrollWindowForElements = api.autoScrollWindow;
4391
+
1889
4392
  // src/editor-reconcile.ts
1890
4393
  function tokenOf(unit) {
1891
4394
  return unidOf(unit.id) + (unit.sig ? "|" + unit.sig : "");
@@ -1925,15 +4428,32 @@ var DocxodusEditor = (() => {
1925
4428
  const bar = token.indexOf("|");
1926
4429
  return bar < 0 ? token : token.slice(0, bar);
1927
4430
  };
1928
- const substituted = [];
4431
+ const moved = [];
1929
4432
  const usedRemoved = /* @__PURE__ */ new Set();
4433
+ const usedAdded = /* @__PURE__ */ new Set();
4434
+ const removedByToken = /* @__PURE__ */ new Map();
4435
+ for (const oi of removed) {
4436
+ (removedByToken.get(oldUnids[oi]) ?? removedByToken.set(oldUnids[oi], []).get(oldUnids[oi])).push(oi);
4437
+ }
4438
+ for (const nj of added) {
4439
+ const candidates = removedByToken.get(newUnids[nj]);
4440
+ const oi = candidates?.find((i2) => !usedRemoved.has(i2));
4441
+ if (oi !== void 0) {
4442
+ moved.push({ oldIndex: oi, newIndex: nj });
4443
+ usedRemoved.add(oi);
4444
+ usedAdded.add(nj);
4445
+ }
4446
+ }
4447
+ const substituted = [];
1930
4448
  const removedByUnid = /* @__PURE__ */ new Map();
1931
4449
  for (const oi of removed) {
4450
+ if (usedRemoved.has(oi)) continue;
1932
4451
  const u = bareUnid(oldUnids[oi]);
1933
4452
  (removedByUnid.get(u) ?? removedByUnid.set(u, []).get(u)).push(oi);
1934
4453
  }
1935
4454
  const unmatchedAdded = [];
1936
4455
  for (const nj of added) {
4456
+ if (usedAdded.has(nj)) continue;
1937
4457
  const candidates = removedByUnid.get(bareUnid(newUnids[nj]));
1938
4458
  const oi = candidates?.find((i2) => !usedRemoved.has(i2));
1939
4459
  if (oi !== void 0) {
@@ -1964,7 +4484,7 @@ var DocxodusEditor = (() => {
1964
4484
  }
1965
4485
  }
1966
4486
  }
1967
- return { keep, removed, added, substituted };
4487
+ return { keep, removed, added, substituted, moved };
1968
4488
  }
1969
4489
  function needsRemount(diff, newUnits, oldKinds, threshold = 40) {
1970
4490
  if (diff.added.length + diff.removed.length > threshold) return true;
@@ -1981,6 +4501,46 @@ var DocxodusEditor = (() => {
1981
4501
 
1982
4502
  // src/editor.ts
1983
4503
  var EDITABLE_TAGS = /* @__PURE__ */ new Set(["P", "H1", "H2", "H3", "H4", "H5", "H6"]);
4504
+ var BLOCK_DRAG_TYPE = "docxodus-block";
4505
+ var blockDragStyledDocuments = /* @__PURE__ */ new WeakSet();
4506
+ function ensureBlockDragStyles(doc) {
4507
+ if (blockDragStyledDocuments.has(doc)) return;
4508
+ blockDragStyledDocuments.add(doc);
4509
+ const style = doc.createElement("style");
4510
+ style.dataset.docxodusBlockDrag = "true";
4511
+ style.textContent = `
4512
+ .docx-block-handle {
4513
+ position: fixed; z-index: 2147483000; display: none; width: 26px; height: 28px;
4514
+ align-items: center; justify-content: center; padding: 0; border: 1px solid #d0d5dd;
4515
+ border-radius: 6px; background: #fff; color: #667085; box-shadow: 0 1px 3px rgba(16,24,40,.12);
4516
+ cursor: grab; font: 700 17px/1 system-ui, sans-serif; user-select: none; touch-action: none;
4517
+ }
4518
+ .docx-block-handle:hover, .docx-block-handle:focus-visible { color: #344054; border-color: #98a2b3; outline: none; }
4519
+ .docx-block-handle[aria-pressed="true"] { color: #175cd3; border-color: #84adff; background: #eff8ff; }
4520
+ .docx-block-handle.docx-block-dragging { cursor: grabbing; opacity: .78; }
4521
+ .docx-block-drop-indicator {
4522
+ position: fixed; z-index: 2147482999; display: none; height: 3px; pointer-events: none;
4523
+ border-radius: 999px; background: #2e90fa; box-shadow: 0 0 0 1px rgba(255,255,255,.85);
4524
+ }
4525
+ .docx-block-move-menu {
4526
+ position: fixed; z-index: 2147483001; display: none; min-width: 150px; padding: 5px;
4527
+ border: 1px solid #d0d5dd; border-radius: 8px; background: #fff;
4528
+ box-shadow: 0 8px 24px rgba(16,24,40,.18); font: 13px/1.35 system-ui, sans-serif;
4529
+ }
4530
+ .docx-block-move-menu button { display: block; width: 100%; padding: 7px 9px; border: 0; border-radius: 5px; background: transparent; color: #344054; text-align: left; }
4531
+ .docx-block-move-menu button:hover, .docx-block-move-menu button:focus-visible { background: #f2f4f7; outline: none; }
4532
+ .docx-block-move-menu button:disabled { color: #98a2b3; background: transparent; }
4533
+ .docx-block-move-flash { animation: docx-block-move-flash 800ms ease-out; }
4534
+ @keyframes docx-block-move-flash { from { box-shadow: 0 0 0 3px rgba(46,144,250,.55); } to { box-shadow: none; } }
4535
+ .docx-block-live-region { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
4536
+ `;
4537
+ (doc.head ?? doc.documentElement).appendChild(style);
4538
+ }
4539
+ function trackedChangeWireName(mode) {
4540
+ if (mode === 1 /* RenderInline */) return "render_inline";
4541
+ if (mode === 2 /* StripDeletions */) return "strip_deletions";
4542
+ return "accept";
4543
+ }
1984
4544
  function fontWeightIsBold(w) {
1985
4545
  if (w === "bold" || w === "bolder") return true;
1986
4546
  const n = parseInt(w, 10);
@@ -2128,9 +4688,9 @@ var DocxodusEditor = (() => {
2128
4688
  }
2129
4689
  function trimmedSpan(block, span) {
2130
4690
  const { leading, trimmedLen } = trimBounds(block);
2131
- const start = Math.max(0, Math.min(span.start - Math.min(span.start, leading), trimmedLen));
2132
- const end = Math.max(start, Math.min(span.start + span.length - leading, trimmedLen));
2133
- return { start, length: end - start };
4691
+ const start2 = Math.max(0, Math.min(span.start - Math.min(span.start, leading), trimmedLen));
4692
+ const end = Math.max(start2, Math.min(span.start + span.length - leading, trimmedLen));
4693
+ return { start: start2, length: end - start2 };
2134
4694
  }
2135
4695
  function contentPositionIn(el, offset) {
2136
4696
  let remaining = offset;
@@ -2173,9 +4733,9 @@ var DocxodusEditor = (() => {
2173
4733
  probe.collapse(true);
2174
4734
  const focusIsBefore = probe.comparePoint(focus.node, focus.offset) < 0;
2175
4735
  const range = document.createRange();
2176
- const start = focusIsBefore ? focus : anchor;
4736
+ const start2 = focusIsBefore ? focus : anchor;
2177
4737
  const end = focusIsBefore ? anchor : focus;
2178
- range.setStart(start.node, start.offset);
4738
+ range.setStart(start2.node, start2.offset);
2179
4739
  range.setEnd(end.node, end.offset);
2180
4740
  sel.removeAllRanges();
2181
4741
  sel.addRange(range);
@@ -2223,17 +4783,17 @@ var DocxodusEditor = (() => {
2223
4783
  const range = sel.getRangeAt(0);
2224
4784
  if (range.collapsed) return null;
2225
4785
  if (!block.contains(range.startContainer) || !block.contains(range.endContainer)) return null;
2226
- const start = contentOffsetOf(block, range.startContainer, range.startOffset);
4786
+ const start2 = contentOffsetOf(block, range.startContainer, range.startOffset);
2227
4787
  const end = contentOffsetOf(block, range.endContainer, range.endOffset);
2228
- const span = trimmedSpan(block, { start: Math.min(start, end), length: Math.abs(end - start) });
4788
+ const span = trimmedSpan(block, { start: Math.min(start2, end), length: Math.abs(end - start2) });
2229
4789
  return span.length > 0 ? span : null;
2230
4790
  }
2231
- function selectRange(el, start, length) {
4791
+ function selectRange(el, start2, length) {
2232
4792
  const sel = typeof window !== "undefined" ? window.getSelection() : null;
2233
4793
  if (!sel || !el.isConnected) return;
2234
4794
  el.focus();
2235
4795
  const range = document.createRange();
2236
- const end = start + length;
4796
+ const end = start2 + length;
2237
4797
  let pos = 0;
2238
4798
  let startSet = false;
2239
4799
  const walk = (node) => {
@@ -2242,8 +4802,8 @@ var DocxodusEditor = (() => {
2242
4802
  if (isInMarker(child)) continue;
2243
4803
  const raw = child.textContent ?? "";
2244
4804
  const len = stripBidi(raw).length;
2245
- if (!startSet && pos + len >= start) {
2246
- range.setStart(child, domOffsetForContentOffset(raw, start - pos));
4805
+ if (!startSet && pos + len >= start2) {
4806
+ range.setStart(child, domOffsetForContentOffset(raw, start2 - pos));
2247
4807
  startSet = true;
2248
4808
  }
2249
4809
  if (startSet && pos + len >= end) {
@@ -2294,7 +4854,7 @@ var DocxodusEditor = (() => {
2294
4854
  return false;
2295
4855
  }
2296
4856
  }
2297
- function completeArgs(bytes, cssPrefix, fabricate, paginated, scale) {
4857
+ function completeArgs(bytes, cssPrefix, fabricate, paginated, scale, renderTrackedChanges) {
2298
4858
  return [
2299
4859
  bytes,
2300
4860
  "Document",
@@ -2318,7 +4878,7 @@ var DocxodusEditor = (() => {
2318
4878
  true,
2319
4879
  /* renderHeadersAndFooters */
2320
4880
  paginated,
2321
- false,
4881
+ renderTrackedChanges,
2322
4882
  true,
2323
4883
  true,
2324
4884
  false,
@@ -2341,6 +4901,21 @@ var DocxodusEditor = (() => {
2341
4901
  * structural edit (split/merge/format) is lost. While this flag is set, commitBlock no-ops.
2342
4902
  */
2343
4903
  this.replacing = false;
4904
+ /** Editor-owned block-move chrome. It is deliberately outside the rendered unit tree. */
4905
+ this.blockDragHandle = null;
4906
+ this.blockDropIndicator = null;
4907
+ this.blockMoveMenu = null;
4908
+ this.blockMoveLive = null;
4909
+ this.blockDragSource = null;
4910
+ this.blockDragCleanup = [];
4911
+ this.blockDragTargetCleanup = [];
4912
+ this.blockDragging = false;
4913
+ this.blockDragPointerDown = false;
4914
+ /** Anchors the current drag source may legally move next to, per the engine's own rules.
4915
+ * Null when the bridge predates ValidMoveTargets — then every block is offered, as before. */
4916
+ this.blockMoveTargets = null;
4917
+ /** Why the last move was refused, verbatim from the engine — diagnostics, not announcement copy. */
4918
+ this.lastMoveError = null;
2344
4919
  /**
2345
4920
  * The last real (non-collapsed) text selection inside an editable block. A toolbar control that
2346
4921
  * must take focus to be used — the font-size combobox — blurs the block and collapses the live
@@ -2497,8 +5072,8 @@ var DocxodusEditor = (() => {
2497
5072
  * body edit root by design — also register. The fence still rejects other editors on the page. */
2498
5073
  editableBlockOf(node) {
2499
5074
  if (!node) return null;
2500
- const start = node.nodeType === 1 ? node : node.parentElement;
2501
- const block = start?.closest('[data-anchor][contenteditable="true"]') ?? null;
5075
+ const start2 = node.nodeType === 1 ? node : node.parentElement;
5076
+ const block = start2?.closest('[data-anchor][contenteditable="true"]') ?? null;
2502
5077
  return block && this.container.contains(block) ? block : null;
2503
5078
  }
2504
5079
  /**
@@ -2539,18 +5114,34 @@ var DocxodusEditor = (() => {
2539
5114
  paginated: options.paginated ?? false,
2540
5115
  scale: options.scale ?? 1,
2541
5116
  headerFooter: options.headerFooter ?? false,
2542
- onEdit: options.onEdit
5117
+ blockDrag: options.blockDrag ?? false,
5118
+ trackedChanges: options.trackedChanges ?? 0 /* Accept */,
5119
+ revisionAuthor: options.revisionAuthor ?? "docxodus",
5120
+ onEdit: options.onEdit,
5121
+ onMove: options.onMove
2543
5122
  };
2544
- const handle = exports.DocxSessionBridge.OpenSession(bytes, '{"emitMarkdownPatch":false}');
5123
+ const handle = exports.DocxSessionBridge.OpenSession(bytes, JSON.stringify({
5124
+ emitMarkdownPatch: false,
5125
+ trackedChanges: trackedChangeWireName(opts.trackedChanges),
5126
+ revisionAuthor: opts.revisionAuthor
5127
+ }));
2545
5128
  const editor = new _DocxEditor(container, exports, handle, opts);
2546
5129
  editor.refreshAnchorMap();
2547
5130
  if (opts.headerFooter) editor.createRegion();
2548
5131
  const fullHtml = exports.DocumentConverter.ConvertDocxToHtmlComplete(
2549
- ...completeArgs(bytes, opts.cssPrefix, opts.fabricateClasses, opts.paginated, opts.scale)
5132
+ ...completeArgs(
5133
+ bytes,
5134
+ opts.cssPrefix,
5135
+ opts.fabricateClasses,
5136
+ opts.paginated,
5137
+ opts.scale,
5138
+ opts.trackedChanges === 1 /* RenderInline */
5139
+ )
2550
5140
  );
2551
5141
  if (opts.paginated) editor.mountPaginated(fullHtml);
2552
5142
  else editor.mountHtml(fullHtml);
2553
5143
  editor.syncRegionToBody();
5144
+ editor.setupBlockDrag();
2554
5145
  return editor;
2555
5146
  }
2556
5147
  /**
@@ -2577,6 +5168,7 @@ var DocxodusEditor = (() => {
2577
5168
  document.removeEventListener("mouseup", this.onMouseUp, true);
2578
5169
  }
2579
5170
  this.clearDragSelection();
5171
+ this.teardownBlockDrag();
2580
5172
  this.exports.DocxSessionBridge.CloseSession(this.handle);
2581
5173
  }
2582
5174
  /**
@@ -2604,6 +5196,416 @@ var DocxodusEditor = (() => {
2604
5196
  get sessionHandle() {
2605
5197
  return this.handle;
2606
5198
  }
5199
+ /** Move one top-level body block relative to another and repaint from the live session. */
5200
+ moveBlock(sourceAnchorId, targetAnchorId, position) {
5201
+ this.assertOpen();
5202
+ const bridge = this.exports.DocxSessionBridge;
5203
+ if (typeof bridge.MoveBlock !== "function") return false;
5204
+ const res = this.parseEdit(
5205
+ bridge.MoveBlock(this.handle, sourceAnchorId, targetAnchorId, position)
5206
+ );
5207
+ if (!res.success) {
5208
+ this.lastMoveError = res.error?.message ?? null;
5209
+ this.announceBlockMove("This block cannot be moved there.");
5210
+ return false;
5211
+ }
5212
+ if ((res.created?.length ?? 0) === 0 && (res.modified?.length ?? 0) === 0 && (res.removed?.length ?? 0) === 0) {
5213
+ this.announceBlockMove("The block is already in that position.");
5214
+ return true;
5215
+ }
5216
+ const destination = res.created?.[0] ?? res.modified?.[0];
5217
+ if (this.renderTrackedChanges) this.remount();
5218
+ else this.reconcile();
5219
+ const moved = destination ? this.bodyUnitNodes().find((el) => el.getAttribute("data-anchor") === destination.unid) : null;
5220
+ if (moved) {
5221
+ moved.classList.add("docx-block-move-flash");
5222
+ moved.addEventListener("animationend", () => moved.classList.remove("docx-block-move-flash"), {
5223
+ once: true
5224
+ });
5225
+ const focusTarget = EDITABLE_TAGS.has(moved.tagName) ? moved : moved.querySelector('[data-anchor][contenteditable="true"]');
5226
+ if (focusTarget) {
5227
+ this.activeBlock = focusTarget;
5228
+ focusTarget.focus({ preventScroll: true });
5229
+ }
5230
+ }
5231
+ this.options.onMove?.({
5232
+ sourceAnchorId,
5233
+ destinationAnchorId: destination?.id ?? sourceAnchorId
5234
+ });
5235
+ this.announceBlockMove("Block moved.");
5236
+ return true;
5237
+ }
5238
+ /** Resolve any rendered descendant to its top-level body move unit (tables stay whole). */
5239
+ blockUnitOf(target) {
5240
+ const node = target instanceof Node ? target : null;
5241
+ const el = node?.nodeType === Node.ELEMENT_NODE ? node : node?.parentElement;
5242
+ if (!el || !this.editRoot.contains(el)) return null;
5243
+ return this.bodyUnitNodes().find((unit) => unit === el || unit.contains(el)) ?? null;
5244
+ }
5245
+ isMovableBlockUnit(unit) {
5246
+ if (!unit || !this.anchorIdOf(unit)) return false;
5247
+ if (unit.matches("[class$='row-del'], [class*='row-del ']") || unit.querySelector("tr[class$='row-del'], tr[class*='row-del '], del[class$='move-from'], del[class*='move-from ']")) return false;
5248
+ return unit.tagName === "TABLE" || EDITABLE_TAGS.has(unit.tagName);
5249
+ }
5250
+ currentBlockDragSource() {
5251
+ if (this.isMovableBlockUnit(this.blockDragSource) && this.blockDragSource.isConnected)
5252
+ return this.blockDragSource;
5253
+ const fromActive = this.blockUnitOf(this.activeBlock);
5254
+ if (this.isMovableBlockUnit(fromActive)) {
5255
+ this.blockDragSource = fromActive;
5256
+ return fromActive;
5257
+ }
5258
+ return null;
5259
+ }
5260
+ showBlockHandle(unit) {
5261
+ const handle = this.blockDragHandle;
5262
+ if (!handle || !this.isMovableBlockUnit(unit)) return;
5263
+ const changed = unit !== this.blockDragSource;
5264
+ this.blockDragSource = unit;
5265
+ if (changed) this.refreshBlockMoveTargets(unit);
5266
+ if (this.blockMoveTargets?.size === 0) {
5267
+ handle.style.display = "none";
5268
+ return;
5269
+ }
5270
+ const rect = unit.getBoundingClientRect();
5271
+ handle.style.display = "flex";
5272
+ handle.style.left = `${Math.max(4, rect.left - 32)}px`;
5273
+ handle.style.top = `${Math.max(4, rect.top + (unit.tagName === "TABLE" ? 6 : Math.max(0, (rect.height - 28) / 2)))}px`;
5274
+ const preview = (unit.textContent ?? "").trim().replace(/\s+/g, " ").slice(0, 48);
5275
+ handle.setAttribute("aria-label", preview ? `Move block: ${preview}` : "Move block");
5276
+ if (changed) this.refreshBlockDropTargets();
5277
+ }
5278
+ hideBlockHandle() {
5279
+ if (this.blockDragging || this.blockMoveMenu?.style.display === "block") return;
5280
+ if (this.blockDragHandle) this.blockDragHandle.style.display = "none";
5281
+ }
5282
+ positionBlockHandle() {
5283
+ const source = this.currentBlockDragSource();
5284
+ if (source && this.blockDragHandle?.style.display !== "none") this.showBlockHandle(source);
5285
+ }
5286
+ showDropIndicator(target, position) {
5287
+ const indicator = this.blockDropIndicator;
5288
+ if (!indicator) return;
5289
+ const rect = this.unitWrapperOf(target).getBoundingClientRect();
5290
+ indicator.style.display = "block";
5291
+ indicator.style.left = `${rect.left}px`;
5292
+ indicator.style.top = `${position === "before" ? rect.top - 1 : rect.bottom - 1}px`;
5293
+ indicator.style.width = `${Math.max(24, rect.width)}px`;
5294
+ }
5295
+ hideDropIndicator() {
5296
+ if (this.blockDropIndicator) this.blockDropIndicator.style.display = "none";
5297
+ }
5298
+ announceBlockMove(message) {
5299
+ const live = this.blockMoveLive;
5300
+ if (!live) return;
5301
+ live.textContent = "";
5302
+ this.container.ownerDocument.defaultView?.setTimeout(() => {
5303
+ live.textContent = message;
5304
+ }, 0);
5305
+ }
5306
+ /**
5307
+ * Ask the engine which anchors the current source may move next to. One call per drag source,
5308
+ * so the UI offers only drops MoveBlock will accept — a document with section breaks is
5309
+ * partitioned into regions, and drawing an indicator across one only to fail the drop was the
5310
+ * behaviour this replaces. Null (no bridge support) keeps the previous offer-everything path.
5311
+ */
5312
+ refreshBlockMoveTargets(source) {
5313
+ const bridge = this.exports.DocxSessionBridge;
5314
+ const sourceId = source ? this.anchorIdOf(source) : null;
5315
+ if (!sourceId || typeof bridge.ValidMoveTargets !== "function") {
5316
+ this.blockMoveTargets = null;
5317
+ return;
5318
+ }
5319
+ try {
5320
+ const targets = JSON.parse(bridge.ValidMoveTargets(this.handle, sourceId));
5321
+ this.blockMoveTargets = new Map(
5322
+ targets.map((t) => [t.anchorId, { before: t.before, after: t.after }])
5323
+ );
5324
+ } catch {
5325
+ this.blockMoveTargets = null;
5326
+ }
5327
+ }
5328
+ /**
5329
+ * Whether `unit` is a legal destination for the current drag source — for a SPECIFIC side when
5330
+ * one is given. A cross-block range or a section break between the blocks can make one side
5331
+ * legal and the other not, so "this target is reachable" is not enough to pick a position.
5332
+ */
5333
+ isValidMoveTarget(unit, position) {
5334
+ if (!this.blockMoveTargets) return true;
5335
+ const id = this.anchorIdOf(unit);
5336
+ const sides = id ? this.blockMoveTargets.get(id) : void 0;
5337
+ if (!sides) return false;
5338
+ return position ? sides[position] : sides.before || sides.after;
5339
+ }
5340
+ /**
5341
+ * The side of `unit` a drop at `clientY` should land on: the half the pointer is in, snapped to
5342
+ * the other side when only that one is legal. Snapping rather than refusing keeps a reachable
5343
+ * target usable — the illegal side is usually illegal only because a section break or a
5344
+ * cross-block range sits between the two blocks on that side.
5345
+ */
5346
+ dropPositionFor(unit, clientY) {
5347
+ const rect = unit.getBoundingClientRect();
5348
+ const preferred = clientY < rect.top + rect.height / 2 ? "before" : "after";
5349
+ if (this.isValidMoveTarget(unit, preferred)) return preferred;
5350
+ const other = preferred === "before" ? "after" : "before";
5351
+ return this.isValidMoveTarget(unit, other) ? other : preferred;
5352
+ }
5353
+ refreshBlockDropTargets() {
5354
+ for (const cleanup of this.blockDragTargetCleanup.splice(0)) cleanup();
5355
+ if (!this.blockDragHandle || this.options.paginated) return;
5356
+ for (const unit of this.bodyUnitNodes().filter((el) => this.isMovableBlockUnit(el))) {
5357
+ this.blockDragTargetCleanup.push(dropTargetForElements({
5358
+ element: unit,
5359
+ // A target the engine would refuse is not a drop target at all, so Pragmatic never
5360
+ // fires onDragEnter for it and no indicator is drawn over it.
5361
+ canDrop: ({ source }) => source.data.type === BLOCK_DRAG_TYPE && source.data.sourceAnchorId !== this.anchorIdOf(unit) && this.isValidMoveTarget(unit),
5362
+ getData: ({ input }) => ({
5363
+ type: BLOCK_DRAG_TYPE,
5364
+ targetAnchorId: this.anchorIdOf(unit),
5365
+ position: this.dropPositionFor(unit, input.clientY),
5366
+ targetElement: unit
5367
+ }),
5368
+ onDragEnter: ({ self }) => {
5369
+ const pos = self.data.position === "after" ? "after" : "before";
5370
+ this.showDropIndicator(unit, pos);
5371
+ },
5372
+ onDrag: ({ self }) => {
5373
+ const pos = self.data.position === "after" ? "after" : "before";
5374
+ this.showDropIndicator(unit, pos);
5375
+ },
5376
+ onDragLeave: () => this.hideDropIndicator()
5377
+ }));
5378
+ }
5379
+ }
5380
+ closeBlockMoveMenu(restoreFocus = false) {
5381
+ if (!this.blockMoveMenu || !this.blockDragHandle) return;
5382
+ this.blockMoveMenu.style.display = "none";
5383
+ this.blockDragHandle.setAttribute("aria-expanded", "false");
5384
+ this.blockDragHandle.setAttribute("aria-pressed", "false");
5385
+ if (restoreFocus) this.blockDragHandle.focus({ preventScroll: true });
5386
+ }
5387
+ openBlockMoveMenu() {
5388
+ const menu = this.blockMoveMenu;
5389
+ const handle = this.blockDragHandle;
5390
+ const source = this.currentBlockDragSource();
5391
+ if (!menu || !handle || !source) return;
5392
+ this.refreshBlockMoveTargets(source);
5393
+ menu.querySelectorAll("button[data-move]").forEach((button) => {
5394
+ button.disabled = !this.blockMoveDestination(source, button.dataset.move ?? "");
5395
+ });
5396
+ const rect = handle.getBoundingClientRect();
5397
+ menu.style.display = "block";
5398
+ menu.style.left = `${Math.max(4, rect.right + 6)}px`;
5399
+ menu.style.top = `${Math.max(4, rect.top)}px`;
5400
+ handle.setAttribute("aria-expanded", "true");
5401
+ handle.setAttribute("aria-pressed", "true");
5402
+ menu.querySelector("button:not(:disabled)")?.focus({ preventScroll: true });
5403
+ }
5404
+ /**
5405
+ * Resolve a move-menu action to the block it should land against, considering only destinations
5406
+ * the engine accepts. "Top"/"bottom" therefore mean the ends of the source's own movable region
5407
+ * — on a document with section breaks that is the section, not the document, which is what makes
5408
+ * the commands work at all there instead of always failing.
5409
+ */
5410
+ blockMoveDestination(source, action) {
5411
+ const units = this.bodyUnitNodes().filter((el) => this.isMovableBlockUnit(el));
5412
+ const index = units.indexOf(source);
5413
+ if (index < 0) return null;
5414
+ const position = action === "up" || action === "top" ? "before" : "after";
5415
+ const candidates = units.filter((el) => el !== source && this.isValidMoveTarget(el, position)).filter((el) => position === "before" ? units.indexOf(el) < index : units.indexOf(el) > index);
5416
+ if (candidates.length === 0) return null;
5417
+ if (action === "up") return { target: candidates[candidates.length - 1], position };
5418
+ if (action === "down") return { target: candidates[0], position };
5419
+ if (action === "top") return { target: candidates[0], position };
5420
+ if (action === "bottom") return { target: candidates[candidates.length - 1], position };
5421
+ return null;
5422
+ }
5423
+ runBlockMoveMenuAction(action) {
5424
+ const source = this.currentBlockDragSource();
5425
+ if (!source) return;
5426
+ const destination = this.blockMoveDestination(source, action);
5427
+ this.closeBlockMoveMenu();
5428
+ if (!destination) return;
5429
+ const sourceId = this.anchorIdOf(source);
5430
+ const targetId = this.anchorIdOf(destination.target);
5431
+ if (sourceId && targetId) this.moveBlock(sourceId, targetId, destination.position);
5432
+ }
5433
+ /** The nearest ancestor that actually scrolls the document flow, for drag autoscroll. */
5434
+ scrollContainer() {
5435
+ const view = this.container.ownerDocument.defaultView;
5436
+ for (let el = this.editRoot; el; el = el.parentElement) {
5437
+ const overflowY = view?.getComputedStyle(el).overflowY ?? "visible";
5438
+ if ((overflowY === "auto" || overflowY === "scroll") && el.scrollHeight > el.clientHeight)
5439
+ return el;
5440
+ }
5441
+ return null;
5442
+ }
5443
+ /** Mount one floating handle; PDD owns pointer dragging while the menu owns keyboard moves. */
5444
+ setupBlockDrag() {
5445
+ if (!this.options.blockDrag || this.options.paginated || this.closed || this.blockDragHandle)
5446
+ return;
5447
+ const doc = this.container.ownerDocument;
5448
+ ensureBlockDragStyles(doc);
5449
+ const handle = doc.createElement("div");
5450
+ handle.className = "docx-block-handle";
5451
+ handle.textContent = "\u283F";
5452
+ handle.tabIndex = 0;
5453
+ handle.setAttribute("role", "button");
5454
+ handle.setAttribute("contenteditable", "false");
5455
+ handle.setAttribute("aria-haspopup", "menu");
5456
+ handle.setAttribute("aria-expanded", "false");
5457
+ handle.setAttribute("aria-pressed", "false");
5458
+ const indicator = doc.createElement("div");
5459
+ indicator.className = "docx-block-drop-indicator";
5460
+ const menu = doc.createElement("div");
5461
+ menu.className = "docx-block-move-menu";
5462
+ menu.setAttribute("role", "menu");
5463
+ menu.innerHTML = `
5464
+ <button type="button" role="menuitem" data-move="up">Move up</button>
5465
+ <button type="button" role="menuitem" data-move="down">Move down</button>
5466
+ <button type="button" role="menuitem" data-move="top">Move to top</button>
5467
+ <button type="button" role="menuitem" data-move="bottom">Move to bottom</button>`;
5468
+ const live = doc.createElement("div");
5469
+ live.className = "docx-block-live-region";
5470
+ live.setAttribute("role", "status");
5471
+ live.setAttribute("aria-live", "polite");
5472
+ this.container.append(handle, indicator, menu, live);
5473
+ this.blockDragHandle = handle;
5474
+ this.blockDropIndicator = indicator;
5475
+ this.blockMoveMenu = menu;
5476
+ this.blockMoveLive = live;
5477
+ const onPointerMove = (event) => {
5478
+ if (this.blockDragging || this.blockDragPointerDown) return;
5479
+ const unit = this.blockUnitOf(event.target);
5480
+ if (this.isMovableBlockUnit(unit)) this.showBlockHandle(unit);
5481
+ };
5482
+ const onFocusIn = (event) => {
5483
+ const unit = this.blockUnitOf(event.target);
5484
+ if (this.isMovableBlockUnit(unit)) this.showBlockHandle(unit);
5485
+ };
5486
+ const onPointerLeave = (event) => {
5487
+ const next = event.relatedTarget instanceof Node ? event.relatedTarget : null;
5488
+ if (next && (handle.contains(next) || menu.contains(next))) return;
5489
+ this.hideBlockHandle();
5490
+ };
5491
+ const onViewportChange = () => this.positionBlockHandle();
5492
+ this.container.addEventListener("pointermove", onPointerMove);
5493
+ this.container.addEventListener("focusin", onFocusIn);
5494
+ this.container.addEventListener("pointerleave", onPointerLeave);
5495
+ doc.addEventListener("scroll", onViewportChange, true);
5496
+ doc.defaultView?.addEventListener("resize", onViewportChange);
5497
+ this.blockDragCleanup.push(
5498
+ () => this.container.removeEventListener("pointermove", onPointerMove),
5499
+ () => this.container.removeEventListener("focusin", onFocusIn),
5500
+ () => this.container.removeEventListener("pointerleave", onPointerLeave),
5501
+ () => doc.removeEventListener("scroll", onViewportChange, true),
5502
+ () => doc.defaultView?.removeEventListener("resize", onViewportChange)
5503
+ );
5504
+ const onHandleClick = () => {
5505
+ if (menu.style.display === "block") this.closeBlockMoveMenu();
5506
+ else this.openBlockMoveMenu();
5507
+ };
5508
+ const onHandlePointerDown = () => {
5509
+ this.blockDragPointerDown = true;
5510
+ };
5511
+ const onPointerUp = () => {
5512
+ this.blockDragPointerDown = false;
5513
+ };
5514
+ const onHandleKeydown = (event) => {
5515
+ if (event.key !== "Enter" && event.key !== " ") return;
5516
+ event.preventDefault();
5517
+ onHandleClick();
5518
+ };
5519
+ const onMenuClick = (event) => {
5520
+ const button = event.target?.closest("button[data-move]");
5521
+ if (button && !button.disabled) this.runBlockMoveMenuAction(button.dataset.move ?? "");
5522
+ };
5523
+ const onMenuKeydown = (event) => {
5524
+ if (event.key === "Escape") {
5525
+ event.preventDefault();
5526
+ this.closeBlockMoveMenu(true);
5527
+ }
5528
+ };
5529
+ handle.addEventListener("click", onHandleClick);
5530
+ handle.addEventListener("pointerdown", onHandlePointerDown);
5531
+ handle.addEventListener("keydown", onHandleKeydown);
5532
+ menu.addEventListener("click", onMenuClick);
5533
+ menu.addEventListener("keydown", onMenuKeydown);
5534
+ doc.addEventListener("pointerup", onPointerUp, true);
5535
+ doc.addEventListener("pointercancel", onPointerUp, true);
5536
+ this.blockDragCleanup.push(
5537
+ () => handle.removeEventListener("click", onHandleClick),
5538
+ () => handle.removeEventListener("pointerdown", onHandlePointerDown),
5539
+ () => handle.removeEventListener("keydown", onHandleKeydown),
5540
+ () => menu.removeEventListener("click", onMenuClick),
5541
+ () => menu.removeEventListener("keydown", onMenuKeydown),
5542
+ () => doc.removeEventListener("pointerup", onPointerUp, true),
5543
+ () => doc.removeEventListener("pointercancel", onPointerUp, true)
5544
+ );
5545
+ this.blockDragCleanup.push(draggable({
5546
+ element: handle,
5547
+ canDrag: () => !!this.currentBlockDragSource(),
5548
+ getInitialData: () => {
5549
+ const source = this.currentBlockDragSource();
5550
+ return { type: BLOCK_DRAG_TYPE, sourceAnchorId: source ? this.anchorIdOf(source) : void 0 };
5551
+ },
5552
+ onDragStart: () => {
5553
+ this.blockDragging = true;
5554
+ handle.classList.add("docx-block-dragging");
5555
+ this.closeBlockMoveMenu();
5556
+ this.refreshBlockMoveTargets(this.currentBlockDragSource());
5557
+ this.refreshBlockDropTargets();
5558
+ },
5559
+ onDrop: () => {
5560
+ this.blockDragging = false;
5561
+ this.blockDragPointerDown = false;
5562
+ handle.classList.remove("docx-block-dragging");
5563
+ this.hideDropIndicator();
5564
+ }
5565
+ }));
5566
+ this.blockDragCleanup.push(monitorForElements({
5567
+ canMonitor: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
5568
+ onDrop: ({ source, location: location2 }) => {
5569
+ this.hideDropIndicator();
5570
+ const drop = location2.current.dropTargets[0]?.data;
5571
+ const sourceId = source.data.sourceAnchorId;
5572
+ const targetId = drop?.targetAnchorId;
5573
+ const position = drop?.position === "after" ? "after" : "before";
5574
+ if (typeof sourceId === "string" && typeof targetId === "string")
5575
+ this.moveBlock(sourceId, targetId, position);
5576
+ else
5577
+ this.announceBlockMove("Move cancelled \u2014 the block was not dropped on a valid position.");
5578
+ }
5579
+ }));
5580
+ const scroller = this.scrollContainer();
5581
+ if (scroller) {
5582
+ this.blockDragCleanup.push(autoScrollForElements({
5583
+ element: scroller,
5584
+ canScroll: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
5585
+ getAllowedAxis: () => "vertical"
5586
+ }));
5587
+ }
5588
+ this.blockDragCleanup.push(autoScrollWindowForElements({
5589
+ canScroll: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
5590
+ getAllowedAxis: () => "vertical"
5591
+ }));
5592
+ this.refreshBlockDropTargets();
5593
+ }
5594
+ teardownBlockDrag() {
5595
+ for (const cleanup of this.blockDragTargetCleanup.splice(0)) cleanup();
5596
+ for (const cleanup of this.blockDragCleanup.splice(0)) cleanup();
5597
+ this.blockDragHandle?.remove();
5598
+ this.blockDropIndicator?.remove();
5599
+ this.blockMoveMenu?.remove();
5600
+ this.blockMoveLive?.remove();
5601
+ this.blockDragHandle = null;
5602
+ this.blockDropIndicator = null;
5603
+ this.blockMoveMenu = null;
5604
+ this.blockMoveLive = null;
5605
+ this.blockDragSource = null;
5606
+ this.blockDragging = false;
5607
+ this.blockDragPointerDown = false;
5608
+ }
2607
5609
  // ─── internals ───────────────────────────────────────────────────────
2608
5610
  assertOpen() {
2609
5611
  if (this.closed) throw new Error("DocxEditor is closed");
@@ -2725,6 +5727,10 @@ var DocxodusEditor = (() => {
2725
5727
  }
2726
5728
  wireBlock(el) {
2727
5729
  if (!EDITABLE_TAGS.has(el.tagName)) return;
5730
+ if (el.closest("tr[class$='row-del'], tr[class*='row-del ']") || el.querySelector(":scope > del[class$='move-from'], :scope > del[class*='move-from ']")) {
5731
+ el.setAttribute("contenteditable", "false");
5732
+ return;
5733
+ }
2728
5734
  const unid = el.getAttribute("data-anchor");
2729
5735
  if (!unid || !this.anchorIdOf(el)) return;
2730
5736
  el.setAttribute("contenteditable", "true");
@@ -2786,12 +5792,7 @@ var DocxodusEditor = (() => {
2786
5792
  this.options.onEdit?.({ anchorId: newAnchor, unid: newUnid });
2787
5793
  return;
2788
5794
  }
2789
- const html = this.exports.DocxSessionBridge.RenderBlockHtml(
2790
- this.handle,
2791
- newAnchor,
2792
- this.options.cssPrefix,
2793
- this.options.fabricateClasses
2794
- );
5795
+ const html = this.renderBlockHtml(newAnchor);
2795
5796
  if (html.charCodeAt(0) !== 123) {
2796
5797
  const fresh = new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
2797
5798
  const inBand = this.isBandBlock(el);
@@ -2832,9 +5833,10 @@ var DocxodusEditor = (() => {
2832
5833
  }
2833
5834
  }
2834
5835
  const inTableCell = !!el.closest("table");
2835
- if (ev.key === "Tab") {
5836
+ if (ev.key === "Tab" && !ev.ctrlKey && !ev.metaKey && !ev.altKey && !ev.isComposing) {
2836
5837
  if (inTableCell) {
2837
5838
  ev.preventDefault();
5839
+ this.navigateTableCell(el, ev.shiftKey);
2838
5840
  return;
2839
5841
  }
2840
5842
  if (isListBlock(el)) {
@@ -2863,6 +5865,42 @@ var DocxodusEditor = (() => {
2863
5865
  }
2864
5866
  }
2865
5867
  }
5868
+ /** Editable cells in visual document order, excluding cells from any nested table. */
5869
+ tableCellsFor(el) {
5870
+ const cell = el.closest("td, th");
5871
+ const table = cell?.closest("table");
5872
+ if (!cell || !table) return null;
5873
+ const cells = Array.from(table.querySelectorAll("td, th")).filter((candidate) => candidate.closest("table") === table);
5874
+ const index = cells.indexOf(cell);
5875
+ return index >= 0 ? { cells, index } : null;
5876
+ }
5877
+ /** First addressable paragraph in a cell, fenced against nested-table descendants. */
5878
+ editableInCell(cell) {
5879
+ return Array.from(
5880
+ cell.querySelectorAll('[data-anchor][contenteditable="true"]')
5881
+ ).find((block) => block.closest("td, th") === cell) ?? null;
5882
+ }
5883
+ /** Word-style cell navigation: Shift+Tab goes back, Tab goes forward, and Tab at the
5884
+ * final cell appends a row before entering its first cell. The first cell is a hard
5885
+ * boundary for Shift+Tab so focus never leaks out of the editor table. */
5886
+ navigateTableCell(el, backwards) {
5887
+ const state = this.tableCellsFor(el);
5888
+ if (!state) return;
5889
+ const adjacent = state.cells[state.index + (backwards ? -1 : 1)];
5890
+ if (adjacent) {
5891
+ const target2 = this.editableInCell(adjacent);
5892
+ if (target2) placeCaretAtOffset(target2, 0);
5893
+ return;
5894
+ }
5895
+ if (backwards) return;
5896
+ this.activeBlock = el;
5897
+ this.insertTableRow("below");
5898
+ const fresh = this.activeBlock ? this.tableCellsFor(this.activeBlock) : null;
5899
+ if (!fresh) return;
5900
+ const target = fresh.cells[fresh.index + 1];
5901
+ const block = target ? this.editableInCell(target) : null;
5902
+ if (block) placeCaretAtOffset(block, 0);
5903
+ }
2866
5904
  /** Shift+Enter: insert an intra-paragraph line break at the caret. Delegates to the
2867
5905
  * native `insertLineBreak` command, which inserts a <br> AND positions the caret
2868
5906
  * after it correctly (handling the browser's bogus trailing-<br> rule) so typing
@@ -2972,21 +6010,21 @@ var DocxodusEditor = (() => {
2972
6010
  while (p < minLen && old[p] === next[p]) p++;
2973
6011
  let s = 0;
2974
6012
  while (s < minLen - p && old[old.length - 1 - s] === next[next.length - 1 - s]) s++;
2975
- let start = p;
6013
+ let start2 = p;
2976
6014
  let len = old.length - p - s;
2977
6015
  let middle = next.slice(p, next.length - s);
2978
6016
  if (len === 0) {
2979
- if (start > 0) {
2980
- start -= 1;
6017
+ if (start2 > 0) {
6018
+ start2 -= 1;
2981
6019
  len = 1;
2982
- middle = old[start] + middle;
6020
+ middle = old[start2] + middle;
2983
6021
  } else {
2984
6022
  len = 1;
2985
6023
  middle = middle + old[0];
2986
6024
  }
2987
6025
  }
2988
6026
  return this.parseEdit(
2989
- this.exports.DocxSessionBridge.ReplaceTextAtSpan(this.handle, fullId, start, len, middle)
6027
+ this.exports.DocxSessionBridge.ReplaceTextAtSpan(this.handle, fullId, start2, len, middle)
2990
6028
  );
2991
6029
  }
2992
6030
  /** Flush a block's current (uncommitted) text to the session; returns the live full id. */
@@ -2998,14 +6036,34 @@ var DocxodusEditor = (() => {
2998
6036
  }
2999
6037
  /** Render a block by anchor and parse it into a detached element (null on error). */
3000
6038
  renderInto(anchorId) {
3001
- const html = this.exports.DocxSessionBridge.RenderBlockHtml(
6039
+ const html = this.renderBlockHtml(anchorId);
6040
+ if (html.charCodeAt(0) === 123) return null;
6041
+ return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
6042
+ }
6043
+ get renderTrackedChanges() {
6044
+ return this.options.trackedChanges === 1 /* RenderInline */;
6045
+ }
6046
+ renderBlockHtml(anchorId) {
6047
+ const bridge = this.exports.DocxSessionBridge;
6048
+ if (typeof bridge.RenderBlockHtmlForReview === "function") {
6049
+ return bridge.RenderBlockHtmlForReview(
6050
+ this.handle,
6051
+ anchorId,
6052
+ this.options.cssPrefix,
6053
+ this.options.fabricateClasses,
6054
+ this.renderTrackedChanges
6055
+ );
6056
+ }
6057
+ return bridge.RenderBlockHtml(
3002
6058
  this.handle,
3003
6059
  anchorId,
3004
6060
  this.options.cssPrefix,
3005
6061
  this.options.fabricateClasses
3006
6062
  );
3007
- if (html.charCodeAt(0) === 123) return null;
3008
- return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
6063
+ }
6064
+ renderPlanJson() {
6065
+ const bridge = this.exports.DocxSessionBridge;
6066
+ return typeof bridge.ListRenderedBlocks === "function" ? bridge.ListRenderedBlocks(this.handle, this.renderTrackedChanges) : bridge.ListBlocks(this.handle);
3009
6067
  }
3010
6068
  /** Render two blocks in ONE batched bridge call when the bundle carries RenderBlocksHtml —
3011
6069
  * the per-render shell/converter setup is paid once instead of twice, which matters on the
@@ -3016,14 +6074,20 @@ var DocxodusEditor = (() => {
3016
6074
  const bridge = this.exports.DocxSessionBridge;
3017
6075
  if (typeof bridge.RenderBlocksHtml === "function") {
3018
6076
  try {
3019
- const map = JSON.parse(
3020
- bridge.RenderBlocksHtml(
3021
- this.handle,
3022
- JSON.stringify([a, b]),
3023
- this.options.cssPrefix,
3024
- this.options.fabricateClasses
3025
- )
6077
+ const idsJson = JSON.stringify([a, b]);
6078
+ const json = typeof bridge.RenderBlocksHtmlForReview === "function" ? bridge.RenderBlocksHtmlForReview(
6079
+ this.handle,
6080
+ idsJson,
6081
+ this.options.cssPrefix,
6082
+ this.options.fabricateClasses,
6083
+ this.renderTrackedChanges
6084
+ ) : bridge.RenderBlocksHtml(
6085
+ this.handle,
6086
+ idsJson,
6087
+ this.options.cssPrefix,
6088
+ this.options.fabricateClasses
3026
6089
  );
6090
+ const map = JSON.parse(json);
3027
6091
  if (!map.error) {
3028
6092
  const parse = (h) => h ? new DOMParser().parseFromString(h, "text/html").body.firstElementChild : null;
3029
6093
  const fa = parse(map[a]);
@@ -3066,9 +6130,9 @@ var DocxodusEditor = (() => {
3066
6130
  const first = all.find((block) => block.getAttribute("data-anchor") === bookmark.startUnid);
3067
6131
  const last = all.find((block) => block.getAttribute("data-anchor") === bookmark.endUnid);
3068
6132
  if (!first || !last || first === last || all.indexOf(first) > all.indexOf(last)) return false;
3069
- const start = contentPositionIn(first, bookmark.startOffset);
6133
+ const start2 = contentPositionIn(first, bookmark.startOffset);
3070
6134
  const end = contentPositionIn(last, bookmark.endOffset);
3071
- return setSelectionBetween(start, end);
6135
+ return setSelectionBetween(start2, end);
3072
6136
  }
3073
6137
  /** Editable blocks the current selection covers, in document order. Uses Range.comparePoint
3074
6138
  * (robust to a selection boundary that normalized onto a wrapper element rather than a block
@@ -3111,8 +6175,8 @@ var DocxodusEditor = (() => {
3111
6175
  if (hasStart && hasEnd) return selectionSpanIn(block);
3112
6176
  const contentLen = blockContentText(block).length;
3113
6177
  if (hasStart) {
3114
- const start = contentOffsetOf(block, range.startContainer, range.startOffset);
3115
- return trimmedSpan(block, { start, length: Math.max(0, contentLen - start) });
6178
+ const start2 = contentOffsetOf(block, range.startContainer, range.startOffset);
6179
+ return trimmedSpan(block, { start: start2, length: Math.max(0, contentLen - start2) });
3116
6180
  }
3117
6181
  if (hasEnd) {
3118
6182
  const end = contentOffsetOf(block, range.endContainer, range.endOffset);
@@ -3707,6 +6771,17 @@ var DocxodusEditor = (() => {
3707
6771
  */
3708
6772
  renderFullHtml() {
3709
6773
  const bridge = this.exports.DocxSessionBridge;
6774
+ if (typeof bridge.RenderHtmlForReview === "function") {
6775
+ const html = bridge.RenderHtmlForReview(
6776
+ this.handle,
6777
+ this.options.cssPrefix,
6778
+ this.options.fabricateClasses,
6779
+ this.options.paginated,
6780
+ this.options.scale,
6781
+ this.renderTrackedChanges
6782
+ );
6783
+ if (html.charCodeAt(0) !== 123) return html;
6784
+ }
3710
6785
  if (typeof bridge.RenderHtml === "function") {
3711
6786
  const html = bridge.RenderHtml(
3712
6787
  this.handle,
@@ -3719,7 +6794,14 @@ var DocxodusEditor = (() => {
3719
6794
  }
3720
6795
  const bytes = typeof bridge.SaveWithAnchorIds === "function" ? bridge.SaveWithAnchorIds(this.handle) : bridge.Save(this.handle);
3721
6796
  return this.exports.DocumentConverter.ConvertDocxToHtmlComplete(
3722
- ...completeArgs(bytes, this.options.cssPrefix, this.options.fabricateClasses, this.options.paginated, this.options.scale)
6797
+ ...completeArgs(
6798
+ bytes,
6799
+ this.options.cssPrefix,
6800
+ this.options.fabricateClasses,
6801
+ this.options.paginated,
6802
+ this.options.scale,
6803
+ this.renderTrackedChanges
6804
+ )
3723
6805
  );
3724
6806
  }
3725
6807
  /** Editable BODY blocks in document order (band blocks are enumerated by `ownerRoot`). */
@@ -3813,7 +6895,7 @@ var DocxodusEditor = (() => {
3813
6895
  reconcileCore() {
3814
6896
  const bridge = this.exports.DocxSessionBridge;
3815
6897
  this.refreshAnchorMap();
3816
- const plan = JSON.parse(bridge.ListBlocks(this.handle));
6898
+ const plan = JSON.parse(this.renderPlanJson());
3817
6899
  if (plan.error) return this.bail(`plan error: ${plan.error}`);
3818
6900
  const oldNodes = this.bodyUnitNodes();
3819
6901
  const oldTokens = oldNodes.map(_DocxEditor.domTokenOf);
@@ -3823,19 +6905,26 @@ var DocxodusEditor = (() => {
3823
6905
  const fnState = this.notesDiff("footnotes", plan.footnotes);
3824
6906
  const enState = this.notesDiff("endnotes", plan.endnotes);
3825
6907
  if (fnState === null || enState === null) return this.bail("notes container unstampable/missing");
3826
- const addedBodyIds = bodyDiff.added.map((j) => plan.body[j].id);
6908
+ const movedBodyNew = new Set(bodyDiff.moved.map((m) => m.newIndex));
6909
+ const addedBodyIds = bodyDiff.added.filter((j) => !movedBodyNew.has(j)).map((j) => plan.body[j].id);
3827
6910
  const addedNoteIds = fnState.diff.added.map((j) => plan.footnotes[j].id).concat(enState.diff.added.map((j) => plan.endnotes[j].id));
3828
6911
  const allIds = addedBodyIds.concat(addedNoteIds);
3829
6912
  let rendered = {};
3830
6913
  if (allIds.length > 0) {
3831
- rendered = JSON.parse(
3832
- bridge.RenderBlocksHtml(
3833
- this.handle,
3834
- JSON.stringify(allIds),
3835
- this.options.cssPrefix,
3836
- this.options.fabricateClasses
3837
- )
6914
+ const idsJson = JSON.stringify(allIds);
6915
+ const renderedJson = typeof bridge.RenderBlocksHtmlForReview === "function" ? bridge.RenderBlocksHtmlForReview(
6916
+ this.handle,
6917
+ idsJson,
6918
+ this.options.cssPrefix,
6919
+ this.options.fabricateClasses,
6920
+ this.renderTrackedChanges
6921
+ ) : bridge.RenderBlocksHtml(
6922
+ this.handle,
6923
+ idsJson,
6924
+ this.options.cssPrefix,
6925
+ this.options.fabricateClasses
3838
6926
  );
6927
+ rendered = JSON.parse(renderedJson);
3839
6928
  if (rendered.error) return this.bail(`render error: ${rendered.error}`);
3840
6929
  for (const id of allIds) if (!rendered[id]) return this.bail(`unrenderable: ${id}`);
3841
6930
  }
@@ -3845,7 +6934,7 @@ var DocxodusEditor = (() => {
3845
6934
  return el;
3846
6935
  };
3847
6936
  const freshBody = /* @__PURE__ */ new Map();
3848
- for (const j of bodyDiff.added) {
6937
+ for (const j of bodyDiff.added.filter((j2) => !movedBodyNew.has(j2))) {
3849
6938
  const el = parse(rendered[plan.body[j].id]);
3850
6939
  if (!el) return this.bail(`unparseable render: ${plan.body[j].id}`);
3851
6940
  freshBody.set(j, el);
@@ -3895,13 +6984,6 @@ var DocxodusEditor = (() => {
3895
6984
  * bail-reason string (parent ambiguity, order violation, wrapper semantics) — the
3896
6985
  * session is already correct, so bailing just means a full repaint. */
3897
6986
  applyBodyDiff(oldNodes, units, diff, fresh) {
3898
- let lastOld = -1;
3899
- for (let j = 0; j < units.length; j++) {
3900
- const oi = diff.keep.get(j);
3901
- if (oi === void 0) continue;
3902
- if (oi < lastOld) return "kept order violation";
3903
- lastOld = oi;
3904
- }
3905
6987
  const subOldByNew = new Map(diff.substituted.map((s) => [s.newIndex, s.oldIndex]));
3906
6988
  for (const [nj, oi] of subOldByNew) {
3907
6989
  const freshRoot = fresh.get(nj);
@@ -3917,13 +6999,18 @@ var DocxodusEditor = (() => {
3917
6999
  }
3918
7000
  this.wireUnit(freshRoot, units[nj]);
3919
7001
  }
3920
- const pureAdded = diff.added.filter((j) => !subOldByNew.has(j));
7002
+ const movedOldByNew = new Map(diff.moved.map((m) => [m.newIndex, m.oldIndex]));
7003
+ const movedNew = new Set(diff.moved.map((m) => m.newIndex));
7004
+ const movedOld = new Set(diff.moved.map((m) => m.oldIndex));
7005
+ const pureAdded = diff.added.filter((j) => !subOldByNew.has(j) && !movedNew.has(j));
3921
7006
  const pureRemoved = diff.removed.filter(
3922
- (i) => !diff.substituted.some((s) => s.oldIndex === i)
7007
+ (i) => !diff.substituted.some((s) => s.oldIndex === i) && !movedOld.has(i)
3923
7008
  );
3924
7009
  const nodeAt = (j) => {
3925
7010
  const oi = diff.keep.get(j);
3926
7011
  if (oi !== void 0) return oldNodes[oi];
7012
+ const movedOi = movedOldByNew.get(j);
7013
+ if (movedOi !== void 0) return oldNodes[movedOi];
3927
7014
  if (subOldByNew.has(j)) return fresh.get(j);
3928
7015
  const f = fresh.get(j);
3929
7016
  return f && f.isConnected ? f : null;
@@ -3933,11 +7020,7 @@ var DocxodusEditor = (() => {
3933
7020
  let prev = null;
3934
7021
  for (let k = j - 1; k >= 0 && !prev; k--) prev = nodeAt(k);
3935
7022
  let next = null;
3936
- for (let k = j + 1; k < units.length && !next; k++) {
3937
- const oi = diff.keep.get(k);
3938
- if (oi !== void 0) next = oldNodes[oi];
3939
- else if (subOldByNew.has(k)) next = fresh.get(k);
3940
- }
7023
+ for (let k = j + 1; k < units.length && !next; k++) next = nodeAt(k);
3941
7024
  const prevW = prev ? this.unitWrapperOf(prev) : null;
3942
7025
  const nextW = next ? this.unitWrapperOf(next) : null;
3943
7026
  if (prevW && nextW && prevW.parentElement !== nextW.parentElement)
@@ -3948,8 +7031,29 @@ var DocxodusEditor = (() => {
3948
7031
  this.wireUnit(el, units[j]);
3949
7032
  }
3950
7033
  for (const i of pureRemoved) {
3951
- const wrapper = this.unitWrapperOf(oldNodes[i]);
3952
- wrapper.remove();
7034
+ this.unitWrapperOf(oldNodes[i]).remove();
7035
+ }
7036
+ for (const { newIndex } of [...diff.moved].sort((a, b) => a.newIndex - b.newIndex)) {
7037
+ const moving = nodeAt(newIndex);
7038
+ if (!moving?.isConnected) return "move source is not connected";
7039
+ const movingW = this.unitWrapperOf(moving);
7040
+ let prevW = null;
7041
+ for (let k = newIndex - 1; k >= 0 && !prevW; k--) {
7042
+ const n = nodeAt(k);
7043
+ if (n?.isConnected) prevW = this.unitWrapperOf(n);
7044
+ }
7045
+ let nextW = null;
7046
+ for (let k = newIndex + 1; k < units.length && !nextW; k++) {
7047
+ const n = nodeAt(k);
7048
+ if (n?.isConnected) nextW = this.unitWrapperOf(n);
7049
+ }
7050
+ if (prevW && prevW !== movingW && prevW.parentElement === movingW.parentElement) {
7051
+ prevW.after(movingW);
7052
+ } else if (nextW && nextW !== movingW && nextW.parentElement === movingW.parentElement) {
7053
+ nextW.before(movingW);
7054
+ } else {
7055
+ return "move neighbors in different parents";
7056
+ }
3953
7057
  }
3954
7058
  return true;
3955
7059
  }
@@ -4073,7 +7177,7 @@ var DocxodusEditor = (() => {
4073
7177
  const bridge = this.exports.DocxSessionBridge;
4074
7178
  if (typeof bridge.ListBlocks !== "function") return;
4075
7179
  try {
4076
- const plan = JSON.parse(bridge.ListBlocks(this.handle));
7180
+ const plan = JSON.parse(this.renderPlanJson());
4077
7181
  if (plan.error) return;
4078
7182
  const nodes = this.bodyUnitNodes();
4079
7183
  if (nodes.length === plan.body.length) {
@@ -4102,6 +7206,7 @@ var DocxodusEditor = (() => {
4102
7206
  * block's content-hashed unid changes across the save/reproject a remount performs.
4103
7207
  */
4104
7208
  remount(focusIndex = -1, caretAtEnd = false) {
7209
+ this.teardownBlockDrag();
4105
7210
  this.refreshAnchorMap();
4106
7211
  const fullHtml = this.renderFullHtml();
4107
7212
  this.activeBlock = null;
@@ -4116,6 +7221,7 @@ var DocxodusEditor = (() => {
4116
7221
  }
4117
7222
  }
4118
7223
  this.syncRegionToBody(this.activeBlock ?? void 0);
7224
+ this.setupBlockDrag();
4119
7225
  }
4120
7226
  };
4121
7227
 
@@ -5324,8 +8430,12 @@ var DocxodusEditor = (() => {
5324
8430
  editable: this.options.editable,
5325
8431
  scale: this.options.scale,
5326
8432
  onEdit: this.options.onEdit,
8433
+ onMove: this.options.onMove,
5327
8434
  paginated,
5328
- headerFooter: this.headerFooter
8435
+ headerFooter: this.headerFooter,
8436
+ blockDrag: this.options.blockDrag ?? true,
8437
+ trackedChanges: this.options.trackedChanges,
8438
+ revisionAuthor: this.options.revisionAuthor
5329
8439
  });
5330
8440
  this.require("save").disabled = false;
5331
8441
  this.require("ribbon").setAttribute("aria-disabled", "false");
@@ -5413,8 +8523,8 @@ var DocxodusEditor = (() => {
5413
8523
  this.keepSelection(tab);
5414
8524
  tab.addEventListener("click", () => this.selectTab(tab.dataset.tab ?? "home"));
5415
8525
  }
5416
- const delegate = (selector, label, fn) => {
5417
- for (const el of Array.from(ribbon.querySelectorAll(selector))) {
8526
+ const delegate = (selector2, label, fn) => {
8527
+ for (const el of Array.from(ribbon.querySelectorAll(selector2))) {
5418
8528
  this.keepSelection(el);
5419
8529
  el.addEventListener("click", () => this.run(label(el), () => fn(el)));
5420
8530
  }