@lystech/sections 0.2.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.
package/dist/editeur.js CHANGED
@@ -1,50 +1,190 @@
1
- import { jsxs as p, jsx as o, Fragment as V } from "react/jsx-runtime";
2
- import { createRoot as H } from "react-dom/client";
3
- import { useState as g, useEffect as T, useCallback as S, useMemo as Q, useRef as W } from "react";
4
- function X({
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
5
  jeton: n,
6
6
  site: t,
7
- apiBaseUrl: s,
7
+ apiBaseUrl: c,
8
8
  surJetonRefuse: r
9
9
  }) {
10
- const c = {
10
+ const a = {
11
11
  "Content-Type": "application/json",
12
12
  Authorization: "Bearer " + n
13
13
  };
14
- function b(e, a) {
15
- if (a && (e.status === 401 || e.status === 403) && r(), !e.ok) throw new Error(String(e.status));
14
+ function f(o, i) {
15
+ if (i && (o.status === 401 || o.status === 403) && r(), !o.ok) throw new Error(String(o.status));
16
16
  }
17
- async function d(e, a = !0) {
18
- const u = await fetch(s + e, {
19
- headers: a ? c : void 0
17
+ async function u(o, i = !0) {
18
+ const h = await fetch(c + o, {
19
+ headers: i ? a : void 0
20
20
  });
21
- return b(u, a), await u.json();
21
+ return f(h, i), await h.json();
22
22
  }
23
- async function l(e, a, u) {
24
- const m = await fetch(s + e, {
25
- method: a,
26
- headers: c,
27
- body: u === void 0 ? void 0 : JSON.stringify(u)
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
28
  });
29
- return b(m, !0), await m.json();
29
+ return f(g, !0), await g.json();
30
30
  }
31
31
  return {
32
32
  /** Les blocs que le site a déclaré savoir afficher. Route publique. */
33
- schemas: () => d("/site-sections/public/" + encodeURIComponent(t) + "/schemas", !1),
33
+ schemas: () => u("/site-sections/public/" + encodeURIComponent(t) + "/schemas", !1),
34
34
  /** Ce qui existe sur une page, brouillons compris. */
35
- pourPage: (e) => d("/site-sections?page=" + encodeURIComponent(e)),
36
- creer: (e, a, u) => l("/site-sections", "POST", { page: e, blockType: a, draft: u }),
37
- enregistrerBrouillon: (e, a) => l("/site-sections/" + e + "/draft", "PUT", { draft: a }),
38
- publier: (e) => l("/site-sections/" + e + "/publish", "POST"),
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
39
  /** Ramène le brouillon à ce qui est en ligne. */
40
- annuler: (e) => l("/site-sections/" + e + "/revert", "POST")
40
+ annuler: (o) => m("/site-sections/" + o + "/revert", "POST")
41
41
  };
42
42
  }
43
- function Z(n, t) {
44
- const s = n && typeof n == "object" && !Array.isArray(n) ? Object.keys(n).filter((c) => /^[a-z]{2}(-[A-Za-z]{2})?$/.test(c)) : [], r = t.slice(0, 2);
45
- return Array.from(/* @__PURE__ */ new Set([r, ...s]));
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]));
46
186
  }
47
- function $(n) {
187
+ function ue(n) {
48
188
  switch (n.type) {
49
189
  case "number":
50
190
  return 0;
@@ -56,164 +196,164 @@ function $(n) {
56
196
  return "";
57
197
  }
58
198
  }
59
- function j({ champ: n, valeur: t, changer: s }) {
199
+ function G({ champ: n, valeur: t, changer: c }) {
60
200
  switch (n.type) {
61
201
  case "richText":
62
- return /* @__PURE__ */ o(
202
+ return /* @__PURE__ */ e(
63
203
  "textarea",
64
204
  {
65
205
  value: String(t ?? ""),
66
- onChange: (r) => s(r.target.value)
206
+ onChange: (r) => c(r.target.value)
67
207
  }
68
208
  );
69
209
  case "number":
70
- return /* @__PURE__ */ o(
210
+ return /* @__PURE__ */ e(
71
211
  "input",
72
212
  {
73
213
  type: "number",
74
214
  value: t === "" || t == null ? "" : String(t),
75
- onChange: (r) => s(r.target.value === "" ? "" : Number(r.target.value))
215
+ onChange: (r) => c(r.target.value === "" ? "" : Number(r.target.value))
76
216
  }
77
217
  );
78
218
  case "boolean":
79
- return /* @__PURE__ */ p("label", { className: "bascule", children: [
80
- /* @__PURE__ */ o(
219
+ return /* @__PURE__ */ b("label", { className: "bascule", children: [
220
+ /* @__PURE__ */ e(
81
221
  "input",
82
222
  {
83
223
  type: "checkbox",
84
224
  checked: t === !0,
85
- onChange: (r) => s(r.target.checked)
225
+ onChange: (r) => c(r.target.checked)
86
226
  }
87
227
  ),
88
- /* @__PURE__ */ o("span", { children: t === !0 ? "Oui" : "Non" })
228
+ /* @__PURE__ */ e("span", { children: t === !0 ? "Oui" : "Non" })
89
229
  ] });
90
230
  case "date":
91
- return /* @__PURE__ */ o(
231
+ return /* @__PURE__ */ e(
92
232
  "input",
93
233
  {
94
234
  type: "date",
95
235
  value: String(t ?? "").slice(0, 10),
96
- onChange: (r) => s(r.target.value)
236
+ onChange: (r) => c(r.target.value)
97
237
  }
98
238
  );
99
239
  case "choice":
100
- return /* @__PURE__ */ p(
240
+ return /* @__PURE__ */ b(
101
241
  "select",
102
242
  {
103
243
  value: String(t ?? ""),
104
- onChange: (r) => s(r.target.value),
244
+ onChange: (r) => c(r.target.value),
105
245
  children: [
106
- /* @__PURE__ */ o("option", { value: "", children: "—" }),
107
- (n.options ?? []).map((r) => /* @__PURE__ */ o("option", { value: r, children: r }, r))
246
+ /* @__PURE__ */ e("option", { value: "", children: "—" }),
247
+ (n.options ?? []).map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
108
248
  ]
109
249
  }
110
250
  );
111
251
  case "url":
112
- return /* @__PURE__ */ o(
252
+ return /* @__PURE__ */ e(
113
253
  "input",
114
254
  {
115
255
  type: "url",
116
256
  value: String(t ?? ""),
117
- onChange: (r) => s(r.target.value),
257
+ onChange: (r) => c(r.target.value),
118
258
  placeholder: "https://"
119
259
  }
120
260
  );
121
261
  case "image":
122
- return /* @__PURE__ */ p(V, { children: [
123
- /* @__PURE__ */ o(
262
+ return /* @__PURE__ */ b(Q, { children: [
263
+ /* @__PURE__ */ e(
124
264
  "input",
125
265
  {
126
266
  type: "url",
127
267
  value: String(t ?? ""),
128
- onChange: (r) => s(r.target.value),
268
+ onChange: (r) => c(r.target.value),
129
269
  placeholder: "https://…"
130
270
  }
131
271
  ),
132
- String(t ?? "").startsWith("http") && /* @__PURE__ */ o("img", { className: "vignette", src: String(t), alt: "" })
272
+ String(t ?? "").startsWith("http") && /* @__PURE__ */ e("img", { className: "vignette", src: String(t), alt: "" })
133
273
  ] });
134
274
  default:
135
- return /* @__PURE__ */ o(
275
+ return /* @__PURE__ */ e(
136
276
  "input",
137
277
  {
138
278
  type: "text",
139
279
  value: String(t ?? ""),
140
- onChange: (r) => s(r.target.value)
280
+ onChange: (r) => c(r.target.value)
141
281
  }
142
282
  );
143
283
  }
144
284
  }
145
- function P({ champ: n, valeur: t, changer: s, langue: r }) {
285
+ function ee({ champ: n, valeur: t, changer: c, langue: r }) {
146
286
  if (n.type === "list") {
147
- const c = Array.isArray(t) ? t : [], b = n.of ?? [], d = (l, e, a) => {
148
- const u = c.map((m, _) => _ === l ? { ...m, [e]: a } : m);
149
- s(u);
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);
150
290
  };
151
- return /* @__PURE__ */ p("div", { className: "champ", children: [
152
- /* @__PURE__ */ o("span", { className: "champ__etiquette", children: n.label }),
153
- n.help && /* @__PURE__ */ o("p", { className: "champ__aide", children: n.help }),
154
- c.map((l, e) => /* @__PURE__ */ p("div", { className: "liste__item", children: [
155
- /* @__PURE__ */ p("div", { className: "liste__tete", children: [
156
- /* @__PURE__ */ o("span", { className: "liste__rang", children: e + 1 }),
157
- /* @__PURE__ */ p("span", { style: { display: "flex", gap: 4 }, children: [
158
- /* @__PURE__ */ o(
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(
159
299
  "button",
160
300
  {
161
301
  type: "button",
162
302
  className: "bouton bouton--icone bouton--discret",
163
303
  title: "Monter",
164
- disabled: e === 0,
304
+ disabled: o === 0,
165
305
  onClick: () => {
166
- const a = [...c];
167
- [a[e - 1], a[e]] = [a[e], a[e - 1]], s(a);
306
+ const i = [...a];
307
+ [i[o - 1], i[o]] = [i[o], i[o - 1]], c(i);
168
308
  },
169
309
  children: "↑"
170
310
  }
171
311
  ),
172
- /* @__PURE__ */ o(
312
+ /* @__PURE__ */ e(
173
313
  "button",
174
314
  {
175
315
  type: "button",
176
316
  className: "bouton bouton--icone bouton--discret",
177
317
  title: "Descendre",
178
- disabled: e === c.length - 1,
318
+ disabled: o === a.length - 1,
179
319
  onClick: () => {
180
- const a = [...c];
181
- [a[e], a[e + 1]] = [a[e + 1], a[e]], s(a);
320
+ const i = [...a];
321
+ [i[o], i[o + 1]] = [i[o + 1], i[o]], c(i);
182
322
  },
183
323
  children: "↓"
184
324
  }
185
325
  ),
186
- /* @__PURE__ */ o(
326
+ /* @__PURE__ */ e(
187
327
  "button",
188
328
  {
189
329
  type: "button",
190
330
  className: "bouton bouton--icone bouton--discret",
191
331
  title: "Retirer",
192
- onClick: () => s(c.filter((a, u) => u !== e)),
332
+ onClick: () => c(a.filter((i, h) => h !== o)),
193
333
  children: "✕"
194
334
  }
195
335
  )
196
336
  ] })
197
337
  ] }),
198
- b.map((a) => /* @__PURE__ */ o(
199
- P,
338
+ f.map((i) => /* @__PURE__ */ e(
339
+ ee,
200
340
  {
201
- champ: a,
341
+ champ: i,
202
342
  langue: r,
203
- valeur: l?.[a.key],
204
- changer: (u) => d(e, a.key, u)
343
+ valeur: m?.[i.key],
344
+ changer: (h) => u(o, i.key, h)
205
345
  },
206
- a.key
346
+ i.key
207
347
  ))
208
- ] }, e)),
209
- /* @__PURE__ */ o(
348
+ ] }, o)),
349
+ /* @__PURE__ */ e(
210
350
  "button",
211
351
  {
212
352
  type: "button",
213
353
  className: "bouton",
214
- onClick: () => s([
215
- ...c,
216
- Object.fromEntries(b.map((l) => [l.key, $(l)]))
354
+ onClick: () => c([
355
+ ...a,
356
+ Object.fromEntries(f.map((m) => [m.key, ue(m)]))
217
357
  ]),
218
358
  children: "+ Ajouter"
219
359
  }
@@ -221,264 +361,509 @@ function P({ champ: n, valeur: t, changer: s, langue: r }) {
221
361
  ] });
222
362
  }
223
363
  if (n.localized) {
224
- const c = Z(t, r), b = t && typeof t == "object" && !Array.isArray(t) ? t : {};
225
- return /* @__PURE__ */ p("div", { className: "champ", children: [
226
- /* @__PURE__ */ o("span", { className: "champ__etiquette", children: n.label }),
227
- n.help && /* @__PURE__ */ o("p", { className: "champ__aide", children: n.help }),
228
- c.map((d) => /* @__PURE__ */ p("div", { style: { marginBottom: 8 }, children: [
229
- /* @__PURE__ */ o("span", { className: "champ__langue", children: d }),
230
- /* @__PURE__ */ o(
231
- j,
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,
232
372
  {
233
373
  champ: n,
234
- valeur: b[d],
235
- changer: (l) => s({ ...b, [d]: l })
374
+ valeur: f[u],
375
+ changer: (m) => c({ ...f, [u]: m })
236
376
  }
237
377
  )
238
- ] }, d))
378
+ ] }, u))
239
379
  ] });
240
380
  }
241
- return /* @__PURE__ */ p("div", { className: "champ", children: [
242
- /* @__PURE__ */ o("label", { className: "champ__etiquette", children: n.label }),
243
- /* @__PURE__ */ o(j, { champ: n, valeur: t, changer: s }),
244
- n.help && /* @__PURE__ */ o("p", { className: "champ__aide", children: n.help })
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 })
245
385
  ] });
246
386
  }
247
- function G(n, t) {
248
- const s = n.haut - 12, r = t + 8, c = n.haut + n.hauteur - 34;
249
- return Math.min(Math.max(s, r), Math.max(r, c));
250
- }
251
- function K() {
252
- let n = 0;
253
- return document.querySelectorAll("header, nav, [class*='header'], [class*='nav']").forEach((t) => {
254
- const s = getComputedStyle(t);
255
- if (s.position !== "fixed" && s.position !== "sticky") return;
256
- const r = t.getBoundingClientRect();
257
- r.top <= 4 && r.height > 0 && r.height < 200 && (n = Math.max(n, r.bottom));
258
- }), n;
259
- }
260
- function Y() {
261
- const [n, t] = g([]), [s, r] = g(0), c = W("");
262
- return T(() => {
263
- let b = 0;
264
- const d = () => {
265
- const a = [];
266
- document.querySelectorAll("[data-lystech-section]").forEach((_) => {
267
- const y = _.getAttribute("data-lystech-section");
268
- if (!y) return;
269
- const x = _.getBoundingClientRect();
270
- x.width < 8 || x.height < 8 || a.push({
271
- blockType: y,
272
- haut: x.top,
273
- gauche: x.left,
274
- largeur: x.width,
275
- hauteur: x.height
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
276
485
  });
277
- });
278
- const u = K(), m = JSON.stringify(a) + "|" + u;
279
- m !== c.current && (c.current = m, t(a), r(u));
280
- }, l = () => {
281
- cancelAnimationFrame(b), b = requestAnimationFrame(d);
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));
282
497
  };
283
- d(), window.addEventListener("scroll", l, !0), window.addEventListener("resize", l);
284
- const e = new MutationObserver(l);
285
- return e.observe(document.body, { childList: !0, subtree: !0 }), () => {
286
- cancelAnimationFrame(b), window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l), e.disconnect();
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;
287
502
  };
288
- }, []), { ancres: n, enTete: s };
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;
289
539
  }
290
- function ee({ api: n, pont: t }) {
291
- const [s, r] = g([]), [c, b] = g([]), [d, l] = g(t.page), [e, a] = g(null), [u, m] = g({}), [_, y] = g(!1), [x, w] = g(!1), [z, f] = g(null), { ancres: I, enTete: R } = Y();
292
- T(() => (t.surChangementDePage = (i) => {
293
- l(i), a(null);
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);
294
550
  }, () => {
295
551
  t.surChangementDePage = void 0;
296
552
  }), [t]);
297
- const C = S(async () => {
553
+ const A = H(async () => {
298
554
  try {
299
- const i = await n.pourPage(d);
300
- return b(i), i;
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;
301
560
  } catch {
302
- return f({ ton: "erreur", texte: "Impossible de lire le contenu du site." }), [];
561
+ return N({
562
+ ton: "erreur",
563
+ texte: "Impossible de lire le contenu du site."
564
+ }), [];
303
565
  }
304
- }, [n, d]);
305
- T(() => {
566
+ }, [n, u]);
567
+ B(() => {
306
568
  n.schemas().then(r).catch(() => r([]));
307
- }, [n]), T(() => {
308
- C();
309
- }, [C]);
310
- const A = S(
311
- (i) => s.find((h) => h.blockType === i),
312
- [s]
313
- ), E = Q(
314
- () => I.filter((i) => A(i.blockType)),
315
- [I, A]
316
- ), U = S(
317
- (i) => {
318
- const h = c.find((N) => N.blockType === i), v = h?.draft ?? h?.data ?? {};
319
- m({ ...v }), a(i), y(!1), f(
320
- h?.draft && JSON.stringify(h.draft) !== JSON.stringify(h.data ?? {}) ? { ton: "info", texte: "Un brouillon non publié est en cours." } : null
321
- );
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 };
322
584
  },
323
585
  [c]
324
- ), q = S(() => {
325
- e && t.poserApercu(e, null), a(null), y(!1), f(null);
326
- }, [e, t]), L = S(
327
- (i, h) => {
328
- m((v) => {
329
- const N = { ...v, [i]: h };
330
- return e && t.poserApercu(e, N), N;
331
- }), y(!0);
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
+ }
332
623
  },
333
- [e, t]
334
- ), O = S(async () => {
335
- if (!e) return null;
336
- const i = c.find((v) => v.blockType === e);
337
- return i?.UID ? (await n.enregistrerBrouillon(i.UID, u), i.UID) : (await n.creer(d, e, u)).UID;
338
- }, [n, e, d, c, u]), M = async () => {
339
- w(!0), f(null);
624
+ [n, M, u, A, a]
625
+ ), P = async () => {
626
+ if (!s.length) return;
627
+ T(!0), N(null);
628
+ const l = s.length;
340
629
  try {
341
- await O(), await C(), y(!1), f({ ton: "ok", texte: "Brouillon enregistré. Rien n'a encore changé pour vos visiteurs." });
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
+ });
342
635
  } catch {
343
- f({ ton: "erreur", texte: "L'enregistrement a échoué. Votre texte est toujours là — réessayez." });
636
+ N({
637
+ ton: "erreur",
638
+ texte: "La publication a échoué. Rien n'a été mis en ligne."
639
+ });
344
640
  } finally {
345
- w(!1);
641
+ T(!1);
346
642
  }
347
- }, B = async () => {
348
- w(!0), f(null);
643
+ }, O = async () => {
644
+ T(!0);
349
645
  try {
350
- const i = await O();
351
- if (!i) throw new Error("sans identifiant");
352
- await n.publier(i), await C(), e && t.poserApercu(e, null), t.recharger(), y(!1), f({ ton: "ok", texte: "Publié. Vos visiteurs le voient maintenant." });
353
- } catch {
354
- f({ ton: "erreur", texte: "La publication a échoué. Rien n'a été mis en ligne." });
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
+ });
355
659
  } finally {
356
- w(!1);
660
+ T(!1);
357
661
  }
358
- }, F = async () => {
359
- if (!e) return;
360
- const i = c.find((h) => h.blockType === e);
361
- w(!0);
362
- try {
363
- i?.UID && await n.annuler(i.UID);
364
- const v = (await C()).find((N) => N.blockType === e);
365
- m({ ...v?.data ?? {} }), t.poserApercu(e, null), y(!1), f({ ton: "info", texte: "Brouillon abandonné. On est revenu à ce qui est en ligne." });
366
- } catch {
367
- f({ ton: "erreur", texte: "Impossible d'abandonner le brouillon." });
368
- } finally {
369
- w(!1);
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
+ }
370
692
  }
371
- }, J = () => {
693
+ }, ie = () => {
372
694
  try {
373
695
  window.sessionStorage.removeItem("lystech-edit");
374
696
  } catch {
375
697
  }
376
698
  window.location.reload();
377
- }, k = e ? A(e) : void 0;
378
- return /* @__PURE__ */ p("div", { className: "calque", children: [
379
- E.map((i) => /* @__PURE__ */ p("div", { children: [
380
- /* @__PURE__ */ o(
381
- "div",
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",
382
714
  {
383
- className: "cadre" + (e === i.blockType ? " cadre--actif" : ""),
384
- style: {
385
- top: i.haut - 4,
386
- left: i.gauche - 4,
387
- width: i.largeur + 8,
388
- height: i.hauteur + 8
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"
389
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…"
390
752
  }
391
753
  ),
392
- /* @__PURE__ */ p(
754
+ /* @__PURE__ */ e(
393
755
  "button",
394
756
  {
395
757
  type: "button",
396
- className: "pastille",
397
- style: { top: G(i, R), left: i.gauche + 6 },
398
- onClick: () => U(i.blockType),
399
- children: [
400
- "✎ ",
401
- A(i.blockType)?.label ?? i.blockType
402
- ]
758
+ className: "bouton bouton--discret",
759
+ onClick: ie,
760
+ children: "Quitter"
403
761
  }
404
762
  )
405
- ] }, i.blockType)),
406
- !e && /* @__PURE__ */ p("div", { className: "barre", children: [
407
- /* @__PURE__ */ o("span", { className: "barre__point" }),
408
- /* @__PURE__ */ p("span", { className: "barre__texte", children: [
409
- "Mode édition — ",
410
- /* @__PURE__ */ o("b", { children: t.site })
411
- ] }),
412
- /* @__PURE__ */ o("span", { className: "barre__compte", children: E.length === 0 ? "aucune section sur cette page" : E.length === 1 ? "1 section modifiable" : E.length + " sections modifiables" }),
413
- /* @__PURE__ */ o("button", { type: "button", className: "bouton bouton--discret", onClick: J, children: "Quitter" })
414
763
  ] }),
415
- e && k && /* @__PURE__ */ p("div", { className: "panneau", role: "dialog", "aria-label": "Modifier " + k.label, children: [
416
- /* @__PURE__ */ p("div", { className: "panneau__tete", children: [
417
- /* @__PURE__ */ p("div", { style: { flex: 1 }, children: [
418
- /* @__PURE__ */ o("h2", { className: "panneau__titre", children: k.label }),
419
- k.description && /* @__PURE__ */ o("p", { className: "panneau__sous", children: k.description })
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." })
420
770
  ] }),
421
- /* @__PURE__ */ o(
771
+ /* @__PURE__ */ e(
422
772
  "button",
423
773
  {
424
774
  type: "button",
425
775
  className: "bouton bouton--icone bouton--discret",
426
- onClick: q,
776
+ onClick: () => S(!1),
427
777
  "aria-label": "Fermer",
428
778
  children: "✕"
429
779
  }
430
780
  )
431
781
  ] }),
432
- /* @__PURE__ */ p("div", { className: "panneau__corps", children: [
433
- z && /* @__PURE__ */ o("p", { className: "message message--" + z.ton, children: z.texte }),
434
- k.fields.map((i) => /* @__PURE__ */ o(
435
- P,
436
- {
437
- champ: i,
438
- langue: t.langue,
439
- valeur: u[i.key],
440
- changer: (h) => L(i.key, h)
441
- },
442
- i.key
443
- ))
444
- ] }),
445
- /* @__PURE__ */ p("div", { className: "panneau__pied", children: [
446
- /* @__PURE__ */ o(
447
- "button",
448
- {
449
- type: "button",
450
- className: "bouton bouton--discret",
451
- onClick: F,
452
- disabled: x,
453
- children: "Abandonner"
454
- }
455
- ),
456
- /* @__PURE__ */ o("span", { className: "espace" }),
457
- /* @__PURE__ */ o(
458
- "button",
459
- {
460
- type: "button",
461
- className: "bouton",
462
- onClick: M,
463
- disabled: x || !_,
464
- children: "Enregistrer"
465
- }
466
- ),
467
- /* @__PURE__ */ o(
468
- "button",
469
- {
470
- type: "button",
471
- className: "bouton bouton--principal",
472
- onClick: B,
473
- disabled: x,
474
- children: "Publier"
475
- }
476
- )
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
+ })
477
800
  ] })
478
- ] })
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
+ )
479
864
  ] });
480
865
  }
481
- const te = `
866
+ const xe = `
482
867
  :host {
483
868
  all: initial;
484
869
  --fond: #16181d;
@@ -598,6 +983,32 @@ const te = `
598
983
  }
599
984
  .panneau__pied .espace { flex: 1; }
600
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
+
601
1012
  /* ------------------------------------------------------------ CHAMPS ---- */
602
1013
 
603
1014
  .champ { margin-bottom: 16px; }
@@ -677,43 +1088,121 @@ input:focus, select:focus, textarea:focus {
677
1088
  @media (prefers-reduced-motion: reduce) {
678
1089
  * { transition: none !important; animation: none !important; }
679
1090
  }
680
- `, D = "lystech-editeur-hote";
681
- function ae({
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({
682
1183
  jeton: n,
683
1184
  site: t,
684
- apiBaseUrl: s,
1185
+ apiBaseUrl: c,
685
1186
  pont: r
686
1187
  }) {
687
- document.getElementById(D)?.remove();
688
- const c = document.createElement("div");
689
- c.id = D, document.body.appendChild(c);
690
- const b = c.attachShadow({ mode: "open" }), d = document.createElement("style");
691
- d.textContent = te, b.appendChild(d);
692
- const l = document.createElement("div");
693
- b.appendChild(l);
694
- let e = H(l);
695
- const a = () => {
1188
+ const { hote: a, point: f } = te(ge), u = Z(f), m = () => {
696
1189
  try {
697
1190
  window.sessionStorage.removeItem("lystech-edit");
698
1191
  } catch {
699
1192
  }
700
1193
  window.location.reload();
701
1194
  };
702
- return e.render(
703
- /* @__PURE__ */ o(
704
- ee,
1195
+ return u.render(
1196
+ /* @__PURE__ */ e(
1197
+ fe,
705
1198
  {
706
- api: X({ jeton: n, site: t, apiBaseUrl: s, surJetonRefuse: a }),
1199
+ api: se({ jeton: n, site: t, apiBaseUrl: c, surJetonRefuse: m }),
707
1200
  pont: r
708
1201
  }
709
1202
  )
710
- ), () => {
711
- const u = e;
712
- e = null, setTimeout(() => {
713
- u?.unmount(), c.remove();
714
- }, 0);
715
- };
1203
+ ), ne(u, a);
716
1204
  }
717
1205
  export {
718
- ae as monterEditeur
1206
+ we as monterConnexion,
1207
+ ke as monterEditeur
719
1208
  };