@lystech/sections 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1208 @@
1
+ import { jsx as e, jsxs as b, Fragment as Q } from "react/jsx-runtime";
2
+ import { createRoot as Z } from "react-dom/client";
3
+ import { useState as k, useRef as F, useEffect as B, useCallback as H, useMemo as W } from "react";
4
+ function se({
5
+ jeton: n,
6
+ site: t,
7
+ apiBaseUrl: c,
8
+ surJetonRefuse: r
9
+ }) {
10
+ const a = {
11
+ "Content-Type": "application/json",
12
+ Authorization: "Bearer " + n
13
+ };
14
+ function f(o, i) {
15
+ if (i && (o.status === 401 || o.status === 403) && r(), !o.ok) throw new Error(String(o.status));
16
+ }
17
+ async function u(o, i = !0) {
18
+ const h = await fetch(c + o, {
19
+ headers: i ? a : void 0
20
+ });
21
+ return f(h, i), await h.json();
22
+ }
23
+ async function m(o, i, h) {
24
+ const g = await fetch(c + o, {
25
+ method: i,
26
+ headers: a,
27
+ body: h === void 0 ? void 0 : JSON.stringify(h)
28
+ });
29
+ return f(g, !0), await g.json();
30
+ }
31
+ return {
32
+ /** Les blocs que le site a déclaré savoir afficher. Route publique. */
33
+ schemas: () => u("/site-sections/public/" + encodeURIComponent(t) + "/schemas", !1),
34
+ /** Ce qui existe sur une page, brouillons compris. */
35
+ pourPage: (o) => u("/site-sections?page=" + encodeURIComponent(o)),
36
+ creer: (o, i, h) => m("/site-sections", "POST", { page: o, blockType: i, draft: h }),
37
+ enregistrerBrouillon: (o, i) => m("/site-sections/" + o + "/draft", "PUT", { draft: i }),
38
+ publier: (o) => m("/site-sections/" + o + "/publish", "POST"),
39
+ /** Ramène le brouillon à ce qui est en ligne. */
40
+ annuler: (o) => m("/site-sections/" + o + "/revert", "POST")
41
+ };
42
+ }
43
+ function ce({
44
+ site: n,
45
+ apiBaseUrl: t,
46
+ surJeton: c,
47
+ surFermer: r
48
+ }) {
49
+ const [a, f] = k(""), [u, m] = k(""), [o, i] = k({ nom: "repos" }), h = async (v) => {
50
+ if (!a || !u) {
51
+ i({ nom: "erreur", texte: "Entrez votre adresse et votre mot de passe." });
52
+ return;
53
+ }
54
+ i({ nom: "envoi" });
55
+ try {
56
+ const S = await fetch(t + "/site-sections/edit-login", {
57
+ method: "POST",
58
+ headers: { "Content-Type": "application/json" },
59
+ body: JSON.stringify({ site: n, email: a, password: u, demanderAcces: v })
60
+ });
61
+ if (S.status === 429) {
62
+ i({
63
+ nom: "erreur",
64
+ texte: "Trop de tentatives. Réessayez dans quelques minutes."
65
+ });
66
+ return;
67
+ }
68
+ const _ = await S.json().catch(() => null);
69
+ if (_?.ok && _?.token) {
70
+ c(_.token);
71
+ return;
72
+ }
73
+ if (_?.raison === "sans_acces") {
74
+ i({ nom: "sans-acces" });
75
+ return;
76
+ }
77
+ if (_?.raison === "demande_envoyee") {
78
+ i({ nom: "demande-envoyee" });
79
+ return;
80
+ }
81
+ if (_?.raison === "trop_de_demandes") {
82
+ i({
83
+ nom: "erreur",
84
+ texte: "Trop de demandes aujourd'hui. Réessayez demain."
85
+ });
86
+ return;
87
+ }
88
+ i({
89
+ nom: "erreur",
90
+ texte: "Adresse ou mot de passe incorrect."
91
+ });
92
+ } catch {
93
+ i({
94
+ nom: "erreur",
95
+ texte: "Connexion au serveur impossible. Vérifiez votre réseau."
96
+ });
97
+ }
98
+ }, g = o.nom === "envoi";
99
+ return /* @__PURE__ */ e("div", { className: "voile", role: "dialog", "aria-modal": "true", "aria-label": "Modifier ce site", children: /* @__PURE__ */ b("div", { className: "fenetre", children: [
100
+ /* @__PURE__ */ b("div", { className: "panneau__tete", children: [
101
+ /* @__PURE__ */ b("div", { style: { flex: 1 }, children: [
102
+ /* @__PURE__ */ e("h2", { className: "panneau__titre", children: "Modifier ce site" }),
103
+ /* @__PURE__ */ e("p", { className: "panneau__sous", children: "Vous vous connectez à Lystech. Cet accès ne sert qu'à modifier le contenu de ce site." })
104
+ ] }),
105
+ /* @__PURE__ */ e(
106
+ "button",
107
+ {
108
+ type: "button",
109
+ className: "bouton bouton--icone bouton--discret",
110
+ onClick: r,
111
+ "aria-label": "Fermer",
112
+ children: "✕"
113
+ }
114
+ )
115
+ ] }),
116
+ /* @__PURE__ */ b(
117
+ "form",
118
+ {
119
+ className: "panneau__corps",
120
+ onSubmit: (v) => {
121
+ v.preventDefault(), h(!1);
122
+ },
123
+ children: [
124
+ o.nom === "erreur" && /* @__PURE__ */ e("p", { className: "message message--erreur", children: o.texte }),
125
+ o.nom === "sans-acces" && /* @__PURE__ */ e("p", { className: "message message--info", children: "Vous êtes bien reconnu, mais vous n'avez pas encore le droit de modifier ce site. Vous pouvez le demander : la personne responsable recevra un courriel." }),
126
+ o.nom === "demande-envoyee" && /* @__PURE__ */ e("p", { className: "message message--ok", children: "Demande envoyée. La personne responsable du site vous répondra." }),
127
+ o.nom !== "demande-envoyee" && /* @__PURE__ */ b(Q, { children: [
128
+ /* @__PURE__ */ b("div", { className: "champ", children: [
129
+ /* @__PURE__ */ e("label", { className: "champ__etiquette", htmlFor: "lys-courriel", children: "Adresse courriel" }),
130
+ /* @__PURE__ */ e(
131
+ "input",
132
+ {
133
+ id: "lys-courriel",
134
+ type: "text",
135
+ inputMode: "email",
136
+ autoComplete: "email",
137
+ value: a,
138
+ disabled: g,
139
+ onChange: (v) => f(v.target.value)
140
+ }
141
+ )
142
+ ] }),
143
+ /* @__PURE__ */ b("div", { className: "champ", children: [
144
+ /* @__PURE__ */ e("label", { className: "champ__etiquette", htmlFor: "lys-mdp", children: "Mot de passe" }),
145
+ /* @__PURE__ */ e(
146
+ "input",
147
+ {
148
+ id: "lys-mdp",
149
+ type: "password",
150
+ autoComplete: "current-password",
151
+ value: u,
152
+ disabled: g,
153
+ onChange: (v) => m(v.target.value)
154
+ }
155
+ )
156
+ ] })
157
+ ] }),
158
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 8, marginTop: 4 }, children: o.nom === "sans-acces" ? /* @__PURE__ */ e(
159
+ "button",
160
+ {
161
+ type: "button",
162
+ className: "bouton bouton--principal",
163
+ disabled: g,
164
+ onClick: () => {
165
+ h(!0);
166
+ },
167
+ children: "Demander l'accès"
168
+ }
169
+ ) : o.nom === "demande-envoyee" ? /* @__PURE__ */ e("button", { type: "button", className: "bouton", onClick: r, children: "Fermer" }) : /* @__PURE__ */ e(
170
+ "button",
171
+ {
172
+ type: "submit",
173
+ className: "bouton bouton--principal",
174
+ disabled: g,
175
+ children: g ? "Vérification…" : "Se connecter"
176
+ }
177
+ ) })
178
+ ]
179
+ }
180
+ )
181
+ ] }) });
182
+ }
183
+ function le(n, t) {
184
+ const c = n && typeof n == "object" && !Array.isArray(n) ? Object.keys(n).filter((a) => /^[a-z]{2}(-[A-Za-z]{2})?$/.test(a)) : [], r = t.slice(0, 2);
185
+ return Array.from(/* @__PURE__ */ new Set([r, ...c]));
186
+ }
187
+ function ue(n) {
188
+ switch (n.type) {
189
+ case "number":
190
+ return 0;
191
+ case "boolean":
192
+ return !1;
193
+ case "list":
194
+ return [];
195
+ default:
196
+ return "";
197
+ }
198
+ }
199
+ function G({ champ: n, valeur: t, changer: c }) {
200
+ switch (n.type) {
201
+ case "richText":
202
+ return /* @__PURE__ */ e(
203
+ "textarea",
204
+ {
205
+ value: String(t ?? ""),
206
+ onChange: (r) => c(r.target.value)
207
+ }
208
+ );
209
+ case "number":
210
+ return /* @__PURE__ */ e(
211
+ "input",
212
+ {
213
+ type: "number",
214
+ value: t === "" || t == null ? "" : String(t),
215
+ onChange: (r) => c(r.target.value === "" ? "" : Number(r.target.value))
216
+ }
217
+ );
218
+ case "boolean":
219
+ return /* @__PURE__ */ b("label", { className: "bascule", children: [
220
+ /* @__PURE__ */ e(
221
+ "input",
222
+ {
223
+ type: "checkbox",
224
+ checked: t === !0,
225
+ onChange: (r) => c(r.target.checked)
226
+ }
227
+ ),
228
+ /* @__PURE__ */ e("span", { children: t === !0 ? "Oui" : "Non" })
229
+ ] });
230
+ case "date":
231
+ return /* @__PURE__ */ e(
232
+ "input",
233
+ {
234
+ type: "date",
235
+ value: String(t ?? "").slice(0, 10),
236
+ onChange: (r) => c(r.target.value)
237
+ }
238
+ );
239
+ case "choice":
240
+ return /* @__PURE__ */ b(
241
+ "select",
242
+ {
243
+ value: String(t ?? ""),
244
+ onChange: (r) => c(r.target.value),
245
+ children: [
246
+ /* @__PURE__ */ e("option", { value: "", children: "—" }),
247
+ (n.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
248
+ ]
249
+ }
250
+ );
251
+ case "url":
252
+ return /* @__PURE__ */ e(
253
+ "input",
254
+ {
255
+ type: "url",
256
+ value: String(t ?? ""),
257
+ onChange: (r) => c(r.target.value),
258
+ placeholder: "https://"
259
+ }
260
+ );
261
+ case "image":
262
+ return /* @__PURE__ */ b(Q, { children: [
263
+ /* @__PURE__ */ e(
264
+ "input",
265
+ {
266
+ type: "url",
267
+ value: String(t ?? ""),
268
+ onChange: (r) => c(r.target.value),
269
+ placeholder: "https://…"
270
+ }
271
+ ),
272
+ String(t ?? "").startsWith("http") && /* @__PURE__ */ e("img", { className: "vignette", src: String(t), alt: "" })
273
+ ] });
274
+ default:
275
+ return /* @__PURE__ */ e(
276
+ "input",
277
+ {
278
+ type: "text",
279
+ value: String(t ?? ""),
280
+ onChange: (r) => c(r.target.value)
281
+ }
282
+ );
283
+ }
284
+ }
285
+ function ee({ champ: n, valeur: t, changer: c, langue: r }) {
286
+ if (n.type === "list") {
287
+ const a = Array.isArray(t) ? t : [], f = n.of ?? [], u = (m, o, i) => {
288
+ const h = a.map((g, v) => v === m ? { ...g, [o]: i } : g);
289
+ c(h);
290
+ };
291
+ return /* @__PURE__ */ b("div", { className: "champ", children: [
292
+ /* @__PURE__ */ e("span", { className: "champ__etiquette", children: n.label }),
293
+ n.help && /* @__PURE__ */ e("p", { className: "champ__aide", children: n.help }),
294
+ a.map((m, o) => /* @__PURE__ */ b("div", { className: "liste__item", children: [
295
+ /* @__PURE__ */ b("div", { className: "liste__tete", children: [
296
+ /* @__PURE__ */ e("span", { className: "liste__rang", children: o + 1 }),
297
+ /* @__PURE__ */ b("span", { style: { display: "flex", gap: 4 }, children: [
298
+ /* @__PURE__ */ e(
299
+ "button",
300
+ {
301
+ type: "button",
302
+ className: "bouton bouton--icone bouton--discret",
303
+ title: "Monter",
304
+ disabled: o === 0,
305
+ onClick: () => {
306
+ const i = [...a];
307
+ [i[o - 1], i[o]] = [i[o], i[o - 1]], c(i);
308
+ },
309
+ children: "↑"
310
+ }
311
+ ),
312
+ /* @__PURE__ */ e(
313
+ "button",
314
+ {
315
+ type: "button",
316
+ className: "bouton bouton--icone bouton--discret",
317
+ title: "Descendre",
318
+ disabled: o === a.length - 1,
319
+ onClick: () => {
320
+ const i = [...a];
321
+ [i[o], i[o + 1]] = [i[o + 1], i[o]], c(i);
322
+ },
323
+ children: "↓"
324
+ }
325
+ ),
326
+ /* @__PURE__ */ e(
327
+ "button",
328
+ {
329
+ type: "button",
330
+ className: "bouton bouton--icone bouton--discret",
331
+ title: "Retirer",
332
+ onClick: () => c(a.filter((i, h) => h !== o)),
333
+ children: "✕"
334
+ }
335
+ )
336
+ ] })
337
+ ] }),
338
+ f.map((i) => /* @__PURE__ */ e(
339
+ ee,
340
+ {
341
+ champ: i,
342
+ langue: r,
343
+ valeur: m?.[i.key],
344
+ changer: (h) => u(o, i.key, h)
345
+ },
346
+ i.key
347
+ ))
348
+ ] }, o)),
349
+ /* @__PURE__ */ e(
350
+ "button",
351
+ {
352
+ type: "button",
353
+ className: "bouton",
354
+ onClick: () => c([
355
+ ...a,
356
+ Object.fromEntries(f.map((m) => [m.key, ue(m)]))
357
+ ]),
358
+ children: "+ Ajouter"
359
+ }
360
+ )
361
+ ] });
362
+ }
363
+ if (n.localized) {
364
+ const a = le(t, r), f = t && typeof t == "object" && !Array.isArray(t) ? t : {};
365
+ return /* @__PURE__ */ b("div", { className: "champ", children: [
366
+ /* @__PURE__ */ e("span", { className: "champ__etiquette", children: n.label }),
367
+ n.help && /* @__PURE__ */ e("p", { className: "champ__aide", children: n.help }),
368
+ a.map((u) => /* @__PURE__ */ b("div", { style: { marginBottom: 8 }, children: [
369
+ /* @__PURE__ */ e("span", { className: "champ__langue", children: u }),
370
+ /* @__PURE__ */ e(
371
+ G,
372
+ {
373
+ champ: n,
374
+ valeur: f[u],
375
+ changer: (m) => c({ ...f, [u]: m })
376
+ }
377
+ )
378
+ ] }, u))
379
+ ] });
380
+ }
381
+ return /* @__PURE__ */ b("div", { className: "champ", children: [
382
+ /* @__PURE__ */ e("label", { className: "champ__etiquette", children: n.label }),
383
+ /* @__PURE__ */ e(G, { champ: n, valeur: t, changer: c }),
384
+ n.help && /* @__PURE__ */ e("p", { className: "champ__aide", children: n.help })
385
+ ] });
386
+ }
387
+ const de = ["lystech-editeur-hote", "lystech-connexion-hote"];
388
+ function pe(n) {
389
+ const t = /* @__PURE__ */ new Map();
390
+ for (const [c, r] of Object.entries(n))
391
+ for (const [a, f] of Object.entries(r)) {
392
+ const u = String(f ?? "").trim();
393
+ if (u.length < 2 || u.includes("{{")) continue;
394
+ const m = t.get(u);
395
+ m ? m.push({ ns: c, chemin: a }) : t.set(u, [{ ns: c, chemin: a }]);
396
+ }
397
+ return t;
398
+ }
399
+ function me(n) {
400
+ const t = /* @__PURE__ */ new Map(), c = document.body.querySelectorAll("*");
401
+ for (const r of c) {
402
+ if (de.some((u) => r.id === u || r.closest("#" + u)) || r.children.length > 0) continue;
403
+ const a = (r.textContent ?? "").trim();
404
+ if (a.length < 2) continue;
405
+ const f = n.get(a);
406
+ f && t.set(r, { valeur: a, candidats: f });
407
+ }
408
+ return t;
409
+ }
410
+ function be({
411
+ source: n,
412
+ actif: t,
413
+ surModification: c
414
+ }) {
415
+ const r = F(/* @__PURE__ */ new Map()), a = F(null), [f, u] = k(null), m = F(n);
416
+ m.current = n;
417
+ const o = F(c);
418
+ return o.current = c, B(() => {
419
+ if (!t) return;
420
+ const i = m.current.langueCourante(), h = pe(m.current.dictionnaire(i)), g = () => {
421
+ r.current = me(h);
422
+ };
423
+ g();
424
+ let v;
425
+ const S = new MutationObserver(() => {
426
+ a.current || (clearTimeout(v), v = setTimeout(g, 250));
427
+ });
428
+ S.observe(document.body, { childList: !0, subtree: !0 });
429
+ const _ = "outline:2px dashed rgba(59,165,141,.85);outline-offset:3px;border-radius:3px;cursor:text;", U = (d) => {
430
+ const s = d.target;
431
+ !(s instanceof HTMLElement) || a.current || r.current.has(s) && (s.dataset.lysStyleAvant || (s.dataset.lysStyleAvant = s.getAttribute("style") ?? ""), s.setAttribute(
432
+ "style",
433
+ (s.dataset.lysStyleAvant ?? "") + _
434
+ ));
435
+ }, z = (d) => {
436
+ const s = d.target;
437
+ if (!(s instanceof HTMLElement) || a.current?.el === s || s.dataset.lysStyleAvant === void 0) return;
438
+ const y = s.dataset.lysStyleAvant;
439
+ delete s.dataset.lysStyleAvant, y ? s.setAttribute("style", y) : s.removeAttribute("style");
440
+ }, T = (d, s) => {
441
+ const y = d.getAttribute("style") ?? "";
442
+ a.current = {
443
+ el: d,
444
+ avant: (d.textContent ?? "").trim(),
445
+ ns: s.ns,
446
+ chemin: s.chemin,
447
+ styleAvant: d.dataset.lysStyleAvant ?? y
448
+ }, d.setAttribute("contenteditable", "plaintext-only"), d.setAttribute(
449
+ "style",
450
+ (d.dataset.lysStyleAvant ?? "") + "outline:2px solid #3ba58d;outline-offset:3px;border-radius:3px;"
451
+ ), d.focus();
452
+ const P = window.getSelection(), O = document.createRange();
453
+ O.selectNodeContents(d), P?.removeAllRanges(), P?.addRange(O);
454
+ }, w = async (d) => {
455
+ const s = a.current;
456
+ if (!s) return;
457
+ a.current = null;
458
+ const y = (s.el.textContent ?? "").trim();
459
+ s.el.removeAttribute("contenteditable");
460
+ const P = s.el.dataset.lysStyleAvant;
461
+ if (delete s.el.dataset.lysStyleAvant, P ? s.el.setAttribute("style", P) : s.el.removeAttribute("style"), d || y === s.avant) {
462
+ d && (s.el.textContent = s.avant);
463
+ return;
464
+ }
465
+ const O = m.current.langueCourante();
466
+ m.current.poser(O, s.ns, s.chemin, y), await o.current(s.ns, s.chemin, O, y);
467
+ }, N = (d) => {
468
+ const s = d.target;
469
+ if (!(s instanceof HTMLElement)) return;
470
+ if (a.current) {
471
+ if (a.current.el === s) return;
472
+ w(!1);
473
+ }
474
+ const y = r.current.get(s);
475
+ if (y) {
476
+ if (d.preventDefault(), d.stopPropagation(), y.candidats.length === 1) {
477
+ T(s, y.candidats[0]);
478
+ return;
479
+ }
480
+ u({
481
+ el: s,
482
+ candidats: y.candidats,
483
+ x: d.clientX,
484
+ y: d.clientY
485
+ });
486
+ }
487
+ }, A = (d) => {
488
+ a.current && (d.key === "Escape" ? (d.preventDefault(), w(!0)) : d.key === "Enter" && !d.shiftKey && (d.preventDefault(), w(!1)));
489
+ }, M = () => {
490
+ a.current && w(!1);
491
+ };
492
+ document.addEventListener("mouseover", U, !0), document.addEventListener("mouseout", z, !0), document.addEventListener("click", N, !0);
493
+ const I = (d) => {
494
+ if (!a.current) return;
495
+ const s = d.inputType;
496
+ (s === "insertParagraph" || s === "insertLineBreak") && (d.preventDefault(), w(!1));
497
+ };
498
+ return document.addEventListener("beforeinput", I, !0), document.addEventListener("keydown", A, !0), document.addEventListener("focusout", M, !0), window.__lysChoisir = (d, s) => {
499
+ u(null), T(s, d);
500
+ }, () => {
501
+ clearTimeout(v), S.disconnect(), document.removeEventListener("mouseover", U, !0), document.removeEventListener("mouseout", z, !0), document.removeEventListener("click", N, !0), document.removeEventListener("beforeinput", I, !0), document.removeEventListener("keydown", A, !0), document.removeEventListener("focusout", M, !0), a.current && w(!0), delete window.__lysChoisir;
502
+ };
503
+ }, [t]), f ? /* @__PURE__ */ b(
504
+ "div",
505
+ {
506
+ className: "choix",
507
+ style: {
508
+ top: Math.min(f.y + 10, window.innerHeight - 200),
509
+ left: Math.min(f.x, window.innerWidth - 280)
510
+ },
511
+ children: [
512
+ /* @__PURE__ */ e("p", { className: "choix__titre", children: "Ce texte apparaît à plusieurs endroits." }),
513
+ /* @__PURE__ */ e("p", { className: "choix__aide", children: "Lequel corrigez-vous ?" }),
514
+ f.candidats.map((i) => /* @__PURE__ */ b(
515
+ "button",
516
+ {
517
+ type: "button",
518
+ className: "choix__option",
519
+ onClick: () => window.__lysChoisir?.(i, f.el),
520
+ children: [
521
+ /* @__PURE__ */ e("span", { className: "choix__chemin", children: i.chemin }),
522
+ /* @__PURE__ */ e("span", { className: "choix__ns", children: i.ns })
523
+ ]
524
+ },
525
+ i.ns + ":" + i.chemin
526
+ )),
527
+ /* @__PURE__ */ e(
528
+ "button",
529
+ {
530
+ type: "button",
531
+ className: "bouton bouton--discret",
532
+ onClick: () => u(null),
533
+ children: "Annuler"
534
+ }
535
+ )
536
+ ]
537
+ }
538
+ ) : null;
539
+ }
540
+ const Y = /^i18n:([^:]+):(.*)$/, J = "commun";
541
+ function K(n, t) {
542
+ return JSON.stringify(n ?? {}) === JSON.stringify(t ?? {});
543
+ }
544
+ function fe({ api: n, pont: t }) {
545
+ const [c, r] = k([]), [a, f] = k([]), [u, m] = k(t.page), [o, i] = k(null), [h, g] = k({}), [v, S] = k(!1), [_, U] = k("modifier"), [z, T] = k(!1), [w, N] = k(
546
+ null
547
+ );
548
+ B(() => (t.surChangementDePage = (l) => {
549
+ m(l), i(null), S(!1);
550
+ }, () => {
551
+ t.surChangementDePage = void 0;
552
+ }), [t]);
553
+ const A = H(async () => {
554
+ try {
555
+ const [l, p] = await Promise.all([
556
+ n.pourPage(u),
557
+ u === J ? Promise.resolve([]) : n.pourPage(J)
558
+ ]), x = [...l, ...p];
559
+ return f(x), x;
560
+ } catch {
561
+ return N({
562
+ ton: "erreur",
563
+ texte: "Impossible de lire le contenu du site."
564
+ }), [];
565
+ }
566
+ }, [n, u]);
567
+ B(() => {
568
+ n.schemas().then(r).catch(() => r([]));
569
+ }, [n]), B(() => {
570
+ A();
571
+ }, [A]);
572
+ const M = H(
573
+ (l, p) => {
574
+ let x = null, C = -1;
575
+ for (const R of c) {
576
+ const L = Y.exec(R.blockType);
577
+ if (!L || L[1] !== l) continue;
578
+ const q = L[2];
579
+ (q === "" || p === q || p.startsWith(q + ".")) && q.length > C && (x = R, C = q.length);
580
+ }
581
+ if (!x) return null;
582
+ const E = Y.exec(x.blockType)?.[2] ?? "", j = E ? p.slice(E.length + 1) : p;
583
+ return { bloc: x, champ: j };
584
+ },
585
+ [c]
586
+ ), I = H(
587
+ (l) => c.find((p) => p.blockType === l),
588
+ [c]
589
+ ), d = W(
590
+ () => c.filter((l) => {
591
+ const p = l.pages ?? [];
592
+ return p.includes(u) || p.includes(J);
593
+ }),
594
+ [c, u]
595
+ ), s = W(
596
+ () => a.filter((l) => l.draft && !K(l.draft, l.data)),
597
+ [a]
598
+ ), y = H(
599
+ async (l, p, x, C) => {
600
+ const E = M(l, p);
601
+ if (!E) {
602
+ N({
603
+ ton: "erreur",
604
+ texte: `Ce texte (${l}:${p}) n'appartient à aucun bloc déclaré.`
605
+ });
606
+ return;
607
+ }
608
+ const j = a.find((X) => X.blockType === E.bloc.blockType), R = j?.draft ?? j?.data ?? {}, L = R[E.champ], q = L && typeof L == "object" && !Array.isArray(L) ? { ...L, [x]: C } : { [x]: C }, $ = { ...R, [E.champ]: q };
609
+ try {
610
+ if (j?.UID)
611
+ await n.enregistrerBrouillon(j.UID, $);
612
+ else {
613
+ const X = E.bloc.pages?.[0] ?? u;
614
+ await n.creer(X, E.bloc.blockType, $);
615
+ }
616
+ await A(), N(null);
617
+ } catch {
618
+ N({
619
+ ton: "erreur",
620
+ texte: "Enregistrement impossible. Votre texte est toujours à l'écran."
621
+ });
622
+ }
623
+ },
624
+ [n, M, u, A, a]
625
+ ), P = async () => {
626
+ if (!s.length) return;
627
+ T(!0), N(null);
628
+ const l = s.length;
629
+ try {
630
+ for (const p of s) await n.publier(p.UID);
631
+ await A(), t.recharger(), N({
632
+ ton: "ok",
633
+ texte: l === 1 ? "Publié. Vos visiteurs le voient maintenant." : `${l} modifications publiées.`
634
+ });
635
+ } catch {
636
+ N({
637
+ ton: "erreur",
638
+ texte: "La publication a échoué. Rien n'a été mis en ligne."
639
+ });
640
+ } finally {
641
+ T(!1);
642
+ }
643
+ }, O = async () => {
644
+ T(!0);
645
+ try {
646
+ for (const p of s) await n.annuler(p.UID);
647
+ const l = await A();
648
+ if (t.sourceTexte) {
649
+ const { appliquerAuxTextes: p } = await import("./morceaux/sourceTexte-BMPMpNg9.js");
650
+ p(
651
+ l.map((x) => ({ blockType: x.blockType, data: x.data })),
652
+ t.sourceTexte
653
+ );
654
+ }
655
+ N({
656
+ ton: "info",
657
+ texte: "Modifications abandonnées. On est revenu à ce qui est en ligne."
658
+ });
659
+ } finally {
660
+ T(!1);
661
+ }
662
+ }, oe = (l) => {
663
+ const p = a.find((x) => x.blockType === l);
664
+ g({ ...p?.draft ?? p?.data ?? {} }), i(l), S(!1), N(null);
665
+ }, re = (l, p) => g((x) => ({ ...x, [l]: p })), ae = async () => {
666
+ if (o) {
667
+ T(!0);
668
+ try {
669
+ const l = a.find((x) => x.blockType === o);
670
+ if (l?.UID) await n.enregistrerBrouillon(l.UID, h);
671
+ else {
672
+ const x = I(o)?.pages?.[0] ?? u;
673
+ await n.creer(x, o, h);
674
+ }
675
+ const p = await A();
676
+ if (t.sourceTexte) {
677
+ const { appliquerAuxTextes: x } = await import("./morceaux/sourceTexte-BMPMpNg9.js");
678
+ x(
679
+ p.map((C) => ({ blockType: C.blockType, data: C.draft ?? C.data })),
680
+ t.sourceTexte
681
+ );
682
+ }
683
+ N({
684
+ ton: "ok",
685
+ texte: "Enregistré. Rien n'a encore changé pour vos visiteurs."
686
+ });
687
+ } catch {
688
+ N({ ton: "erreur", texte: "L'enregistrement a échoué." });
689
+ } finally {
690
+ T(!1);
691
+ }
692
+ }
693
+ }, ie = () => {
694
+ try {
695
+ window.sessionStorage.removeItem("lystech-edit");
696
+ } catch {
697
+ }
698
+ window.location.reload();
699
+ }, D = o ? I(o) : void 0, V = !o && !v;
700
+ return /* @__PURE__ */ b("div", { className: "calque", children: [
701
+ t.sourceTexte && /* @__PURE__ */ e(
702
+ be,
703
+ {
704
+ source: t.sourceTexte,
705
+ actif: V && !z && _ === "modifier",
706
+ surModification: y
707
+ }
708
+ ),
709
+ V && /* @__PURE__ */ b("div", { className: "barre", children: [
710
+ /* @__PURE__ */ e("span", { className: "barre__point" }),
711
+ /* @__PURE__ */ e("span", { className: "barre__texte", children: _ === "modifier" ? "Cliquez un texte pour le corriger" : "Navigation libre — les clics ouvrent les liens" }),
712
+ /* @__PURE__ */ e(
713
+ "button",
714
+ {
715
+ type: "button",
716
+ className: "bouton " + (_ === "circuler" ? "bouton--principal" : ""),
717
+ onClick: () => U((l) => l === "modifier" ? "circuler" : "modifier"),
718
+ title: _ === "modifier" ? "Passer en navigation pour changer de page" : "Revenir a la modification des textes",
719
+ children: _ === "modifier" ? "Circuler" : "Modifier"
720
+ }
721
+ ),
722
+ s.length > 0 ? /* @__PURE__ */ b(Q, { children: [
723
+ /* @__PURE__ */ e("span", { className: "barre__compte", children: s.length === 1 ? "1 modification non publiée" : `${s.length} modifications non publiées` }),
724
+ /* @__PURE__ */ e(
725
+ "button",
726
+ {
727
+ type: "button",
728
+ className: "bouton bouton--principal",
729
+ onClick: P,
730
+ disabled: z,
731
+ children: "Publier"
732
+ }
733
+ ),
734
+ /* @__PURE__ */ e(
735
+ "button",
736
+ {
737
+ type: "button",
738
+ className: "bouton bouton--discret",
739
+ onClick: O,
740
+ disabled: z,
741
+ children: "Abandonner"
742
+ }
743
+ )
744
+ ] }) : /* @__PURE__ */ e("span", { className: "barre__compte", children: "tout est publié" }),
745
+ /* @__PURE__ */ e(
746
+ "button",
747
+ {
748
+ type: "button",
749
+ className: "bouton bouton--discret",
750
+ onClick: () => S(!0),
751
+ children: "Plus…"
752
+ }
753
+ ),
754
+ /* @__PURE__ */ e(
755
+ "button",
756
+ {
757
+ type: "button",
758
+ className: "bouton bouton--discret",
759
+ onClick: ie,
760
+ children: "Quitter"
761
+ }
762
+ )
763
+ ] }),
764
+ w && V && /* @__PURE__ */ e("div", { className: "flottant", children: /* @__PURE__ */ e("p", { className: "message message--" + w.ton, children: w.texte }) }),
765
+ v && /* @__PURE__ */ b("div", { className: "panneau", role: "dialog", "aria-label": "Tous les contenus", children: [
766
+ /* @__PURE__ */ b("div", { className: "panneau__tete", children: [
767
+ /* @__PURE__ */ b("div", { style: { flex: 1 }, children: [
768
+ /* @__PURE__ */ e("h2", { className: "panneau__titre", children: "Tous les contenus" }),
769
+ /* @__PURE__ */ e("p", { className: "panneau__sous", children: "Y compris ce qui ne s'affiche pas dans la page : titre de l'onglet, description dans les moteurs de recherche, textes contenant une valeur calculée." })
770
+ ] }),
771
+ /* @__PURE__ */ e(
772
+ "button",
773
+ {
774
+ type: "button",
775
+ className: "bouton bouton--icone bouton--discret",
776
+ onClick: () => S(!1),
777
+ "aria-label": "Fermer",
778
+ children: "✕"
779
+ }
780
+ )
781
+ ] }),
782
+ /* @__PURE__ */ b("div", { className: "panneau__corps", children: [
783
+ d.length === 0 && /* @__PURE__ */ e("p", { className: "message message--info", children: "Aucun contenu déclaré pour cette page." }),
784
+ d.map((l) => {
785
+ const p = a.find((C) => C.blockType === l.blockType), x = p?.draft && !K(p.draft, p.data);
786
+ return /* @__PURE__ */ b(
787
+ "button",
788
+ {
789
+ type: "button",
790
+ className: "rangee",
791
+ onClick: () => oe(l.blockType),
792
+ children: [
793
+ /* @__PURE__ */ e("span", { className: "rangee__nom", children: l.label }),
794
+ /* @__PURE__ */ e("span", { className: "rangee__info", children: x ? "non publié" : `${l.fields.length} textes` })
795
+ ]
796
+ },
797
+ l.blockType
798
+ );
799
+ })
800
+ ] })
801
+ ] }),
802
+ o && D && /* @__PURE__ */ b(
803
+ "div",
804
+ {
805
+ className: "panneau",
806
+ role: "dialog",
807
+ "aria-label": "Modifier " + D.label,
808
+ children: [
809
+ /* @__PURE__ */ b("div", { className: "panneau__tete", children: [
810
+ /* @__PURE__ */ b("div", { style: { flex: 1 }, children: [
811
+ /* @__PURE__ */ e("h2", { className: "panneau__titre", children: D.label }),
812
+ D.description && /* @__PURE__ */ e("p", { className: "panneau__sous", children: D.description })
813
+ ] }),
814
+ /* @__PURE__ */ e(
815
+ "button",
816
+ {
817
+ type: "button",
818
+ className: "bouton bouton--icone bouton--discret",
819
+ onClick: () => i(null),
820
+ "aria-label": "Fermer",
821
+ children: "✕"
822
+ }
823
+ )
824
+ ] }),
825
+ /* @__PURE__ */ b("div", { className: "panneau__corps", children: [
826
+ w && /* @__PURE__ */ e("p", { className: "message message--" + w.ton, children: w.texte }),
827
+ D.fields.map((l) => /* @__PURE__ */ e(
828
+ ee,
829
+ {
830
+ champ: l,
831
+ langue: t.langue,
832
+ valeur: h[l.key],
833
+ changer: (p) => re(l.key, p)
834
+ },
835
+ l.key
836
+ ))
837
+ ] }),
838
+ /* @__PURE__ */ b("div", { className: "panneau__pied", children: [
839
+ /* @__PURE__ */ e(
840
+ "button",
841
+ {
842
+ type: "button",
843
+ className: "bouton bouton--discret",
844
+ onClick: () => i(null),
845
+ disabled: z,
846
+ children: "Fermer"
847
+ }
848
+ ),
849
+ /* @__PURE__ */ e("span", { className: "espace" }),
850
+ /* @__PURE__ */ e(
851
+ "button",
852
+ {
853
+ type: "button",
854
+ className: "bouton bouton--principal",
855
+ onClick: ae,
856
+ disabled: z,
857
+ children: "Enregistrer"
858
+ }
859
+ )
860
+ ] })
861
+ ]
862
+ }
863
+ )
864
+ ] });
865
+ }
866
+ const xe = `
867
+ :host {
868
+ all: initial;
869
+ --fond: #16181d;
870
+ --fond-clair: #21242b;
871
+ --bord: #333844;
872
+ --texte: #f2f3f5;
873
+ --texte-doux: #a3a9b6;
874
+ --accent: #3ba58d;
875
+ --accent-sombre: #2d8570;
876
+ --danger: #d9776a;
877
+ font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
878
+ "Helvetica Neue", Arial, sans-serif;
879
+ font-size: 14px;
880
+ line-height: 1.45;
881
+ color: var(--texte);
882
+ }
883
+
884
+ * { box-sizing: border-box; }
885
+
886
+ /* LE CALQUE LAISSE PASSER LES CLICS. Un conteneur fixe en plein écran qui
887
+ intercepte tout rendrait le site inutilisable derrière lui : on ne pourrait
888
+ plus naviguer, ni même faire défiler correctement. Seuls ses ENFANTS
889
+ reprennent les clics. */
890
+ .calque {
891
+ position: fixed;
892
+ inset: 0;
893
+ pointer-events: none;
894
+ z-index: 2147483000;
895
+ }
896
+ .calque > * { pointer-events: auto; }
897
+
898
+ /* ---------------------------------------------------------- CADRES ------ */
899
+
900
+ .cadre {
901
+ position: fixed;
902
+ border: 2px dashed rgba(59, 165, 141, 0.55);
903
+ border-radius: 6px;
904
+ pointer-events: none;
905
+ transition: border-color 120ms ease;
906
+ }
907
+ .cadre--actif { border-color: var(--accent); border-style: solid; }
908
+
909
+ .pastille {
910
+ position: fixed;
911
+ display: inline-flex;
912
+ align-items: center;
913
+ gap: 6px;
914
+ padding: 5px 10px;
915
+ border: 0;
916
+ border-radius: 999px;
917
+ background: var(--accent);
918
+ color: #06120e;
919
+ font-size: 12px;
920
+ font-weight: 650;
921
+ letter-spacing: 0.01em;
922
+ cursor: pointer;
923
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
924
+ }
925
+ .pastille:hover { background: #45bda2; }
926
+ .pastille:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
927
+
928
+ /* ------------------------------------------------------------ BARRE ----- */
929
+
930
+ .barre {
931
+ position: fixed;
932
+ left: 50%;
933
+ bottom: 18px;
934
+ transform: translateX(-50%);
935
+ display: flex;
936
+ align-items: center;
937
+ gap: 14px;
938
+ padding: 9px 14px;
939
+ border: 1px solid var(--bord);
940
+ border-radius: 999px;
941
+ background: var(--fond);
942
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
943
+ max-width: calc(100vw - 24px);
944
+ }
945
+ .barre__point {
946
+ width: 8px; height: 8px; border-radius: 50%;
947
+ background: var(--accent);
948
+ flex: none;
949
+ }
950
+ .barre__texte { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
951
+ .barre__texte b { font-weight: 650; }
952
+ .barre__compte { color: var(--texte-doux); font-size: 12px; white-space: nowrap; }
953
+
954
+ /* ----------------------------------------------------------- PANNEAU ---- */
955
+
956
+ .panneau {
957
+ position: fixed;
958
+ top: 0; right: 0; bottom: 0;
959
+ width: min(420px, 100vw);
960
+ display: flex;
961
+ flex-direction: column;
962
+ background: var(--fond);
963
+ border-left: 1px solid var(--bord);
964
+ box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
965
+ }
966
+ @media (max-width: 520px) {
967
+ .panneau { top: auto; height: 78vh; border-left: 0; border-top: 1px solid var(--bord); }
968
+ }
969
+
970
+ .panneau__tete {
971
+ display: flex; align-items: flex-start; gap: 10px;
972
+ padding: 16px 16px 12px;
973
+ border-bottom: 1px solid var(--bord);
974
+ }
975
+ .panneau__titre { font-size: 15px; font-weight: 650; margin: 0; }
976
+ .panneau__sous { margin: 3px 0 0; font-size: 12px; color: var(--texte-doux); }
977
+ .panneau__corps { flex: 1; overflow-y: auto; padding: 14px 16px 18px; }
978
+ .panneau__pied {
979
+ display: flex; gap: 8px; align-items: center;
980
+ padding: 12px 16px;
981
+ border-top: 1px solid var(--bord);
982
+ background: var(--fond-clair);
983
+ }
984
+ .panneau__pied .espace { flex: 1; }
985
+
986
+ /* --------------------------------------------------- CONNEXION ---------- */
987
+
988
+ /* Le voile PREND les clics, lui : une boite de dialogue qui demande un mot de
989
+ passe ne doit pas laisser cliquer la page derriere elle. C'est l'exception
990
+ a la regle du calque, et elle est volontaire. */
991
+ .voile {
992
+ position: fixed;
993
+ inset: 0;
994
+ display: flex;
995
+ align-items: center;
996
+ justify-content: center;
997
+ padding: 16px;
998
+ background: rgba(8, 10, 14, 0.62);
999
+ backdrop-filter: blur(2px);
1000
+ }
1001
+
1002
+ .fenetre {
1003
+ width: min(420px, 100%);
1004
+ max-height: 90vh;
1005
+ overflow-y: auto;
1006
+ border: 1px solid var(--bord);
1007
+ border-radius: 12px;
1008
+ background: var(--fond);
1009
+ box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
1010
+ }
1011
+
1012
+ /* ------------------------------------------------------------ CHAMPS ---- */
1013
+
1014
+ .champ { margin-bottom: 16px; }
1015
+ .champ__etiquette {
1016
+ display: block; margin-bottom: 5px;
1017
+ font-size: 12px; font-weight: 600; color: var(--texte);
1018
+ }
1019
+ .champ__aide { margin: 4px 0 0; font-size: 11.5px; color: var(--texte-doux); }
1020
+ .champ__langue {
1021
+ display: inline-block; margin: 0 0 4px;
1022
+ font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
1023
+ text-transform: uppercase; color: var(--texte-doux);
1024
+ }
1025
+
1026
+ input[type="text"], input[type="url"], input[type="number"], input[type="date"],
1027
+ select, textarea {
1028
+ width: 100%;
1029
+ padding: 8px 10px;
1030
+ border: 1px solid var(--bord);
1031
+ border-radius: 6px;
1032
+ background: var(--fond-clair);
1033
+ color: var(--texte);
1034
+ font: inherit;
1035
+ font-size: 13px;
1036
+ }
1037
+ textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
1038
+ input:focus, select:focus, textarea:focus {
1039
+ outline: none; border-color: var(--accent);
1040
+ box-shadow: 0 0 0 3px rgba(59, 165, 141, 0.18);
1041
+ }
1042
+
1043
+ .bascule { display: flex; align-items: center; gap: 8px; }
1044
+ .bascule input { width: 16px; height: 16px; accent-color: var(--accent); }
1045
+
1046
+ .vignette {
1047
+ margin-top: 8px; max-height: 110px; border-radius: 6px;
1048
+ border: 1px solid var(--bord); display: block;
1049
+ }
1050
+
1051
+ /* --------------------------------------------------------- LISTES ------- */
1052
+
1053
+ .liste__item {
1054
+ border: 1px solid var(--bord); border-radius: 8px;
1055
+ padding: 12px; margin-bottom: 10px; background: var(--fond-clair);
1056
+ }
1057
+ .liste__tete {
1058
+ display: flex; align-items: center; justify-content: space-between;
1059
+ margin-bottom: 8px;
1060
+ }
1061
+ .liste__rang { font-size: 11px; font-weight: 700; color: var(--texte-doux); }
1062
+
1063
+ /* --------------------------------------------------------- BOUTONS ------ */
1064
+
1065
+ .bouton {
1066
+ display: inline-flex; align-items: center; justify-content: center; gap: 6px;
1067
+ padding: 8px 14px; border-radius: 7px; border: 1px solid transparent;
1068
+ font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
1069
+ background: var(--fond-clair); color: var(--texte); border-color: var(--bord);
1070
+ }
1071
+ .bouton:hover { background: #2a2e37; }
1072
+ .bouton:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
1073
+ .bouton--principal { background: var(--accent); border-color: var(--accent); color: #06120e; }
1074
+ .bouton--principal:hover { background: #45bda2; }
1075
+ .bouton--discret { background: transparent; border-color: transparent; color: var(--texte-doux); }
1076
+ .bouton--discret:hover { background: var(--fond-clair); color: var(--texte); }
1077
+ .bouton[disabled] { opacity: 0.5; cursor: default; }
1078
+ .bouton--icone { padding: 6px 9px; }
1079
+
1080
+ .message {
1081
+ margin: 0 0 12px; padding: 9px 11px; border-radius: 7px;
1082
+ font-size: 12.5px; border: 1px solid;
1083
+ }
1084
+ .message--erreur { background: rgba(217, 119, 106, 0.12); border-color: rgba(217, 119, 106, 0.4); color: #f0b3a9; }
1085
+ .message--ok { background: rgba(59, 165, 141, 0.12); border-color: rgba(59, 165, 141, 0.4); color: #8fd9c6; }
1086
+ .message--info { background: var(--fond-clair); border-color: var(--bord); color: var(--texte-doux); }
1087
+
1088
+ @media (prefers-reduced-motion: reduce) {
1089
+ * { transition: none !important; animation: none !important; }
1090
+ }
1091
+ `, he = `
1092
+ /* --------------------------------------------------------- CHOIX -------- */
1093
+
1094
+ /* Quand un meme texte vient de plusieurs cles, on demande laquelle plutot que
1095
+ de deviner — et de modifier la mauvaise sans que personne le voie. */
1096
+ .choix {
1097
+ position: fixed;
1098
+ width: 260px;
1099
+ padding: 12px;
1100
+ border: 1px solid var(--bord);
1101
+ border-radius: 10px;
1102
+ background: var(--fond);
1103
+ box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
1104
+ }
1105
+ .choix__titre { margin: 0 0 2px; font-size: 12.5px; font-weight: 650; }
1106
+ .choix__aide { margin: 0 0 10px; font-size: 11.5px; color: var(--texte-doux); }
1107
+ .choix__option {
1108
+ display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
1109
+ width: 100%; margin-bottom: 6px; padding: 7px 9px;
1110
+ border: 1px solid var(--bord); border-radius: 7px;
1111
+ background: var(--fond-clair); color: var(--texte);
1112
+ font: inherit; text-align: left; cursor: pointer;
1113
+ }
1114
+ .choix__option:hover { background: #2a2e37; border-color: var(--accent); }
1115
+ .choix__chemin { font-size: 12px; font-weight: 600; }
1116
+ .choix__ns { font-size: 10.5px; color: var(--texte-doux); }
1117
+
1118
+ /* ------------------------------------------------------- RANGEES -------- */
1119
+
1120
+ .rangee {
1121
+ display: flex; align-items: center; justify-content: space-between; gap: 10px;
1122
+ width: 100%; margin-bottom: 6px; padding: 10px 12px;
1123
+ border: 1px solid var(--bord); border-radius: 8px;
1124
+ background: var(--fond-clair); color: var(--texte);
1125
+ font: inherit; text-align: left; cursor: pointer;
1126
+ }
1127
+ .rangee:hover { background: #2a2e37; border-color: var(--accent); }
1128
+ .rangee__nom { font-size: 13px; font-weight: 600; }
1129
+ .rangee__info { font-size: 11.5px; color: var(--texte-doux); white-space: nowrap; }
1130
+
1131
+ /* ------------------------------------------------------ FLOTTANT -------- */
1132
+
1133
+ /* Un message au-dessus de la barre, pour confirmer sans ouvrir de panneau. */
1134
+ .flottant {
1135
+ position: fixed;
1136
+ left: 50%; bottom: 76px;
1137
+ transform: translateX(-50%);
1138
+ max-width: min(460px, calc(100vw - 24px));
1139
+ }
1140
+ .flottant .message { margin: 0; box-shadow: 0 8px 26px rgba(0,0,0,.4); }
1141
+ `, ge = "lystech-editeur-hote", ve = "lystech-connexion-hote";
1142
+ function te(n) {
1143
+ document.getElementById(n)?.remove();
1144
+ const t = document.createElement("div");
1145
+ t.id = n, document.body.appendChild(t);
1146
+ const c = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1147
+ r.textContent = xe + he, c.appendChild(r);
1148
+ const a = document.createElement("div");
1149
+ return c.appendChild(a), { hote: t, point: a };
1150
+ }
1151
+ function ne(n, t) {
1152
+ let c = n;
1153
+ return () => {
1154
+ const r = c;
1155
+ c = null, setTimeout(() => {
1156
+ r?.unmount(), t.remove();
1157
+ }, 0);
1158
+ };
1159
+ }
1160
+ function we({
1161
+ site: n,
1162
+ apiBaseUrl: t,
1163
+ surJeton: c
1164
+ }) {
1165
+ const { hote: r, point: a } = te(ve), f = Z(a), u = () => m();
1166
+ f.render(
1167
+ /* @__PURE__ */ e(
1168
+ ce,
1169
+ {
1170
+ site: n,
1171
+ apiBaseUrl: t,
1172
+ surJeton: (o) => {
1173
+ m(), c(o);
1174
+ },
1175
+ surFermer: u
1176
+ }
1177
+ )
1178
+ );
1179
+ const m = ne(f, r);
1180
+ return m;
1181
+ }
1182
+ function ke({
1183
+ jeton: n,
1184
+ site: t,
1185
+ apiBaseUrl: c,
1186
+ pont: r
1187
+ }) {
1188
+ const { hote: a, point: f } = te(ge), u = Z(f), m = () => {
1189
+ try {
1190
+ window.sessionStorage.removeItem("lystech-edit");
1191
+ } catch {
1192
+ }
1193
+ window.location.reload();
1194
+ };
1195
+ return u.render(
1196
+ /* @__PURE__ */ e(
1197
+ fe,
1198
+ {
1199
+ api: se({ jeton: n, site: t, apiBaseUrl: c, surJetonRefuse: m }),
1200
+ pont: r
1201
+ }
1202
+ )
1203
+ ), ne(u, a);
1204
+ }
1205
+ export {
1206
+ we as monterConnexion,
1207
+ ke as monterEditeur
1208
+ };