@amsom-habitat/cresol 0.1.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/cresol.js ADDED
@@ -0,0 +1,2628 @@
1
+ import { AmsomModal as e, AmsomOverlay as t } from "@amsom-habitat/ui";
2
+ import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createSlots as c, createTextVNode as l, createVNode as u, guardReactiveProps as d, inject as f, mergeProps as p, normalizeClass as m, normalizeProps as h, openBlock as g, provide as _, reactive as v, ref as y, renderList as b, renderSlot as x, resolveComponent as S, toDisplayString as C, toHandlers as ee, toRef as w, unref as T, vShow as E, withCtx as D, withDirectives as O } from "vue";
3
+ import { AmsomNavTabsHorizontal as te } from "@amsom-habitat/nav-tabs";
4
+ import ne from "@amsom-habitat/horizontal-stepper";
5
+ import { AmsomAutocomplete as k } from "@amsom-habitat/amsom-autocomplete";
6
+ import re from "@amsom-habitat/axios-overlay";
7
+ import A from "@amsom-habitat/user-manager";
8
+ import { library as ie } from "@fortawesome/fontawesome-svg-core";
9
+ import { AmsomTextarea as ae } from "@amsom-habitat/amsom-textarea";
10
+ import { AmsomUploadFile as oe } from "@amsom-habitat/file-manager";
11
+ //#region src/utils/provenanceContact.js
12
+ var se = [
13
+ {
14
+ id: "T",
15
+ libelle: "Téléphone",
16
+ icon: "phone"
17
+ },
18
+ {
19
+ id: "M",
20
+ libelle: "Email",
21
+ icon: "envelope"
22
+ },
23
+ {
24
+ id: "G",
25
+ libelle: "Gardien",
26
+ icon: "user-shield"
27
+ },
28
+ {
29
+ id: "V",
30
+ libelle: "Visite au siège",
31
+ icon: "building"
32
+ },
33
+ {
34
+ id: "IP",
35
+ libelle: "Incident de permanence",
36
+ icon: "exclamation-triangle"
37
+ },
38
+ {
39
+ id: "C",
40
+ libelle: "Courrier",
41
+ icon: "envelope-open"
42
+ }
43
+ ], ce = "T", le = Symbol("cresol:draft"), j = () => ({
44
+ idCommune: null,
45
+ commune: null,
46
+ idEntree: null,
47
+ entree: null,
48
+ etage: null,
49
+ idModule: null,
50
+ libelleModule: null,
51
+ codeProgramme: null,
52
+ codeTranche: null,
53
+ codeBatiment: null,
54
+ codeEscalier: null,
55
+ typeContratActuel: null,
56
+ idContratActuel: null,
57
+ occupantActuel: null
58
+ }), M = () => ({
59
+ idMotif: null,
60
+ idCategorie: null,
61
+ idType: null,
62
+ idNature: null,
63
+ libelle: null,
64
+ responsable: null,
65
+ cibleOverride: !1,
66
+ cibleMode: null,
67
+ contratReclamant: !0,
68
+ contratCible: null,
69
+ reprendreLocataireActuel: !1,
70
+ patrimoine: null,
71
+ description: null,
72
+ dateFaits: null,
73
+ dateFaitsOverride: !1,
74
+ fichier: null
75
+ }), N = [
76
+ "reclamant",
77
+ "provenance",
78
+ "motif",
79
+ "cible",
80
+ "description",
81
+ "dateFaits",
82
+ "responsable",
83
+ "fichier"
84
+ ], ue = [
85
+ "D",
86
+ "U",
87
+ "T"
88
+ ], P = (e = "T") => ({
89
+ reclamant: {
90
+ type: null,
91
+ id: null
92
+ },
93
+ provenance: e,
94
+ lignes: [{
95
+ ...M(),
96
+ cibleMode: "contrat",
97
+ patrimoine: j(),
98
+ description: ""
99
+ }]
100
+ }), de = (e) => e?.id ?? e ?? null, fe = (e) => {
101
+ if (!e) return "Cible non définie";
102
+ let t = [
103
+ e.commune,
104
+ e.entree,
105
+ e.libelleModule
106
+ ].filter(Boolean);
107
+ return e.etage != null && !e.libelleModule && t.push(`Étage ${e.etage}`), t.length ? t.join(" — ") : "Cible non définie";
108
+ }, pe = (e) => !!e && (e.idModule != null || e.idEntree != null), me = (e, t) => e.cibleMode === "demande" || !e.cibleOverride && e.patrimoine == null ? !0 : e.cibleMode === "contrat" ? !!(e.contratReclamant && t || e.contratCible) && e.patrimoine?.idModule != null : pe(e.patrimoine), he = (e, t) => e.description == null ? !t : e.description.trim().length > 0, F = (e = {}) => {
109
+ let t = {
110
+ ...M(),
111
+ ...e
112
+ };
113
+ return e.patrimoine && (t.patrimoine = {
114
+ ...j(),
115
+ ...e.patrimoine
116
+ }), t;
117
+ }, ge = (e) => {
118
+ let t = P();
119
+ if (!e) return t;
120
+ let n = Array.isArray(e.lignes) && e.lignes.length ? e.lignes : null;
121
+ return {
122
+ ...t,
123
+ ...e,
124
+ reclamant: {
125
+ ...t.reclamant,
126
+ ...e.reclamant ?? {}
127
+ },
128
+ provenance: e.provenance ?? t.provenance,
129
+ lignes: n ? n.map((e, n) => n === 0 ? {
130
+ ...t.lignes[0],
131
+ ...F(e)
132
+ } : F(e)) : t.lignes
133
+ };
134
+ };
135
+ function _e({ reclamants: e, modules: t, idModulePrefere: n = y(null), readonly: i = y(!1) } = {}) {
136
+ let a = v(P()), o = r(() => {
137
+ let e = T(i);
138
+ return e === !0 ? N : Array.isArray(e) ? e : [];
139
+ }), s = (e) => o.value.includes(e), c = r(() => a.lignes[0]), l = r(() => a.lignes.slice(1)), u = r(() => T(e) ?? []), d = r(() => u.value.find((e) => e.type === a.reclamant.type && String(e.id) === String(a.reclamant.id)) ?? u.value[0] ?? null), f = r(() => {
140
+ let e = T(t) ?? [], r = T(n);
141
+ return (r == null ? null : e.find((e) => String(e.idModule) === String(r))) ?? e.find((e) => e.estModulePrincipal) ?? e[0] ?? null;
142
+ }), p = r(() => !!d.value && !ue.includes(d.value.type)), m = {
143
+ draft: a,
144
+ lignePrincipale: c,
145
+ lignesAssociees: l,
146
+ reclamantsDisponibles: u,
147
+ reclamantSelectionne: d,
148
+ moduleReclamantPrincipal: f,
149
+ reclamantEstContrat: p,
150
+ ciblesValid: r(() => a.lignes.every((e) => me(e, p.value))),
151
+ detailsValid: r(() => a.lignes.every((e, t) => he(e, t === 0))),
152
+ isReadonly: s,
153
+ reset(e = null) {
154
+ let t = ge(e);
155
+ Object.assign(a, t), a.lignes = t.lignes;
156
+ },
157
+ setProvenance(e) {
158
+ a.provenance = e;
159
+ },
160
+ syncReclamant() {
161
+ let e = d.value;
162
+ m.setReclamant({
163
+ type: e?.type ?? null,
164
+ id: e?.id ?? null
165
+ });
166
+ },
167
+ setReclamant({ type: e, id: t }) {
168
+ if (a.reclamant = {
169
+ type: e ?? null,
170
+ id: t ?? null
171
+ }, s("cible")) return;
172
+ let n = a.lignes[0];
173
+ e === "D" ? (n.cibleMode = "demande", n.patrimoine = null) : (n.cibleMode = p.value ? "contrat" : "patrimoine", n.contratReclamant = p.value, n.contratCible = null, n.reprendreLocataireActuel = !1, n.patrimoine = j(), m.prefillCiblePrincipale());
174
+ },
175
+ prefillCiblePrincipale() {
176
+ if (s("cible")) return;
177
+ let e = f.value;
178
+ e && m.prefillFromModule(0, e);
179
+ },
180
+ _resetAfterNomenclature() {
181
+ a.lignes[0].responsable = null, a.lignes.splice(1);
182
+ },
183
+ setCategorie(e) {
184
+ let t = a.lignes[0];
185
+ t.idCategorie = e, t.idType = null, t.idNature = null, t.idMotif = null, m._resetAfterNomenclature();
186
+ },
187
+ setType(e) {
188
+ let t = a.lignes[0];
189
+ t.idType = e, t.idNature = null, t.idMotif = null, m._resetAfterNomenclature();
190
+ },
191
+ setNature(e) {
192
+ let t = a.lignes[0];
193
+ t.idNature = e, t.idMotif = null, m._resetAfterNomenclature();
194
+ },
195
+ setMotif(e) {
196
+ a.lignes[0].idMotif = e, m._resetAfterNomenclature();
197
+ },
198
+ selectMotifChain(e) {
199
+ let t = a.lignes[0];
200
+ t.idCategorie = e?.idCategorie ?? null, t.idType = e?.idType ?? null, t.idNature = e?.idNature ?? null, t.idMotif = e?.id ?? null, m._resetAfterNomenclature();
201
+ },
202
+ toggleLigneAssociee(e, t = {}) {
203
+ let n = a.lignes.findIndex((t, n) => n > 0 && t.idMotif === e);
204
+ if (n !== -1) {
205
+ a.lignes.splice(n, 1);
206
+ return;
207
+ }
208
+ a.lignes.push({
209
+ ...M(),
210
+ idMotif: e,
211
+ ...t
212
+ });
213
+ },
214
+ _patrimoine(e) {
215
+ return a.lignes[e]?.patrimoine ?? null;
216
+ },
217
+ setCibleMode(e, t) {
218
+ let n = a.lignes[e];
219
+ n && (n.cibleMode = t, n.reprendreLocataireActuel = !1, n.contratReclamant = t === "contrat" && p.value, n.contratCible = null, t === "demande" ? n.patrimoine = null : n.patrimoine ??= j());
220
+ },
221
+ toggleContratReclamant(e, t) {
222
+ let n = a.lignes[e];
223
+ n && (n.contratReclamant = t ?? !n.contratReclamant, n.contratCible = null, n.patrimoine && m.setPatrimoineModule(e, null));
224
+ },
225
+ setContratCible(e, t) {
226
+ let n = a.lignes[e];
227
+ n && (n.contratCible = t ? {
228
+ typeContrat: t.typeContrat,
229
+ idContrat: t.idContrat,
230
+ libelle: t.libelleContrat ?? null
231
+ } : null, m.setPatrimoineModule(e, null));
232
+ },
233
+ setPatrimoineCommune(e, t) {
234
+ let n = m._patrimoine(e);
235
+ n && (n.idCommune = t?.idCommune ?? null, n.commune = t?.commune ?? null, m.setPatrimoineEntree(e, null));
236
+ },
237
+ setPatrimoineEntree(e, t) {
238
+ let n = m._patrimoine(e);
239
+ n && (n.idEntree = t?.idEntree ?? null, n.entree = t?.entree ?? null, n.codeProgramme = t?.codeProgramme ?? null, n.codeTranche = t?.codeTranche ?? null, n.codeBatiment = t?.codeBatiment ?? null, n.codeEscalier = t?.codeEscalier ?? null, n.etage = null, m.setPatrimoineModule(e, null));
240
+ },
241
+ setPatrimoineEtage(e, t) {
242
+ let n = m._patrimoine(e);
243
+ n && (n.etage = t, m.setPatrimoineModule(e, null));
244
+ },
245
+ setPatrimoineModule(e, t) {
246
+ let n = m._patrimoine(e);
247
+ n && (n.idModule = t?.idModule ?? null, n.libelleModule = t?.libelleModule ?? null, n.typeContratActuel = t?.typeContratActuel ?? null, n.idContratActuel = t?.idContratActuel ?? null, n.occupantActuel = t?.occupantActuel ?? null, t && (n.codeProgramme = t.codeProgramme ?? n.codeProgramme, n.codeTranche = t.codeTranche ?? n.codeTranche, n.codeBatiment = t.codeBatiment ?? n.codeBatiment, n.codeEscalier = t.codeEscalier ?? n.codeEscalier, t.idEntree != null && (n.idEntree = t.idEntree), t.etage != null && (n.etage = t.etage)));
248
+ },
249
+ prefillFromModule(e, t) {
250
+ let n = m._patrimoine(e);
251
+ n && t && (n.idCommune = t.idCommune ?? null, n.commune = t.commune ?? null, n.idEntree = t.idEntree ?? null, n.entree = t.adresse ?? t.numeroRue ?? null, n.codeProgramme = t.codeProgramme ?? null, n.codeTranche = t.codeTranche ?? null, n.codeBatiment = t.codeBatiment ?? null, n.codeEscalier = t.codeEscalier ?? null, n.etage = t.etage ?? null, n.idModule = t.idModule ?? null, n.libelleModule = t.libelleModule ?? t.adresse ?? null, n.typeContratActuel = t.typeContratActuel ?? null, n.idContratActuel = t.idContratActuel ?? null, n.occupantActuel = t.occupantActuel ?? null);
252
+ },
253
+ toggleCibleOverride(e) {
254
+ let t = a.lignes[e];
255
+ if (!t) return;
256
+ let n = a.lignes[0];
257
+ t.cibleOverride ? (t.cibleOverride = !1, t.cibleMode = null, t.patrimoine = null, t.reprendreLocataireActuel = !1, t.contratReclamant = !0, t.contratCible = null) : (t.cibleOverride = !0, t.cibleMode = n.cibleMode, t.patrimoine = n.cibleMode === "demande" ? null : { ...n.patrimoine }, t.reprendreLocataireActuel = n.reprendreLocataireActuel, t.contratReclamant = n.contratReclamant, t.contratCible = n.contratCible ? { ...n.contratCible } : null);
258
+ },
259
+ setReprendreLocataireActuel(e, t) {
260
+ let n = a.lignes[e];
261
+ n && (n.reprendreLocataireActuel = !!t);
262
+ },
263
+ setDescription(e, t) {
264
+ let n = a.lignes[e];
265
+ n && (n.description = t);
266
+ },
267
+ setDateFaits(e, t) {
268
+ let n = a.lignes[e];
269
+ n && (n.dateFaits = t);
270
+ },
271
+ setResponsable(e, t) {
272
+ let n = a.lignes[e];
273
+ n && (n.responsable = t);
274
+ },
275
+ setFichier(e, t) {
276
+ let n = a.lignes[e];
277
+ n && (n.fichier = t);
278
+ },
279
+ toggleDescriptionOverride(e) {
280
+ let t = a.lignes[e];
281
+ t && (t.description = t.description == null ? "" : null);
282
+ },
283
+ toggleDateFaitsOverride(e) {
284
+ let t = a.lignes[e];
285
+ t && (t.dateFaitsOverride = !t.dateFaitsOverride, t.dateFaits = t.dateFaitsOverride ? a.lignes[0].dateFaits : null);
286
+ },
287
+ _patrimoinePayload(e) {
288
+ return e.idModule == null ? {
289
+ idProgramme: e.codeProgramme,
290
+ idTranche: e.codeTranche,
291
+ idBatiment: e.codeBatiment,
292
+ idEscalier: e.codeEscalier,
293
+ etage: e.etage
294
+ } : { idModule: e.idModule };
295
+ },
296
+ _lignePayload(e, t) {
297
+ let n = a.lignes[0], r = t > 0 && !e.cibleOverride ? n : e, i = (e.description ?? "").trim() || (n.description ?? "").trim(), o = e.dateFaits == null ? n.dateFaits : e.dateFaits, s = a.reclamant.type === "D", c = {
298
+ categorie: e.idCategorie,
299
+ type: e.idType,
300
+ nature: e.idNature,
301
+ motif: e.idMotif,
302
+ description: i,
303
+ dateFaits: o,
304
+ responsable: de(e.responsable)
305
+ };
306
+ if (r.cibleMode === "demande") return {
307
+ ...c,
308
+ codeTypeCible: "D",
309
+ idCible: a.reclamant.id,
310
+ deduireCible: !1
311
+ };
312
+ let l = m._patrimoinePayload(r.patrimoine);
313
+ if (r.cibleMode === "contrat" && !r.reprendreLocataireActuel) {
314
+ let e = r.contratReclamant && p.value ? {
315
+ typeContrat: a.reclamant.type,
316
+ idContrat: a.reclamant.id
317
+ } : r.contratCible;
318
+ return {
319
+ ...c,
320
+ patrimoine: l,
321
+ codeTypeCible: e?.typeContrat ?? null,
322
+ idCible: e?.idContrat ?? null,
323
+ deduireCible: !1
324
+ };
325
+ }
326
+ return {
327
+ ...c,
328
+ patrimoine: l,
329
+ codeTypeCible: null,
330
+ idCible: null,
331
+ deduireCible: r.patrimoine?.idModule != null && !s
332
+ };
333
+ },
334
+ cibleResume(e) {
335
+ let t = a.lignes[0], n = e !== t && !e.cibleOverride ? t : e;
336
+ if (n.cibleMode === "demande") return "La demande";
337
+ let r = fe(n.patrimoine);
338
+ if (n.cibleMode !== "contrat") return r;
339
+ let i = "Contrat non défini";
340
+ if (n.contratReclamant && p.value) i = "Contrat du réclamant";
341
+ else if (n.contratCible) {
342
+ let e = n.contratCible;
343
+ i = `${e.libelle ?? "Contrat"} (${e.typeContrat}/${e.idContrat})`;
344
+ }
345
+ return `${i} — ${r}`;
346
+ },
347
+ lignesPayload() {
348
+ return a.lignes.map((e, t) => m._lignePayload(e, t));
349
+ },
350
+ creationPayload() {
351
+ let e = d.value;
352
+ return {
353
+ typeReclamant: e?.type ?? null,
354
+ reclamant: e?.id ?? null,
355
+ lignes: m.lignesPayload(),
356
+ provenance: a.provenance
357
+ };
358
+ }
359
+ };
360
+ return v(m);
361
+ }
362
+ function ve(e) {
363
+ return _(le, e), e;
364
+ }
365
+ function I() {
366
+ let e = f(le, null);
367
+ if (!e) throw Error("useSollicitationDraft() hors de <creer-sollicitation-form>");
368
+ return e;
369
+ }
370
+ //#endregion
371
+ //#region \0plugin-vue:export-helper
372
+ var L = (e, t) => {
373
+ let n = e.__vccOpts || e;
374
+ for (let [e, r] of t) n[e] = r;
375
+ return n;
376
+ }, ye = {
377
+ name: "AsideBlock",
378
+ components: { AmsomNavTabsHorizontal: te },
379
+ props: { nbSimilaires: {
380
+ type: Number,
381
+ default: 0
382
+ } },
383
+ setup() {
384
+ return { draft: I() };
385
+ },
386
+ data() {
387
+ return { activeTab: null };
388
+ },
389
+ computed: {
390
+ lignePrincipale() {
391
+ return this.draft.lignePrincipale;
392
+ },
393
+ scope() {
394
+ let e = this.lignePrincipale, t = e?.cibleMode === "demande";
395
+ return {
396
+ idMotif: e?.idMotif ?? null,
397
+ codeProgramme: t ? null : e?.patrimoine?.codeProgramme ?? null,
398
+ idCible: t ? this.draft.draft.reclamant?.id ?? null : null,
399
+ reclamant: this.draft.reclamantSelectionne
400
+ };
401
+ },
402
+ tabs() {
403
+ return [...this.$slots.similaires ? [{
404
+ id: "similarite",
405
+ label: "Similarité",
406
+ icon: "layer-group"
407
+ }] : [], ...this.$slots.evenements ? [{
408
+ id: "evenements",
409
+ label: "Événements",
410
+ icon: "circle-exclamation"
411
+ }] : []];
412
+ }
413
+ },
414
+ watch: { tabs: {
415
+ immediate: !0,
416
+ handler(e) {
417
+ e.some((e) => e.id === this.activeTab) || (this.activeTab = e[0]?.id ?? null);
418
+ }
419
+ } }
420
+ }, be = {
421
+ key: 0,
422
+ class: "badge bg-danger ms-1"
423
+ }, xe = { style: { "min-height": "320px" } }, Se = { key: 0 }, Ce = { key: 1 };
424
+ function we(e, t, n, r, c, l) {
425
+ let f = S("font-awesome-icon"), p = S("amsom-nav-tabs-horizontal");
426
+ return l.tabs.length ? (g(), i(p, {
427
+ key: 0,
428
+ modelValue: c.activeTab,
429
+ "onUpdate:modelValue": t[0] ||= (e) => c.activeTab = e,
430
+ items: l.tabs,
431
+ "item-key": "id",
432
+ "tab-spacing": 1
433
+ }, {
434
+ libelle: D(({ item: e }) => [
435
+ u(f, { icon: e.icon }, null, 8, ["icon"]),
436
+ s("span", null, C(e.label), 1),
437
+ e.id === "similarite" && n.nbSimilaires > 0 ? (g(), o("span", be, C(n.nbSimilaires), 1)) : a("", !0)
438
+ ]),
439
+ content: D(() => [s("div", xe, [e.$slots.similaires ? O((g(), o("div", Se, [x(e.$slots, "similaires", h(d(l.scope)))], 512)), [[E, c.activeTab === "similarite"]]) : a("", !0), e.$slots.evenements ? O((g(), o("div", Ce, [x(e.$slots, "evenements")], 512)), [[E, c.activeTab === "evenements"]]) : a("", !0)])]),
440
+ _: 3
441
+ }, 8, ["modelValue", "items"])) : a("", !0);
442
+ }
443
+ var Te = /*#__PURE__*/ L(ye, [["render", we]]), R = Symbol("cresol:options"), Ee = (e) => _(R, e), z = () => f(R, {});
444
+ //#endregion
445
+ //#region src/utils/text.js
446
+ function B(e, t = !0) {
447
+ if (!e) return null;
448
+ let n = e.toString().normalize("NFD").replace(/[̀-ͯ]/g, "");
449
+ return t ? n.toLowerCase() : n;
450
+ }
451
+ //#endregion
452
+ //#region src/components/ReclamantSelecteurBlock.vue
453
+ var De = {
454
+ name: "ReclamantSelecteurBlock",
455
+ components: { AmsomAutocomplete: k },
456
+ props: {
457
+ mode: {
458
+ type: String,
459
+ default: null
460
+ },
461
+ inline: {
462
+ type: Boolean,
463
+ default: !0
464
+ }
465
+ },
466
+ setup() {
467
+ return {
468
+ draft: I(),
469
+ options: z()
470
+ };
471
+ },
472
+ computed: {
473
+ reclamants() {
474
+ return this.draft.reclamantsDisponibles;
475
+ },
476
+ reclamantSelectionne() {
477
+ return this.draft.reclamantSelectionne;
478
+ },
479
+ presentation() {
480
+ return this.mode ?? this.options.reclamantMode;
481
+ },
482
+ estFige() {
483
+ return this.reclamants.length <= 1 || this.draft.isReadonly("reclamant");
484
+ }
485
+ },
486
+ methods: {
487
+ reclamantId(e) {
488
+ let t = this.reclamants.indexOf(e);
489
+ return t < 0 ? null : t;
490
+ },
491
+ select(e) {
492
+ e && this.draft.setReclamant(e);
493
+ },
494
+ filterReclamants({ search: e, items: t }) {
495
+ let n = (B(e) ?? "").trim();
496
+ return n ? t.filter((e) => (B(e?.libelle) ?? "").includes(n)) : t;
497
+ }
498
+ }
499
+ }, Oe = {
500
+ key: 0,
501
+ class: "fs-7 text-muted"
502
+ }, ke = { class: "fw-medium" }, Ae = {
503
+ key: 0,
504
+ class: "btn-group btn-group-sm",
505
+ role: "group"
506
+ }, je = ["onClick"], Me = ["value"], Ne = ["value"];
507
+ function Pe(e, t, r, a, c, u) {
508
+ let d = S("amsom-autocomplete");
509
+ return u.estFige ? (g(), o("div", Oe, [t[2] ||= l(" Réclamant : ", -1), s("span", ke, C(u.reclamantSelectionne?.libelle), 1)])) : (g(), o("div", {
510
+ key: 1,
511
+ class: m(r.inline ? "d-flex align-items-center justify-content-between gap-2 border-bottom pb-2" : "d-flex flex-column gap-1")
512
+ }, [t[3] ||= s("span", { class: "fs-7 fw-semibold text-muted text-uppercase" }, "Réclamant", -1), u.presentation === "switch" ? (g(), o("div", Ae, [(g(!0), o(n, null, b(u.reclamants, (e, t) => (g(), o("button", {
513
+ key: t,
514
+ type: "button",
515
+ class: m(["btn btn-sm py-0", e === u.reclamantSelectionne ? "btn-primary" : "btn-outline-primary"]),
516
+ onClick: (t) => u.select(e)
517
+ }, C(e.libelle), 11, je))), 128))])) : u.presentation === "autocomplete" ? (g(), i(d, {
518
+ key: 1,
519
+ "model-value": u.reclamantSelectionne,
520
+ items: u.reclamants,
521
+ "get-id": u.reclamantId,
522
+ "get-input-libelle": (e) => e?.libelle ?? "",
523
+ "filtering-function": u.filterReclamants,
524
+ placeholder: "Rechercher un réclamant…",
525
+ "input-size": "sm",
526
+ "hide-choices": "",
527
+ class: m(r.inline ? "" : "w-100"),
528
+ "onUpdate:modelValue": t[0] ||= (e) => u.select(e)
529
+ }, null, 8, [
530
+ "model-value",
531
+ "items",
532
+ "get-id",
533
+ "get-input-libelle",
534
+ "filtering-function",
535
+ "class"
536
+ ])) : (g(), o("select", {
537
+ key: 2,
538
+ class: m(["form-select form-select-sm", r.inline ? "w-auto" : ""]),
539
+ value: u.reclamants.indexOf(u.reclamantSelectionne),
540
+ onChange: t[1] ||= (e) => u.select(u.reclamants[e.target.value])
541
+ }, [(g(!0), o(n, null, b(u.reclamants, (e, t) => (g(), o("option", {
542
+ key: t,
543
+ value: t
544
+ }, C(e.libelle), 9, Ne))), 128))], 42, Me))], 2));
545
+ }
546
+ var V = /*#__PURE__*/ L(De, [["render", Pe]]), Fe = {
547
+ name: "ProvenanceSelecteurBlock",
548
+ setup() {
549
+ return { draft: I() };
550
+ },
551
+ computed: {
552
+ provenances() {
553
+ return se;
554
+ },
555
+ selected() {
556
+ return this.draft.draft.provenance;
557
+ },
558
+ provenanceChoisie() {
559
+ return this.provenances.find((e) => e.id === this.selected) ?? null;
560
+ }
561
+ }
562
+ }, Ie = {
563
+ key: 0,
564
+ class: "fs-7 text-muted"
565
+ }, Le = { class: "fw-medium" }, Re = { key: 1 }, ze = { class: "d-flex flex-wrap gap-2" }, Be = ["onClick"], Ve = {
566
+ key: 0,
567
+ class: "fs-7 text-danger mt-1"
568
+ };
569
+ function He(e, t, r, c, d, f) {
570
+ let p = S("font-awesome-icon");
571
+ return c.draft.isReadonly("provenance") ? (g(), o("div", Ie, [t[0] ||= l(" Provenance du contact : ", -1), s("span", Le, [f.provenanceChoisie?.icon ? (g(), i(p, {
572
+ key: 0,
573
+ icon: f.provenanceChoisie.icon,
574
+ "fixed-width": ""
575
+ }, null, 8, ["icon"])) : a("", !0), l(" " + C(f.provenanceChoisie?.libelle ?? "—"), 1)])])) : (g(), o("div", Re, [
576
+ t[1] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, [l(" Provenance du contact "), s("span", { class: "text-danger" }, "*")], -1),
577
+ s("div", ze, [(g(!0), o(n, null, b(f.provenances, (e) => (g(), o("button", {
578
+ key: e.id,
579
+ type: "button",
580
+ class: m(["btn btn-sm d-inline-flex align-items-center gap-2", e.id === f.selected ? "btn-primary" : "btn-outline-primary"]),
581
+ onClick: (t) => c.draft.setProvenance(e.id)
582
+ }, [u(p, {
583
+ icon: f.provenanceChoisie.icon,
584
+ "fixed-width": ""
585
+ }, null, 8, ["icon"]), s("span", null, C(e.libelle), 1)], 10, Be))), 128))]),
586
+ f.selected ? a("", !0) : (g(), o("div", Ve, " Sélectionnez par quel canal la sollicitation vous est parvenue. "))
587
+ ]));
588
+ }
589
+ var Ue = /*#__PURE__*/ L(Fe, [["render", He]]), We = {
590
+ name: "EtapeReclamantBlock",
591
+ components: {
592
+ ReclamantSelecteurBlock: V,
593
+ ProvenanceSelecteurBlock: Ue
594
+ },
595
+ props: { premiere: {
596
+ type: Boolean,
597
+ default: !1
598
+ } }
599
+ }, Ge = { class: "d-flex flex-column gap-3" }, Ke = { class: "alert alert-light border py-2 px-3 mb-0 fs-7" };
600
+ function qe(e, t, n, r, c, d) {
601
+ let f = S("font-awesome-icon"), p = S("reclamant-selecteur-block"), m = S("provenance-selecteur-block");
602
+ return g(), o("div", Ge, [
603
+ s("div", Ke, [u(f, {
604
+ icon: "user",
605
+ class: "text-primary me-2"
606
+ }), t[0] ||= l(" Pour qui cette sollicitation est-elle créée\xA0? ", -1)]),
607
+ u(p, {
608
+ mode: "select",
609
+ inline: !1
610
+ }),
611
+ n.premiere ? (g(), i(m, { key: 0 })) : a("", !0)
612
+ ]);
613
+ }
614
+ var Je = /*#__PURE__*/ L(We, [["render", qe]]), Ye = {
615
+ baseUrl: "",
616
+ getToken: () => A.getToken(),
617
+ setToken: (e) => A.setToken(e),
618
+ logout: () => A.logout(),
619
+ goToLoginPage: () => A.goToLoginPage()
620
+ };
621
+ function Xe(e = {}) {
622
+ Object.assign(Ye, e);
623
+ }
624
+ var H = () => Ye;
625
+ //#endregion
626
+ //#region src/api/transport/axiosOverlayConnector.js
627
+ function Ze(e, t = {}) {
628
+ let n = H(), r = {
629
+ getToken: () => n.getToken?.() ?? null,
630
+ setToken: (e) => n.setToken?.(e),
631
+ logout: () => n.logout?.(),
632
+ errorsHandlers: {
633
+ default: ({ error: e, reject: t }) => {
634
+ console.error("Erreur API (cresol):", e), t(e);
635
+ },
636
+ 401: ({ error: e, overlayConfig: t, reject: r }) => {
637
+ t.allowRedirect && n.goToLoginPage?.(), r(e);
638
+ },
639
+ 498: ({ error: e, overlayConfig: t, reject: r }) => {
640
+ t.allowRedirect && n.goToLoginPage?.(), r(e);
641
+ }
642
+ }
643
+ };
644
+ return t.functions = {
645
+ ...r,
646
+ ...t.functions ?? {}
647
+ }, t.functions.errorsHandlers = {
648
+ ...r.errorsHandlers,
649
+ ...t.functions.errorsHandlers ?? {}
650
+ }, re(e, t);
651
+ }
652
+ //#endregion
653
+ //#region src/api/transport/httpClient.js
654
+ var Qe = (e, t) => {
655
+ let n = t || H().baseUrl;
656
+ if (!n) throw Error("Cresol : baseUrl non renseignée (configureCresol ou prop baseUrl)");
657
+ return `${n}${e}`;
658
+ }, $e = (e = {}) => {
659
+ let t = new URLSearchParams();
660
+ Object.entries(e).forEach(([e, n]) => {
661
+ n != null && n !== "" && t.append(e, typeof n == "object" ? JSON.stringify(n) : n);
662
+ });
663
+ let n = t.toString();
664
+ return n ? `?${n}` : "";
665
+ }, et = (e = {}, t) => t ? {
666
+ ...e,
667
+ functions: {
668
+ ...e.functions ?? {},
669
+ getToken: () => t
670
+ }
671
+ } : e, tt = ({ method: e, path: t, params: n, data: r, signal: i, token: a, baseUrl: o }, s = {}) => Ze({
672
+ url: Qe(`${t}${$e(n)}`, o),
673
+ method: e,
674
+ ...r === void 0 ? {} : { data: r },
675
+ ...i ? { signal: i } : {}
676
+ }, et(s, a)), U = (e, { params: t, signal: n, overlay: r, token: i, baseUrl: a } = {}) => tt({
677
+ method: "GET",
678
+ path: e,
679
+ params: t,
680
+ signal: n,
681
+ token: i,
682
+ baseUrl: a
683
+ }, r).then((e) => e.data), nt = (e, t, { params: n, signal: r, overlay: i, token: a, baseUrl: o } = {}) => tt({
684
+ method: "POST",
685
+ path: e,
686
+ params: n,
687
+ data: t,
688
+ signal: r,
689
+ token: a,
690
+ baseUrl: o
691
+ }, i).then((e) => e.data), rt = { mustBeAuthenticated: !1 }, W = (e, { signal: t, token: n, baseUrl: r } = {}) => U(e, {
692
+ signal: t,
693
+ token: n,
694
+ baseUrl: r,
695
+ overlay: rt
696
+ }), it = (e) => W("/v2/sollicitation/motifs", e), at = (e) => W("/v2/sollicitation/categories", e), ot = (e) => W("/v2/sollicitation/types", e), st = (e) => W("/v2/sollicitation/natures", e), ct = (e) => W("/v2/sollicitation/etats", e), lt = ({ signal: e, token: t, baseUrl: n } = {}) => U("/collaborateurs", {
697
+ params: { actif: !0 },
698
+ signal: e,
699
+ token: t,
700
+ baseUrl: n
701
+ }), ut = ({ signal: e, token: t, baseUrl: n } = {}) => U("/cally2/patrimoine_communes", {
702
+ signal: e,
703
+ token: t,
704
+ baseUrl: n
705
+ }), dt = (e, { signal: t, token: n, baseUrl: r } = {}) => U("/cally2/patrimoine_entrees", {
706
+ params: { idCommune: e },
707
+ signal: t,
708
+ token: n,
709
+ baseUrl: r
710
+ }), ft = (e, { signal: t, token: n, baseUrl: r } = {}) => U("/cally2/patrimoine_modules", {
711
+ params: { codeProgramme: e },
712
+ signal: t,
713
+ token: n,
714
+ baseUrl: r
715
+ }), pt = ({ idContrat: e, typeContrat: t }, { signal: n, token: r, baseUrl: i } = {}) => U("/cally2/contrat_modules", {
716
+ params: {
717
+ idContrat: e,
718
+ typeContrat: t
719
+ },
720
+ signal: n,
721
+ token: r,
722
+ baseUrl: i
723
+ }), mt = ({ motif: e, categorie: t, type: n, nature: r }, { signal: i, token: a, baseUrl: o } = {}) => U("/v2/sollicitation/responsables", {
724
+ params: {
725
+ motif: e,
726
+ categorie: t,
727
+ type: n,
728
+ nature: r
729
+ },
730
+ signal: i,
731
+ token: a,
732
+ baseUrl: o
733
+ }), ht = ({ idContrat: e, libelle: t }, { signal: n, token: r, baseUrl: i } = {}) => U("/cockpit/circuit_achat/contrats", {
734
+ params: {
735
+ idContrat: e,
736
+ libelle: t
737
+ },
738
+ signal: n,
739
+ token: r,
740
+ baseUrl: i
741
+ });
742
+ //#endregion
743
+ //#region src/utils/apiError.js
744
+ function G(e) {
745
+ let t = e?.response?.data;
746
+ return t?.error ? t.error : t?.errorList ? t.errorList.map((e) => e.message).join(", ") : e?.response?.status === 500 ? "Erreur interne" : e?.response?.status === 401 ? "Non autorisé à faire cette action" : "Erreur";
747
+ }
748
+ var gt = (e) => e?.name === "AbortError" || e?.name === "CanceledError", _t = Symbol("cresol:data"), vt = () => ({
749
+ motifs: null,
750
+ categories: null,
751
+ types: null,
752
+ natures: null,
753
+ etats: null,
754
+ collaborateurs: null,
755
+ communes: null,
756
+ adressesByCommune: {},
757
+ modulesByProgramme: {},
758
+ modulesByContrat: {},
759
+ responsablesByMotif: {}
760
+ }), K = /* @__PURE__ */ new Map(), yt = (e) => (K.has(e) || K.set(e, v(vt())), K.get(e)), q = /* @__PURE__ */ new Map();
761
+ function bt() {
762
+ K.clear(), q.clear();
763
+ }
764
+ var J = (e, t, n) => e?.find((e) => e[t] === n)?.libelle ?? n, Y = (e, t, n) => e?.find((e) => e[t] === n)?.icon ?? null;
765
+ function xt({ onError: e, token: t, baseUrl: n } = {}) {
766
+ let i = y(0), a = () => ({
767
+ token: T(t) || null,
768
+ baseUrl: T(n) || null
769
+ }), o = () => T(n) || H().baseUrl || "", s = () => yt(o()), c = (t, n) => {
770
+ let r = `${o()}|${t}`;
771
+ if (q.has(r)) return q.get(r);
772
+ i.value += 1;
773
+ let a = Promise.resolve().then(n).catch((t) => (gt(t) || e?.(G(t)), null)).finally(() => {
774
+ --i.value, q.delete(r);
775
+ });
776
+ return q.set(r, a), a;
777
+ }, l = (e, t) => s()[e]?.length ? Promise.resolve(s()[e]) : c(`referentiel:${e}`, async () => (s()[e] = await t(a()), s()[e])), u = {
778
+ get cache() {
779
+ return s();
780
+ },
781
+ loading: i,
782
+ isLoading: r(() => i.value > 0),
783
+ loadNomenclature() {
784
+ return Promise.all([
785
+ l("motifs", it),
786
+ l("categories", at),
787
+ l("types", ot),
788
+ l("natures", st),
789
+ l("etats", ct)
790
+ ]);
791
+ },
792
+ loadCollaborateurs: () => l("collaborateurs", lt),
793
+ loadCommunes() {
794
+ return s().communes?.length ? Promise.resolve(s().communes) : c("communes", async () => (s().communes = await ut(a()), s().communes));
795
+ },
796
+ loadAdresses(e) {
797
+ return e == null ? Promise.resolve([]) : s().adressesByCommune[e] ? Promise.resolve(s().adressesByCommune[e]) : c(`adresses:${e}`, async () => {
798
+ let t = await dt(e, a());
799
+ return s().adressesByCommune[e] = t ?? [], t;
800
+ });
801
+ },
802
+ loadModulesOfProgramme(e) {
803
+ return e == null ? Promise.resolve([]) : s().modulesByProgramme[e] ? Promise.resolve(s().modulesByProgramme[e]) : c(`modules:${e}`, async () => {
804
+ let t = await ft(e, a());
805
+ return s().modulesByProgramme[e] = t ?? [], t;
806
+ });
807
+ },
808
+ loadModulesOfContrat({ idContrat: e, typeContrat: t }) {
809
+ if (e == null) return Promise.resolve([]);
810
+ let n = `${t ?? ""}|${e}`;
811
+ return s().modulesByContrat[n] ? Promise.resolve(s().modulesByContrat[n]) : c(`contratModules:${n}`, async () => {
812
+ let r = await pt({
813
+ idContrat: e,
814
+ typeContrat: t
815
+ }, a());
816
+ return s().modulesByContrat[n] = r ?? [], r;
817
+ });
818
+ },
819
+ async searchContrats(e, { signal: t } = {}) {
820
+ let n = (e ?? "").trim();
821
+ if (!n) return [];
822
+ let r = await ht(/^\d+$/.test(n) ? { idContrat: n } : { libelle: n }, {
823
+ ...a(),
824
+ signal: t
825
+ }), i = /* @__PURE__ */ new Map();
826
+ for (let e of r ?? []) {
827
+ let t = `${e.typeContrat}|${e.idContrat}`, n = i.get(t);
828
+ if (!n) {
829
+ i.set(t, {
830
+ typeContrat: e.typeContrat,
831
+ idContrat: e.idContrat,
832
+ libelle: e.libelle ?? null,
833
+ dateSortie: e.dateSortie ?? null,
834
+ nbModules: 1
835
+ });
836
+ continue;
837
+ }
838
+ n.nbModules += 1, e.dateSortie ?? (n.dateSortie = null);
839
+ }
840
+ return [...i.values()].sort((e, t) => (e.dateSortie == null ? 0 : 1) - (t.dateSortie == null ? 0 : 1) || (e.libelle ?? "").localeCompare(t.libelle ?? ""));
841
+ },
842
+ loadResponsables({ motif: e, categorie: t, type: n, nature: r }) {
843
+ return e == null ? Promise.resolve([]) : s().responsablesByMotif[e] ? Promise.resolve(s().responsablesByMotif[e]) : c(`responsables:${e}`, async () => {
844
+ let i = await mt({
845
+ motif: e,
846
+ categorie: t,
847
+ type: n,
848
+ nature: r
849
+ }, a());
850
+ return s().responsablesByMotif[e] = i ?? [], i;
851
+ });
852
+ },
853
+ adressesOfCommune: (e) => s().adressesByCommune[e] ?? null,
854
+ modulesOfProgramme: (e) => s().modulesByProgramme[e] ?? null,
855
+ modulesOfContrat: ({ idContrat: e, typeContrat: t }) => s().modulesByContrat[`${t ?? ""}|${e}`] ?? null,
856
+ allAdresses: () => Object.values(s().adressesByCommune).flat(),
857
+ getResponsableSuggere({ idMotif: e, codeProgramme: t, codeTranche: n, codeBatiment: r, codeEscalier: i }) {
858
+ let a = s().responsablesByMotif[e];
859
+ if (!a?.length || t == null) return null;
860
+ let o = a.filter((e) => String(e.codeProgramme) === String(t) && (e.codeTranche == null || e.codeTranche === n) && (e.codeBatiment == null || e.codeBatiment === r) && (e.codeEscalier == null || e.codeEscalier === i));
861
+ if (!o.length) return null;
862
+ let c = (e) => (e.codeEscalier == null ? 0 : 4) + (e.codeBatiment == null ? 0 : 2) + (e.codeTranche == null ? 0 : 1), l = o.reduce((e, t) => c(t) > c(e) ? t : e);
863
+ return {
864
+ idResponsable: l.idResponsable,
865
+ libelle: l.libelleResponsable
866
+ };
867
+ },
868
+ motifLibelle: (e) => J(s().motifs, "id", e),
869
+ categorieLibelle: (e) => J(s().categories, "id", e),
870
+ typeLibelle: (e) => J(s().types, "id", e),
871
+ natureLibelle: (e) => J(s().natures, "id", e),
872
+ etatLibelle: (e) => J(s().etats, "code", e),
873
+ motifIcon: (e) => Y(s().motifs, "id", e),
874
+ categorieIcon: (e) => Y(s().categories, "id", e),
875
+ typeIcon: (e) => Y(s().types, "id", e),
876
+ natureIcon: (e) => Y(s().natures, "id", e)
877
+ };
878
+ return v(u);
879
+ }
880
+ function St(e) {
881
+ return _(_t, e), e;
882
+ }
883
+ function X() {
884
+ let e = f(_t, null);
885
+ if (!e) throw Error("useCresolData() hors de <creer-sollicitation-form>");
886
+ return e;
887
+ }
888
+ //#endregion
889
+ //#region src/utils/fontAwesomeIcons.js
890
+ var Ct = (e) => "fa" + e.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
891
+ async function wt(e) {
892
+ let t = await import("@fortawesome/free-solid-svg-icons");
893
+ [...new Set(e.filter(Boolean))].forEach((e) => {
894
+ let n = t[Ct(e)];
895
+ n && ie.add(n);
896
+ });
897
+ }
898
+ //#endregion
899
+ //#region src/components/EtapeCategorieBlock.vue
900
+ var Tt = {
901
+ name: "EtapeCategorieBlock",
902
+ components: {
903
+ AmsomOverlay: t,
904
+ AmsomAutocomplete: k,
905
+ ReclamantSelecteurBlock: V,
906
+ ProvenanceSelecteurBlock: Ue
907
+ },
908
+ props: { premiere: {
909
+ type: Boolean,
910
+ default: !1
911
+ } },
912
+ setup() {
913
+ return {
914
+ draft: I(),
915
+ data: X(),
916
+ options: z()
917
+ };
918
+ },
919
+ data() {
920
+ return { iconsReady: !1 };
921
+ },
922
+ computed: {
923
+ mainLigne() {
924
+ return this.draft.lignePrincipale;
925
+ },
926
+ motifFige() {
927
+ return this.draft.isReadonly("motif");
928
+ },
929
+ activeMotifs() {
930
+ return (this.data.cache.motifs ?? []).filter((e) => !e.estDesactive).slice().sort((e, t) => (e.categorie ?? "").localeCompare(t.categorie ?? "") || (e.type ?? "").localeCompare(t.type ?? "") || (e.nature ?? "").localeCompare(t.nature ?? "") || (e.libelle ?? "").localeCompare(t.libelle ?? ""));
931
+ },
932
+ allowedMotifs() {
933
+ let e = this.options.nomenclatureFilter;
934
+ if (typeof e != "function") return this.activeMotifs;
935
+ let t = this.draft.reclamantSelectionne;
936
+ return this.activeMotifs.filter((n) => e(n, { reclamant: t }));
937
+ },
938
+ categoriesList() {
939
+ return this.distinct(this.allowedMotifs, "idCategorie", "categorie", (e) => this.data.categorieIcon(e));
940
+ },
941
+ typesList() {
942
+ return this.mainLigne.idCategorie ? this.distinct(this.allowedMotifs.filter((e) => e.idCategorie === this.mainLigne.idCategorie), "idType", "type", (e) => this.data.typeIcon(e)) : [];
943
+ },
944
+ naturesList() {
945
+ return this.mainLigne.idType ? this.distinct(this.allowedMotifs.filter((e) => e.idType === this.mainLigne.idType), "idNature", "nature", (e) => this.data.natureIcon(e)) : [];
946
+ },
947
+ motifsList() {
948
+ return this.mainLigne.idNature ? this.allowedMotifs.filter((e) => e.idNature === this.mainLigne.idNature).map((e) => ({
949
+ id: e.id,
950
+ libelle: e.libelle,
951
+ icon: e.icon
952
+ })) : [];
953
+ },
954
+ selectedMotif() {
955
+ return this.mainLigne.idMotif ? this.activeMotifs.find((e) => e.id === this.mainLigne.idMotif) ?? null : null;
956
+ },
957
+ motifsAssocies() {
958
+ let e = this.selectedMotif?.association;
959
+ return e ? Object.entries(e).map(([e, t]) => ({
960
+ libelle: e,
961
+ idMotif: t
962
+ })) : [];
963
+ },
964
+ selectionChain() {
965
+ let e = [];
966
+ return this.mainLigne.idCategorie && e.push({
967
+ level: "categorie",
968
+ libelle: this.data.categorieLibelle(this.mainLigne.idCategorie),
969
+ icon: this.data.categorieIcon(this.mainLigne.idCategorie)
970
+ }), this.mainLigne.idType && e.push({
971
+ level: "type",
972
+ libelle: this.data.typeLibelle(this.mainLigne.idType),
973
+ icon: this.data.typeIcon(this.mainLigne.idType)
974
+ }), this.mainLigne.idNature && e.push({
975
+ level: "nature",
976
+ libelle: this.data.natureLibelle(this.mainLigne.idNature),
977
+ icon: this.data.natureIcon(this.mainLigne.idNature)
978
+ }), this.mainLigne.idMotif && e.push({
979
+ level: "motif",
980
+ libelle: this.data.motifLibelle(this.mainLigne.idMotif),
981
+ icon: this.data.motifIcon(this.mainLigne.idMotif)
982
+ }), e;
983
+ },
984
+ currentLevel() {
985
+ return this.mainLigne.idCategorie ? this.mainLigne.idType ? this.mainLigne.idNature ? this.mainLigne.idMotif ? null : {
986
+ title: "Motif",
987
+ options: this.motifsList,
988
+ select: (e) => this.draft.setMotif(e)
989
+ } : {
990
+ title: "Nature",
991
+ options: this.naturesList,
992
+ select: (e) => this.draft.setNature(e)
993
+ } : {
994
+ title: "Type",
995
+ options: this.typesList,
996
+ select: (e) => this.draft.setType(e)
997
+ } : {
998
+ title: "Catégorie",
999
+ options: this.categoriesList,
1000
+ select: (e) => this.draft.setCategorie(e)
1001
+ };
1002
+ },
1003
+ motifRecherche: {
1004
+ get() {
1005
+ return this.selectedMotif;
1006
+ },
1007
+ set(e) {
1008
+ let t = e && typeof e == "object" ? e : e ? this.activeMotifs.find((t) => t.id === e) : null;
1009
+ t ? this.draft.selectMotifChain(t) : this.draft.setCategorie(null);
1010
+ }
1011
+ }
1012
+ },
1013
+ async created() {
1014
+ await this.data.loadNomenclature(), await this.registerIcons(), this.iconsReady = !0;
1015
+ },
1016
+ methods: {
1017
+ goBackTo(e) {
1018
+ e === "categorie" ? this.draft.setCategorie(null) : e === "type" ? this.draft.setType(null) : e === "nature" ? this.draft.setNature(null) : e === "motif" && this.draft.setMotif(null);
1019
+ },
1020
+ isActive(e) {
1021
+ return this.draft.lignesAssociees.some((t) => t.idMotif === e);
1022
+ },
1023
+ toggleMotifAssocie(e) {
1024
+ let t = this.activeMotifs.find((t) => t.id === e.idMotif);
1025
+ this.draft.toggleLigneAssociee(e.idMotif, {
1026
+ libelle: e.libelle,
1027
+ idCategorie: t?.idCategorie ?? null,
1028
+ idType: t?.idType ?? null,
1029
+ idNature: t?.idNature ?? null
1030
+ });
1031
+ },
1032
+ registerIcons() {
1033
+ return wt([
1034
+ ...this.data.cache.categories ?? [],
1035
+ ...this.data.cache.types ?? [],
1036
+ ...this.data.cache.natures ?? [],
1037
+ ...this.activeMotifs
1038
+ ].map((e) => e.icon));
1039
+ },
1040
+ filterMotifs({ search: e, items: t }) {
1041
+ let n = (B(e) ?? "").trim();
1042
+ if (!n) return t;
1043
+ let r = n.split(/\s+/);
1044
+ return t.filter((e) => {
1045
+ let t = B(`${e.libelle} ${e.categorie} ${e.type} ${e.nature}`) ?? "";
1046
+ return r.every((e) => t.includes(e));
1047
+ });
1048
+ },
1049
+ getMotifId(e) {
1050
+ return e ? e.id : null;
1051
+ },
1052
+ getMotifInputLibelle(e) {
1053
+ return e ? e.libelle : "";
1054
+ },
1055
+ distinct(e, t, n, r) {
1056
+ let i = /* @__PURE__ */ new Map();
1057
+ for (let a of e) a[t] != null && !i.has(a[t]) && i.set(a[t], {
1058
+ id: a[t],
1059
+ libelle: a[n] ?? a[t],
1060
+ icon: r ? r(a[t]) : null
1061
+ });
1062
+ return [...i.values()].sort((e, t) => (e.libelle ?? "").localeCompare(t.libelle ?? ""));
1063
+ },
1064
+ motifLibelleFromId(e) {
1065
+ return this.activeMotifs.find((t) => t.id === e)?.libelle ?? e;
1066
+ }
1067
+ }
1068
+ }, Et = {
1069
+ key: 0,
1070
+ class: "d-flex flex-column gap-3"
1071
+ }, Dt = { key: 2 }, Ot = { class: "d-flex flex-wrap align-items-center gap-2" }, kt = { class: "badge rounded-pill bg-primary d-inline-flex align-items-center gap-2" }, At = { key: 3 }, jt = { class: "d-flex align-items-center gap-2" }, Mt = { class: "min-w-0" }, Nt = { class: "fw-medium text-truncate" }, Pt = { class: "text-muted d-block text-truncate" }, Ft = {
1072
+ key: 4,
1073
+ class: "d-flex align-items-center gap-2 text-muted fs-7"
1074
+ }, It = {
1075
+ key: 5,
1076
+ class: "d-flex flex-wrap align-items-center gap-2"
1077
+ }, Lt = ["onClick"], Rt = { key: 6 }, zt = { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-2" }, Bt = { class: "row justify-content-around g-3" }, Vt = ["title", "onClick"], Ht = { class: "fs-7 mt-1 lh-sm" }, Ut = {
1078
+ key: 0,
1079
+ class: "col-12 text-muted fs-7"
1080
+ }, Wt = [
1081
+ "id",
1082
+ "checked",
1083
+ "disabled",
1084
+ "onChange"
1085
+ ], Gt = ["for"];
1086
+ function Kt(e, t, r, c, d, f) {
1087
+ let p = S("reclamant-selecteur-block"), m = S("provenance-selecteur-block"), h = S("font-awesome-icon"), _ = S("amsom-autocomplete"), v = S("amsom-overlay");
1088
+ return g(), i(v, { loading: c.data.isLoading && !c.data.cache.motifs || !d.iconsReady }, {
1089
+ default: D(() => [d.iconsReady ? (g(), o("div", Et, [
1090
+ c.options.reclamantMode === "step" ? a("", !0) : (g(), i(p, { key: 0 })),
1091
+ r.premiere ? (g(), i(m, { key: 1 })) : a("", !0),
1092
+ f.motifFige && f.selectionChain.length ? (g(), o("div", Dt, [t[1] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Motif", -1), s("div", Ot, [(g(!0), o(n, null, b(f.selectionChain, (e, t) => (g(), o(n, { key: e.level }, [t > 0 ? (g(), i(h, {
1093
+ key: 0,
1094
+ icon: "fa-solid fa-chevron-right",
1095
+ class: "text-muted fs-7"
1096
+ })) : a("", !0), s("span", kt, [e.icon ? (g(), i(h, {
1097
+ key: 0,
1098
+ icon: e.icon,
1099
+ "fixed-width": ""
1100
+ }, null, 8, ["icon"])) : a("", !0), l(" " + C(e.libelle), 1)])], 64))), 128))])])) : a("", !0),
1101
+ f.motifFige ? a("", !0) : (g(), o("div", At, [t[2] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, " Rechercher un motif ", -1), u(_, {
1102
+ modelValue: f.motifRecherche,
1103
+ "onUpdate:modelValue": t[0] ||= (e) => f.motifRecherche = e,
1104
+ items: f.allowedMotifs,
1105
+ "get-id": f.getMotifId,
1106
+ "get-input-libelle": f.getMotifInputLibelle,
1107
+ "get-input-libelle-from-id": f.motifLibelleFromId,
1108
+ "filtering-function": f.filterMotifs,
1109
+ placeholder: "Rechercher (motif, catégorie, type, nature)…",
1110
+ "input-size": "sm",
1111
+ "hide-choices": ""
1112
+ }, {
1113
+ options: D((e) => [s("div", jt, [e?.icon ? (g(), i(h, {
1114
+ key: 0,
1115
+ icon: e.icon,
1116
+ class: "text-primary",
1117
+ "fixed-width": ""
1118
+ }, null, 8, ["icon"])) : a("", !0), s("div", Mt, [s("div", Nt, C(e?.libelle), 1), s("small", Pt, C(e?.categorie) + " › " + C(e?.type) + " › " + C(e?.nature), 1)])])]),
1119
+ _: 1
1120
+ }, 8, [
1121
+ "modelValue",
1122
+ "items",
1123
+ "get-id",
1124
+ "get-input-libelle",
1125
+ "get-input-libelle-from-id",
1126
+ "filtering-function"
1127
+ ])])),
1128
+ f.motifFige ? a("", !0) : (g(), o("div", Ft, [...t[3] ||= [
1129
+ s("hr", { class: "flex-grow-1 my-0" }, null, -1),
1130
+ s("span", null, "ou sélection guidée", -1),
1131
+ s("hr", { class: "flex-grow-1 my-0" }, null, -1)
1132
+ ]])),
1133
+ !f.motifFige && f.selectionChain.length ? (g(), o("div", It, [(g(!0), o(n, null, b(f.selectionChain, (e, t) => (g(), o(n, { key: e.level }, [t > 0 ? (g(), i(h, {
1134
+ key: 0,
1135
+ icon: "fa-solid fa-chevron-right",
1136
+ class: "text-muted fs-7"
1137
+ })) : a("", !0), s("button", {
1138
+ type: "button",
1139
+ class: "btn btn-sm btn-primary rounded-pill d-inline-flex align-items-center gap-2",
1140
+ onClick: (t) => f.goBackTo(e.level)
1141
+ }, [
1142
+ e.icon ? (g(), i(h, {
1143
+ key: 0,
1144
+ icon: e.icon,
1145
+ "fixed-width": ""
1146
+ }, null, 8, ["icon"])) : a("", !0),
1147
+ s("span", null, C(e.libelle), 1),
1148
+ u(h, {
1149
+ icon: "fa-solid fa-xmark",
1150
+ class: "fs-7 opacity-75"
1151
+ })
1152
+ ], 8, Lt)], 64))), 128))])) : a("", !0),
1153
+ !f.motifFige && f.currentLevel ? (g(), o("div", Rt, [s("label", zt, C(f.currentLevel.title), 1), s("div", Bt, [(g(!0), o(n, null, b(f.currentLevel.options, (e) => (g(), o("div", {
1154
+ key: e.id,
1155
+ class: "col-3 text-center"
1156
+ }, [s("button", {
1157
+ type: "button",
1158
+ class: "btn btn-lg btn-outline-primary btn-circle d-flex align-items-center justify-content-center mx-auto",
1159
+ title: e.libelle,
1160
+ onClick: (t) => f.currentLevel.select(e.id)
1161
+ }, [e.icon ? (g(), i(h, {
1162
+ key: 0,
1163
+ icon: e.icon,
1164
+ size: "lg"
1165
+ }, null, 8, ["icon"])) : a("", !0)], 8, Vt), s("div", Ht, C(e.libelle), 1)]))), 128)), f.currentLevel.options.length ? a("", !0) : (g(), o("div", Ut, " Aucun choix disponible "))])])) : a("", !0),
1166
+ f.motifsAssocies.length ? (g(), o(n, { key: 7 }, [t[4] ||= s("div", { class: "d-flex align-items-center gap-2 text-muted fs-7" }, [
1167
+ s("hr", { class: "flex-grow-1 my-0" }),
1168
+ s("span", null, "Autres motifs liés"),
1169
+ s("hr", { class: "flex-grow-1 my-0" })
1170
+ ], -1), (g(!0), o(n, null, b(f.motifsAssocies, (e) => (g(), o("div", {
1171
+ key: e.idMotif,
1172
+ class: "form-check form-switch"
1173
+ }, [s("input", {
1174
+ id: `assoc-${e.idMotif}`,
1175
+ class: "form-check-input",
1176
+ type: "checkbox",
1177
+ checked: f.isActive(e.idMotif),
1178
+ disabled: f.motifFige,
1179
+ onChange: (t) => f.toggleMotifAssocie(e)
1180
+ }, null, 40, Wt), s("label", {
1181
+ class: "form-check-label fs-7",
1182
+ for: `assoc-${e.idMotif}`
1183
+ }, C(e.libelle) + " ? ", 9, Gt)]))), 128))], 64)) : a("", !0)
1184
+ ])) : a("", !0)]),
1185
+ _: 1
1186
+ }, 8, ["loading"]);
1187
+ }
1188
+ var qt = /*#__PURE__*/ L(Tt, [["render", Kt]]), Jt = {
1189
+ B: "briefcase",
1190
+ M: "store",
1191
+ W: "dungeon",
1192
+ E: "user-graduate",
1193
+ K: "building-shield",
1194
+ F: "person-shelter",
1195
+ S: "square-parking",
1196
+ V: "hands-holding"
1197
+ };
1198
+ function Yt(e, t = !1, n = "circle-question") {
1199
+ return e === "L" ? t ? "building" : "house" : Jt[e] ?? n;
1200
+ }
1201
+ function Xt(e) {
1202
+ return e ? e.idCategorieModule === "L" ? e.estCollectif ? "Appartement" : "Maison" : e.categorieModule ?? "" : "";
1203
+ }
1204
+ //#endregion
1205
+ //#region src/components/CiblePickerBlock.vue
1206
+ var Zt = 0, Qt = {
1207
+ name: "CiblePickerBlock",
1208
+ components: { AmsomAutocomplete: k },
1209
+ props: {
1210
+ patrimoine: {
1211
+ type: Object,
1212
+ required: !0
1213
+ },
1214
+ cibleMode: {
1215
+ type: String,
1216
+ default: "contrat"
1217
+ },
1218
+ reclamantModules: {
1219
+ type: Array,
1220
+ default: () => []
1221
+ },
1222
+ reclamantType: {
1223
+ type: String,
1224
+ default: null
1225
+ },
1226
+ contratReclamant: {
1227
+ type: Boolean,
1228
+ default: !0
1229
+ },
1230
+ contratCible: {
1231
+ type: Object,
1232
+ default: null
1233
+ },
1234
+ afficheCaseContratReclamant: {
1235
+ type: Boolean,
1236
+ default: !1
1237
+ },
1238
+ locataireActuelOption: {
1239
+ type: Object,
1240
+ default: null
1241
+ }
1242
+ },
1243
+ emits: [
1244
+ "change-mode",
1245
+ "select-commune",
1246
+ "select-adresse",
1247
+ "select-etage",
1248
+ "select-module",
1249
+ "select-contrat",
1250
+ "toggle-contrat-reclamant",
1251
+ "toggle-reprendre-locataire-actuel"
1252
+ ],
1253
+ setup() {
1254
+ return { data: X() };
1255
+ },
1256
+ data() {
1257
+ return {
1258
+ uid: ++Zt,
1259
+ rechercheContrat: "",
1260
+ contratsTrouves: [],
1261
+ rechercheEnCours: !1,
1262
+ rechercheFaite: !1
1263
+ };
1264
+ },
1265
+ computed: {
1266
+ availableModes() {
1267
+ return this.reclamantType === "D" ? [{
1268
+ key: "demande",
1269
+ label: "La demande",
1270
+ icon: "hourglass",
1271
+ aide: "Cible la demande elle-même (sans localisation)."
1272
+ }] : [{
1273
+ key: "contrat",
1274
+ label: "Le contrat",
1275
+ icon: "file-signature",
1276
+ aide: "Cible un contrat et l’un de ses modules."
1277
+ }, {
1278
+ key: "patrimoine",
1279
+ label: "Le patrimoine",
1280
+ icon: "building",
1281
+ aide: "Une adresse seule pour une partie commune, un module pour un logement précis."
1282
+ }];
1283
+ },
1284
+ currentMode() {
1285
+ return this.availableModes.find((e) => e.key === this.cibleMode);
1286
+ },
1287
+ contratModules() {
1288
+ return this.contratReclamant ? this.reclamantModules : this.contratCible ? this.data.modulesOfContrat(this.contratCible) ?? [] : [];
1289
+ },
1290
+ areModulesLocked() {
1291
+ return this.cibleMode === "contrat" ? this.contratModules.length <= 1 : !this.patrimoine.idEntree;
1292
+ },
1293
+ adresses() {
1294
+ let e = this.patrimoine.idCommune;
1295
+ return e == null ? [] : this.data.adressesOfCommune(e) ?? [];
1296
+ },
1297
+ programmeModules() {
1298
+ let e = this.patrimoine.codeProgramme;
1299
+ return e == null ? [] : this.data.modulesOfProgramme(e) ?? [];
1300
+ },
1301
+ adresseModules() {
1302
+ let e = this.patrimoine.idEntree;
1303
+ return e == null ? [] : this.programmeModules.filter((t) => t.idEntree === e);
1304
+ },
1305
+ autresModules() {
1306
+ let e = this.patrimoine.idEntree, t = Object.fromEntries(this.data.allAdresses().map((e) => [e.idEntree, e]));
1307
+ return this.programmeModules.map((n) => {
1308
+ let r = t[n.idEntree]?.entree ?? `Adresse ${n.idEntree}`;
1309
+ return {
1310
+ ...n,
1311
+ _autreLibelle: n.idEntree === e && n.etage != null ? `${r} — Étage ${n.etage}` : r
1312
+ };
1313
+ });
1314
+ },
1315
+ modules() {
1316
+ if (this.cibleMode === "contrat") return this.contratModules.slice().sort((e, t) => e.estModulePrincipal && !t.estModulePrincipal ? -1 : !e.estModulePrincipal && t.estModulePrincipal ? 1 : t.dateDebut - e.dateDebut);
1317
+ let e = this.patrimoine.etage, t = e == null ? this.adresseModules : this.adresseModules.filter((t) => String(t.etage) === String(e)), n = new Set(t.map((e) => e.idModule));
1318
+ return [...t, ...this.autresModules.filter((e) => !n.has(e.idModule))];
1319
+ },
1320
+ etages() {
1321
+ return [...new Set(this.adresseModules.map((e) => e.etage).filter((e) => e != null))].sort((e, t) => String(e).localeCompare(String(t), "fr", { numeric: !0 })).map((e) => ({
1322
+ id: e,
1323
+ libelle: `Étage ${e}`
1324
+ }));
1325
+ },
1326
+ selectedContrat: {
1327
+ get() {
1328
+ let e = this.contratCible;
1329
+ return e ? this.contratsTrouves.find((t) => String(t.idContrat) === String(e.idContrat) && t.typeContrat === e.typeContrat) ?? {
1330
+ ...e,
1331
+ libelle: e.libelle
1332
+ } : null;
1333
+ },
1334
+ set(e) {
1335
+ this.$emit("select-contrat", e ?? null);
1336
+ }
1337
+ },
1338
+ selectedCommune: {
1339
+ get() {
1340
+ let e = this.patrimoine.idCommune;
1341
+ return e == null ? null : (this.data.cache.communes || []).find((t) => t.idCommune === e) ?? null;
1342
+ },
1343
+ set(e) {
1344
+ this.$emit("select-commune", e ?? null);
1345
+ }
1346
+ },
1347
+ selectedAdresse: {
1348
+ get() {
1349
+ let e = this.patrimoine.idEntree;
1350
+ return e == null ? null : this.adresses.find((t) => t.idEntree === e) ?? null;
1351
+ },
1352
+ set(e) {
1353
+ this.$emit("select-adresse", e ?? null);
1354
+ }
1355
+ },
1356
+ selectedEtage: {
1357
+ get() {
1358
+ let e = this.patrimoine.etage;
1359
+ return e == null ? null : this.etages.find((t) => t.id === e) ?? null;
1360
+ },
1361
+ set(e) {
1362
+ this.$emit("select-etage", e?.id ?? null);
1363
+ }
1364
+ },
1365
+ selectedModule: {
1366
+ get() {
1367
+ let e = this.patrimoine.idModule;
1368
+ return e == null ? null : this.modules.find((t) => t.idModule === e) ?? null;
1369
+ },
1370
+ set(e) {
1371
+ this.$emit("select-module", e ?? null);
1372
+ }
1373
+ }
1374
+ },
1375
+ watch: {
1376
+ modules: {
1377
+ immediate: !0,
1378
+ handler(e) {
1379
+ this.cibleMode === "contrat" && e.length === 1 && this.patrimoine.idModule == null && this.$emit("select-module", e[0]);
1380
+ }
1381
+ },
1382
+ contratReclamant() {
1383
+ this.contratsTrouves = [], this.rechercheFaite = !1;
1384
+ }
1385
+ },
1386
+ beforeUnmount() {
1387
+ clearTimeout(this.rechercheTimeout), this.controller?.abort();
1388
+ },
1389
+ methods: {
1390
+ rechercherPlusTard(e) {
1391
+ clearTimeout(this.rechercheTimeout), this.rechercheTimeout = setTimeout(() => this.rechercherContrat(e), 400);
1392
+ },
1393
+ rechercherContrat(e) {
1394
+ let t = (e ?? "").trim();
1395
+ if (t.length < 2) {
1396
+ this.contratsTrouves = [], this.rechercheEnCours = !1;
1397
+ return;
1398
+ }
1399
+ this.controller?.abort(), this.controller = new AbortController(), this.rechercheEnCours = !0, this.data.searchContrats(t, { signal: this.controller.signal }).then((e) => {
1400
+ this.contratsTrouves = e ?? [], this.rechercheEnCours = !1;
1401
+ }).catch(() => {
1402
+ this.rechercheEnCours = !1;
1403
+ });
1404
+ },
1405
+ contratInputLibelle(e) {
1406
+ return e ? [e.libelle, `${e.typeContrat}/${e.idContrat}`].filter(Boolean).join(" — ") : "";
1407
+ },
1408
+ filterOn(e) {
1409
+ return ({ search: t, items: n }) => {
1410
+ let r = (B(t) ?? "").trim();
1411
+ return r ? n.filter((t) => (B(t?.[e]) ?? "").includes(r)) : n;
1412
+ };
1413
+ },
1414
+ filterModules({ search: e, items: t }) {
1415
+ let n = (B(e) ?? "").trim();
1416
+ return n ? t.filter((e) => (B(this.moduleInputLibelle(e)) ?? "").includes(n) || (B(e?._autreLibelle) ?? "").includes(n)) : t;
1417
+ },
1418
+ getCategorieModuleIcon: Yt,
1419
+ categorieLibelle: Xt,
1420
+ moduleLibelle(e) {
1421
+ return e ? e.libelleModule ?? e.adresse ?? `Module ${e.idModule}` : "";
1422
+ },
1423
+ moduleInputLibelle(e) {
1424
+ let t = this.categorieLibelle(e);
1425
+ return t ? `${t} — ${this.moduleLibelle(e)}` : this.moduleLibelle(e);
1426
+ },
1427
+ isExit(e) {
1428
+ return !!e?.dateFin && e.dateFin < Math.floor(Date.now() / 1e3);
1429
+ }
1430
+ }
1431
+ }, $t = { class: "d-flex flex-column gap-3" }, en = {
1432
+ class: "btn-group w-100",
1433
+ role: "group"
1434
+ }, tn = ["onClick"], nn = { class: "text-muted d-block mt-1" }, rn = {
1435
+ key: 0,
1436
+ class: "form-check"
1437
+ }, an = ["id", "checked"], on = ["for"], sn = { key: 1 }, cn = { class: "min-w-0" }, ln = { class: "fw-medium text-truncate text-capitalize" }, un = { class: "text-muted d-block text-truncate" }, dn = { key: 0 }, fn = {
1438
+ key: 1,
1439
+ class: "text-warning"
1440
+ }, pn = { class: "min-w-0" }, mn = { class: "fw-medium text-truncate" }, hn = { class: "text-muted d-block text-truncate" }, gn = {
1441
+ key: 2,
1442
+ class: "row g-2"
1443
+ }, _n = { class: "col-12 col-md-5" }, vn = ["value"], yn = { class: "col-12 col-md-5" }, bn = ["value"], xn = { class: "col-12 col-md-2" }, Sn = ["value"], Cn = { key: 3 }, wn = { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, Tn = {
1444
+ key: 0,
1445
+ class: "text-lowercase fw-normal"
1446
+ }, En = { class: "d-flex flex-wrap align-items-center gap-1" }, Dn = ["title"], On = { class: "text-muted" }, kn = {
1447
+ key: 1,
1448
+ class: "d-block text-truncate"
1449
+ }, An = {
1450
+ key: 2,
1451
+ class: "text-muted d-block"
1452
+ }, jn = {
1453
+ key: 0,
1454
+ class: "text-muted d-block"
1455
+ }, Mn = {
1456
+ key: 1,
1457
+ class: "mt-2 d-flex flex-column gap-2"
1458
+ }, Nn = { class: "form-check mb-0 ms-3" }, Pn = ["id", "checked"], Fn = ["for"];
1459
+ function In(e, t, r, c, d, f) {
1460
+ let p = S("font-awesome-icon"), h = S("amsom-autocomplete");
1461
+ return g(), o("div", $t, [
1462
+ s("div", null, [
1463
+ t[7] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, " La sollicitation concerne… ", -1),
1464
+ s("div", en, [(g(!0), o(n, null, b(f.availableModes, (t) => (g(), o("button", {
1465
+ key: t.key,
1466
+ type: "button",
1467
+ class: m(["btn btn-sm", r.cibleMode === t.key ? "btn-primary" : "btn-outline-primary"]),
1468
+ onClick: (n) => e.$emit("change-mode", t.key)
1469
+ }, [u(p, {
1470
+ icon: t.icon,
1471
+ class: "me-1"
1472
+ }, null, 8, ["icon"]), l(" " + C(t.label), 1)], 10, tn))), 128))]),
1473
+ s("small", nn, C(f.currentMode?.aide), 1)
1474
+ ]),
1475
+ r.cibleMode === "contrat" ? (g(), o(n, { key: 0 }, [r.afficheCaseContratReclamant ? (g(), o("div", rn, [s("input", {
1476
+ id: `contrat-reclamant-${d.uid}`,
1477
+ class: "form-check-input",
1478
+ type: "checkbox",
1479
+ checked: r.contratReclamant,
1480
+ onChange: t[0] ||= (t) => e.$emit("toggle-contrat-reclamant", t.target.checked)
1481
+ }, null, 40, an), s("label", {
1482
+ class: "form-check-label fs-7",
1483
+ for: `contrat-reclamant-${d.uid}`
1484
+ }, " Contrat du réclamant ", 8, on)])) : a("", !0), r.contratReclamant ? a("", !0) : (g(), o("div", sn, [t[8] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, " Contrat ciblé ", -1), u(h, {
1485
+ modelValue: f.selectedContrat,
1486
+ "onUpdate:modelValue": t[1] ||= (e) => f.selectedContrat = e,
1487
+ items: d.contratsTrouves,
1488
+ "filtering-function": ({ items: e }) => e,
1489
+ loading: d.rechercheEnCours,
1490
+ "get-id": (e) => e ? `${e.typeContrat}|${e.idContrat}` : null,
1491
+ "get-input-libelle": f.contratInputLibelle,
1492
+ placeholder: "Numéro de contrat ou nom du locataire…",
1493
+ "input-size": "sm",
1494
+ "hide-choices": "",
1495
+ "debounce-delay": 0,
1496
+ onSearch: f.rechercherPlusTard
1497
+ }, {
1498
+ options: D((e) => [s("div", cn, [s("div", ln, C(e?.libelle ?? `Contrat ${e?.idContrat}`), 1), s("small", un, [
1499
+ l(C(e?.typeContrat) + "/" + C(e?.idContrat) + " ", 1),
1500
+ e?.nbModules > 1 ? (g(), o("span", dn, " — " + C(e.nbModules) + " modules", 1)) : a("", !0),
1501
+ e?.dateSortie ? (g(), o("span", fn, " — sorti")) : a("", !0)
1502
+ ])])]),
1503
+ _: 1
1504
+ }, 8, [
1505
+ "modelValue",
1506
+ "items",
1507
+ "filtering-function",
1508
+ "loading",
1509
+ "get-id",
1510
+ "get-input-libelle",
1511
+ "onSearch"
1512
+ ])]))], 64)) : a("", !0),
1513
+ r.cibleMode === "patrimoine" ? (g(), o(n, { key: 1 }, [
1514
+ s("div", null, [t[9] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Commune", -1), u(h, {
1515
+ modelValue: f.selectedCommune,
1516
+ "onUpdate:modelValue": t[2] ||= (e) => f.selectedCommune = e,
1517
+ items: c.data.cache.communes || [],
1518
+ "get-id": (e) => e?.idCommune,
1519
+ "get-input-libelle": (e) => e?.commune ?? "",
1520
+ "filtering-function": f.filterOn("commune"),
1521
+ placeholder: "Rechercher une commune…",
1522
+ "input-size": "sm",
1523
+ "hide-choices": ""
1524
+ }, null, 8, [
1525
+ "modelValue",
1526
+ "items",
1527
+ "get-id",
1528
+ "get-input-libelle",
1529
+ "filtering-function"
1530
+ ])]),
1531
+ s("div", null, [t[10] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Adresse", -1), u(h, {
1532
+ modelValue: f.selectedAdresse,
1533
+ "onUpdate:modelValue": t[3] ||= (e) => f.selectedAdresse = e,
1534
+ items: f.adresses,
1535
+ "get-id": (e) => e?.idEntree,
1536
+ "get-input-libelle": (e) => e?.entree ?? "",
1537
+ "filtering-function": f.filterOn("entree"),
1538
+ disabled: !r.patrimoine.idCommune,
1539
+ placeholder: "Rechercher une adresse…",
1540
+ "input-size": "sm",
1541
+ "hide-choices": ""
1542
+ }, {
1543
+ options: D((e) => [s("div", pn, [s("div", mn, C(e?.entree), 1), s("small", hn, C(e?.commune) + " — Programme " + C(e?.codeProgramme), 1)])]),
1544
+ _: 1
1545
+ }, 8, [
1546
+ "modelValue",
1547
+ "items",
1548
+ "get-id",
1549
+ "get-input-libelle",
1550
+ "filtering-function",
1551
+ "disabled"
1552
+ ])]),
1553
+ s("div", null, [t[11] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Étage", -1), u(h, {
1554
+ modelValue: f.selectedEtage,
1555
+ "onUpdate:modelValue": t[4] ||= (e) => f.selectedEtage = e,
1556
+ items: f.etages,
1557
+ "get-id": (e) => e?.id,
1558
+ "get-input-libelle": (e) => e?.libelle ?? "",
1559
+ disabled: !r.patrimoine.idEntree,
1560
+ placeholder: "Tous les étages…",
1561
+ "input-size": "sm",
1562
+ "hide-choices": ""
1563
+ }, null, 8, [
1564
+ "modelValue",
1565
+ "items",
1566
+ "get-id",
1567
+ "get-input-libelle",
1568
+ "disabled"
1569
+ ])])
1570
+ ], 64)) : a("", !0),
1571
+ r.cibleMode === "contrat" ? (g(), o("div", gn, [
1572
+ s("div", _n, [t[12] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Commune", -1), s("input", {
1573
+ class: "form-control form-control-sm",
1574
+ disabled: "",
1575
+ value: r.patrimoine.commune ?? "—"
1576
+ }, null, 8, vn)]),
1577
+ s("div", yn, [t[13] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Adresse", -1), s("input", {
1578
+ class: "form-control form-control-sm",
1579
+ disabled: "",
1580
+ value: r.patrimoine.entree ?? "—"
1581
+ }, null, 8, bn)]),
1582
+ s("div", xn, [t[14] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Étage", -1), s("input", {
1583
+ class: "form-control form-control-sm",
1584
+ disabled: "",
1585
+ value: r.patrimoine.etage ?? "—"
1586
+ }, null, 8, Sn)])
1587
+ ])) : a("", !0),
1588
+ r.cibleMode === "contrat" || r.cibleMode === "patrimoine" ? (g(), o("div", Cn, [
1589
+ s("label", wn, [t[15] ||= l(" Module ", -1), r.cibleMode === "patrimoine" ? (g(), o("span", Tn, "(facultatif)")) : a("", !0)]),
1590
+ u(h, {
1591
+ modelValue: f.selectedModule,
1592
+ "onUpdate:modelValue": t[5] ||= (e) => f.selectedModule = e,
1593
+ items: f.modules,
1594
+ "get-id": (e) => e?.idModule,
1595
+ "get-input-libelle": (e) => f.moduleInputLibelle(e),
1596
+ "filtering-function": f.filterModules,
1597
+ disabled: f.areModulesLocked,
1598
+ placeholder: "Rechercher un module…",
1599
+ "input-size": "sm",
1600
+ "hide-choices": ""
1601
+ }, {
1602
+ options: D((e) => [s("div", { class: m(["min-w-0 w-100 rounded position-relative", e?._autreLibelle ? "bg-yellow-subtle p-2" : ""]) }, [
1603
+ e?._autreLibelle ? (g(), i(p, {
1604
+ key: 0,
1605
+ icon: "building",
1606
+ class: "position-absolute top-0 end-0 m-1 text-muted",
1607
+ title: "Autre adresse ou étage du même programme"
1608
+ })) : a("", !0),
1609
+ s("div", { class: m(["fw-medium text-truncate", [e?._autreLibelle ? "text-muted" : "", f.isExit(e) ? "text-decoration-line-through" : ""]]) }, C(f.moduleLibelle(e)), 3),
1610
+ s("div", En, [f.categorieLibelle(e) ? (g(), o("span", {
1611
+ key: 0,
1612
+ class: "badge bg-info",
1613
+ title: e?.categorieModule
1614
+ }, [u(p, { icon: f.getCategorieModuleIcon(e?.idCategorieModule, e?.estCollectif) }, null, 8, ["icon"])], 8, Dn)) : a("", !0), s("small", On, "N° " + C(e?.idModule), 1)]),
1615
+ e?._autreLibelle ? (g(), o("small", kn, C(e._autreLibelle), 1)) : e?.etage == null ? a("", !0) : (g(), o("small", An, " Étage " + C(e.etage), 1))
1616
+ ], 2)]),
1617
+ _: 1
1618
+ }, 8, [
1619
+ "modelValue",
1620
+ "items",
1621
+ "get-id",
1622
+ "get-input-libelle",
1623
+ "filtering-function",
1624
+ "disabled"
1625
+ ]),
1626
+ r.cibleMode === "patrimoine" && !r.patrimoine.idModule ? (g(), o("small", jn, " Sans module, la sollicitation cible la partie commune de l’adresse. ")) : a("", !0),
1627
+ r.locataireActuelOption ? (g(), o("div", Mn, [s("div", { class: m(["alert d-flex align-items-start gap-2 py-2 px-3 mt-2 mb-0 fs-7", r.locataireActuelOption.reprendre ? "alert-warning" : "alert-secondary border"]) }, [u(p, {
1628
+ icon: "circle-info",
1629
+ class: "mt-1"
1630
+ }), s("span", null, C(r.locataireActuelOption.hint), 1)], 2), s("div", Nn, [s("input", {
1631
+ id: `locataire-actuel-${d.uid}`,
1632
+ class: "form-check-input",
1633
+ type: "checkbox",
1634
+ checked: r.locataireActuelOption.reprendre,
1635
+ onChange: t[6] ||= (t) => e.$emit("toggle-reprendre-locataire-actuel", t.target.checked)
1636
+ }, null, 40, Pn), s("label", {
1637
+ class: "form-check-label fs-7",
1638
+ for: `locataire-actuel-${d.uid}`
1639
+ }, " Rattacher au locataire actuel du module ", 8, Fn)])])) : a("", !0)
1640
+ ])) : a("", !0)
1641
+ ]);
1642
+ }
1643
+ //#endregion
1644
+ //#region src/components/EtapeCibleBlock.vue
1645
+ var Ln = {
1646
+ name: "EtapeCibleBlock",
1647
+ components: {
1648
+ AmsomOverlay: t,
1649
+ CiblePickerBlock: /* @__PURE__ */ L(Qt, [["render", In]])
1650
+ },
1651
+ setup() {
1652
+ return {
1653
+ draft: I(),
1654
+ data: X(),
1655
+ options: z()
1656
+ };
1657
+ },
1658
+ computed: {
1659
+ lignePrincipale() {
1660
+ return this.draft.lignePrincipale;
1661
+ },
1662
+ lignesAssociees() {
1663
+ return this.draft.lignesAssociees;
1664
+ },
1665
+ reclamantModules() {
1666
+ return this.options.modulesReclamant ?? [];
1667
+ },
1668
+ mainModule() {
1669
+ return this.draft.moduleReclamantPrincipal;
1670
+ },
1671
+ cibleFigee() {
1672
+ return this.draft.isReadonly("cible");
1673
+ },
1674
+ reclamantType() {
1675
+ return this.draft.draft.reclamant.type;
1676
+ },
1677
+ motifLibelle() {
1678
+ let e = this.lignePrincipale.idMotif;
1679
+ return e == null ? null : this.data.motifLibelle(e);
1680
+ }
1681
+ },
1682
+ async created() {
1683
+ if (this.reclamantType === "D" || this.cibleFigee) return;
1684
+ await this.data.loadCommunes(), !this.draft.reclamantEstContrat && this.lignePrincipale.cibleMode === "contrat" && this.draft.setCibleMode(0, "patrimoine");
1685
+ let e = this.lignePrincipale.patrimoine;
1686
+ await this.data.loadAdresses(e?.idCommune ?? null), this.lignePrincipale.cibleMode !== "contrat" && await this.data.loadModulesOfProgramme(e?.codeProgramme ?? null);
1687
+ },
1688
+ methods: {
1689
+ pickerProps(e) {
1690
+ return {
1691
+ patrimoine: e.patrimoine,
1692
+ cibleMode: e.cibleMode,
1693
+ reclamantModules: this.reclamantModules,
1694
+ reclamantType: this.reclamantType,
1695
+ contratReclamant: e.contratReclamant,
1696
+ contratCible: e.contratCible,
1697
+ afficheCaseContratReclamant: this.draft.reclamantEstContrat,
1698
+ locataireActuelOption: this.locataireActuelOption(e)
1699
+ };
1700
+ },
1701
+ onChangeMode(e, t = 0) {
1702
+ this.draft.setCibleMode(t, e), this.applyMode(e, t);
1703
+ },
1704
+ onSelectCommune(e, t = 0) {
1705
+ this.draft.setPatrimoineCommune(t, e ?? null), e?.idCommune != null && this.data.loadAdresses(e.idCommune);
1706
+ },
1707
+ onSelectAdresse(e, t = 0) {
1708
+ this.draft.setPatrimoineEntree(t, e ?? null), e?.codeProgramme != null && this.data.loadModulesOfProgramme(e.codeProgramme);
1709
+ },
1710
+ onSelectEtage(e, t = 0) {
1711
+ this.draft.setPatrimoineEtage(t, e ?? null);
1712
+ },
1713
+ onSelectModule(e, t = 0) {
1714
+ let n = this.draft.draft.lignes[t];
1715
+ e && n?.cibleMode === "contrat" ? this.draft.prefillFromModule(t, e) : this.draft.setPatrimoineModule(t, e ?? null);
1716
+ },
1717
+ onToggleReprendre(e, t = 0) {
1718
+ this.draft.setReprendreLocataireActuel(t, e);
1719
+ },
1720
+ onToggleContratReclamant(e, t = 0) {
1721
+ this.draft.toggleContratReclamant(t, e), e && this.draft.prefillFromModule(t, this.mainModule);
1722
+ },
1723
+ onSelectContrat(e, t = 0) {
1724
+ this.draft.setContratCible(t, e), e && this.data.loadModulesOfContrat({
1725
+ idContrat: e.idContrat,
1726
+ typeContrat: e.typeContrat
1727
+ });
1728
+ },
1729
+ locataireActuelOption(e) {
1730
+ if (e?.cibleMode !== "contrat") return null;
1731
+ let t = e?.patrimoine;
1732
+ if (!t || t.idModule == null) return null;
1733
+ let n = e.contratReclamant && this.draft.reclamantEstContrat, r = n ? {
1734
+ typeContrat: this.draft.draft.reclamant.type,
1735
+ idContrat: this.draft.draft.reclamant.id
1736
+ } : e.contratCible;
1737
+ if (!r?.idContrat || String(t.idContratActuel) === String(r.idContrat) && String(t.typeContratActuel) === String(r.typeContrat)) return null;
1738
+ let i = !!e.reprendreLocataireActuel, a = n ? "Le réclamant n’occupe plus ce module : " : "Le contrat ciblé n’occupe plus ce module : ";
1739
+ if (!i) a += "la cible restera le contrat ciblé, ancien occupant de ce module.";
1740
+ else if (t.idContratActuel == null) a += "ce module est vacant, la sollicitation ne sera rattachée à aucun contrat.";
1741
+ else {
1742
+ let e = t.occupantActuel ?? "contrat sans libellé", n = (t.typeContratActuel ? `${t.typeContratActuel}/` : "") + t.idContratActuel;
1743
+ a += `la cible sera le locataire actuel du module : ${e} ${n}.`;
1744
+ }
1745
+ return {
1746
+ reprendre: i,
1747
+ hint: a
1748
+ };
1749
+ },
1750
+ async applyMode(e, t = 0) {
1751
+ if (e === "contrat") {
1752
+ this.draft.prefillFromModule(t, this.mainModule);
1753
+ return;
1754
+ }
1755
+ this.mainModule && (this.draft.prefillFromModule(t, this.mainModule), this.mainModule.idCommune != null && await this.data.loadAdresses(this.mainModule.idCommune), this.mainModule.codeProgramme != null && await this.data.loadModulesOfProgramme(this.mainModule.codeProgramme));
1756
+ }
1757
+ }
1758
+ }, Rn = { class: "d-flex flex-column gap-3" }, zn = {
1759
+ key: 0,
1760
+ class: "alert alert-light border py-2 px-3 mb-0 d-flex align-items-center gap-2"
1761
+ }, Bn = { class: "fs-7" }, Vn = {
1762
+ key: 1,
1763
+ class: "d-flex flex-column gap-1"
1764
+ }, Hn = {
1765
+ key: 0,
1766
+ class: "text-muted me-1"
1767
+ }, Un = { class: "d-flex align-items-center gap-2" }, Wn = { class: "fw-medium fs-7" }, Gn = { class: "form-check form-switch mb-0" }, Kn = [
1768
+ "id",
1769
+ "checked",
1770
+ "onChange"
1771
+ ], qn = ["for"], Jn = {
1772
+ key: 0,
1773
+ class: "mt-2"
1774
+ };
1775
+ function Yn(e, t, r, c, d, f) {
1776
+ let m = S("font-awesome-icon"), h = S("cible-picker-block"), _ = S("amsom-overlay");
1777
+ return g(), i(_, { loading: c.data.isLoading }, {
1778
+ default: D(() => [s("div", Rn, [
1779
+ f.motifLibelle ? (g(), o("div", zn, [u(m, {
1780
+ icon: "tag",
1781
+ class: "text-primary"
1782
+ }), s("span", Bn, [t[8] ||= s("span", { class: "text-muted text-uppercase fw-semibold me-1" }, "Motif", -1), l(C(f.motifLibelle), 1)])])) : a("", !0),
1783
+ f.cibleFigee ? (g(), o("div", Vn, [(g(!0), o(n, null, b(c.draft.draft.lignes, (e, t) => (g(), o("span", {
1784
+ key: t,
1785
+ class: "fs-7"
1786
+ }, [
1787
+ u(m, {
1788
+ icon: "location-dot",
1789
+ class: "text-primary me-2"
1790
+ }),
1791
+ f.lignesAssociees.length ? (g(), o("span", Hn, C(t === 0 ? f.motifLibelle : e.libelle) + " : ", 1)) : a("", !0),
1792
+ l(" " + C(c.draft.cibleResume(e)), 1)
1793
+ ]))), 128))])) : (g(), i(h, p({ key: 2 }, f.pickerProps(f.lignePrincipale), {
1794
+ onChangeMode: t[0] ||= (e) => f.onChangeMode(e),
1795
+ onSelectCommune: t[1] ||= (e) => f.onSelectCommune(e),
1796
+ onSelectAdresse: t[2] ||= (e) => f.onSelectAdresse(e),
1797
+ onSelectEtage: t[3] ||= (e) => f.onSelectEtage(e),
1798
+ onSelectModule: t[4] ||= (e) => f.onSelectModule(e),
1799
+ onSelectContrat: t[5] ||= (e) => f.onSelectContrat(e),
1800
+ onToggleContratReclamant: t[6] ||= (e) => f.onToggleContratReclamant(e),
1801
+ onToggleReprendreLocataireActuel: t[7] ||= (e) => f.onToggleReprendre(e)
1802
+ }), null, 16)),
1803
+ !f.cibleFigee && f.lignesAssociees.length && f.reclamantType !== "D" ? (g(), o(n, { key: 3 }, [t[9] ||= s("div", { class: "d-flex align-items-center gap-2 text-muted fs-7" }, [
1804
+ s("hr", { class: "flex-grow-1 my-0" }),
1805
+ s("span", null, "Cible des autres motifs"),
1806
+ s("hr", { class: "flex-grow-1 my-0" })
1807
+ ], -1), (g(!0), o(n, null, b(f.lignesAssociees, (e, t) => (g(), o("div", {
1808
+ key: e.idMotif,
1809
+ class: "border rounded p-2"
1810
+ }, [s("div", Un, [s("span", Wn, C(e.libelle), 1), s("div", Gn, [s("input", {
1811
+ id: `memecible-${e.idMotif}`,
1812
+ class: "form-check-input",
1813
+ type: "checkbox",
1814
+ checked: !e.patrimoine,
1815
+ onChange: (e) => c.draft.toggleCibleOverride(t + 1)
1816
+ }, null, 40, Kn), s("label", {
1817
+ class: "form-check-label fs-7",
1818
+ for: `memecible-${e.idMotif}`
1819
+ }, " Même cible que la ligne principale ", 8, qn)])]), e.patrimoine ? (g(), o("div", Jn, [u(h, p({ ref_for: !0 }, f.pickerProps(e), {
1820
+ onChangeMode: (e) => f.onChangeMode(e, t + 1),
1821
+ onSelectCommune: (e) => f.onSelectCommune(e, t + 1),
1822
+ onSelectAdresse: (e) => f.onSelectAdresse(e, t + 1),
1823
+ onSelectEtage: (e) => f.onSelectEtage(e, t + 1),
1824
+ onSelectModule: (e) => f.onSelectModule(e, t + 1),
1825
+ onSelectContrat: (e) => f.onSelectContrat(e, t + 1),
1826
+ onToggleContratReclamant: (e) => f.onToggleContratReclamant(e, t + 1),
1827
+ onToggleReprendreLocataireActuel: (e) => f.onToggleReprendre(e, t + 1)
1828
+ }), null, 16, [
1829
+ "onChangeMode",
1830
+ "onSelectCommune",
1831
+ "onSelectAdresse",
1832
+ "onSelectEtage",
1833
+ "onSelectModule",
1834
+ "onSelectContrat",
1835
+ "onToggleContratReclamant",
1836
+ "onToggleReprendreLocataireActuel"
1837
+ ])])) : a("", !0)]))), 128))], 64)) : a("", !0)
1838
+ ])]),
1839
+ _: 1
1840
+ }, 8, ["loading"]);
1841
+ }
1842
+ var Xn = /*#__PURE__*/ L(Ln, [["render", Yn]]), Zn = {
1843
+ name: "LigneDocumentBlock",
1844
+ components: { AmsomUploadFile: oe },
1845
+ props: {
1846
+ index: {
1847
+ type: Number,
1848
+ required: !0
1849
+ },
1850
+ fichier: {
1851
+ type: [Object, Array],
1852
+ default: null
1853
+ },
1854
+ readonly: {
1855
+ type: Boolean,
1856
+ default: !1
1857
+ }
1858
+ },
1859
+ emits: ["update"]
1860
+ };
1861
+ function Qn(e, t, n, r, i, a) {
1862
+ let c = S("amsom-upload-file");
1863
+ return g(), o("div", null, [t[1] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, "Document", -1), u(c, {
1864
+ "model-value": n.fichier,
1865
+ renameable: "",
1866
+ "output-format": "object",
1867
+ name: `cresol-creation-ged-${n.index}`,
1868
+ "merge-pdfs": "",
1869
+ "read-only": n.readonly,
1870
+ "onUpdate:modelValue": t[0] ||= (t) => e.$emit("update", t)
1871
+ }, null, 8, [
1872
+ "model-value",
1873
+ "name",
1874
+ "read-only"
1875
+ ])]);
1876
+ }
1877
+ var $n = /*#__PURE__*/ L(Zn, [["render", Qn]]);
1878
+ //#endregion
1879
+ //#region src/utils/date.js
1880
+ function er(e) {
1881
+ return e == null ? "" : (/* @__PURE__ */ new Date(e * 1e3)).toISOString().slice(0, 10);
1882
+ }
1883
+ function tr(e) {
1884
+ return e ? Math.floor(new Date(e).getTime() / 1e3) : null;
1885
+ }
1886
+ //#endregion
1887
+ //#region src/components/LigneDetailBlock.vue
1888
+ var nr = 4e3, rr = {
1889
+ name: "LigneDetailBlock",
1890
+ components: {
1891
+ AmsomAutocomplete: k,
1892
+ AmsomTextarea: ae,
1893
+ LigneDocumentBlock: $n
1894
+ },
1895
+ props: { index: {
1896
+ type: Number,
1897
+ required: !0
1898
+ } },
1899
+ setup() {
1900
+ return {
1901
+ draft: I(),
1902
+ data: X()
1903
+ };
1904
+ },
1905
+ computed: {
1906
+ descriptionMaxLength: () => nr,
1907
+ isPrincipale() {
1908
+ return this.index === 0;
1909
+ },
1910
+ ligne() {
1911
+ return this.draft.draft.lignes[this.index];
1912
+ },
1913
+ lignePrincipale() {
1914
+ return this.draft.lignePrincipale;
1915
+ },
1916
+ collaborateurs() {
1917
+ return (this.data.cache.collaborateurs ?? []).filter((e) => e.actif !== !1);
1918
+ },
1919
+ dateFaits() {
1920
+ return this.isPrincipale || this.ligne.dateFaitsOverride ? this.ligne.dateFaits : this.lignePrincipale.dateFaits;
1921
+ }
1922
+ },
1923
+ methods: {
1924
+ timestampToDateInput: er,
1925
+ dateInputToTimestamp: tr,
1926
+ responsableLibelle(e) {
1927
+ let t = e && typeof e != "object" ? this.collaborateurs.find((t) => String(t.id) === String(e)) : e;
1928
+ return t ? `${t.prenom} ${t.nom}` : "";
1929
+ },
1930
+ filterCollaborateurs({ search: e, items: t }) {
1931
+ let n = (B(e) ?? "").trim();
1932
+ return n ? t.filter((e) => (B(`${e.prenom} ${e.nom} ${e.service}`) ?? "").includes(n)) : t;
1933
+ }
1934
+ }
1935
+ }, ir = { class: "d-flex flex-column gap-2" }, ar = { class: "d-flex align-items-center gap-2 mb-1" }, or = { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-0" }, sr = {
1936
+ key: 0,
1937
+ class: "ms-1 text-danger"
1938
+ }, cr = {
1939
+ key: 0,
1940
+ class: "form-check form-switch mb-0"
1941
+ }, lr = [
1942
+ "id",
1943
+ "checked",
1944
+ "disabled"
1945
+ ], ur = ["for"], dr = {
1946
+ key: 1,
1947
+ class: "text-muted d-block",
1948
+ style: { "white-space": "pre-line" }
1949
+ }, fr = { class: "row g-3" }, pr = { class: "col-6" }, mr = { class: "d-flex align-items-center gap-2 mb-1" }, hr = {
1950
+ key: 0,
1951
+ class: "form-check form-switch mb-0"
1952
+ }, gr = [
1953
+ "id",
1954
+ "checked",
1955
+ "disabled"
1956
+ ], _r = ["for"], vr = ["value"], yr = {
1957
+ key: 1,
1958
+ class: "text-muted d-block"
1959
+ }, br = {
1960
+ key: 0,
1961
+ class: "text-muted d-block"
1962
+ }, xr = { class: "min-w-0" }, Sr = { class: "fw-medium text-truncate" }, Cr = {
1963
+ key: 0,
1964
+ class: "text-muted d-block"
1965
+ }, wr = {
1966
+ key: 2,
1967
+ class: "text-muted"
1968
+ }, Tr = { class: "col-12 col-md-6" };
1969
+ function Er(e, t, n, r, c, d) {
1970
+ let f = S("amsom-textarea"), p = S("amsom-autocomplete"), m = S("ligne-document-block");
1971
+ return g(), o("div", ir, [s("div", null, [s("div", ar, [s("label", or, [t[6] ||= l(" Description", -1), d.isPrincipale ? (g(), o("span", sr, "*")) : a("", !0)]), d.isPrincipale ? a("", !0) : (g(), o("div", cr, [s("input", {
1972
+ id: `memedetail-${d.ligne.idMotif}`,
1973
+ class: "form-check-input",
1974
+ type: "checkbox",
1975
+ checked: d.ligne.description == null,
1976
+ disabled: r.draft.isReadonly("description"),
1977
+ onChange: t[0] ||= (e) => r.draft.toggleDescriptionOverride(n.index)
1978
+ }, null, 40, lr), s("label", {
1979
+ class: "form-check-label fs-7",
1980
+ for: `memedetail-${d.ligne.idMotif}`
1981
+ }, " Même description ", 8, ur)]))]), !r.draft.isReadonly("description") && (d.isPrincipale || d.ligne.description != null) ? (g(), i(f, {
1982
+ key: 0,
1983
+ "model-value": d.ligne.description,
1984
+ "input-size": "sm",
1985
+ rows: d.isPrincipale ? 4 : 3,
1986
+ maxlength: d.descriptionMaxLength,
1987
+ placeholder: d.isPrincipale ? "Décrivez la sollicitation…" : "Décrivez ce motif…",
1988
+ "onUpdate:modelValue": t[1] ||= (e) => r.draft.setDescription(n.index, e)
1989
+ }, null, 8, [
1990
+ "model-value",
1991
+ "rows",
1992
+ "maxlength",
1993
+ "placeholder"
1994
+ ])) : (g(), o("small", dr, C((d.ligne.description ?? d.lignePrincipale.description) || "—"), 1))]), s("div", fr, [s("div", pr, [s("div", null, [s("div", mr, [t[7] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-0" }, " Date des faits ", -1), d.isPrincipale ? a("", !0) : (g(), o("div", hr, [s("input", {
1995
+ id: `memedate-${d.ligne.idMotif}`,
1996
+ class: "form-check-input",
1997
+ type: "checkbox",
1998
+ checked: !d.ligne.dateFaitsOverride,
1999
+ disabled: r.draft.isReadonly("dateFaits"),
2000
+ onChange: t[2] ||= (e) => r.draft.toggleDateFaitsOverride(n.index)
2001
+ }, null, 40, gr), s("label", {
2002
+ class: "form-check-label fs-7",
2003
+ for: `memedate-${d.ligne.idMotif}`
2004
+ }, " Même date ", 8, _r)]))]), !r.draft.isReadonly("dateFaits") && (d.isPrincipale || d.ligne.dateFaitsOverride) ? (g(), o("input", {
2005
+ key: 0,
2006
+ value: d.timestampToDateInput(d.ligne.dateFaits),
2007
+ type: "date",
2008
+ class: "form-control form-control-sm",
2009
+ onInput: t[3] ||= (e) => r.draft.setDateFaits(n.index, d.dateInputToTimestamp(e.target.value))
2010
+ }, null, 40, vr)) : (g(), o("small", yr, C(d.timestampToDateInput(d.dateFaits) || "—"), 1))]), s("div", null, [
2011
+ t[8] ||= s("label", { class: "form-label fs-7 fw-semibold text-muted text-uppercase mb-1" }, " Responsable ", -1),
2012
+ r.draft.isReadonly("responsable") ? (g(), o("small", br, C(d.responsableLibelle(d.ligne.responsable) || "Déterminé automatiquement"), 1)) : (g(), i(p, {
2013
+ key: 1,
2014
+ "model-value": d.ligne.responsable,
2015
+ items: d.collaborateurs,
2016
+ "get-id": (e) => e?.id,
2017
+ "get-input-libelle": d.responsableLibelle,
2018
+ "filtering-function": d.filterCollaborateurs,
2019
+ placeholder: "Rechercher un responsable…",
2020
+ "input-size": "sm",
2021
+ "hide-choices": "",
2022
+ "onUpdate:modelValue": t[4] ||= (e) => r.draft.setResponsable(n.index, e ?? null)
2023
+ }, {
2024
+ options: D((e) => [s("div", xr, [s("div", Sr, C(e?.prenom) + " " + C(e?.nom), 1), e?.service ? (g(), o("small", Cr, C(e.service), 1)) : a("", !0)])]),
2025
+ _: 1
2026
+ }, 8, [
2027
+ "model-value",
2028
+ "items",
2029
+ "get-id",
2030
+ "get-input-libelle",
2031
+ "filtering-function"
2032
+ ])),
2033
+ d.isPrincipale && !d.ligne.responsable && !r.draft.isReadonly("responsable") ? (g(), o("small", wr, " Aucun paramétrage trouvé : le responsable sera déterminé automatiquement. ")) : a("", !0)
2034
+ ])]), s("div", Tr, [u(m, {
2035
+ index: n.index,
2036
+ fichier: d.ligne.fichier,
2037
+ readonly: r.draft.isReadonly("fichier"),
2038
+ onUpdate: t[5] ||= (e) => r.draft.setFichier(n.index, e)
2039
+ }, null, 8, [
2040
+ "index",
2041
+ "fichier",
2042
+ "readonly"
2043
+ ])])])]);
2044
+ }
2045
+ //#endregion
2046
+ //#region src/components/EtapeDetailsBlock.vue
2047
+ var Dr = {
2048
+ name: "EtapeDetailsBlock",
2049
+ components: {
2050
+ AmsomOverlay: t,
2051
+ LigneDetailBlock: /* @__PURE__ */ L(rr, [["render", Er]])
2052
+ },
2053
+ setup() {
2054
+ return {
2055
+ draft: I(),
2056
+ data: X()
2057
+ };
2058
+ },
2059
+ computed: {
2060
+ lignePrincipale() {
2061
+ return this.draft.lignePrincipale;
2062
+ },
2063
+ lignesAssociees() {
2064
+ return this.draft.lignesAssociees;
2065
+ },
2066
+ collaborateurs() {
2067
+ return (this.data.cache.collaborateurs ?? []).filter((e) => e.actif !== !1);
2068
+ },
2069
+ motifLibelle() {
2070
+ let e = this.lignePrincipale.idMotif;
2071
+ return e == null ? null : this.data.motifLibelle(e);
2072
+ }
2073
+ },
2074
+ async created() {
2075
+ await this.data.loadCollaborateurs(), await this.prefillResponsables();
2076
+ },
2077
+ methods: {
2078
+ codeOfPatrimoine(e) {
2079
+ return {
2080
+ codeProgramme: e?.codeProgramme,
2081
+ codeTranche: e?.codeTranche,
2082
+ codeBatiment: e?.codeBatiment,
2083
+ codeEscalier: e?.codeEscalier
2084
+ };
2085
+ },
2086
+ async suggestResponsable(e, t = null) {
2087
+ await this.data.loadResponsables({
2088
+ motif: e.idMotif,
2089
+ categorie: e.idCategorie,
2090
+ type: e.idType,
2091
+ nature: e.idNature
2092
+ });
2093
+ let n = this.codeOfPatrimoine(t ?? this.lignePrincipale.patrimoine), r = this.data.getResponsableSuggere({
2094
+ idMotif: e.idMotif,
2095
+ ...n
2096
+ });
2097
+ return r ? this.collaborateurs.find((e) => String(e.id) === String(r.idResponsable)) ?? null : null;
2098
+ },
2099
+ async prefillResponsables() {
2100
+ if (!this.draft.isReadonly("responsable")) for (let [e, t] of this.draft.draft.lignes.entries()) {
2101
+ if (t.responsable != null || t.idMotif == null) continue;
2102
+ let n = await this.suggestResponsable(t, t.patrimoine ?? null);
2103
+ n && this.draft.setResponsable(e, n);
2104
+ }
2105
+ }
2106
+ }
2107
+ }, Or = { class: "d-flex flex-column gap-3" }, kr = { class: "alert alert-light border py-2 px-3 mb-0 d-flex flex-column gap-1" }, Ar = {
2108
+ key: 0,
2109
+ class: "fs-7"
2110
+ }, jr = { class: "fs-7" }, Mr = { class: "bg-light rounded px-2 py-1 d-flex flex-column gap-1" }, Nr = { class: "fs-7" }, Pr = { class: "fs-7" };
2111
+ function Fr(e, t, r, c, d, f) {
2112
+ let p = S("font-awesome-icon"), m = S("ligne-detail-block"), h = S("amsom-overlay");
2113
+ return g(), i(h, { loading: c.data.isLoading && !c.data.cache.collaborateurs }, {
2114
+ default: D(() => [s("div", Or, [
2115
+ s("div", kr, [f.motifLibelle ? (g(), o("span", Ar, [
2116
+ u(p, {
2117
+ icon: "tag",
2118
+ class: "text-primary me-2"
2119
+ }),
2120
+ t[0] ||= s("span", { class: "text-muted text-uppercase fw-semibold me-1" }, "Motif", -1),
2121
+ l(C(f.motifLibelle), 1)
2122
+ ])) : a("", !0), s("span", jr, [
2123
+ u(p, {
2124
+ icon: "location-dot",
2125
+ class: "text-primary me-2"
2126
+ }),
2127
+ t[1] ||= s("span", { class: "text-muted text-uppercase fw-semibold me-1" }, "Cible", -1),
2128
+ l(" " + C(c.draft.cibleResume(f.lignePrincipale)), 1)
2129
+ ])]),
2130
+ u(m, { index: 0 }),
2131
+ f.lignesAssociees.length ? (g(), o(n, { key: 0 }, [t[4] ||= s("div", { class: "d-flex align-items-center gap-2 text-muted fs-7" }, [
2132
+ s("hr", { class: "flex-grow-1 my-0" }),
2133
+ s("span", null, "Détail des autres motifs"),
2134
+ s("hr", { class: "flex-grow-1 my-0" })
2135
+ ], -1), (g(!0), o(n, null, b(f.lignesAssociees, (e, n) => (g(), o("div", {
2136
+ key: e.idMotif,
2137
+ class: "border rounded p-2 d-flex flex-column gap-2"
2138
+ }, [s("div", Mr, [s("span", Nr, [
2139
+ u(p, {
2140
+ icon: "tag",
2141
+ class: "text-primary me-2"
2142
+ }),
2143
+ t[2] ||= s("span", { class: "text-muted text-uppercase fw-semibold me-1" }, "Motif", -1),
2144
+ l(" " + C(e.libelle), 1)
2145
+ ]), s("span", Pr, [
2146
+ u(p, {
2147
+ icon: "location-dot",
2148
+ class: "text-primary me-2"
2149
+ }),
2150
+ t[3] ||= s("span", { class: "text-muted text-uppercase fw-semibold me-1" }, "Cible", -1),
2151
+ l(" " + C(c.draft.cibleResume(e)), 1)
2152
+ ])]), u(m, { index: n + 1 }, null, 8, ["index"])]))), 128))], 64)) : a("", !0)
2153
+ ])]),
2154
+ _: 1
2155
+ }, 8, ["loading"]);
2156
+ }
2157
+ //#endregion
2158
+ //#region src/components/StepperBlock.vue
2159
+ var Ir = {
2160
+ name: "StepperBlock",
2161
+ components: {
2162
+ AmsomHorizontalStepper: ne,
2163
+ AmsomOverlay: t,
2164
+ EtapeReclamantBlock: Je,
2165
+ EtapeCategorieBlock: qt,
2166
+ EtapeCibleBlock: Xn,
2167
+ EtapeDetailsBlock: /* @__PURE__ */ L(Dr, [["render", Fr]])
2168
+ },
2169
+ props: {
2170
+ step: {
2171
+ type: Number,
2172
+ default: 1
2173
+ },
2174
+ creating: {
2175
+ type: Boolean,
2176
+ default: !1
2177
+ }
2178
+ },
2179
+ emits: [
2180
+ "update:step",
2181
+ "stepChange",
2182
+ "submit"
2183
+ ],
2184
+ setup() {
2185
+ return {
2186
+ draft: I(),
2187
+ data: X(),
2188
+ options: z()
2189
+ };
2190
+ },
2191
+ computed: {
2192
+ steps() {
2193
+ return [
2194
+ ...this.options.reclamantMode === "step" ? [{
2195
+ key: "reclamant",
2196
+ label: "Réclamant",
2197
+ icon: "user"
2198
+ }] : [],
2199
+ {
2200
+ key: "categorie",
2201
+ label: "Catégorisation",
2202
+ icon: "tag"
2203
+ },
2204
+ {
2205
+ key: "cible",
2206
+ label: "Cible",
2207
+ icon: "location-dot"
2208
+ },
2209
+ {
2210
+ key: "details",
2211
+ label: "Détails",
2212
+ icon: "info"
2213
+ }
2214
+ ];
2215
+ },
2216
+ currentKey() {
2217
+ return this.steps[this.step - 1]?.key ?? null;
2218
+ },
2219
+ lignePrincipale() {
2220
+ return this.draft.lignePrincipale;
2221
+ },
2222
+ aideMotif() {
2223
+ let e = this.lignePrincipale.idMotif;
2224
+ return e ? this.data.cache.motifs?.find((t) => t.id === e)?.aide ?? null : null;
2225
+ },
2226
+ canGoNext() {
2227
+ return this.gatePassed(this.currentKey);
2228
+ },
2229
+ canCreer() {
2230
+ return !!this.lignePrincipale.idMotif && !!this.draft.draft.provenance && this.draft.ciblesValid && this.draft.detailsValid && this.draft.reclamantSelectionne != null;
2231
+ },
2232
+ stepperSteps() {
2233
+ return this.steps.map((e, t) => {
2234
+ let n = t + 1;
2235
+ return {
2236
+ numero: n,
2237
+ subtitle: e.label,
2238
+ subtitleColor: n === this.step ? "primary" : "muted",
2239
+ icon: n < this.step ? "check" : e.icon,
2240
+ iconColor: "white",
2241
+ bubbleBgColor: n > this.step ? "gray" : "primary",
2242
+ clickable: n < this.step
2243
+ };
2244
+ });
2245
+ }
2246
+ },
2247
+ watch: { step(e, t) {
2248
+ this.$emit("stepChange", {
2249
+ step: e,
2250
+ key: this.currentKey,
2251
+ previous: {
2252
+ step: t,
2253
+ key: this.steps[t - 1]?.key ?? null
2254
+ }
2255
+ });
2256
+ } },
2257
+ methods: {
2258
+ gatePassed(e) {
2259
+ return e === "reclamant" ? this.draft.reclamantSelectionne != null && !!this.draft.draft.provenance : e === "categorie" ? !!this.lignePrincipale.idMotif && !!this.draft.draft.provenance : e !== "cible" || this.draft.ciblesValid;
2260
+ },
2261
+ onStepClick(e) {
2262
+ e < this.step && this.$emit("update:step", e);
2263
+ },
2264
+ goPrevious() {
2265
+ this.step > 1 && this.$emit("update:step", this.step - 1);
2266
+ },
2267
+ goNext() {
2268
+ this.step >= this.steps.length || !this.canGoNext || (this.currentKey === "categorie" && this.preloadResponsables(), this.$emit("update:step", this.step + 1));
2269
+ },
2270
+ preloadResponsables() {
2271
+ this.draft.draft.lignes.forEach((e) => this.data.loadResponsables({
2272
+ motif: e.idMotif,
2273
+ categorie: e.idCategorie,
2274
+ type: e.idType,
2275
+ nature: e.idNature
2276
+ }));
2277
+ }
2278
+ }
2279
+ }, Lr = { class: "d-flex flex-column gap-3" }, Rr = {
2280
+ key: 0,
2281
+ class: "w-100 fs-6 fw-medium my-3 alert alert-info",
2282
+ style: { "white-space": "pre-line" }
2283
+ }, zr = { style: { "min-height": "260px" } }, Br = { class: "d-flex justify-content-between" }, Vr = { key: 1 }, Hr = ["disabled"], Ur = ["disabled"];
2284
+ function Wr(e, t, n, r, c, d) {
2285
+ let f = S("amsom-horizontal-stepper"), p = S("font-awesome-icon"), m = S("etape-reclamant-block"), h = S("etape-categorie-block"), _ = S("etape-cible-block"), v = S("etape-details-block"), y = S("amsom-overlay");
2286
+ return g(), i(y, { loading: n.creating }, {
2287
+ default: D(() => [s("div", Lr, [
2288
+ u(f, {
2289
+ steps: d.stepperSteps,
2290
+ size: "md",
2291
+ onStepClick: d.onStepClick
2292
+ }, null, 8, ["steps", "onStepClick"]),
2293
+ d.aideMotif ? (g(), o("div", Rr, [u(p, {
2294
+ icon: "circle-info",
2295
+ class: "text-info-emphasis me-2"
2296
+ }), s("span", null, C(d.aideMotif), 1)])) : a("", !0),
2297
+ s("div", zr, [d.currentKey === "reclamant" ? (g(), i(m, {
2298
+ key: 0,
2299
+ premiere: n.step === 1
2300
+ }, null, 8, ["premiere"])) : d.currentKey === "categorie" ? (g(), i(h, {
2301
+ key: 1,
2302
+ premiere: n.step === 1
2303
+ }, null, 8, ["premiere"])) : d.currentKey === "cible" ? (g(), i(_, { key: 2 })) : d.currentKey === "details" ? (g(), i(v, { key: 3 })) : a("", !0)]),
2304
+ s("div", Br, [n.step > 1 ? (g(), o("button", {
2305
+ key: 0,
2306
+ class: "btn btn-sm btn-outline-secondary",
2307
+ onClick: t[0] ||= (...e) => d.goPrevious && d.goPrevious(...e)
2308
+ }, [u(p, {
2309
+ icon: "chevron-left",
2310
+ class: "me-1"
2311
+ }), t[3] ||= l(" Précédent ", -1)])) : (g(), o("span", Vr)), n.step < d.steps.length ? (g(), o("button", {
2312
+ key: 2,
2313
+ class: "btn btn-sm btn-primary",
2314
+ disabled: !d.canGoNext,
2315
+ onClick: t[1] ||= (...e) => d.goNext && d.goNext(...e)
2316
+ }, [t[4] ||= l(" Suivant ", -1), u(p, {
2317
+ icon: "chevron-right",
2318
+ class: "ms-1"
2319
+ })], 8, Hr)) : (g(), o("button", {
2320
+ key: 3,
2321
+ class: "btn btn-sm btn-success",
2322
+ disabled: !d.canCreer || n.creating,
2323
+ onClick: t[2] ||= (t) => e.$emit("submit")
2324
+ }, [u(p, {
2325
+ icon: "check",
2326
+ class: "me-1"
2327
+ }), t[5] ||= l(" Créer la sollicitation ", -1)], 8, Ur))])
2328
+ ])]),
2329
+ _: 1
2330
+ }, 8, ["loading"]);
2331
+ }
2332
+ var Gr = /*#__PURE__*/ L(Ir, [["render", Wr]]), Kr = (e, { signal: t, token: n, baseUrl: r } = {}) => nt("/cally2/creer_sollicitation", e, {
2333
+ signal: t,
2334
+ token: n,
2335
+ baseUrl: r
2336
+ }), qr = ({ idSollicitation: e, pj: t }, { signal: n, token: r, baseUrl: i } = {}) => nt("/cally2/upload_sollicitation_ged", {
2337
+ idSollicitation: e,
2338
+ pj: t
2339
+ }, {
2340
+ signal: n,
2341
+ token: r,
2342
+ baseUrl: i
2343
+ }), Z = {
2344
+ modelValue: {
2345
+ type: Object,
2346
+ default: null
2347
+ },
2348
+ reclamants: {
2349
+ type: Array,
2350
+ default: () => []
2351
+ },
2352
+ reclamantMode: {
2353
+ type: String,
2354
+ default: "select",
2355
+ validator: (e) => [
2356
+ "select",
2357
+ "switch",
2358
+ "autocomplete",
2359
+ "step"
2360
+ ].includes(e)
2361
+ },
2362
+ readonly: {
2363
+ type: [Boolean, Array],
2364
+ default: !1,
2365
+ validator: (e) => typeof e == "boolean" || e.every((e) => N.includes(e))
2366
+ },
2367
+ modules: {
2368
+ type: Array,
2369
+ default: null
2370
+ },
2371
+ idModule: {
2372
+ type: [String, Number],
2373
+ default: null
2374
+ },
2375
+ nomenclatureFilter: {
2376
+ type: Function,
2377
+ default: null
2378
+ },
2379
+ aside: {
2380
+ type: Boolean,
2381
+ default: !0
2382
+ },
2383
+ nbSimilaires: {
2384
+ type: Number,
2385
+ default: 0
2386
+ },
2387
+ baseUrl: {
2388
+ type: String,
2389
+ default: null
2390
+ },
2391
+ token: {
2392
+ type: String,
2393
+ default: null
2394
+ }
2395
+ }, Jr = Object.keys(Z), Q = [
2396
+ "update:modelValue",
2397
+ "reclamantChange",
2398
+ "motifChange",
2399
+ "stepChange",
2400
+ "beforeCreate",
2401
+ "created",
2402
+ "createError",
2403
+ "error"
2404
+ ], Yr = {
2405
+ name: "CreerSollicitationForm",
2406
+ components: {
2407
+ AsideBlock: Te,
2408
+ StepperBlock: Gr
2409
+ },
2410
+ props: { ...Z },
2411
+ emits: [...Q],
2412
+ setup(e, { emit: t }) {
2413
+ let n = (e) => t("error", e), i = {
2414
+ token: w(e, "token"),
2415
+ baseUrl: w(e, "baseUrl")
2416
+ }, a = St(xt({
2417
+ onError: n,
2418
+ ...i
2419
+ })), o = y(null), s = r(() => e.modules ?? o.value ?? []), c = ve(_e({
2420
+ reclamants: w(e, "reclamants"),
2421
+ modules: s,
2422
+ idModulePrefere: w(e, "idModule"),
2423
+ readonly: w(e, "readonly")
2424
+ }));
2425
+ return Ee(v({
2426
+ nomenclatureFilter: w(e, "nomenclatureFilter"),
2427
+ reclamantMode: w(e, "reclamantMode"),
2428
+ modulesReclamant: s,
2429
+ ...i
2430
+ })), {
2431
+ data: a,
2432
+ draft: c,
2433
+ modulesCharges: o,
2434
+ onError: n
2435
+ };
2436
+ },
2437
+ data() {
2438
+ return {
2439
+ currentStep: 1,
2440
+ creating: !1
2441
+ };
2442
+ },
2443
+ computed: {
2444
+ requestOptions() {
2445
+ return {
2446
+ token: this.token,
2447
+ baseUrl: this.baseUrl
2448
+ };
2449
+ },
2450
+ motifChoisi() {
2451
+ let [e, ...t] = this.draft.draft.lignes;
2452
+ return {
2453
+ idCategorie: e.idCategorie,
2454
+ idType: e.idType,
2455
+ idNature: e.idNature,
2456
+ idMotif: e.idMotif,
2457
+ motifsAssocies: t.map((e) => e.idMotif)
2458
+ };
2459
+ }
2460
+ },
2461
+ watch: { "draft.draft": {
2462
+ deep: !0,
2463
+ handler(e) {
2464
+ this.$emit("update:modelValue", e);
2465
+ }
2466
+ } },
2467
+ async created() {
2468
+ this.draft.reset(this.modelValue), this.draft.syncReclamant(), this.$watch("draft.reclamantSelectionne", (e) => this.$emit("reclamantChange", e)), this.$watch(() => JSON.stringify(this.motifChoisi), () => this.$emit("motifChange", this.motifChoisi)), this.data.loadNomenclature();
2469
+ let e = this.draft.reclamantSelectionne;
2470
+ !this.modules && this.draft.reclamantEstContrat && (this.modulesCharges = await this.data.loadModulesOfContrat({
2471
+ idContrat: e.id,
2472
+ typeContrat: e.type
2473
+ }), this.draft.prefillCiblePrincipale());
2474
+ },
2475
+ methods: {
2476
+ async creer() {
2477
+ if (!this.creating) {
2478
+ this.creating = !0;
2479
+ try {
2480
+ let e = this.draft.creationPayload();
2481
+ if (!await this.autoriserCreation(e)) return;
2482
+ let t;
2483
+ try {
2484
+ t = await Kr(e, this.requestOptions) ?? [];
2485
+ } catch (t) {
2486
+ if (gt(t)) return;
2487
+ let n = G(t);
2488
+ this.$emit("createError", {
2489
+ error: t,
2490
+ message: n,
2491
+ payload: e
2492
+ }), this.onError(n);
2493
+ return;
2494
+ }
2495
+ let n = await this.sendFiles(t);
2496
+ this.$emit("created", t, {
2497
+ payload: e,
2498
+ fichiers: n
2499
+ });
2500
+ } finally {
2501
+ this.creating = !1;
2502
+ }
2503
+ }
2504
+ },
2505
+ async autoriserCreation(e) {
2506
+ let t = !1, n = [];
2507
+ if (this.$emit("beforeCreate", {
2508
+ payload: e,
2509
+ cancel: () => {
2510
+ t = !0;
2511
+ },
2512
+ waitUntil: (e) => {
2513
+ n.push(e);
2514
+ }
2515
+ }), t) return !1;
2516
+ try {
2517
+ let e = await Promise.all(n);
2518
+ return !t && !e.includes(!1);
2519
+ } catch {
2520
+ return !1;
2521
+ }
2522
+ },
2523
+ sendFiles(e) {
2524
+ let t = [...e], n = this.draft.draft.lignes.filter((e) => e.fichier?.[0]).map((e) => {
2525
+ let n = e.fichier[0], r = e.libelle || e.idMotif, i = t.findIndex((t) => String(t.idMotif) === String(e.idMotif)), a = i === -1 ? null : t.splice(i, 1)[0], o = {
2526
+ idMotif: e.idMotif,
2527
+ nom: n.name,
2528
+ idSollicitation: a?.id ?? null
2529
+ }, s = (e) => {
2530
+ let t = `Document non envoyé (${r}) : ${e}`;
2531
+ return this.onError(t), {
2532
+ ...o,
2533
+ ok: !1,
2534
+ message: t
2535
+ };
2536
+ };
2537
+ return a?.id ? qr({
2538
+ idSollicitation: a.id,
2539
+ pj: {
2540
+ name: n.name,
2541
+ type: n.type || "application/pdf",
2542
+ file: n.file
2543
+ }
2544
+ }, this.requestOptions).then(() => ({
2545
+ ...o,
2546
+ ok: !0,
2547
+ message: null
2548
+ })).catch((e) => s(G(e))) : Promise.resolve(s("sollicitation introuvable dans la réponse"));
2549
+ });
2550
+ return Promise.all(n);
2551
+ }
2552
+ }
2553
+ }, Xr = { class: "row g-3" }, Zr = {
2554
+ key: 0,
2555
+ class: "col-12 col-lg-4"
2556
+ };
2557
+ function Qr(e, t, n, r, i, l) {
2558
+ let f = S("aside-block"), p = S("stepper-block");
2559
+ return g(), o("div", Xr, [e.aside ? (g(), o("div", Zr, [x(e.$slots, "aside", {}, () => [u(f, { "nb-similaires": e.nbSimilaires }, c({ _: 2 }, [e.$slots["aside-similaires"] ? {
2560
+ name: "similaires",
2561
+ fn: D((t) => [x(e.$slots, "aside-similaires", h(d(t)))]),
2562
+ key: "0"
2563
+ } : void 0, e.$slots["aside-evenements"] ? {
2564
+ name: "evenements",
2565
+ fn: D(() => [x(e.$slots, "aside-evenements")]),
2566
+ key: "1"
2567
+ } : void 0]), 1032, ["nb-similaires"])])])) : a("", !0), s("div", { class: m(["col-12", e.aside ? "col-lg-8" : ""]) }, [u(p, {
2568
+ step: i.currentStep,
2569
+ "onUpdate:step": t[0] ||= (e) => i.currentStep = e,
2570
+ creating: i.creating,
2571
+ onStepChange: t[1] ||= (t) => e.$emit("stepChange", t),
2572
+ onSubmit: l.creer
2573
+ }, null, 8, [
2574
+ "step",
2575
+ "creating",
2576
+ "onSubmit"
2577
+ ])], 2)]);
2578
+ }
2579
+ var $ = /*#__PURE__*/ L(Yr, [["render", Qr]]), $r = {
2580
+ name: "CreerSollicitationModal",
2581
+ components: {
2582
+ AmsomModal: e,
2583
+ CreerSollicitationForm: $
2584
+ },
2585
+ props: {
2586
+ ...Z,
2587
+ titre: {
2588
+ type: String,
2589
+ default: "Nouvelle sollicitation"
2590
+ },
2591
+ closeOnCreated: {
2592
+ type: Boolean,
2593
+ default: !0
2594
+ }
2595
+ },
2596
+ emits: [...Q, "close"],
2597
+ computed: {
2598
+ formProps() {
2599
+ return Object.fromEntries(Jr.map((e) => [e, this[e]]));
2600
+ },
2601
+ formListeners() {
2602
+ return Object.fromEntries(Q.filter((e) => e !== "created").map((e) => [e, (...t) => this.$emit(e, ...t)]));
2603
+ }
2604
+ },
2605
+ methods: { onCreated(...e) {
2606
+ this.$emit("created", ...e), this.closeOnCreated && this.$emit("close");
2607
+ } }
2608
+ }, ei = { class: "fw-medium fs-5" };
2609
+ function ti(e, t, n, r, a, o) {
2610
+ let l = S("creer-sollicitation-form"), f = S("amsom-modal");
2611
+ return g(), i(f, {
2612
+ "close-option": "",
2613
+ size: "xl",
2614
+ onClose: t[0] ||= (t) => e.$emit("close")
2615
+ }, {
2616
+ default: D(() => [s("span", ei, C(n.titre), 1), u(l, p({ class: "pt-3" }, o.formProps, ee(o.formListeners), { onCreated: o.onCreated }), c({ _: 2 }, [b(e.$slots, (t, n) => ({
2617
+ name: n,
2618
+ fn: D((t) => [x(e.$slots, n, h(d(t ?? {})))])
2619
+ }))]), 1040, ["onCreated"])]),
2620
+ _: 3
2621
+ });
2622
+ }
2623
+ var ni = /*#__PURE__*/ L($r, [["render", ti]]), ri = {
2624
+ CreerSollicitationModal: ni,
2625
+ CreerSollicitationForm: $
2626
+ };
2627
+ //#endregion
2628
+ export { $ as CreerSollicitationForm, ni as CreerSollicitationModal, ce as DEFAULT_PROVENANCE_CONTACT, se as PROVENANCES_CONTACT, N as READONLY_FIELDS, Xe as configureCresol, ri as default, P as getDefaultDraft, M as getDefaultLigne, j as getDefaultPatrimoine, bt as resetCresolCache };