@tricoteuses/tisseuse 0.11.0 → 0.12.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.
package/dist/index.js CHANGED
@@ -1,74 +1,74 @@
1
- import { $ as e, $t as t, A as n, An as r, At as i, B as a, Bt as o, C as s, Cn as c, Ct as l, D as u, Dn as d, Dt as f, E as p, En as m, Et as ee, F as te, Ft as ne, G as re, Gt as ie, H as ae, Ht as oe, I as se, It as ce, J as le, Jt as ue, K as de, Kt as fe, L as pe, Lt as me, M as he, Mn as ge, Mt as h, N as _e, Nn as ve, Nt as g, O as ye, On as be, Ot as xe, P as Se, Pn as _, Pt as Ce, Q as we, Qt as Te, R as Ee, Rt as De, S as Oe, Sn as ke, St as Ae, T as je, Tn as v, Tt as Me, U as Ne, Ut as Pe, V as Fe, Vt as y, W as Ie, Wt as Le, X as Re, Xt as ze, Y as Be, Yt as Ve, Z as He, Zt as Ue, _ as b, _n as x, _t as We, a as Ge, an as Ke, at as qe, b as Je, bn as S, bt as Ye, c as Xe, cn as Ze, ct as Qe, d as $e, dn as et, dt as tt, en as nt, et as rt, f as it, fn as at, ft as ot, g as st, gn as C, gt as ct, h as lt, hn as w, ht as ut, i as T, in as dt, it as ft, j as E, jn as pt, jt as mt, k as ht, kn as gt, kt as _t, l as vt, ln as yt, lt as bt, m as xt, mn as D, mt as St, n as Ct, nn as wt, nt as Tt, o as Et, on as Dt, ot as Ot, p as kt, pn as At, pt as jt, q as Mt, qt as Nt, r as Pt, rn as Ft, rt as It, s as Lt, sn as Rt, st as zt, t as Bt, tn as Vt, tt as Ht, u as Ut, un as Wt, ut as Gt, v as Kt, vn as O, vt as qt, w as Jt, wn as Yt, wt as Xt, x as Zt, xn as Qt, xt as $t, y as en, yn as tn, yt as nn, z as rn, zt as an } from "./html-DfrdIKTl.js";
1
+ import { $ as e, $t as t, A as n, An as r, At as i, B as a, Bt as o, C as s, Cn as c, Ct as l, D as u, Dn as d, Dt as f, E as p, En as m, Et as h, F as g, Fn as _, Ft as ee, G as te, Gt as ne, H as re, Ht as ie, I as ae, In as v, It as oe, J as se, Jt as ce, K as le, Kt as ue, L as de, Lt as y, M as fe, Mn as pe, Mt as b, N as me, Nn as he, Nt as x, O as ge, On as _e, Ot as ve, P as ye, Pn as be, Pt as xe, Q as Se, Qt as Ce, R as we, Rt as Te, S as Ee, Sn as S, St as De, T as Oe, Tn as ke, Tt as Ae, U as je, Ut as Me, V as Ne, Vt as C, W as Pe, Wt as Fe, X as Ie, Xt as Le, Y as Re, Yt as ze, Z as Be, Zt as Ve, _ as He, _n as w, _t as Ue, a as We, an as Ge, at as Ke, b as qe, bn as Je, bt as Ye, c as Xe, cn as Ze, ct as Qe, d as $e, dn as et, dt as tt, en as nt, et as rt, f as it, fn as at, ft as ot, g as st, gn as T, gt as ct, h as lt, hn as ut, ht as dt, i as E, in as ft, it as pt, j as D, jn as mt, jt as ht, k as gt, kn as O, kt as _t, l as vt, ln as yt, lt as bt, m as xt, mn as St, mt as Ct, n as wt, nn as Tt, nt as Et, o as Dt, on as Ot, ot as kt, p as At, pn as jt, pt as Mt, q as Nt, qt as Pt, r as Ft, rn as It, rt as Lt, s as Rt, sn as zt, st as Bt, t as Vt, tn as Ht, tt as Ut, u as Wt, un as Gt, ut as Kt, v as qt, vn as k, vt as Jt, w as Yt, wn as Xt, wt as Zt, x as Qt, xn as A, xt as $t, y as en, yn as j, yt as tn, z as nn, zt as rn } from "./html-kKhAILq4.js";
2
2
  //#region ../../node_modules/@tricoteuses/legifrance/dist/legal/index.js
3
- function on(e, t) {
3
+ function an(e, t) {
4
4
  if (e != null) {
5
5
  if (!Array.isArray(e)) return e;
6
6
  for (let n of e) if (n["@debut"] <= t && t <= n["@fin"]) return n;
7
7
  return e[0];
8
8
  }
9
9
  }
10
- function* k(e) {
11
- yield e, e.TM !== void 0 && (yield* k(e.TM));
10
+ function* M(e) {
11
+ yield e, e.TM !== void 0 && (yield* M(e.TM));
12
12
  }
13
13
  //#endregion
14
14
  //#region src/lib/articles.ts
15
- var A = ["2222-02-22", "2999-01-01"], sn = (e) => {
15
+ var N = ["2222-02-22", "2999-01-01"], on = (e) => {
16
16
  if (e !== void 0) for (let t = 0; t < e.length; ++t) {
17
- let n = nt(new D(e, t));
17
+ let n = nt(new T(e, t));
18
18
  if (typeof n == "string") return n;
19
19
  }
20
- }, cn = (e) => (e === void 0 ? [] : Array.isArray(e) ? e : [e]).map((e) => sn(e["#text"])).find((e) => e !== void 0), ln = (e) => {
20
+ }, sn = (e) => (e === void 0 ? [] : Array.isArray(e) ? e : [e]).map((e) => on(e["#text"])).find((e) => e !== void 0), cn = (e) => {
21
21
  let t = e.META.META_SPEC.META_ARTICLE.DATE_DEBUT;
22
- if (t !== void 0 && !A.includes(t)) return t;
23
- let n = e.CONTEXTE.TEXTE, r = n.TITRE_TXT, i = [...r === void 0 ? [] : (Array.isArray(r) ? r : [r]).map((e) => e["@debut"]), ...n.TM === void 0 ? [] : k(n.TM).map((e) => (Array.isArray(e.TITRE_TM) ? e.TITRE_TM : [e.TITRE_TM]).map((e) => e["@debut"])).toArray().flat()].filter((e) => !A.includes(e));
22
+ if (t !== void 0 && !N.includes(t)) return t;
23
+ let n = e.CONTEXTE.TEXTE, r = n.TITRE_TXT, i = [...r === void 0 ? [] : (Array.isArray(r) ? r : [r]).map((e) => e["@debut"]), ...n.TM === void 0 ? [] : M(n.TM).map((e) => (Array.isArray(e.TITRE_TM) ? e.TITRE_TM : [e.TITRE_TM]).map((e) => e["@debut"])).toArray().flat()].filter((e) => !N.includes(e));
24
24
  if (i.length > 0) return i.sort().at(-1);
25
25
  let a = n["@date_publi"];
26
- if (a !== void 0 && !A.includes(a)) return a;
26
+ if (a !== void 0 && !N.includes(a)) return a;
27
27
  let o = n["@date_signature"];
28
- if (o !== void 0 && !A.includes(o)) return o;
28
+ if (o !== void 0 && !N.includes(o)) return o;
29
29
  let s = e.META.META_SPEC.META_ARTICLE.DATE_FIN;
30
- if (s !== void 0 && !A.includes(s)) return s;
31
- let c = cn(r);
30
+ if (s !== void 0 && !N.includes(s)) return s;
31
+ let c = sn(r);
32
32
  if (c !== void 0) return c;
33
- if (A.includes(t ?? "")) return t;
33
+ if (N.includes(t ?? "")) return t;
34
34
  throw Error(`Missing date signature in article ${e.META.META_COMMUN.ID}`);
35
- }, j = (e) => {
35
+ }, P = (e) => {
36
36
  let t = e.META.META_SPEC.META_ARTICLE.DATE_DEBUT;
37
- if (t !== void 0 && !A.includes(t)) return t;
37
+ if (t !== void 0 && !N.includes(t)) return t;
38
38
  let n = e.CONTEXTE.TEXTE, r = n["@date_signature"];
39
- if (r !== void 0 && !A.includes(r)) return r;
39
+ if (r !== void 0 && !N.includes(r)) return r;
40
40
  let i = n["@date_publi"];
41
- if (i !== void 0 && !A.includes(i)) return i;
42
- let a = n.TITRE_TXT, o = [...a === void 0 ? [] : (Array.isArray(a) ? a : [a]).map((e) => e["@debut"]), ...n.TM === void 0 ? [] : k(n.TM).map((e) => (Array.isArray(e.TITRE_TM) ? e.TITRE_TM : [e.TITRE_TM]).map((e) => e["@debut"])).toArray().flat()].filter((e) => !A.includes(e));
41
+ if (i !== void 0 && !N.includes(i)) return i;
42
+ let a = n.TITRE_TXT, o = [...a === void 0 ? [] : (Array.isArray(a) ? a : [a]).map((e) => e["@debut"]), ...n.TM === void 0 ? [] : M(n.TM).map((e) => (Array.isArray(e.TITRE_TM) ? e.TITRE_TM : [e.TITRE_TM]).map((e) => e["@debut"])).toArray().flat()].filter((e) => !N.includes(e));
43
43
  if (o.length > 0) return o.sort().at(-1);
44
44
  let s = e.META.META_SPEC.META_ARTICLE.DATE_FIN;
45
- if (s !== void 0 && !A.includes(s)) return s;
46
- let c = cn(a);
45
+ if (s !== void 0 && !N.includes(s)) return s;
46
+ let c = sn(a);
47
47
  if (c !== void 0) return c;
48
- if (A.includes(t ?? "")) return t;
48
+ if (N.includes(t ?? "")) return t;
49
49
  throw Error(`Missing date signature in article ${e.META.META_COMMUN.ID}`);
50
50
  };
51
- async function un(e, t, n, r) {
52
- let i = await v(e, t, n);
51
+ async function ln(e, t, n, r) {
52
+ let i = await d(e, t, n);
53
53
  if (i === void 0) return;
54
- let a = j(i), o = i.META.META_COMMUN.ORIGINE, s = i.CONTEXTE.TEXTE;
54
+ let a = P(i), o = i.META.META_COMMUN.ORIGINE, s = i.CONTEXTE.TEXTE;
55
55
  if (s.TM === void 0) return;
56
- let c = k(s.TM).toArray().reverse(), l;
56
+ let c = M(s.TM).toArray().reverse(), l;
57
57
  switch (o) {
58
58
  case "JORF":
59
59
  l = c.map((e) => e.TITRE_TM["@id"]);
60
60
  break;
61
61
  case "LEGI":
62
- l = c.map((e) => on(e.TITRE_TM, a)?.["@id"]);
62
+ l = c.map((e) => an(e.TITRE_TM, a)?.["@id"]);
63
63
  break;
64
- default: _("getOrLoadArticleSiblingId origine", o);
64
+ default: v("getOrLoadArticleSiblingId origine", o);
65
65
  }
66
- return await (r === -1 ? N : M)(e, t, n, a, i.num, l);
66
+ return await (r === -1 ? L : I)(e, t, n, a, i.num, l);
67
67
  }
68
- async function dn(e, t, n, r, i, a) {
68
+ async function un(e, t, n, r, i, a) {
69
69
  let o = r[n];
70
70
  if (o === void 0) {
71
- let s = await d(e, t, n);
71
+ let s = await O(e, t, n);
72
72
  if (s === void 0) return;
73
73
  let c = s.STRUCTURE_TA;
74
74
  if (c === void 0) return;
@@ -96,8 +96,8 @@ async function dn(e, t, n, r, i, a) {
96
96
  }
97
97
  return o;
98
98
  }
99
- async function fn(e, t, n) {
100
- let r = await d(e, t, n);
99
+ async function F(e, t, n) {
100
+ let r = await O(e, t, n);
101
101
  if (r === void 0) return;
102
102
  let i = r.STRUCTURE_TA;
103
103
  if (i === void 0) return;
@@ -105,86 +105,86 @@ async function fn(e, t, n) {
105
105
  if (a !== void 0) return a[0]["@id"];
106
106
  let o = i.LIEN_SECTION_TA;
107
107
  if (o !== void 0) for (let n of o) {
108
- let r = await fn(e, t, n["@id"]);
108
+ let r = await F(e, t, n["@id"]);
109
109
  if (r !== void 0) return r;
110
110
  }
111
111
  }
112
- async function pn(e, t, n) {
113
- let r = await d(e, t, n);
112
+ async function dn(e, t, n) {
113
+ let r = await O(e, t, n);
114
114
  if (r === void 0) return;
115
115
  let i = r.STRUCTURE_TA;
116
116
  if (i === void 0) return;
117
117
  let a = i.LIEN_SECTION_TA;
118
118
  if (a !== void 0) for (let n of a.toReversed()) {
119
- let r = await pn(e, t, n["@id"]);
119
+ let r = await dn(e, t, n["@id"]);
120
120
  if (r !== void 0) return r;
121
121
  }
122
122
  return i.LIEN_ART?.at(-1)?.["@id"];
123
123
  }
124
- async function M(e, t, n, r, i, a, o = 0, s = {}, c = void 0) {
124
+ async function I(e, t, n, r, i, a, o = 0, s = {}, c = void 0) {
125
125
  let l = a[o];
126
126
  if (l === void 0) return;
127
- let u = await dn(e, t, l, s, n, c);
127
+ let u = await un(e, t, l, s, n, c);
128
128
  if (u === void 0) return;
129
- let { area: d, index: f, sectionTa: p } = u, m = p.STRUCTURE_TA;
130
- switch (d) {
129
+ let { area: f, index: p, sectionTa: m } = u, h = m.STRUCTURE_TA;
130
+ switch (f) {
131
131
  case "LIEN_ART": {
132
- let c = m.LIEN_ART;
133
- for (let n = f + 1; n < c.length; n++) {
132
+ let c = h.LIEN_ART;
133
+ for (let n = p + 1; n < c.length; n++) {
134
134
  let a = c[n];
135
135
  if (a["@num"] !== i) {
136
- let n = await v(e, t, a["@id"]);
137
- if (n !== void 0 && j(n) <= r) return a["@id"];
136
+ let n = await d(e, t, a["@id"]);
137
+ if (n !== void 0 && P(n) <= r) return a["@id"];
138
138
  }
139
139
  }
140
- let u = m.LIEN_SECTION_TA;
140
+ let u = h.LIEN_SECTION_TA;
141
141
  if (u !== void 0) for (let n of u) {
142
- let r = await fn(e, t, n["@id"]);
142
+ let r = await F(e, t, n["@id"]);
143
143
  if (r !== void 0) return r;
144
144
  }
145
- return await M(e, t, n, r, i, a, o + 1, s, l);
145
+ return await I(e, t, n, r, i, a, o + 1, s, l);
146
146
  }
147
147
  case "LIEN_SECTION_TA": {
148
- let c = m.LIEN_SECTION_TA;
149
- for (let n = f + 1; n < c.length; n++) {
150
- let r = await fn(e, t, c[n]["@id"]);
148
+ let c = h.LIEN_SECTION_TA;
149
+ for (let n = p + 1; n < c.length; n++) {
150
+ let r = await F(e, t, c[n]["@id"]);
151
151
  if (r !== void 0) return r;
152
152
  }
153
- return await M(e, t, n, r, i, a, o + 1, s, l);
153
+ return await I(e, t, n, r, i, a, o + 1, s, l);
154
154
  }
155
- default: _("moveToNextArticleId area", d);
155
+ default: v("moveToNextArticleId area", f);
156
156
  }
157
157
  }
158
- async function N(e, t, n, r, i, a, o = 0, s = {}, c = void 0) {
158
+ async function L(e, t, n, r, i, a, o = 0, s = {}, c = void 0) {
159
159
  let l = a[o];
160
160
  if (l === void 0) return;
161
- let u = await dn(e, t, l, s, n, c);
161
+ let u = await un(e, t, l, s, n, c);
162
162
  if (u === void 0) return;
163
- let { area: d, index: f, sectionTa: p } = u, m = p.STRUCTURE_TA;
164
- switch (d) {
163
+ let { area: f, index: p, sectionTa: m } = u, h = m.STRUCTURE_TA;
164
+ switch (f) {
165
165
  case "LIEN_ART": {
166
- let c = m.LIEN_ART;
167
- for (let n = f - 1; n >= 0; n--) {
166
+ let c = h.LIEN_ART;
167
+ for (let n = p - 1; n >= 0; n--) {
168
168
  let a = c[n];
169
169
  if (a["@num"] !== i) {
170
- let n = await v(e, t, a["@id"]);
171
- if (n !== void 0 && j(n) <= r) return a["@id"];
170
+ let n = await d(e, t, a["@id"]);
171
+ if (n !== void 0 && P(n) <= r) return a["@id"];
172
172
  }
173
173
  }
174
- return await N(e, t, n, r, i, a, o + 1, s, l);
174
+ return await L(e, t, n, r, i, a, o + 1, s, l);
175
175
  }
176
176
  case "LIEN_SECTION_TA": {
177
- for (let n = f - 1; n >= 0; n--) {
178
- let r = await pn(e, t, m.LIEN_SECTION_TA[n]["@id"]);
177
+ for (let n = p - 1; n >= 0; n--) {
178
+ let r = await dn(e, t, h.LIEN_SECTION_TA[n]["@id"]);
179
179
  if (r !== void 0) return r;
180
180
  }
181
- let c = m.LIEN_ART;
182
- return c === void 0 ? await N(e, t, n, r, i, a, o + 1, s, l) : (u.area = "LIEN_ART", u.index = c.length, await N(e, t, n, r, i, a, o, s));
181
+ let c = h.LIEN_ART;
182
+ return c === void 0 ? await L(e, t, n, r, i, a, o + 1, s, l) : (u.area = "LIEN_ART", u.index = c.length, await L(e, t, n, r, i, a, o, s));
183
183
  }
184
- default: _("moveToPreviousArticleId area", d);
184
+ default: v("moveToPreviousArticleId area", f);
185
185
  }
186
186
  }
187
- var mn = (e) => (t, n) => {
187
+ var fn = (e) => (t, n) => {
188
188
  let r = e(t), i = e(n);
189
189
  if (r !== i) return r.localeCompare(i);
190
190
  let a = t.META.META_COMMUN, o = a.ORIGINE, s = n.META.META_COMMUN, c = s.ORIGINE;
@@ -203,13 +203,13 @@ var mn = (e) => (t, n) => {
203
203
  if (m <= i) return 1;
204
204
  }
205
205
  throw Error(`TODO: Unable to sort articles ${a.ID} & ${s.ID} by date.`);
206
- }, hn = new Intl.DateTimeFormat("fr-FR", { dateStyle: "long" });
207
- function gn(e) {
208
- return hn.format(new Date(e)).replace(/^1 /, "1er ");
206
+ }, pn = new Intl.DateTimeFormat("fr-FR", { dateStyle: "long" });
207
+ function mn(e) {
208
+ return pn.format(new Date(e)).replace(/^1 /, "1er ");
209
209
  }
210
210
  //#endregion
211
211
  //#region src/lib/extractors/article_portions.ts
212
- var P = /^\s*([IVXLCDM]+|[A-Z]|[a-z]|\d+)(?:\s*(?:°|\.|\)|-|–|—))+(?:\s+|(?=\p{L}))/u, _n = /^\s*(partie|livre|titre|sous-titre|chapitre|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe)\s+([IVXLCDM]+|[A-Z]|\d+)(?:\s*(?:°|\.|\)|-))?\s*/iu, vn = /^(partie|livre|titre|sous-titre|chapitre|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe)\b/i, yn = {
212
+ var R = new RegExp(String.raw`^\s*([IVXLCDM]+|[A-Z]|[a-z]|\d+)(?:\s+(?:${Ge}))?(?:\s*(?:°|\.|\)|-|–|—))+(?:\s+(?:${Ge}))?(?:\s+|(?=[\p{L}\p{N}]))`, "iu"), hn = /^\s*(partie|livre|titre|sous-titre|chapitre|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe)\s+([IVXLCDM]+|[A-Z]|\d+)(?:\s*(?:°|\.|\)|-))?\s*/iu, gn = /^(partie|livre|titre|sous-titre|chapitre|section|sous-section|paragraphe|sous-paragraphe|sous-sous-paragraphe)\b/i, _n = {
213
213
  partie: 0,
214
214
  livre: 1,
215
215
  titre: 2,
@@ -221,10 +221,17 @@ var P = /^\s*([IVXLCDM]+|[A-Z]|[a-z]|\d+)(?:\s*(?:°|\.|\)|-|–|—))+(?:\s+|(?
221
221
  "sous-paragraphe": 8,
222
222
  "sous-sous-paragraphe": 9
223
223
  };
224
- function F(e) {
224
+ function z(e) {
225
225
  return /^[IVXLCDM]+$/i.test(e);
226
226
  }
227
- function bn(e) {
227
+ function vn(e) {
228
+ let t = A(e, Ue);
229
+ return t && typeof t == "object" && t.type === "item" && typeof t.index == "number" && typeof t.num == "string" ? {
230
+ num: t.num,
231
+ index: t.index
232
+ } : null;
233
+ }
234
+ function yn(e) {
228
235
  let t = {
229
236
  I: 1,
230
237
  V: 5,
@@ -241,18 +248,29 @@ function bn(e) {
241
248
  }
242
249
  return n || void 0;
243
250
  }
244
- function I(e) {
245
- if (/^\d+$/.test(e)) return Number(e);
246
- if (/^[A-Z]$/i.test(e)) return e.toLowerCase().charCodeAt(0) - 97 + 1;
247
- if (F(e)) return bn(e);
251
+ function B(e) {
252
+ let t = e.trim(), n = t.split(/\s+/), r = n[0] ? n[0].replace(/[^\p{L}\p{N}]+/gu, "") : t, i = n.length > 1 ? n.slice(1).join(" ") : void 0, a = (() => {
253
+ if (/^\d+$/.test(r)) return Number(r);
254
+ if (/^[A-Z]$/i.test(r)) return r.toLowerCase().charCodeAt(0) - 97 + 1;
255
+ if (z(r)) return yn(r);
256
+ })();
257
+ if (a === void 0) return;
258
+ if (!i) return a;
259
+ let o = A(i, ft);
260
+ if (o && typeof o == "object" && "value" in o) {
261
+ let e = o.value;
262
+ if (typeof e == "number") return a + e / 1e3;
263
+ }
264
+ return a;
248
265
  }
249
- function xn(e) {
250
- return F(e) ? 100 : /^[A-Z]$/.test(e) ? 101 : /^\d+$/.test(e) ? 102 : /^[a-z]$/.test(e) ? 103 : 104;
266
+ function bn(e) {
267
+ let t = e.trim().split(/\s+/)[0] ?? e, n = t.replace(/[^\p{L}\p{N}]+/gu, "");
268
+ return /^[ivxlcdm]+$/.test(n) && (n.length > 1 || /^[ivx]$/.test(n)) ? 105 : /^[A-Z]$/.test(n) ? 101 : /^\d+$/.test(n) && /°/.test(t) ? 103 : /^\d+$/.test(n) ? 102 : /^[a-z]$/.test(n) ? 104 : z(n) ? 100 : 105;
251
269
  }
252
- function L(e) {
270
+ function V(e) {
253
271
  return e.children.filter((e) => e.type === "alinéa").length + 1;
254
272
  }
255
- function Sn(t) {
273
+ function xn(t) {
256
274
  let n = e(t), r = {
257
275
  type: "article",
258
276
  children: []
@@ -283,36 +301,36 @@ function Sn(t) {
283
301
  let l = (e, n, r) => {
284
302
  let a = e, o = n;
285
303
  for (;;) {
286
- let e = o.match(P);
304
+ let e = o.match(R);
287
305
  if (!e) break;
288
- let t = e[1], n = {
306
+ let t = vn(e[0]), n = t?.num ?? e[1], r = {
289
307
  type: "item",
290
- index: I(t),
291
- num: t,
308
+ index: t?.index ?? B(n),
309
+ num: n,
292
310
  label: void 0,
293
311
  children: []
294
312
  };
295
- a.children.push(n), i.push({
296
- level: xn(t),
297
- node: n
298
- }), a = n, o = o.slice(e[0].length).trim();
313
+ a.children.push(r), i.push({
314
+ level: bn(n),
315
+ node: r
316
+ }), a = r, o = o.slice(e[0].length).trim();
299
317
  }
300
318
  o && a.children.push({
301
319
  type: "alinéa",
302
- index: L(a),
320
+ index: V(a),
303
321
  text: o,
304
322
  html: r,
305
323
  paragraphIndex: t
306
324
  });
307
325
  };
308
326
  for (let e of c) {
309
- let n = e.text, a = n.match(_n);
327
+ let n = e.text, a = n.match(hn);
310
328
  if (a) {
311
- let o = a[1].toLowerCase(), s = a[2], c = yn[o];
329
+ let o = a[1].toLowerCase(), s = a[2], c = _n[o];
312
330
  for (; i.length > 0 && i[i.length - 1].level >= c;) i.pop();
313
331
  let u = i[i.length - 1]?.node ?? r, d = {
314
332
  type: o,
315
- index: I(s),
333
+ index: B(s),
316
334
  num: s,
317
335
  label: void 0,
318
336
  children: []
@@ -322,35 +340,35 @@ function Sn(t) {
322
340
  node: d
323
341
  });
324
342
  let f = n.slice(a[0].length).trim();
325
- f && (vn.test(f) ? d.label = f : P.test(f) ? l(d, f, e.html) : d.children.push({
343
+ f && (gn.test(f) ? d.label = f : R.test(f) ? l(d, f, e.html) : d.children.push({
326
344
  type: "alinéa",
327
- index: L(d),
345
+ index: V(d),
328
346
  text: f,
329
347
  html: e.html,
330
348
  paragraphIndex: t
331
349
  }));
332
350
  continue;
333
351
  }
334
- let o = n.match(P);
352
+ let o = n.match(R);
335
353
  if (o) {
336
- let a = o[1], s = xn(a);
337
- for (; i.length > 0 && i[i.length - 1].level >= s;) i.pop();
338
- let c = i[i.length - 1]?.node ?? r, u = {
354
+ let a = vn(o[0]), s = a?.num ?? o[1], c = bn(s);
355
+ for (; i.length > 0 && i[i.length - 1].level >= c;) i.pop();
356
+ let u = i[i.length - 1]?.node ?? r, d = {
339
357
  type: "item",
340
- index: I(a),
341
- num: a,
358
+ index: a?.index ?? B(s),
359
+ num: s,
342
360
  label: void 0,
343
361
  children: []
344
362
  };
345
- c.children.push(u), i.push({
346
- level: s,
347
- node: u
363
+ u.children.push(d), i.push({
364
+ level: c,
365
+ node: d
348
366
  });
349
- let d = n.slice(o[0].length).trim();
350
- d && (vn.test(d) ? u.label = d : P.test(d) ? l(u, d, e.html) : u.children.push({
367
+ let f = n.slice(o[0].length).trim();
368
+ f && (gn.test(f) ? d.label = f : R.test(f) ? l(d, f, e.html) : d.children.push({
351
369
  type: "alinéa",
352
- index: L(u),
353
- text: d,
370
+ index: V(d),
371
+ text: f,
354
372
  html: e.html,
355
373
  paragraphIndex: t
356
374
  }));
@@ -359,7 +377,7 @@ function Sn(t) {
359
377
  let s = i[i.length - 1]?.node ?? r;
360
378
  s.children.push({
361
379
  type: "alinéa",
362
- index: L(s),
380
+ index: V(s),
363
381
  text: n,
364
382
  html: e.html,
365
383
  paragraphIndex: t
@@ -367,8 +385,8 @@ function Sn(t) {
367
385
  }
368
386
  }), r;
369
387
  }
370
- function R(e) {
371
- return e.type === "parent-enfant" ? [...R(e.parent), ...R(e.child)] : ie(e) && (fe(e) || Nt(e)) ? [{
388
+ function H(e) {
389
+ return e.type === "parent-enfant" ? [...H(e.parent), ...H(e.child)] : ne(e) && (ue(e) || Pt(e)) ? [{
372
390
  type: e.type,
373
391
  index: e.index,
374
392
  num: e.num,
@@ -376,10 +394,41 @@ function R(e) {
376
394
  present: e.present
377
395
  }] : [];
378
396
  }
379
- function z(e) {
380
- if (e.type === "reference_et_action") return z(e.reference);
397
+ function U(e) {
398
+ if (e.type === "reference_et_action") return U(e.reference);
399
+ if (e.type === "parent-enfant") {
400
+ let t = U(e.parent), n = U(e.child);
401
+ if (t.length === 0) return n;
402
+ if (n.length === 0) return t;
403
+ let r = [];
404
+ for (let e of t) for (let t of n) {
405
+ if (e.kind === "single" && t.kind === "single") {
406
+ r.push({
407
+ kind: "single",
408
+ steps: [...e.steps, ...t.steps]
409
+ });
410
+ continue;
411
+ }
412
+ if (e.kind === "single" && t.kind === "range") {
413
+ r.push({
414
+ kind: "range",
415
+ first: [...e.steps, ...t.first],
416
+ last: [...e.steps, ...t.last],
417
+ count: t.count
418
+ });
419
+ continue;
420
+ }
421
+ e.kind === "range" && t.kind === "single" && r.push({
422
+ kind: "range",
423
+ first: [...e.first, ...t.steps],
424
+ last: [...e.last, ...t.steps],
425
+ count: e.count
426
+ });
427
+ }
428
+ return r;
429
+ }
381
430
  if (e.type === "bounded-interval") {
382
- let t = R(e.first), n = R(e.last);
431
+ let t = H(e.first), n = H(e.last);
383
432
  return t.length === 0 || n.length === 0 ? [] : [{
384
433
  kind: "range",
385
434
  first: t,
@@ -387,7 +436,7 @@ function z(e) {
387
436
  }];
388
437
  }
389
438
  if (e.type === "counted-interval") {
390
- let t = R(e.first);
439
+ let t = H(e.first);
391
440
  return t.length === 0 ? [] : [{
392
441
  kind: "range",
393
442
  first: t,
@@ -395,16 +444,16 @@ function z(e) {
395
444
  count: e.count
396
445
  }];
397
446
  }
398
- if (e.type === "enumeration") return [...z(e.left), ...z(e.right)];
399
- if (e.type === "exclusion") return z(e.left);
400
- let t = R(e);
447
+ if (e.type === "enumeration") return [...U(e.left), ...U(e.right)];
448
+ if (e.type === "exclusion") return U(e.left);
449
+ let t = H(e);
401
450
  return t.length === 0 ? [] : [{
402
451
  kind: "single",
403
452
  steps: t
404
453
  }];
405
454
  }
406
- function Cn(e) {
407
- let t = z(e);
455
+ function Sn(e) {
456
+ let t = U(e);
408
457
  if (t.length === 0) return t;
409
458
  let n = t[0];
410
459
  if (n?.kind === "single" && n.steps.length > 1) {
@@ -416,19 +465,18 @@ function Cn(e) {
416
465
  }
417
466
  return t;
418
467
  }
419
- function wn(e, t) {
420
- if (t.index !== void 0 && e.index !== void 0) return t.index === e.index;
468
+ function Cn(e, t) {
421
469
  if (t.num !== void 0 && e.num !== void 0) {
422
- let n = (e) => e.toLowerCase().replace(/[°.]/g, "").trim();
423
- return n(t.num) === n(e.num);
470
+ let n = (e) => e.toLowerCase().replace(/[.)]/g, "").trim();
471
+ if (n(t.num) !== n(e.num)) return !1;
424
472
  }
425
- return !1;
473
+ return t.index !== void 0 && e.index !== void 0 ? t.index === e.index : t.num !== void 0 && e.num !== void 0;
426
474
  }
427
- function Tn(e, t) {
428
- let n = (e) => "children" in e && (e.type === "article" || e.type === "item" || y.includes(e.type)) ? e.children : [], r = (e) => e.type === "alinéa" ? [e] : e.type === "article" || e.type === "item" || y.includes(e.type) ? e.children.flatMap(r) : [];
429
- if (y.includes(t.type)) {
475
+ function wn(e, t) {
476
+ let n = (e) => "children" in e && (e.type === "article" || e.type === "item" || C.includes(e.type)) ? e.children : [], r = (e) => e.type === "alinéa" ? [e] : e.type === "article" || e.type === "item" || C.includes(e.type) ? e.children.flatMap(r) : [];
477
+ if (C.includes(t.type)) {
430
478
  let r = n(e);
431
- for (let e of r) if (y.includes(e.type) && e.type === t.type && wn(e, t)) return {
479
+ for (let e of r) if (C.includes(e.type) && e.type === t.type && Cn(e, t)) return {
432
480
  node: e,
433
481
  path: [e]
434
482
  };
@@ -436,13 +484,13 @@ function Tn(e, t) {
436
484
  }
437
485
  if (t.type === "item") {
438
486
  let r = n(e);
439
- for (let e of r) if (e.type === "item" && wn(e, t)) return {
487
+ for (let e of r) if (e.type === "item" && Cn(e, t)) return {
440
488
  node: e,
441
489
  path: [e]
442
490
  };
443
491
  for (let e of r) {
444
492
  if (e.type === "alinéa") continue;
445
- let n = Tn(e, t);
493
+ let n = wn(e, t);
446
494
  if (n) return {
447
495
  node: n.node,
448
496
  path: [e, ...n.path]
@@ -467,29 +515,34 @@ function Tn(e, t) {
467
515
  return null;
468
516
  }
469
517
  if (t.type === "phrase") {
470
- if (e.type !== "alinéa" || t.index === void 0) return null;
471
- let n = e.text.split(/(?<=[.!?;:])\s+/).map((e) => e.trim()).filter(Boolean), r = t.index, i = r < 0 ? n.length + r + 1 : r;
472
- if (i < 1 || i > n.length) return null;
473
- let a = n[i - 1];
518
+ if (t.index === void 0) return null;
519
+ let r = e.type === "alinéa" ? [e] : n(e).filter((e) => e.type === "alinéa");
520
+ if (r.length === 0) return null;
521
+ let i = r.flatMap((e) => e.text.split(/(?<=[.!?;:])\s+/).map((e) => e.trim()).filter(Boolean).map((t) => ({
522
+ alinea: e,
523
+ text: t
524
+ }))), a = t.index, o = a < 0 ? i.length + a + 1 : a;
525
+ if (o < 1 || o > i.length) return null;
526
+ let s = i[o - 1];
474
527
  return {
475
528
  node: {
476
529
  type: "alinéa",
477
- index: e.index,
478
- text: a,
479
- html: e.html,
480
- paragraphIndex: e.paragraphIndex
530
+ index: s.alinea.index,
531
+ text: s.text,
532
+ html: s.alinea.html,
533
+ paragraphIndex: s.alinea.paragraphIndex
481
534
  },
482
- path: [e]
535
+ path: [s.alinea]
483
536
  };
484
537
  }
485
538
  return null;
486
539
  }
487
- function B(e, t) {
540
+ function Tn(e, t) {
488
541
  if (t.kind === "range") {
489
- let n = B(e, {
542
+ let n = Tn(e, {
490
543
  kind: "single",
491
544
  steps: t.first
492
- }), r = B(e, {
545
+ }), r = Tn(e, {
493
546
  kind: "single",
494
547
  steps: t.last
495
548
  });
@@ -503,7 +556,7 @@ function B(e, t) {
503
556
  }
504
557
  let n = e, r = [];
505
558
  for (let e of t.steps) {
506
- let t = Tn(n, e);
559
+ let t = wn(n, e);
507
560
  if (!t) return null;
508
561
  n = t.node, r.push(...t.path);
509
562
  }
@@ -515,11 +568,11 @@ function B(e, t) {
515
568
  }
516
569
  //#endregion
517
570
  //#region src/lib/extractors/action_directives.ts
518
- function V(e) {
571
+ function W(e) {
519
572
  return e.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
520
573
  }
521
- function H(e) {
522
- return e.replace(P, "");
574
+ function G(e) {
575
+ return e.replace(R, "");
523
576
  }
524
577
  function En(e) {
525
578
  let t = e.split("\n"), n = [], r = 0;
@@ -534,124 +587,245 @@ function En(e) {
534
587
  return n;
535
588
  }
536
589
  function Dn(e) {
537
- return P.test(e);
590
+ return R.test(e);
538
591
  }
539
592
  function On(e) {
540
- let t = P.exec(e);
593
+ let t = R.exec(e);
541
594
  if (!t) return null;
542
595
  let n = t[1] ?? "";
543
596
  return n ? /^\d+$/.test(n) ? {
544
597
  marker: n,
545
598
  level: 2
546
- } : F(n) ? {
599
+ } : /^[ivxlcdm]+$/.test(n) && (n.length > 1 || /^[ivx]$/.test(n)) ? {
547
600
  marker: n,
548
- level: 1
601
+ level: 4
549
602
  } : /^[a-z]$/.test(n) ? {
550
603
  marker: n,
551
604
  level: 3
552
- } : (/^[A-Z]$/.test(n), {
605
+ } : z(n) || /^[A-Z]$/.test(n) ? {
606
+ marker: n,
607
+ level: 1
608
+ } : {
553
609
  marker: n,
554
610
  level: 2
555
- }) : null;
611
+ } : null;
556
612
  }
557
613
  function kn(e) {
558
- if (!e.trim().endsWith(":")) return !1;
559
- let t = V(e);
560
- return /\bainsi\s+modifie/.test(t);
561
- }
562
- function U(e) {
563
- return /\b(inséré|insere|ajouté|ajoute|remplacé|remplace|supprimé|supprime|abrogé|abroge|complété|complete)\b/i.exec(e)?.index ?? null;
564
- }
565
- function W(e) {
566
- return e.type === "reference_et_action" ? e.reference : e;
614
+ let t = W(e), n = /(?:^|[^\p{L}])(insere(?:e|es|s)?|ajoute(?:e|es|s)?|remplace(?:e|es|s)?|supprime(?:e|es|s)?|abroge(?:e|es|s)?|complete(?:e|es|s)?|retabli(?:e|es|s)?)(?=$|[^\p{L}])/u.exec(t);
615
+ return n ? (n.index ?? 0) + (n[0].length - n[1].length) : null;
567
616
  }
568
617
  function An(e) {
569
- return s(new D(e)).map(W).find((e) => h(e) === "article") || (Vn(e)?.reference ?? null);
618
+ return e.type === "reference_et_action" ? e.reference : e;
570
619
  }
571
620
  function jn(e) {
572
- let t = U(e) ?? e.length, n = G(e);
573
- return s(new D(e)).map(W).filter((e) => !K(e.position, n) && h(e) !== "article" && (e.position?.start ?? 0) < t).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0))[0] ?? null;
621
+ return s(new T(e)).map(An).find((e) => b(e) === "article") || (cr(e)?.reference ?? null);
574
622
  }
575
623
  function Mn(e) {
576
- let t = U(e) ?? e.length, n = G(e), r = s(new D(e)).map(W).filter((e) => !K(e.position, n) && (e.position?.start ?? 0) < t).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0));
577
- return r.length === 0 ? null : r.find((e) => h(e) !== "article") ?? null ?? r[0] ?? null;
624
+ let t = kn(e) ?? e.length, n = Qn(e), r = s(new T(e)).map(An).filter((e) => !$n(e.position, n) && b(e) !== "article" && (e.position?.start ?? 0) < t).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0));
625
+ if (r[0]) return r[0];
626
+ let i = e.slice(0, t).trimEnd();
627
+ return J(i, 0) ?? J(i.replace(/\b(?:est|sont)\s*$/iu, "").trimEnd(), 0);
578
628
  }
579
629
  function Nn(e) {
580
- let t = En(e), n = t.findIndex((e) => kn(e.text));
581
- if (n === -1) return null;
582
- let r = An(t[n]?.text ?? ""), i = [], a = null;
583
- for (let e = n + 1; e < t.length; e += 1) {
584
- let n = t[e];
585
- if (n) {
586
- if (Dn(n.text)) {
587
- a && i.push(a), a = {
588
- lines: [n],
589
- start: n.start,
590
- end: n.end
591
- };
592
- continue;
630
+ let t = kn(e) ?? e.length, n = Qn(e), r = s(new T(e)).map(An).filter((e) => !$n(e.position, n) && (e.position?.start ?? 0) < t).sort((e, t) => (e.position?.start ?? 0) - (t.position?.start ?? 0));
631
+ return r.length === 0 ? null : r.find((e) => b(e) !== "article") ?? null ?? r[0] ?? null;
632
+ }
633
+ function Pn(e) {
634
+ let t = [e, G(e)].map((e) => e.trim()).filter((e, t, n) => e && n.indexOf(e) === t);
635
+ for (let e of t) {
636
+ let t = J(e, 0) ?? or(e) ?? Nn(e) ?? jn(e);
637
+ if (t) return t;
638
+ }
639
+ return null;
640
+ }
641
+ function Fn(e) {
642
+ return e?.toLowerCase().replace(/[.)]/g, "").trim();
643
+ }
644
+ function In(e, t) {
645
+ return !(e.type !== t.type || e.index !== void 0 && t.index !== void 0 && e.index !== t.index || e.num !== void 0 && t.num !== void 0 && Fn(e.num) !== Fn(t.num));
646
+ }
647
+ function Ln(e) {
648
+ let t = null;
649
+ for (let n of y(e)) t = n;
650
+ return t;
651
+ }
652
+ function Rn(e, t) {
653
+ return t && e.type === "parent-enfant" && In(e.parent, t) ? e.child : e;
654
+ }
655
+ function zn(e, t) {
656
+ let n = null;
657
+ for (let r of y(e)) r.type === t && r.relative === void 0 && (r.index === void 0 && r.num === void 0 || (n = r));
658
+ return n;
659
+ }
660
+ function Bn(e, t) {
661
+ if (!t) return e;
662
+ let n = structuredClone(e), r = (e) => {
663
+ if (e.type !== "parent-enfant" && e.type !== "bounded-interval" && e.type !== "counted-interval" && e.type !== "enumeration" && e.type !== "exclusion" && e.type !== "reference_et_action") {
664
+ if (e.relative === 0) {
665
+ let n = zn(t, e.type);
666
+ n && (e.index = n.index, e.num = n.num, delete e.relative);
593
667
  }
594
- a && (a.lines.push(n), a.end = n.end);
668
+ return;
669
+ }
670
+ switch (e.type) {
671
+ case "parent-enfant":
672
+ r(e.parent), r(e.child);
673
+ break;
674
+ case "bounded-interval":
675
+ r(e.first), r(e.last);
676
+ break;
677
+ case "counted-interval":
678
+ r(e.first);
679
+ break;
680
+ case "enumeration":
681
+ case "exclusion":
682
+ r(e.left), r(e.right);
683
+ break;
684
+ case "reference_et_action":
685
+ r(e.reference);
686
+ break;
595
687
  }
688
+ };
689
+ return r(n), n;
690
+ }
691
+ function Vn(e) {
692
+ let t = (e) => {
693
+ if (e.type !== "parent-enfant" && e.type !== "bounded-interval" && e.type !== "counted-interval" && e.type !== "enumeration" && e.type !== "exclusion" && e.type !== "reference_et_action") return e.relative !== void 0;
694
+ switch (e.type) {
695
+ case "parent-enfant": return t(e.parent) || t(e.child);
696
+ case "bounded-interval": return t(e.first) || t(e.last);
697
+ case "counted-interval": return t(e.first);
698
+ case "enumeration":
699
+ case "exclusion": return t(e.left) || t(e.right);
700
+ case "reference_et_action": return t(e.reference);
701
+ }
702
+ };
703
+ return t(e);
704
+ }
705
+ function Hn(e) {
706
+ let t = [], n = [];
707
+ for (let r of e) {
708
+ if (!Dn(r.text)) {
709
+ n[n.length - 1]?.body.push(r);
710
+ continue;
711
+ }
712
+ let e = On(r.text)?.level ?? 0, i = {
713
+ body: [],
714
+ children: [],
715
+ level: e,
716
+ line: r
717
+ };
718
+ for (; n.length > 0 && n[n.length - 1].level >= e;) n.pop();
719
+ n.length === 0 ? t.push(i) : n[n.length - 1]?.children.push(i), n.push(i);
596
720
  }
597
- if (a && i.push(a), i.length === 0) return null;
598
- let o = [], s = [];
599
- for (let e of i) {
600
- let t = e.lines.map((e) => e.text);
601
- if (t.length === 0) continue;
602
- let n = On(t[0] ?? "")?.level ?? 0;
603
- t[0] = H(t[0] ?? "");
604
- let i = t.join("\n").trim();
605
- if (!i) continue;
606
- for (; s.length > 0 && s[s.length - 1].level >= n;) s.pop();
607
- let a = jn(i);
608
- if (U(i) === null && i.trim().endsWith(":")) {
609
- let e = Mn(i);
610
- e && n > 0 && s.push({
611
- level: n,
612
- reference: e
613
- });
721
+ return t;
722
+ }
723
+ function Un(e, t) {
724
+ if (!e) return t;
725
+ if (!t) return e;
726
+ let n = Rn(t, Ln(e));
727
+ return n.type === "article" || b(n), x(e, n);
728
+ }
729
+ function Wn(e) {
730
+ return [G(e.line.text), ...e.body.map((e) => e.text)].join("\n").trim();
731
+ }
732
+ function Gn(e) {
733
+ return e.body[e.body.length - 1]?.end ?? e.line.end;
734
+ }
735
+ function Kn(e, t) {
736
+ let n = [], r = t;
737
+ for (let i of e) {
738
+ let e = G(i.line.text), a = Wn(i);
739
+ if (!a) continue;
740
+ let o = Pn(e), s = Un(t, o), c = kn(a) !== null;
741
+ if (i.children.length > 0) {
742
+ let e = s ?? t, a = Kn(i.children, e);
743
+ a.length > 0 && (n.push(...a), r = a[a.length - 1]?.reference ?? r);
744
+ continue;
745
+ }
746
+ if (!c) {
747
+ r = s ?? r;
614
748
  continue;
615
749
  }
616
- let c = r;
617
- for (let e of s) c = c ? g(c, e.reference) : e.reference;
618
- if (c ||= An(i), a && n > 0 && (c = c ? a.type === "article" || h(a) === "article" ? g(a, c) : g(c, a) : a), !c) continue;
619
- let l = Y({
750
+ let l = jn(a), u = Un(t, Mn(a) ?? l ?? o) ?? l ?? s;
751
+ if (!u) continue;
752
+ u = Bn(u, Vn(u) ? r ?? t : t);
753
+ let d = Y({
620
754
  action: { action: "modifier" },
621
- reference: c,
755
+ reference: u,
622
756
  sourcePosition: {
623
- start: e.start,
624
- stop: e.end
757
+ start: i.line.start,
758
+ stop: Gn(i)
625
759
  },
626
- sourceText: i
760
+ sourceText: a
627
761
  });
628
- l && o.push(l);
762
+ if (!d) {
763
+ r = u;
764
+ continue;
765
+ }
766
+ Array.isArray(d) ? n.push(...d) : n.push(d), r = u;
629
767
  }
630
- return o.length > 0 ? o : null;
768
+ return n;
631
769
  }
632
- function Pn(e) {
770
+ function qn(e) {
771
+ let t = En(e), n = t.findIndex((e) => Dn(e.text));
772
+ if (n === -1) return null;
773
+ let r = t.slice(0, n).reverse().map((e) => Pn(e.text)).find((e) => e !== null) ?? null, i = Kn(Hn(t.slice(n)), r);
774
+ return i.length > 0 ? i : null;
775
+ }
776
+ function Jn(e) {
633
777
  return e.split(/\n+/).map((e) => e.replace(/^\s*[«“"]\s*/u, "").trim()).filter((e) => e.length > 0).join("\n").replace(/[»”"]\s*$/u, "").trim();
634
778
  }
635
- function Fn(e) {
779
+ function Yn(e) {
636
780
  let t = [], n = 0;
637
781
  for (; n < e.length;) {
638
782
  let r = e.indexOf("«", n);
639
783
  if (r === -1) break;
640
- let i = new D(e);
784
+ let i = new T(e);
641
785
  i.offset = r;
642
- let a = Be(i);
786
+ let a = Re(i);
643
787
  if (!a) {
644
788
  n = r + 1;
645
789
  continue;
646
790
  }
647
- let o = we(i, a);
648
- t.push(Pn(o.output));
649
- let s = a.position?.stop ?? r + 1;
650
- n = Math.max(s, r + 1);
791
+ let o = Jn(Se(i, a).output), s = a.position ?? {
792
+ start: r,
793
+ stop: r + 1
794
+ };
795
+ t.push({
796
+ text: o,
797
+ start: s.start,
798
+ end: s.stop
799
+ });
800
+ let c = s.stop ?? r + 1;
801
+ n = Math.max(c, r + 1);
651
802
  }
652
803
  return t;
653
804
  }
654
- function G(e) {
805
+ function Xn(e) {
806
+ let t = e.trim();
807
+ if (!t) return null;
808
+ let n = Tt(new T(t));
809
+ if (typeof n == "number") return n;
810
+ if (n && typeof n == "object" && "value" in n) {
811
+ let e = n.value;
812
+ return Number.isFinite(e) ? e : null;
813
+ }
814
+ let r = Ot(new T(t));
815
+ if (r && typeof r == "object" && "value" in r) {
816
+ let e = r.value;
817
+ return Number.isFinite(e) ? e : null;
818
+ }
819
+ return typeof r == "number" ? r : null;
820
+ }
821
+ function Zn(e, t) {
822
+ let n = e.slice(0, t), r = /([0-9A-Za-zÀ-ÖØ-öø-ÿ'’.-]+)\s+occurrence\b/giu, i = null, a;
823
+ for (; (a = r.exec(n)) !== null;) i = a;
824
+ if (!i) return null;
825
+ let o = i[1], s = Xn(o);
826
+ return !s || s < 1 ? null : s;
827
+ }
828
+ function Qn(e) {
655
829
  let t = [], n = 0;
656
830
  for (; n < e.length;) {
657
831
  let r = e.indexOf("«", n);
@@ -671,10 +845,10 @@ function G(e) {
671
845
  }
672
846
  return t;
673
847
  }
674
- function K(e, t) {
848
+ function $n(e, t) {
675
849
  return e ? t.some((t) => e.start >= t.start && e.stop <= t.end) : !1;
676
850
  }
677
- function In(e) {
851
+ function er(e) {
678
852
  if (!e.includes("«")) return e;
679
853
  let t = e.split(""), n = !1;
680
854
  for (let e = 0; e < t.length; e++) {
@@ -691,109 +865,180 @@ function In(e) {
691
865
  }
692
866
  return t.join("");
693
867
  }
694
- function q(e, t) {
868
+ function K(e, t) {
695
869
  e && (e.start += t, e.stop += t);
696
870
  }
697
- function J(e, t) {
871
+ function q(e, t) {
698
872
  if (e.type === "parent-enfant") {
699
- J(e.parent, t), J(e.child, t), q(e.position, t);
873
+ q(e.parent, t), q(e.child, t), K(e.position, t);
700
874
  return;
701
875
  }
702
876
  if (e.type === "bounded-interval") {
703
- J(e.first, t), J(e.last, t), q(e.position, t);
877
+ q(e.first, t), q(e.last, t), K(e.position, t);
704
878
  return;
705
879
  }
706
880
  if (e.type === "counted-interval") {
707
- J(e.first, t), q(e.position, t);
881
+ q(e.first, t), K(e.position, t);
708
882
  return;
709
883
  }
710
884
  if (e.type === "enumeration" || e.type === "exclusion") {
711
- J(e.left, t), J(e.right, t), q(e.position, t);
885
+ q(e.left, t), q(e.right, t), K(e.position, t);
712
886
  return;
713
887
  }
714
888
  if (e.type === "reference_et_action") {
715
- J(e.reference, t), q(e.position, t);
889
+ q(e.reference, t), K(e.position, t);
716
890
  return;
717
891
  }
718
- q(e.position, t);
892
+ K(e.position, t);
719
893
  }
720
- function Ln(e) {
894
+ function tr(e) {
721
895
  return e.replace(/\b(de\s+l['’]?|de\s+la|de\s+le|du|des)\s*$/i, "");
722
896
  }
723
- function Rn(e, t) {
724
- let n = Ln(e);
897
+ function nr(e) {
898
+ let t = W(e);
899
+ return t.startsWith("alinea") ? "alinéa" : t.startsWith("phrase") ? "phrase" : null;
900
+ }
901
+ function rr(e) {
902
+ let t = /^(?:(?:[aà]\s+)?l['’]|(?:[aà]\s+)?la\b|(?:[aà]\s+)?le\b|les\b|des\b|aux\b|du\b)\s*/iu.exec(e)?.[0].length ?? 0, n = e.slice(t > 0 ? t : 0).trim();
903
+ return n ? {
904
+ text: n,
905
+ offset: t
906
+ } : null;
907
+ }
908
+ function ir(e) {
909
+ let t = new T(e), n = Jt(t);
910
+ return !n || t.remaining().trim().length !== 0 ? null : n;
911
+ }
912
+ function J(e, t) {
913
+ let n = e.trim().replace(/[;:,]\s*$/u, "").trim();
725
914
  if (!n) return null;
726
915
  let r = [...n.matchAll(/\p{L}/gu)];
727
916
  for (let e of r) {
917
+ let r = e.index ?? 0, i = n.slice(r).trim(), a = /\b(alinéas?|phrases?)\b\s*$/iu.exec(i);
918
+ if (!a || a.index === void 0) continue;
919
+ let o = nr(a[1] ?? "");
920
+ if (!o) continue;
921
+ let s = i.slice(0, a.index).trim();
922
+ if (!s) continue;
923
+ let c = /\s*(,|\bet\b|\bou\b)\s*/giu, l = [], u = 0, d;
924
+ for (; (d = c.exec(s)) !== null;) {
925
+ let e = W(d[1] ?? "");
926
+ l.push({
927
+ separator: e === "ou" ? "ou" : e === "," ? "," : "et",
928
+ start: u,
929
+ text: s.slice(u, d.index)
930
+ }), u = c.lastIndex;
931
+ }
932
+ if (l.push({
933
+ start: u,
934
+ text: s.slice(u)
935
+ }), l.length < 2) continue;
936
+ let f = [], p = [], m = !0, h;
937
+ for (let [e, n] of l.entries()) {
938
+ let i = rr(n.text);
939
+ if (!i) {
940
+ f.length = 0;
941
+ break;
942
+ }
943
+ let a = ir(`${i.text} ${o}`);
944
+ if (!a) {
945
+ f.length = 0;
946
+ break;
947
+ }
948
+ q(a, t + r + n.start + i.offset), f.push(a), a.type !== o || a.index === void 0 || a.index < 1 || h !== void 0 && a.index !== h + 1 ? m = !1 : h = a.index, e < l.length - 1 && (p.push(n.separator ?? "et"), (n.separator ?? "et") === "ou" && (m = !1));
949
+ }
950
+ let [g, ..._] = f;
951
+ if (!g || _.length === 0) continue;
952
+ let ee = {
953
+ start: t + r + l[0].start,
954
+ stop: t + r + i.length
955
+ };
956
+ return m ? {
957
+ first: g,
958
+ last: f[f.length - 1],
959
+ position: ee,
960
+ type: "bounded-interval"
961
+ } : xe(g, _.map((e, t) => [p[t] ?? "et", e]), ee);
962
+ }
963
+ return null;
964
+ }
965
+ function ar(e, t) {
966
+ let n = tr(e);
967
+ if (!n) return null;
968
+ let r = J(n, t);
969
+ if (r) return r;
970
+ let i = [...n.matchAll(/\p{L}/gu)];
971
+ for (let e of i) {
728
972
  let r = e.index ?? 0, i = n.slice(r);
729
973
  if (!i) continue;
730
- let a = new D(i), o = qt(a);
731
- if (!(!o || a.offset === 0) && i.slice(a.offset).trim().length === 0) return J(o, t + r), o;
974
+ let a = new T(i), o = Jt(a);
975
+ if (!(!o || a.offset === 0) && i.slice(a.offset).trim().length === 0) return q(o, t + r), o;
732
976
  }
733
977
  return null;
734
978
  }
735
- function zn(e) {
979
+ function or(e) {
736
980
  let t = /\barticle\b/i.exec(e);
737
981
  if (!t || t.index === void 0) return null;
738
- let n = t.index, r = zt(new D(e.slice(n)));
982
+ let n = t.index, r = Bt(new T(e.slice(n)));
739
983
  if (!r) return null;
740
- J(r, n);
741
- let i = Rn(e.slice(0, n), 0);
742
- return i ? g(r, i) : null;
984
+ q(r, n);
985
+ let i = ar(e.slice(0, n), 0);
986
+ return i ? x(r, i) : null;
743
987
  }
744
- function Bn(e, t, n, r = e) {
745
- let i = V(e), a = Fn(r), o = /\bredige\b|\bredigee\b|\bredigees\b|\brediges\b|\bainsi\b/.test(i) || /\bdispositions suivantes\b/.test(i), s = /\bapres\b/.test(i) || /\bapres (la|les) reference\b|\bapres (le|les) mots\b|\bapres la mention\b/.test(i), c = /\bavant\b/.test(i) || /\bavant (la|les) reference\b|\bavant (le|les) mots\b|\bavant la mention\b/.test(i), l = /\binsere(?:e|es|s)?\b|\bajoute\b|\bajoutee\b|\bajoutes\b|\bajoutees\b|\bcomplete\b/.test(i), u = /\bremplace\b|\bremplacee\b|\bremplaces\b|\bremplacees\b/.test(i), d = /\bsupprime\b|\bsupprimee\b|\bsupprimes\b|\bsupprimees\b|\babroge\b|\babrogee\b|\babroges\b|\babrogees\b/.test(i);
746
- if (t.action === "supprimer" || d) return n === "article" && a.length === 0 ? { kind: "delete_article" } : a.length >= 1 ? {
988
+ function sr(e, t, n, r) {
989
+ let i = W(e), a = /\bredige\b|\bredigee\b|\bredigees\b|\brediges\b|\bainsi\b/.test(i) || /\bdispositions suivantes\b/.test(i), o = /\bapres\b/.test(i) || /\bapres (la|les) reference\b|\bapres (le|les) mots\b|\bapres la mention\b/.test(i), s = /\bavant\b/.test(i) || /\bavant (la|les) reference\b|\bavant (le|les) mots\b|\bavant la mention\b/.test(i), c = t.action === "rétablir" || /\bretabl/.test(i), l = /\binsere(?:e|es|s)?\b|\bajoute\b|\bajoutee\b|\bajoutes\b|\bajoutees\b|\bcomplete\b/.test(i) || c, u = /\bremplace\b|\bremplacee\b|\bremplaces\b|\bremplacees\b/.test(i), d = /\bsupprime\b|\bsupprimee\b|\bsupprimes\b|\bsupprimees\b|\babroge\b|\babrogee\b|\babroges\b|\babrogees\b/.test(i);
990
+ if (t.action === "supprimer" || d) return n === "article" && r.length === 0 ? { kind: "delete_article" } : r.length >= 1 ? {
747
991
  kind: "delete",
748
- targetText: a[0]
992
+ targetText: r[0],
993
+ extraTargetTexts: r.slice(1)
749
994
  } : { kind: "delete_portion" };
750
- if (u && a.length >= 2) return {
995
+ if (u && r.length >= 2) return {
751
996
  kind: "replace",
752
- targetText: a[0],
753
- replacementText: a[1]
997
+ targetText: r[0],
998
+ replacementText: r[1]
754
999
  };
755
- if (u && a.length === 1 && o) return {
1000
+ if (u && r.length === 1 && a) return {
756
1001
  kind: "replace_portion",
757
- replacementText: a[0]
1002
+ replacementText: r[0]
758
1003
  };
759
- if (l && a.length >= 2) {
760
- if (s) return {
1004
+ if (l && r.length >= 2) {
1005
+ if (o) return {
761
1006
  kind: "insert_after",
762
- targetText: a[0],
763
- insertText: a[1]
1007
+ targetText: r[0],
1008
+ insertText: r[1]
764
1009
  };
765
- if (c) return {
1010
+ if (s) return {
766
1011
  kind: "insert_before",
767
- targetText: a[0],
768
- insertText: a[1]
1012
+ targetText: r[0],
1013
+ insertText: r[1]
769
1014
  };
770
1015
  }
771
- return l && a.length === 1 ? s ? {
1016
+ return l && r.length === 1 ? o ? {
772
1017
  kind: "insert_after",
773
1018
  targetText: "",
774
- insertText: a[0]
775
- } : c ? {
1019
+ insertText: r[0]
1020
+ } : s ? {
776
1021
  kind: "insert_before",
777
1022
  targetText: "",
778
- insertText: a[0]
1023
+ insertText: r[0]
779
1024
  } : {
780
1025
  kind: "insert_after",
781
1026
  targetText: "",
782
- insertText: a[0]
1027
+ insertText: r[0]
783
1028
  } : null;
784
1029
  }
785
1030
  function Y({ action: e, reference: t, sourcePosition: n, sourceText: r, fullText: i }) {
786
- let a = e.target ?? h(t), o = Cn(t), s = Bn(r, e, a, i && n.start < i.length ? i.slice(n.start) : r);
787
- if (!s) return null;
788
- switch (s.kind) {
1031
+ let a = e.target ?? b(t), o = Sn(t), s = i && n.start < i.length ? i.slice(n.start) : r, c = Yn(s), l = sr(r, e, a, c.map((e) => e.text));
1032
+ if (!l) return null;
1033
+ switch (l.kind) {
789
1034
  case "insert_after":
790
1035
  case "insert_before": return {
791
- kind: s.kind,
1036
+ kind: l.kind,
792
1037
  targetType: a,
793
1038
  reference: t,
794
1039
  portionSelectors: o,
795
- targetText: s.targetText,
796
- insertText: s.insertText,
1040
+ targetText: l.targetText,
1041
+ insertText: l.insertText,
797
1042
  sourcePosition: n,
798
1043
  sourceText: r
799
1044
  };
@@ -802,8 +1047,8 @@ function Y({ action: e, reference: t, sourcePosition: n, sourceText: r, fullText
802
1047
  targetType: a,
803
1048
  reference: t,
804
1049
  portionSelectors: o,
805
- targetText: s.targetText,
806
- replacementText: s.replacementText,
1050
+ targetText: l.targetText,
1051
+ replacementText: l.replacementText,
807
1052
  sourcePosition: n,
808
1053
  sourceText: r
809
1054
  };
@@ -812,19 +1057,34 @@ function Y({ action: e, reference: t, sourcePosition: n, sourceText: r, fullText
812
1057
  targetType: a,
813
1058
  reference: t,
814
1059
  portionSelectors: o,
815
- replacementText: s.replacementText,
816
- sourcePosition: n,
817
- sourceText: r
818
- };
819
- case "delete": return {
820
- kind: "delete",
821
- targetType: a,
822
- reference: t,
823
- portionSelectors: o,
824
- targetText: s.targetText,
1060
+ replacementText: l.replacementText,
825
1061
  sourcePosition: n,
826
1062
  sourceText: r
827
1063
  };
1064
+ case "delete": {
1065
+ let e = c.map((e) => Zn(s, e.start)), i = /* @__PURE__ */ new Map();
1066
+ for (let [t, n] of c.entries()) i.has(n.text) || i.set(n.text, e[t] ?? null);
1067
+ let u = [l.targetText, ...l.extraTargetTexts ?? []].filter((e) => e && e.trim().length > 0).filter((e, t, n) => n.indexOf(e) === t);
1068
+ return u.length > 1 ? u.map((e) => ({
1069
+ kind: "delete",
1070
+ targetType: a,
1071
+ reference: t,
1072
+ portionSelectors: o,
1073
+ targetText: e,
1074
+ occurrenceIndex: i.get(e) ?? void 0,
1075
+ sourcePosition: n,
1076
+ sourceText: r
1077
+ })) : {
1078
+ kind: "delete",
1079
+ targetType: a,
1080
+ reference: t,
1081
+ portionSelectors: o,
1082
+ targetText: l.targetText,
1083
+ occurrenceIndex: i.get(l.targetText) ?? void 0,
1084
+ sourcePosition: n,
1085
+ sourceText: r
1086
+ };
1087
+ }
828
1088
  case "delete_portion": return {
829
1089
  kind: "delete_portion",
830
1090
  targetType: a,
@@ -844,7 +1104,7 @@ function Y({ action: e, reference: t, sourcePosition: n, sourceText: r, fullText
844
1104
  default: return null;
845
1105
  }
846
1106
  }
847
- function Vn(e) {
1107
+ function cr(e) {
848
1108
  let t = /\barticle\s+([0-9]+(?:-[0-9]+)?(?:\s*[A-Z])?(?:\s+[a-z]+)?)\b/i.exec(e);
849
1109
  if (!t || t.index === void 0) return null;
850
1110
  let n = t.index, r = t.index + t[0].length;
@@ -863,22 +1123,22 @@ function Vn(e) {
863
1123
  }
864
1124
  };
865
1125
  }
866
- function Hn(e, t) {
867
- let n = b(e).output;
1126
+ function lr(e, t) {
1127
+ let n = He(e).output;
868
1128
  if (t.allowListExtraction) {
869
- let e = Nn(n);
1129
+ let e = qn(n);
870
1130
  if (e) return e;
871
1131
  }
872
- let r = G(n), i = In(n), a = s(new D(n));
873
- if (r.length > 0 && (a = a.filter((e) => !K(e.position, r))), a.length === 0 && (a = s(new D(i.split(",")[0] ?? i))), a.length === 0) {
874
- let e = Vn(i);
1132
+ let r = Qn(n), i = er(n), a = s(new T(n));
1133
+ if (r.length > 0 && (a = a.filter((e) => !$n(e.position, r))), a.length === 0 && (a = s(new T(i.split(",")[0] ?? i))), a.length === 0) {
1134
+ let e = cr(i);
875
1135
  e && (a = [{
876
1136
  ...e.reference,
877
1137
  position: e.position
878
1138
  }]);
879
1139
  }
880
1140
  if (a.length === 1 && a[0]?.type === "article") {
881
- let e = zn(i);
1141
+ let e = or(i);
882
1142
  e && (a = [e]);
883
1143
  }
884
1144
  let o = [];
@@ -894,7 +1154,7 @@ function Hn(e, t) {
894
1154
  sourceText: i,
895
1155
  fullText: n
896
1156
  });
897
- a && o.push(a);
1157
+ a && (Array.isArray(a) ? o.push(...a) : o.push(a));
898
1158
  continue;
899
1159
  }
900
1160
  let t = Y({
@@ -907,10 +1167,10 @@ function Hn(e, t) {
907
1167
  sourceText: n,
908
1168
  fullText: n
909
1169
  });
910
- t && o.push(t);
1170
+ t && (Array.isArray(t) ? o.push(...t) : o.push(t));
911
1171
  }
912
1172
  if (o.length === 0) {
913
- let e = Vn(i);
1173
+ let e = cr(i);
914
1174
  if (e) {
915
1175
  let t = Y({
916
1176
  action: { action: "modifier" },
@@ -919,54 +1179,54 @@ function Hn(e, t) {
919
1179
  sourceText: n,
920
1180
  fullText: n
921
1181
  });
922
- t && o.push(t);
1182
+ t && (Array.isArray(t) ? o.push(...t) : o.push(t));
923
1183
  }
924
1184
  }
925
1185
  return o;
926
1186
  }
927
- function Un(e) {
928
- return Hn(e, { allowListExtraction: !0 });
1187
+ function ur(e) {
1188
+ return lr(e, { allowListExtraction: !0 });
929
1189
  }
930
- function Wn(e) {
931
- let t = V(e);
1190
+ function dr(e) {
1191
+ let t = W(e);
932
1192
  return t.includes("«") || t.includes("»") || !e.trim().endsWith(":") ? !1 : /\b(remplace|modifie|redige|rediges|redigee|redigees)\b/.test(t);
933
1193
  }
934
- function Gn(e, t) {
1194
+ function fr(e, t) {
935
1195
  let n = [], r = !1, i = t + 1;
936
1196
  for (; i < e.length;) {
937
- let t = e[i], a = H(t);
1197
+ let t = e[i], a = G(t);
938
1198
  if (!r && a.includes("«") && (r = !0), r) {
939
1199
  if (n.push(a), a.includes("»")) break;
940
1200
  } else if (a.trim().length > 0) break;
941
1201
  i += 1;
942
1202
  }
943
1203
  return !r || n.length === 0 ? null : {
944
- combinedText: [H(e[t]), ...n].join("\n"),
1204
+ combinedText: [G(e[t]), ...n].join("\n"),
945
1205
  endIndex: i
946
1206
  };
947
1207
  }
948
- function Kn(e) {
1208
+ function pr(e) {
949
1209
  let t = st()(e).output.split("\n").map((e) => e.trim()).filter((e) => e.length > 0), n = [];
950
1210
  for (let e = 0; e < t.length; e += 1) {
951
1211
  let r = t[e];
952
- if (Wn(r)) {
953
- let r = Gn(t, e);
1212
+ if (dr(r)) {
1213
+ let r = fr(t, e);
954
1214
  if (r) {
955
- let t = Un(r.combinedText);
1215
+ let t = ur(r.combinedText);
956
1216
  if (t.length > 0) {
957
1217
  n.push(...t), e = r.endIndex;
958
1218
  continue;
959
1219
  }
960
1220
  }
961
1221
  }
962
- let i = Hn(r, { allowListExtraction: !1 });
1222
+ let i = lr(r, { allowListExtraction: !1 });
963
1223
  i.length > 0 && n.push(...i);
964
1224
  }
965
1225
  return n;
966
1226
  }
967
1227
  //#endregion
968
1228
  //#region src/lib/json.ts
969
- var qn = (e, t) => t instanceof Object && !Array.isArray(t) ? Object.keys(t).sort().reduce((e, n) => (e[n] = t[n], e), {}) : t;
1229
+ var mr = (e, t) => t instanceof Object && !Array.isArray(t) ? Object.keys(t).sort().reduce((e, n) => (e[n] = t[n], e), {}) : t;
970
1230
  //#endregion
971
1231
  //#region src/lib/markdown.ts
972
1232
  function X(e) {
@@ -974,8 +1234,8 @@ function X(e) {
974
1234
  }
975
1235
  //#endregion
976
1236
  //#region src/lib/linkers/markdown.ts
977
- async function Jn({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previousContext: a, text: o }) {
978
- let s = b(o), c = new D(s.output);
1237
+ async function hr({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previousContext: a, text: o }) {
1238
+ let s = He(o), c = new T(s.output);
979
1239
  c.currentArticle = a?.currentArticle, c.currentText = a?.currentText;
980
1240
  let l = o, u = 0;
981
1241
  for await (let a of Xe({
@@ -989,7 +1249,7 @@ async function Jn({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previous
989
1249
  let { articleId: e, originalTransformation: t } = a;
990
1250
  if (e !== void 0) {
991
1251
  if (t === void 0) throw Error(`Missing originalTransformation attribute in external article link: ${JSON.stringify(a, null, 2)}`);
992
- let o = E(t, `[${X(n(l, t, u))}](${T(i, r, e)})`);
1252
+ let o = D(t, `[${X(n(l, t, u))}](${E(i, r, e)})`);
993
1253
  l = l.slice(0, t.position.start + u) + o + l.slice(t.position.stop + u), u += o.length - (t.position.stop - t.position.start);
994
1254
  }
995
1255
  break;
@@ -998,7 +1258,7 @@ async function Jn({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previous
998
1258
  let { originalTransformation: e, sectionTaId: t } = a;
999
1259
  if (t !== void 0) {
1000
1260
  if (e === void 0) throw Error(`Missing originalTransformation attribute in external division link: ${JSON.stringify(a, null, 2)}`);
1001
- let o = E(e, `[${X(n(l, e, u))}](${T(i, r, t)})`);
1261
+ let o = D(e, `[${X(n(l, e, u))}](${E(i, r, t)})`);
1002
1262
  l = l.slice(0, e.position.start + u) + o + l.slice(e.position.stop + u), u += o.length - (e.position.stop - e.position.start);
1003
1263
  }
1004
1264
  break;
@@ -1010,14 +1270,14 @@ async function Jn({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previous
1010
1270
  continue;
1011
1271
  }
1012
1272
  if (e === void 0) throw Error(`Missing originalTransformation attribute in external text link: ${JSON.stringify(a, null, 2)}`);
1013
- let o = E(e, `[${X(n(l, e, u))}](${T(i, r, t.cid)})`);
1273
+ let o = D(e, `[${X(n(l, e, u))}](${E(i, r, t.cid)})`);
1014
1274
  l = l.slice(0, e.position.start + u) + o + l.slice(e.position.stop + u), u += o.length - (e.position.stop - e.position.start);
1015
1275
  break;
1016
1276
  }
1017
1277
  case "internal_article": {
1018
1278
  let { definition: e, originalTransformation: t } = a;
1019
1279
  if (t === void 0) throw Error(`Missing originalTransformation attribute in internal article link: ${JSON.stringify(a, null, 2)}`);
1020
- let r = E(t, `[${X(n(l, t, u))}](#definition_article_${e.textId}_${e.article.num.replaceAll(" ", "_")})`);
1280
+ let r = D(t, `[${X(n(l, t, u))}](#definition_article_${e.textId}_${e.article.num.replaceAll(" ", "_")})`);
1021
1281
  l = l.slice(0, t.position.start + u) + r + l.slice(t.position.stop + u), u += r.length - (t.position.stop - t.position.start);
1022
1282
  break;
1023
1283
  }
@@ -1025,11 +1285,11 @@ async function Jn({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previous
1025
1285
  let { url: e, originalTransformation: t } = a;
1026
1286
  if (e === void 0) continue;
1027
1287
  if (t === void 0) throw Error(`Missing originalTransformation attribute in european text link: ${JSON.stringify(a, null, 2)}`);
1028
- let r = E(t, `<a class="lien_texte_european" href="${e}" target="_blank">${n(l, t, u)}</a>`);
1288
+ let r = D(t, `<a class="lien_texte_european" href="${e}" target="_blank">${n(l, t, u)}</a>`);
1029
1289
  l = l.slice(0, t.position.start + u) + r + l.slice(t.position.stop + u), u += r.length - (t.position.stop - t.position.start);
1030
1290
  break;
1031
1291
  }
1032
- default: _("Link", a);
1292
+ default: v("Link", a);
1033
1293
  }
1034
1294
  return {
1035
1295
  context: c,
@@ -1038,7 +1298,7 @@ async function Jn({ canutesDb: e, date: t, linkBaseUrl: r, linkType: i, previous
1038
1298
  }
1039
1299
  //#endregion
1040
1300
  //#region src/lib/loaders/assemblee.ts
1041
- async function Yn(e, t, n) {
1301
+ async function gr(e, t, n) {
1042
1302
  let r = t.get("Document");
1043
1303
  r === void 0 && (r = /* @__PURE__ */ new Map(), t.set("Document", r));
1044
1304
  let i = r.get(n);
@@ -1048,7 +1308,7 @@ async function Yn(e, t, n) {
1048
1308
  WHERE uid = ${n}
1049
1309
  `)[0]?.data, r.set(n, i ?? null)), i ?? void 0;
1050
1310
  }
1051
- async function Xn(e, t, n) {
1311
+ async function _r(e, t, n) {
1052
1312
  let r = t.get("Document");
1053
1313
  return r === void 0 && (r = /* @__PURE__ */ new Map(), t.set("Document", r)), (await e`
1054
1314
  SELECT data, uid
@@ -1056,7 +1316,7 @@ async function Xn(e, t, n) {
1056
1316
  WHERE dossier_uid = ${n}
1057
1317
  `).map(({ data: e, uid: t }) => (r.set(t, e ?? null), e));
1058
1318
  }
1059
- async function Zn(e, t, n) {
1319
+ async function vr(e, t, n) {
1060
1320
  let r = t.get("DossierParlementaire");
1061
1321
  r === void 0 && (r = /* @__PURE__ */ new Map(), t.set("DossierParlementaire", r));
1062
1322
  let i = r.get(n);
@@ -1068,15 +1328,15 @@ async function Zn(e, t, n) {
1068
1328
  }
1069
1329
  //#endregion
1070
1330
  //#region src/lib/text_parsers/search_queries.ts
1071
- var Qn = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i" }), Z = C([
1072
- Qn,
1073
- O(yt, { default: "" }),
1074
- w(jt, St)
1331
+ var yr = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i" }), Z = k([
1332
+ yr,
1333
+ Je(et, { default: "" }),
1334
+ w(Mt, Ct)
1075
1335
  ], { value: (e, t) => ({
1076
1336
  num: e[2],
1077
1337
  position: t.position(),
1078
1338
  type: "article"
1079
- }) }), $n = w(S("c(?:ode|\\.)? ?civ(?:il)?", {
1339
+ }) }), br = w(S("c(?:ode|\\.)? ?civ(?:il)?", {
1080
1340
  flags: "i",
1081
1341
  value: (e, t) => ({
1082
1342
  cid: "LEGITEXT000006070721",
@@ -1184,27 +1444,27 @@ var Qn = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i
1184
1444
  title: "Code de commerce",
1185
1445
  type: "texte"
1186
1446
  })
1187
- })), Q = w($n, x(de, { value: (e, t) => e === void 0 ? void 0 : {
1447
+ })), Q = w(br, j(le, { value: (e, t) => e === void 0 ? void 0 : {
1188
1448
  ...e,
1189
1449
  position: t.position()
1190
- } }), x(re, { value: (e, t) => ({
1450
+ } }), j(te, { value: (e, t) => ({
1191
1451
  ...e,
1192
1452
  position: t.position()
1193
- }) })), $ = O(S(" (?:du |de la |de l'|des |de |d')?", { flags: "i" }), { default: "" }), er = S(".+?(?=\\s*(?:du |de la |de l'|des |de |d')?\\s*(?:art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?))", {
1453
+ }) })), $ = Je(S(" (?:du |de la |de l'|des |de |d')?", { flags: "i" }), { default: "" }), xr = S(".+?(?=\\s*(?:du |de la |de l'|des |de |d')?\\s*(?:art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?))", {
1194
1454
  flags: "i",
1195
1455
  value: (e, t) => ({
1196
1456
  type: "texte",
1197
1457
  title: e[0].trim(),
1198
1458
  position: t.position()
1199
1459
  })
1200
- }), tr = S(".+", {
1460
+ }), Sr = S(".+", {
1201
1461
  flags: "i",
1202
1462
  value: (e, t) => ({
1203
1463
  type: "texte",
1204
1464
  title: e[0].trim(),
1205
1465
  position: t.position()
1206
1466
  })
1207
- }), nr = w(C([
1467
+ }), Cr = w(k([
1208
1468
  Q,
1209
1469
  $,
1210
1470
  Z
@@ -1216,7 +1476,7 @@ var Qn = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i
1216
1476
  position: t.position(),
1217
1477
  type: "parent-enfant"
1218
1478
  };
1219
- } }), C([
1479
+ } }), k([
1220
1480
  Z,
1221
1481
  $,
1222
1482
  Q
@@ -1225,8 +1485,8 @@ var Qn = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i
1225
1485
  parent: e[2],
1226
1486
  position: t.position(),
1227
1487
  type: "parent-enfant"
1228
- }) }), C([
1229
- er,
1488
+ }) }), k([
1489
+ xr,
1230
1490
  $,
1231
1491
  Z
1232
1492
  ], { value: (e, t) => {
@@ -1237,25 +1497,25 @@ var Qn = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i
1237
1497
  position: t.position(),
1238
1498
  type: "parent-enfant"
1239
1499
  };
1240
- } }), C([
1500
+ } }), k([
1241
1501
  Z,
1242
1502
  $,
1243
- tr
1503
+ Sr
1244
1504
  ], { value: (e, t) => ({
1245
1505
  child: e[0],
1246
1506
  parent: e[2],
1247
1507
  position: t.position(),
1248
1508
  type: "parent-enfant"
1249
- }) }), Z, Q, tr), rr = (e) => e?.replace(/\n/g, " ").replace(/ {2,}/g, " ").replace(/ \(\d+\)\.?$/, "").replace(/\.$/, ""), ir = (e) => {
1509
+ }) }), Z, Q, Sr), wr = (e) => e?.replace(/\n/g, " ").replace(/ {2,}/g, " ").replace(/ \(\d+\)\.?$/, "").replace(/\.$/, ""), Tr = (e) => {
1250
1510
  let t = e.META.META_SPEC.META_TEXTE_VERSION.DATE_DEBUT;
1251
1511
  return t === void 0 || ["2222-02-22", "2999-01-01"].includes(t) ? e.META.META_SPEC.META_TEXTE_CHRONICLE.DATE_PUBLI : t;
1252
- }, ar = (e) => {
1512
+ }, Er = (e) => {
1253
1513
  let t = e.META.META_SPEC.META_TEXTE_CHRONICLE.DATE_TEXTE;
1254
1514
  if (!["2222-02-22", "2999-01-01"].includes(t)) return t;
1255
1515
  let n = e.META.META_SPEC.META_TEXTE_VERSION.DATE_DEBUT;
1256
1516
  if (n !== void 0 && !["2222-02-22", "2999-01-01"].includes(n)) return n;
1257
1517
  throw Error(`Missing date signature in text ${e.META.META_COMMUN.ID}`);
1258
- }, or = (e) => (t, n) => {
1518
+ }, Dr = (e) => (t, n) => {
1259
1519
  let r = e(t), i = e(n);
1260
1520
  if (r !== i) return r.localeCompare(i);
1261
1521
  let a = t.META.META_COMMUN, o = a.ORIGINE, s = n.META.META_COMMUN, c = s.ORIGINE;
@@ -1264,6 +1524,6 @@ var Qn = S("art(?:icle|icl|ic|i|s)?\\.?|al(?:inéa|inea|in|i)?\\.?", { flags: "i
1264
1524
  if (c === "JORF") return 1;
1265
1525
  }
1266
1526
  throw Error(`TODO: Unable to sort texts ${a.ID} & ${s.ID} by date.`);
1267
- }, sr = Jn;
1527
+ }, Or = hr;
1268
1528
  //#endregion
1269
- export { D as TextParserContext, le as action, an as actionTargets, g as addChildLeftToLastChild, Bt as addLinksOrReferencesToHtmlPage, Ct as addLinksToHtml, Jn as addLinksToMarkdown, sr as addLinksToText, Ge as addPositionsToTableOfContentsItems, wt as adjectifNumeralOrdinalCourt, Me as adjectifTemporelSingulier, Ft as adverbeMultiplicatifLatin, $t as adverbeRelatif, w as alternatives, zt as article, Qe as articles, _ as assertNever, ut as auPortion, ct as auxPortions, Sn as buildArticlePortionTreeFromHtml, C as chain, je as chainTransformers, Be as citation, Re as citationLigne, He as citationSimple, rr as cleanTexteTitle, o as compoundReferencesSeparators, x as convert, Ut as convertHtmlElementsToText, Ce as createEnumerationOrBoundedInterval, ne as createParentChildTreeFromReferences, nt as date, $e as decodeNamedHtmlEntities, it as decodeNumericHtmlEntities, bt as definitionArticleDansCitation, Gt as definitionArticleDansProjetOuPropositionLoi, Ht as definitionDivision, pe as definitionTexteFrancais, tt as designationArticle, Tt as designationDivision, ee as ditPluriel, f as ditSingulier, It as division, y as divisionTypes, ft as divisions, Vt as duDate, yt as espace, Ae as espaceAdverbeRelatif, oe as europeanLawNatures, Yt as extendLoadedArticle, Kn as extractActionDirectivesFromHtml, Un as extractActionDirectivesFromText, rt as extractBillDefinitions, Je as extractCitationReferences, Cn as extractPortionSelectors, Zt as extractReferences, Oe as extractReferencesWithOriginalTransformations, Xe as extractTextLinks, gn as formatLongDate, Pe as frenchLawNatures, ln as getArticleDateDebut, j as getArticleDateSignature, s as getExtractedReferences, Jt as getExtractedReferencesWithOriginalTransformations, Et as getExtractedTableOfContentsFromTextBill, v as getOrLoadArticle, un as getOrLoadArticleSiblingId, Yn as getOrLoadDocument, Xn as getOrLoadDocumentsByDossierParlementaireUid, Zn as getOrLoadDossierParlementaire, m as getOrLoadJo, d as getOrLoadSectionTa, be as getOrLoadSectionsTa, gt as getOrLoadTexteVersion, r as getOrLoadTextelr, pt as getOrLoadTextesVersions, ge as getOrLoadTexteslr, ir as getTexteVersionDateDebut, ar as getTexteVersionDateSignature, Ee as identificationTexteEuropeen, Le as internationalLawNatures, xe as introPluriel, _t as introSingulier, ie as isTextAstAtomicReference, fe as isTextAstDivision, Nt as isTextAstPortion, ce as iterAtomicFirstParentReferences, me as iterAtomicReferences, De as iterIncludedReferences, vt as iterReferenceLinks, qn as jsonReplacer, ue as lawNatures, Wt as lettreAscii, i as liaisonPluriel, mt as liaisonSingulier, Pt as linkTypes, ot as listeArticles, he as listeReferencesSeules, ve as loadArticles, Ve as localizationAdverbs, qe as natureDivisionSingulier, rn as natureTexteFrancais, Ue as newAssembleeObjectCache, Te as newLegifranceObjectCache, t as newObjectCache, p as newReverseTransformationsMergedFromPositionsIterator, jt as nomArticle, St as nomSpecialArticle, dt as nombreAsTextAstNumber, Ke as nombreCardinal, Dt as nombreRomainCardinal, Rt as nombreRomainOrdinal, Ze as nombreRomainOu0iAsTextAstNumber, et as nonLettre, at as numero, Ot as numeroDivision, a as numeroEtOuDateTexteFrancais, We as numeroPortion, Fe as numeroTexteEuropeen, ae as numeroTexteFrancais, O as optional, Ne as optionalEspaceDuTerritoire, tn as parseText, ze as portionTypes, nn as portions, _e as reference, Se as referenceSeule, S as regExp, l as relatifPlurielPrepose, Xt as relatifSingulierPrepose, Qt as repeat, kt as replaceHtmlPatterns, xt as replacePattern, lt as replaceTextPatterns, B as resolvePortionSelector, u as reversePositionsSplitFromPositions, ye as reverseTransformationFromPosition, ht as reverseTransformationsMergedFromPositions, n as reverseTransformedInnerFragment, E as reverseTransformedReplacement, Z as searchArticle, Qn as searchArticleKeyword, nr as searchQueryReference, Q as searchTexte, $n as searchTexteAbbreviations, st as simplifyHtml, b as simplifyPlainText, Kt as simplifyText, en as simplifyUnicodeCharacters, mn as sortArticlesByDate, or as sortTextesVersionsByDate, Ie as texte, re as texteEuropeen, de as texteFrancais, Mt as texteInternational, Ye as unePortion, te as uniteBasePreciseeSingulier, se as uniteBaseSingulier, T as urlFromLegalId, ke as variable, At as virguleOuEspace, Lt as walkTableOfContents, c as wordsTree };
1529
+ export { T as TextParserContext, se as action, rn as actionTargets, x as addChildLeftToLastChild, Vt as addLinksOrReferencesToHtmlPage, wt as addLinksToHtml, hr as addLinksToMarkdown, Or as addLinksToText, We as addPositionsToTableOfContentsItems, It as adjectifNumeralOrdinalCourt, Ae as adjectifTemporelSingulier, ft as adverbeMultiplicatifLatin, $t as adverbeRelatif, w as alternatives, Bt as article, Qe as articles, v as assertNever, dt as auPortion, ct as auxPortions, xn as buildArticlePortionTreeFromHtml, k as chain, Oe as chainTransformers, Re as citation, Ie as citationLigne, Be as citationSimple, wr as cleanTexteTitle, o as compoundReferencesSeparators, j as convert, Wt as convertHtmlElementsToText, xe as createEnumerationOrBoundedInterval, ee as createParentChildTreeFromReferences, nt as date, $e as decodeNamedHtmlEntities, it as decodeNumericHtmlEntities, bt as definitionArticleDansCitation, Kt as definitionArticleDansProjetOuPropositionLoi, Ut as definitionDivision, de as definitionTexteFrancais, tt as designationArticle, Et as designationDivision, h as ditPluriel, f as ditSingulier, Lt as division, C as divisionTypes, pt as divisions, Ht as duDate, et as espace, De as espaceAdverbeRelatif, ie as europeanLawNatures, m as extendLoadedArticle, pr as extractActionDirectivesFromHtml, ur as extractActionDirectivesFromText, rt as extractBillDefinitions, qe as extractCitationReferences, Sn as extractPortionSelectors, Qt as extractReferences, Ee as extractReferencesWithOriginalTransformations, Xe as extractTextLinks, mn as formatLongDate, Me as frenchLawNatures, cn as getArticleDateDebut, P as getArticleDateSignature, s as getExtractedReferences, Yt as getExtractedReferencesWithOriginalTransformations, Dt as getExtractedTableOfContentsFromTextBill, d as getOrLoadArticle, ln as getOrLoadArticleSiblingId, gr as getOrLoadDocument, _r as getOrLoadDocumentsByDossierParlementaireUid, vr as getOrLoadDossierParlementaire, _e as getOrLoadJo, O as getOrLoadSectionTa, r as getOrLoadSectionsTa, mt as getOrLoadTexteVersion, pe as getOrLoadTextelr, he as getOrLoadTextesVersions, be as getOrLoadTexteslr, Tr as getTexteVersionDateDebut, Er as getTexteVersionDateSignature, we as identificationTexteEuropeen, Fe as internationalLawNatures, ve as introPluriel, _t as introSingulier, ne as isTextAstAtomicReference, ue as isTextAstDivision, Pt as isTextAstPortion, oe as iterAtomicFirstParentReferences, y as iterAtomicReferences, Te as iterIncludedReferences, vt as iterReferenceLinks, mr as jsonReplacer, ce as lawNatures, at as lettreAscii, i as liaisonPluriel, ht as liaisonSingulier, Ft as linkTypes, ot as listeArticles, fe as listeReferencesSeules, _ as loadArticles, ze as localizationAdverbs, Ke as natureDivisionSingulier, nn as natureTexteFrancais, Ve as newAssembleeObjectCache, Ce as newLegifranceObjectCache, t as newObjectCache, p as newReverseTransformationsMergedFromPositionsIterator, Mt as nomArticle, Ct as nomSpecialArticle, Ot as nombreAsTextAstNumber, zt as nombreCardinal, Ze as nombreRomainCardinal, yt as nombreRomainOrdinal, Gt as nombreRomainOu0iAsTextAstNumber, jt as nonLettre, St as numero, kt as numeroDivision, a as numeroEtOuDateTexteFrancais, Ue as numeroPortion, Ne as numeroTexteEuropeen, re as numeroTexteFrancais, Je as optional, je as optionalEspaceDuTerritoire, A as parseText, Le as portionTypes, tn as portions, me as reference, ye as referenceSeule, S as regExp, l as relatifPlurielPrepose, Zt as relatifSingulierPrepose, c as repeat, At as replaceHtmlPatterns, xt as replacePattern, lt as replaceTextPatterns, Tn as resolvePortionSelector, u as reversePositionsSplitFromPositions, ge as reverseTransformationFromPosition, gt as reverseTransformationsMergedFromPositions, n as reverseTransformedInnerFragment, D as reverseTransformedReplacement, Z as searchArticle, yr as searchArticleKeyword, Cr as searchQueryReference, Q as searchTexte, br as searchTexteAbbreviations, st as simplifyHtml, He as simplifyPlainText, qt as simplifyText, en as simplifyUnicodeCharacters, fn as sortArticlesByDate, Dr as sortTextesVersionsByDate, Pe as texte, te as texteEuropeen, le as texteFrancais, Nt as texteInternational, Ye as unePortion, g as uniteBasePreciseeSingulier, ae as uniteBaseSingulier, E as urlFromLegalId, Xt as variable, ut as virguleOuEspace, Rt as walkTableOfContents, ke as wordsTree };