@tricoteuses/assemblee 3.7.0 → 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.
@@ -11,12 +11,14 @@ export interface ArtifactManifest extends ArtifactVersion {
11
11
  sha256: string;
12
12
  }
13
13
  export interface DiscoveryOptions {
14
+ circuitBreakerCooldownMs?: number;
14
15
  fetch?: typeof fetch;
15
16
  probeCount?: number;
16
17
  timeoutMs?: number;
17
18
  }
18
19
  export interface DownloadOptions {
19
20
  chunkSizeBytes?: number;
21
+ circuitBreakerCooldownMs?: number;
20
22
  fetch?: typeof fetch;
21
23
  maxRetryDurationMs?: number;
22
24
  now?: () => number;
@@ -37,6 +39,8 @@ export interface DownloadRetryEvent {
37
39
  request: number;
38
40
  sourceUrl: string;
39
41
  }
42
+ /** Forget a previously tripped circuit breaker (mainly useful in tests). */
43
+ export declare function resetCircuitBreaker(): void;
40
44
  export declare function formatDuration(milliseconds: number): string;
41
45
  export interface ErrorDiagnostic {
42
46
  cause?: ErrorDiagnostic;
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,20 +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) {
8549
- let t = Nu(Pu(e)), n = [], r = [], i = "generalExpose", a = null, o = null, s = t("h1, h2, h3, h4, h5, h6, p.assnatFPFexpogentitre1, p.assnatFPFexpogentexte, li.assnatFPFexpogentexte, li.assnatFPFprojetloiartexte, p.assnatFPFprojetloiartexte, p.assnatFPFfinartexte, table, img").toArray(), c = () => {
8550
- o && (n.push(o), o = null);
8567
+ function id(e) {
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 = () => {
8569
+ o && s.length > 0 && (o.alineas = ad(s)), s = [];
8570
+ }, u = () => {
8571
+ o && (l(), n.push(o), o = null);
8551
8572
  };
8552
- for (let e of s) {
8573
+ for (let e of c) {
8553
8574
  if (i === "done") break;
8554
- let s = t(e), g = Q(s.text()), _ = rd(s), v = _ !== null, y = _ !== null && _ >= 2 && _ <= 5, b = s.hasClass("assnatFPFexpogentitre1"), x = s.hasClass("assnatFPFexpogentexte"), S = s.hasClass("assnatFPFprojetloiartexte"), te = s.hasClass("assnatFPFfinartexte"), ne = s.is("table"), re = s.is("img"), ie = s.find("img").length > 0;
8555
- if (!(v && g.length === 0) && !(ne && s.find("p.assnatFARTT08Bleu").length > 0) && !(ne && nd(s)) && !(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)) {
8556
8577
  if (i === "generalExpose") {
8557
8578
  if (_ === 1) {
8558
8579
  let e = g.toLowerCase();
@@ -8560,96 +8581,151 @@ function td(e) {
8560
8581
  a && n.push(a), a = null, i = "hierarchy";
8561
8582
  continue;
8562
8583
  }
8563
- 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)));
8564
8585
  }
8565
8586
  if (y && (a && n.push(a), a = null, i = "hierarchy"), a) {
8566
- if (re) {
8567
- let e = od(s);
8587
+ if (ie) {
8588
+ let e = pd(c);
8568
8589
  if (e) {
8569
- var l;
8570
- (l = a).alineas ?? (l.alineas = []), a.alineas.push(e);
8590
+ var d;
8591
+ (d = a).alineas ?? (d.alineas = []), a.alineas.push(e);
8571
8592
  }
8572
8593
  } else if ((_ === 1 || _ === 6) && g.length > 0) {
8573
- var u;
8574
- (u = a).titres ?? (u.titres = []), a.titres.push($(s));
8594
+ var f;
8595
+ (f = a).titres ?? (f.titres = []), a.titres.push($(c));
8575
8596
  } else if (b || x) {
8576
- let e = ie ? id(s) : $(s);
8597
+ let e = ae ? dd(c) : $(c);
8577
8598
  if (e) {
8578
- var d;
8579
- (d = a).alineas ?? (d.alineas = []), a.alineas.push(e);
8599
+ var p;
8600
+ (p = a).alineas ?? (p.alineas = []), a.alineas.push(e);
8580
8601
  }
8581
- } else if (ne) {
8582
- var f;
8583
- (f = a).alineas ?? (f.alineas = []), a.alineas.push($u(s));
8602
+ } else if (re) {
8603
+ var ee;
8604
+ (ee = a).alineas ?? (ee.alineas = []), a.alineas.push(nd(c));
8584
8605
  }
8585
8606
  continue;
8586
8607
  }
8587
8608
  }
8588
- if (Qu(g)) {
8589
- c(), a && (n.push(a), a = null), i = "done";
8609
+ if (td(g)) {
8610
+ u(), a && (n.push(a), a = null), i = "done";
8590
8611
  continue;
8591
8612
  }
8592
8613
  if (_ !== 1) {
8593
8614
  if (y) {
8594
- c();
8595
- let e = _ - 2, t = ed[e];
8615
+ u();
8616
+ let e = _ - 2, t = rd[e];
8596
8617
  for (; r.length > 0 && r[r.length - 1] >= e;) r.pop();
8597
8618
  r.push(e);
8598
- let a = Zu(`D_${Xu(g)}`, t, e + 1, r.length);
8599
- a.titres = [$(s)], n.push(a), i = "hierarchy";
8619
+ let a = ed(`D_${$u(g)}`, t, e + 1, r.length);
8620
+ a.titres = [$(c)], n.push(a), i = "hierarchy";
8600
8621
  continue;
8601
8622
  }
8602
8623
  if (_ === 6) {
8603
- c();
8624
+ u();
8604
8625
  let e = r.length + 1;
8605
- o = Zu(`D_${Xu(g)}`, "Article", 5, e), o.titres = [$(s)], i = "articleBody";
8626
+ o = ed(`D_${$u(g)}`, "Article", 5, e), o.titres = [$(c)], s = [], i = "articleBody";
8606
8627
  continue;
8607
8628
  }
8608
8629
  if (S && i === "articleBody" && o) {
8609
- var p;
8630
+ s.push({
8631
+ type: "marker",
8632
+ number: cd(g)
8633
+ });
8634
+ continue;
8635
+ }
8636
+ if (te && i === "articleBody" && o) {
8610
8637
  if (g.length === 0) continue;
8611
- (p = o).alineas ?? (p.alineas = []), o.alineas.push($(s));
8638
+ s.push({
8639
+ type: "content",
8640
+ content: $(c)
8641
+ });
8612
8642
  continue;
8613
8643
  }
8614
- if (ne && i === "articleBody" && o) {
8615
- var ee;
8616
- (ee = o).alineas ?? (ee.alineas = []), o.alineas.push($u(s));
8644
+ if (re && i === "articleBody" && o) {
8645
+ s.push({
8646
+ type: "content",
8647
+ content: nd(c)
8648
+ });
8617
8649
  continue;
8618
8650
  }
8619
- if (te && o) {
8620
- i = "articleExpose";
8651
+ if (ne && o) {
8652
+ l(), i = "articleExpose";
8621
8653
  continue;
8622
8654
  }
8623
8655
  if (b && i === "articleBody" && o) {
8624
- i = "articleExpose";
8656
+ l(), i = "articleExpose";
8625
8657
  continue;
8626
8658
  }
8627
8659
  if (i === "articleExpose" && o) {
8628
8660
  if (b) continue;
8629
8661
  if (x) {
8630
8662
  var m;
8631
- (m = o).exposeDesMotifs ?? (m.exposeDesMotifs = []), o.exposeDesMotifs.push($(s));
8663
+ (m = o).exposeDesMotifs ?? (m.exposeDesMotifs = []), o.exposeDesMotifs.push($(c));
8632
8664
  continue;
8633
8665
  }
8634
- if (ne) {
8666
+ if (re) {
8635
8667
  var h;
8636
- (h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push($u(s));
8668
+ (h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push(nd(c));
8637
8669
  }
8638
8670
  }
8639
8671
  }
8640
8672
  }
8641
8673
  }
8642
- return c(), a && n.push(a), { subdivisions: n };
8674
+ return u(), a && n.push(a), { subdivisions: n };
8643
8675
  }
8644
- function nd(e) {
8676
+ function ad(e) {
8677
+ let t = e.flatMap((e) => e.type === "content" ? [e.content] : []);
8678
+ if (e.length - t.length === 0) return t;
8679
+ let n = [], r, i;
8680
+ for (let a of e) {
8681
+ if (a.type === "content") {
8682
+ if (!r) return t;
8683
+ r.contents.push(a.content);
8684
+ continue;
8685
+ }
8686
+ if (a.number === void 0 || (i === void 0 ? a.number !== 1 : a.number <= i)) return t;
8687
+ r = {
8688
+ number: a.number,
8689
+ contents: []
8690
+ }, n.push(r), i = a.number;
8691
+ }
8692
+ od(n);
8693
+ let a = [];
8694
+ for (let e = 0; e < n.length; e++) {
8695
+ let r = n[e], i = n[e + 1], o = i ? i.number - r.number : 1;
8696
+ if (r.contents.length < o) return t;
8697
+ for (let e = 0; e < o - 1; e++) a.push(r.contents[e]);
8698
+ a.push(sd(r.contents.slice(o - 1)));
8699
+ }
8700
+ return a;
8701
+ }
8702
+ function od(e) {
8703
+ for (let t = 0; t < e.length - 1; t++) {
8704
+ let n = e[t].contents, r = e[t + 1].contents, i = n[n.length - 1];
8705
+ i?.texte?.trim() === "«" && r.some(({ html: e }) => /<table\b/.test(e ?? "")) && (n.pop(), r.unshift(i));
8706
+ }
8707
+ }
8708
+ function sd(e) {
8709
+ return {
8710
+ texte: e.flatMap(({ texte: e }) => e === void 0 ? [] : [e]).join("\n"),
8711
+ html: e.flatMap(({ html: e }) => e === void 0 ? [] : [e]).join("\n")
8712
+ };
8713
+ }
8714
+ function cd(e) {
8715
+ let t = /^\((\d+)\)$/.exec(e);
8716
+ if (!t) return;
8717
+ let n = Number(t[1]);
8718
+ return Number.isSafeInteger(n) && n > 0 ? n : void 0;
8719
+ }
8720
+ function ld(e) {
8645
8721
  let t = e.children("tbody").children("tr").add(e.children("tr"));
8646
8722
  return t.length === 1 && t.children("td").length === 1 && e.find("h6, .assnatFPFexpogentexte").length > 0;
8647
8723
  }
8648
- function rd(e) {
8724
+ function ud(e) {
8649
8725
  for (let t = 1; t <= 6; t++) if (e.is(`h${t}`)) return t;
8650
8726
  return null;
8651
8727
  }
8652
- function id(e) {
8728
+ function dd(e) {
8653
8729
  let t = e.clone();
8654
8730
  t.find("img").remove();
8655
8731
  let n = Q(t.text());
@@ -8658,14 +8734,14 @@ function id(e) {
8658
8734
  html: Q(t.html())
8659
8735
  } : null;
8660
8736
  }
8661
- function ad(e) {
8737
+ function fd(e) {
8662
8738
  if (!e || !/^\d+$/.test(e)) return;
8663
8739
  let t = Number(e);
8664
8740
  return t > 0 ? t : void 0;
8665
8741
  }
8666
- function od(e) {
8742
+ function pd(e) {
8667
8743
  if (!e.attr("src")) return null;
8668
- let t = ad(e.attr("width")), n = ad(e.attr("height"));
8744
+ let t = fd(e.attr("width")), n = fd(e.attr("height"));
8669
8745
  return t === 15 && n === 15 || t === 2 && n === 138 ? null : {
8670
8746
  texte: Q(e.attr("alt") ?? ""),
8671
8747
  html: e.prop("outerHTML") || ""
@@ -8673,18 +8749,18 @@ function od(e) {
8673
8749
  }
8674
8750
  //#endregion
8675
8751
  //#region src/parsers/plf/later_stage.ts
8676
- function sd(e) {
8752
+ function md(e) {
8677
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();
8678
8754
  for (let e of c) {
8679
8755
  let c = t(e), l = Q(c.text());
8680
- 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;
8681
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");
8682
8758
  if (d) {
8683
8759
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 0;) r.pop();
8684
8760
  r.push(0);
8685
- let e = cd(a, $(c));
8761
+ let e = hd(a, $(c));
8686
8762
  a = null, o = null;
8687
- 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);
8688
8764
  t.titres = [e], n.push(t);
8689
8765
  continue;
8690
8766
  }
@@ -8695,9 +8771,9 @@ function sd(e) {
8695
8771
  if (p) {
8696
8772
  for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 1;) r.pop();
8697
8773
  r.push(1);
8698
- let e = cd(o, $(c));
8774
+ let e = hd(o, $(c));
8699
8775
  o = null;
8700
- 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);
8701
8777
  t.titres = [e], n.push(t);
8702
8778
  continue;
8703
8779
  }
@@ -8708,7 +8784,7 @@ function sd(e) {
8708
8784
  if (ee) {
8709
8785
  i && n.push(i);
8710
8786
  let e = r.length + 1;
8711
- i = Zu(`D_${Xu(l)}`, "Article", 5, e), i.titres = [$(c)];
8787
+ i = ed(`D_${$u(l)}`, "Article", 5, e), i.titres = [$(c)];
8712
8788
  continue;
8713
8789
  }
8714
8790
  if (m) {
@@ -8718,7 +8794,7 @@ function sd(e) {
8718
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;
8719
8795
  for (; r.length > 0 && r[r.length - 1] >= d;) r.pop();
8720
8796
  r.push(d);
8721
- let f = Zu(`D_${Xu(l)}`, u, d + 1, r.length);
8797
+ let f = ed(`D_${$u(l)}`, u, d + 1, r.length);
8722
8798
  f.titres = [$(c)], n.push(f);
8723
8799
  continue;
8724
8800
  }
@@ -8726,14 +8802,14 @@ function sd(e) {
8726
8802
  continue;
8727
8803
  }
8728
8804
  if (h && i) {
8729
- i.alineas = i.alineas || [], i.alineas.push($u(c));
8805
+ i.alineas = i.alineas || [], i.alineas.push(nd(c));
8730
8806
  continue;
8731
8807
  }
8732
8808
  (/assnat5Chapitre(Intit|Num)/.test(c.attr("class") ?? "") || /assnat6Section(Intit|Num)/.test(c.attr("class") ?? "")) && i && (i.alineas = i.alineas || [], i.alineas.push($(c)));
8733
8809
  }
8734
8810
  return i && n.push(i), { subdivisions: n };
8735
8811
  }
8736
- function cd(e, t) {
8812
+ function hd(e, t) {
8737
8813
  return e === null ? t : {
8738
8814
  texte: `${e.texte} : ${t.texte}`,
8739
8815
  html: `${e.html} : ${t.html}`
@@ -8741,20 +8817,20 @@ function cd(e, t) {
8741
8817
  }
8742
8818
  //#endregion
8743
8819
  //#region src/parsers/plf/variant_detection.ts
8744
- var ld = [
8820
+ var gd = [
8745
8821
  "assnatFPFexpogentexte",
8746
8822
  "assnatFPFexpogentitre1",
8747
8823
  "assnatFPFexpogentitre2",
8748
8824
  "assnatFPFexpogentitre3",
8749
8825
  "assnatFPFexpogentitre4"
8750
8826
  ];
8751
- function ud(e) {
8827
+ function _d(e) {
8752
8828
  let t = Nu(Pu(e));
8753
- 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(ld.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";
8754
8830
  }
8755
8831
  //#endregion
8756
8832
  //#region src/parsers/plf/credits.ts
8757
- var dd = {
8833
+ var vd = {
8758
8834
  bg: {
8759
8835
  budgetType: "budgetGeneral",
8760
8836
  libelle: "Budget général"
@@ -8772,15 +8848,15 @@ var dd = {
8772
8848
  libelle: "Comptes de concours financiers"
8773
8849
  }
8774
8850
  };
8775
- function fd(e) {
8851
+ function yd(e) {
8776
8852
  if (!e) return [];
8777
- let t = Nu(Pu(e)), n = vd(t);
8853
+ let t = Nu(Pu(e)), n = Td(t);
8778
8854
  if (n.length === 0) return [];
8779
8855
  let r = [];
8780
8856
  for (let e of n) {
8781
8857
  let n = [], i;
8782
8858
  for (let r of e.tableEls) {
8783
- let e = gd(t, r);
8859
+ let e = Cd(t, r);
8784
8860
  n.push(...e.missions), e.total && (i = e.total);
8785
8861
  }
8786
8862
  n.length === 0 && !e.estConformeVersionPrecedente || r.push({
@@ -8796,7 +8872,7 @@ function fd(e) {
8796
8872
  }
8797
8873
  return r;
8798
8874
  }
8799
- function pd(e) {
8875
+ function bd(e) {
8800
8876
  let t = Q(e).replace(/[\u2212\u2011]/g, "-").replace(/\s/g, "").replace(/[^0-9,.-]/g, ""), n = (t.match(/,/g) ?? []).length;
8801
8877
  if (n > 1) return;
8802
8878
  let r = n === 1 ? t.replace(/\./g, "").replace(",", ".") : t;
@@ -8804,23 +8880,23 @@ function pd(e) {
8804
8880
  let i = Number(r);
8805
8881
  return Number.isNaN(i) ? void 0 : i;
8806
8882
  }
8807
- function md(e) {
8883
+ function xd(e) {
8808
8884
  let t = Q(e);
8809
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();
8810
8886
  }
8811
- function hd(e, t) {
8812
- let n = pd(t(e[1]).text()), r = pd(t(e[2]).text());
8887
+ function Sd(e, t) {
8888
+ let n = bd(t(e[1]).text()), r = bd(t(e[2]).text());
8813
8889
  return e.length >= 5 ? {
8814
8890
  autorisationEngagement: n,
8815
8891
  creditPaiement: r,
8816
- autorisationEngagementAnnule: pd(t(e[3]).text()),
8817
- creditPaiementAnnule: pd(t(e[4]).text())
8892
+ autorisationEngagementAnnule: bd(t(e[3]).text()),
8893
+ creditPaiementAnnule: bd(t(e[4]).text())
8818
8894
  } : {
8819
8895
  autorisationEngagement: n,
8820
8896
  creditPaiement: r
8821
8897
  };
8822
8898
  }
8823
- function gd(e, t) {
8899
+ function Cd(e, t) {
8824
8900
  let n = [], r = null, i = null, a, o = e(t).find("tbody tr").toArray(), s = o.some((t) => {
8825
8901
  let n = (e(t).find("td").first().attr("style") || "").replace(/[\n\t]/g, " ");
8826
8902
  return /border-top/.test(n);
@@ -8830,7 +8906,7 @@ function gd(e, t) {
8830
8906
  if (o.length < 3) continue;
8831
8907
  let c = e(o[0]), l = (c.attr("style") || "").replace(/[\n\t]/g, " "), u = Q(c.text());
8832
8908
  if (!u) continue;
8833
- let d = /^total/i.test(u), f = hd(o, e);
8909
+ let d = /^total/i.test(u), f = Sd(o, e);
8834
8910
  if (d) {
8835
8911
  a = f;
8836
8912
  continue;
@@ -8844,7 +8920,7 @@ function gd(e, t) {
8844
8920
  }
8845
8921
  if (s ? /border-top/.test(l) : /border-bottom/.test(l)) {
8846
8922
  r && n.push(r);
8847
- let e = md(c.text());
8923
+ let e = xd(c.text());
8848
8924
  if (e === void 0) {
8849
8925
  r = null, i = null;
8850
8926
  continue;
@@ -8858,7 +8934,7 @@ function gd(e, t) {
8858
8934
  continue;
8859
8935
  }
8860
8936
  if (r) {
8861
- let e = md(c.text());
8937
+ let e = xd(c.text());
8862
8938
  if (e === void 0) {
8863
8939
  i = null;
8864
8940
  continue;
@@ -8874,11 +8950,11 @@ function gd(e, t) {
8874
8950
  total: a
8875
8951
  };
8876
8952
  }
8877
- function _d(e, t) {
8953
+ function wd(e, t) {
8878
8954
  let n = e(t).find("tr").slice(0, 3).find("th, td").toArray().map((t) => Q(e(t).text()).toLocaleLowerCase("fr"));
8879
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"));
8880
8956
  }
8881
- function vd(e) {
8957
+ function Td(e) {
8882
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);
8883
8959
  for (let o of a) {
8884
8960
  let a = e(o);
@@ -8895,7 +8971,7 @@ function vd(e) {
8895
8971
  for (let t of e) {
8896
8972
  let e = i.get(t);
8897
8973
  e ? e.estConformeVersionPrecedente = !0 : i.set(t, {
8898
- ...dd[t],
8974
+ ...vd[t],
8899
8975
  tableEls: [],
8900
8976
  estConformeVersionPrecedente: !0
8901
8977
  });
@@ -8911,7 +8987,7 @@ function vd(e) {
8911
8987
  s !== /COMPTES\s+DE\s+CONCOURS\s+FINANCIERS/i.test(e) && (n = s ? "cas" : "ccf");
8912
8988
  continue;
8913
8989
  }
8914
- if (!_d(e, o)) continue;
8990
+ if (!wd(e, o)) continue;
8915
8991
  let s = t === "B" ? "bg" : t === "C" ? "ba" : t === "D" ? n : void 0;
8916
8992
  if (!s) continue;
8917
8993
  r = !0;
@@ -8921,7 +8997,7 @@ function vd(e) {
8921
8997
  continue;
8922
8998
  }
8923
8999
  i.set(s, {
8924
- ...dd[s],
9000
+ ...vd[s],
8925
9001
  tableEls: [o],
8926
9002
  estConformeVersionPrecedente: !1
8927
9003
  });
@@ -8930,8 +9006,8 @@ function vd(e) {
8930
9006
  }
8931
9007
  //#endregion
8932
9008
  //#region src/parsers/plf/index.ts
8933
- function yd(e) {
8934
- return e ? ud(e) === "depot" ? td(e) : sd(e) : { subdivisions: [] };
9009
+ function Ed(e) {
9010
+ return e ? _d(e) === "depot" ? id(e) : md(e) : { subdivisions: [] };
8935
9011
  }
8936
9012
  //#endregion
8937
- export { Ju as iterRechercheAmendements, Yu as iterRechercheRawAmendements, yd as parsePlf, fd as parsePlfCredits, Wu as parseTexte };
9013
+ export { Zu as iterRechercheAmendements, Qu as iterRechercheRawAmendements, Ed as parsePlf, yd as parsePlfCredits, qu as parseTexte };
@@ -0,0 +1 @@
1
+ export declare function ensureSenateurPhoto(urlPhoto: string, photoFilePath: string, width: number, height: number): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/assemblee",
3
- "version": "3.7.0",
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",