@tricoteuses/assemblee 3.7.1 → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/parsers.js +103 -84
  2. package/package.json +1 -1
package/lib/parsers.js CHANGED
@@ -8291,13 +8291,32 @@ var Vu = [
8291
8291
  function Hu(e) {
8292
8292
  return Vu.some((t) => t.test(e));
8293
8293
  }
8294
- function Uu(e, t) {
8295
- let n = e(t), [r] = Iu(Ru(n.is("table") ? Fu(n) : Lu(Q(n.text()))));
8294
+ var Uu = "";
8295
+ function Wu(e, t) {
8296
+ if (!e.is("[class*=\"Num\"]") || e.find("br").length === 0) return t;
8297
+ let n = e.clone();
8298
+ return n.find("br").replaceWith(Uu), Lu(Q(Nu(n.html() ?? "", null, !1).root().text().split(Uu)[0])) || t;
8299
+ }
8300
+ function Gu(e, t) {
8301
+ let n = e(t), [r] = Iu(Ru(Wu(n, n.is("table") ? Fu(n) : Lu(Q(n.text())))));
8296
8302
  return r !== null && r >= 0;
8297
8303
  }
8298
- function Wu(e, t) {
8304
+ function Ku(e, t) {
8305
+ if (e.find("br").length === 0) return [t];
8306
+ let n = e.clone();
8307
+ n.find("br").replaceWith(Uu);
8308
+ let r = (n.html() ?? "").split(Uu).flatMap((t) => {
8309
+ let n = e.clone().html(Nu(t, null, !1).html()), r = Lu(Q(n.text()));
8310
+ return r ? [{
8311
+ texte: r,
8312
+ html: Lu(Q(n.prop("outerHTML") || ""))
8313
+ }] : [];
8314
+ });
8315
+ return r.length > 1 ? r : [t];
8316
+ }
8317
+ function qu(e, t) {
8299
8318
  let n = Nu(Pu(t, { removeEmptyElements: !0 })), r = n("p:not(table p), h4, table").toArray().filter((e) => Lu(Q(n(e).text())).length > 0), i = [], a = [], o = null, s = null, c = !1, l = [], u = [], d = [], f = !1, p = !1, ee = !1, m = Array.from({ length: r.length + 1 }, () => !1), h = !1;
8300
- for (let e = r.length - 1; e >= 0; e--) h = h || Uu(n, r[e]), m[e] = h;
8319
+ for (let e = r.length - 1; e >= 0; e--) h = h || Gu(n, r[e]), m[e] = h;
8301
8320
  for (let e = 0; e < r.length; e++) {
8302
8321
  let t = r[e], h = n(t), g = h.find("a").first().attr("href") || "", _ = h.hasClass("assnatFootnoteText") || g.startsWith("#_ftnref"), v = Lu(Q(h.prop("outerHTML") || "")), y = h.is("table") ? Fu(h) : Lu(Q(h.text()));
8303
8322
  if (_) {
@@ -8307,7 +8326,7 @@ function Wu(e, t) {
8307
8326
  });
8308
8327
  continue;
8309
8328
  }
8310
- let b = Ru(y), [x, S] = Iu(b);
8329
+ let b = Ru(Wu(h, y)), [x, S] = Iu(b);
8311
8330
  if (!f) {
8312
8331
  if (x !== null && x >= 0 && S !== "Annexe") f = !0;
8313
8332
  else continue;
@@ -8347,10 +8366,10 @@ function Wu(e, t) {
8347
8366
  titres: l,
8348
8367
  alineas: u
8349
8368
  }); a.length > 0 && o < a[a.length - 1];) a.pop();
8350
- (a.length === 0 || o > a[a.length - 1]) && a.push(o), s = S, l = [{
8369
+ (a.length === 0 || o > a[a.length - 1]) && a.push(o), s = S, l = Ku(h, {
8351
8370
  texte: y,
8352
8371
  html: v
8353
- }], u = [], c = !b.match(/^ARTICLES?(_|$)/) && !b.match(/^EXPOSE_DES_MOTIFS$/);
8372
+ }), u = [], c = !b.match(/^ARTICLES?(_|$)/) && !b.match(/^EXPOSE_DES_MOTIFS$/);
8354
8373
  }
8355
8374
  }
8356
8375
  l.length > 0 && i.push({
@@ -8388,7 +8407,7 @@ function Wu(e, t) {
8388
8407
  }
8389
8408
  //#endregion
8390
8409
  //#region node_modules/date-fns/formatISO.js
8391
- function Gu(t, n) {
8410
+ function Ju(t, n) {
8392
8411
  let r = i(t, n?.in);
8393
8412
  if (isNaN(+r)) throw RangeError("Invalid time value");
8394
8413
  let a = n?.format ?? "extended", o = n?.representation ?? "complete", s = "", c = "", l = a === "extended" ? "-" : "", u = a === "extended" ? ":" : "";
@@ -8413,14 +8432,14 @@ function Gu(t, n) {
8413
8432
  }
8414
8433
  //#endregion
8415
8434
  //#region src/parsers/recherche_amendements.ts
8416
- var Ku = /* @__PURE__ */ RegExp("^(\\ufeff?(= yaml =|---)$[\\s\\S]*?^(?:\\2|\\.\\.\\.)\\s*$(?:\\r?\\n)?)", "m");
8417
- function qu(e) {
8418
- return e.replace(Ku, "");
8435
+ var Yu = /* @__PURE__ */ RegExp("^(\\ufeff?(= yaml =|---)$[\\s\\S]*?^(?:\\2|\\.\\.\\.)\\s*$(?:\\r?\\n)?)", "m");
8436
+ function Xu(e) {
8437
+ return e.replace(Yu, "");
8419
8438
  }
8420
- async function* Ju(e, t, n, i, o, s = {}) {
8421
- for await (let [c, l] of Yu(e, t, n, i, o, s)) a(l), yield [c, r.toAmendement(JSON.stringify(l))];
8439
+ async function* Zu(e, t, n, i, o, s = {}) {
8440
+ for await (let [c, l] of Qu(e, t, n, i, o, s)) a(l), yield [c, r.toAmendement(JSON.stringify(l))];
8422
8441
  }
8423
- async function* Yu(e, r, i, a, f, p = {}) {
8442
+ async function* Qu(e, r, i, a, f, p = {}) {
8424
8443
  await s.ensureDir(e), o.strictEqual(/[?&]date_depot=/.exec(r), null, `URL ${r} already contains a deposit date`), o.strictEqual(/[?&]order=/.exec(r), null, `URL ${r} already contains a sort order`), o.strictEqual(/[?&]page=/.exec(r), null, `URL ${r} already contains a page number`), i && o.notStrictEqual(/[?&]etat=/.exec(r), null, `In incremental mode, URL ${r} must contain an "etat" query parameter`), r += (r.includes("?") ? "&" : "?") + "order=date_depot,desc&page=1", a != null && o.notStrictEqual(/\d{4}-\d{2}-\d{2}/.exec(a), null, `Invalid format for minimum date: ${a}`);
8425
8444
  let ee = 0;
8426
8445
  iterSearchPages: for (;;) {
@@ -8458,11 +8477,11 @@ async function* Yu(e, r, i, a, f, p = {}) {
8458
8477
  let e = l.querySelectorAll("td");
8459
8478
  if (o.strictEqual(e.length, 11, `Unexpected number of columns in amendment row: ${l.outerHTML}`), a != null) {
8460
8479
  let r = e[10];
8461
- if (Gu(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < a) break iterSearchPages;
8480
+ if (Ju(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < a) break iterSearchPages;
8462
8481
  }
8463
8482
  if (f != null) {
8464
8483
  let r = e[7];
8465
- if (r.text && Gu(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < f) continue;
8484
+ if (r.text && Ju(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < f) continue;
8466
8485
  }
8467
8486
  }
8468
8487
  let m = l.getAttribute("data-href");
@@ -8479,7 +8498,7 @@ async function* Yu(e, r, i, a, f, p = {}) {
8479
8498
  if (i) break iterSearchPages;
8480
8499
  continue;
8481
8500
  }
8482
- if (_ !== null && qu(_) === y) continue;
8501
+ if (_ !== null && Xu(_) === y) continue;
8483
8502
  p.verbose && console.log(_ === null ? `Adding amendement search cache: ${g}…` : `Updating amendement search cache: ${g}…`);
8484
8503
  let x = new URL(m, "https://www.assemblee-nationale.fr/").toString(), S = await fetch(x);
8485
8504
  if (S.status === 404) {
@@ -8509,7 +8528,7 @@ async function* Yu(e, r, i, a, f, p = {}) {
8509
8528
  }
8510
8529
  //#endregion
8511
8530
  //#region src/parsers/plf/parser_utils.ts
8512
- function Xu(e) {
8531
+ function $u(e) {
8513
8532
  return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toUpperCase();
8514
8533
  }
8515
8534
  function $(e) {
@@ -8518,7 +8537,7 @@ function $(e) {
8518
8537
  html: Q(e.html())
8519
8538
  };
8520
8539
  }
8521
- function Zu(e, t, n, r) {
8540
+ function ed(e, t, n, r) {
8522
8541
  return {
8523
8542
  id: e,
8524
8543
  type: t,
@@ -8528,10 +8547,10 @@ function Zu(e, t, n, r) {
8528
8547
  alineas: []
8529
8548
  };
8530
8549
  }
8531
- function Qu(e) {
8550
+ function td(e) {
8532
8551
  return /états\s+l[ée]gislatifs\s+annex/i.test(e);
8533
8552
  }
8534
- function $u(e) {
8553
+ function nd(e) {
8535
8554
  return {
8536
8555
  texte: Fu(e),
8537
8556
  html: e.prop("outerHTML") || ""
@@ -8539,22 +8558,22 @@ function $u(e) {
8539
8558
  }
8540
8559
  //#endregion
8541
8560
  //#region src/parsers/plf/depot.ts
8542
- var ed = [
8561
+ var rd = [
8543
8562
  "Partie",
8544
8563
  "Titre",
8545
8564
  "Chapitre",
8546
8565
  "Section"
8547
8566
  ];
8548
- function td(e) {
8567
+ function id(e) {
8549
8568
  let t = Nu(Pu(e)), n = [], r = [], i = "generalExpose", a = null, o = null, s = [], c = t("h1, h2, h3, h4, h5, h6, p.assnatPastille, p.assnatFPFexpogentitre1, p.assnatFPFexpogentexte, li.assnatFPFexpogentexte, li.assnatFPFprojetloiartexte, p.assnatFPFprojetloiartexte, p.assnatFPFfinartexte, table, img").toArray(), l = () => {
8550
- o && s.length > 0 && (o.alineas = nd(s)), s = [];
8569
+ o && s.length > 0 && (o.alineas = ad(s)), s = [];
8551
8570
  }, u = () => {
8552
8571
  o && (l(), n.push(o), o = null);
8553
8572
  };
8554
8573
  for (let e of c) {
8555
8574
  if (i === "done") break;
8556
- let c = t(e), g = Q(c.text()), _ = sd(c), v = _ !== null, y = _ !== null && _ >= 2 && _ <= 5, b = c.hasClass("assnatFPFexpogentitre1"), x = c.hasClass("assnatFPFexpogentexte"), S = c.hasClass("assnatPastille"), te = c.hasClass("assnatFPFprojetloiartexte"), ne = c.hasClass("assnatFPFfinartexte"), re = c.is("table"), ie = c.is("img"), ae = c.find("img").length > 0;
8557
- if (!(v && g.length === 0) && !(re && c.find("p.assnatFARTT08Bleu").length > 0) && !(re && od(c)) && !(x && g.length === 0)) {
8575
+ let c = t(e), g = Q(c.text()), _ = ud(c), v = _ !== null, y = _ !== null && _ >= 2 && _ <= 5, b = c.hasClass("assnatFPFexpogentitre1"), x = c.hasClass("assnatFPFexpogentexte"), S = c.hasClass("assnatPastille"), te = c.hasClass("assnatFPFprojetloiartexte"), ne = c.hasClass("assnatFPFfinartexte"), re = c.is("table"), ie = c.is("img"), ae = c.find("img").length > 0;
8576
+ if (!(v && g.length === 0) && !(re && c.find("p.assnatFARTT08Bleu").length > 0) && !(re && ld(c)) && !(x && g.length === 0)) {
8558
8577
  if (i === "generalExpose") {
8559
8578
  if (_ === 1) {
8560
8579
  let e = g.toLowerCase();
@@ -8562,11 +8581,11 @@ function td(e) {
8562
8581
  a && n.push(a), a = null, i = "hierarchy";
8563
8582
  continue;
8564
8583
  }
8565
- e.includes("exposé général des motifs") && (a ?? (a = Zu("D_EXPOSE", "Exposé des motifs", 1, 1)));
8584
+ e.includes("exposé général des motifs") && (a ?? (a = ed("D_EXPOSE", "Exposé des motifs", 1, 1)));
8566
8585
  }
8567
8586
  if (y && (a && n.push(a), a = null, i = "hierarchy"), a) {
8568
8587
  if (ie) {
8569
- let e = ud(c);
8588
+ let e = pd(c);
8570
8589
  if (e) {
8571
8590
  var d;
8572
8591
  (d = a).alineas ?? (d.alineas = []), a.alineas.push(e);
@@ -8575,42 +8594,42 @@ function td(e) {
8575
8594
  var f;
8576
8595
  (f = a).titres ?? (f.titres = []), a.titres.push($(c));
8577
8596
  } else if (b || x) {
8578
- let e = ae ? cd(c) : $(c);
8597
+ let e = ae ? dd(c) : $(c);
8579
8598
  if (e) {
8580
8599
  var p;
8581
8600
  (p = a).alineas ?? (p.alineas = []), a.alineas.push(e);
8582
8601
  }
8583
8602
  } else if (re) {
8584
8603
  var ee;
8585
- (ee = a).alineas ?? (ee.alineas = []), a.alineas.push($u(c));
8604
+ (ee = a).alineas ?? (ee.alineas = []), a.alineas.push(nd(c));
8586
8605
  }
8587
8606
  continue;
8588
8607
  }
8589
8608
  }
8590
- if (Qu(g)) {
8609
+ if (td(g)) {
8591
8610
  u(), a && (n.push(a), a = null), i = "done";
8592
8611
  continue;
8593
8612
  }
8594
8613
  if (_ !== 1) {
8595
8614
  if (y) {
8596
8615
  u();
8597
- let e = _ - 2, t = ed[e];
8616
+ let e = _ - 2, t = rd[e];
8598
8617
  for (; r.length > 0 && r[r.length - 1] >= e;) r.pop();
8599
8618
  r.push(e);
8600
- let a = Zu(`D_${Xu(g)}`, t, e + 1, r.length);
8619
+ let a = ed(`D_${$u(g)}`, t, e + 1, r.length);
8601
8620
  a.titres = [$(c)], n.push(a), i = "hierarchy";
8602
8621
  continue;
8603
8622
  }
8604
8623
  if (_ === 6) {
8605
8624
  u();
8606
8625
  let e = r.length + 1;
8607
- o = Zu(`D_${Xu(g)}`, "Article", 5, e), o.titres = [$(c)], s = [], i = "articleBody";
8626
+ o = ed(`D_${$u(g)}`, "Article", 5, e), o.titres = [$(c)], s = [], i = "articleBody";
8608
8627
  continue;
8609
8628
  }
8610
8629
  if (S && i === "articleBody" && o) {
8611
8630
  s.push({
8612
8631
  type: "marker",
8613
- number: ad(g)
8632
+ number: cd(g)
8614
8633
  });
8615
8634
  continue;
8616
8635
  }
@@ -8625,7 +8644,7 @@ function td(e) {
8625
8644
  if (re && i === "articleBody" && o) {
8626
8645
  s.push({
8627
8646
  type: "content",
8628
- content: $u(c)
8647
+ content: nd(c)
8629
8648
  });
8630
8649
  continue;
8631
8650
  }
@@ -8646,7 +8665,7 @@ function td(e) {
8646
8665
  }
8647
8666
  if (re) {
8648
8667
  var h;
8649
- (h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push($u(c));
8668
+ (h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push(nd(c));
8650
8669
  }
8651
8670
  }
8652
8671
  }
@@ -8654,7 +8673,7 @@ function td(e) {
8654
8673
  }
8655
8674
  return u(), a && n.push(a), { subdivisions: n };
8656
8675
  }
8657
- function nd(e) {
8676
+ function ad(e) {
8658
8677
  let t = e.flatMap((e) => e.type === "content" ? [e.content] : []);
8659
8678
  if (e.length - t.length === 0) return t;
8660
8679
  let n = [], r, i;
@@ -8670,43 +8689,43 @@ function nd(e) {
8670
8689
  contents: []
8671
8690
  }, n.push(r), i = a.number;
8672
8691
  }
8673
- rd(n);
8692
+ od(n);
8674
8693
  let a = [];
8675
8694
  for (let e = 0; e < n.length; e++) {
8676
8695
  let r = n[e], i = n[e + 1], o = i ? i.number - r.number : 1;
8677
8696
  if (r.contents.length < o) return t;
8678
8697
  for (let e = 0; e < o - 1; e++) a.push(r.contents[e]);
8679
- a.push(id(r.contents.slice(o - 1)));
8698
+ a.push(sd(r.contents.slice(o - 1)));
8680
8699
  }
8681
8700
  return a;
8682
8701
  }
8683
- function rd(e) {
8702
+ function od(e) {
8684
8703
  for (let t = 0; t < e.length - 1; t++) {
8685
8704
  let n = e[t].contents, r = e[t + 1].contents, i = n[n.length - 1];
8686
8705
  i?.texte?.trim() === "«" && r.some(({ html: e }) => /<table\b/.test(e ?? "")) && (n.pop(), r.unshift(i));
8687
8706
  }
8688
8707
  }
8689
- function id(e) {
8708
+ function sd(e) {
8690
8709
  return {
8691
8710
  texte: e.flatMap(({ texte: e }) => e === void 0 ? [] : [e]).join("\n"),
8692
8711
  html: e.flatMap(({ html: e }) => e === void 0 ? [] : [e]).join("\n")
8693
8712
  };
8694
8713
  }
8695
- function ad(e) {
8714
+ function cd(e) {
8696
8715
  let t = /^\((\d+)\)$/.exec(e);
8697
8716
  if (!t) return;
8698
8717
  let n = Number(t[1]);
8699
8718
  return Number.isSafeInteger(n) && n > 0 ? n : void 0;
8700
8719
  }
8701
- function od(e) {
8720
+ function ld(e) {
8702
8721
  let t = e.children("tbody").children("tr").add(e.children("tr"));
8703
8722
  return t.length === 1 && t.children("td").length === 1 && e.find("h6, .assnatFPFexpogentexte").length > 0;
8704
8723
  }
8705
- function sd(e) {
8724
+ function ud(e) {
8706
8725
  for (let t = 1; t <= 6; t++) if (e.is(`h${t}`)) return t;
8707
8726
  return null;
8708
8727
  }
8709
- function cd(e) {
8728
+ function dd(e) {
8710
8729
  let t = e.clone();
8711
8730
  t.find("img").remove();
8712
8731
  let n = Q(t.text());
@@ -8715,14 +8734,14 @@ function cd(e) {
8715
8734
  html: Q(t.html())
8716
8735
  } : null;
8717
8736
  }
8718
- function ld(e) {
8737
+ function fd(e) {
8719
8738
  if (!e || !/^\d+$/.test(e)) return;
8720
8739
  let t = Number(e);
8721
8740
  return t > 0 ? t : void 0;
8722
8741
  }
8723
- function ud(e) {
8742
+ function pd(e) {
8724
8743
  if (!e.attr("src")) return null;
8725
- let t = ld(e.attr("width")), n = ld(e.attr("height"));
8744
+ let t = fd(e.attr("width")), n = fd(e.attr("height"));
8726
8745
  return t === 15 && n === 15 || t === 2 && n === 138 ? null : {
8727
8746
  texte: Q(e.attr("alt") ?? ""),
8728
8747
  html: e.prop("outerHTML") || ""
@@ -8730,18 +8749,18 @@ function ud(e) {
8730
8749
  }
8731
8750
  //#endregion
8732
8751
  //#region src/parsers/plf/later_stage.ts
8733
- function dd(e) {
8752
+ function md(e) {
8734
8753
  let t = Nu(Pu(e)), n = [], r = [], i = null, a = null, o = null, s = !1, c = t("p.assnat2PartieNum, p.assnat2PartieIntit, p.assnat4TitreNum, p.assnat4TitreNum0, p.assnat4TitreIntit, p.assnat9ArticleNum, p.assnatLoiTexte, p.assnat1TomeNum, table, p.assnat5ChapitreIntit, p.assnat5ChapitreIntit0, p.assnat5ChapitreNum, p.assnat5ChapitreNum0, p.assnat6SectionIntit, p.assnat6SectionIntit0, p.assnat6SectionNum, p.assnat6SectionNum0").toArray();
8735
8754
  for (let e of c) {
8736
8755
  let c = t(e), l = Q(c.text());
8737
- if (l.length === 0 || (!s && Qu(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
8756
+ if (l.length === 0 || (!s && td(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
8738
8757
  let u = c.hasClass("assnat2PartieNum"), d = c.hasClass("assnat2PartieIntit"), f = c.hasClass("assnat4TitreNum") || c.hasClass("assnat4TitreNum0"), p = c.hasClass("assnat4TitreIntit"), ee = c.hasClass("assnat9ArticleNum"), m = c.hasClass("assnatLoiTexte"), h = c.is("table");
8739
8758
  if (d) {
8740
8759
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 0;) r.pop();
8741
8760
  r.push(0);
8742
- let e = fd(a, $(c));
8761
+ let e = hd(a, $(c));
8743
8762
  a = null, o = null;
8744
- let t = Zu(`D_${Xu(e.texte ?? l)}`, "Partie", 1, r.length);
8763
+ let t = ed(`D_${$u(e.texte ?? l)}`, "Partie", 1, r.length);
8745
8764
  t.titres = [e], n.push(t);
8746
8765
  continue;
8747
8766
  }
@@ -8752,9 +8771,9 @@ function dd(e) {
8752
8771
  if (p) {
8753
8772
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 1;) r.pop();
8754
8773
  r.push(1);
8755
- let e = fd(o, $(c));
8774
+ let e = hd(o, $(c));
8756
8775
  o = null;
8757
- let t = Zu(`D_${Xu(e.texte ?? l)}`, "Titre", 2, r.length);
8776
+ let t = ed(`D_${$u(e.texte ?? l)}`, "Titre", 2, r.length);
8758
8777
  t.titres = [e], n.push(t);
8759
8778
  continue;
8760
8779
  }
@@ -8765,7 +8784,7 @@ function dd(e) {
8765
8784
  if (ee) {
8766
8785
  i && n.push(i);
8767
8786
  let e = r.length + 1;
8768
- i = Zu(`D_${Xu(l)}`, "Article", 5, e), i.titres = [$(c)];
8787
+ i = ed(`D_${$u(l)}`, "Article", 5, e), i.titres = [$(c)];
8769
8788
  continue;
8770
8789
  }
8771
8790
  if (m) {
@@ -8775,7 +8794,7 @@ function dd(e) {
8775
8794
  let e = /^chapitre\b/i.test(l), t = /^section\b/i.test(l), a = /^[IVXLCDM]+[.\s]/.test(l), o = /^[A-Z][.\s]/.test(l), s = e || !t && a, u = s ? "Chapitre" : t || !e && o ? "Section" : "Chapitre", d = s ? 2 : 3;
8776
8795
  for (; r.length > 0 && r[r.length - 1] >= d;) r.pop();
8777
8796
  r.push(d);
8778
- let f = Zu(`D_${Xu(l)}`, u, d + 1, r.length);
8797
+ let f = ed(`D_${$u(l)}`, u, d + 1, r.length);
8779
8798
  f.titres = [$(c)], n.push(f);
8780
8799
  continue;
8781
8800
  }
@@ -8783,14 +8802,14 @@ function dd(e) {
8783
8802
  continue;
8784
8803
  }
8785
8804
  if (h && i) {
8786
- i.alineas = i.alineas || [], i.alineas.push($u(c));
8805
+ i.alineas = i.alineas || [], i.alineas.push(nd(c));
8787
8806
  continue;
8788
8807
  }
8789
8808
  (/assnat5Chapitre(Intit|Num)/.test(c.attr("class") ?? "") || /assnat6Section(Intit|Num)/.test(c.attr("class") ?? "")) && i && (i.alineas = i.alineas || [], i.alineas.push($(c)));
8790
8809
  }
8791
8810
  return i && n.push(i), { subdivisions: n };
8792
8811
  }
8793
- function fd(e, t) {
8812
+ function hd(e, t) {
8794
8813
  return e === null ? t : {
8795
8814
  texte: `${e.texte} : ${t.texte}`,
8796
8815
  html: `${e.html} : ${t.html}`
@@ -8798,20 +8817,20 @@ function fd(e, t) {
8798
8817
  }
8799
8818
  //#endregion
8800
8819
  //#region src/parsers/plf/variant_detection.ts
8801
- var pd = [
8820
+ var gd = [
8802
8821
  "assnatFPFexpogentexte",
8803
8822
  "assnatFPFexpogentitre1",
8804
8823
  "assnatFPFexpogentitre2",
8805
8824
  "assnatFPFexpogentitre3",
8806
8825
  "assnatFPFexpogentitre4"
8807
8826
  ];
8808
- function md(e) {
8827
+ function _d(e) {
8809
8828
  let t = Nu(Pu(e));
8810
- return t("h1, h2, h3, h4, h5, h6").toArray().some((e) => Q(t(e).text()).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().includes("expose general des motifs")) || t(pd.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
8829
+ return t("h1, h2, h3, h4, h5, h6").toArray().some((e) => Q(t(e).text()).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().includes("expose general des motifs")) || t(gd.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
8811
8830
  }
8812
8831
  //#endregion
8813
8832
  //#region src/parsers/plf/credits.ts
8814
- var hd = {
8833
+ var vd = {
8815
8834
  bg: {
8816
8835
  budgetType: "budgetGeneral",
8817
8836
  libelle: "Budget général"
@@ -8829,15 +8848,15 @@ var hd = {
8829
8848
  libelle: "Comptes de concours financiers"
8830
8849
  }
8831
8850
  };
8832
- function gd(e) {
8851
+ function yd(e) {
8833
8852
  if (!e) return [];
8834
- let t = Nu(Pu(e)), n = Sd(t);
8853
+ let t = Nu(Pu(e)), n = Td(t);
8835
8854
  if (n.length === 0) return [];
8836
8855
  let r = [];
8837
8856
  for (let e of n) {
8838
8857
  let n = [], i;
8839
8858
  for (let r of e.tableEls) {
8840
- let e = bd(t, r);
8859
+ let e = Cd(t, r);
8841
8860
  n.push(...e.missions), e.total && (i = e.total);
8842
8861
  }
8843
8862
  n.length === 0 && !e.estConformeVersionPrecedente || r.push({
@@ -8853,7 +8872,7 @@ function gd(e) {
8853
8872
  }
8854
8873
  return r;
8855
8874
  }
8856
- function _d(e) {
8875
+ function bd(e) {
8857
8876
  let t = Q(e).replace(/[\u2212\u2011]/g, "-").replace(/\s/g, "").replace(/[^0-9,.-]/g, ""), n = (t.match(/,/g) ?? []).length;
8858
8877
  if (n > 1) return;
8859
8878
  let r = n === 1 ? t.replace(/\./g, "").replace(",", ".") : t;
@@ -8861,23 +8880,23 @@ function _d(e) {
8861
8880
  let i = Number(r);
8862
8881
  return Number.isNaN(i) ? void 0 : i;
8863
8882
  }
8864
- function vd(e) {
8883
+ function xd(e) {
8865
8884
  let t = Q(e);
8866
8885
  if (!/\(\s*ligne\s+supprim(?:ée|ee)\s*\)\s*$/i.test(t)) return t.replace(/\s*\(\s*ligne\s+nouvelle\s*\)\s*$/i, "").trim();
8867
8886
  }
8868
- function yd(e, t) {
8869
- let n = _d(t(e[1]).text()), r = _d(t(e[2]).text());
8887
+ function Sd(e, t) {
8888
+ let n = bd(t(e[1]).text()), r = bd(t(e[2]).text());
8870
8889
  return e.length >= 5 ? {
8871
8890
  autorisationEngagement: n,
8872
8891
  creditPaiement: r,
8873
- autorisationEngagementAnnule: _d(t(e[3]).text()),
8874
- creditPaiementAnnule: _d(t(e[4]).text())
8892
+ autorisationEngagementAnnule: bd(t(e[3]).text()),
8893
+ creditPaiementAnnule: bd(t(e[4]).text())
8875
8894
  } : {
8876
8895
  autorisationEngagement: n,
8877
8896
  creditPaiement: r
8878
8897
  };
8879
8898
  }
8880
- function bd(e, t) {
8899
+ function Cd(e, t) {
8881
8900
  let n = [], r = null, i = null, a, o = e(t).find("tbody tr").toArray(), s = o.some((t) => {
8882
8901
  let n = (e(t).find("td").first().attr("style") || "").replace(/[\n\t]/g, " ");
8883
8902
  return /border-top/.test(n);
@@ -8887,7 +8906,7 @@ function bd(e, t) {
8887
8906
  if (o.length < 3) continue;
8888
8907
  let c = e(o[0]), l = (c.attr("style") || "").replace(/[\n\t]/g, " "), u = Q(c.text());
8889
8908
  if (!u) continue;
8890
- let d = /^total/i.test(u), f = yd(o, e);
8909
+ let d = /^total/i.test(u), f = Sd(o, e);
8891
8910
  if (d) {
8892
8911
  a = f;
8893
8912
  continue;
@@ -8901,7 +8920,7 @@ function bd(e, t) {
8901
8920
  }
8902
8921
  if (s ? /border-top/.test(l) : /border-bottom/.test(l)) {
8903
8922
  r && n.push(r);
8904
- let e = vd(c.text());
8923
+ let e = xd(c.text());
8905
8924
  if (e === void 0) {
8906
8925
  r = null, i = null;
8907
8926
  continue;
@@ -8915,7 +8934,7 @@ function bd(e, t) {
8915
8934
  continue;
8916
8935
  }
8917
8936
  if (r) {
8918
- let e = vd(c.text());
8937
+ let e = xd(c.text());
8919
8938
  if (e === void 0) {
8920
8939
  i = null;
8921
8940
  continue;
@@ -8931,11 +8950,11 @@ function bd(e, t) {
8931
8950
  total: a
8932
8951
  };
8933
8952
  }
8934
- function xd(e, t) {
8953
+ function wd(e, t) {
8935
8954
  let n = e(t).find("tr").slice(0, 3).find("th, td").toArray().map((t) => Q(e(t).text()).toLocaleLowerCase("fr"));
8936
8955
  return n.some((e) => e.includes("mission / programme")) && n.some((e) => e.includes("autorisation") && e.includes("engagement")) && n.some((e) => e.includes("crédit") && e.includes("paiement"));
8937
8956
  }
8938
- function Sd(e) {
8957
+ function Td(e) {
8939
8958
  let t, n, r = !1, i = /* @__PURE__ */ new Map(), a = e("p, h1, h2, h3, h4, h5, h6, a:not([href]), table").toArray().filter((t) => e(t).parents("table").length === 0);
8940
8959
  for (let o of a) {
8941
8960
  let a = e(o);
@@ -8952,7 +8971,7 @@ function Sd(e) {
8952
8971
  for (let t of e) {
8953
8972
  let e = i.get(t);
8954
8973
  e ? e.estConformeVersionPrecedente = !0 : i.set(t, {
8955
- ...hd[t],
8974
+ ...vd[t],
8956
8975
  tableEls: [],
8957
8976
  estConformeVersionPrecedente: !0
8958
8977
  });
@@ -8968,7 +8987,7 @@ function Sd(e) {
8968
8987
  s !== /COMPTES\s+DE\s+CONCOURS\s+FINANCIERS/i.test(e) && (n = s ? "cas" : "ccf");
8969
8988
  continue;
8970
8989
  }
8971
- if (!xd(e, o)) continue;
8990
+ if (!wd(e, o)) continue;
8972
8991
  let s = t === "B" ? "bg" : t === "C" ? "ba" : t === "D" ? n : void 0;
8973
8992
  if (!s) continue;
8974
8993
  r = !0;
@@ -8978,7 +8997,7 @@ function Sd(e) {
8978
8997
  continue;
8979
8998
  }
8980
8999
  i.set(s, {
8981
- ...hd[s],
9000
+ ...vd[s],
8982
9001
  tableEls: [o],
8983
9002
  estConformeVersionPrecedente: !1
8984
9003
  });
@@ -8987,8 +9006,8 @@ function Sd(e) {
8987
9006
  }
8988
9007
  //#endregion
8989
9008
  //#region src/parsers/plf/index.ts
8990
- function Cd(e) {
8991
- return e ? md(e) === "depot" ? td(e) : dd(e) : { subdivisions: [] };
9009
+ function Ed(e) {
9010
+ return e ? _d(e) === "depot" ? id(e) : md(e) : { subdivisions: [] };
8992
9011
  }
8993
9012
  //#endregion
8994
- export { Ju as iterRechercheAmendements, Yu as iterRechercheRawAmendements, Cd as parsePlf, gd as parsePlfCredits, Wu as parseTexte };
9013
+ export { Zu as iterRechercheAmendements, Qu as iterRechercheRawAmendements, Ed as parsePlf, yd as parsePlfCredits, qu as parseTexte };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/assemblee",
3
- "version": "3.7.1",
3
+ "version": "3.7.2",
4
4
  "description": "Retrieve, clean up & handle French Assemblée nationale's open data",
5
5
  "keywords": [
6
6
  "Assemblée nationale",