@wisemen/wise-crm-web 2.0.0-alpha.9 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,906 @@
1
+ import { defineComponent as $, useModel as re, openBlock as a, createElementBlock as g, createVNode as i, unref as t, withCtx as y, Fragment as P, renderList as H, createBlock as h, createElementVNode as s, renderSlot as U, mergeModels as ce, createStaticVNode as ue, resolveDynamicComponent as de, toDisplayString as C, computed as b, mergeProps as Y, normalizeClass as me, normalizeStyle as F, toValue as L, createCommentVNode as v, useSlots as pe } from "vue";
2
+ import { UITabs as fe, UITabsList as _e, UITabsItem as ye, UITextareaField as Z, toFormField as J, UIIconButton as S, UIDropdownMenu as ee, UIDropdownMenuGroup as z, UIDropdownMenuItem as T, UILoader as xe, useToast as he, UIFormDialog as ge, UIDialogHeader as be, UIDialogBody as ve, UIDialogFooter as we, UIDialogFooterCancel as ke, UIDialogFooterSubmit as $e, UIDashboardPage as Ce, UITabsRouterLink as Ue, UITabsRouterLinkItem as Ie, UIText as De, UISeparator as Se, UIDropdownMenuSeparator as Te, UIBadge as N, UISkeletonItem as Ae } from "@wisemen/vue-core-design-system";
3
+ import { ApiUtil as k, useMutation as te, useQuery as Ne } from "@wisemen/vue-core-api-utils";
4
+ import { K as Pe, Z as Be, L as Ee, N as Ve, O as ze, P as He, Q as Me, R as Fe, k as Le, S as Re, J as je, E as qe, i as We, U as ne, H as B, h as oe, u as Ge, X as Ke, b as le, Y as Oe, $ as Qe, a0 as R, a1 as E, a2 as j, a3 as q, a4 as W, g as Xe, a5 as Ye, a6 as Ze, w as Je, a7 as et, a8 as tt, a9 as nt } from "./index-BocNglY-.js";
5
+ import { useI18n as D } from "vue-i18n";
6
+ import { useForm as ie } from "formango";
7
+ import { Temporal as ot } from "temporal-polyfill";
8
+ import { z as G } from "zod";
9
+ import { onKeyStroke as lt, useClipboard as it } from "@vueuse/core";
10
+ import { useRoute as at, RouterView as st } from "vue-router";
11
+ import { bs as rt } from "./uuid.util-DUuuAgdg.js";
12
+ import { Motion as ct } from "motion-v";
13
+ const ut = { class: "mt-lg flex h-full flex-1 flex-col overflow-hidden" }, dt = { class: "min-h-0 flex-1 overflow-y-auto px-lg py-lg" }, yn = /* @__PURE__ */ $({
14
+ __name: "CrmDetailSidebarTabs",
15
+ props: /* @__PURE__ */ ce({
16
+ tabs: {}
17
+ }, {
18
+ modelValue: {
19
+ required: !0
20
+ },
21
+ modelModifiers: {}
22
+ }),
23
+ emits: ["update:modelValue"],
24
+ setup(c) {
25
+ const e = c, n = re(c, "modelValue");
26
+ return (l, o) => (a(), g("div", ut, [
27
+ i(t(fe), {
28
+ modelValue: n.value,
29
+ "onUpdate:modelValue": o[0] || (o[0] = (f) => n.value = f),
30
+ "is-full-width": !0,
31
+ "underline-tabs-horizontal-list-padding": "lg",
32
+ class: "flex h-full flex-1 flex-col"
33
+ }, {
34
+ default: y(() => [
35
+ i(t(_e), { class: "py-xxs" }, {
36
+ default: y(() => [
37
+ (a(!0), g(P, null, H(e.tabs, (f) => (a(), h(t(ye), {
38
+ key: f.value,
39
+ value: f.value,
40
+ icon: f.icon,
41
+ label: f.label
42
+ }, null, 8, ["value", "icon", "label"]))), 128))
43
+ ]),
44
+ _: 1
45
+ }),
46
+ s("div", dt, [
47
+ U(l.$slots, "default")
48
+ ])
49
+ ]),
50
+ _: 3
51
+ }, 8, ["modelValue"])
52
+ ]));
53
+ }
54
+ }), mt = {}, pt = {
55
+ fill: "none",
56
+ height: "100%",
57
+ viewBox: "0 0 756 560",
58
+ width: "100%",
59
+ xmlns: "http://www.w3.org/2000/svg"
60
+ };
61
+ function ft(c, e) {
62
+ return a(), g("svg", pt, [...e[0] || (e[0] = [
63
+ ue('<mask id="mask0_2103_18170" height="768" maskUnits="userSpaceOnUse" style="mask-type:alpha;" width="768" x="-6" y="-208"><rect fill="url(#paint0_radial_2103_18170)" height="768" transform="translate(-6 -208)" width="768"></rect></mask><g mask="url(#mask0_2103_18170)"><g clip-path="url(#clip0_2103_18170)"><g clip-path="url(#clip1_2103_18170)"><line stroke="currentColor" x1="42.5" x2="42.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="90.5" x2="90.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="138.5" x2="138.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="186.5" x2="186.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="234.5" x2="234.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="282.5" x2="282.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="330.5" x2="330.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="378.5" x2="378.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="426.5" x2="426.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="474.5" x2="474.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="522.5" x2="522.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="570.5" x2="570.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="618.5" x2="618.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="666.5" x2="666.5" y1="-208" y2="560"></line><line stroke="currentColor" x1="714.5" x2="714.5" y1="-208" y2="560"></line></g><rect height="767" stroke="currentColor" width="767" x="-5.5" y="-207.5"></rect><g clip-path="url(#clip2_2103_18170)"><line stroke="currentColor" x1="-6" x2="762" y1="31.5" y2="31.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="79.5" y2="79.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="127.5" y2="127.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="175.5" y2="175.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="223.5" y2="223.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="271.5" y2="271.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="319.5" y2="319.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="367.5" y2="367.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="415.5" y2="415.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="463.5" y2="463.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="511.5" y2="511.5"></line><line stroke="currentColor" x1="-6" x2="762" y1="559.5" y2="559.5"></line></g><rect height="767" stroke="currentColor" width="767" x="-5.5" y="-207.5"></rect></g></g><defs><radialGradient id="paint0_radial_2103_18170" cx="0" cy="0" gradientTransform="translate(384 384) rotate(90) scale(384 384)" gradientUnits="userSpaceOnUse" r="1"><stop></stop><stop offset="1" stop-opacity="0"></stop></radialGradient><clipPath id="clip0_2103_18170"><rect fill="white" height="768" transform="translate(-6 -208)" width="768"></rect></clipPath><clipPath id="clip1_2103_18170"><rect fill="white" height="768" width="768" x="-6" y="-208"></rect></clipPath><clipPath id="clip2_2103_18170"><rect fill="white" height="768" width="768" x="-6" y="-208"></rect></clipPath></defs>', 3)
64
+ ])]);
65
+ }
66
+ const _t = /* @__PURE__ */ Pe(mt, [["render", ft]]), yt = { class: "relative flex h-full flex-col items-center justify-center text-center" }, xt = { class: "relative z-1 flex flex-col items-center gap-lg" }, ht = { class: "flex size-12 items-center justify-center rounded-full border-3 border-solid border-white bg-brand-200 p-md shadow-md" }, gt = { class: "flex flex-col gap-sm" }, bt = { class: "text-md font-semibold" }, vt = { class: "text-sm text-tertiary" }, wt = { class: "absolute inset-x-0 scale-140 opacity-10" }, kt = /* @__PURE__ */ $({
67
+ __name: "AppEmptyState",
68
+ props: {
69
+ title: {},
70
+ description: {},
71
+ icon: {}
72
+ },
73
+ setup(c) {
74
+ const e = c;
75
+ return (n, l) => (a(), g("div", yt, [
76
+ s("div", xt, [
77
+ s("div", ht, [
78
+ (a(), h(de(e.icon), { class: "size-full text-brand-600" }))
79
+ ]),
80
+ s("div", gt, [
81
+ s("h3", bt, C(e.title), 1),
82
+ s("p", vt, C(e.description), 1)
83
+ ])
84
+ ]),
85
+ s("div", wt, [
86
+ i(_t)
87
+ ])
88
+ ]));
89
+ }
90
+ });
91
+ class V {
92
+ static fromDto(e) {
93
+ return {
94
+ uuid: e.uuid,
95
+ lastUpdatedByUserUuid: e.lastUpdatedByUserUuid,
96
+ updatedAt: Be.fromDto(e.updatedAt),
97
+ content: e.content,
98
+ lastUpdatedByUser: e.lastUpdatedByUser
99
+ };
100
+ }
101
+ }
102
+ class $t {
103
+ static toDto(e, n, l, o) {
104
+ return {
105
+ businessUuid: n ?? null,
106
+ dealUuid: o ?? null,
107
+ individualUuid: l ?? null,
108
+ content: e.note ?? ""
109
+ };
110
+ }
111
+ }
112
+ class ae {
113
+ static async create(e, n) {
114
+ const l = await k.fromPromise(Ee({
115
+ body: $t.toDto(
116
+ e,
117
+ n.businessUuid,
118
+ n.individualUuid,
119
+ n.dealUuid
120
+ )
121
+ }));
122
+ return k.void(l);
123
+ }
124
+ static async delete(e) {
125
+ const n = await k.fromPromise(Ve({
126
+ path: {
127
+ uuid: e
128
+ }
129
+ }));
130
+ return k.void(n);
131
+ }
132
+ static async getBusinessNotes(e, n) {
133
+ return (await k.fromPromise(ze({
134
+ query: e,
135
+ path: {
136
+ businessUuid: n
137
+ }
138
+ }))).map((o) => ({
139
+ data: o.data.items.map(V.fromDto),
140
+ meta: {
141
+ next: o.data.meta.next
142
+ }
143
+ }));
144
+ }
145
+ static async getDealNotes(e, n) {
146
+ return (await k.fromPromise(He({
147
+ query: e,
148
+ path: {
149
+ dealUuid: n
150
+ }
151
+ }))).map((o) => ({
152
+ data: o.data.items.map(V.fromDto),
153
+ meta: {
154
+ next: o.data.meta.next
155
+ }
156
+ }));
157
+ }
158
+ static async getIndividualNotes(e, n) {
159
+ return (await k.fromPromise(Me({
160
+ query: e,
161
+ path: {
162
+ individualUuid: n
163
+ }
164
+ }))).map((o) => ({
165
+ data: o.data.items.map(V.fromDto),
166
+ meta: {
167
+ next: o.data.meta.next
168
+ }
169
+ }));
170
+ }
171
+ static async update(e, n) {
172
+ const l = await k.fromPromise(Fe({
173
+ body: {
174
+ content: n
175
+ },
176
+ path: {
177
+ uuid: e
178
+ }
179
+ }));
180
+ return k.void(l);
181
+ }
182
+ }
183
+ function xn() {
184
+ return te({
185
+ queryFn: async ({
186
+ params: c
187
+ }) => await ae.delete(c.noteUuid),
188
+ queryKeysToInvalidate: {
189
+ noteBusinessIndex: {},
190
+ noteDealIndex: {},
191
+ noteIndividualIndex: {}
192
+ }
193
+ });
194
+ }
195
+ const se = G.object({
196
+ note: G.string().trim().min(1)
197
+ }), Ct = { class: "flex justify-end p-md" }, Ut = /* @__PURE__ */ $({
198
+ __name: "NoteForm",
199
+ props: {
200
+ content: {},
201
+ onSubmit: { type: Function }
202
+ },
203
+ setup(c) {
204
+ const e = c, n = D(), l = ie({
205
+ initialState: {
206
+ note: e.content ?? null
207
+ },
208
+ schema: se,
209
+ onSubmit: async (d) => {
210
+ await e.onSubmit(d), l.reset();
211
+ }
212
+ }), o = l.register("note"), f = b(() => o.modelValue.value === null || o.modelValue.value.trim().length === 0);
213
+ async function p(d) {
214
+ !l.isValid.value || l.isSubmitting.value || d.key === "Enter" && !d.shiftKey && (d.preventDefault(), await l.submit(), o.setValue(null));
215
+ }
216
+ return (d, x) => (a(), g("div", null, [
217
+ i(Le, {
218
+ "can-exit-when-dirty": !0,
219
+ form: t(l),
220
+ class: "w-full"
221
+ }, {
222
+ default: y(() => [
223
+ i(t(Z), Y(t(J)(t(o)), {
224
+ errors: [],
225
+ "error-message": null,
226
+ placeholder: t(n).t("wise_crm.note.create_placeholder"),
227
+ "class-config": {
228
+ input: "h-20"
229
+ },
230
+ onKeydown: p
231
+ }), {
232
+ bottom: y(() => [
233
+ s("div", Ct, [
234
+ i(t(S), {
235
+ "is-loading": t(l).isSubmitting.value,
236
+ "is-disabled": f.value,
237
+ label: t(n).t("wise_crm.info_dialog.notes.submit_note_label"),
238
+ icon: t(Re),
239
+ class: "rounded-full shadow-none",
240
+ type: "submit",
241
+ size: "sm"
242
+ }, null, 8, ["is-loading", "is-disabled", "label", "icon"])
243
+ ])
244
+ ]),
245
+ _: 1
246
+ }, 16, ["placeholder"])
247
+ ]),
248
+ _: 1
249
+ }, 8, ["form"])
250
+ ]));
251
+ }
252
+ }), It = { class: "flex flex-col gap-md" }, Dt = { class: "relative flex flex-1 flex-col gap-sm overflow-hidden rounded-lg border border-primary p-lg" }, St = { class: "mr-3xl max-w-full text-sm text-wrap wrap-break-word whitespace-pre-wrap" }, Tt = { class: "flex items-center gap-sm text-xs text-placeholder" }, At = { class: "absolute top-1 right-1" }, Nt = /* @__PURE__ */ $({
253
+ __name: "NoteList",
254
+ props: {
255
+ notes: {}
256
+ },
257
+ emits: ["delete", "next", "update"],
258
+ setup(c, { emit: e }) {
259
+ const n = c, l = e, o = D();
260
+ function f(_) {
261
+ const m = _.updatedAt, r = m.toInstant(), u = ot.Now.instant(), w = B.diffInSeconds(r, u), I = B.diffInMinutes(r, u), M = B.diffInHours(r, u);
262
+ return w < 60 ? o.t("wise_crm.note.just_now") : I < 60 ? o.t("wise_crm.note.minutes_ago", {
263
+ count: Math.round(I)
264
+ }) : M < 24 ? o.t("wise_crm.note.hours_ago", {
265
+ count: Math.round(M)
266
+ }) : oe().toDateTime(m);
267
+ }
268
+ function p() {
269
+ l("next");
270
+ }
271
+ function d(_) {
272
+ l("delete", _);
273
+ }
274
+ function x(_) {
275
+ l("update", _);
276
+ }
277
+ return (_, m) => (a(), h(je, { "on-next": p }, {
278
+ default: y(() => [
279
+ s("div", It, [
280
+ (a(!0), g(P, null, H(n.notes, (r) => (a(), g("div", {
281
+ key: r.content,
282
+ class: "flex gap-sm"
283
+ }, [
284
+ s("div", Dt, [
285
+ s("p", St, C(r.content), 1),
286
+ s("div", Tt, [
287
+ s("span", null, C(f(r)), 1),
288
+ m[0] || (m[0] = s("div", { class: "size-1 rounded-full bg-gray-400" }, null, -1)),
289
+ s("span", null, C(r.lastUpdatedByUser), 1)
290
+ ]),
291
+ s("div", At, [
292
+ i(t(ee), { "popover-align": "end" }, {
293
+ trigger: y(() => [
294
+ i(t(S), {
295
+ label: t(o).t("wise_crm.info_dialog.notes.action_button_label"),
296
+ icon: t(ne),
297
+ variant: "tertiary",
298
+ size: "sm"
299
+ }, null, 8, ["label", "icon"])
300
+ ]),
301
+ content: y(() => [
302
+ i(t(z), null, {
303
+ default: y(() => [
304
+ i(t(T), {
305
+ label: t(o).t("wise_crm.info_dialog.notes.update_note"),
306
+ config: {
307
+ left: {
308
+ type: "icon",
309
+ icon: t(qe)
310
+ }
311
+ },
312
+ onSelect: (u) => x(r)
313
+ }, null, 8, ["label", "config", "onSelect"]),
314
+ i(t(T), {
315
+ "is-destructive": !0,
316
+ label: t(o).t("wise_crm.shared.delete"),
317
+ config: {
318
+ left: {
319
+ type: "icon",
320
+ icon: t(We)
321
+ }
322
+ },
323
+ onSelect: (u) => d(r.uuid)
324
+ }, null, 8, ["label", "config", "onSelect"])
325
+ ]),
326
+ _: 2
327
+ }, 1024)
328
+ ]),
329
+ _: 2
330
+ }, 1024)
331
+ ])
332
+ ])
333
+ ]))), 128))
334
+ ])
335
+ ]),
336
+ _: 1
337
+ }));
338
+ }
339
+ }), Pt = { class: "flex h-full flex-col justify-between gap-lg" }, Bt = {
340
+ key: 0,
341
+ class: "flex h-70 flex-col items-center justify-center gap-md text-quaternary"
342
+ }, Et = { class: "text-xs" }, hn = /* @__PURE__ */ $({
343
+ __name: "CrmDetailSidebarNotesView",
344
+ props: {
345
+ hasNextPage: { type: Boolean },
346
+ isLoading: { type: Boolean },
347
+ notes: {},
348
+ onSubmit: { type: Function }
349
+ },
350
+ emits: ["delete", "next", "update"],
351
+ setup(c, { emit: e }) {
352
+ const n = c, l = e, o = D(), f = Ge();
353
+ async function p(m) {
354
+ try {
355
+ await n.onSubmit(m);
356
+ } catch (r) {
357
+ f.show(r);
358
+ }
359
+ }
360
+ function d() {
361
+ l("next");
362
+ }
363
+ function x(m) {
364
+ l("delete", m);
365
+ }
366
+ function _(m) {
367
+ l("update", m);
368
+ }
369
+ return (m, r) => (a(), g("div", Pt, [
370
+ n.isLoading ? (a(), g("div", Bt, [
371
+ i(t(xe), { class: "size-4" }),
372
+ s("p", Et, C(t(o).t("wise_crm.shared.loading")), 1)
373
+ ])) : n.notes.length === 0 ? (a(), h(kt, {
374
+ key: 1,
375
+ title: t(o).t("wise_crm.info_dialog.notes.empty_state.title"),
376
+ description: t(o).t("wise_crm.info_dialog.notes.empty_state.description"),
377
+ icon: t(Ke)
378
+ }, null, 8, ["title", "description", "icon"])) : (a(), h(Nt, {
379
+ key: 2,
380
+ notes: n.notes,
381
+ onDelete: x,
382
+ onUpdate: _,
383
+ onNext: d
384
+ }, null, 8, ["notes"])),
385
+ i(Ut, { "on-submit": p })
386
+ ]));
387
+ }
388
+ });
389
+ function Vt() {
390
+ return te({
391
+ queryFn: async ({
392
+ body: c,
393
+ params: e
394
+ }) => await ae.update(e.noteUuid, c.note),
395
+ queryKeysToInvalidate: {
396
+ noteBusinessIndex: {},
397
+ noteDealIndex: {},
398
+ noteIndividualIndex: {}
399
+ }
400
+ });
401
+ }
402
+ const gn = /* @__PURE__ */ $({
403
+ __name: "NoteUpdateDialog",
404
+ props: {
405
+ businessUuid: {},
406
+ individualUuid: {},
407
+ note: {}
408
+ },
409
+ emits: ["close"],
410
+ setup(c, { emit: e }) {
411
+ const n = c, l = e, o = D(), f = he(), p = Vt(), d = ie({
412
+ initialState: {
413
+ note: n.note.content ?? null
414
+ },
415
+ schema: se,
416
+ onSubmit: async (m) => {
417
+ const r = await p.execute({
418
+ body: {
419
+ note: m.note
420
+ },
421
+ params: {
422
+ businessUuid: n.businessUuid,
423
+ individualUuid: n.individualUuid,
424
+ noteUuid: n.note.uuid
425
+ }
426
+ });
427
+ if (r.isErr()) {
428
+ f.apiError(r.error);
429
+ return;
430
+ }
431
+ l("close");
432
+ },
433
+ onSubmitError: () => {
434
+ f.unableToSave();
435
+ }
436
+ }), x = d.register("note");
437
+ function _() {
438
+ l("close");
439
+ }
440
+ return (m, r) => (a(), h(t(ge), {
441
+ form: t(d),
442
+ size: "sm",
443
+ onClose: _
444
+ }, {
445
+ default: y(() => [
446
+ i(t(be), {
447
+ title: t(o).t("wise_crm.note.update_dialog.title"),
448
+ description: t(o).t("wise_crm.note.update_dialog.description")
449
+ }, null, 8, ["title", "description"]),
450
+ i(t(ve), null, {
451
+ default: y(() => [
452
+ i(t(Z), Y(t(J)(t(x)), {
453
+ label: t(o).t("wise_crm.note.form.note.label"),
454
+ "class-config": { input: "h-32" }
455
+ }), null, 16, ["label"])
456
+ ]),
457
+ _: 1
458
+ }),
459
+ i(t(we), null, {
460
+ default: y(() => [
461
+ i(t(ke)),
462
+ i(t($e), {
463
+ label: t(o).t("shared.update")
464
+ }, null, 8, ["label"])
465
+ ]),
466
+ _: 1
467
+ })
468
+ ]),
469
+ _: 1
470
+ }, 8, ["form"]));
471
+ }
472
+ }), zt = ["width", "height", "viewBox"], Ht = ["d"], K = 0.5523, A = 24, Mt = 26, Ft = /* @__PURE__ */ $({
473
+ __name: "CrmDetailViewFolderNotchSvg",
474
+ props: {
475
+ bodyWidth: {},
476
+ curveHeight: {}
477
+ },
478
+ setup(c) {
479
+ const e = c, n = b(() => Math.max(e.bodyWidth, A)), l = b(() => n.value + e.curveHeight), o = b(() => e.curveHeight + Mt), f = b(() => {
480
+ const p = n.value, d = e.curveHeight, x = d / 2, _ = x * K, m = A * (1 - K), r = p + x, u = p + d;
481
+ return [
482
+ `M0 ${A}`,
483
+ `C0 ${m} ${m} 0 ${A} 0`,
484
+ `H${p}`,
485
+ `C${p + _} 0 ${r} ${x - _} ${r} ${x}`,
486
+ `C${r} ${x + _} ${u - _} ${d} ${u} ${d}`,
487
+ `V${o.value}`,
488
+ "H0",
489
+ `V${A}`,
490
+ "Z"
491
+ ].join(" ");
492
+ });
493
+ return (p, d) => (a(), g("svg", {
494
+ width: l.value,
495
+ height: o.value,
496
+ viewBox: `0 0 ${l.value} ${o.value}`,
497
+ fill: "none",
498
+ xmlns: "http://www.w3.org/2000/svg"
499
+ }, [
500
+ s("path", {
501
+ d: f.value,
502
+ class: "fill-(--bg-primary)"
503
+ }, null, 8, Ht)
504
+ ], 8, zt));
505
+ }
506
+ });
507
+ class O {
508
+ /**
509
+ * Checks if the element accepts text input (input, textarea, select or contenteditable).
510
+ * @param element The element to check, usually `document.activeElement`.
511
+ * @returns True if the element is editable, false otherwise.
512
+ */
513
+ static isEditable(e) {
514
+ return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement || e.isContentEditable;
515
+ }
516
+ /**
517
+ * Checks if any parent element has `aria-hidden="true"` set. use this to check if a dialog or a popover is open.
518
+ * @param element The element to start checking from.
519
+ * @returns True if any parent has `aria-hidden="true"`, false otherwise.
520
+ */
521
+ static parentHasAriaHidden(e) {
522
+ let n = e.parentElement;
523
+ for (; n; ) {
524
+ if (n.hasAttribute("aria-hidden"))
525
+ return n.getAttribute("aria-hidden") === "true";
526
+ n = n.parentElement;
527
+ }
528
+ return !1;
529
+ }
530
+ }
531
+ const Lt = { class: "relative isolate flex size-full flex-col px-md pt-12 pb-md md:px-6xl md:pb-xl" }, Rt = { class: "relative isolate mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col rounded-3xl rounded-tl-none bg-primary shadow-lg" }, jt = { class: "relative shrink-0 px-3xl pt-3xl pb-xl" }, qt = { class: "shrink-0 px-3xl" }, Wt = { class: "min-h-0 flex-1 overflow-y-auto p-3xl" }, Gt = {
532
+ key: 0,
533
+ class: "shrink-0 px-3xl py-xl text-sm text-tertiary"
534
+ }, Q = 160, X = 32, bn = /* @__PURE__ */ $({
535
+ __name: "CrmDetailView",
536
+ props: {
537
+ title: {},
538
+ createdAt: {},
539
+ lastActivityAt: {},
540
+ backgroundColor: {},
541
+ entityType: {},
542
+ tabs: {}
543
+ },
544
+ setup(c) {
545
+ const e = c, n = D(), l = le(), o = at(), f = oe(), p = b(() => e.backgroundColor === void 0 ? l.getEntityConfig(e.entityType)?.color ?? null : e.backgroundColor), d = b(() => e.backgroundColor !== null), x = {
546
+ isResizable: !0,
547
+ defaultWidth: "25rem",
548
+ variant: "bordered-overlay"
549
+ }, _ = {
550
+ icon: Qe,
551
+ label: n.t("wise_crm.shared.back"),
552
+ onClick: l.goToReturnRoute
553
+ };
554
+ return lt("Escape", (m) => {
555
+ if (m.defaultPrevented)
556
+ return;
557
+ const r = document.activeElement;
558
+ r && O.parentHasAriaHidden(r) || r && O.isEditable(r) || l.goToReturnRoute();
559
+ }), (m, r) => (a(), h(Oe, {
560
+ "primary-action": _,
561
+ class: "size-full"
562
+ }, {
563
+ default: y(() => [
564
+ i(t(Ce), {
565
+ title: e.title ?? "",
566
+ "detail-pane": x,
567
+ "is-detail-pane-open": !0,
568
+ class: "size-full",
569
+ "is-title-hidden": ""
570
+ }, {
571
+ default: y(() => [
572
+ i(R, {
573
+ color: t(l).getEntityConfig(e.entityType)?.color ?? null,
574
+ class: "size-full"
575
+ }, {
576
+ default: y(() => [
577
+ s("div", Lt, [
578
+ i(R, {
579
+ color: p.value,
580
+ class: me([d.value ? "opacity-100" : "opacity-0", "pointer-events-none absolute inset-0 -z-10 transition-opacity duration-300"]),
581
+ "aria-hidden": "true"
582
+ }, {
583
+ default: y(() => [...r[0] || (r[0] = [
584
+ s("div", { class: "size-full bg-linear-to-b from-brand-200 to-transparent to-40% dark:from-brand-900/60" }, null, -1)
585
+ ])]),
586
+ _: 1
587
+ }, 8, ["color", "class"]),
588
+ s("div", Rt, [
589
+ s("div", {
590
+ style: F({ left: `${Q}px` }),
591
+ "aria-hidden": "true",
592
+ class: "pointer-events-none absolute right-7 bottom-full h-4 rounded-t-2xl bg-primary/50"
593
+ }, null, 4),
594
+ i(Ft, {
595
+ "body-width": Q,
596
+ "curve-height": X,
597
+ style: F({ transform: `translateY(-${X}px)` }),
598
+ "aria-hidden": "true",
599
+ class: "pointer-events-none absolute top-0 left-0 block h-auto"
600
+ }, null, 8, ["style"]),
601
+ s("div", jt, [
602
+ U(m.$slots, "header")
603
+ ]),
604
+ s("div", qt, [
605
+ i(t(Ue), { variant: "underline" }, {
606
+ default: y(() => [
607
+ (a(!0), g(P, null, H(e.tabs, (u) => (a(), h(t(Ie), {
608
+ key: L(u.label),
609
+ label: L(u.label),
610
+ to: {
611
+ name: u.to,
612
+ params: t(o).params
613
+ }
614
+ }, null, 8, ["label", "to"]))), 128))
615
+ ]),
616
+ _: 1
617
+ })
618
+ ]),
619
+ s("div", Wt, [
620
+ i(t(st))
621
+ ]),
622
+ e.createdAt !== null && e.lastActivityAt !== null ? (a(), g("p", Gt, C(t(n).t("wise_crm.detail_view.footer", {
623
+ createdAt: t(f).toDate(e.createdAt.toPlainDate()),
624
+ lastActivityAt: t(f).toDate(e.lastActivityAt.toPlainDate())
625
+ })), 1)) : v("", !0)
626
+ ])
627
+ ])
628
+ ]),
629
+ _: 3
630
+ }, 8, ["color"])
631
+ ]),
632
+ "detail-pane": y(() => [
633
+ U(m.$slots, "sidebar")
634
+ ]),
635
+ _: 3
636
+ }, 8, ["title"])
637
+ ]),
638
+ _: 3
639
+ }));
640
+ }
641
+ }), Kt = { class: "flex flex-col gap-lg" }, Ot = { class: "group/header-row flex items-center justify-between gap-lg" }, Qt = { class: "flex min-w-0 flex-1 items-center gap-lg" }, Xt = {
642
+ class: "flex size-14 shrink-0 items-center justify-center rounded-xl bg-brand-100 text-lg font-semibold text-brand-700 dark:bg-brand-900 dark:text-brand-200",
643
+ "aria-hidden": "true"
644
+ }, Yt = { class: "flex min-w-0 flex-1 flex-col" }, Zt = {
645
+ key: 0,
646
+ class: "font-mono text-xs text-tertiary"
647
+ }, Jt = { class: "flex shrink-0 items-center group-has-data-name-editing/header-row:hidden" }, en = { class: "hidden items-center gap-sm md:flex" }, tn = { class: "flex items-center gap-xs md:hidden" }, nn = { class: "flex flex-wrap items-center gap-sm" }, vn = /* @__PURE__ */ $({
648
+ __name: "CrmDetailHeader",
649
+ props: {
650
+ createdAt: {},
651
+ name: {},
652
+ address: {},
653
+ email: {},
654
+ entityLabel: {},
655
+ entityType: {},
656
+ identifier: {},
657
+ mobilePhone: {},
658
+ owner: {},
659
+ phone: {},
660
+ status: {}
661
+ },
662
+ setup(c) {
663
+ const e = c, n = D(), l = le(), o = it(), f = pe(), p = b(() => e.name.split(" ").filter((u) => u.length > 0).slice(0, 2).map((u) => u.charAt(0).toUpperCase()).join("")), d = b(() => new Intl.DateTimeFormat(n.locale.value, {
664
+ month: "short",
665
+ year: "numeric"
666
+ }).format(e.createdAt.epochMilliseconds));
667
+ function x() {
668
+ o.copy(window.location.href);
669
+ }
670
+ function _(u) {
671
+ return {
672
+ left: {
673
+ icon: u,
674
+ type: "icon"
675
+ }
676
+ };
677
+ }
678
+ function m(u) {
679
+ window.location.href = u;
680
+ }
681
+ function r(u) {
682
+ window.open(`https://maps.google.com/?q=${encodeURIComponent(j.format(u))}`, "_blank", "noopener,noreferrer");
683
+ }
684
+ return (u, w) => (a(), g("div", Kt, [
685
+ s("div", Ot, [
686
+ s("div", Qt, [
687
+ s("div", Xt, C(p.value), 1),
688
+ s("div", Yt, [
689
+ U(u.$slots, "name", {}, () => [
690
+ i(t(De), {
691
+ text: e.name,
692
+ as: "h1",
693
+ class: "text-lg font-semibold text-primary"
694
+ }, null, 8, ["text"])
695
+ ]),
696
+ e.identifier !== null ? (a(), g("span", Zt, C(t(n).t("wise_crm.detail_view.identifier", { value: e.identifier })), 1)) : v("", !0)
697
+ ])
698
+ ]),
699
+ s("div", Jt, [
700
+ s("div", en, [
701
+ e.email !== null ? (a(), h(E, {
702
+ key: 0,
703
+ value: e.email,
704
+ type: "email"
705
+ }, null, 8, ["value"])) : v("", !0),
706
+ e.mobilePhone !== null || e.phone !== null ? (a(), h(E, {
707
+ key: 1,
708
+ value: e.mobilePhone ?? e.phone ?? "",
709
+ type: "phone"
710
+ }, null, 8, ["value"])) : v("", !0),
711
+ e.address !== null ? (a(), h(E, {
712
+ key: 2,
713
+ value: t(j).format(e.address),
714
+ type: "address"
715
+ }, null, 8, ["value"])) : v("", !0),
716
+ U(u.$slots, "actions"),
717
+ i(t(S), {
718
+ icon: t(q),
719
+ label: t(n).t("wise_crm.detail_view.copy_link"),
720
+ variant: "tertiary",
721
+ size: "sm",
722
+ onClick: x
723
+ }, null, 8, ["icon", "label"]),
724
+ i(t(Se), {
725
+ orientation: "vertical",
726
+ class: "mx-xs h-5"
727
+ }),
728
+ i(t(S), {
729
+ icon: t(W),
730
+ label: t(n).t("wise_crm.detail_view.close"),
731
+ variant: "tertiary",
732
+ size: "sm",
733
+ onClick: w[0] || (w[0] = (I) => t(l).goToReturnRoute())
734
+ }, null, 8, ["icon", "label"])
735
+ ]),
736
+ s("div", tn, [
737
+ i(t(ee), { "popover-align": "end" }, {
738
+ trigger: y(() => [
739
+ i(t(S), {
740
+ icon: t(ne),
741
+ label: t(n).t("wise_crm.detail_view.more_actions"),
742
+ variant: "tertiary",
743
+ size: "sm"
744
+ }, null, 8, ["icon", "label"])
745
+ ]),
746
+ content: y(() => [
747
+ i(t(z), null, {
748
+ default: y(() => [
749
+ e.email !== null ? (a(), h(t(T), {
750
+ key: 0,
751
+ config: _(t(Xe)),
752
+ label: t(n).t("wise_crm.detail_view.send_email"),
753
+ onSelect: w[1] || (w[1] = (I) => m(`mailto:${e.email}`))
754
+ }, null, 8, ["config", "label"])) : v("", !0),
755
+ e.mobilePhone !== null || e.phone !== null ? (a(), h(t(T), {
756
+ key: 1,
757
+ config: _(t(Ye)),
758
+ label: t(n).t("wise_crm.detail_view.call"),
759
+ onSelect: w[2] || (w[2] = (I) => m(`tel:${e.mobilePhone ?? e.phone}`))
760
+ }, null, 8, ["config", "label"])) : v("", !0),
761
+ e.address !== null ? (a(), h(t(T), {
762
+ key: 2,
763
+ config: _(t(Ze)),
764
+ label: t(n).t("wise_crm.detail_view.open_address"),
765
+ onSelect: w[3] || (w[3] = (I) => r(e.address))
766
+ }, null, 8, ["config", "label"])) : v("", !0),
767
+ i(t(T), {
768
+ config: _(t(q)),
769
+ label: t(n).t("wise_crm.detail_view.copy_link"),
770
+ onSelect: x
771
+ }, null, 8, ["config", "label"])
772
+ ]),
773
+ _: 1
774
+ }),
775
+ t(f)["menu-actions"] !== void 0 ? (a(), g(P, { key: 0 }, [
776
+ i(t(Te)),
777
+ i(t(z), null, {
778
+ default: y(() => [
779
+ U(u.$slots, "menu-actions")
780
+ ]),
781
+ _: 3
782
+ })
783
+ ], 64)) : v("", !0)
784
+ ]),
785
+ _: 3
786
+ }),
787
+ i(t(S), {
788
+ icon: t(W),
789
+ label: t(n).t("wise_crm.detail_view.close"),
790
+ variant: "tertiary",
791
+ size: "sm",
792
+ onClick: w[4] || (w[4] = (I) => t(l).goToReturnRoute())
793
+ }, null, 8, ["icon", "label"])
794
+ ])
795
+ ])
796
+ ]),
797
+ s("div", nn, [
798
+ e.entityLabel !== null ? (a(), h(t(N), {
799
+ key: 0,
800
+ icon: e.entityType === t(rt).BUSINESS ? t(Je) : t(et),
801
+ label: e.entityLabel,
802
+ variant: "translucent",
803
+ color: "brand"
804
+ }, null, 8, ["icon", "label"])) : v("", !0),
805
+ e.status !== null ? (a(), h(t(N), {
806
+ key: 1,
807
+ label: e.status.label,
808
+ color: e.status.color,
809
+ variant: "translucent"
810
+ }, null, 8, ["label", "color"])) : v("", !0),
811
+ U(u.$slots, "badges"),
812
+ i(t(N), {
813
+ label: t(n).t("wise_crm.detail_view.since", { date: d.value }),
814
+ variant: "outline",
815
+ color: "gray"
816
+ }, null, 8, ["label"]),
817
+ U(u.$slots, "owner", {}, () => [
818
+ e.owner !== null ? (a(), h(t(N), {
819
+ key: 0,
820
+ icon: t(tt),
821
+ label: e.owner,
822
+ variant: "outline",
823
+ color: "gray"
824
+ }, null, 8, ["icon", "label"])) : v("", !0)
825
+ ])
826
+ ])
827
+ ]));
828
+ }
829
+ }), wn = /* @__PURE__ */ $({
830
+ __name: "CrmDetailHeaderBadge",
831
+ props: {
832
+ uuid: {},
833
+ badge: {},
834
+ entity: {}
835
+ },
836
+ setup(c) {
837
+ const e = c, n = D(), l = Ne("wiseCrmHeaderBadge", {
838
+ params: {
839
+ uuid: b(() => e.uuid),
840
+ badgeKey: b(() => e.badge.key),
841
+ entity: b(() => e.entity),
842
+ // Labels are translated by the host app, so refetch them in the new locale
843
+ locale: b(() => n.locale.value)
844
+ },
845
+ queryFn: () => k.fromPromise(f())
846
+ }), o = b(() => {
847
+ if (!l.result.value.isOk())
848
+ return null;
849
+ const p = l.result.value.getValue();
850
+ if (p === null)
851
+ return null;
852
+ const d = typeof p == "string" ? {
853
+ label: p
854
+ } : p, x = d.label.trim();
855
+ return x === "" ? null : {
856
+ ...d,
857
+ label: x
858
+ };
859
+ });
860
+ async function f() {
861
+ try {
862
+ return await e.badge.getData({
863
+ uuid: e.uuid
864
+ });
865
+ } catch (p) {
866
+ return nt.error(new Error(`[wise-crm] Header badge "${e.badge.key}" failed to load`, {
867
+ cause: p
868
+ })), null;
869
+ }
870
+ }
871
+ return (p, d) => t(l).isLoading.value ? (a(), h(t(Ae), {
872
+ key: 0,
873
+ "is-animated": !0,
874
+ class: "h-6 w-16"
875
+ })) : o.value !== null ? (a(), h(t(ct), {
876
+ key: 1,
877
+ initial: { opacity: 0 },
878
+ animate: { opacity: 1 },
879
+ transition: { duration: 0.15 },
880
+ class: "flex max-w-full min-w-0"
881
+ }, {
882
+ default: y(() => [
883
+ i(t(N), {
884
+ label: o.value.label,
885
+ icon: o.value.icon ?? e.badge.icon,
886
+ color: o.value.color ?? e.badge.color,
887
+ dot: o.value.dot ?? e.badge.dot,
888
+ variant: o.value.variant ?? e.badge.variant,
889
+ class: "max-w-full"
890
+ }, null, 8, ["label", "icon", "color", "dot", "variant"])
891
+ ]),
892
+ _: 1
893
+ })) : v("", !0);
894
+ }
895
+ });
896
+ export {
897
+ ae as N,
898
+ gn as _,
899
+ hn as a,
900
+ yn as b,
901
+ bn as c,
902
+ vn as d,
903
+ wn as e,
904
+ kt as f,
905
+ xn as u
906
+ };