useyuva 0.0.9 → 0.0.11
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/README.md +24 -2
- package/dist/esm/analytics.js +1 -1
- package/dist/esm/chat.js +1 -1
- package/dist/esm/{client-p9899hvt.js → client-ebw9d6ms.js} +1 -1
- package/dist/esm/docs.js +1 -1
- package/dist/esm/index-6brgxahe.js +12 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/nuxt/runtime/analytics.js +10 -1
- package/dist/esm/react.js +1 -1
- package/dist/esm/subscribe.js +1 -1
- package/dist/esm/yuva-chat-kf9vz8r3.js +193 -0
- package/dist/types/analytics/core.d.ts +12 -3
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/client/client.d.ts +2 -0
- package/dist/types/schema.gen.d.ts +2179 -163
- package/dist/widget/yuva-subscribe-client-kba66fz1.js +11 -0
- package/dist/yuva-analytics-consent.js +1 -0
- package/dist/yuva-analytics.js +1 -1
- package/dist/yuva-chat.js +5 -5
- package/dist/yuva-docs.js +6 -6
- package/dist/yuva-subscribe.js +1 -1
- package/package.json +2 -1
- package/dist/esm/index-8hzbxjv3.js +0 -12
- package/dist/esm/yuva-chat-zzebx8pk.js +0 -193
- package/dist/widget/yuva-subscribe-client-s3cx942g.js +0 -11
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import{randomId2,createYuvaClient2}from"./index-8hzbxjv3.js";import{richText}from"./index-jdxce2se.js";import{ApiError2}from"./index-gk84nm8f.js";import{launcherOf,readStored,writeStored}from"./index-98r96a7e.js";import{setupI18n}from"@lingui/core";var messages=JSON.parse(`{"-HY5kX":["New conversation"],"-f5Tkb":["Bad"],"09Tv5j":["Reconnecting…"],"0XGLbP":["Your sign-in has expired. Reload the page and try again."],"1EICzz":["We're away right now"],"4TqZiz":["Could not send your rating. Try again."],"6Uau97":["Skip"],"6gRgw8":["Retry"],"6lGaum":["Seen"],"ASr-r0":["Show older conversations"],"Amai22":["Chat is not available right now."],"E_qvzP":["Enter a valid e-mail address."],"GQVIIl":["You seem to be offline."],"JkW3Ph":["This file type is not accepted."],"JlFcis":["Send"],"KDw4GX":["Try again"],"M62PBt":["Nobody is available right now. Leave your e-mail and we'll send the reply there too."],"N7m8E-":["Attach files"],"NBdIgR":["Comment"],"OEEQKT":["Good"],"Pwqkdw":["Loading…"],"PxYAul":["Typing…"],"RzWUUK":["Write a message…"],"S63MQu":["All conversations"],"SOk0EB":["Thanks for your feedback"],"Sad2tK":["Sending…"],"SdV5Cn":["Send us a message and we will reply here."],"UY1vmE":["Attachment"],"VggdQJ":["Usually replies in ",["duration"]],"XJURKP":["E-mail address"],"YyNOE7":["Conversation"],"ZxJcgC":["Could not save your e-mail address. Try again."],"axQ1h6":["Anything you'd like to add? (optional)"],"eOu9Px":["The file is too large."],"h69WC6":["Sent"],"iGNUZJ":["Thanks! We'll e-mail you at ",["known"]," if you're gone when we reply."],"meAa31":["No conversations yet"],"nhTADq":["We'll reply as soon as we can"],"njBr8W":["you@example.com"],"oXOSPE":["Online"],"t7TeQU":["Messages"],"tHaDPf":[["name"]," is typing…"],"tfDRzk":["Save"],"tzsBOP":["Too many attempts. Wait a moment and try again."],"uA8iBc":["How did we do?"],"upFvcp":["Not sent."],"w61W3L":["Remove ",["0"]],"xDAtGP":["Message"],"ydzYKJ":["You:"],"yz7wBu":["Close"],"zLzEI3":["Sign in to chat with us."]}`);var messages2=JSON.parse('{"-HY5kX":["Neue Unterhaltung"],"-f5Tkb":["Schlecht"],"09Tv5j":["Verbindung wird wiederhergestellt…"],"0XGLbP":["Ihre Anmeldung ist abgelaufen. Laden Sie die Seite neu und versuchen Sie es erneut."],"1EICzz":["Wir sind gerade nicht da"],"4TqZiz":["Ihre Bewertung konnte nicht gesendet werden. Versuchen Sie es erneut."],"6Uau97":["Überspringen"],"6gRgw8":["Erneut versuchen"],"6lGaum":["Gesehen"],"ASr-r0":["Ältere Unterhaltungen anzeigen"],"Amai22":["Der Chat ist gerade nicht verfügbar."],"E_qvzP":["Geben Sie eine gültige E-Mail-Adresse ein."],"GQVIIl":["Sie scheinen offline zu sein."],"JkW3Ph":["Dieser Dateityp wird nicht akzeptiert."],"JlFcis":["Senden"],"KDw4GX":["Erneut versuchen"],"M62PBt":["Gerade ist niemand erreichbar. Hinterlassen Sie Ihre E-Mail-Adresse, dann senden wir die Antwort auch dorthin."],"N7m8E-":["Dateien anhängen"],"NBdIgR":["Kommentar"],"OEEQKT":["Gut"],"Pwqkdw":["Wird geladen…"],"PxYAul":["Schreibt…"],"RzWUUK":["Nachricht schreiben…"],"S63MQu":["Alle Unterhaltungen"],"SOk0EB":["Danke für Ihr Feedback"],"Sad2tK":["Wird gesendet…"],"SdV5Cn":["Schreiben Sie uns, wir antworten hier."],"UY1vmE":["Anhang"],"VggdQJ":["Übliche Antwortzeit: ",["duration"]],"XJURKP":["E-Mail-Adresse"],"YyNOE7":["Unterhaltung"],"ZxJcgC":["Ihre E-Mail-Adresse konnte nicht gespeichert werden. Versuchen Sie es erneut."],"axQ1h6":["Möchten Sie noch etwas ergänzen? (optional)"],"eOu9Px":["Die Datei ist zu groß."],"h69WC6":["Gesendet"],"iGNUZJ":["Danke! Falls Sie nicht mehr da sind, wenn wir antworten, schreiben wir Ihnen an ",["known"],"."],"meAa31":["Noch keine Unterhaltungen"],"nhTADq":["Wir antworten so schnell wie möglich"],"njBr8W":["sie@beispiel.de"],"oXOSPE":["Online"],"t7TeQU":["Nachrichten"],"tHaDPf":[["name"]," schreibt…"],"tfDRzk":["Speichern"],"tzsBOP":["Zu viele Versuche. Warten Sie einen Moment und versuchen Sie es erneut."],"uA8iBc":["Wie zufrieden waren Sie?"],"upFvcp":["Nicht gesendet."],"w61W3L":[["0"]," entfernen"],"xDAtGP":["Nachricht"],"ydzYKJ":["Sie:"],"yz7wBu":["Schließen"],"zLzEI3":["Melden Sie sich an, um mit uns zu chatten."]}');var messages3=JSON.parse('{"-HY5kX":["Yeni konuşma"],"-f5Tkb":["Kötü"],"09Tv5j":["Yeniden bağlanıyor…"],"0XGLbP":["Oturumunuzun süresi doldu. Sayfayı yenileyip tekrar deneyin."],"1EICzz":["Şu anda uzaktayız"],"4TqZiz":["Değerlendirmeniz gönderilemedi. Tekrar deneyin."],"6Uau97":["Geç"],"6gRgw8":["Tekrar dene"],"6lGaum":["Görüldü"],"ASr-r0":["Eski konuşmaları göster"],"Amai22":["Sohbet şu anda kullanılamıyor."],"E_qvzP":["Geçerli bir e-posta adresi girin."],"GQVIIl":["Çevrimdışı görünüyorsunuz."],"JkW3Ph":["Bu dosya türü kabul edilmiyor."],"JlFcis":["Gönder"],"KDw4GX":["Tekrar dene"],"M62PBt":["Şu anda müsait kimse yok. E-posta adresinizi bırakın, yanıtı oraya da gönderelim."],"N7m8E-":["Dosya ekle"],"NBdIgR":["Yorum"],"OEEQKT":["İyi"],"Pwqkdw":["Yükleniyor…"],"PxYAul":["Yazıyor…"],"RzWUUK":["Bir mesaj yazın…"],"S63MQu":["Tüm konuşmalar"],"SOk0EB":["Geri bildiriminiz için teşekkürler"],"Sad2tK":["Gönderiliyor…"],"SdV5Cn":["Bize bir mesaj gönderin, yanıtımız burada görünecek."],"UY1vmE":["Ek"],"VggdQJ":["Genellikle ",["duration"]," içinde yanıt verir"],"XJURKP":["E-posta adresi"],"YyNOE7":["Konuşma"],"ZxJcgC":["E-posta adresiniz kaydedilemedi. Tekrar deneyin."],"axQ1h6":["Eklemek istediğiniz bir şey var mı? (isteğe bağlı)"],"eOu9Px":["Dosya çok büyük."],"h69WC6":["Gönderildi"],"iGNUZJ":["Teşekkürler! Yanıtladığımızda burada değilseniz ",["known"]," adresine e-posta göndereceğiz."],"meAa31":["Henüz konuşma yok"],"nhTADq":["En kısa sürede yanıt vereceğiz"],"njBr8W":["siz@ornek.com"],"oXOSPE":["Çevrimiçi"],"t7TeQU":["Mesajlar"],"tHaDPf":[["name"]," yazıyor…"],"tfDRzk":["Kaydet"],"tzsBOP":["Çok fazla deneme. Biraz bekleyip tekrar deneyin."],"uA8iBc":["Nasıldık?"],"upFvcp":["Gönderilemedi."],"w61W3L":[["0"]," kaldır"],"xDAtGP":["Mesaj"],"ydzYKJ":["Siz:"],"yz7wBu":["Kapat"],"zLzEI3":["Bizimle sohbet etmek için giriş yapın."]}');var styles=`
|
|
2
|
-
[hidden] { display: none !important; }
|
|
3
|
-
.header {
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
gap: 10px;
|
|
7
|
-
padding-block: 12px;
|
|
8
|
-
padding-inline: 14px 10px;
|
|
9
|
-
background: var(--yuva-accent);
|
|
10
|
-
color: var(--yuva-on-accent);
|
|
11
|
-
}
|
|
12
|
-
.heading { flex: 1; min-inline-size: 0; }
|
|
13
|
-
.title {
|
|
14
|
-
margin: 0;
|
|
15
|
-
font-size: 16px;
|
|
16
|
-
font-weight: 600;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
text-overflow: ellipsis;
|
|
19
|
-
white-space: nowrap;
|
|
20
|
-
}
|
|
21
|
-
.status { display: flex; align-items: center; gap: 6px; font-size: 13px; opacity: 0.9; }
|
|
22
|
-
.dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px rgb(255 255 255 / 0.6); }
|
|
23
|
-
.dot.away { background: #9ca3af; }
|
|
24
|
-
.avatars { display: flex; }
|
|
25
|
-
.avatars .avatar { margin-inline-start: -8px; box-shadow: 0 0 0 2px var(--yuva-accent); }
|
|
26
|
-
.avatars .avatar:first-child { margin-inline-start: 0; }
|
|
27
|
-
.avatar {
|
|
28
|
-
display: grid;
|
|
29
|
-
place-items: center;
|
|
30
|
-
flex: none;
|
|
31
|
-
inline-size: 28px;
|
|
32
|
-
block-size: 28px;
|
|
33
|
-
border-radius: 50%;
|
|
34
|
-
background: var(--yuva-soft);
|
|
35
|
-
color: var(--yuva-fg);
|
|
36
|
-
font-size: 11px;
|
|
37
|
-
font-weight: 700;
|
|
38
|
-
text-transform: uppercase;
|
|
39
|
-
}
|
|
40
|
-
.icon {
|
|
41
|
-
display: grid;
|
|
42
|
-
place-items: center;
|
|
43
|
-
flex: none;
|
|
44
|
-
inline-size: 32px;
|
|
45
|
-
block-size: 32px;
|
|
46
|
-
padding: 0;
|
|
47
|
-
border: 0;
|
|
48
|
-
border-radius: 8px;
|
|
49
|
-
background: transparent;
|
|
50
|
-
color: inherit;
|
|
51
|
-
cursor: pointer;
|
|
52
|
-
}
|
|
53
|
-
.icon:hover { background: rgb(127 127 127 / 0.18); }
|
|
54
|
-
.icon:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
|
|
55
|
-
[dir="rtl"] .flip { transform: scaleX(-1); }
|
|
56
|
-
.body { position: relative; flex: 1; min-block-size: 0; display: flex; flex-direction: column; }
|
|
57
|
-
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
|
|
58
|
-
.center { flex: 1; display: grid; place-content: center; gap: 6px; padding: 24px; text-align: center; }
|
|
59
|
-
.empty { margin: 0; font-weight: 600; }
|
|
60
|
-
.hint { margin: 0; color: var(--yuva-muted); font-size: 14px; }
|
|
61
|
-
.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
|
|
62
|
-
.item {
|
|
63
|
-
display: flex;
|
|
64
|
-
gap: 10px;
|
|
65
|
-
align-items: center;
|
|
66
|
-
inline-size: 100%;
|
|
67
|
-
padding: 10px;
|
|
68
|
-
border: 0;
|
|
69
|
-
border-radius: 10px;
|
|
70
|
-
background: transparent;
|
|
71
|
-
color: inherit;
|
|
72
|
-
font: inherit;
|
|
73
|
-
text-align: start;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
.item:hover, .item:focus-visible { background: var(--yuva-soft); outline: none; }
|
|
77
|
-
.item-main { flex: 1; min-inline-size: 0; }
|
|
78
|
-
.item-top { display: flex; gap: 8px; justify-content: space-between; }
|
|
79
|
-
.item-subject, .item-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
80
|
-
.item-subject { font-weight: 600; }
|
|
81
|
-
.item-preview { color: var(--yuva-muted); font-size: 14px; }
|
|
82
|
-
.item.unread .item-preview { color: var(--yuva-fg); font-weight: 600; }
|
|
83
|
-
.item-time { flex: none; color: var(--yuva-muted); font-size: 12px; }
|
|
84
|
-
.unread-dot { flex: none; inline-size: 9px; block-size: 9px; border-radius: 50%; background: var(--yuva-accent); }
|
|
85
|
-
.primary {
|
|
86
|
-
margin: 10px;
|
|
87
|
-
padding: 10px 14px;
|
|
88
|
-
border: 0;
|
|
89
|
-
border-radius: 10px;
|
|
90
|
-
background: var(--yuva-accent);
|
|
91
|
-
color: var(--yuva-on-accent);
|
|
92
|
-
font: inherit;
|
|
93
|
-
font-weight: 600;
|
|
94
|
-
cursor: pointer;
|
|
95
|
-
}
|
|
96
|
-
.row { display: flex; gap: 8px; align-items: flex-end; max-inline-size: 85%; }
|
|
97
|
-
.row.mine { align-self: flex-end; }
|
|
98
|
-
.row.theirs .avatar { margin-block-end: 2px; }
|
|
99
|
-
.avatar img { inline-size: 100%; block-size: 100%; border-radius: 50%; object-fit: cover; }
|
|
100
|
-
.group-gap { margin-block-start: 8px; }
|
|
101
|
-
.author { margin: 6px 0 2px; margin-inline-start: 36px; color: var(--yuva-muted); font-size: 12px; }
|
|
102
|
-
.bubble {
|
|
103
|
-
padding: 8px 12px;
|
|
104
|
-
border-radius: 16px;
|
|
105
|
-
background: var(--yuva-soft);
|
|
106
|
-
overflow-wrap: anywhere;
|
|
107
|
-
white-space: normal;
|
|
108
|
-
}
|
|
109
|
-
.mine .bubble { background: var(--yuva-accent); color: var(--yuva-on-accent); border-end-end-radius: 4px; }
|
|
110
|
-
.theirs .bubble { border-end-start-radius: 4px; }
|
|
111
|
-
.bubble a { color: inherit; text-decoration: underline; }
|
|
112
|
-
.bubble code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; padding: 1px 4px; border-radius: 4px; background: rgb(127 127 127 / 0.2); }
|
|
113
|
-
.bubble pre { margin: 4px 0; padding: 8px; border-radius: 8px; background: rgb(127 127 127 / 0.2); font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: pre-wrap; }
|
|
114
|
-
.greeting { align-self: flex-start; max-inline-size: 85%; }
|
|
115
|
-
.files { display: flex; flex-direction: column; gap: 4px; margin-block-start: 4px; }
|
|
116
|
-
.files img { display: block; max-inline-size: 100%; max-block-size: 220px; border-radius: 10px; cursor: zoom-in; }
|
|
117
|
-
.file {
|
|
118
|
-
display: inline-flex;
|
|
119
|
-
gap: 6px;
|
|
120
|
-
align-items: center;
|
|
121
|
-
padding: 6px 10px;
|
|
122
|
-
border: 1px solid currentColor;
|
|
123
|
-
border-radius: 8px;
|
|
124
|
-
background: transparent;
|
|
125
|
-
color: inherit;
|
|
126
|
-
font: inherit;
|
|
127
|
-
font-size: 13px;
|
|
128
|
-
cursor: pointer;
|
|
129
|
-
}
|
|
130
|
-
.meta { align-self: flex-end; color: var(--yuva-muted); font-size: 12px; margin-block-start: 2px; }
|
|
131
|
-
.meta.failed { color: var(--yuva-danger); }
|
|
132
|
-
.link { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
|
|
133
|
-
.typing { display: flex; gap: 6px; align-items: center; color: var(--yuva-muted); font-size: 13px; margin-block-start: 6px; }
|
|
134
|
-
.typing i { display: inline-block; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
|
|
135
|
-
.typing i:nth-child(2) { animation-delay: 0.2s; }
|
|
136
|
-
.typing i:nth-child(3) { animation-delay: 0.4s; }
|
|
137
|
-
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
|
|
138
|
-
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; } }
|
|
139
|
-
.card { margin-block-start: 10px; padding: 12px; border: 1px solid var(--yuva-border); border-radius: 12px; font-size: 14px; }
|
|
140
|
-
.card p { margin: 0 0 8px; }
|
|
141
|
-
.card form { display: flex; gap: 6px; }
|
|
142
|
-
.card input {
|
|
143
|
-
flex: 1;
|
|
144
|
-
min-inline-size: 0;
|
|
145
|
-
padding: 8px 10px;
|
|
146
|
-
border: 1px solid var(--yuva-border);
|
|
147
|
-
border-radius: 8px;
|
|
148
|
-
background: var(--yuva-bg);
|
|
149
|
-
color: inherit;
|
|
150
|
-
font: inherit;
|
|
151
|
-
}
|
|
152
|
-
.card button { padding: 8px 12px; border: 0; border-radius: 8px; background: var(--yuva-accent); color: var(--yuva-on-accent); font: inherit; font-weight: 600; cursor: pointer; }
|
|
153
|
-
.card .error { margin: 6px 0 0; color: var(--yuva-danger); }
|
|
154
|
-
.card button:disabled { opacity: 0.6; cursor: default; }
|
|
155
|
-
.rate { text-align: center; }
|
|
156
|
-
.choices { display: flex; justify-content: center; gap: 10px; }
|
|
157
|
-
.card .choice { inline-size: 44px; block-size: 44px; padding: 0; border: 1px solid var(--yuva-border); border-radius: 50%; background: var(--yuva-bg); font-size: 20px; line-height: 1; }
|
|
158
|
-
.card .choice:hover:not(:disabled), .card .choice[aria-pressed="true"] { border-color: var(--yuva-accent); box-shadow: 0 0 0 1px var(--yuva-accent); }
|
|
159
|
-
.card .choice:disabled { opacity: 1; }
|
|
160
|
-
.card .choice:focus-visible { outline: 2px solid var(--yuva-accent); outline-offset: 2px; }
|
|
161
|
-
.rate .choices + p { margin: 8px 0 0; }
|
|
162
|
-
.rate form { flex-direction: column; margin-block-start: 10px; }
|
|
163
|
-
.rate textarea { box-sizing: border-box; inline-size: 100%; padding: 8px 10px; border: 1px solid var(--yuva-border); border-radius: 8px; background: var(--yuva-bg); color: inherit; font: inherit; resize: vertical; }
|
|
164
|
-
.rate .actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
|
|
165
|
-
.card .link { padding: 0; background: none; color: var(--yuva-muted); font-weight: 400; }
|
|
166
|
-
.composer { border-block-start: 1px solid var(--yuva-border); padding: 8px; }
|
|
167
|
-
.composer form { display: flex; gap: 4px; align-items: flex-end; }
|
|
168
|
-
.composer textarea {
|
|
169
|
-
flex: 1;
|
|
170
|
-
min-inline-size: 0;
|
|
171
|
-
box-sizing: border-box;
|
|
172
|
-
block-size: 38px;
|
|
173
|
-
max-block-size: 140px;
|
|
174
|
-
padding: 8px 10px;
|
|
175
|
-
border: 0;
|
|
176
|
-
border-radius: 10px;
|
|
177
|
-
background: transparent;
|
|
178
|
-
color: inherit;
|
|
179
|
-
font: inherit;
|
|
180
|
-
resize: none;
|
|
181
|
-
outline: none;
|
|
182
|
-
}
|
|
183
|
-
.composer .icon { color: var(--yuva-muted); }
|
|
184
|
-
.composer .send { color: var(--yuva-accent); }
|
|
185
|
-
.composer .send:disabled { opacity: 0.4; cursor: default; }
|
|
186
|
-
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px 6px; }
|
|
187
|
-
.chip { display: inline-flex; gap: 4px; align-items: center; max-inline-size: 100%; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--yuva-soft); font-size: 13px; }
|
|
188
|
-
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 180px; }
|
|
189
|
-
.chip .icon { inline-size: 22px; block-size: 22px; }
|
|
190
|
-
.banner { padding: 6px 12px; background: var(--yuva-soft); color: var(--yuva-muted); font-size: 13px; text-align: center; }
|
|
191
|
-
@media (max-width: 480px) { .composer textarea, .card input, .card textarea { font-size: 16px; } }
|
|
192
|
-
.sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
193
|
-
`;var catalogs={en:messages,tr:messages3,de:messages2},maxFiles=10,groupGap=300000,icons={close:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',back:'<svg class="flip" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6"/></svg>',attach:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 11.5l-8.3 8.3a5 5 0 01-7-7L13 4.5a3.3 3.3 0 014.7 4.7l-8.3 8.3a1.7 1.7 0 01-2.4-2.4L14.5 7.6"/></svg>',send:'<svg class="flip" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3.4 20.4l17.5-7.5a1 1 0 000-1.8L3.4 3.6a1 1 0 00-1.4 1.2L4.5 12l-2.5 7.2a1 1 0 001.4 1.2zM4.5 12h7"/></svg>',file:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6v18h12V7z M14 3v4h4"/></svg>'};function el(tag,className,text){let element=document.createElement(tag);if(className)element.className=className;if(text!==void 0)element.textContent=text;return element}function iconButton(icon,label,onClick,className="icon"){let button=el("button",className);return button.type="button",button.innerHTML=icon,button.setAttribute("aria-label",label),button.title=label,button.addEventListener("click",onClick),button}var time=(value)=>Date.parse(value),byCreated=(a,b)=>time(a.created_at)-time(b.created_at),byActivity=(a,b)=>time(b.last_message_at??b.created_at)-time(a.last_message_at??a.created_at),authorKey=(m)=>m.author.type==="contact"?"contact":`${m.author.type}:${m.author.name??""}`,isImage=(a)=>/^image\/(png|jpeg|gif|webp)$/.test(a.content_type);class Chat{#host;#i18n;#client;#inbox=null;#contact=null;#phase="loading";#error="";#starting=null;#beginning=null;#conversations=new Map;#conversationCursor;#threads=new Map;#pending=[];#typing=new Map;#view=null;#reconnecting=!1;#files=[];#typingSentAt=0;#typingIdle=null;#blobs=new Map;#blobLoads=new Map;#avatars=new Map;#emailSaved=!1;#emailError="";#connectedBefore=!1;#ratings=new Map;#rateCard=el("div","card rate");#rateComment=el("textarea");#rateKey="";#rateFor=null;#header=el("header","header");#banner=el("div","banner");#body=el("div","body");#scroll=el("div","scroll");#email=el("div","card");#emailInput=el("input");#composer=el("div","composer");#chips=el("div","chips");#textarea=el("textarea");#fileInput=el("input");#sendButton;#attachButton;#live=el("div","sr");#scrollThread;#atEnd=!0;constructor(host){this.#host=host;let{server,channel}=host.config();this.#client=createYuvaClient2({server,channel:channel??"",identityToken:()=>host.identityToken()}),this.#client.on("event",(message)=>this.#event(message)),this.#client.on("connection",({state,attempt})=>{if(state!=="reconnecting")return;this.#reconnecting=attempt>0,this.#renderBanner()}),this.#client.on("session",({session,renewed})=>{if(this.#setInbox(session.inbox),this.#contact=session.contact,renewed)this.#reload()}),this.#setLocale(),this.#live.setAttribute("aria-live","polite"),this.#scroll.addEventListener("scroll",()=>{if(this.#atEnd=this.#scroll.scrollHeight-this.#scroll.scrollTop-this.#scroll.clientHeight<48,this.#scroll.scrollTop<60&&this.#view?.kind==="thread"&&this.#view.id)this.#loadMessages(this.#view.id,!0)}),this.#textarea.rows=1,this.#textarea.addEventListener("keydown",(event)=>{if(event.key==="Enter"&&!event.shiftKey&&!event.isComposing)event.preventDefault(),this.#send()}),this.#textarea.addEventListener("input",()=>{this.#autosize(),this.#syncSend(),this.#typingInput()}),this.#textarea.addEventListener("paste",(event)=>{let files=Array.from(event.clipboardData?.files??[]);if(files.length===0)return;event.preventDefault(),this.#addFiles(files)}),this.#fileInput.type="file",this.#fileInput.multiple=!0,this.#fileInput.hidden=!0,this.#fileInput.addEventListener("change",()=>{this.#addFiles(Array.from(this.#fileInput.files??[])),this.#fileInput.value=""}),this.#attachButton=iconButton(icons.attach,"",()=>this.#fileInput.click()),this.#sendButton=iconButton(icons.send,"",()=>void this.#send(),"icon send");let form=el("form");form.addEventListener("submit",(event)=>{event.preventDefault(),this.#send()}),form.append(this.#attachButton,this.#textarea,this.#sendButton,this.#fileInput),this.#composer.append(this.#chips,form),this.#emailInput.type="email",this.#emailInput.required=!0,this.#emailInput.autocomplete="email",this.#rateComment.rows=2,this.#rateComment.maxLength=2000,this.#rateComment.dir="auto",document.addEventListener("visibilitychange",this.#onVisible),window.addEventListener("online",this.#onVisible),this.#renderAll(),this.#start()}update(){this.#setLocale(),this.#renderAll()}opened(){if(this.#phase==="error"){this.#starting=null,this.#start();return}if(this.#phase==="ready")this.#client.token?this.#refreshSession():this.#preview().then(()=>this.#render()).catch(()=>{return});if(this.#render(),this.#scrollToEnd(),this.#markRead(),this.#host.config().layout==="launcher")this.#textarea.focus({preventScroll:!0})}closed(){this.#stopTyping()}identityChanged(){this.#reset(),this.#start()}async signOut(){let signingOut=this.#client.signOut();if(this.#reset(),await signingOut,this.#host.isOpen())this.#start();else this.#render()}destroy(){this.#client.reset(),this.#stopTyping(),document.removeEventListener("visibilitychange",this.#onVisible),window.removeEventListener("online",this.#onVisible);for(let url of this.#blobs.values())URL.revokeObjectURL(url)}#reset(){this.#client.reset(),this.#starting=null,this.#beginning=null,this.#inbox=null,this.#contact=null,this.#phase="loading",this.#conversations.clear(),this.#threads.clear(),this.#pending=[],this.#ratings.clear(),this.#rateKey="",this.#view=null,this.#connectedBefore=!1,this.#host.setUnread(0)}#onVisible=()=>{if(document.visibilityState!=="visible")return;this.#client.reconnect(),this.#markRead(),this.#refreshInbox()};#setLocale(){let{locale}=this.#host.config();this.#i18n=setupI18n({locale,messages:{[locale]:catalogs[locale]??messages}})}#t(descriptor){return this.#i18n._(descriptor)}#start(){return this.#starting??=(async()=>{this.#phase="loading",this.#render();let{channel}=this.#host.config();if(!channel)throw new ApiError2(0,"not_configured");if(await this.#host.identityToken()||readStored(channel).session)await this.#begin();else if(await this.#preview(),!this.#inbox?.chat.allow_anonymous)throw new ApiError2(403,"anonymous_not_allowed");if(this.#phase="ready",!this.#view){let list=this.#sorted();if(this.#view=list.length>1?{kind:"list"}:{kind:"thread",id:list[0]?.id??null},this.#view.kind==="thread"&&this.#view.id)await this.#loadMessages(this.#view.id)}this.#render(),this.#scrollToEnd(),this.#markRead()})().catch((error)=>{if(this.#starting=null,this.#refusal(error))return;this.#phase="error",this.#error=error instanceof ApiError2?error.code:"error",this.#render()}),this.#starting}async#preview(){let inbox=await this.#fetchInbox();if(!this.#client.token)this.#setInbox(inbox)}#fetchInbox(){if(!this.#host.config().channel)throw new ApiError2(0,"not_configured");return this.#client.channelSettings()}#setInbox(inbox){let{channel}=this.#host.config();this.#inbox=inbox;let launcher=launcherOf(inbox);if(this.#host.setLauncher(launcher),channel)writeStored(channel,{...readStored(channel),launcher})}async#refreshInbox(){if(this.#phase!=="ready")return;try{this.#setInbox(await this.#fetchInbox()),this.#render()}catch(error){this.#refusal(error,!0)}}#refusal(error,channelRequest=!this.#client.token){let refused=error instanceof ApiError2&&(error.code==="origin_not_allowed"||error.status===404&&channelRequest);if(refused)this.#host.refused();return refused}#begin(){return this.#beginning??=(async()=>{await this.#client.start(),await this.#loadConversations(),await this.#client.connect()})().finally(()=>{this.#beginning=null}),this.#beginning}async#refreshSession(){try{await this.#client.refresh(),this.#render()}catch{}}async#loadConversations(more=!1){let page=await this.#client.listConversations({limit:50,cursor:more?this.#conversationCursor:void 0});if(!more)this.#conversations.clear();for(let conversation of page.items)this.#conversations.set(conversation.id,conversation);this.#conversationCursor=page.next_cursor,this.#syncUnread()}async#reload(){await this.#loadConversations();let current=this.#view?.kind==="thread"?this.#view.id:null;for(let id of this.#threads.keys())if(id!==current)this.#threads.delete(id);if(current)this.#threads.delete(current),await this.#loadMessages(current);this.#render()}async#loadMessages(id,older=!1){let thread=this.#threads.get(id);if(!thread)thread={messages:[],complete:!1,loading:!1},this.#threads.set(id,thread);if(thread.loading||older&&(thread.complete||!thread.cursor))return;thread.loading=!0;let before=this.#scroll.scrollHeight-this.#scroll.scrollTop;try{let page=await this.#client.listMessages(id,{order:"desc",limit:30,cursor:older?thread.cursor:void 0}),known=new Set(thread.messages.map((m)=>m.id));thread.messages=[...thread.messages,...page.items.filter((m)=>!known.has(m.id))].sort(byCreated),thread.cursor=page.next_cursor,thread.complete=!page.next_cursor}finally{thread.loading=!1}if(older)this.#render(),this.#scroll.scrollTop=this.#scroll.scrollHeight-before}#event(message){switch(message.type){case"ready":if(this.#reconnecting=!1,this.#renderBanner(),this.#connectedBefore)this.#refreshInbox();this.#connectedBefore=!0;return;case"inbox.updated":{let asked=this.#inbox?.ask_for_rating;if(this.#setInbox(message.data),asked!==void 0&&asked!==message.data.ask_for_rating)this.#loadConversations().then(()=>this.#render()).catch(()=>{return});break}case"resync_required":this.#reload();return;case"presence":if(this.#inbox)this.#inbox={...this.#inbox,presence:message.data};break;case"conversation.created":if(!this.#conversations.has(message.data.id))this.#conversations.set(message.data.id,message.data);if(this.#view?.kind==="thread"&&this.#view.id===null&&this.#conversations.size>1)this.#view=this.#pending.some((p)=>p.conversation===null)?this.#view:{kind:"list"};this.#syncUnread();break;case"conversation.updated":{let conversation=this.#conversations.get(message.data.id),{status,can_rate,rating}=message.data;if(conversation)this.#conversations.set(conversation.id,{...conversation,status,can_rate,rating});if(!can_rate)this.#ratings.delete(message.data.id);break}case"message.created":case"message.updated":this.#upsertMessage(message.data,message.type==="message.created");break;case"read":{let conversation=this.#conversations.get(message.data.conversation_id),previous=conversation?.last_read_by_member_at;if(conversation&&(!previous||time(message.data.read_at)>time(previous)))this.#conversations.set(conversation.id,{...conversation,last_read_by_member_at:message.data.read_at});break}case"typing":{let id=message.data.conversation_id,previous=this.#typing.get(id);if(previous)clearTimeout(previous.timer);if(message.data.typing){let name=message.data.author.name??"";this.#typing.set(id,{name,timer:setTimeout(()=>this.#typing.delete(id)&&this.#render(),8000)})}else this.#typing.delete(id);break}}this.#render()}#upsertMessage(message,created){let id=message.conversation_id,thread=this.#threads.get(id);if(thread){let index=thread.messages.findIndex((m)=>m.id===message.id);if(index>=0)thread.messages[index]=message;else thread.messages=[...thread.messages,message].sort(byCreated)}if(message.client_id)this.#pending=this.#pending.filter((p)=>p.client_id!==message.client_id);let conversation=this.#conversations.get(id);if(!conversation){this.#client.getConversation(id).then((c)=>{this.#conversations.set(c.id,c),this.#syncUnread(),this.#render()}).catch(()=>{return});return}if(created){let text=message.body.replace(/\s+/g," ").trim();if(this.#conversations.set(id,{...conversation,last_message:{id:message.id,author_type:message.author.type,text:text.length>140?`${text.slice(0,139)}…`:text,created_at:message.created_at},last_message_at:message.created_at,unread:conversation.unread||message.author.type!=="contact"}),message.author.type!=="contact"){let typing=this.#typing.get(id);if(typing)clearTimeout(typing.timer);this.#typing.delete(id),this.#announce(message)}}this.#syncUnread(),this.#markRead()}#announce(message){this.#live.textContent=`${message.author.name||this.#inbox?.name||""}: ${message.body.slice(0,200)}`}#syncUnread(){let count=0;for(let conversation of this.#conversations.values())if(conversation.unread)count++;this.#host.setUnread(count)}#visibleThread(){if(!this.#host.isOpen()||document.visibilityState!=="visible")return null;return this.#view?.kind==="thread"?this.#view.id:null}#markRead(){let id=this.#visibleThread(),conversation=id?this.#conversations.get(id):void 0;if(!id||!conversation?.unread)return;this.#conversations.set(id,{...conversation,unread:!1}),this.#syncUnread(),this.#client.markRead(id).catch(()=>{let current=this.#conversations.get(id);if(current)this.#conversations.set(id,{...current,unread:!0});this.#syncUnread()})}#addFiles(files){this.#files=[...this.#files,...files].slice(0,maxFiles),this.#renderChips(),this.#syncSend(),this.#textarea.focus()}#autosize(){if(this.#textarea.style.blockSize="",this.#textarea.value==="")return;this.#textarea.style.blockSize="auto",this.#textarea.style.blockSize=`${Math.max(38,Math.min(this.#textarea.scrollHeight,140))}px`}#syncSend(){this.#sendButton.disabled=this.#textarea.value.trim()===""&&this.#files.length===0}#typingInput(){let id=this.#view?.kind==="thread"?this.#view.id:null;if(!id||this.#textarea.value.trim()===""){this.#stopTyping();return}if(Date.now()-this.#typingSentAt>3000)this.#typingSentAt=Date.now(),this.#client.setTyping(id,!0).catch(()=>{return});if(this.#typingIdle)clearTimeout(this.#typingIdle);this.#typingIdle=setTimeout(()=>this.#stopTyping(),4000)}#stopTyping(){if(this.#typingIdle)clearTimeout(this.#typingIdle);if(this.#typingIdle=null,this.#typingSentAt===0)return;this.#typingSentAt=0;let id=this.#view?.kind==="thread"?this.#view.id:null;if(id)this.#client.setTyping(id,!1).catch(()=>{return})}async#send(){if(this.#phase!=="ready"||this.#view?.kind!=="thread")return;let body=this.#textarea.value.trim(),files=this.#files;if(!body&&files.length===0)return;if(this.#view.id===null&&this.#pending.some((p)=>p.conversation===null))return;this.#stopTyping(),this.#textarea.value="",this.#files=[],this.#autosize(),this.#renderChips(),this.#syncSend();let pending={client_id:randomId2(),conversation:this.#view.id,body,files,state:"sending"};this.#pending.push(pending),this.#render(),this.#scrollToEnd(),await this.#deliver(pending)}async#deliver(pending){pending.state="sending",this.#render();let input={body:pending.body,files:pending.files,client_id:pending.client_id};try{if(pending.conversation===null){let created=await this.#client.startConversation(input),id=created.conversation.id;if(!this.#conversations.has(id))this.#conversations.set(id,created.conversation);if(!this.#threads.has(id))this.#threads.set(id,{messages:[],complete:!0,loading:!1});if(this.#view?.kind==="thread"&&this.#view.id===null)this.#view={kind:"thread",id};this.#upsertMessage(created.message,!1)}else{let message=await this.#client.sendMessage(pending.conversation,input);this.#upsertMessage(message,!0)}this.#pending=this.#pending.filter((p)=>p!==pending)}catch(error){let status=error instanceof ApiError2?error.status:0;pending.state=status===413||status===415?"refused":"failed",pending.status=status}this.#render(),this.#scrollToEnd()}async rate(id,rating,comment){try{let conversation=await this.#client.rate(id,rating,comment);return this.#conversations.set(conversation.id,conversation),this.#ratings.delete(id),this.#render(),conversation}catch(error){if(error instanceof ApiError2&&error.status===409){let current=await this.#client.getConversation(id).catch(()=>null);if(current)this.#conversations.set(current.id,current);this.#ratings.delete(id),this.#render()}throw error}}#choose(id,choice){if(this.#ratings.get(id)?.state==="sending")return;if(this.#ratings.set(id,{choice,state:"choosing"}),this.#render(),this.#rateComment.focus({preventScroll:!0}),this.#atEnd)this.#scrollToEnd()}async#submitRating(id,withComment){let draft=this.#ratings.get(id);if(!draft||draft.state==="sending")return;draft.state="sending",this.#render();try{await this.rate(id,draft.choice,withComment?this.#rateComment.value:void 0),this.#rateComment.value=""}catch(error){if(error instanceof ApiError2&&error.status===409)return;draft.state="failed",this.#render()}}async#saveEmail(){let email=this.#emailInput.value.trim();if(!email||!this.#emailInput.checkValidity()){this.#emailError=this.#t({id:"E_qvzP"}),this.#renderEmail();return}try{this.#contact=await this.#client.setEmail(email),this.#emailSaved=!0,this.#emailError=""}catch{this.#emailError=this.#t({id:"ZxJcgC"})}this.#renderEmail()}#attachmentUrl(attachment){let cached=this.#blobs.get(attachment.id);if(cached)return Promise.resolve(cached);let load=this.#blobLoads.get(attachment.id);if(!load)load=this.#client.attachment(attachment.id).then((blob)=>{let url=URL.createObjectURL(blob);return this.#blobs.set(attachment.id,url),url}),load.catch(()=>this.#blobLoads.delete(attachment.id)),this.#blobLoads.set(attachment.id,load);return load}async#download(attachment){let url=await this.#attachmentUrl(attachment),a=el("a");a.href=url,a.download=attachment.filename,a.rel="noopener",a.click()}#sorted(){return[...this.#conversations.values()].sort(byActivity)}#nobodyAvailable(){let inbox=this.#inbox;if(!inbox)return!1;return!inbox.open_now||inbox.mode==="async"||!inbox.presence?.available}#scrollToEnd(){this.#atEnd=!0,this.#scroll.scrollTop=this.#scroll.scrollHeight,requestAnimationFrame(()=>{if(this.#atEnd)this.#scroll.scrollTop=this.#scroll.scrollHeight})}#renderAll(){this.#textarea.placeholder=this.#t({id:"RzWUUK"}),this.#textarea.setAttribute("aria-label",this.#t({id:"xDAtGP"})),this.#attachButton.setAttribute("aria-label",this.#t({id:"N7m8E-"})),this.#attachButton.title=this.#t({id:"N7m8E-"}),this.#sendButton.setAttribute("aria-label",this.#t({id:"JlFcis"})),this.#sendButton.title=this.#t({id:"JlFcis"}),this.#emailInput.placeholder=this.#t({id:"njBr8W"}),this.#emailInput.setAttribute("aria-label",this.#t({id:"XJURKP"})),this.#syncSend(),this.#renderChips(),this.#render()}#render(){let panel=this.#host.panel;if(panel.childElementCount===0){let style=el("style");style.textContent=styles,panel.append(style,this.#header,this.#banner,this.#body,this.#live),this.#header.id="yuva-title",panel.setAttribute("aria-labelledby","yuva-title")}if(this.#renderHeader(),this.#renderBanner(),this.#phase!=="ready"){this.#scrollThread=void 0;let center=el("div","center");if(this.#phase==="loading")center.append(el("p","hint",this.#t({id:"Pwqkdw"})));else{center.append(el("p","empty",this.#errorText()));let retry=el("button","primary",this.#t({id:"KDw4GX"}));retry.type="button",retry.addEventListener("click",()=>{this.#starting=null,this.#start()}),center.append(retry)}this.#body.replaceChildren(center);return}if(this.#view?.kind==="list")this.#renderList();else this.#renderThread()}#errorText(){switch(this.#error){case"anonymous_not_allowed":return this.#t({id:"zLzEI3"});case"invalid_identity_token":return this.#t({id:"0XGLbP"});case"rate_limited":return this.#t({id:"tzsBOP"});case"network":return this.#t({id:"GQVIIl"});default:return this.#t({id:"Amai22"})}}#renderHeader(){let{layout}=this.#host.config(),inbox=this.#inbox,children=[],view=this.#view;if(this.#phase==="ready"&&view?.kind==="thread"&&(this.#conversations.size>1||view.id===null&&this.#conversations.size>0))children.push(iconButton(icons.back,this.#t({id:"S63MQu"}),()=>{this.#stopTyping(),this.#view={kind:"list"},this.#render()}));let heading=el("div","heading");if(heading.append(el("h2","title",inbox?.name||this.#t({id:"t7TeQU"}))),inbox){let status=el("div","status");if(inbox.mode==="live"&&inbox.open_now&&inbox.presence?.available){let avatars=el("div","avatars");for(let member of inbox.presence?.members.slice(0,3)??[]){let avatar=el("span","avatar",member.initials||"•");avatar.title=member.name,avatars.append(avatar)}status.append(avatars,el("span","dot"),el("span","",this.#t({id:"oXOSPE"})))}else if(!inbox.open_now||inbox.mode==="live")status.append(el("span","dot away"),el("span","",this.#t({id:"1EICzz"})));else status.append(el("span","",this.#replyTime(inbox.expected_reply_minutes)));heading.append(status)}if(children.push(heading),layout==="launcher")children.push(iconButton(icons.close,this.#t({id:"yz7wBu"}),()=>this.#host.close()));this.#header.replaceChildren(...children)}#replyTime(minutes){if(!minutes)return this.#t({id:"nhTADq"});let{locale}=this.#host.config(),[value,unit]=minutes<60?[minutes,"minute"]:minutes<1440?[Math.round(minutes/60),"hour"]:[Math.round(minutes/1440),"day"],duration=new Intl.NumberFormat(locale,{style:"unit",unit,unitDisplay:"long"}).format(value);return this.#t({id:"VggdQJ",values:{duration}})}#renderBanner(){this.#banner.hidden=!this.#reconnecting,this.#banner.textContent=this.#t({id:"09Tv5j"})}#renderList(){this.#scrollThread=void 0;let{locale}=this.#host.config(),list=el("ul","list"),today=new Date().toDateString();for(let conversation of this.#sorted()){let button=el("button",conversation.unread?"item unread":"item");button.type="button";let main=el("div","item-main"),top=el("div","item-top");top.append(el("span","item-subject",conversation.subject||this.#inbox?.name||this.#t({id:"YyNOE7"})));let at=new Date(conversation.last_message_at??conversation.created_at);top.append(el("span","item-time",new Intl.DateTimeFormat(locale,at.toDateString()===today?{timeStyle:"short"}:{month:"short",day:"numeric"}).format(at)));let preview=conversation.last_message?`${conversation.last_message.author_type==="contact"?this.#t({id:"ydzYKJ"})+" ":""}${conversation.last_message.text||this.#t({id:"UY1vmE"})}`:"",previewLine=el("div","item-preview",preview.replace(/\*\*|`/g,""));if(previewLine.dir="auto",main.append(top,previewLine),button.append(main),conversation.unread)button.append(el("span","unread-dot"));button.addEventListener("click",()=>void this.#openThread(conversation.id));let item=el("li");item.append(button),list.append(item)}if(this.#conversationCursor){let more=el("button","link",this.#t({id:"ASr-r0"}));more.type="button",more.style.margin="8px auto",more.style.display="block",more.addEventListener("click",()=>void this.#loadConversations(!0).then(()=>this.#render())),list.append(more)}let start=el("button","primary",this.#t({id:"-HY5kX"}));start.type="button",start.addEventListener("click",()=>{this.#view={kind:"thread",id:null},this.#render(),this.#textarea.focus()}),this.#body.replaceChildren(list,start)}async#openThread(id){if(this.#view={kind:"thread",id},this.#render(),!this.#threads.get(id)?.complete&&!this.#threads.get(id)?.messages.length)await this.#loadMessages(id).catch(()=>{return});this.#render(),this.#scrollToEnd(),this.#markRead()}#avatar(author){let avatar=el("span","avatar",author.initials||""),url=author.avatar_url,state=url?this.#avatars.get(url):!1;if(!url||state===!1)return avatar;let img=el("img");if(img.alt="",img.referrerPolicy="no-referrer",state)return img.src=url,avatar.replaceChildren(img),avatar;return img.addEventListener("load",()=>{if(this.#avatars.set(url,!0),avatar.isConnected)avatar.replaceChildren(img)}),img.addEventListener("error",()=>this.#avatars.set(url,!1)),img.src=url,avatar}#renderThread(){let view=this.#view;if(view?.kind!=="thread")return;let id=view.id,sameThread=this.#scrollThread===id,atEnd=this.#atEnd,thread=id?this.#threads.get(id):void 0,messages=thread?.messages??[],pending=this.#pending.filter((p)=>p.conversation===id),nodes=[],greeting=this.#inbox?.chat.greeting;if(!thread||thread.complete){if(greeting){let bubble=el("div","bubble greeting");bubble.append(richText(greeting)),nodes.push(bubble)}else if(messages.length===0&&pending.length===0){let center=el("div","center");center.append(el("p","empty",this.#t({id:"meAa31"})),el("p","hint",this.#t({id:"SdV5Cn"}))),nodes.push(center)}}else if(thread.loading)nodes.push(el("p","hint",this.#t({id:"Pwqkdw"})));messages.forEach((message,i)=>{let previous=messages[i-1],next=messages[i+1]??(pending.length>0?null:void 0),mine=message.author.type==="contact",starts=!previous||authorKey(previous)!==authorKey(message)||time(message.created_at)-time(previous.created_at)>groupGap,ends=next===void 0||(next===null?!mine:authorKey(next)!==authorKey(message)||time(next.created_at)-time(message.created_at)>groupGap);if(!mine&&starts&&message.author.name)nodes.push(el("div","author",message.author.name));let row=el("div",`row ${mine?"mine":"theirs"}${starts&&i>0?" group-gap":""}`);if(!mine){let avatar=this.#avatar(message.author);if(!ends)avatar.style.visibility="hidden";row.append(avatar)}let bubble=el("div","bubble");if(bubble.dir="auto",bubble.title=new Date(message.created_at).toLocaleString(this.#host.config().locale),message.body.trim())bubble.append(richText(message.body));if(message.attachments.length>0)bubble.append(this.#renderAttachments(message.attachments));if(row.append(bubble),nodes.push(row),ends){let meta=this.#formatTime(message.created_at);if(mine&&i===messages.length-1&&pending.length===0){let readAt=id?this.#conversations.get(id)?.last_read_by_member_at:void 0,seen=readAt&&time(readAt)>=time(message.created_at);meta+=` · ${seen?this.#t({id:"6lGaum"}):this.#t({id:"h69WC6"})}`}let line=el("div","meta",meta);if(!mine)line.style.alignSelf="flex-start";if(!mine)line.style.marginInlineStart="36px";nodes.push(line)}});let conversation=id?this.#conversations.get(id):void 0,rate=conversation?this.#renderRating(conversation):null;if(rate)nodes.push(rate);pending.forEach((item,i)=>{let row=el("div",`row mine${i===0&&messages.length>0&&messages[messages.length-1]?.author.type!=="contact"?" group-gap":""}`),bubble=el("div","bubble");if(bubble.dir="auto",item.body)bubble.append(richText(item.body));if(item.files.length>0){let files=el("div","files");for(let file of item.files)files.append(el("span","file",file.name||"image"));bubble.append(files)}if(row.append(bubble),nodes.push(row),item.state==="failed"){let line=el("div","meta failed",`${this.#t({id:"upFvcp"})} `),retry=el("button","link",this.#t({id:"6gRgw8"}));retry.type="button",retry.addEventListener("click",()=>void this.#deliver(item)),line.append(retry),nodes.push(line)}else if(item.state==="refused"){let reason=item.status===413?this.#t({id:"eOu9Px"}):this.#t({id:"JkW3Ph"});nodes.push(el("div","meta failed",`${this.#t({id:"upFvcp"})} ${reason}`))}else if(i===pending.length-1)nodes.push(el("div","meta",this.#t({id:"Sad2tK"})))});let typing=id?this.#typing.get(id):void 0;if(typing){let line=el("div","typing");line.append(el("i"),el("i"),el("i"));let name=typing.name;line.append(el("span","",name?this.#t({id:"tHaDPf",values:{name}}):this.#t({id:"PxYAul"}))),nodes.push(line)}let focused=this.#scroll.getRootNode().activeElement===this.#rateComment,{selectionStart,selectionEnd}=this.#rateComment;if(this.#scroll.replaceChildren(...nodes),focused&&this.#rateComment.isConnected)this.#rateComment.focus({preventScroll:!0}),this.#rateComment.setSelectionRange(selectionStart,selectionEnd);if(this.#renderEmail(),this.#body.firstChild!==this.#scroll)this.#body.replaceChildren(this.#scroll,this.#email,this.#composer);if(this.#scrollThread=id,!sameThread||atEnd)this.#scrollToEnd()}#renderRating(conversation){let rated=conversation.status==="closed"?conversation.rating:void 0,draft=conversation.can_rate&&this.#inbox?.ask_for_rating?this.#ratings.get(conversation.id):void 0;if(!rated&&!(conversation.can_rate&&this.#inbox?.ask_for_rating))return null;let card=this.#rateCard,key=[conversation.id,rated,draft?.choice,draft?.state,this.#host.config().locale].join(":");if(key===this.#rateKey)return card;if(this.#rateKey=key,this.#rateFor!==conversation.id)this.#rateFor=conversation.id,this.#rateComment.value="";let question=this.#t({id:"uA8iBc"});card.setAttribute("role","group"),card.setAttribute("aria-label",question);let choices=el("div","choices");for(let value of["good","bad"]){if(rated&&rated!==value)continue;let button=el("button","choice",value==="good"?"\uD83D\uDC4D":"\uD83D\uDC4E");button.type="button";let label=value==="good"?this.#t({id:"OEEQKT"}):this.#t({id:"-f5Tkb"});button.setAttribute("aria-label",label),button.title=label,button.setAttribute("aria-pressed",String((rated??draft?.choice)===value)),button.disabled=!!rated||draft?.state==="sending",button.addEventListener("click",()=>this.#choose(conversation.id,value)),choices.append(button)}if(rated)return card.replaceChildren(choices,el("p","",this.#t({id:"SOk0EB"}))),card;if(card.replaceChildren(el("p","",question),choices),!draft)return card;this.#rateComment.placeholder=this.#t({id:"axQ1h6"}),this.#rateComment.setAttribute("aria-label",this.#t({id:"NBdIgR"})),this.#rateComment.disabled=draft.state==="sending";let form=el("form");form.addEventListener("submit",(event)=>{event.preventDefault(),this.#submitRating(conversation.id,!0)});let skip=el("button","link",this.#t({id:"6Uau97"}));skip.type="button",skip.disabled=draft.state==="sending",skip.addEventListener("click",()=>void this.#submitRating(conversation.id,!1));let send=el("button","",draft.state==="sending"?this.#t({id:"Sad2tK"}):this.#t({id:"JlFcis"}));send.type="submit",send.disabled=draft.state==="sending";let actions=el("div","actions");if(actions.append(skip,send),form.append(this.#rateComment,actions),card.append(form),draft.state==="failed")card.append(el("p","error",this.#t({id:"4TqZiz"})));return card}#renderAttachments(attachments){let files=el("div","files");for(let attachment of attachments)if(isImage(attachment)){let img=el("img");img.alt=attachment.filename;let cached=this.#blobs.get(attachment.id);if(cached)img.src=cached;else this.#attachmentUrl(attachment).then((url)=>{img.src=url}).catch(()=>{return});img.addEventListener("load",()=>{if(this.#atEnd)this.#scroll.scrollTop=this.#scroll.scrollHeight}),img.addEventListener("click",()=>void this.#download(attachment)),files.append(img)}else{let button=el("button","file");button.type="button",button.innerHTML=icons.file,button.append(el("span","",attachment.filename)),button.addEventListener("click",()=>void this.#download(attachment)),files.append(button)}return files}#formatTime(value){return new Intl.DateTimeFormat(this.#host.config().locale,{timeStyle:"short"}).format(new Date(value))}#renderEmail(){let contact=this.#contact,chat=this.#inbox?.chat,sent=(this.#view?.kind==="thread"?this.#view.id:null)!==null||this.#pending.length>0,known=contact?.email||contact?.typed_email,show=!!chat?.ask_email_offline&&this.#nobodyAvailable()&&sent&&(!known||this.#emailSaved);if(this.#email.hidden=!show,!show)return;if(known&&this.#emailSaved){this.#email.replaceChildren(el("p","",this.#t({id:"iGNUZJ",values:{known}})));return}if(this.#email.querySelector("form")){let error=this.#email.querySelector(".error");if(error)error.textContent=this.#emailError;else if(this.#emailError)this.#email.append(el("p","error",this.#emailError));return}let form=el("form");form.noValidate=!0,form.addEventListener("submit",(event)=>{event.preventDefault(),this.#saveEmail()});let save=el("button","",this.#t({id:"tfDRzk"}));if(save.type="submit",form.append(this.#emailInput,save),this.#email.replaceChildren(el("p","",this.#t({id:"M62PBt"})),form),this.#emailError)this.#email.append(el("p","error",this.#emailError))}#renderChips(){this.#chips.hidden=this.#files.length===0,this.#chips.replaceChildren(...this.#files.map((file,index)=>{let chip=el("span","chip");return chip.append(el("span","",file.name||"image"),iconButton(icons.close,this.#t({id:"w61W3L",values:{0:file.name}}),()=>{this.#files=this.#files.filter((_,i)=>i!==index),this.#renderChips(),this.#syncSend()})),chip}))}}function mount(host){return new Chat(host)}export{mount};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
class c extends Error{status;code;constructor(e,t){super(`${e} ${t}`);this.status=e;this.code=t}}async function g(e,t,n,{method:s="GET",json:i,body:o,headers:a={},token:p,blob:r}={}){if(a={...a},p)a.Authorization=`Bearer ${p}`;let m=o;if(i!==void 0)a["Content-Type"]="application/json",m=JSON.stringify(i);let l;try{l=await e(t+n,{method:s,headers:a,body:m,credentials:"omit"})}catch{throw new c(0,"network")}if(!l.ok){let u="error";try{u=(await l.json()).code??u}catch{}throw new c(l.status,u)}if(l.status===204)return;return r?await l.blob():await l.json()}function P(e,t,n){return g(e,t,`/client/v1/channels/${encodeURIComponent(n)}/lists`)}function b(e,t,n,s){return g(e,t,`/client/v1/channels/${encodeURIComponent(n)}/subscriptions`,{method:"POST",json:s})}class C{server;socketClass;handlers;#s=null;#o=0;#p=0;#t=null;#a=!0;constructor(e,t,n){this.server=e;this.socketClass=t;this.handlers=n}get connected(){return this.#s?.readyState===1}start(){if(this.#a=!1,!this.#s)this.#r()}stop(){if(this.#a=!0,this.#t)clearTimeout(this.#t);this.#t=null;let e=this.#s;this.#s=null,e?.close(1000)}reset(){this.#o=0}nudge(){if(this.#a||this.#s)return;if(this.#t)clearTimeout(this.#t);this.#t=null,this.#r()}#r(){let e=this.handlers.token();if(!e||this.#a)return;let t=new URL(`${this.server}/client/v1/realtime`,globalThis.location?.href);if(t.protocol=t.protocol==="https:"?"wss:":"ws:",this.#o>0)t.searchParams.set("last_event_id",String(this.#o));let n;try{n=new this.socketClass(t,["yuva",`yuva.token.${e}`])}catch{this.#n();return}this.#s=n,n.onmessage=(s)=>{let i;try{i=JSON.parse(String(s.data))}catch{return}if(i.type==="ready")this.#p=0,this.#o=Math.max(this.#o,i.last_event_id);else if("id"in i&&typeof i.id==="number")this.#o=Math.max(this.#o,i.id);this.handlers.event(i)},n.onclose=(s)=>{if(this.#s!==n)return;if(this.#s=null,this.#a)return;if(s.code===1008){this.#o=0,this.handlers.sessionEnded();return}this.#n()}}#n(){if(this.#a||this.#t)return;let e=this.#p++;this.handlers.reconnecting(e);let t=Math.min(30000,1000*2**e)*(0.75+Math.random()*0.5);this.#t=setTimeout(()=>{this.#t=null,this.#r()},t)}}function I(e,t,n){let s=new URL("/account/connect",e);return s.searchParams.set("channel",t),s.searchParams.set("origin",n),s.href}function T(e){let t=e;return!!t&&typeof t.token==="string"&&t.token.startsWith("yuva_rd_")&&typeof t.expires_at==="string"&&!Number.isNaN(Date.parse(t.expires_at))&&typeof t.channel_key==="string"&&typeof t.origin==="string"&&!!t.reader&&typeof t.reader.initials==="string"}function R(e,t,{width:n=460,height:s=640}={}){let i=new URL(e).origin,o=location.origin,a=Math.max(0,(window.screenX??0)+((window.outerWidth??n)-n)/2),p=Math.max(0,(window.screenY??0)+((window.outerHeight??s)-s)/2),r=window.open(I(e,t,o),"yuva-reader",`popup=yes,width=${n},height=${s},left=${Math.round(a)},top=${Math.round(p)}`);if(!r)return Promise.reject(new c(0,"popup_blocked"));return new Promise((m,l)=>{let u=!1,f=()=>{u=!0,window.removeEventListener("message",S),clearInterval(v)},S=(h)=>{if(u||h.origin!==i||h.source&&h.source!==r)return;let d=h.data;if(!T(d)||d.channel_key!==t||d.origin!==o)return;f();try{r.close()}catch{}m({token:d.token,expires_at:d.expires_at,reader:d.reader})},v=setInterval(()=>{let h=!1;try{h=r.closed}catch{}if(!h)return;clearInterval(v),setTimeout(()=>{if(u)return;f(),l(new c(0,"sign_in_cancelled"))},300)},500);window.addEventListener("message",S)})}function x(e){return`yuva:${e}`}function w(e,t){return`yuva:reader:${e} ${t}`}function k(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();return Array.from(crypto.getRandomValues(new Uint8Array(16)),(e)=>e.toString(16).padStart(2,"0")).join("")}function M(e){try{let t=(e.split(".")[1]??"").replace(/-/g,"+").replace(/_/g,"/"),n=JSON.parse(atob(t));return typeof n.sub==="string"?n.sub:null}catch{return null}}function U(){try{let t=globalThis.localStorage;if(t)return t}catch{}let e=new Map;return{getItem:(t)=>e.get(t)??null,setItem:(t,n)=>void e.set(t,n)}}function y(e){let t=new URLSearchParams;for(let[s,i]of Object.entries(e))if(i!==void 0)t.set(s,String(i));let n=t.toString();return n?`?${n}`:""}function E(e){return e.replace(/"/g,"%22").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function _(e,t,n){let s=[];for(let[i,o]of e)s.push(`--${n}\r
|
|
2
|
-
Content-Disposition: form-data; name="${i}"\r
|
|
3
|
-
\r
|
|
4
|
-
${o}\r
|
|
5
|
-
`);for(let i of t){let o=i.name||"file";s.push(`--${n}\r
|
|
6
|
-
Content-Disposition: form-data; name="files"; filename="${E(o)}"\r
|
|
7
|
-
Content-Type: ${i.type||"application/octet-stream"}\r
|
|
8
|
-
\r
|
|
9
|
-
`,i,`\r
|
|
10
|
-
`)}return s.push(`--${n}--\r
|
|
11
|
-
`),new Blob(s)}class D{server;channel;#s;#o;#p;#t;#a;#r=null;#n=null;#m=null;#g=null;#i=null;#c;#C=new Map;constructor(e){this.server=e.server.replace(/\/+$/,""),this.channel=e.channel,this.#s=e.fetch??((t,n)=>fetch(t,n)),this.#o=e.WebSocket??globalThis.WebSocket,this.#p=e.storage??U(),this.#t=e.identityToken??null,this.#a=e.idempotencyKeys??typeof globalThis.document>"u"}get session(){return this.#n}get token(){return this.#r}get connected(){return this.#i?.connected??!1}on(e,t){let n=this.#C.get(e);if(!n)this.#C.set(e,n=new Set);return n.add(t),()=>void n.delete(t)}#l(e,t){for(let n of this.#C.get(e)??[])n(t)}stored(){try{let e=this.#p.getItem(x(this.channel));return e?JSON.parse(e):{}}catch{return{}}}#y(e){try{this.#p.setItem(x(this.channel),JSON.stringify(e))}catch{}}channelSettings(){return this.#h(`/client/v1/channels/${encodeURIComponent(this.channel)}`)}ratePage(e){return this.#h(`/client/v1/channels/${encodeURIComponent(this.channel)}/page-ratings`,{method:"POST",json:e})}lists(){return P(this.#s,this.server,this.channel)}subscribe(e){return b(this.#s,this.server,this.channel,e)}subscriptions(){return this.#e("/client/v1/subscriptions")}subscribeList(e,t){return this.#e(`/client/v1/subscriptions/${encodeURIComponent(e)}`,{method:"PUT",json:t})}unsubscribeList(e){return this.#e(`/client/v1/subscriptions/${encodeURIComponent(e)}`,{method:"DELETE"})}setIdentityToken(e){this.#t=e,this.reset()}start(){if(this.#n)return Promise.resolve(this.#n);return this.#m??=this.#P(!1).then((e)=>(this.#l("session",{session:e,renewed:!1}),e)).finally(()=>{this.#m=null}),this.#m}async refresh(){let e=await this.#e("/client/v1/session");return this.#n={...this.#n,...e},this.#l("session",{session:this.#n,renewed:!1}),this.#n}reset(){this.#i?.stop(),this.#i?.reset(),this.#m=null,this.#g=null,this.#r=null,this.#n=null}async signOut(){let e=this.#r;this.reset();let t=this.stored();if(delete t.session,this.#y(t),e)await this.#h("/client/v1/session",{method:"DELETE",token:e}).catch(()=>{return})}async connect(){if(!this.#o)throw Error("Yuva: no WebSocket in this runtime; pass options.WebSocket");if(await this.start(),this.#i??=new C(this.server,this.#o,{token:()=>this.#r,event:(e)=>{if(e.type==="ready")this.#l("connection",{state:"open",attempt:0});this.#l("event",e)},sessionEnded:()=>void this.#v().catch(()=>this.#i?.nudge()),reconnecting:(e)=>{if(this.#l("connection",{state:"reconnecting",attempt:e}),e===2)this.#e("/client/v1/session").catch(()=>{return})}}),!this.#i.connected)this.#l("connection",{state:"connecting",attempt:0});this.#i.start()}disconnect(){this.#i?.stop(),this.#l("connection",{state:"closed",attempt:0})}reconnect(){this.#i?.nudge()}listConversations(e={}){return this.#e(`/client/v1/conversations${y({...e})}`)}getConversation(e){return this.#e(`/client/v1/conversations/${encodeURIComponent(e)}`)}startConversation(e){return this.#e("/client/v1/conversations",this.#S(e))}listMessages(e,t={}){return this.#e(`/client/v1/conversations/${encodeURIComponent(e)}/messages${y({...t})}`)}sendMessage(e,t){return this.#e(`/client/v1/conversations/${encodeURIComponent(e)}/messages`,this.#S(t))}markRead(e,t){return this.#e(`/client/v1/conversations/${encodeURIComponent(e)}/read`,{method:"POST",json:t?{message_id:t}:{}})}rate(e,t,n){let s={rating:t,comment:n?.trim()||void 0};return this.#e(`/client/v1/conversations/${encodeURIComponent(e)}/rating`,{method:"POST",json:s})}setTyping(e,t){return this.#e(`/client/v1/conversations/${encodeURIComponent(e)}/typing`,{method:"POST",json:{typing:t}})}setEmail(e){return this.#e("/client/v1/contact/email",{method:"PUT",json:{email:e}})}attachment(e){return this.#e(`/client/v1/attachments/${encodeURIComponent(e)}`,{blob:!0})}sendFeedback(e){let t=e.client_id??k();return this.#e("/client/v1/feedback",{method:"POST",headers:this.#f(t),json:{...e,client_id:t}})}get reader(){if(this.#c===void 0)try{let e=this.#p.getItem(w(this.server,this.channel));this.#c=e?JSON.parse(e):null}catch{this.#c=null}if(this.#c&&Date.parse(this.#c.expires_at)<=Date.now()+30000)this.#d(null);return this.#c}#d(e){let t=this.#c?.token!==e?.token;this.#c=e;try{this.#p.setItem(w(this.server,this.channel),e?JSON.stringify(e):"")}catch{}if(t)this.#l("reader",e)}readerSignIn(e){return R(this.server,this.channel,e).then((t)=>(this.#d(t),t))}setReader(e){this.#d(e)}async readerSignOut(){let e=this.reader?.token;if(this.#d(null),e)await this.#h("/client/v1/reader-token",{method:"DELETE",token:e}).catch(()=>{return})}listDiscussions(e,t={}){return this.#u(`/client/v1/channels/${encodeURIComponent(this.channel)}/discussions${y({page:e,...t})}`,{},!1)}getDiscussion(e){return this.#u(`/client/v1/channels/${encodeURIComponent(this.channel)}/discussions/${encodeURIComponent(e)}`,{},!1)}startDiscussion(e){return this.#u("/client/v1/discussions",{method:"POST",json:e})}replyToDiscussion(e,t){return this.#u(`/client/v1/discussions/${encodeURIComponent(e)}/posts`,{method:"POST",json:t})}editDiscussionPost(e,t){return this.#u(`/client/v1/discussion-posts/${encodeURIComponent(e)}`,{method:"PATCH",json:t})}deleteDiscussionPost(e){return this.#u(`/client/v1/discussion-posts/${encodeURIComponent(e)}`,{method:"DELETE"})}voteDiscussionPost(e,t=!0){return this.#u(`/client/v1/discussion-posts/${encodeURIComponent(e)}/vote`,{method:t?"PUT":"DELETE"})}followDiscussion(e,t=!0){return this.#u(`/client/v1/discussions/${encodeURIComponent(e)}/follow`,{method:t?"PUT":"DELETE"})}acceptDiscussionAnswer(e,t){let n=`/client/v1/discussions/${encodeURIComponent(e)}/answer`;return this.#u(n,t?{method:"PUT",json:{post_id:t}}:{method:"DELETE"})}async discussionWriter(){if(this.reader)return"reader";if(this.#n)return this.#n.contact.identified?"contact":null;return await this.#t?.()?"contact":null}async#u(e,t,n=!0){let s=this.reader;if(s)try{return await this.#h(e,{...t,token:s.token})}catch(o){if(!(o instanceof c)||o.status!==401||this.#c?.token!==s.token)throw o;if(this.#d(null),n)throw new c(403,"sign_in_required")}if(await this.discussionWriter()==="contact")return this.#e(e,t);if(n)throw new c(403,"sign_in_required");return this.#h(e,t)}#f(e){return this.#a&&/^[\x20-\x7e]{1,255}$/.test(e)?{"Idempotency-Key":e}:{}}#S({body:e,subject:t,files:n=[],client_id:s=k()}){let i=this.#f(s);if(n.length===0)return{method:"POST",headers:i,json:{body:e,subject:t,client_id:s}};let o=[];if(t)o.push(["subject",t]);if(e)o.push(["body",e]);o.push(["client_id",s]);let a=`yuva-${s.replace(/[^\w-]/g,"").slice(0,60)}-${s.length}`;return i["Content-Type"]=`multipart/form-data; boundary=${a}`,{method:"POST",headers:i,body:_(o,n,a)}}#h(e,t){return g(this.#s,this.server,e,t)}async#e(e,t={},n=!0){if(!this.#r)await this.start();try{return await this.#h(e,{...t,token:this.#r})}catch(s){if(!n||!(s instanceof c)||s.status!==401)throw s;return await this.#v(),this.#e(e,t,!1)}}#v(){return this.#g??=(async()=>{let e=await this.#P(!0);if(this.#i)this.#i.stop(),this.#i.reset(),this.#i.start();this.#l("session",{session:e,renewed:!0})})().finally(()=>{this.#g=null}),this.#g}async#P(e){let t=this.stored(),n=await this.#t?.()||null,s=n?M(n):null,i=t.session;if(!e&&i&&i.sub===s&&Date.parse(i.expires_at)>Date.now()+60000)try{let r=await this.#h("/client/v1/session",{token:i.token});return this.#b(r,i.token,s)}catch(r){if(!(r instanceof c)||r.status!==401&&r.status!==403)throw r}let o=await this.#h("/client/v1/session",{method:"POST",json:{channel_key:this.channel,identity_token:n??void 0,visitor_id:t.visitor_id}}),{token:a,...p}=o;return this.#b(p,a,s)}#b(e,t,n){this.#r=t,this.#n=e;let s=this.stored();if(s.session={token:t,expires_at:e.expires_at,sub:n},e.visitor_id)s.visitor_id=e.visitor_id;else if(e.contact.identified)delete s.visitor_id;return this.#y(s),e}}function O(e){return new D(e)}export{O as createYuvaClient};
|