@univerjs/drawing 0.1.15 → 0.1.16

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.
package/lib/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var Dt = Object.defineProperty;
2
2
  var Ut = (t, e, n) => e in t ? Dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var q = (t, e, n) => (Ut(t, typeof e != "symbol" ? e + "" : e, n), n);
3
+ var V = (t, e, n) => Ut(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  import { Subject as we } from "rxjs";
5
5
  import { sortRules as Mt, sortRulesByDesc as Nt, Tools as kt, Plugin as Rt, mergeOverrideWithDependencies as St } from "@univerjs/core";
6
6
  import { createIdentifier as It, Inject as jt, Injector as Tt } from "@wendellhu/redi";
@@ -279,9 +279,9 @@ var ht = {};
279
279
  e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
280
280
  }(t.ConflictType || (t.ConflictType = {}));
281
281
  })(ht);
282
- var it = {}, Ve = {}, vt;
282
+ var it = {}, Fe = {}, vt;
283
283
  function pt() {
284
- return vt || (vt = 1, Object.defineProperty(Ve, "__esModule", { value: !0 }), Ve.uniToStrPos = Ve.strPosToUni = void 0, Ve.strPosToUni = (t, e = t.length) => {
284
+ return vt || (vt = 1, Object.defineProperty(Fe, "__esModule", { value: !0 }), Fe.uniToStrPos = Fe.strPosToUni = void 0, Fe.strPosToUni = (t, e = t.length) => {
285
285
  let n = 0, s = 0;
286
286
  for (; s < e; s++) {
287
287
  const i = t.charCodeAt(s);
@@ -290,14 +290,14 @@ function pt() {
290
290
  if (s !== e)
291
291
  throw Error("Invalid offset - splits unicode bytes");
292
292
  return s - n;
293
- }, Ve.uniToStrPos = (t, e) => {
293
+ }, Fe.uniToStrPos = (t, e) => {
294
294
  let n = 0;
295
295
  for (; e > 0; e--) {
296
296
  const s = t.charCodeAt(n);
297
297
  n += s >= 55296 && s <= 57343 ? 2 : 1;
298
298
  }
299
299
  return n;
300
- }), Ve;
300
+ }), Fe;
301
301
  }
302
302
  var st = {}, yt;
303
303
  function at() {
@@ -359,17 +359,16 @@ function at() {
359
359
  const d = (f) => f, l = (f) => i(f, d);
360
360
  t.dlen = (f) => typeof f == "number" ? f : e.strPosToUni(f);
361
361
  const a = (f) => (_) => {
362
- if (!(!_ || _.d === 0 || _.d === ""))
363
- if (f.length === 0)
364
- f.push(_);
365
- else if (typeof _ == typeof f[f.length - 1])
366
- if (typeof _ == "object") {
367
- const w = f[f.length - 1];
368
- w.d = typeof w.d == "string" && typeof _.d == "string" ? w.d + _.d : t.dlen(w.d) + t.dlen(_.d);
369
- } else
370
- f[f.length - 1] += _;
371
- else
372
- f.push(_);
362
+ if (!(!_ || _.d === 0 || _.d === "")) if (f.length === 0)
363
+ f.push(_);
364
+ else if (typeof _ == typeof f[f.length - 1])
365
+ if (typeof _ == "object") {
366
+ const w = f[f.length - 1];
367
+ w.d = typeof w.d == "string" && typeof _.d == "string" ? w.d + _.d : t.dlen(w.d) + t.dlen(_.d);
368
+ } else
369
+ f[f.length - 1] += _;
370
+ else
371
+ f.push(_);
373
372
  }, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d);
374
373
  t.uniSlice = (f, _, w) => {
375
374
  const L = e.uniToStrPos(f, _), X = w == null ? 1 / 0 : e.uniToStrPos(f, w);
@@ -576,11 +575,10 @@ function at() {
576
575
  t.default = ve;
577
576
  }(st)), st;
578
577
  }
579
- var Qe = {}, mt;
578
+ var Qe = {}, bt;
580
579
  function xt() {
581
- if (mt)
582
- return Qe;
583
- mt = 1, Object.defineProperty(Qe, "__esModule", { value: !0 });
580
+ if (bt) return Qe;
581
+ bt = 1, Object.defineProperty(Qe, "__esModule", { value: !0 });
584
582
  const t = at(), e = pt();
585
583
  function n(s, i) {
586
584
  return {
@@ -621,9 +619,9 @@ function xt() {
621
619
  }
622
620
  return Qe.default = n, n.provides = { text: !0 }, Qe;
623
621
  }
624
- var bt;
622
+ var mt;
625
623
  function Lt() {
626
- return bt || (bt = 1, function(t) {
624
+ return mt || (mt = 1, function(t) {
627
625
  var e = Ce && Ce.__createBinding || (Object.create ? function(c, h, R, Z) {
628
626
  Z === void 0 && (Z = R), Object.defineProperty(c, Z, { enumerable: !0, get: function() {
629
627
  return h[R];
@@ -635,12 +633,9 @@ function Lt() {
635
633
  } : function(c, h) {
636
634
  c.default = h;
637
635
  }), s = Ce && Ce.__importStar || function(c) {
638
- if (c && c.__esModule)
639
- return c;
636
+ if (c && c.__esModule) return c;
640
637
  var h = {};
641
- if (c != null)
642
- for (var R in c)
643
- Object.hasOwnProperty.call(c, R) && e(h, c, R);
638
+ if (c != null) for (var R in c) Object.hasOwnProperty.call(c, R) && e(h, c, R);
644
639
  return n(h, c), h;
645
640
  }, i = Ce && Ce.__importDefault || function(c) {
646
641
  return c && c.__esModule ? c : { default: c };
@@ -695,8 +690,7 @@ function Lt() {
695
690
  }), t.editOp = t.replaceOp = t.insertOp = t.moveOp = t.removeOp = t.type = void 0;
696
691
  const n = e(ct), s = e(dt), i = ft, d = ht;
697
692
  function l(r, u) {
698
- if (!r)
699
- throw new Error(u);
693
+ if (!r) throw new Error(u);
700
694
  }
701
695
  t.type = {
702
696
  name: "json1",
@@ -739,7 +733,7 @@ function Lt() {
739
733
  }
740
734
  t.removeOp = (r, u = !0) => i.writeCursor().writeAtPath(r, "r", u).get(), t.moveOp = (r, u) => i.writeCursor().writeMove(r, u).get(), t.insertOp = (r, u) => i.writeCursor().writeAtPath(r, "i", u).get(), t.replaceOp = (r, u, y) => i.writeCursor().at(r, (A) => {
741
735
  A.write("r", u), A.write("i", y);
742
- }).get(), t.editOp = (r, u, y, A = !1) => i.writeCursor().at(r, (m) => _(m, u, y, A)).get();
736
+ }).get(), t.editOp = (r, u, y, A = !1) => i.writeCursor().at(r, (b) => _(b, u, y, A)).get();
743
737
  const R = (r, u) => r != null && (typeof u == "number" ? Array.isArray(r) : typeof r == "object"), Z = (r, u) => R(r, u) ? r[u] : void 0, pe = {};
744
738
  function J(r) {
745
739
  let u = r.type ? r.type : r;
@@ -747,8 +741,7 @@ function Lt() {
747
741
  }
748
742
  const Ie = (r) => {
749
743
  const u = pe[r];
750
- if (u)
751
- return u;
744
+ if (u) return u;
752
745
  throw Error("Missing type: " + r);
753
746
  };
754
747
  J(Lt());
@@ -761,8 +754,8 @@ function Lt() {
761
754
  transform: (r) => r
762
755
  });
763
756
  const ve = (r) => r == null ? null : r.et ? Ie(r.et) : r.es ? pe["text-unicode"] : r.ena != null ? pe.number : null, f = (r) => r.es ? r.es : r.ena != null ? r.ena : r.e, _ = (r, u, y, A = !1) => {
764
- const [m, C] = typeof u == "string" ? [Ie(u), u] : [u, u.name];
765
- !A && m.isNoop && m.isNoop(y) || (C === "number" ? r.write("ena", y) : C === "text-unicode" ? r.write("es", y) : (r.write("et", C), r.write("e", y)));
757
+ const [b, C] = typeof u == "string" ? [Ie(u), u] : [u, u.name];
758
+ !A && b.isNoop && b.isNoop(y) || (C === "number" ? r.write("ena", y) : C === "text-unicode" ? r.write("es", y) : (r.write("et", C), r.write("e", y)));
766
759
  };
767
760
  function w(r) {
768
761
  l(typeof r == "number"), l(r >= 0), l(r === (0 | r));
@@ -771,148 +764,130 @@ function Lt() {
771
764
  typeof r == "number" ? w(r) : l(typeof r == "string");
772
765
  }
773
766
  function X(r) {
774
- if (r === null)
775
- return;
767
+ if (r === null) return;
776
768
  const u = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), A = (C) => {
777
769
  let $ = !0, j = !1;
778
770
  for (let p in C) {
779
771
  const v = C[p];
780
- if ($ = !1, l(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p")
781
- w(v), l(!u.has(v)), u.add(v), l(C.r === void 0);
782
- else if (p === "d")
783
- w(v), l(!y.has(v)), y.add(v), l(C.i === void 0);
772
+ if ($ = !1, l(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") w(v), l(!u.has(v)), u.add(v), l(C.r === void 0);
773
+ else if (p === "d") w(v), l(!y.has(v)), y.add(v), l(C.i === void 0);
784
774
  else if (p === "e" || p === "es" || p === "ena") {
785
775
  l(!j), j = !0;
786
- const b = ve(C);
787
- l(b, "Missing type in edit"), b.checkValidOp && b.checkValidOp(f(C));
776
+ const m = ve(C);
777
+ l(m, "Missing type in edit"), m.checkValidOp && m.checkValidOp(f(C));
788
778
  }
789
779
  }
790
780
  l(!$);
791
- }, m = (C, $, j) => {
792
- if (!Array.isArray(C))
793
- throw Error("Op must be null or a list");
794
- if (C.length === 0)
795
- throw Error("Empty descent");
781
+ }, b = (C, $, j) => {
782
+ if (!Array.isArray(C)) throw Error("Op must be null or a list");
783
+ if (C.length === 0) throw Error("Empty descent");
796
784
  $ || L(C[0]);
797
- let p = 1, v = 0, b = 0;
785
+ let p = 1, v = 0, m = 0;
798
786
  for (let I = 0; I < C.length; I++) {
799
787
  const T = C[I];
800
788
  if (l(T != null), Array.isArray(T)) {
801
- const G = m(T, !1);
789
+ const G = b(T, !1);
802
790
  if (v) {
803
- const g = typeof b, N = typeof G;
804
- g === N ? l(b < G, "descent keys are not in order") : l(g === "number" && N === "string");
791
+ const g = typeof m, N = typeof G;
792
+ g === N ? l(m < G, "descent keys are not in order") : l(g === "number" && N === "string");
805
793
  }
806
- b = G, v++, p = 3;
807
- } else
808
- typeof T == "object" ? (l(p === 1, `Prev not scalar - instead ${p}`), A(T), p = 2) : (l(p !== 3), L(T), l(i.isValidPathItem(T), "Invalid path key"), p = 1);
794
+ m = G, v++, p = 3;
795
+ } else typeof T == "object" ? (l(p === 1, `Prev not scalar - instead ${p}`), A(T), p = 2) : (l(p !== 3), L(T), l(i.isValidPathItem(T), "Invalid path key"), p = 1);
809
796
  }
810
797
  return l(v !== 1, "Operation makes multiple descents. Remove some []"), l(p === 2 || p === 3), C[0];
811
798
  };
812
- m(r, !0), l(u.size === y.size, "Mismatched picks and drops in op");
813
- for (let C = 0; C < u.size; C++)
814
- l(u.has(C)), l(y.has(C));
799
+ b(r, !0), l(u.size === y.size, "Mismatched picks and drops in op");
800
+ for (let C = 0; C < u.size; C++) l(u.has(C)), l(y.has(C));
815
801
  }
816
802
  function H(r) {
817
803
  let u = 0, y = [];
818
804
  const A = i.writeCursor();
819
- return A.mergeTree(r, (m, C) => {
820
- const $ = ve(m);
805
+ return A.mergeTree(r, (b, C) => {
806
+ const $ = ve(b);
821
807
  if ($) {
822
- const p = f(m);
808
+ const p = f(b);
823
809
  _(C, $, $.normalize ? $.normalize(p) : p);
824
810
  }
825
- for (const p of ["r", "p", "i", "d"])
826
- if (m[p] !== void 0) {
827
- const v = p === "p" || p === "d" ? (j = m[p], y[j] == null && (y[j] = u++), y[j]) : m[p];
828
- C.write(p, v);
829
- }
811
+ for (const p of ["r", "p", "i", "d"]) if (b[p] !== void 0) {
812
+ const v = p === "p" || p === "d" ? (j = b[p], y[j] == null && (y[j] = u++), y[j]) : b[p];
813
+ C.write(p, v);
814
+ }
830
815
  var j;
831
816
  }), A.get();
832
817
  }
833
818
  function Ae(r, u) {
834
- if (X(u), u === null)
835
- return r;
819
+ if (X(u), u === null) return r;
836
820
  const y = [];
837
- return function A(m, C) {
838
- let $ = m, j = 0, p = {
839
- root: m
840
- }, v = 0, b = p, I = "root";
821
+ return function A(b, C) {
822
+ let $ = b, j = 0, p = {
823
+ root: b
824
+ }, v = 0, m = p, I = "root";
841
825
  function T() {
842
826
  for (; v < j; v++) {
843
827
  let G = C[v];
844
- typeof G != "object" && (l(R(b, I)), b = b[I] = W(b[I]), I = G);
828
+ typeof G != "object" && (l(R(m, I)), m = m[I] = W(m[I]), I = G);
845
829
  }
846
830
  }
847
831
  for (; j < C.length; j++) {
848
832
  const G = C[j];
849
833
  if (Array.isArray(G)) {
850
834
  const g = A($, G);
851
- g !== $ && g !== void 0 && (T(), $ = b[I] = g);
835
+ g !== $ && g !== void 0 && (T(), $ = m[I] = g);
852
836
  } else if (typeof G == "object") {
853
- G.d != null ? (T(), $ = h(b, I, y[G.d])) : G.i !== void 0 && (T(), $ = h(b, I, G.i));
837
+ G.d != null ? (T(), $ = h(m, I, y[G.d])) : G.i !== void 0 && (T(), $ = h(m, I, G.i));
854
838
  const g = ve(G);
855
- if (g)
856
- T(), $ = b[I] = g.apply($, f(G));
857
- else if (G.e !== void 0)
858
- throw Error("Subtype " + G.et + " undefined");
859
- } else
860
- $ = Z($, G);
839
+ if (g) T(), $ = m[I] = g.apply($, f(G));
840
+ else if (G.e !== void 0) throw Error("Subtype " + G.et + " undefined");
841
+ } else $ = Z($, G);
861
842
  }
862
843
  return p.root;
863
- }(r = function A(m, C) {
844
+ }(r = function A(b, C) {
864
845
  const $ = [];
865
846
  let j = 0;
866
847
  for (; j < C.length; j++) {
867
848
  const I = C[j];
868
- if (Array.isArray(I))
869
- break;
870
- typeof I != "object" && ($.push(m), m = Z(m, I));
849
+ if (Array.isArray(I)) break;
850
+ typeof I != "object" && ($.push(b), b = Z(b, I));
871
851
  }
872
- for (let I = C.length - 1; I >= j; I--)
873
- m = A(m, C[I]);
852
+ for (let I = C.length - 1; I >= j; I--) b = A(b, C[I]);
874
853
  for (--j; j >= 0; j--) {
875
854
  const I = C[j];
876
855
  if (typeof I != "object") {
877
856
  const T = $.pop();
878
- m = m === Z(T, I) ? T : m === void 0 ? c(T, I) : (v = I, b = m, (p = W(p = T))[v] = b, p);
879
- } else
880
- O(I) && (l(m !== void 0, "Cannot pick up or remove undefined"), I.p != null && (y[I.p] = m), m = void 0);
857
+ b = b === Z(T, I) ? T : b === void 0 ? c(T, I) : (v = I, m = b, (p = W(p = T))[v] = m, p);
858
+ } else O(I) && (l(b !== void 0, "Cannot pick up or remove undefined"), I.p != null && (y[I.p] = b), b = void 0);
881
859
  }
882
- var p, v, b;
883
- return m;
860
+ var p, v, m;
861
+ return b;
884
862
  }(r, u), u);
885
863
  }
886
864
  function ue(r, u) {
887
865
  r = r.slice(), X(u);
888
866
  const y = i.readCursor(u);
889
- let A, m, C = !1;
867
+ let A, b, C = !1;
890
868
  const $ = [];
891
869
  for (let p = 0; ; p++) {
892
- const v = r[p], b = y.getComponent();
893
- if (b && (b.r !== void 0 ? C = !0 : b.p != null && (C = !1, A = b.p, m = p)), p >= r.length)
894
- break;
870
+ const v = r[p], m = y.getComponent();
871
+ if (m && (m.r !== void 0 ? C = !0 : m.p != null && (C = !1, A = m.p, b = p)), p >= r.length) break;
895
872
  let I = 0;
896
873
  const T = i.advancer(y, void 0, (g, N) => {
897
874
  O(N) && I++;
898
875
  });
899
876
  $.unshift(T);
900
877
  const G = T(v);
901
- if (typeof v == "number" && (r[p] -= I), !G)
902
- break;
878
+ if (typeof v == "number" && (r[p] -= I), !G) break;
903
879
  }
904
- if ($.forEach((p) => p.end()), C)
905
- return null;
880
+ if ($.forEach((p) => p.end()), C) return null;
906
881
  const j = () => {
907
882
  let p = 0;
908
883
  if (A != null) {
909
884
  const v = y.getPath();
910
- p = v.length, r = v.concat(r.slice(m));
885
+ p = v.length, r = v.concat(r.slice(b));
911
886
  }
912
887
  for (; p < r.length; p++) {
913
- const v = r[p], b = a(y), I = ve(b);
888
+ const v = r[p], m = a(y), I = ve(m);
914
889
  if (I) {
915
- const g = f(b);
890
+ const g = f(m);
916
891
  I.transformPosition && (r[p] = I.transformPosition(r[p], g));
917
892
  break;
918
893
  }
@@ -920,8 +895,7 @@ function Lt() {
920
895
  const G = i.advancer(y, (g, N) => o(N) ? ~(g - T) : g - T, (g, N) => {
921
896
  o(N) && T++;
922
897
  })(v);
923
- if (typeof v == "number" && (r[p] += T), !G)
924
- break;
898
+ if (typeof v == "number" && (r[p] += T), !G) break;
925
899
  }
926
900
  };
927
901
  return A != null ? y.eachDrop(null, (p) => {
@@ -929,121 +903,106 @@ function Lt() {
929
903
  }) : j(), r;
930
904
  }
931
905
  function ne(r, u) {
932
- if (X(r), X(u), r == null)
933
- return u;
934
- if (u == null)
935
- return r;
906
+ if (X(r), X(u), r == null) return u;
907
+ if (u == null) return r;
936
908
  let y = 0;
937
- const A = i.readCursor(r), m = i.readCursor(u), C = i.writeCursor(), $ = [], j = [], p = [], v = [], b = [], I = [], T = /* @__PURE__ */ new Set();
909
+ const A = i.readCursor(r), b = i.readCursor(u), C = i.writeCursor(), $ = [], j = [], p = [], v = [], m = [], I = [], T = /* @__PURE__ */ new Set();
938
910
  A.traverse(null, (g) => {
939
911
  g.p != null && (p[g.p] = A.clone());
940
- }), m.traverse(null, (g) => {
941
- g.d != null && (v[g.d] = m.clone());
912
+ }), b.traverse(null, (g) => {
913
+ g.d != null && (v[g.d] = b.clone());
942
914
  });
943
915
  const G = i.writeCursor();
944
- return function g(N, re, te, K, se, Te, me, _e) {
916
+ return function g(N, re, te, K, se, Te, be, _e) {
945
917
  l(re || te);
946
918
  const oe = a(re), De = a(te), Me = !!De && De.r !== void 0, Le = !!oe && oe.i !== void 0, Ue = oe ? oe.d : null, Ee = De ? De.p : null, $e = (Te || Me) && Ee == null;
947
- if (Ee != null)
948
- K = v[Ee], me = j[Ee] = new i.WriteCursor();
949
- else if (De && De.r !== void 0)
950
- K = null;
919
+ if (Ee != null) K = v[Ee], be = j[Ee] = new i.WriteCursor();
920
+ else if (De && De.r !== void 0) K = null;
951
921
  else {
952
922
  const D = a(K);
953
923
  D && D.d != null && (K = null);
954
924
  }
955
925
  const Q = a(K);
956
- if (Ue != null)
957
- if (N = p[Ue], _e = $[Ue] = new i.WriteCursor(), $e)
958
- Te && !Me && _e.write("r", !0);
959
- else {
960
- const D = b[Ue] = y++;
961
- me.write("d", D);
962
- }
963
- else if (oe && oe.i !== void 0)
964
- N = null;
926
+ if (Ue != null) if (N = p[Ue], _e = $[Ue] = new i.WriteCursor(), $e) Te && !Me && _e.write("r", !0);
927
+ else {
928
+ const D = m[Ue] = y++;
929
+ be.write("d", D);
930
+ }
931
+ else if (oe && oe.i !== void 0) N = null;
965
932
  else {
966
933
  const D = a(N);
967
934
  D && D.p != null && (N = null);
968
935
  }
969
936
  let U;
970
937
  Le ? (l(se === void 0), U = oe.i) : U = se;
971
- const B = (Ee == null ? !Le || Te || Me : U === void 0) ? null : me.getComponent();
938
+ const B = (Ee == null ? !Le || Te || Me : U === void 0) ? null : be.getComponent();
972
939
  if (Ee != null) {
973
940
  if (!(se !== void 0 || Le)) {
974
- const D = Ue != null ? b[Ue] : y++;
941
+ const D = Ue != null ? m[Ue] : y++;
975
942
  I[Ee] = D, _e.write("p", D);
976
943
  }
977
- } else
978
- Me && (Le || se !== void 0 || (De.r, _e.write("r", De.r)));
944
+ } else Me && (Le || se !== void 0 || (De.r, _e.write("r", De.r)));
979
945
  const M = $e ? null : ve(oe), P = ve(Q);
980
946
  if ((M || P) && (M && M.name, P && P.name), M && P) {
981
947
  l(M === P);
982
948
  const D = f(oe), x = f(Q), he = M.compose(D, x);
983
- _(me, M, he), T.add(Q);
984
- } else
985
- M ? _(me, M, f(oe)) : P && (_(me, P, f(Q)), T.add(Q));
949
+ _(be, M, he), T.add(Q);
950
+ } else M ? _(be, M, f(oe)) : P && (_(be, P, f(Q)), T.add(Q));
986
951
  const k = typeof U == "object" && U != null;
987
952
  let z = !1, Y = 0, ee = 0, fe = 0, de = 0, le = 0;
988
953
  const ye = i.advancer(K, (D, x) => o(x) ? de - D - 1 : D - de, (D, x) => {
989
954
  o(x) && de++;
990
- }), V = i.advancer(N, (D, x) => O(x) ? Y - D - 1 : D - Y, (D, x) => {
955
+ }), q = i.advancer(N, (D, x) => O(x) ? Y - D - 1 : D - Y, (D, x) => {
991
956
  O(x) && Y++;
992
957
  });
993
958
  if (i.eachChildOf(re, te, (D, x, he) => {
994
- let be, We, He = D, Ne = D, Ye = D;
959
+ let me, We, He = D, Ne = D, Ye = D;
995
960
  if (typeof D == "number") {
996
961
  let Oe = D + fe;
997
962
  We = ye(Oe), Ne = Oe + de;
998
963
  let ce = D + ee;
999
- be = V(ce), o(a(We)) && (be = null), He = ce + Y, Ye = D + le, l(He >= 0, "p1PickKey is negative"), l(Ne >= 0, "p2DropKey is negative");
964
+ me = q(ce), o(a(We)) && (me = null), He = ce + Y, Ye = D + le, l(He >= 0, "p1PickKey is negative"), l(Ne >= 0, "p2DropKey is negative");
1000
965
  const ke = o(a(x)), Ge = O(a(he));
1001
966
  (ke || Ge && !$e) && le--, ke && ee--, Ge && fe--;
1002
- } else
1003
- be = V(D), We = ye(D);
1004
- _e.descend(He), me.descend(Ne);
1005
- const Xe = k && !o(a(x)) ? U[Ye] : void 0, Se = g(be, x, he, We, Xe, $e, me, _e);
967
+ } else me = q(D), We = ye(D);
968
+ _e.descend(He), be.descend(Ne);
969
+ const Xe = k && !o(a(x)) ? U[Ye] : void 0, Se = g(me, x, he, We, Xe, $e, be, _e);
1006
970
  var je, S, ie;
1007
- k && !$e ? Xe !== Se && (z || (U = Array.isArray(U) ? U.slice() : Object.assign({}, U), z = !0), je = U, ie = Se, typeof (S = Ye) == "number" ? (l(Array.isArray(je)), l(S < je.length)) : (l(!Array.isArray(je)), l(je[S] !== void 0)), ie === void 0 ? typeof S == "number" ? je.splice(S, 1) : delete je[S] : je[S] = ie) : l(Se === void 0), me.ascend(), _e.ascend();
1008
- }), V.end(), ye.end(), B != null)
1009
- B.i = U;
1010
- else if (!Te && !Me && Ee == null)
1011
- return U;
1012
- }(A, A.clone(), m, m.clone(), void 0, !1, C, G), C.reset(), C.mergeTree(G.get()), C.reset(), C.get(), $.map((g) => g.get()), j.map((g) => g.get()), A.traverse(C, (g, N) => {
971
+ k && !$e ? Xe !== Se && (z || (U = Array.isArray(U) ? U.slice() : Object.assign({}, U), z = !0), je = U, ie = Se, typeof (S = Ye) == "number" ? (l(Array.isArray(je)), l(S < je.length)) : (l(!Array.isArray(je)), l(je[S] !== void 0)), ie === void 0 ? typeof S == "number" ? je.splice(S, 1) : delete je[S] : je[S] = ie) : l(Se === void 0), be.ascend(), _e.ascend();
972
+ }), q.end(), ye.end(), B != null) B.i = U;
973
+ else if (!Te && !Me && Ee == null) return U;
974
+ }(A, A.clone(), b, b.clone(), void 0, !1, C, G), C.reset(), C.mergeTree(G.get()), C.reset(), C.get(), $.map((g) => g.get()), j.map((g) => g.get()), A.traverse(C, (g, N) => {
1013
975
  const re = g.p;
1014
976
  if (re != null) {
1015
- const te = b[re];
977
+ const te = m[re];
1016
978
  te != null && N.write("p", te);
1017
979
  const K = $[re];
1018
980
  K && K.get(), K && N.mergeTree(K.get());
1019
- } else
1020
- g.r !== void 0 && N.write("r", g.r);
1021
- }), C.reset(), C.get(), m.traverse(C, (g, N) => {
981
+ } else g.r !== void 0 && N.write("r", g.r);
982
+ }), C.reset(), C.get(), b.traverse(C, (g, N) => {
1022
983
  const re = g.d;
1023
984
  if (re != null) {
1024
985
  const K = I[re];
1025
986
  K != null && N.write("d", K);
1026
987
  const se = j[re];
1027
988
  se && N.mergeTree(se.get());
1028
- } else
1029
- g.i !== void 0 && N.write("i", g.i);
989
+ } else g.i !== void 0 && N.write("i", g.i);
1030
990
  const te = ve(g);
1031
991
  te && !T.has(g) && _(N, te, f(g));
1032
992
  }), C.get();
1033
993
  }
1034
994
  function ae(r) {
1035
- if (r == null)
1036
- return null;
995
+ if (r == null) return null;
1037
996
  const u = new i.ReadCursor(r), y = new i.WriteCursor();
1038
997
  let A;
1039
- const m = [], C = [];
998
+ const b = [], C = [];
1040
999
  return function $(j, p, v) {
1041
- const b = j.getComponent();
1000
+ const m = j.getComponent();
1042
1001
  let I, T = !1;
1043
- if (b) {
1044
- b.p != null && (p.write("d", b.p), m[b.p] = j.clone()), b.r !== void 0 && p.write("i", b.r), b.d != null && (p.write("p", b.d), v = void 0), b.i !== void 0 && (v = I = b.i);
1045
- const g = ve(b);
1046
- g && (v === void 0 ? (A || (A = /* @__PURE__ */ new Set()), A.add(b)) : (f(b), v = g.apply(v, f(b)), T = !0));
1002
+ if (m) {
1003
+ m.p != null && (p.write("d", m.p), b[m.p] = j.clone()), m.r !== void 0 && p.write("i", m.r), m.d != null && (p.write("p", m.d), v = void 0), m.i !== void 0 && (v = I = m.i);
1004
+ const g = ve(m);
1005
+ g && (v === void 0 ? (A || (A = /* @__PURE__ */ new Set()), A.add(m)) : (f(m), v = g.apply(v, f(m)), T = !0));
1047
1006
  }
1048
1007
  let G = 0;
1049
1008
  for (const g of j) {
@@ -1052,36 +1011,31 @@ function Lt() {
1052
1011
  o(j.getComponent()) && G++;
1053
1012
  const te = $(j, p, re);
1054
1013
  if (v !== void 0 && te !== void 0) {
1055
- if (T || (T = !0, v = W(v)), !R(v, N))
1056
- throw Error("Cannot modify child - invalid operation");
1014
+ if (T || (T = !0, v = W(v)), !R(v, N)) throw Error("Cannot modify child - invalid operation");
1057
1015
  v[N] = te;
1058
1016
  }
1059
1017
  p.ascend();
1060
1018
  }
1061
- if (I === void 0)
1062
- return T ? v : void 0;
1019
+ if (I === void 0) return T ? v : void 0;
1063
1020
  p.write("r", v);
1064
1021
  }(u, y, void 0), A && (y.reset(), function $(j, p, v) {
1065
- const b = p.getComponent();
1066
- if (b) {
1067
- const g = b.d;
1068
- if (g != null && (j = m[g], v = C[g] = i.writeCursor()), A.has(b)) {
1069
- const N = ve(b);
1070
- if (!N.invert)
1071
- throw Error(`Cannot invert subtype ${N.name}`);
1072
- _(v, N, N.invert(f(b)));
1022
+ const m = p.getComponent();
1023
+ if (m) {
1024
+ const g = m.d;
1025
+ if (g != null && (j = b[g], v = C[g] = i.writeCursor()), A.has(m)) {
1026
+ const N = ve(m);
1027
+ if (!N.invert) throw Error(`Cannot invert subtype ${N.name}`);
1028
+ _(v, N, N.invert(f(m)));
1073
1029
  }
1074
1030
  }
1075
1031
  let I = 0, T = 0;
1076
1032
  const G = i.advancer(j, (g, N) => O(N) ? I - g - 1 : g - I, (g, N) => {
1077
1033
  O(N) && I++;
1078
1034
  });
1079
- for (const g of p)
1080
- if (typeof g == "number") {
1081
- const N = g - T, re = G(N), te = N + I;
1082
- v.descend(te), $(re, p, v), o(p.getComponent()) && T++, v.ascend();
1083
- } else
1084
- v.descend(g), $(G(g), p, v), v.ascend();
1035
+ for (const g of p) if (typeof g == "number") {
1036
+ const N = g - T, re = G(N), te = N + I;
1037
+ v.descend(te), $(re, p, v), o(p.getComponent()) && T++, v.ascend();
1038
+ } else v.descend(g), $(G(g), p, v), v.ascend();
1085
1039
  G.end();
1086
1040
  }(u.clone(), u, y), C.length && (y.reset(), u.traverse(y, ($, j) => {
1087
1041
  const p = $.p;
@@ -1096,31 +1050,29 @@ function Lt() {
1096
1050
  if (r == null || !ge(r, (p) => {
1097
1051
  var v;
1098
1052
  return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
1099
- }))
1100
- return r;
1053
+ })) return r;
1101
1054
  const y = new i.ReadCursor(r), A = new i.WriteCursor();
1102
- let m = !1;
1103
- const C = [], $ = [], j = (p, v, b) => {
1055
+ let b = !1;
1056
+ const C = [], $ = [], j = (p, v, m) => {
1104
1057
  const I = p.getComponent();
1105
1058
  let T = !1;
1106
1059
  if (I) {
1107
1060
  I.d != null && v.write("d", I.d), I.i !== void 0 && v.write("i", I.i);
1108
1061
  const g = I.p;
1109
- if (g != null && (C[g] = p.clone(), l(b !== void 0, "Operation picks up at an invalid key"), $[g] = b, v.write("p", I.p)), I.r !== void 0 && b === void 0)
1110
- throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
1062
+ if (g != null && (C[g] = p.clone(), l(m !== void 0, "Operation picks up at an invalid key"), $[g] = m, v.write("p", I.p)), I.r !== void 0 && m === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
1111
1063
  const N = ve(I);
1112
- N && (N.makeInvertible ? m = !0 : _(v, N, f(I), !0));
1064
+ N && (N.makeInvertible ? b = !0 : _(v, N, f(I), !0));
1113
1065
  }
1114
1066
  let G = 0;
1115
1067
  for (const g of p) {
1116
1068
  v.descend(g);
1117
- const N = typeof g == "number" ? g - G : g, re = Z(b, N), te = j(p, v, re);
1118
- re !== te && (T || (T = !0, b = W(b)), te === void 0 ? (b = c(b, N), typeof g == "number" && G++) : b[N] = te), v.ascend();
1069
+ const N = typeof g == "number" ? g - G : g, re = Z(m, N), te = j(p, v, re);
1070
+ re !== te && (T || (T = !0, m = W(m)), te === void 0 ? (m = c(m, N), typeof g == "number" && G++) : m[N] = te), v.ascend();
1119
1071
  }
1120
- return I && (I.r !== void 0 ? (v.write("r", s.default(b)), b = void 0) : I.p != null && (b = void 0)), b;
1072
+ return I && (I.r !== void 0 ? (v.write("r", s.default(m)), m = void 0) : I.p != null && (m = void 0)), m;
1121
1073
  };
1122
- return j(y, A, u), A.get(), m && (A.reset(), function p(v, b, I, T, G) {
1123
- const g = b.getComponent();
1074
+ return j(y, A, u), A.get(), b && (A.reset(), function p(v, m, I, T, G) {
1075
+ const g = m.getComponent();
1124
1076
  if (g) {
1125
1077
  g.i !== void 0 ? (T = g.i, G = !0) : g.d != null && (T = $[g.d], v = C[g.d], G = !1, g.d);
1126
1078
  let K = ve(g);
@@ -1133,14 +1085,13 @@ function Lt() {
1133
1085
  const te = i.advancer(v, (K, se) => O(se) ? N - K - 1 : K - N, (K, se) => {
1134
1086
  O(se) && N++;
1135
1087
  });
1136
- for (const K of b)
1137
- if (typeof K == "number") {
1138
- const se = K - re, Te = te(se), me = se + N, _e = Z(T, G ? se : me);
1139
- I.descend(K), p(Te, b, I, _e, G), o(b.getComponent()) && re++, I.ascend();
1140
- } else {
1141
- const se = Z(T, K);
1142
- I.descend(K), p(te(K), b, I, se, G), I.ascend();
1143
- }
1088
+ for (const K of m) if (typeof K == "number") {
1089
+ const se = K - re, Te = te(se), be = se + N, _e = Z(T, G ? se : be);
1090
+ I.descend(K), p(Te, m, I, _e, G), o(m.getComponent()) && re++, I.ascend();
1091
+ } else {
1092
+ const se = Z(T, K);
1093
+ I.descend(K), p(te(K), m, I, se, G), I.ascend();
1094
+ }
1144
1095
  te.end();
1145
1096
  }(y.clone(), y, A, u, !1)), A.get();
1146
1097
  }
@@ -1148,8 +1099,7 @@ function Lt() {
1148
1099
  return ae(Pe(r, u));
1149
1100
  }
1150
1101
  const tt = (r) => {
1151
- if (r == null)
1152
- return null;
1102
+ if (r == null) return null;
1153
1103
  const u = r.slice();
1154
1104
  for (let y = 0; y < r.length; y++) {
1155
1105
  const A = u[y];
@@ -1160,34 +1110,32 @@ function Lt() {
1160
1110
  function nt(r, u, y) {
1161
1111
  l(y === "left" || y === "right", "Direction must be left or right");
1162
1112
  const A = y === "left" ? 0 : 1;
1163
- if (u == null)
1164
- return {
1165
- ok: !0,
1166
- result: r
1167
- };
1113
+ if (u == null) return {
1114
+ ok: !0,
1115
+ result: r
1116
+ };
1168
1117
  X(r), X(u);
1169
- let m = null;
1170
- const C = [], $ = [], j = [], p = [], v = [], b = [], I = [], T = [], G = [], g = [], N = [], re = [], te = [], K = [], se = [];
1118
+ let b = null;
1119
+ const C = [], $ = [], j = [], p = [], v = [], m = [], I = [], T = [], G = [], g = [], N = [], re = [], te = [], K = [], se = [];
1171
1120
  let Te = 0;
1172
- const me = i.readCursor(r), _e = i.readCursor(u), oe = i.writeCursor();
1121
+ const be = i.readCursor(r), _e = i.readCursor(u), oe = i.writeCursor();
1173
1122
  if (function Q(U, B = null, M) {
1174
1123
  const P = a(B);
1175
- P && (P.r !== void 0 ? M = B.clone() : P.p != null && (M = null, b[P.p] = U.clone()));
1124
+ P && (P.r !== void 0 ? M = B.clone() : P.p != null && (M = null, m[P.p] = U.clone()));
1176
1125
  const k = U.getComponent();
1177
1126
  let z;
1178
1127
  k && (z = k.p) != null && (v[z] = B ? B.clone() : null, j[z] = U.clone(), M && (g[z] = !0, G[z] = M), P && P.p != null && (K[z] = P.p));
1179
1128
  const Y = i.advancer(B);
1180
- for (const ee of U)
1181
- Q(U, Y(ee), M);
1129
+ for (const ee of U) Q(U, Y(ee), M);
1182
1130
  Y.end();
1183
- }(_e, me, null), function Q(U, B, M, P, k) {
1131
+ }(_e, be, null), function Q(U, B, M, P, k) {
1184
1132
  const z = M.getComponent();
1185
1133
  let Y, ee = !1;
1186
- z && ((Y = z.d) != null ? (p[Y] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(Y)), U = v[Y] || null, B = j[Y] || null, g[Y] ? (k && (N[Y] = !0), k = G[Y] || null) : !k || A !== 1 && K[Y] != null || m == null && (m = {
1134
+ z && ((Y = z.d) != null ? (p[Y] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(Y)), U = v[Y] || null, B = j[Y] || null, g[Y] ? (k && (N[Y] = !0), k = G[Y] || null) : !k || A !== 1 && K[Y] != null || b == null && (b = {
1187
1135
  type: d.ConflictType.RM_UNEXPECTED_CONTENT,
1188
1136
  op1: t.removeOp(k.getPath()),
1189
1137
  op2: t.moveOp(B.getPath(), M.getPath())
1190
- }), ee = !0) : z.i !== void 0 && (U = B = null, ee = !0, k && m == null && (m = {
1138
+ }), ee = !0) : z.i !== void 0 && (U = B = null, ee = !0, k && b == null && (b = {
1191
1139
  type: d.ConflictType.RM_UNEXPECTED_CONTENT,
1192
1140
  op1: t.removeOp(k.getPath()),
1193
1141
  op2: t.insertOp(M.getPath(), z.i)
@@ -1195,29 +1143,27 @@ function Lt() {
1195
1143
  const fe = a(U);
1196
1144
  fe && (fe.r !== void 0 ? k = U.clone() : fe.p != null && (fe.p, P = fe.p, k = null));
1197
1145
  const de = ve(z);
1198
- de && k && m == null && (m = {
1146
+ de && k && b == null && (b = {
1199
1147
  type: d.ConflictType.RM_UNEXPECTED_CONTENT,
1200
1148
  op1: t.removeOp(k.getPath()),
1201
1149
  op2: t.editOp(M.getPath(), de, f(z), !0)
1202
1150
  });
1203
1151
  let le = 0, ye = 0;
1204
- const V = i.advancer(B, (x, he) => O(he) ? le - x - 1 : x - le, (x, he) => {
1152
+ const q = i.advancer(B, (x, he) => O(he) ? le - x - 1 : x - le, (x, he) => {
1205
1153
  O(he) && le++;
1206
1154
  }), D = i.advancer(U);
1207
- for (const x of M)
1208
- if (typeof x == "number") {
1209
- const he = x - ye, be = V(he);
1210
- ye += +Q(D(he + le), be, M, P, k);
1211
- } else {
1212
- const he = V(x);
1213
- Q(D(x), he, M, P, k);
1214
- }
1215
- return V.end(), D.end(), ee;
1216
- }(me, _e, _e.clone(), null, null), p.map((Q) => Q && Q.get()), m)
1217
- return {
1218
- ok: !1,
1219
- conflict: m
1220
- };
1155
+ for (const x of M) if (typeof x == "number") {
1156
+ const he = x - ye, me = q(he);
1157
+ ye += +Q(D(he + le), me, M, P, k);
1158
+ } else {
1159
+ const he = q(x);
1160
+ Q(D(x), he, M, P, k);
1161
+ }
1162
+ return q.end(), D.end(), ee;
1163
+ }(be, _e, _e.clone(), null, null), p.map((Q) => Q && Q.get()), b) return {
1164
+ ok: !1,
1165
+ conflict: b
1166
+ };
1221
1167
  N.map((Q) => !!Q);
1222
1168
  const De = [];
1223
1169
  let Me = null;
@@ -1225,32 +1171,29 @@ function Lt() {
1225
1171
  let z = !1;
1226
1172
  const Y = a(B);
1227
1173
  if (O(Y)) {
1228
- const V = Y.p;
1229
- V != null ? (M = p[V], P = re[V] = i.writeCursor(), z = !0, k = null) : (M = null, k = B.clone());
1230
- } else
1231
- o(a(M)) && (M = null);
1174
+ const q = Y.p;
1175
+ q != null ? (M = p[q], P = re[q] = i.writeCursor(), z = !0, k = null) : (M = null, k = B.clone());
1176
+ } else o(a(M)) && (M = null);
1232
1177
  const ee = U.getComponent();
1233
1178
  if (ee) {
1234
- const V = ee.p;
1235
- V != null ? (k && (T[V] = k), De[V] = k || A === 1 && z ? null : P.getComponent(), C[V] = U.clone(), M && (I[V] = M.clone())) : ee.r !== void 0 && (k || P.write("r", !0), (k || z) && (Me == null && (Me = /* @__PURE__ */ new Set()), Me.add(ee)));
1179
+ const q = ee.p;
1180
+ q != null ? (k && (T[q] = k), De[q] = k || A === 1 && z ? null : P.getComponent(), C[q] = U.clone(), M && (I[q] = M.clone())) : ee.r !== void 0 && (k || P.write("r", !0), (k || z) && (Me == null && (Me = /* @__PURE__ */ new Set()), Me.add(ee)));
1236
1181
  }
1237
1182
  let fe = 0, de = 0;
1238
- const le = i.advancer(B, void 0, (V, D) => {
1183
+ const le = i.advancer(B, void 0, (q, D) => {
1239
1184
  O(D) && fe++;
1240
- }), ye = i.advancer(M, (V, D) => o(D) ? ~(V - de) : V - de, (V, D) => {
1185
+ }), ye = i.advancer(M, (q, D) => o(D) ? ~(q - de) : q - de, (q, D) => {
1241
1186
  o(D) && de++;
1242
1187
  });
1243
- if (U)
1244
- for (const V of U)
1245
- if (typeof V == "string") {
1246
- const D = le(V), x = ye(V);
1247
- P.descend(V), Q(U, D, x, P, k), P.ascend();
1248
- } else {
1249
- const D = le(V), x = V - fe, he = O(a(D)) ? null : ye(x), be = x + de;
1250
- l(be >= 0), P.descend(be), Q(U, D, he, P, k), P.ascend();
1251
- }
1188
+ if (U) for (const q of U) if (typeof q == "string") {
1189
+ const D = le(q), x = ye(q);
1190
+ P.descend(q), Q(U, D, x, P, k), P.ascend();
1191
+ } else {
1192
+ const D = le(q), x = q - fe, he = O(a(D)) ? null : ye(x), me = x + de;
1193
+ l(me >= 0), P.descend(me), Q(U, D, he, P, k), P.ascend();
1194
+ }
1252
1195
  le.end(), ye.end();
1253
- })(me, _e, _e.clone(), oe, null), oe.reset();
1196
+ })(be, _e, _e.clone(), oe, null), oe.reset();
1254
1197
  let Le = [];
1255
1198
  if (function Q(U, B, M, P, k, z) {
1256
1199
  l(B);
@@ -1264,11 +1207,11 @@ function Lt() {
1264
1207
  let Oe = !1;
1265
1208
  if (Y.i !== void 0 || S != null && ie) {
1266
1209
  let ce;
1267
- ee && (ee.i !== void 0 || (ce = ee.d) != null && !g[ce]) && (Oe = ce != null ? S != null && S === K[ce] : n.default(ee.i, Y.i), Oe || ce != null && A !== 1 && K[ce] != null || m == null && (m = {
1210
+ ee && (ee.i !== void 0 || (ce = ee.d) != null && !g[ce]) && (Oe = ce != null ? S != null && S === K[ce] : n.default(ee.i, Y.i), Oe || ce != null && A !== 1 && K[ce] != null || b == null && (b = {
1268
1211
  type: d.ConflictType.DROP_COLLISION,
1269
1212
  op1: de(S != null ? C[S] : null, B, Y),
1270
1213
  op2: de(ce != null ? j[ce] : null, P, ee)
1271
- })), Oe || (z ? m == null && (m = {
1214
+ })), Oe || (z ? b == null && (b = {
1272
1215
  type: d.ConflictType.RM_UNEXPECTED_CONTENT,
1273
1216
  op1: de(S != null ? C[S] : null, B, Y),
1274
1217
  op2: t.removeOp(z.getPath())
@@ -1277,115 +1220,103 @@ function Lt() {
1277
1220
  const ce = T[S];
1278
1221
  ce && (z = ce.clone());
1279
1222
  }
1280
- S != null ? (U = C[S], M = b[S], P = I[S]) : Y.i !== void 0 && (U = M = null, Oe || (P = null));
1281
- } else
1282
- O(a(U)) && (U = M = P = null);
1223
+ S != null ? (U = C[S], M = m[S], P = I[S]) : Y.i !== void 0 && (U = M = null, Oe || (P = null));
1224
+ } else O(a(U)) && (U = M = P = null);
1283
1225
  const le = a(U), ye = a(M);
1284
1226
  if (O(ye)) {
1285
1227
  const S = ye.p;
1286
1228
  ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (P = null, z = M.clone()) : S != null && (P = p[S], A !== 1 && K[S] != null || ((k = te[S]) || (k = te[S] = i.writeCursor()), k.reset(), z = null));
1287
- } else
1288
- !o(Y) && o(ee) && (P = null);
1229
+ } else !o(Y) && o(ee) && (P = null);
1289
1230
  ee = P != null ? P.getComponent() : null;
1290
- const V = ve(Y);
1291
- if (V) {
1231
+ const q = ve(Y);
1232
+ if (q) {
1292
1233
  const S = f(Y);
1293
- if (z)
1294
- m == null && (m = {
1295
- type: d.ConflictType.RM_UNEXPECTED_CONTENT,
1296
- op1: t.editOp(B.getPath(), V, S, !0),
1297
- op2: t.removeOp(z.getPath())
1298
- });
1234
+ if (z) b == null && (b = {
1235
+ type: d.ConflictType.RM_UNEXPECTED_CONTENT,
1236
+ op1: t.editOp(B.getPath(), q, S, !0),
1237
+ op2: t.removeOp(z.getPath())
1238
+ });
1299
1239
  else {
1300
1240
  const ie = ve(ee);
1301
1241
  let Oe;
1302
1242
  if (ie) {
1303
- if (V !== ie)
1304
- throw Error("Transforming incompatible types");
1243
+ if (q !== ie) throw Error("Transforming incompatible types");
1305
1244
  const ce = f(ee);
1306
- Oe = V.transform(S, ce, y);
1307
- } else
1308
- Oe = s.default(S);
1309
- _(k, V, Oe);
1245
+ Oe = q.transform(S, ce, y);
1246
+ } else Oe = s.default(S);
1247
+ _(k, q, Oe);
1310
1248
  }
1311
1249
  }
1312
- let D = 0, x = 0, he = 0, be = 0, We = 0, He = 0, Ne = U != null && U.descendFirst(), Ye = Ne;
1250
+ let D = 0, x = 0, he = 0, me = 0, We = 0, He = 0, Ne = U != null && U.descendFirst(), Ye = Ne;
1313
1251
  const Xe = i.advancer(M, void 0, (S, ie) => {
1314
1252
  O(ie) && he++;
1315
1253
  });
1316
1254
  let Se = P != null && P.descendFirst(), je = Se;
1317
- for (const S of B)
1318
- if (typeof S == "number") {
1319
- let ie;
1320
- const Oe = o(B.getComponent()), ce = S - x;
1321
- {
1322
- let Be;
1323
- for (; Ne && typeof (Be = U.getKey()) == "number"; ) {
1324
- Be += D;
1325
- const Re = U.getComponent(), ze = O(Re);
1326
- if (Be > ce || Be === ce && (!ze || A === 0 && Oe))
1327
- break;
1328
- if (ze) {
1329
- D--;
1330
- const Ke = Re.p;
1331
- K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 || Me && Me.has(Re)) && (Ke == null || !De[Ke] || A !== 1 && K.includes(Ke)) || We--;
1332
- }
1333
- Ne = U.nextSibling();
1255
+ for (const S of B) if (typeof S == "number") {
1256
+ let ie;
1257
+ const Oe = o(B.getComponent()), ce = S - x;
1258
+ {
1259
+ let Be;
1260
+ for (; Ne && typeof (Be = U.getKey()) == "number"; ) {
1261
+ Be += D;
1262
+ const Re = U.getComponent(), ze = O(Re);
1263
+ if (Be > ce || Be === ce && (!ze || A === 0 && Oe)) break;
1264
+ if (ze) {
1265
+ D--;
1266
+ const Ke = Re.p;
1267
+ K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 || Me && Me.has(Re)) && (Ke == null || !De[Ke] || A !== 1 && K.includes(Ke)) || We--;
1334
1268
  }
1335
- ie = Ne && Be === ce ? U : null;
1269
+ Ne = U.nextSibling();
1336
1270
  }
1337
- const ke = ce - D;
1338
- let Ge = Xe(ke);
1339
- const rt = ke - he;
1340
- let Je = null;
1341
- {
1342
- let Be, Re;
1343
- for (; Se && typeof (Be = P.getKey()) == "number"; ) {
1344
- Re = Be - be;
1345
- const ze = P.getComponent(), Ke = o(ze);
1346
- if (Re > rt)
1271
+ ie = Ne && Be === ce ? U : null;
1272
+ }
1273
+ const ke = ce - D;
1274
+ let Ge = Xe(ke);
1275
+ const rt = ke - he;
1276
+ let Je = null;
1277
+ {
1278
+ let Be, Re;
1279
+ for (; Se && typeof (Be = P.getKey()) == "number"; ) {
1280
+ Re = Be - me;
1281
+ const ze = P.getComponent(), Ke = o(ze);
1282
+ if (Re > rt) break;
1283
+ if (Re === rt) {
1284
+ if (!Ke) {
1285
+ Je = P;
1347
1286
  break;
1348
- if (Re === rt) {
1349
- if (!Ke) {
1287
+ }
1288
+ {
1289
+ if (A === 0 && Oe) {
1350
1290
  Je = P;
1351
1291
  break;
1352
1292
  }
1353
- {
1354
- if (A === 0 && Oe) {
1355
- Je = P;
1356
- break;
1357
- }
1358
- const Fe = Ge && O(Ge.getComponent());
1359
- if (A === 0 && Fe)
1360
- break;
1361
- }
1293
+ const Ve = Ge && O(Ge.getComponent());
1294
+ if (A === 0 && Ve) break;
1362
1295
  }
1363
- if (Ke) {
1364
- const Fe = ze.d;
1365
- K[Fe], ze.i === void 0 && (g[Fe] || K[Fe] != null && A !== 1) ? (g[Fe] || K[Fe] != null && A === 0) && (be++, He--) : be++;
1366
- }
1367
- Se = P.nextSibling();
1368
1296
  }
1369
- }
1370
- const Ot = rt + be + We + He;
1371
- l(Ot >= 0, "trying to descend to a negative index"), k.descend(Ot), Oe && (ie = Ge = Je = null, x++), Q(ie, B, Ge, Je, k, z) && He++, k.ascend();
1372
- } else {
1373
- let ie;
1374
- for (; Ne && (ie = U.getKey(), typeof ie != "string" || !(ie > S || ie === S)); )
1375
- Ne = U.nextSibling();
1376
- const Oe = Ne && ie === S ? U : null, ce = Xe(S);
1377
- let ke;
1378
- for (; Se && (ke = P.getKey(), typeof ke != "string" || !(ke > S || ke === S)); )
1297
+ if (Ke) {
1298
+ const Ve = ze.d;
1299
+ K[Ve], ze.i === void 0 && (g[Ve] || K[Ve] != null && A !== 1) ? (g[Ve] || K[Ve] != null && A === 0) && (me++, He--) : me++;
1300
+ }
1379
1301
  Se = P.nextSibling();
1380
- const Ge = Se && ke === S ? P : null;
1381
- k.descend(S), Q(Oe, B, ce, Ge, k, z), k.ascend();
1302
+ }
1382
1303
  }
1304
+ const Ot = rt + me + We + He;
1305
+ l(Ot >= 0, "trying to descend to a negative index"), k.descend(Ot), Oe && (ie = Ge = Je = null, x++), Q(ie, B, Ge, Je, k, z) && He++, k.ascend();
1306
+ } else {
1307
+ let ie;
1308
+ for (; Ne && (ie = U.getKey(), typeof ie != "string" || !(ie > S || ie === S)); ) Ne = U.nextSibling();
1309
+ const Oe = Ne && ie === S ? U : null, ce = Xe(S);
1310
+ let ke;
1311
+ for (; Se && (ke = P.getKey(), typeof ke != "string" || !(ke > S || ke === S)); ) Se = P.nextSibling();
1312
+ const Ge = Se && ke === S ? P : null;
1313
+ k.descend(S), Q(Oe, B, ce, Ge, k, z), k.ascend();
1314
+ }
1383
1315
  return Xe.end(), Ye && U.ascend(), je && P.ascend(), fe;
1384
- }(me, me.clone(), _e, _e.clone(), oe, null), m)
1385
- return {
1386
- ok: !1,
1387
- conflict: m
1388
- };
1316
+ }(be, be.clone(), _e, _e.clone(), oe, null), b) return {
1317
+ ok: !1,
1318
+ conflict: b
1319
+ };
1389
1320
  oe.reset();
1390
1321
  const Ue = (Q, U, B) => Q.traverse(U, (M, P) => {
1391
1322
  M.d != null && B(M.d, Q, P);
@@ -1394,7 +1325,7 @@ function Lt() {
1394
1325
  g[Q] && !N[Q] && B.write("r", !0), re[Q] && B.mergeTree(re[Q].get());
1395
1326
  }), oe.reset());
1396
1327
  const Ee = [], $e = [];
1397
- if ((te.length || g.length) && !m) {
1328
+ if ((te.length || g.length) && !b) {
1398
1329
  const Q = i.readCursor(tt(oe.get()));
1399
1330
  if (Ue(Q, null, (U, B) => {
1400
1331
  Ee[U] = B.clone();
@@ -1404,14 +1335,11 @@ function Lt() {
1404
1335
  });
1405
1336
  }), function U(B, M, P, k, z, Y) {
1406
1337
  const ee = a(M);
1407
- if (ee && O(ee))
1408
- if (ee.p != null) {
1409
- const D = ee.p;
1410
- Ee[D].getPath(), P = Ee[D], k = $e[D] = i.writeCursor();
1411
- } else
1412
- ee.r !== void 0 && (P = null);
1413
- else
1414
- o(a(P)) && (P = null);
1338
+ if (ee && O(ee)) if (ee.p != null) {
1339
+ const D = ee.p;
1340
+ Ee[D].getPath(), P = Ee[D], k = $e[D] = i.writeCursor();
1341
+ } else ee.r !== void 0 && (P = null);
1342
+ else o(a(P)) && (P = null);
1415
1343
  const fe = B.getComponent();
1416
1344
  if (fe) {
1417
1345
  let D;
@@ -1423,21 +1351,18 @@ function Lt() {
1423
1351
  let de = 0, le = 0;
1424
1352
  const ye = i.advancer(M, void 0, (D, x) => {
1425
1353
  O(x) && de--;
1426
- }), V = i.advancer(P, (D, x) => o(x) ? -(D - le) - 1 : D - le, (D, x) => {
1354
+ }), q = i.advancer(P, (D, x) => o(x) ? -(D - le) - 1 : D - le, (D, x) => {
1427
1355
  o(x) && le++;
1428
1356
  });
1429
- for (const D of B)
1430
- if (typeof D == "number") {
1431
- const x = ye(D), he = D + de, be = V(he), We = he + le;
1432
- k.descend(We), U(B, x, be, k), k.ascend();
1433
- } else
1434
- k.descend(D), U(B, ye(D), V(D), k), k.ascend();
1435
- ye.end(), V.end();
1436
- }(_e, Q, Q.clone(), oe), oe.reset(), m)
1437
- return {
1438
- ok: !1,
1439
- conflict: m
1440
- };
1357
+ for (const D of B) if (typeof D == "number") {
1358
+ const x = ye(D), he = D + de, me = q(he), We = he + le;
1359
+ k.descend(We), U(B, x, me, k), k.ascend();
1360
+ } else k.descend(D), U(B, ye(D), q(D), k), k.ascend();
1361
+ ye.end(), q.end();
1362
+ }(_e, Q, Q.clone(), oe), oe.reset(), b) return {
1363
+ ok: !1,
1364
+ conflict: b
1365
+ };
1441
1366
  if (oe.get(), $e.length) {
1442
1367
  const U = $e.map((M) => M ? M.get() : null), B = i.readCursor(tt(oe.get()));
1443
1368
  if (Ue(B, oe, (M, P, k) => {
@@ -1455,7 +1380,7 @@ function Lt() {
1455
1380
  g[le] || A !== 1 && K[le] != null || P.writeMove(j[le].getPath(), p[le].getPath(), z++);
1456
1381
  });
1457
1382
  });
1458
- }), m = {
1383
+ }), b = {
1459
1384
  type: d.ConflictType.BLACKHOLE,
1460
1385
  op1: M.get(),
1461
1386
  op2: P.get()
@@ -1463,9 +1388,9 @@ function Lt() {
1463
1388
  }
1464
1389
  }
1465
1390
  }
1466
- return m ? {
1391
+ return b ? {
1467
1392
  ok: !1,
1468
- conflict: m
1393
+ conflict: b
1469
1394
  } : {
1470
1395
  ok: !0,
1471
1396
  result: oe.get()
@@ -1477,8 +1402,7 @@ function Lt() {
1477
1402
  };
1478
1403
  function At(r, u, y) {
1479
1404
  const A = nt(r, u, y);
1480
- if (A.ok)
1481
- return A.result;
1405
+ if (A.ok) return A.result;
1482
1406
  gt(A.conflict);
1483
1407
  }
1484
1408
  const qe = (r) => {
@@ -1487,32 +1411,31 @@ function Lt() {
1487
1411
  (o(y) || ve(y)) && A.write("r", !0);
1488
1412
  }), u.get();
1489
1413
  }, Pt = (r, u) => {
1490
- const { type: y, op1: A, op2: m } = r;
1414
+ const { type: y, op1: A, op2: b } = r;
1491
1415
  switch (y) {
1492
1416
  case d.ConflictType.DROP_COLLISION:
1493
- return u === "left" ? [null, qe(m)] : [qe(A), null];
1417
+ return u === "left" ? [null, qe(b)] : [qe(A), null];
1494
1418
  case d.ConflictType.RM_UNEXPECTED_CONTENT:
1495
1419
  let C = !1;
1496
1420
  return i.readCursor(A).traverse(null, ($) => {
1497
1421
  $.r !== void 0 && (C = !0);
1498
- }), C ? [null, qe(m)] : [qe(A), null];
1422
+ }), C ? [null, qe(b)] : [qe(A), null];
1499
1423
  case d.ConflictType.BLACKHOLE:
1500
- return [qe(A), qe(m)];
1424
+ return [qe(A), qe(b)];
1501
1425
  default:
1502
1426
  throw Error("Unrecognised conflict: " + y);
1503
1427
  }
1504
1428
  };
1505
1429
  function _t(r, u, y, A) {
1506
- let m = null;
1430
+ let b = null;
1507
1431
  for (; ; ) {
1508
1432
  const C = nt(u, y, A);
1509
- if (C.ok)
1510
- return ne(m, C.result);
1433
+ if (C.ok) return ne(b, C.result);
1511
1434
  {
1512
1435
  const { conflict: $ } = C;
1513
1436
  r($) || gt($);
1514
1437
  const [j, p] = Pt($, A);
1515
- u = ne(H(u), j), y = ne(H(y), p), m = ne(m, p);
1438
+ u = ne(H(u), j), y = ne(H(y), p), b = ne(b, p);
1516
1439
  }
1517
1440
  }
1518
1441
  }
@@ -1525,8 +1448,7 @@ function Lt() {
1525
1448
  } : function(d, l, a, E) {
1526
1449
  E === void 0 && (E = a), d[E] = l[a];
1527
1450
  }), n = Ce && Ce.__exportStar || function(d, l) {
1528
- for (var a in d)
1529
- a !== "default" && !l.hasOwnProperty(a) && e(l, d, a);
1451
+ for (var a in d) a !== "default" && !l.hasOwnProperty(a) && e(l, d, a);
1530
1452
  };
1531
1453
  Object.defineProperty(t, "__esModule", { value: !0 }), n(Ct, t);
1532
1454
  var s = ft;
@@ -1542,41 +1464,43 @@ function Lt() {
1542
1464
  })(F);
1543
1465
  class Ht {
1544
1466
  constructor() {
1545
- q(this, "drawingManagerData", {});
1546
- q(this, "_oldDrawingManagerData", {});
1547
- q(this, "_focusDrawings", []);
1548
- q(this, "_remove$", new we());
1549
- q(this, "remove$", this._remove$.asObservable());
1550
- q(this, "_add$", new we());
1551
- q(this, "add$", this._add$.asObservable());
1552
- q(this, "_update$", new we());
1553
- q(this, "update$", this._update$.asObservable());
1554
- q(this, "_order$", new we());
1555
- q(this, "order$", this._order$.asObservable());
1556
- q(this, "_group$", new we());
1557
- q(this, "group$", this._group$.asObservable());
1558
- q(this, "_ungroup$", new we());
1559
- q(this, "ungroup$", this._ungroup$.asObservable());
1560
- q(this, "_refreshTransform$", new we());
1561
- q(this, "refreshTransform$", this._refreshTransform$.asObservable());
1562
- q(this, "_visible$", new we());
1563
- q(this, "visible$", this._visible$.asObservable());
1467
+ V(this, "drawingManagerData", {});
1468
+ V(this, "_oldDrawingManagerData", {});
1469
+ V(this, "_focusDrawings", []);
1470
+ V(this, "_remove$", new we());
1471
+ V(this, "remove$", this._remove$.asObservable());
1472
+ V(this, "_add$", new we());
1473
+ V(this, "add$", this._add$.asObservable());
1474
+ V(this, "_update$", new we());
1475
+ V(this, "update$", this._update$.asObservable());
1476
+ V(this, "_order$", new we());
1477
+ V(this, "order$", this._order$.asObservable());
1478
+ V(this, "_group$", new we());
1479
+ V(this, "group$", this._group$.asObservable());
1480
+ V(this, "_ungroup$", new we());
1481
+ V(this, "ungroup$", this._ungroup$.asObservable());
1482
+ V(this, "_refreshTransform$", new we());
1483
+ V(this, "refreshTransform$", this._refreshTransform$.asObservable());
1484
+ V(this, "_visible$", new we());
1485
+ V(this, "visible$", this._visible$.asObservable());
1564
1486
  // private readonly _externalUpdate$ = new Subject<T[]>();
1565
1487
  // readonly externalUpdate$ = this._externalUpdate$.asObservable();
1566
- q(this, "_focus$", new we());
1567
- q(this, "focus$", this._focus$.asObservable());
1568
- q(this, "_featurePluginUpdate$", new we());
1569
- q(this, "featurePluginUpdate$", this._featurePluginUpdate$.asObservable());
1570
- q(this, "_featurePluginAdd$", new we());
1571
- q(this, "featurePluginAdd$", this._featurePluginAdd$.asObservable());
1572
- q(this, "_featurePluginRemove$", new we());
1573
- q(this, "featurePluginRemove$", this._featurePluginRemove$.asObservable());
1574
- q(this, "_featurePluginOrderUpdate$", new we());
1575
- q(this, "featurePluginOrderUpdate$", this._featurePluginOrderUpdate$.asObservable());
1576
- q(this, "_featurePluginGroupUpdate$", new we());
1577
- q(this, "featurePluginGroupUpdate$", this._featurePluginGroupUpdate$.asObservable());
1578
- q(this, "_featurePluginUngroupUpdate$", new we());
1579
- q(this, "featurePluginUngroupUpdate$", this._featurePluginUngroupUpdate$.asObservable());
1488
+ V(this, "_focus$", new we());
1489
+ V(this, "focus$", this._focus$.asObservable());
1490
+ V(this, "_featurePluginUpdate$", new we());
1491
+ V(this, "featurePluginUpdate$", this._featurePluginUpdate$.asObservable());
1492
+ V(this, "_featurePluginAdd$", new we());
1493
+ V(this, "featurePluginAdd$", this._featurePluginAdd$.asObservable());
1494
+ V(this, "_featurePluginRemove$", new we());
1495
+ V(this, "featurePluginRemove$", this._featurePluginRemove$.asObservable());
1496
+ V(this, "_featurePluginOrderUpdate$", new we());
1497
+ V(this, "featurePluginOrderUpdate$", this._featurePluginOrderUpdate$.asObservable());
1498
+ V(this, "_featurePluginGroupUpdate$", new we());
1499
+ V(this, "featurePluginGroupUpdate$", this._featurePluginGroupUpdate$.asObservable());
1500
+ V(this, "_featurePluginUngroupUpdate$", new we());
1501
+ V(this, "featurePluginUngroupUpdate$", this._featurePluginUngroupUpdate$.asObservable());
1502
+ V(this, "_visible", !0);
1503
+ V(this, "_editable", !0);
1580
1504
  }
1581
1505
  dispose() {
1582
1506
  this._remove$.complete(), this._add$.complete(), this._update$.complete(), this._order$.complete(), this._focus$.complete(), this._featurePluginUpdate$.complete(), this._featurePluginAdd$.complete(), this._featurePluginRemove$.complete(), this._featurePluginOrderUpdate$.complete(), this.drawingManagerData = {}, this._oldDrawingManagerData = {};
@@ -1926,6 +1850,18 @@ class Ht {
1926
1850
  var s, i;
1927
1851
  return ((i = (s = this.drawingManagerData[e]) == null ? void 0 : s[n]) == null ? void 0 : i.order) || [];
1928
1852
  }
1853
+ getDrawingVisible() {
1854
+ return this._visible;
1855
+ }
1856
+ getDrawingEditable() {
1857
+ return this._editable;
1858
+ }
1859
+ setDrawingVisible(e) {
1860
+ this._visible = e;
1861
+ }
1862
+ setDrawingEditable(e) {
1863
+ this._editable = e;
1864
+ }
1929
1865
  }
1930
1866
  class Kt extends Ht {
1931
1867
  }
@@ -1946,13 +1882,13 @@ const un = async (t) => new Promise((e, n) => {
1946
1882
  };
1947
1883
  });
1948
1884
  var et = /* @__PURE__ */ ((t) => (t.URL = "URL", t.UUID = "UUID", t.BASE64 = "BASE64", t))(et || {}), Ze = /* @__PURE__ */ ((t) => (t.SUCCUSS = "0", t.ERROR_EXCEED_SIZE = "1", t.ERROR_IMAGE_TYPE = "2", t.ERROR_UPLOAD_COUNT_LIMIT = "3", t.ERROR_IMAGE = "4", t))(Ze || {});
1949
- const Ft = It("core.image-io.service");
1950
- class Vt {
1885
+ const Vt = It("core.image-io.service");
1886
+ class Ft {
1951
1887
  constructor() {
1952
- q(this, "_waitCount", 0);
1953
- q(this, "_change$", new we());
1954
- q(this, "change$", this._change$);
1955
- q(this, "_imageSourceCache", /* @__PURE__ */ new Map());
1888
+ V(this, "_waitCount", 0);
1889
+ V(this, "_change$", new we());
1890
+ V(this, "change$", this._change$);
1891
+ V(this, "_imageSourceCache", /* @__PURE__ */ new Map());
1956
1892
  }
1957
1893
  setWaitCount(e) {
1958
1894
  this._waitCount = e, this._change$.next(e);
@@ -2023,11 +1959,11 @@ let wt = (ot = class extends Rt {
2023
1959
  _initDependencies(t) {
2024
1960
  var s;
2025
1961
  St([
2026
- [Ft, { useClass: Vt }],
1962
+ [Vt, { useClass: Ft }],
2027
1963
  [zt, { useClass: Kt }]
2028
1964
  ], (s = this._config) == null ? void 0 : s.override).forEach((i) => t.add(i));
2029
1965
  }
2030
- }, q(ot, "pluginName", en), ot);
1966
+ }, V(ot, "pluginName", en), ot);
2031
1967
  wt = Jt([
2032
1968
  Qt(1, jt(Tt))
2033
1969
  ], wt);
@@ -2042,8 +1978,8 @@ export {
2042
1978
  Kt as DrawingManagerService,
2043
1979
  Xt as DrawingTypeEnum,
2044
1980
  zt as IDrawingManagerService,
2045
- Ft as IImageIoService,
2046
- Vt as ImageIoService,
1981
+ Vt as IImageIoService,
1982
+ Ft as ImageIoService,
2047
1983
  et as ImageSourceType,
2048
1984
  Ze as ImageUploadStatusType,
2049
1985
  Ht as UnitDrawingService,