@runtypelabs/persona 4.17.1 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/chunk-3I2S3I5P.js +1 -0
  2. package/dist/chunk-76IELU7F.js +1 -0
  3. package/dist/chunk-EFJBUH5F.js +1 -0
  4. package/dist/chunk-PDPVORUF.js +1 -0
  5. package/dist/chunk-Q735PSZL.js +1 -0
  6. package/dist/chunk-VK6JOIYJ.js +1 -0
  7. package/dist/codegen.cjs +4 -4
  8. package/dist/codegen.js +4 -4
  9. package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
  10. package/dist/context-mentions.cjs +9 -8
  11. package/dist/context-mentions.d.cts +1212 -14
  12. package/dist/context-mentions.d.ts +1212 -14
  13. package/dist/context-mentions.js +9 -8
  14. package/dist/event-stream-view-4EZ7BGFK.js +1 -0
  15. package/dist/event-stream-view.cjs +129 -0
  16. package/dist/event-stream-view.d.cts +8384 -0
  17. package/dist/event-stream-view.d.ts +8384 -0
  18. package/dist/event-stream-view.js +129 -0
  19. package/dist/history-view-BD6OXLNA.js +898 -0
  20. package/dist/history-view.cjs +898 -0
  21. package/dist/history-view.d.cts +1461 -0
  22. package/dist/history-view.d.ts +1461 -0
  23. package/dist/history-view.js +898 -0
  24. package/dist/index.cjs +77 -77
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1987 -17
  27. package/dist/index.d.ts +1987 -17
  28. package/dist/index.global.js +67 -66
  29. package/dist/index.global.js.map +1 -1
  30. package/dist/index.js +77 -77
  31. package/dist/index.js.map +1 -1
  32. package/dist/launcher.global.js +5 -4
  33. package/dist/launcher.global.js.map +1 -1
  34. package/dist/plugin-kit.cjs +1 -1
  35. package/dist/plugin-kit.d.cts +0 -8
  36. package/dist/plugin-kit.d.ts +0 -8
  37. package/dist/plugin-kit.js +1 -1
  38. package/dist/smart-dom-reader.d.cts +1212 -14
  39. package/dist/smart-dom-reader.d.ts +1212 -14
  40. package/dist/theme-editor-preview.cjs +970 -73
  41. package/dist/theme-editor-preview.d.cts +1331 -15
  42. package/dist/theme-editor-preview.d.ts +1331 -15
  43. package/dist/theme-editor-preview.js +81 -81
  44. package/dist/theme-editor.cjs +7 -7
  45. package/dist/theme-editor.d.cts +1215 -15
  46. package/dist/theme-editor.d.ts +1215 -15
  47. package/dist/theme-editor.js +9 -9
  48. package/dist/theme-reference.cjs +1 -1
  49. package/dist/theme-reference.d.cts +226 -7
  50. package/dist/theme-reference.d.ts +226 -7
  51. package/dist/theme-reference.js +1 -1
  52. package/dist/widget.css +1 -1
  53. package/package.json +16 -4
  54. package/src/client-history-rest.test.ts +1034 -0
  55. package/src/client-visitor-history.test.ts +596 -0
  56. package/src/client.ts +1040 -24
  57. package/src/components/artifact-inline.ts +8 -1
  58. package/src/components/artifact-pane.test.ts +278 -1
  59. package/src/components/artifact-pane.ts +135 -67
  60. package/src/components/artifact-preview.test.ts +14 -1
  61. package/src/components/artifact-preview.ts +9 -0
  62. package/src/components/header-builder.ts +3 -0
  63. package/src/components/header-layouts.test.ts +171 -7
  64. package/src/components/header-layouts.ts +83 -53
  65. package/src/components/header-parts.test.ts +154 -1
  66. package/src/components/header-parts.ts +266 -138
  67. package/src/components/history-confirm-dialog.ts +177 -0
  68. package/src/components/history-shell-copy.ts +99 -0
  69. package/src/components/history-view/announcer.ts +40 -0
  70. package/src/components/history-view/copy.ts +105 -0
  71. package/src/components/history-view/css.ts +1078 -0
  72. package/src/components/history-view/grouping.test.ts +142 -0
  73. package/src/components/history-view/grouping.ts +142 -0
  74. package/src/components/history-view/icons.ts +73 -0
  75. package/src/components/history-view/rows.ts +341 -0
  76. package/src/components/history-view/state.ts +309 -0
  77. package/src/components/history-view.test.ts +2660 -0
  78. package/src/components/history-view.ts +1891 -0
  79. package/src/components/launcher-surface.test.ts +133 -0
  80. package/src/components/launcher.test.ts +18 -0
  81. package/src/components/launcher.ts +7 -7
  82. package/src/components/panel.ts +17 -7
  83. package/src/components/welcome.ts +72 -2
  84. package/src/defaults.ts +36 -3
  85. package/src/event-stream-view-bundle.test.ts +69 -0
  86. package/src/event-stream-view-entry.ts +19 -0
  87. package/src/event-stream-view-loader.ts +31 -0
  88. package/src/event-stream-view.ts +19 -0
  89. package/src/generated/runtype-openapi-contract.ts +1 -0
  90. package/src/history-render.ts +325 -0
  91. package/src/history-view-bundle.test.ts +78 -0
  92. package/src/history-view-entry.ts +41 -0
  93. package/src/history-view-loader.test.ts +30 -0
  94. package/src/history-view-loader.ts +32 -0
  95. package/src/history-view.ts +28 -0
  96. package/src/index-core.ts +50 -2
  97. package/src/index-global.ts +55 -0
  98. package/src/internal/demo-history-provider.test.ts +402 -0
  99. package/src/internal/demo-history-provider.ts +689 -0
  100. package/src/internal/history-provider-registry.ts +25 -0
  101. package/src/internal/history-provider.ts +150 -0
  102. package/src/internal/runtype-history-provider.test.ts +313 -0
  103. package/src/internal/runtype-history-provider.ts +240 -0
  104. package/src/plugin-kit.test.ts +16 -0
  105. package/src/plugin-kit.ts +13 -5
  106. package/src/plugins/types.ts +177 -1
  107. package/src/session-history.test.ts +1397 -0
  108. package/src/session.ts +1200 -26
  109. package/src/styles/widget-styles.test.ts +133 -0
  110. package/src/styles/widget.css +227 -8
  111. package/src/theme-editor/preview-utils.test.ts +19 -0
  112. package/src/theme-editor/preview-utils.ts +15 -1
  113. package/src/theme-editor/preview.ts +7 -1
  114. package/src/theme-editor/role-mappings.ts +4 -1
  115. package/src/theme-editor/sections.test.ts +168 -1
  116. package/src/theme-editor/sections.ts +136 -7
  117. package/src/theme-editor/webmcp/summary.ts +16 -2
  118. package/src/theme-reference.ts +20 -6
  119. package/src/types/theme.ts +213 -7
  120. package/src/types.ts +927 -7
  121. package/src/ui.artifact-rail-resize.test.ts +235 -0
  122. package/src/ui.attachments-drop.test.ts +1 -0
  123. package/src/ui.header-update-stability.test.ts +2 -2
  124. package/src/ui.history-chunk.test.ts +72 -0
  125. package/src/ui.history-config-provider.test.ts +318 -0
  126. package/src/ui.history-controller.test.ts +711 -0
  127. package/src/ui.history-lifecycle.test.ts +456 -0
  128. package/src/ui.history-render-hooks.test.ts +904 -0
  129. package/src/ui.history-shell.test.ts +1887 -0
  130. package/src/ui.rail-overlay.test.ts +573 -0
  131. package/src/ui.rail-resize.test.ts +284 -0
  132. package/src/ui.rebuild-composer.test.ts +21 -0
  133. package/src/ui.render-welcome.test.ts +42 -0
  134. package/src/ui.shortcuts.test.ts +166 -0
  135. package/src/ui.ts +3071 -240
  136. package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
  137. package/src/utils/artifact-file.ts +15 -0
  138. package/src/utils/artifact-gate.test.ts +4 -0
  139. package/src/utils/artifact-gate.ts +13 -17
  140. package/src/utils/artifact-resize.test.ts +28 -0
  141. package/src/utils/artifact-resize.ts +9 -2
  142. package/src/utils/buttons.ts +188 -1
  143. package/src/utils/config-merge.test.ts +91 -0
  144. package/src/utils/dropdown.ts +10 -1
  145. package/src/utils/history-messages.test.ts +284 -0
  146. package/src/utils/history-messages.ts +284 -0
  147. package/src/utils/icons.ts +3 -0
  148. package/src/utils/shortcuts.test.ts +288 -0
  149. package/src/utils/shortcuts.ts +221 -0
  150. package/src/utils/theme.test.ts +501 -4
  151. package/src/utils/theme.ts +42 -3
  152. package/src/utils/tokens.ts +153 -15
  153. package/src/utils/tooltip-timing.ts +4 -0
  154. package/src/utils/tooltip.test.ts +249 -7
  155. package/src/utils/tooltip.ts +146 -4
  156. package/src/utils/visitor-store.test.ts +425 -0
  157. package/src/utils/visitor-store.ts +337 -0
  158. package/dist/chunk-QJ4LV2KW.js +0 -1
@@ -0,0 +1,898 @@
1
+ import{b as ye,c as ot}from"./chunk-EFJBUH5F.js";import{a as rt}from"./chunk-Q735PSZL.js";import{c as n,d as T}from"./chunk-76IELU7F.js";function it(){let e=document.createElement("div");e.className="persona-history-sr-only",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-persona-history-live-region","");let r;return{element:e,announce(i){r!==void 0&&clearTimeout(r),e.textContent="",r=setTimeout(()=>{r=void 0,e.textContent=i},0)},destroy(){r!==void 0&&clearTimeout(r),e.remove()}}}var nt=`
2
+ .persona-history-view {
3
+ --persona-history-surface-bg: var(--persona-surface, #ffffff);
4
+ --persona-history-topbar-bg: var(--persona-header-bg, var(--persona-surface, #ffffff));
5
+ --persona-history-border: var(--persona-divider, var(--persona-border, #e5e7eb));
6
+ --persona-history-row-hover-bg: var(--persona-button-ghost-hover-bg, rgba(0, 0, 0, 0.04));
7
+ --persona-history-row-avatar-bg: var(--persona-header-icon-bg, var(--persona-primary, #2563eb));
8
+ --persona-history-row-active-bg: var(--persona-divider, var(--persona-border, #e5e7eb));
9
+ --persona-history-skeleton-bg: var(--persona-divider, var(--persona-border, #e5e7eb));
10
+ --persona-history-focus-ring: var(--persona-primary, #2563eb);
11
+ --persona-history-slide: 20px;
12
+ --persona-history-row-min-height: 60px;
13
+ --persona-history-topbar-min-height: 56px;
14
+ box-sizing: border-box;
15
+ display: flex;
16
+ flex-direction: column;
17
+ width: 100%;
18
+ max-width: 100%;
19
+ min-width: 0;
20
+ height: 100%;
21
+ overflow: hidden;
22
+ background: var(--persona-history-surface-bg);
23
+ color: var(--persona-text, #111827);
24
+ font-family: var(--persona-font-family, inherit);
25
+ font-size: 14px;
26
+ line-height: 1.45;
27
+ opacity: 1;
28
+ }
29
+ .persona-history-view *,
30
+ .persona-history-view *::before,
31
+ .persona-history-view *::after {
32
+ box-sizing: border-box;
33
+ }
34
+ .persona-history-view--enter .persona-history-body {
35
+ animation: persona-history-enter-body var(--persona-history-enter-ms, 180ms)
36
+ var(--persona-history-enter-easing, cubic-bezier(0, 0, 0.2, 1)) both;
37
+ }
38
+ @keyframes persona-history-enter-body {
39
+ from { opacity: 0; transform: translateX(var(--persona-history-slide)); }
40
+ to { opacity: 1; transform: none; }
41
+ }
42
+ .persona-history-view .persona-history-sr-only,
43
+ .persona-history-view--panel .persona-history-group-heading,
44
+ .persona-history-view--panel .persona-history-conversations-title,
45
+ .persona-history-view .persona-history-scope-alert[data-persona-history-scope-tone="ambient"] {
46
+ position: absolute;
47
+ width: 1px;
48
+ height: 1px;
49
+ margin: -1px;
50
+ padding: 0;
51
+ overflow: hidden;
52
+ clip: rect(0 0 0 0);
53
+ clip-path: inset(50%);
54
+ white-space: nowrap;
55
+ border: 0;
56
+ }
57
+
58
+ .persona-history-view .persona-history-topbar,
59
+ .persona-history-topbar.persona-history-topbar--shell {
60
+ display: grid;
61
+ grid-template-columns: 44px minmax(0, 1fr) 44px;
62
+ align-items: center;
63
+ gap: 4px;
64
+ }
65
+ .persona-history-view .persona-history-topbar {
66
+ min-height: var(--persona-history-topbar-min-height);
67
+ padding: 6px 8px;
68
+ background: var(--persona-history-topbar-bg);
69
+ border-bottom: 1px solid var(--persona-history-border);
70
+ }
71
+ .persona-history-view .persona-history-heading-group,
72
+ .persona-history-topbar--shell .persona-history-heading-group {
73
+ min-width: 0;
74
+ text-align: center;
75
+ }
76
+ .persona-history-view .persona-history-title,
77
+ .persona-history-topbar--shell .persona-history-title {
78
+ margin: 0;
79
+ padding: 0;
80
+ font-family: var(--persona-components-header-title-fontFamily, inherit);
81
+ font-size: var(--persona-components-header-title-fontSize, 1rem);
82
+ font-weight: var(--persona-components-header-title-fontWeight, 600);
83
+ line-height: var(--persona-components-header-title-lineHeight, 1.5rem);
84
+ color: var(--persona-header-title-fg, var(--persona-primary, #0f0f0f));
85
+ overflow: hidden;
86
+ text-overflow: ellipsis;
87
+ white-space: nowrap;
88
+ }
89
+ .persona-history-view .persona-history-caption {
90
+ position: relative;
91
+ display: flex;
92
+ align-items: center;
93
+ gap: 8px;
94
+ padding: 0 4px;
95
+ }
96
+ .persona-history-view .persona-history-scope {
97
+ flex: 1 1 auto;
98
+ margin: 0;
99
+ font-size: 12px;
100
+ line-height: 1.35;
101
+ color: var(--persona-text-muted, #6b7280);
102
+ overflow-wrap: anywhere;
103
+ }
104
+ .persona-history-view .persona-history-conversations-title {
105
+ margin: 0;
106
+ font-family: var(--persona-components-history-listHeading-fontFamily, inherit);
107
+ font-size: var(--persona-components-history-listHeading-fontSize, 14px);
108
+ font-weight: var(--persona-components-history-listHeading-fontWeight, 600);
109
+ line-height: var(--persona-components-history-listHeading-lineHeight, 20px);
110
+ letter-spacing: var(--persona-components-history-listHeading-letterSpacing, normal);
111
+ color: var(--persona-components-history-listHeading-color, var(--persona-text, #111827));
112
+ overflow: hidden;
113
+ text-overflow: ellipsis;
114
+ white-space: nowrap;
115
+ }
116
+ .persona-history-view .persona-history-scope-icon {
117
+ display: none;
118
+ }
119
+ .persona-history-view .persona-history-scope-description {
120
+ display: block;
121
+ }
122
+ .persona-history-view .persona-history-scope-alert {
123
+ display: flex;
124
+ flex-direction: column;
125
+ align-items: flex-start;
126
+ gap: 8px;
127
+ margin: 0;
128
+ padding: 10px 12px;
129
+ border: 1px solid var(--persona-history-border);
130
+ border-radius: var(--persona-radius-md, 8px);
131
+ font-size: 12px;
132
+ color: var(--persona-text-muted, #6b7280);
133
+ }
134
+ .persona-history-view .persona-history-scope-alert-title {
135
+ display: block;
136
+ font-weight: 600;
137
+ color: var(--persona-text, #111827);
138
+ }
139
+
140
+ .persona-history-view button.persona-history-icon-button,
141
+ .persona-history-topbar--shell button.persona-history-icon-button {
142
+ display: inline-flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ width: 44px;
146
+ height: 44px;
147
+ min-width: 44px;
148
+ min-height: 44px;
149
+ padding: 0;
150
+ margin: 0;
151
+ border: 0;
152
+ border-radius: var(--persona-button-ghost-radius, var(--persona-radius-md, 8px));
153
+ background: transparent;
154
+ color: var(--persona-header-action-icon-fg, var(--persona-text-muted, #6b7280));
155
+ cursor: pointer;
156
+ }
157
+ .persona-history-view button.persona-history-icon-button:hover:not(:disabled),
158
+ .persona-history-topbar--shell button.persona-history-icon-button:hover:not(:disabled) {
159
+ background: var(--persona-button-ghost-hover-bg, rgba(0, 0, 0, 0.04));
160
+ }
161
+ .persona-history-view button:focus-visible,
162
+ .persona-history-view [role="menuitem"]:focus-visible,
163
+ .persona-history-topbar--shell button:focus-visible {
164
+ outline: 2px solid var(--persona-history-focus-ring, var(--persona-primary, #2563eb));
165
+ outline-offset: 2px;
166
+ }
167
+ .persona-history-view button:disabled {
168
+ opacity: 0.55;
169
+ cursor: default;
170
+ }
171
+ .persona-history-view button.persona-history-list-options {
172
+ width: 28px;
173
+ height: 28px;
174
+ min-width: 28px;
175
+ min-height: 28px;
176
+ margin-left: auto;
177
+ }
178
+ .persona-history-view button.persona-history-list-options[aria-expanded="true"] {
179
+ background: var(--persona-button-ghost-hover-bg, rgba(0, 0, 0, 0.04));
180
+ color: var(--persona-text, #111827);
181
+ }
182
+
183
+ .persona-history-view .persona-history-body {
184
+ flex: 1 1 auto;
185
+ min-height: 0;
186
+ overflow-y: auto;
187
+ overflow-x: hidden;
188
+ padding: 12px 16px 16px;
189
+ display: flex;
190
+ flex-direction: column;
191
+ gap: 16px;
192
+ }
193
+ .persona-history-view button.persona-history-new {
194
+ display: inline-flex;
195
+ align-items: center;
196
+ gap: 8px;
197
+ max-width: 100%;
198
+ border: 1px solid transparent;
199
+ border-radius: var(--persona-button-radius, var(--persona-radius-lg, 10px));
200
+ font: inherit;
201
+ font-size: 14px;
202
+ line-height: 20px;
203
+ text-align: left;
204
+ cursor: pointer;
205
+ }
206
+ .persona-history-view button.persona-history-new span {
207
+ min-width: 0;
208
+ overflow-wrap: anywhere;
209
+ }
210
+ .persona-history-view .persona-history-list-region {
211
+ display: flex;
212
+ flex-direction: column;
213
+ gap: 16px;
214
+ min-width: 0;
215
+ }
216
+
217
+ .persona-history-view .persona-history-group-heading {
218
+ margin: 0 0 4px;
219
+ padding: 0 4px;
220
+ font-family: var(--persona-components-history-groupHeading-fontFamily, inherit);
221
+ font-size: var(--persona-components-history-groupHeading-fontSize, 12px);
222
+ font-weight: var(--persona-components-history-groupHeading-fontWeight, 600);
223
+ line-height: var(--persona-components-history-groupHeading-lineHeight, 1.35);
224
+ letter-spacing: var(--persona-components-history-groupHeading-letterSpacing, normal);
225
+ color: var(--persona-components-history-groupHeading-color, var(--persona-text-muted, #6b7280));
226
+ }
227
+ .persona-history-view ul.persona-history-list {
228
+ list-style: none;
229
+ margin: 0;
230
+ padding: 0;
231
+ }
232
+ .persona-history-view li.persona-history-item {
233
+ position: relative;
234
+ margin: 0;
235
+ padding: 0;
236
+ list-style: none;
237
+ }
238
+ .persona-history-view button.persona-history-row {
239
+ display: flex;
240
+ align-items: center;
241
+ gap: 8px;
242
+ width: 100%;
243
+ min-height: var(--persona-history-row-min-height);
244
+ padding: 10px 16px;
245
+ margin: 0;
246
+ border: 0;
247
+ border-radius: 0;
248
+ background: transparent;
249
+ color: inherit;
250
+ font: inherit;
251
+ text-align: left;
252
+ cursor: pointer;
253
+ }
254
+ .persona-history-view li.persona-history-item:hover button.persona-history-row:not(:disabled),
255
+ .persona-history-view button.persona-history-row:hover:not(:disabled) {
256
+ background: var(--persona-history-row-hover-bg);
257
+ }
258
+ .persona-history-view button.persona-history-row[aria-current="page"] {
259
+ background: var(--persona-history-row-active-bg);
260
+ }
261
+ .persona-history-view .persona-history-row-avatar {
262
+ display: flex;
263
+ flex: 0 0 auto;
264
+ align-items: center;
265
+ justify-content: center;
266
+ width: 40px;
267
+ height: 40px;
268
+ overflow: hidden;
269
+ border-radius: 16.7%;
270
+ background: var(--persona-history-row-avatar-bg);
271
+ color: var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff));
272
+ font-size: 20px;
273
+ line-height: 1;
274
+ }
275
+ .persona-history-view .persona-history-row-avatar img {
276
+ width: 100%;
277
+ height: 100%;
278
+ object-fit: cover;
279
+ }
280
+ .persona-history-view .persona-history-row-body {
281
+ flex: 1 1 auto;
282
+ min-width: 0;
283
+ line-height: 21px;
284
+ }
285
+ .persona-history-view .persona-history-row-head {
286
+ display: flex;
287
+ align-items: baseline;
288
+ gap: 8px;
289
+ min-width: 0;
290
+ }
291
+ .persona-history-view .persona-history-row-title {
292
+ flex: 1 1 auto;
293
+ min-width: 0;
294
+ font-size: 14px;
295
+ font-weight: 600;
296
+ color: var(--persona-text, #111827);
297
+ }
298
+ .persona-history-view .persona-history-truncate {
299
+ display: block;
300
+ overflow: hidden;
301
+ text-overflow: ellipsis;
302
+ white-space: nowrap;
303
+ }
304
+ .persona-history-view time.persona-history-row-time {
305
+ flex: 0 0 auto;
306
+ white-space: nowrap;
307
+ font-size: 14px;
308
+ font-weight: 400;
309
+ font-variant-numeric: tabular-nums;
310
+ color: var(--persona-text-muted, #6b7280);
311
+ }
312
+ .persona-history-view .persona-history-row-star {
313
+ flex: 0 0 auto;
314
+ display: inline-flex;
315
+ align-self: center;
316
+ color: var(--persona-text-muted, #6b7280);
317
+ }
318
+ .persona-history-view .persona-history-row-preview {
319
+ font-size: 14px;
320
+ color: var(--persona-text-muted, #6b7280);
321
+ }
322
+ .persona-history-view button.persona-history-row-menu-button {
323
+ position: absolute;
324
+ top: 50%;
325
+ right: 6px;
326
+ transform: translateY(-50%);
327
+ color: var(--persona-text-muted, #6b7280);
328
+ }
329
+ @media (hover: hover) {
330
+ .persona-history-view button.persona-history-row-menu-button {
331
+ opacity: 0;
332
+ transition: opacity 120ms ease;
333
+ }
334
+ .persona-history-view li.persona-history-item:hover time.persona-history-row-time,
335
+ .persona-history-view li.persona-history-item:focus-within time.persona-history-row-time {
336
+ opacity: 0;
337
+ }
338
+ .persona-history-view li.persona-history-item:hover button.persona-history-row-menu-button,
339
+ .persona-history-view li.persona-history-item:focus-within button.persona-history-row-menu-button {
340
+ opacity: 1;
341
+ }
342
+ }
343
+ .persona-history-view button.persona-history-row-menu-button[aria-expanded="true"] {
344
+ opacity: 1;
345
+ }
346
+ .persona-history-view button.persona-history-row-menu-button:hover:not(:disabled),
347
+ .persona-history-view button.persona-history-row-menu-button[aria-expanded="true"] {
348
+ background: linear-gradient(var(--persona-history-row-hover-bg), var(--persona-history-row-hover-bg)),
349
+ linear-gradient(var(--persona-history-row-hover-bg), var(--persona-history-row-hover-bg)),
350
+ var(--persona-history-surface-bg);
351
+ color: var(--persona-text, #111827);
352
+ }
353
+ @media (hover: hover) {
354
+ .persona-history-view li.persona-history-item:hover .persona-history-row-preview,
355
+ .persona-history-view li.persona-history-item:focus-within .persona-history-row-preview,
356
+ .persona-history-view li.persona-history-item:has(button[aria-expanded="true"]) .persona-history-row-preview {
357
+ -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 84px), transparent calc(100% - 36px));
358
+ mask-image: linear-gradient(to right, #000 calc(100% - 84px), transparent calc(100% - 36px));
359
+ }
360
+ }
361
+ .persona-history-view li.persona-history-item--no-menu:hover time.persona-history-row-time,
362
+ .persona-history-view li.persona-history-item--no-menu:focus-within time.persona-history-row-time {
363
+ opacity: 1;
364
+ }
365
+ .persona-history-view li.persona-history-item--no-menu:hover .persona-history-row-preview,
366
+ .persona-history-view li.persona-history-item--no-menu:focus-within .persona-history-row-preview,
367
+ .persona-history-view li.persona-history-item--no-menu .persona-history-row-preview {
368
+ -webkit-mask-image: none;
369
+ mask-image: none;
370
+ }
371
+ .persona-history-view .persona-history-menu {
372
+ position: absolute;
373
+ top: calc(50% + 20px);
374
+ right: 8px;
375
+ z-index: 2;
376
+ min-width: 160px;
377
+ max-width: calc(100% - 16px);
378
+ padding: 4px;
379
+ border: 1px solid var(--persona-history-border);
380
+ border-radius: var(--persona-history-menu-radius, 12px);
381
+ background: var(--persona-history-surface-bg);
382
+ background: var(--persona-history-menu-bg, color-mix(in srgb, var(--persona-history-surface-bg) 92%, #fff));
383
+ box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
384
+ }
385
+ .persona-history-view .persona-history-caption .persona-history-menu {
386
+ top: calc(100% - 2px);
387
+ right: 4px;
388
+ }
389
+ .persona-history-view--rail .persona-history-caption .persona-history-menu {
390
+ grid-row: 1 / 2;
391
+ grid-column: 1 / -1;
392
+ top: calc(100% + 2px);
393
+ right: 0;
394
+ }
395
+ .persona-history-view button.persona-history-menu-item {
396
+ display: block;
397
+ width: 100%;
398
+ min-height: 32px;
399
+ padding: 6px 10px;
400
+ border: 0;
401
+ border-radius: 8px;
402
+ background: transparent;
403
+ color: var(--persona-text, #111827);
404
+ font: inherit;
405
+ text-align: left;
406
+ cursor: pointer;
407
+ }
408
+ .persona-history-view button.persona-history-menu-item--danger {
409
+ color: var(--persona-history-danger-fg, var(--persona-palette-colors-error-600, #b91c1c));
410
+ }
411
+ .persona-history-view button.persona-history-menu-item:hover:not(:disabled) {
412
+ background: var(--persona-history-row-hover-bg);
413
+ }
414
+ .persona-history-view .persona-history-row-error {
415
+ display: flex;
416
+ flex-wrap: wrap;
417
+ align-items: center;
418
+ gap: 8px;
419
+ padding: 8px 16px 12px;
420
+ font-size: 13px;
421
+ color: var(--persona-history-danger-fg, var(--persona-palette-colors-error-600, #b91c1c));
422
+ }
423
+
424
+ .persona-history-view button.persona-history-secondary {
425
+ display: inline-flex;
426
+ align-items: center;
427
+ justify-content: center;
428
+ gap: 8px;
429
+ width: 100%;
430
+ min-height: 44px;
431
+ padding: 10px 16px;
432
+ margin: 0;
433
+ border: 1px solid var(--persona-history-border);
434
+ border-radius: var(--persona-button-radius, var(--persona-radius-lg, 10px));
435
+ background: transparent;
436
+ color: var(--persona-text, #111827);
437
+ font: inherit;
438
+ font-weight: 500;
439
+ cursor: pointer;
440
+ }
441
+ .persona-history-view button.persona-history-secondary:hover:not(:disabled) {
442
+ background: var(--persona-history-row-hover-bg);
443
+ }
444
+ .persona-history-view .persona-history-state {
445
+ display: flex;
446
+ flex-direction: column;
447
+ align-items: flex-start;
448
+ gap: 8px;
449
+ padding: 8px 4px;
450
+ }
451
+ .persona-history-view .persona-history-state-title {
452
+ margin: 0;
453
+ font-size: 14px;
454
+ font-weight: 600;
455
+ color: var(--persona-text, #111827);
456
+ }
457
+ .persona-history-view .persona-history-state-description {
458
+ margin: 0;
459
+ font-size: 13px;
460
+ color: var(--persona-text-muted, #6b7280);
461
+ overflow-wrap: anywhere;
462
+ }
463
+ .persona-history-view button.persona-history-state-action {
464
+ width: auto;
465
+ min-width: 44px;
466
+ }
467
+ .persona-history-view .persona-history-view-loading {
468
+ display: flex;
469
+ flex-direction: column;
470
+ animation: persona-history-skeleton-in 120ms ease-out 250ms both;
471
+ }
472
+ @keyframes persona-history-skeleton-in {
473
+ from { opacity: 0; }
474
+ to { opacity: 1; }
475
+ }
476
+ .persona-history-view .persona-history-skeleton-row {
477
+ display: flex;
478
+ flex-direction: column;
479
+ justify-content: center;
480
+ gap: 9px;
481
+ min-height: var(--persona-history-row-min-height);
482
+ padding: 10px 16px;
483
+ }
484
+ .persona-history-view .persona-history-skeleton-head {
485
+ display: flex;
486
+ align-items: center;
487
+ justify-content: space-between;
488
+ gap: 8px;
489
+ }
490
+ .persona-history-view .persona-history-skeleton-bar {
491
+ height: 12px;
492
+ border-radius: 999px;
493
+ background: var(--persona-history-skeleton-bg);
494
+ animation: persona-history-pulse 1400ms ease-in-out infinite;
495
+ }
496
+ .persona-history-view .persona-history-skeleton-bar--time {
497
+ flex: 0 0 auto;
498
+ width: 22px;
499
+ }
500
+ .persona-history-view .persona-history-skeleton-bar--preview {
501
+ width: 88%;
502
+ }
503
+ @keyframes persona-history-pulse {
504
+ 0%, 100% { opacity: 1; }
505
+ 50% { opacity: 0.55; }
506
+ }
507
+
508
+ .persona-history-view--panel .persona-history-list-region {
509
+ gap: 0;
510
+ }
511
+ .persona-history-view--panel .persona-history-group {
512
+ margin: 0 -16px;
513
+ }
514
+ .persona-history-view--panel button.persona-history-load-more {
515
+ margin-top: 12px;
516
+ }
517
+ .persona-history-view--panel button.persona-history-new {
518
+ order: 1;
519
+ position: sticky;
520
+ bottom: 12px;
521
+ z-index: 1;
522
+ align-self: center;
523
+ width: auto;
524
+ min-height: 40px;
525
+ padding: 10px 16px;
526
+ margin: auto 0 0;
527
+ background: var(--persona-button-primary-bg, var(--persona-primary, #2563eb));
528
+ color: var(--persona-button-primary-fg, var(--persona-text-inverse, #ffffff));
529
+ font-weight: 600;
530
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
531
+ }
532
+
533
+ .persona-history-view--rail {
534
+ --persona-history-slide: 12px;
535
+ --persona-history-surface-bg: var(--persona-container, #f7f7f8);
536
+ --persona-history-topbar-bg: transparent;
537
+ --persona-history-topbar-min-height: 48px;
538
+ --persona-history-row-min-height: 36px;
539
+ }
540
+ .persona-history-view--rail .persona-history-topbar {
541
+ grid-template-columns: minmax(0, 1fr) auto;
542
+ min-height: var(
543
+ --persona-history-rail-header-min-height,
544
+ var(--persona-header-min-height, 56px)
545
+ );
546
+ padding: 2px 6px;
547
+ background: var(
548
+ --persona-history-rail-header-bg,
549
+ var(--persona-history-surface-bg)
550
+ );
551
+ border-bottom: var(--persona-history-rail-header-border, 0);
552
+ }
553
+ .persona-history-view--rail .persona-history-heading-group {
554
+ text-align: left;
555
+ padding-left: 10px;
556
+ }
557
+ .persona-history-view--rail-right .persona-history-topbar {
558
+ grid-template-columns: auto minmax(0, 1fr);
559
+ }
560
+ .persona-history-view--rail-right .persona-history-heading-group {
561
+ padding: 0 10px 0 0;
562
+ }
563
+ .persona-history-view--rail .persona-history-topbar button.persona-history-icon-button {
564
+ width: 36px;
565
+ height: 36px;
566
+ min-width: 36px;
567
+ min-height: 36px;
568
+ color: var(--persona-text-muted, #6b7280);
569
+ }
570
+ @media (pointer: coarse) {
571
+ .persona-history-view--rail .persona-history-topbar button.persona-history-icon-button {
572
+ width: 44px;
573
+ height: 44px;
574
+ min-width: 44px;
575
+ min-height: 44px;
576
+ }
577
+ .persona-history-view button.persona-history-menu-item {
578
+ min-height: 44px;
579
+ padding: 10px 12px;
580
+ }
581
+ .persona-history-view .persona-history-row-preview {
582
+ -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 84px), transparent calc(100% - 36px));
583
+ mask-image: linear-gradient(to right, #000 calc(100% - 84px), transparent calc(100% - 36px));
584
+ }
585
+ .persona-history-view button.persona-history-list-options {
586
+ width: 40px;
587
+ height: 40px;
588
+ min-width: 40px;
589
+ min-height: 40px;
590
+ }
591
+ }
592
+ .persona-history-view--rail .persona-history-title {
593
+ font-family: var(--persona-components-history-railHeader-title-fontFamily, inherit);
594
+ font-size: var(--persona-components-history-railHeader-title-fontSize, 14px);
595
+ font-weight: var(--persona-components-history-railHeader-title-fontWeight, 600);
596
+ line-height: var(--persona-components-history-railHeader-title-lineHeight, inherit);
597
+ letter-spacing: var(--persona-components-history-railHeader-title-letterSpacing, normal);
598
+ color: var(
599
+ --persona-components-history-railHeader-title-color,
600
+ var(--persona-text, #111827)
601
+ );
602
+ }
603
+ .persona-history-view .persona-history-heading-brand {
604
+ display: flex;
605
+ align-items: center;
606
+ gap: 8px;
607
+ min-width: 0;
608
+ }
609
+ .persona-history-view .persona-history-brand-mark {
610
+ display: flex;
611
+ flex: none;
612
+ align-items: center;
613
+ justify-content: center;
614
+ }
615
+ .persona-history-view .persona-history-brand-mark > img,
616
+ .persona-history-view .persona-history-brand-mark > svg {
617
+ width: 20px;
618
+ height: 20px;
619
+ object-fit: contain;
620
+ }
621
+ .persona-history-view .persona-history-wordmark {
622
+ min-width: 0;
623
+ overflow: hidden;
624
+ color: var(--persona-text, #111827);
625
+ font-size: 14px;
626
+ font-weight: 600;
627
+ text-overflow: ellipsis;
628
+ white-space: nowrap;
629
+ }
630
+ .persona-history-view .persona-history-toggle-brand {
631
+ display: none;
632
+ }
633
+ .persona-history-view--rail-collapsed .persona-history-back--branded .persona-history-toggle-brand {
634
+ display: flex;
635
+ }
636
+ .persona-history-view--rail-collapsed .persona-history-back--branded > svg {
637
+ display: none;
638
+ }
639
+ .persona-history-view--rail-collapsed .persona-history-back--branded:hover .persona-history-toggle-brand,
640
+ .persona-history-view--rail-collapsed .persona-history-back--branded:focus-visible .persona-history-toggle-brand {
641
+ display: none;
642
+ }
643
+ .persona-history-view--rail-collapsed .persona-history-back--branded:hover > svg,
644
+ .persona-history-view--rail-collapsed .persona-history-back--branded:focus-visible > svg {
645
+ display: block;
646
+ }
647
+ @media (pointer: coarse) {
648
+ .persona-history-view--rail-collapsed .persona-history-back--branded .persona-history-toggle-brand {
649
+ display: none;
650
+ }
651
+ .persona-history-view--rail-collapsed .persona-history-back--branded > svg {
652
+ display: block;
653
+ }
654
+ }
655
+ .persona-history-view--rail .persona-history-body {
656
+ gap: 8px;
657
+ padding: 4px 0 12px;
658
+ }
659
+ .persona-history-view--rail .persona-history-caption,
660
+ .persona-history-view--rail .persona-history-scope-alert,
661
+ .persona-history-view--rail .persona-history-state {
662
+ padding-right: 16px;
663
+ padding-left: 16px;
664
+ }
665
+ .persona-history-view--rail .persona-history-caption {
666
+ display: grid;
667
+ grid-template-columns: minmax(0, 1fr) auto;
668
+ /* Explicit rows: the abspos menu is grid-placed into row 1, and abspos
669
+ grid placement only resolves against explicit lines (implicit/auto ends
670
+ fall back to the padding-box edge, i.e. below the scope line). */
671
+ grid-template-rows: auto auto;
672
+ align-items: center;
673
+ row-gap: 2px;
674
+ }
675
+ .persona-history-view--rail .persona-history-conversations-title {
676
+ grid-row: 1;
677
+ grid-column: 1;
678
+ }
679
+ .persona-history-view--rail .persona-history-caption button.persona-history-list-options {
680
+ grid-row: 1;
681
+ grid-column: 2;
682
+ margin-left: 0;
683
+ }
684
+ .persona-history-view--rail .persona-history-scope {
685
+ grid-row: 2;
686
+ grid-column: 1 / -1;
687
+ display: flex;
688
+ align-items: center;
689
+ gap: 6px;
690
+ }
691
+ .persona-history-view--rail .persona-history-scope[hidden] {
692
+ display: none;
693
+ }
694
+ .persona-history-view--rail .persona-history-scope-title {
695
+ min-width: 0;
696
+ overflow: hidden;
697
+ text-overflow: ellipsis;
698
+ white-space: nowrap;
699
+ }
700
+ .persona-history-view--rail .persona-history-scope[data-persona-history-identity="browser_only"] .persona-history-scope-icon {
701
+ display: flex;
702
+ flex: none;
703
+ align-items: center;
704
+ }
705
+ .persona-history-view--rail.persona-history-view--has-nav .persona-history-caption {
706
+ margin-top: 4px;
707
+ padding-top: 12px;
708
+ border-top: 1px solid var(--persona-history-border);
709
+ }
710
+ .persona-history-view--rail button.persona-history-new {
711
+ width: calc(100% - 12px);
712
+ min-height: 36px;
713
+ padding: 6px 10px;
714
+ margin: 0 6px;
715
+ border-radius: 10px;
716
+ background: transparent;
717
+ color: inherit;
718
+ font-weight: 500;
719
+ }
720
+ .persona-history-view--rail button.persona-history-new:hover:not(:disabled) {
721
+ background: var(--persona-history-row-hover-bg);
722
+ }
723
+ .persona-history-view--rail .persona-history-list-region {
724
+ gap: 24px;
725
+ }
726
+ .persona-history-view .persona-history-nav {
727
+ display: flex;
728
+ flex-direction: column;
729
+ gap: 2px;
730
+ }
731
+ .persona-history-view .persona-history-nav--footer {
732
+ margin-top: auto;
733
+ }
734
+ .persona-history-view .persona-history-nav[hidden] {
735
+ display: none;
736
+ }
737
+ .persona-history-view button.persona-history-nav-item {
738
+ display: flex;
739
+ align-items: center;
740
+ gap: 8px;
741
+ width: calc(100% - 12px);
742
+ min-height: 36px;
743
+ padding: 6px 10px;
744
+ margin: 0 6px;
745
+ border: 0;
746
+ border-radius: 10px;
747
+ background: transparent;
748
+ color: inherit;
749
+ font: inherit;
750
+ text-align: left;
751
+ cursor: pointer;
752
+ }
753
+ .persona-history-view button.persona-history-nav-item:hover:not(:disabled) {
754
+ background: var(--persona-history-row-hover-bg);
755
+ }
756
+ .persona-history-view .persona-history-nav-icon {
757
+ display: flex;
758
+ flex: none;
759
+ align-items: center;
760
+ justify-content: center;
761
+ width: 20px;
762
+ height: 20px;
763
+ color: var(--persona-text-muted, #6b7280);
764
+ }
765
+ .persona-history-view .persona-history-nav-icon > * {
766
+ width: 20px;
767
+ height: 20px;
768
+ object-fit: contain;
769
+ }
770
+ .persona-history-view .persona-history-nav-label {
771
+ flex: 1 1 auto;
772
+ min-width: 0;
773
+ }
774
+ .persona-history-view .persona-history-nav-badge {
775
+ flex: none;
776
+ padding: 0 6px;
777
+ border-radius: 999px;
778
+ background: var(--persona-history-row-hover-bg);
779
+ color: var(--persona-text-muted, #6b7280);
780
+ font-size: 11px;
781
+ line-height: 18px;
782
+ }
783
+ .persona-history-view--rail .persona-history-group-heading {
784
+ margin: 0 0 6px;
785
+ padding: 0 16px;
786
+ font-size: var(--persona-components-history-groupHeading-fontSize, 13px);
787
+ font-weight: var(--persona-components-history-groupHeading-fontWeight, 500);
788
+ line-height: var(--persona-components-history-groupHeading-lineHeight, 20px);
789
+ }
790
+ .persona-history-view--rail .persona-history-row-avatar,
791
+ .persona-history-view--rail .persona-history-row-preview,
792
+ .persona-history-view--rail time.persona-history-row-time {
793
+ display: none;
794
+ }
795
+ .persona-history-view--rail button.persona-history-row {
796
+ min-height: 36px;
797
+ padding: 6px 10px;
798
+ margin: 0 6px;
799
+ width: calc(100% - 12px);
800
+ border-radius: 10px;
801
+ }
802
+ .persona-history-view--rail .persona-history-row-title {
803
+ font-weight: 400;
804
+ }
805
+ .persona-history-view--rail button.persona-history-row-menu-button {
806
+ right: 10px;
807
+ width: 28px;
808
+ height: 28px;
809
+ min-width: 28px;
810
+ min-height: 28px;
811
+ }
812
+ .persona-history-view--rail .persona-history-skeleton-row {
813
+ padding: 6px 16px;
814
+ }
815
+ .persona-history-view--rail .persona-history-skeleton-bar--preview,
816
+ .persona-history-view--rail .persona-history-skeleton-bar--time {
817
+ display: none;
818
+ }
819
+ .persona-history-view--rail-collapsed .persona-history-topbar {
820
+ grid-template-columns: minmax(0, 1fr);
821
+ justify-items: center;
822
+ padding: 2px;
823
+ }
824
+ .persona-history-view--rail-collapsed .persona-history-heading-group,
825
+ .persona-history-view--rail-collapsed .persona-history-body > :not(.persona-history-new):not(.persona-history-nav) {
826
+ display: none;
827
+ }
828
+ .persona-history-view--rail-collapsed button.persona-history-new {
829
+ width: 36px;
830
+ padding: 0;
831
+ margin: 0 auto;
832
+ justify-content: center;
833
+ }
834
+ .persona-history-view--rail-collapsed button.persona-history-new span {
835
+ display: none;
836
+ }
837
+ .persona-history-view--rail-collapsed .persona-history-nav .persona-history-group-heading,
838
+ .persona-history-view--rail-collapsed button.persona-history-nav-item:not(.persona-history-nav-item--icon),
839
+ .persona-history-view--rail-collapsed .persona-history-nav-label,
840
+ .persona-history-view--rail-collapsed .persona-history-nav-badge {
841
+ display: none;
842
+ }
843
+ .persona-history-view--rail-collapsed button.persona-history-nav-item {
844
+ width: 36px;
845
+ padding: 0;
846
+ margin: 0 auto;
847
+ justify-content: center;
848
+ }
849
+
850
+ [data-persona-history-suppressed] { display: none !important; }
851
+ .persona-history-header-host {
852
+ display: flex;
853
+ flex: 1 1 auto;
854
+ align-self: stretch;
855
+ align-items: center;
856
+ min-width: 0;
857
+ }
858
+ .persona-history-rail-host {
859
+ transition: flex-basis 180ms cubic-bezier(0, 0, 0.2, 1);
860
+ }
861
+ .persona-history-topbar.persona-history-topbar--shell {
862
+ flex: 1 1 auto;
863
+ min-width: 0;
864
+ grid-template-columns: var(--persona-header-control-size, 44px) minmax(0, 1fr) var(--persona-header-control-size, 44px);
865
+ }
866
+ .persona-history-topbar--shell button.persona-history-icon-button {
867
+ width: var(--persona-header-control-size, 44px);
868
+ height: var(--persona-header-control-size, 44px);
869
+ min-width: var(--persona-header-control-size, 44px);
870
+ min-height: var(--persona-header-control-size, 44px);
871
+ }
872
+ .persona-history-topbar--shell button.persona-history-icon-button svg {
873
+ width: var(--persona-header-control-icon-size, 20px);
874
+ height: var(--persona-header-control-icon-size, 20px);
875
+ }
876
+ @media (pointer: coarse) {
877
+ .persona-history-topbar--shell button.persona-history-icon-button {
878
+ min-width: 40px;
879
+ min-height: 40px;
880
+ }
881
+ }
882
+ .persona-history-topbar--shell.persona-history-topbar--shell-enter {
883
+ animation: persona-history-header-fade 120ms cubic-bezier(0, 0, 0.2, 1) both;
884
+ }
885
+ @keyframes persona-history-header-fade {
886
+ from { opacity: 0; }
887
+ to { opacity: 1; }
888
+ }
889
+
890
+ @media (prefers-reduced-motion: reduce) {
891
+ .persona-history-view--enter .persona-history-body { animation: none; }
892
+ .persona-history-topbar--shell.persona-history-topbar--shell-enter {
893
+ animation: none;
894
+ }
895
+ .persona-history-view .persona-history-skeleton-bar { animation: none; }
896
+ .persona-history-rail-host { transition: none; }
897
+ }
898
+ `;var ue={...ot,emptyTitle:"No conversations yet",emptyDescription:"Start a conversation and it will show up here.",errorTitle:"Could not load conversations",errorDescription:"Something went wrong. Please try again.",retryLabel:"Retry",rateLimitedTitle:"Too many requests",rateLimitedDescription:"Please wait a moment before trying again.",groupStarred:"Starred",groupToday:"Today",groupYesterday:"Yesterday",groupPrevious7Days:"Previous 7 days",groupPrevious30Days:"Previous 30 days",groupMonthYear:"{month} {year}",browserOnlyTitle:"On this device",browserOnlyDescription:"Another browser or device keeps its own separate history.",verifyingTitle:"Checking your account",verifyingDescription:"Looking for messages linked to your account.",verifiedTitle:"Available across signed-in devices",verifiedDescription:"This list refreshes when the chat opens rather than syncing live.",authenticationRequiredTitle:"Sign in to see your messages",authenticationRequiredDescription:"Your session expired. Sign in again to load account history.",identityProviderFailedTitle:"Account history is unavailable",identityProviderFailedDescription:"We could not verify your account, so account history is not shown here.",proofNotAdmittedTitle:"Account history is unavailable",proofNotAdmittedDescription:"This assistant is not set up to accept your account identity.",retryIdentityLabel:"Try again",backLabel:"Back to conversation",closeLabel:"Close conversation list",loadingLabel:"Loading conversations",loadMoreLabel:"Load more",loadingMoreLabel:"Loading more conversations",conversationsTitle:"Conversations",rowActionsLabel:"Conversation options",listOptionsLabel:"Conversation options",deleteConversationLabel:"Delete",clearHistoryLabel:"Delete all conversations",resetIdentityLabel:"Forget this device",messageCountLabel:"{count} messages",messageCountLabelOne:"1 message",conversationRemovedNotice:"Conversation deleted.",historyClearedNotice:"All conversations were deleted.",unavailableTitle:"Conversation history is unavailable",unavailableDescription:"Try again later.",newConversationRequiredTitle:"Start a new conversation",newConversationRequiredDescription:"The previous conversation is gone. Start a new one to keep chatting.",rateLimitedWaitDescription:"You can try again in {seconds} seconds.",openFailedLabel:"Could not open that conversation.",deleteFailedLabel:"Could not delete that conversation.",relativeNow:"now",relativeMinutes:"{value}m",relativeHours:"{value}h",relativeDays:"{value}d",relativeWeeks:"{value}w",relativeYears:"{value}y"};function he(e){if(!e)return ue;let r={...ue};for(let[i,s]of Object.entries(e))typeof s=="string"&&s.length>0&&(r[i]=s);return r}function A(e,r){return e.replace(/\{(\w+)\}/g,(i,s)=>s in r?String(r[s]):i)}var Pe=864e5;function Vt(e){let r=new Date(e);return r.setHours(0,0,0,0),r.getTime()}function _e(e,r){let i=Date.parse(e);return Number.isFinite(i)?i:r}function Ot(e,r){let i=_e(e,r),s=Vt(r);if(i>=s)return"today";if(i>=s-Pe)return"yesterday";if(i>=s-7*Pe)return"previous-7-days";if(i>=s-30*Pe)return"previous-30-days";let l=new Date(i);return`month:${l.getFullYear()}-${l.getMonth()}`}function qt(e,r,i,s){if(e==="today")return s.groupToday;if(e==="yesterday")return s.groupYesterday;if(e==="previous-7-days")return s.groupPrevious7Days;if(e==="previous-30-days")return s.groupPrevious30Days;let l=new Date(_e(r,i));return A(s.groupMonthYear,{month:l.toLocaleString(void 0,{month:"long"}),year:l.getFullYear()})}function st(e,r,i,s="time"){let l=e.filter(h=>h.starred),p=l.length>0?[{key:"starred",label:i.groupStarred,items:l}]:[];if(s==="none"){let h=e.filter(y=>!y.starred);return h.length>0&&p.push({key:"recent",label:i.conversationsTitle,items:h}),p}for(let h of e){if(h.starred)continue;let y=Ot(h.updatedAt,r),u=p[p.length-1];if(u&&u.key===y){u.items.push(h);continue}p.push({key:y,label:qt(y,h.updatedAt,r,i),items:[h]})}return p}function at(e,r,i){let s=Math.max(0,r-_e(e,r)),l=Math.floor(s/6e4);if(l<1)return i.relativeNow;if(l<60)return A(i.relativeMinutes,{value:l});let p=Math.floor(l/60);if(p<24)return A(i.relativeHours,{value:p});let h=Math.floor(p/24);if(h<7)return A(i.relativeDays,{value:h});let y=Math.floor(h/7);return h<365?A(i.relativeWeeks,{value:y}):A(i.relativeYears,{value:Math.floor(h/365)})}function lt(e,r){return e===1?r.messageCountLabelOne:A(r.messageCountLabel,{count:e})}var me="http://www.w3.org/2000/svg",Ft={"arrow-left":["m12 19-7-7 7-7","M19 12H5"],plus:["M5 12h14","M12 5v14"],star:["m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z"],x:["M18 6 6 18","m6 6 12 12"],"panel-left":["M9 3v18"],monitor:["M8 21h8","M12 17v4"],ellipsis:[]},zt={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function _(e,r=20){let i=document.createElementNS(me,"svg");if(i.setAttribute("width",String(r)),i.setAttribute("height",String(r)),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false"),e==="ellipsis"){for(let l of[12,19,5]){let p=document.createElementNS(me,"circle");p.setAttribute("cx",String(l)),p.setAttribute("cy","12"),p.setAttribute("r","1"),i.appendChild(p)}return i}let s=zt[e];if(s){let l=document.createElementNS(me,"rect");l.setAttribute("x",String(s[0])),l.setAttribute("y",String(s[1])),l.setAttribute("width",String(s[2])),l.setAttribute("height",String(s[3])),l.setAttribute("rx","2"),i.appendChild(l)}for(let l of Ft[e]){let p=document.createElementNS(me,"path");p.setAttribute("d",l),i.appendChild(p)}return i}var $t=/^(https?:|\/|data:)/i;function Kt(e){let r=n("span",{className:"persona-history-row-avatar",attrs:{"aria-hidden":"true"}});return $t.test(e)?r.appendChild(n("img",{attrs:{src:e,alt:"",loading:"lazy"}})):r.textContent=e,r}var Bt=e=>`row:${e}`,Wt=e=>`menu:${e}`,te=e=>`menu-item:${e}`;function pt(e){let{conversation:r,copy:i,busy:s,pending:l}=e,p=s||l!==null,h=r.title.trim().length>0,y=r.starred?(()=>{let M=_("star",11);return M.setAttribute("fill","currentColor"),M.setAttribute("stroke-width","1"),n("span",{className:"persona-history-row-star"},M,n("span",{className:"persona-history-sr-only",text:i.groupStarred}))})():null,u=n("div",{className:"persona-history-row-head"},n("span",{className:"persona-history-row-title persona-history-truncate",text:h?r.title:r.preview??""}),y,n("time",{className:"persona-history-row-time",attrs:{datetime:r.updatedAt},text:at(r.updatedAt,e.nowMs,i)})),S=h&&r.preview?n("span",{className:"persona-history-row-preview persona-history-truncate",text:r.preview}):null,b=n("button",{className:T("persona-history-row",e.active&&"persona-history-row--active",l&&`persona-history-row--${l}`),attrs:{type:"button","data-persona-history-focus":Bt(r.id),"data-persona-history-conversation":r.id,...e.active?{"aria-current":"page"}:{},...p?{"aria-disabled":"true"}:{},...l?{"aria-busy":"true"}:{}}},e.avatar?Kt(e.avatar):null,n("div",{className:"persona-history-row-body"},u,S,n("span",{className:"persona-history-row-count persona-history-sr-only",text:lt(r.messageCount,i)})));b.addEventListener("click",()=>{p||e.onOpen()});let oe=e.showDelete?Ie({className:"persona-history-row-menu-button",label:`${i.rowActionsLabel}: ${r.title}`,focusKey:Wt(r.id),open:e.menuOpen,inert:p,onToggle:e.onToggleMenu}):null;return n("li",{className:T("persona-history-item",!e.showDelete&&"persona-history-item--no-menu"),attrs:{"data-persona-history-item":r.id}},b,oe,e.menuOpen&&e.showDelete?Yt(e):null,e.error?Gt(e.error,i,r.id):null)}function Yt(e){let{conversation:r,copy:i}=e;return Ve({label:`${i.rowActionsLabel}: ${r.title}`,items:[{label:i.deleteConversationLabel,focusKey:te(r.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function Ie(e){let r=n("button",{className:T("persona-history-icon-button",e.className),attrs:{type:"button","aria-label":e.label,"aria-haspopup":"menu","aria-expanded":e.open?"true":"false","data-persona-history-focus":e.focusKey,...e.inert?{"aria-disabled":"true"}:{}}});r.appendChild(_("ellipsis",e.iconSize));let i=()=>r.getAttribute("aria-disabled")==="true";return r.addEventListener("click",s=>{s.stopPropagation(),!i()&&e.onToggle()}),r.addEventListener("keydown",s=>{s.key!=="ArrowDown"&&s.key!=="ArrowUp"||(s.preventDefault(),!(i()||r.getAttribute("aria-expanded")==="true")&&e.onToggle())}),r}function Ve(e){let r=n("div",{className:"persona-history-menu",attrs:{role:"menu","aria-label":e.label}});for(let i of e.items){let s=n("button",{className:T("persona-history-menu-item",i.danger&&"persona-history-menu-item--danger"),text:i.label,attrs:{type:"button",role:"menuitem",tabindex:"0","data-persona-history-focus":i.focusKey}});s.addEventListener("click",()=>{e.onCloseMenu(),i.onSelect()}),r.appendChild(s)}return r.addEventListener("keydown",i=>{let s=Array.from(r.querySelectorAll('[role="menuitem"]'));if(s.length===0)return;let l=s.indexOf(document.activeElement);if(i.key==="Tab"){e.onCloseMenu({restoreFocus:!0});return}if(i.key==="ArrowDown"){i.preventDefault(),s[(l+1+s.length)%s.length]?.focus();return}if(i.key==="ArrowUp"){i.preventDefault(),s[(l-1+s.length)%s.length]?.focus();return}if(i.key==="Home"){i.preventDefault(),s[0]?.focus();return}i.key==="End"&&(i.preventDefault(),s[s.length-1]?.focus())}),r}function Gt(e,r,i){let s=n("button",{className:"persona-history-secondary persona-history-state-action",text:r.retryLabel,attrs:{type:"button","data-persona-history-focus":`row-retry:${i}`}});return s.addEventListener("click",e.retry),n("div",{className:"persona-history-row-error",attrs:{role:"alert"}},n("span",{text:e.message}),s)}function jt(e){switch(e){case"authentication_failed":case"authentication_required":case"identity_provider_failed":case"proof_not_admitted":case"unsupported_scope":case"unavailable":return e;default:return"unknown"}}function dt(e){if(ye(e)){if(e.code==="rate_limited")return{kind:"rate_limited",retryAfterSeconds:e.retryAfterSeconds??0};let r=jt(e.code);return{kind:"error",reason:r,retryable:r!=="unsupported_scope"}}return{kind:"error",reason:"unknown",retryable:!0}}function Ut(e,r){switch(e.state){case"authentication_required":return{title:r.authenticationRequiredTitle,description:r.authenticationRequiredDescription};case"identity_provider_failed":return{title:r.identityProviderFailedTitle,description:r.identityProviderFailedDescription};case"configuration_error":return{title:r.proofNotAdmittedTitle,description:r.proofNotAdmittedDescription};default:return null}}function Xt(e,r){switch(e){case"authentication_required":case"authentication_failed":return{title:r.authenticationRequiredTitle,description:r.authenticationRequiredDescription};case"identity_provider_failed":return{title:r.identityProviderFailedTitle,description:r.identityProviderFailedDescription};case"proof_not_admitted":case"unsupported_scope":return{title:r.proofNotAdmittedTitle,description:r.proofNotAdmittedDescription};case"unavailable":return{title:r.unavailableTitle,description:r.unavailableDescription};default:return{title:r.errorTitle,description:r.errorDescription}}}function ve(e,r,i,s){let l=n("button",{className:"persona-history-secondary persona-history-state-action",text:e,attrs:{type:"button","data-persona-history-focus":r,...i?{"aria-disabled":"true"}:{}}});return l.addEventListener("click",()=>{i||s()}),l}function re(e,r,i,s,l){return n("div",{className:"persona-history-state",attrs:{"data-persona-history-state":e,...l?{role:"alert"}:{role:"status"}}},n("p",{className:"persona-history-state-title",text:r}),n("p",{className:"persona-history-state-description",text:i}),s)}function Zt(e){let r=["42%","58%","34%"],i=["94%","78%","88%"],s=[0,1,2].map(l=>n("div",{className:"persona-history-skeleton-row",attrs:{"aria-hidden":"true"}},n("div",{className:"persona-history-skeleton-head"},n("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--title",style:{width:r[l]}}),n("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--time"})),n("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--preview",style:{width:i[l]}})));return n("div",{className:"persona-history-view-loading",attrs:{"data-persona-history-state":"loading",role:"status","aria-label":e.loadingLabel}},...s)}function ct(e){let{state:r,copy:i,busy:s}=e;if(r.kind==="loading")return Zt(i);if(r.kind==="empty"){let y=Ut(e.identityStatus,i);return y?re("identity",y.title,y.description,e.onRetry?ve(i.retryIdentityLabel,"state-retry",s,e.onRetry):null,!0):re("empty",i.emptyTitle,i.emptyDescription,null,!1)}if(r.kind==="rate_limited"){let y=r.retryAfterSeconds>0?A(i.rateLimitedWaitDescription,{seconds:r.retryAfterSeconds}):i.rateLimitedDescription;return re("rate_limited",i.rateLimitedTitle,y,e.onRetry?ve(i.retryLabel,"state-retry",s,e.onRetry):null,!1)}if(r.kind==="new_conversation_required")return re("new_conversation_required",i.newConversationRequiredTitle,i.newConversationRequiredDescription,e.onStartNew?ve(i.newConversationLabel,"state-retry",s,e.onStartNew):null,!0);let{title:l,description:p}=Xt(r.reason,i),h=r.reason==="authentication_required"||r.reason==="authentication_failed"||r.reason==="identity_provider_failed"?i.retryIdentityLabel:i.retryLabel;return re("error",l,p,r.retryable&&e.onRetry?ve(h,"state-retry",s,e.onRetry):null,!0)}var Jt=25,F="persona:list-options",Qt=180,yt=120,er=160,tr="cubic-bezier(0.4, 0, 1, 1)",rr={panel:20,rail:12},or=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,ir=e=>e.finished?e.finished.then(()=>{},()=>{}):Promise.resolve();function ge(e){return`${e.state}:${"reason"in e?e.reason:""}`}function ut(e,r){switch(e.state){case"verified":return{title:r.verifiedTitle,description:r.verifiedDescription,pending:!1};case"verifying":case"resetting":return{title:r.verifyingTitle,description:r.verifyingDescription,pending:!0};case"authentication_required":return{title:r.authenticationRequiredTitle,description:r.authenticationRequiredDescription,pending:!1};case"identity_provider_failed":return{title:r.identityProviderFailedTitle,description:r.identityProviderFailedDescription,pending:!1};case"configuration_error":return{title:r.proofNotAdmittedTitle,description:r.proofNotAdmittedDescription,pending:!1};case"unavailable":return{title:r.unavailableTitle,description:r.unavailableDescription,pending:!1};default:return{title:r.browserOnlyTitle,description:r.browserOnlyDescription,pending:!1}}}function nr(e){return e.state==="verified"||e.state==="browser_only"}function sr(e){return e.state==="authentication_required"||e.state==="identity_provider_failed"||e.state==="configuration_error"}function ht(e){let r=he(e.copy),i=e.now??(()=>Date.now()),s=e.pageSize??Jt,l=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,p=[],h=null,y={kind:"loading",phase:"initial"},u=null,S=e.activeConversationId,b=e.provider.getIdentityStatus(),oe=ge(b),x=null,M=!1,m=!1,Y=0,k=e.presentation,mt=e.collapsible!==!1,R=e.collapsed===!0,Oe=e.railSide==="right",G=e.renderDom!==!1,I=new Map,E=null,fe=it(),ie=t=>{!G&&e.onAnnounce?e.onAnnounce(t):fe.announce(t)},w=()=>u!==null,qe=`${l}-body`,f=n("button",{className:"persona-history-icon-button persona-history-back",attrs:{type:"button"}}),j=()=>k==="rail"&&mt,ne,vt=()=>{if(e.railBrand){if(!j()){f.classList.remove("persona-history-back--branded");return}if(ne===void 0){let t=e.railBrand(!0);ne=t?n("span",{className:"persona-history-brand-mark persona-history-toggle-brand",attrs:{"aria-hidden":"true"}},t):null}ne&&(f.classList.add("persona-history-back--branded"),f.appendChild(ne))}},be=()=>{let t=j(),o=k==="rail";f.setAttribute("data-persona-history-focus",t?"collapse":"close"),f.setAttribute("aria-label",t?R?r.expandLabel:r.collapseLabel:o?r.closeLabel:r.backLabel),t?(f.setAttribute("aria-expanded",R?"false":"true"),f.setAttribute("aria-controls",qe),e.collapseShortcut?.aria&&f.setAttribute("aria-keyshortcuts",e.collapseShortcut.aria)):(f.removeAttribute("aria-expanded"),f.removeAttribute("aria-controls"),f.removeAttribute("aria-keyshortcuts")),f.replaceChildren(_(t?"panel-left":o?"x":"arrow-left")),vt()};be(),f.addEventListener("click",()=>{j()?e.onToggleCollapse?.():e.onClose()});let we=n("h2",{className:"persona-history-title",text:r.viewTitle,attrs:{id:l}}),Fe=n("span",{className:"persona-history-scope-title"}),z=n("p",{className:"persona-history-scope"},n("span",{className:"persona-history-scope-icon",attrs:{"aria-hidden":"true"}},_("monitor",14)),Fe),se=n("div",{className:"persona-history-heading-group"},we),ze=!1,ae,xe=()=>{let t=k==="rail",o=t?e.renderRailHeader:void 0,a=null,c=o!==void 0;if(o)try{a=o({collapsed:R,defaultTitle:r.viewTitle})}catch(d){c=!1,ze||(ze=!0,console.warn("[persona] history rail renderHeader threw",d))}if(!c&&t&&e.railBrand){if(ae===void 0){let d=e.railBrand(!1);ae=d?n("span",{className:"persona-history-heading-brand",attrs:{"aria-hidden":"true"}},n("span",{className:"persona-history-brand-mark"},d),n("span",{className:"persona-history-wordmark",text:r.viewTitle})):null}ae&&(c=!0,a=ae)}we.classList.toggle("persona-history-sr-only",c),se.replaceChildren(we),a&&se.appendChild(a)};xe();let $=n("button",{className:"persona-history-icon-button persona-history-new-icon",attrs:{type:"button","data-persona-history-focus":"new-icon","aria-label":r.newConversationLabel}});$.appendChild(_("plus")),$.addEventListener("click",()=>{ee()});let gt=[f,$].map(t=>e.attachTooltip?.({anchor:t,text:()=>t.getAttribute("aria-label")??"",...t===f&&e.collapseShortcut?{hint:()=>j()?e.collapseShortcut.hint:""}:{}})),C=n("div",{className:"persona-history-topbar"}),$e=null,He=()=>{let t=k==="rail",o=t?Oe?"rail-right":"rail":"panel";o!==$e&&($e=o,o==="rail"?C.append(se,f):C.append(f,se),t?$.remove():C.appendChild($),v.classList.toggle("persona-history-view--rail-right",o==="rail-right"))},V=n("div",{className:"persona-history-scope-alert"}),Ke=`${l}-scope`,ft=_("plus",18),Se=n("button",{className:"persona-history-new",attrs:{type:"button","data-persona-history-focus":"new"}},ft,n("span",{text:r.newConversationLabel}));Se.addEventListener("click",()=>{ee()});let ke=n("div",{className:"persona-history-list-region"}),Be=e.showDeleteAll!==!1,We=!!e.provider.resetDevice,Ye=e.listActions??[],O=Be||We||Ye.length>0?Ie({className:"persona-history-list-options",label:r.listOptionsLabel,focusKey:`menu:${F}`,open:!1,inert:!0,iconSize:16,onToggle:()=>Qe(F)}):null,bt=n("h3",{className:"persona-history-conversations-title",text:r.conversationsTitle}),K=n("div",{className:"persona-history-caption",attrs:{"data-persona-history-item":F}},bt,e.showScopeStatus?z:null,O),B=n("div",{className:"persona-history-body",attrs:{id:qe}},e.showScopeStatus?V:null,Se,K,ke),U=e.headerPlacement??"inline";U==="external"&&C.classList.add("persona-history-topbar--shell","persona-history-topbar--shell-enter");let v=n("div",{className:T("persona-history-view",`persona-history-view--${e.presentation}`,"persona-history-view--enter"),attrs:{role:"region","aria-labelledby":l,"data-persona-history-presentation":e.presentation}},fe.element,U==="inline"?C:null,B),Ce=()=>{v.classList.toggle("persona-history-view--rail-collapsed",R&&j())};Ce(),He();let wt=(t,o)=>{let a=`${l}-s${o}`,c=n("div",{className:T("persona-history-nav",t.placement==="footer"&&"persona-history-nav--footer"),attrs:{role:"group","data-persona-rail-section":t.id,...t.title?{"aria-labelledby":a}:{"aria-label":t.id}}});t.title&&c.appendChild(n("h3",{className:"persona-history-group-heading",text:t.title,attrs:{id:a}}));for(let d of t.items){let H=d.iconNode?.()??null,P=n("button",{className:T("persona-history-nav-item",H&&"persona-history-nav-item--icon"),attrs:{type:"button","aria-label":d.label,"data-persona-rail-item":d.id}},H?n("span",{className:"persona-history-nav-icon"},H):null,n("span",{className:"persona-history-nav-label persona-history-truncate",text:d.label}),d.badge?n("span",{className:"persona-history-nav-badge",text:d.badge}):null);P.addEventListener("click",()=>d.onSelect()),c.appendChild(P)}return c},X=null,Ge=null,Le=()=>{!X||!G||k!=="rail"||R===Ge||(Ge=R,e.railSections.forEach((t,o)=>{if(!t.render)return;let a=X[o],c=t.title?a.firstElementChild:null,d=null;try{d=t.render(R)}catch(H){t.render=void 0,console.warn("[persona] history rail section threw",t.id,H)}a.replaceChildren(...c?[c]:[],...d?[d]:[]),a.hidden=!d}))},je=()=>{let t=e.railSections;if(v.classList.toggle("persona-history-view--has-nav",k==="rail"&&!!t?.some(o=>o.placement==="above-conversations")),!!t?.length){if(k!=="rail"){X?.forEach(o=>o.remove());return}X??(X=t.map(wt));for(let o of["above-conversations","below-conversations","footer"]){let a=o==="above-conversations"?K.parentNode===B?K:ke:null;t.forEach((c,d)=>{c.placement===o&&B.insertBefore(X[d],a)})}Le()}};je(),rt(v,"persona-history-view",nt);let Ue=(t,o)=>{let a=v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(t),c=Number.parseFloat(a??"");return Number.isFinite(c)&&c>=0?c:o},xt=(t,o)=>v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(t).trim()||o,Z=null,q=()=>{Z!==null&&(clearTimeout(Z),Z=null),v.removeEventListener("animationend",q),v.classList.remove("persona-history-view--enter")};v.addEventListener("animationend",q),Z=setTimeout(()=>{Z=setTimeout(q,Ue("--persona-history-enter-ms",Qt)+60)},0);let J=null,Q=()=>{J!==null&&(clearTimeout(J),J=null),C.classList.remove("persona-history-topbar--shell-enter")},Ht=()=>{Q(),C.classList.add("persona-history-topbar--shell-enter"),J=setTimeout(Q,yt+60)};U==="external"&&(J=setTimeout(Q,yt+60));let le=[],pe=null,St=()=>{if(pe)return pe;if(m||or()||typeof v.animate!="function")return q(),null;let t=v.ownerDocument.defaultView?.getComputedStyle(B).opacity||"1";q(),v.style.pointerEvents="none",D.style.pointerEvents="none";let o={duration:Ue("--persona-history-exit-ms",er),easing:xt("--persona-history-exit-easing",tr),fill:"forwards"},a=rr[k];return le=[B.animate([{opacity:t,transform:"none"},{opacity:0,transform:`translateX(${a}px)`}],o)],pe=Promise.all(le.map(ir)).then(()=>{}),pe},Te=(t,o)=>{t&&(o?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled"))},D=C,Ae=null,kt=()=>{let t=e.slots?.header;if(!t)return;let o=`${k}|${ge(b)}|${u?`${u.kind}:${"conversationId"in u?u.conversationId:""}`:""}`;if(o===Ae)return;Ae=o;let a=t({identityStatus:b,pendingAction:u,copy:r,defaultRenderer:()=>C})??C;a!==D&&(D.replaceWith(a),D=a)},Xe=null,Ct=()=>{if(!e.showScopeStatus)return;let t=ge(b);if(t===Xe)return;Xe=t;let o=ut(b,r);Fe.textContent=o.title;let a=nr(b);if(z.hidden=!a,V.replaceChildren(...a?[]:[n("span",{className:"persona-history-scope-alert-title",text:o.title})],n("span",{className:"persona-history-scope-description",text:o.description,attrs:{id:Ke}})),V.setAttribute("data-persona-history-scope-tone",a?"ambient":"attention"),a?z.setAttribute("aria-describedby",Ke):z.removeAttribute("aria-describedby"),o.pending?V.setAttribute("role","status"):V.removeAttribute("role"),V.setAttribute("data-persona-history-identity",b.state),z.setAttribute("data-persona-history-identity",b.state),sr(b)){let c=n("button",{className:"persona-history-secondary persona-history-state-action",text:r.retryIdentityLabel,attrs:{type:"button","data-persona-history-focus":"identity-retry"}});c.addEventListener("click",()=>{w()||N("refresh")}),V.appendChild(c)}},Ze=t=>u?u.kind==="open"&&u.conversationId===t?"opening":u.kind==="delete"&&u.conversationId===t?"deleting":null:null,Lt=()=>{let t=document.activeElement;return!(t instanceof HTMLElement)||!v.contains(t)?null:t.getAttribute("data-persona-history-focus")},Tt=t=>{if(M&&x){M=!1;let o=v.querySelector(`[data-persona-history-focus="${te(x)}"]`);if(o){o.focus();return}}t&&v.querySelector(`[data-persona-history-focus="${t}"]`)?.focus()},At=()=>{if(!E)return null;let t=n("button",{className:"persona-history-secondary persona-history-state-action",text:r.retryLabel,attrs:{type:"button","data-persona-history-focus":"action-retry"}}),o=E;return t.addEventListener("click",()=>{w()||o.retry()}),n("div",{className:"persona-history-row-error",attrs:{role:"alert"}},n("span",{text:o.message}),t)},Rt=()=>st(p,i(),r,e.grouping).map((t,o)=>{let a=`${l}-g${o}`,c=n("ul",{className:"persona-history-list",attrs:{"aria-labelledby":a}});for(let d of t.items){let H=()=>pt({conversation:d,active:d.id===S,pending:Ze(d.id),busy:w(),menuOpen:x===d.id,error:I.get(d.id)??null,avatar:e.rowAvatar,showDelete:e.showDelete!==!1,nowMs:i(),copy:r,onOpen:()=>{de(d.id)},onToggleMenu:()=>Qe(d.id),onCloseMenu:De=>L(De),onDelete:()=>{ce(d.id)}}),W=e.slots?.conversation?.({conversation:d,active:d.id===S,pending:Ze(d.id),open:()=>de(d.id),requestDelete:()=>ce(d.id),defaultRenderer:H})??H();c.appendChild(W instanceof HTMLLIElement?W:n("li",{className:"persona-history-item"},W))}return n("div",{className:"persona-history-group",attrs:{"data-persona-history-group":t.key}},n("h3",{className:T("persona-history-group-heading",t.key==="recent"&&"persona-history-sr-only"),text:t.label,attrs:{id:a}}),c)}),Et=()=>{if(!h)return null;let t=u?.kind==="load-more"||y.kind==="loading"&&y.phase==="load-more",o=n("button",{className:"persona-history-secondary persona-history-load-more",text:t?r.loadingMoreLabel:r.loadMoreLabel,attrs:{type:"button","data-persona-history-focus":"load-more",...t?{"aria-busy":"true","aria-disabled":"true"}:{},...w()&&!t?{"aria-disabled":"true"}:{}}});return o.addEventListener("click",()=>{w()||N("load-more")}),o},Nt=()=>{let t=Lt(),o=[At()],a=p.length>0;if(a&&(o.push(...Rt()),o.push(Et())),y.kind!=="ready"&&!(y.kind==="loading"&&y.phase!=="initial"&&a)){let d=y,H=d.kind==="loading"?void 0:()=>N("refresh"),P=d.kind==="new_conversation_required"?()=>ee():void 0,W=()=>ct({state:d,copy:r,identityStatus:b,busy:w(),...H?{onRetry:()=>{H()}}:{},...P?{onStartNew:()=>{P()}}:{}}),De=e.slots?.state?.({state:d,identityStatus:b,copy:r,...H?{retry:H}:{},...P?{startNewConversation:P}:{},defaultRenderer:W});o.push(De??W())}ke.replaceChildren(...o.filter(d=>!!d)),Tt(t)},Mt=()=>{let t=y.kind==="loading"&&p.length===0,o=[],a=()=>o.length===0?te(F):`${te(F)}-${o.length}`;if(!t)for(let c of Ye)o.push({label:c.label,focusKey:a(),danger:c.danger===!0,onSelect:()=>{c.onSelect({conversations:[...p]})}});return Be&&!(p.length===0&&(y.kind==="empty"||t))&&o.push({label:r.clearHistoryLabel,focusKey:a(),danger:!0,onSelect:()=>{Ee()}}),We&&!t&&o.push({label:r.resetIdentityLabel,focusKey:a(),danger:!0,onSelect:()=>{Me()}}),o},Dt=()=>{if(Te(Se,w()),Te($,w()),O){let t=Mt(),o=y.kind==="loading"&&p.length===0;O.hidden=t.length===0&&!o,Te(O,w()||t.length===0),O.setAttribute("aria-expanded",x===F?"true":"false");let a=K.querySelector(".persona-history-menu");if(x!==F||t.length===0)a?.remove();else{let c=Ve({label:r.listOptionsLabel,items:t,onCloseMenu:d=>L(d)});a?a.replaceWith(c):K.appendChild(c)}}K.hidden=k!=="rail"&&(!O||O.hidden)&&(!e.showScopeStatus||z.hidden)},Je,Pt=()=>{let t=e.onActiveConversationChange;if(!t)return;let o=p.find(c=>c.id===S)??null,a=o?`${o.id}\0${o.title}\0${o.starred?1:0}`:"";a!==Je&&(Je=a,t(o))},g=()=>{if(!m){if(Pt(),!G){e.onModelChange?.();return}kt(),Ct(),Dt(),Nt(),Le()}},L=t=>{if(!x)return;let o=x;x=null,M=!1,g(),t?.restoreFocus&&v.querySelector(`[data-persona-history-focus="menu:${o}"]`)?.focus()},Qe=t=>{if(x===t){L({restoreFocus:!0});return}x=t,M=!0,g()},et=t=>{if(!x)return;let o=t.target;o instanceof Node&&v.contains(o)&&o.closest?.(`[data-persona-history-item="${x}"]`)||L()};document.addEventListener("pointerdown",et,!0);let tt=t=>{t.key!=="Escape"||!x||(t.stopPropagation(),L({restoreFocus:!0}))};v.addEventListener("keydown",tt);async function N(t){if(m)return;let o=++Y,a=t==="load-more"?h:null;if(!(t==="load-more"&&!a)){u={kind:t==="load-more"?"load-more":"refresh"},y={kind:"loading",phase:t},t!=="load-more"&&(I.clear(),E=null),L(),g();try{let c=await e.provider.list({limit:s,context:e.context,...a?{cursor:a}:{},...e.targetId?{targetId:e.targetId}:{}});if(m||o!==Y)return;p=a?[...p,...c.items]:c.items,h=c.nextCursor,y=p.length===0?{kind:"empty"}:{kind:"ready"}}catch(c){if(m||o!==Y)return;y=dt(c)}finally{!m&&o===Y&&(u=null,g())}}}let Re=t=>{p=p.filter(o=>o.id!==t),I.delete(t),S===t&&(S=null),p.length===0&&!h&&(y={kind:"empty"})};async function de(t){if(!(w()||m)){I.delete(t),L(),u={kind:"open",conversationId:t},g();try{if(await e.onSelect(t),m)return;S=t}catch{if(m)return;I.set(t,{message:r.openFailedLabel,retry:()=>{de(t)}})}finally{m||(u=null,g())}}}async function ce(t){if(w()||m)return"cancelled";I.delete(t),u={kind:"delete",conversationId:t},g();try{let o=await e.onRequestDeleteConversation(t);return m||o==="deleted"&&(Re(t),ie(r.conversationRemovedNotice)),o}catch(o){return m||(ye(o)&&o.code==="not_found"?Re(t):I.set(t,{message:r.deleteFailedLabel,retry:()=>{ce(t)}})),"cancelled"}finally{m||(u=null,g())}}async function ee(){if(!(w()||m)){E=null,L(),u={kind:"start-new"},g();try{if(await e.onStartNew(),m)return;y.kind==="new_conversation_required"&&(y=p.length===0?{kind:"empty"}:{kind:"ready"})}catch{if(m)return;E={message:r.errorDescription,retry:()=>{ee()}}}finally{m||(u=null,g())}}}async function Ee(){if(w()||m)return"cancelled";E=null,L(),u={kind:"clear"},g();try{let t=await e.onRequestClearHistory();return m||t==="cleared"&&(p=[],h=null,S=null,y={kind:"empty"},ie(r.historyClearedNotice)),t}catch{return m||(E={message:r.errorDescription,retry:()=>{Ee()}}),"cancelled"}finally{m||(u=null,g())}}let Ne={outcome:"cancelled"};async function Me(){if(w()||m||!e.onRequestResetIdentity)return Ne;E=null,L(),u={kind:"reset"},g();try{let t=await e.onRequestResetIdentity();return m||t.outcome==="reset"&&(ie(t.remoteRevocationConfirmed?r.identityResetNotice:r.identityResetUnconfirmedNotice),u=null,await N("refresh")),t}catch{return m||(E={message:r.errorDescription,retry:()=>{Me()}}),Ne}finally{!m&&u?.kind==="reset"&&(u=null,g())}}let _t=e.provider.subscribeIdentityStatus(t=>{if(m)return;let o=ge(t),a=o!==oe;b=t,oe=o,g(),a&&t.state!=="verifying"&&ie(ut(t,r).title)}),It=e.provider.subscribeAvailability?.(t=>{if(!m){if(t){N("refresh");return}p=[],h=null,y={kind:"error",reason:"unavailable",retryable:!1},g()}});return g(),N("initial"),{element:v,copy:r,getModel:()=>({conversations:p,activeConversationId:S,state:y,pendingAction:u,identityStatus:b,nextCursor:h}),operations:{refresh:async()=>{w()||await N("refresh")},loadMore:async()=>{w()||await N("load-more")},openConversation:t=>de(t),startNewConversation:()=>ee(),requestDeleteConversation:t=>ce(t),requestClearConversationHistory:()=>Ee(),requestResetHistoryIdentity:()=>Me()},setDomRenderEnabled:t=>{t!==G&&(G=t,t&&g())},refresh:()=>{N("refresh")},setPresentation:t=>{if(t===k)return;q(),k=t,Ae=null;let o=t==="rail";v.classList.toggle("persona-history-view--panel",!o),v.classList.toggle("persona-history-view--rail",o),v.setAttribute("data-persona-history-presentation",t),be(),Ce(),He(),xe(),je(),g()},setCollapsed:t=>{t!==R&&(R=t,Ce(),be(),xe(),Le())},setRailSide:t=>{Oe=t==="right",He()},getHeaderElement:()=>D,setHeaderPlacement:t=>{if(t===U)return;U=t;let o=t==="external";if(C.classList.toggle("persona-history-topbar--shell",o),o){Ht(),D.remove();return}Q(),v.insertBefore(D,B)},setActiveConversationId:t=>{S!==t&&(S=t,g())},applyConversationSummary:t=>{let o=p.findIndex(a=>a.id===t.id);o!==-1&&(p[o]=t,g())},removeConversationSummary:t=>{p.some(o=>o.id===t)&&(Re(t),g())},setNewConversationRequired:t=>{t?y={kind:"new_conversation_required"}:y.kind==="new_conversation_required"&&(y=p.length===0?{kind:"empty"}:{kind:"ready"}),g()},playExit:St,destroy:()=>{m=!0,Y+=1,q(),Q(),gt.forEach(t=>t?.destroy()),D.remove(),le.forEach(t=>t.cancel()),le=[],_t(),It?.(),document.removeEventListener("pointerdown",et,!0),v.removeEventListener("keydown",tt),fe.destroy(),v.remove(),v.replaceChildren()}}}export{ue as HISTORY_VIEW_COPY_DEFAULTS,ht as createHistoryView,he as resolveHistoryViewCopy};