@henryavila/mdprobe 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { useState } from 'preact/hooks'
2
2
  import { rightPanelOpen, filteredAnnotations, selectedAnnotationId, showResolved,
3
- filterTag, filterAuthor, uniqueTags, uniqueAuthors, openAnnotations } from '../state/store.js'
3
+ filterTag, filterAuthor, uniqueTags, uniqueAuthors, openAnnotations,
4
+ anchoredAnnotations, orphanedAnnotations, driftWarning } from '../state/store.js'
4
5
  import { AnnotationForm } from './AnnotationForm.jsx'
5
6
  import { ReplyThread } from './ReplyThread.jsx'
6
7
 
@@ -64,80 +65,41 @@ export function RightPanel({ annotationOps }) {
64
65
 
65
66
  {/* Annotation list */}
66
67
  <div style="overflow-y: auto; padding: 0 8px; flex: 1">
67
- {filteredAnnotations.value.length === 0 ? (
68
+ {anchoredAnnotations.value.length === 0 && orphanedAnnotations.value.length === 0 ? (
68
69
  <div style="padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px">
69
70
  No annotations
70
71
  </div>
71
72
  ) : (
72
- filteredAnnotations.value.map(ann => (
73
- <div
74
- key={ann.id}
75
- data-annotation-id={ann.id}
76
- class={`annotation-card ${selectedAnnotationId.value === ann.id ? 'selected' : ''} ${ann.status === 'resolved' ? 'resolved' : ''}`}
77
- onClick={() => handleAnnotationClick(ann)}
78
- >
79
- {/* Tag + Author + Time */}
80
- <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 6px">
81
- <span class={`tag tag-${ann.tag}`}>{ann.tag}</span>
82
- <span style="font-size: 11px; color: var(--text-muted)">{ann.author}</span>
83
- {ann.status === 'resolved' && <span style="font-size: 10px; color: var(--status-approved)">✓ resolved</span>}
73
+ <>
74
+ {anchoredAnnotations.value.length === 0 && orphanedAnnotations.value.length === 0 && filteredAnnotations.value.length > 0 ? (
75
+ <div style="padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px">
76
+ No annotations
84
77
  </div>
85
-
86
- {/* Quote */}
87
- {ann.selectors?.quote?.exact && (
88
- <div class="quote">{ann.selectors.quote.exact}</div>
89
- )}
90
-
91
- {/* Comment */}
92
- <div style="font-size: 13px; margin-top: 4px">{ann.comment}</div>
93
-
94
- {/* Actions (when selected) */}
95
- {selectedAnnotationId.value === ann.id && (
96
- <div style="margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap">
97
- {ann.status === 'open' ? (
98
- <button class="btn btn-sm" onClick={(e) => { e.stopPropagation(); annotationOps.resolveAnnotation(ann.id) }}>
99
- Resolve
100
- </button>
101
- ) : (
102
- <button class="btn btn-sm" onClick={(e) => { e.stopPropagation(); annotationOps.reopenAnnotation(ann.id) }}>
103
- Reopen
104
- </button>
105
- )}
106
- <button class="btn btn-sm" onClick={(e) => { e.stopPropagation(); setEditingId(ann.id) }}>
107
- Edit
108
- </button>
109
- <button class="btn btn-sm btn-danger" onClick={(e) => {
110
- e.stopPropagation()
111
- if (confirm('Delete this annotation?')) annotationOps.deleteAnnotation(ann.id)
112
- }}>
113
- Delete
114
- </button>
115
- </div>
116
- )}
117
-
118
- {/* Edit form */}
119
- {editingId === ann.id && (
120
- <AnnotationForm
121
- annotation={ann}
122
- onSave={(data) => {
123
- annotationOps.updateAnnotation(ann.id, data)
124
- setEditingId(null)
125
- }}
126
- onCancel={() => setEditingId(null)}
78
+ ) : (
79
+ anchoredAnnotations.value.map(ann => (
80
+ <AnnotationCard
81
+ key={ann.id}
82
+ ann={ann}
83
+ isSelected={selectedAnnotationId.value === ann.id}
84
+ onClick={() => handleAnnotationClick(ann)}
85
+ annotationOps={annotationOps}
86
+ editingId={editingId}
87
+ setEditingId={setEditingId}
127
88
  />
128
- )}
129
-
130
- {/* Replies */}
131
- {ann.replies?.length > 0 && (
132
- <ReplyThread replies={ann.replies} />
133
- )}
134
-
135
- {/* Reply input (when selected) */}
136
- {selectedAnnotationId.value === ann.id && (
137
- <ReplyInput annotationId={ann.id} onReply={annotationOps.addReply} />
138
- )}
139
- </div>
140
- ))
89
+ ))
90
+ )}
91
+
92
+ {driftWarning.value && orphanedAnnotations.value.length > 0 && (
93
+ <OrphanedSection
94
+ annotations={orphanedAnnotations.value}
95
+ selectedAnnotationId={selectedAnnotationId.value}
96
+ onSelect={(ann) => { selectedAnnotationId.value = ann.id }}
97
+ annotationOps={annotationOps}
98
+ editingId={editingId}
99
+ setEditingId={setEditingId}
100
+ />
101
+ )}
102
+ </>
141
103
  )}
142
104
  </div>
143
105
  </div>
@@ -146,6 +108,103 @@ export function RightPanel({ annotationOps }) {
146
108
  )
147
109
  }
148
110
 
111
+ function AnnotationCard({ ann, isSelected, onClick, annotationOps, editingId, setEditingId, orphaned = false }) {
112
+ return (
113
+ <div
114
+ data-annotation-id={ann.id}
115
+ class={`annotation-card ${isSelected ? 'selected' : ''} ${ann.status === 'resolved' ? 'resolved' : ''} ${orphaned ? 'orphaned' : ''}`}
116
+ onClick={onClick}
117
+ >
118
+ {/* Tag + Author + Status */}
119
+ <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 6px">
120
+ <span class={`tag tag-${ann.tag}`}>{ann.tag}</span>
121
+ <span style="font-size: 11px; color: var(--text-muted)">{ann.author}</span>
122
+ {ann.status === 'resolved' && <span style="font-size: 10px; color: var(--status-approved)">✓ resolved</span>}
123
+ {orphaned && <span style="font-size: 10px; color: var(--tag-bug)">não encontrada</span>}
124
+ </div>
125
+
126
+ {/* Quote */}
127
+ {ann.selectors?.quote?.exact && (
128
+ <div class="quote">{ann.selectors.quote.exact}</div>
129
+ )}
130
+
131
+ {/* Comment */}
132
+ <div style="font-size: 13px; margin-top: 4px">{ann.comment}</div>
133
+
134
+ {/* Actions (when selected) */}
135
+ {isSelected && (
136
+ <div style="margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap">
137
+ {ann.status === 'open' ? (
138
+ <button class="btn btn-sm" onClick={(e) => { e.stopPropagation(); annotationOps.resolveAnnotation(ann.id) }}>
139
+ Resolve
140
+ </button>
141
+ ) : (
142
+ <button class="btn btn-sm" onClick={(e) => { e.stopPropagation(); annotationOps.reopenAnnotation(ann.id) }}>
143
+ Reopen
144
+ </button>
145
+ )}
146
+ <button class="btn btn-sm" onClick={(e) => { e.stopPropagation(); setEditingId(ann.id) }}>
147
+ Edit
148
+ </button>
149
+ <button class="btn btn-sm btn-danger" onClick={(e) => {
150
+ e.stopPropagation()
151
+ if (confirm('Delete this annotation?')) annotationOps.deleteAnnotation(ann.id)
152
+ }}>
153
+ Delete
154
+ </button>
155
+ </div>
156
+ )}
157
+
158
+ {/* Edit form */}
159
+ {editingId === ann.id && (
160
+ <AnnotationForm
161
+ annotation={ann}
162
+ onSave={(data) => {
163
+ annotationOps.updateAnnotation(ann.id, data)
164
+ setEditingId(null)
165
+ }}
166
+ onCancel={() => setEditingId(null)}
167
+ />
168
+ )}
169
+
170
+ {/* Replies */}
171
+ {ann.replies?.length > 0 && (
172
+ <ReplyThread replies={ann.replies} />
173
+ )}
174
+
175
+ {/* Reply input (when selected) */}
176
+ {isSelected && (
177
+ <ReplyInput annotationId={ann.id} onReply={annotationOps.addReply} />
178
+ )}
179
+ </div>
180
+ )
181
+ }
182
+
183
+ function OrphanedSection({ annotations, selectedAnnotationId, onSelect, annotationOps, editingId, setEditingId }) {
184
+ const [collapsed, setCollapsed] = useState(false)
185
+
186
+ return (
187
+ <div class="orphaned-section">
188
+ <div class="orphaned-section-header" onClick={() => setCollapsed(c => !c)}>
189
+ <span>{collapsed ? '▸' : '▾'}</span>
190
+ <span>Não encontradas ({annotations.length})</span>
191
+ </div>
192
+ {!collapsed && annotations.map(ann => (
193
+ <AnnotationCard
194
+ key={ann.id}
195
+ ann={ann}
196
+ isSelected={selectedAnnotationId === ann.id}
197
+ onClick={() => onSelect(ann)}
198
+ annotationOps={annotationOps}
199
+ editingId={editingId}
200
+ setEditingId={setEditingId}
201
+ orphaned
202
+ />
203
+ ))}
204
+ </div>
205
+ )
206
+ }
207
+
149
208
  function ReplyInput({ annotationId, onReply }) {
150
209
  const [text, setText] = useState('')
151
210
 
@@ -1,4 +1,4 @@
1
- import { annotations, sections, currentFile, author, driftWarning, sectionLevel } from '../state/store.js'
1
+ import { annotations, sections, currentFile, author, driftWarning, sectionLevel, anchorStatus } from '../state/store.js'
2
2
 
3
3
  const API_BASE = '' // same origin
4
4
 
@@ -25,6 +25,11 @@ export function useAnnotations() {
25
25
  sections.value = data.sections || []
26
26
  if (data.sectionLevel != null) sectionLevel.value = data.sectionLevel
27
27
  driftWarning.value = data.drift || false
28
+ if (data.drift && typeof data.drift === 'object') {
29
+ anchorStatus.value = data.drift.anchorStatus || {}
30
+ } else {
31
+ anchorStatus.value = {}
32
+ }
28
33
  return data
29
34
  }
30
35
 
@@ -69,7 +69,7 @@ async function initMermaid(elements) {
69
69
  }
70
70
  await window.mermaid.run({ nodes: [...elements] })
71
71
  } catch (err) {
72
- console.warn('mdprobe: Mermaid rendering failed', err)
72
+ console.warn('mdProbe: Mermaid rendering failed', err)
73
73
  }
74
74
  }
75
75
 
@@ -92,6 +92,6 @@ async function initKaTeX(elements) {
92
92
  }
93
93
  }
94
94
  } catch (err) {
95
- console.warn('mdprobe: KaTeX rendering failed', err)
95
+ console.warn('mdProbe: KaTeX rendering failed', err)
96
96
  }
97
97
  }
@@ -7,6 +7,7 @@ import {
7
7
  annotations,
8
8
  sections,
9
9
  driftWarning,
10
+ anchorStatus,
10
11
  } from '../state/store.js'
11
12
 
12
13
  const RECONNECT_DELAY_MS = 2000
@@ -25,6 +26,8 @@ export function useWebSocket() {
25
26
  const reconnectTimer = useRef(null)
26
27
  const unmounted = useRef(false)
27
28
 
29
+ const hasConnected = useRef(false)
30
+
28
31
  const connect = useCallback(() => {
29
32
  if (unmounted.current) return
30
33
 
@@ -35,6 +38,14 @@ export function useWebSocket() {
35
38
  ws.onopen = () => {
36
39
  // Reset back-off on successful connection
37
40
  reconnectDelay.current = RECONNECT_DELAY_MS
41
+
42
+ // On reconnect, re-sync file list from server (may be a new server)
43
+ if (hasConnected.current) {
44
+ fetch('/api/files').then(r => r.json()).then(data => {
45
+ files.value = data
46
+ }).catch(() => {})
47
+ }
48
+ hasConnected.current = true
38
49
  }
39
50
 
40
51
  ws.onmessage = (event) => {
@@ -42,7 +53,7 @@ export function useWebSocket() {
42
53
  try {
43
54
  msg = JSON.parse(event.data)
44
55
  } catch {
45
- console.warn('mdprobe: received non-JSON WebSocket message')
56
+ console.warn('mdProbe: received non-JSON WebSocket message')
46
57
  return
47
58
  }
48
59
 
@@ -84,17 +95,20 @@ export function useWebSocket() {
84
95
 
85
96
  case 'drift':
86
97
  driftWarning.value = msg.warning || true
98
+ if (msg.anchorStatus) {
99
+ anchorStatus.value = msg.anchorStatus
100
+ }
87
101
  break
88
102
 
89
103
  case 'error':
90
104
  // Keep last valid render; surface the warning in the console
91
- console.warn('mdprobe:', msg.message)
105
+ console.warn('mdProbe:', msg.message)
92
106
  break
93
107
  }
94
108
  }
95
109
 
96
110
  ws.onerror = (err) => {
97
- console.warn('mdprobe: WebSocket error', err)
111
+ console.warn('mdProbe: WebSocket error', err)
98
112
  }
99
113
 
100
114
  ws.onclose = () => {
package/src/ui/index.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>mdprobe</title>
6
+ <title>mdProbe</title>
7
7
  <script>
8
8
  (function() {
9
9
  var theme = localStorage.getItem('mdprobe-theme') || 'mocha';
@@ -22,6 +22,7 @@ export const leftPanelOpen = signal(localStorage.getItem('mdprobe-left-panel') !
22
22
  export const rightPanelOpen = signal(localStorage.getItem('mdprobe-right-panel') !== 'false')
23
23
  export const theme = signal(localStorage.getItem('mdprobe-theme') || 'mocha')
24
24
  export const driftWarning = signal(false)
25
+ export const anchorStatus = signal({}) // Map<annotationId, 'anchored'|'orphan'>
25
26
 
26
27
  // Persist panel state on change via effect (subscribed below)
27
28
  leftPanelOpen.subscribe(v => localStorage.setItem('mdprobe-left-panel', v))
@@ -55,6 +56,14 @@ export const filteredAnnotations = computed(() => {
55
56
  return list
56
57
  })
57
58
 
59
+ export const orphanedAnnotations = computed(() =>
60
+ filteredAnnotations.value.filter(a => anchorStatus.value[a.id] === 'orphan')
61
+ )
62
+
63
+ export const anchoredAnnotations = computed(() =>
64
+ filteredAnnotations.value.filter(a => anchorStatus.value[a.id] !== 'orphan')
65
+ )
66
+
58
67
  export const uniqueTags = computed(() =>
59
68
  [...new Set(annotations.value.map(a => a.tag))]
60
69
  )
@@ -1,5 +1,5 @@
1
1
  /* ==========================================================================
2
- mdprobe — Catppuccin Theme System & Layout
2
+ mdProbe — Catppuccin Theme System & Layout
3
3
  ========================================================================== */
4
4
 
5
5
  /* --------------------------------------------------------------------------
@@ -173,7 +173,7 @@ body {
173
173
  #app {
174
174
  display: grid;
175
175
  grid-template-columns: auto 1fr auto;
176
- grid-template-rows: 48px 1fr 32px;
176
+ grid-template-rows: 48px auto 1fr 32px;
177
177
  height: 100vh;
178
178
  background: var(--bg-primary);
179
179
  color: var(--text-primary);
@@ -183,6 +183,7 @@ body {
183
183
  Header bar (row 1, spans all columns)
184
184
  -------------------------------------------------------------------------- */
185
185
  .header {
186
+ grid-row: 1;
186
187
  grid-column: 1 / -1;
187
188
  display: flex;
188
189
  align-items: center;
@@ -203,6 +204,7 @@ body {
203
204
  Left panel
204
205
  -------------------------------------------------------------------------- */
205
206
  .left-panel {
207
+ grid-row: 3;
206
208
  width: var(--panel-width);
207
209
  transition: width 0.2s ease;
208
210
  overflow: hidden;
@@ -241,6 +243,7 @@ body {
241
243
  Right panel
242
244
  -------------------------------------------------------------------------- */
243
245
  .right-panel {
246
+ grid-row: 3;
244
247
  width: var(--panel-width);
245
248
  transition: width 0.2s ease;
246
249
  overflow: hidden;
@@ -292,14 +295,18 @@ body {
292
295
 
293
296
  .panel-content {
294
297
  flex: 1;
295
- overflow-y: auto;
298
+ overflow: hidden;
296
299
  padding: 4px 8px;
300
+ display: flex;
301
+ flex-direction: column;
302
+ min-height: 0;
297
303
  }
298
304
 
299
305
  /* --------------------------------------------------------------------------
300
306
  Content area
301
307
  -------------------------------------------------------------------------- */
302
308
  .content-area-wrapper {
309
+ grid-row: 3;
303
310
  overflow-y: auto;
304
311
  min-width: 0;
305
312
  }
@@ -657,6 +664,7 @@ body {
657
664
  Status bar (row 3, spans all columns)
658
665
  -------------------------------------------------------------------------- */
659
666
  .status-bar {
667
+ grid-row: 4;
660
668
  grid-column: 1 / -1;
661
669
  display: flex;
662
670
  align-items: center;
@@ -746,6 +754,23 @@ body {
746
754
  .section-status-label.approved { color: var(--status-approved); }
747
755
  .section-status-label.rejected { color: var(--status-rejected); }
748
756
 
757
+ /* --------------------------------------------------------------------------
758
+ File list section (constrained height so TOC gets priority)
759
+ -------------------------------------------------------------------------- */
760
+ .file-list-section {
761
+ padding: 0 8px 8px;
762
+ max-height: 35%;
763
+ overflow-y: auto;
764
+ flex-shrink: 0;
765
+ }
766
+
767
+ .toc-section {
768
+ padding: 0 8px;
769
+ flex: 1;
770
+ overflow-y: auto;
771
+ min-height: 0;
772
+ }
773
+
749
774
  /* --------------------------------------------------------------------------
750
775
  File list items
751
776
  -------------------------------------------------------------------------- */
@@ -1113,6 +1138,8 @@ body {
1113
1138
  Drift warning banner
1114
1139
  -------------------------------------------------------------------------- */
1115
1140
  .drift-banner {
1141
+ grid-row: 2;
1142
+ grid-column: 1 / -1;
1116
1143
  padding: 8px 16px;
1117
1144
  background: var(--tag-question);
1118
1145
  color: white;
@@ -1120,7 +1147,6 @@ body {
1120
1147
  display: flex;
1121
1148
  align-items: center;
1122
1149
  gap: 8px;
1123
- grid-column: 1 / -1;
1124
1150
  }
1125
1151
 
1126
1152
  .drift-banner .dismiss {
@@ -1134,6 +1160,40 @@ body {
1134
1160
  opacity: 1;
1135
1161
  }
1136
1162
 
1163
+ /* --------------------------------------------------------------------------
1164
+ Orphaned annotations section
1165
+ -------------------------------------------------------------------------- */
1166
+ .orphaned-section {
1167
+ border-top: 1px solid var(--border);
1168
+ padding-top: 8px;
1169
+ margin-top: 8px;
1170
+ }
1171
+
1172
+ .orphaned-section-header {
1173
+ display: flex;
1174
+ align-items: center;
1175
+ gap: 6px;
1176
+ cursor: pointer;
1177
+ padding: 6px 4px;
1178
+ font-size: 12px;
1179
+ font-weight: 500;
1180
+ color: var(--tag-bug);
1181
+ }
1182
+
1183
+ .orphaned-section-header:hover {
1184
+ opacity: 0.8;
1185
+ }
1186
+
1187
+ .annotation-card.orphaned {
1188
+ opacity: 0.65;
1189
+ border-left-color: var(--tag-bug);
1190
+ border-left-style: dashed;
1191
+ }
1192
+
1193
+ .annotation-card.orphaned .quote {
1194
+ text-decoration: line-through;
1195
+ }
1196
+
1137
1197
  /* --------------------------------------------------------------------------
1138
1198
  Utility classes
1139
1199
  -------------------------------------------------------------------------- */
@@ -1,2 +0,0 @@
1
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var Ie,k,vt,mt,F,Qe,gt,yt,Me,ge,ce,bt,Ke,qe,He,xe={},we=[],Wt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Pe=Array.isArray;function U(t,e){for(var n in e)t[n]=e[n];return t}function Xe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function zt(t,e,n){var i,r,o,l={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:l[o]=e[o];if(arguments.length>2&&(l.children=arguments.length>3?Ie.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)l[o]===void 0&&(l[o]=t.defaultProps[o]);return ye(t,l,i,r,null)}function ye(t,e,n,i,r){var o={type:t,props:e,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++vt,__i:-1,__u:0};return r==null&&k.vnode!=null&&k.vnode(o),o}function J(t){return t.children}function ue(t,e){this.props=t,this.context=e}function ie(t,e){if(e==null)return t.__?ie(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?ie(t):null}function Bt(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,i=[],r=[],o=U({},e);o.__v=e.__v+1,k.vnode&&k.vnode(o),Je(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,i,n??ie(e),!!(32&e.__u),r),o.__v=e.__v,o.__.__k[o.__i]=o,St(i,o,r),e.__e=e.__=null,o.__e!=n&&xt(o)}}function xt(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),xt(t)}function et(t){(!t.__d&&(t.__d=!0)&&F.push(t)&&!ke.__r++||Qe!=k.debounceRendering)&&((Qe=k.debounceRendering)||gt)(ke)}function ke(){try{for(var t,e=1;F.length;)F.length>e&&F.sort(yt),t=F.shift(),e=F.length,Bt(t)}finally{F.length=ke.__r=0}}function wt(t,e,n,i,r,o,l,a,d,u,y){var c,f,_,p,h,v,m,g=i&&i.__k||we,$=e.length;for(d=Kt(n,e,g,d,$),c=0;c<$;c++)(_=n.__k[c])!=null&&(f=_.__i!=-1&&g[_.__i]||xe,_.__i=c,v=Je(t,_,f,r,o,l,a,d,u,y),p=_.__e,_.ref&&f.ref!=_.ref&&(f.ref&&Ve(f.ref,null,_),y.push(_.ref,_.__c||p,_)),h==null&&p!=null&&(h=p),(m=!!(4&_.__u))||f.__k===_.__k?(d=kt(_,d,t,m),m&&f.__e&&(f.__e=null)):typeof _.type=="function"&&v!==void 0?d=v:p&&(d=p.nextSibling),_.__u&=-7);return n.__e=h,d}function Kt(t,e,n,i,r){var o,l,a,d,u,y=n.length,c=y,f=0;for(t.__k=new Array(r),o=0;o<r;o++)(l=e[o])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[o]=ye(null,l,null,null,null):Pe(l)?l=t.__k[o]=ye(J,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[o]=ye(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[o]=l,d=o+f,l.__=t,l.__b=t.__b+1,a=null,(u=l.__i=Xt(l,n,d,c))!=-1&&(c--,(a=n[u])&&(a.__u|=2)),a==null||a.__v==null?(u==-1&&(r>y?f--:r<y&&f++),typeof l.type!="function"&&(l.__u|=4)):u!=d&&(u==d-1?f--:u==d+1?f++:(u>d?f--:f++,l.__u|=4))):t.__k[o]=null;if(c)for(o=0;o<y;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==i&&(i=ie(a)),Ct(a,a));return i}function kt(t,e,n,i){var r,o;if(typeof t.type=="function"){for(r=t.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=t,e=kt(r[o],e,n,i));return e}t.__e!=e&&(i&&(e&&t.type&&!e.parentNode&&(e=ie(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Xt(t,e,n,i){var r,o,l,a=t.key,d=t.type,u=e[n],y=u!=null&&(2&u.__u)==0;if(u===null&&a==null||y&&a==u.key&&d==u.type)return n;if(i>(y?1:0)){for(r=n-1,o=n+1;r>=0||o<e.length;)if((u=e[l=r>=0?r--:o++])!=null&&(2&u.__u)==0&&a==u.key&&d==u.type)return l}return-1}function tt(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Wt.test(e)?n:n+"px"}function ve(t,e,n,i,r){var o,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof i=="string"&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||tt(t.style,e,"");if(n)for(e in n)i&&n[e]==i[e]||tt(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(bt,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i?n[ce]=i[ce]:(n[ce]=Ke,t.addEventListener(e,o?He:qe,o)):t.removeEventListener(e,o?He:qe,o);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function nt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[ge]==null)e[ge]=Ke++;else if(e[ge]<n[ce])return;return n(k.event?k.event(e):e)}}}function Je(t,e,n,i,r,o,l,a,d,u){var y,c,f,_,p,h,v,m,g,$,b,x,S,R,j,P=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),o=[a=e.__e=n.__e]),(y=k.__b)&&y(e);e:if(typeof P=="function")try{if(m=e.props,g=P.prototype&&P.prototype.render,$=(y=P.contextType)&&i[y.__c],b=y?$?$.props.value:y.__:i,n.__c?v=(c=e.__c=n.__c).__=c.__E:(g?e.__c=c=new P(m,b):(e.__c=c=new ue(m,b),c.constructor=P,c.render=Vt),$&&$.sub(c),c.state||(c.state={}),c.__n=i,f=c.__d=!0,c.__h=[],c._sb=[]),g&&c.__s==null&&(c.__s=c.state),g&&P.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=U({},c.__s)),U(c.__s,P.getDerivedStateFromProps(m,c.__s))),_=c.props,p=c.state,c.__v=e,f)g&&P.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),g&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(g&&P.getDerivedStateFromProps==null&&m!==_&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(m,b),e.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(m,c.__s,b)===!1){e.__v!=n.__v&&(c.props=m,c.state=c.__s,c.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(D){D&&(D.__=e)}),we.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&l.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(m,c.__s,b),g&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(_,p,h)})}if(c.context=b,c.props=m,c.__P=t,c.__e=!1,x=k.__r,S=0,g)c.state=c.__s,c.__d=!1,x&&x(e),y=c.render(c.props,c.state,c.context),we.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,x&&x(e),y=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++S<25);c.state=c.__s,c.getChildContext!=null&&(i=U(U({},i),c.getChildContext())),g&&!f&&c.getSnapshotBeforeUpdate!=null&&(h=c.getSnapshotBeforeUpdate(_,p)),R=y!=null&&y.type===J&&y.key==null?$t(y.props.children):y,a=wt(t,Pe(R)?R:[R],e,n,i,r,o,l,a,d,u),c.base=e.__e,e.__u&=-161,c.__h.length&&l.push(c),v&&(c.__E=c.__=null)}catch(D){if(e.__v=null,d||o!=null)if(D.then){for(e.__u|=d?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else{for(j=o.length;j--;)Xe(o[j]);Fe(e)}else e.__e=n.__e,e.__k=n.__k,D.then||Fe(e);k.__e(D,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):a=e.__e=Jt(n.__e,e,n,i,r,o,l,d,u);return(y=k.diffed)&&y(e),128&e.__u?void 0:a}function Fe(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Fe))}function St(t,e,n){for(var i=0;i<n.length;i++)Ve(n[i],n[++i],n[++i]);k.__c&&k.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(o){o.call(r)})}catch(o){k.__e(o,r.__v)}})}function $t(t){return typeof t!="object"||t==null||t.__b>0?t:Pe(t)?t.map($t):U({},t)}function Jt(t,e,n,i,r,o,l,a,d){var u,y,c,f,_,p,h,v=n.props||xe,m=e.props,g=e.type;if(g=="svg"?r="http://www.w3.org/2000/svg":g=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((_=o[u])&&"setAttribute"in _==!!g&&(g?_.localName==g:_.nodeType==3)){t=_,o[u]=null;break}}if(t==null){if(g==null)return document.createTextNode(m);t=document.createElementNS(r,g,m.is&&m),a&&(k.__m&&k.__m(e,o),a=!1),o=null}if(g==null)v===m||a&&t.data==m||(t.data=m);else{if(o=o&&Ie.call(t.childNodes),!a&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(_=t.attributes[u]).name]=_.value;for(u in v)_=v[u],u=="dangerouslySetInnerHTML"?c=_:u=="children"||u in m||u=="value"&&"defaultValue"in m||u=="checked"&&"defaultChecked"in m||ve(t,u,null,_,r);for(u in m)_=m[u],u=="children"?f=_:u=="dangerouslySetInnerHTML"?y=_:u=="value"?p=_:u=="checked"?h=_:a&&typeof _!="function"||v[u]===_||ve(t,u,_,v[u],r);if(y)a||c&&(y.__html==c.__html||y.__html==t.innerHTML)||(t.innerHTML=y.__html),e.__k=[];else if(c&&(t.innerHTML=""),wt(e.type=="template"?t.content:t,Pe(f)?f:[f],e,n,i,g=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,l,o?o[0]:n.__k&&ie(n,0),a,d),o!=null)for(u=o.length;u--;)Xe(o[u]);a||(u="value",g=="progress"&&p==null?t.removeAttribute("value"):p!=null&&(p!==t[u]||g=="progress"&&!p||g=="option"&&p!=v[u])&&ve(t,u,p,v[u],r),u="checked",h!=null&&h!=t[u]&&ve(t,u,h,v[u],r))}return t}function Ve(t,e,n){try{if(typeof t=="function"){var i=typeof t.__u=="function";i&&t.__u(),i&&e==null||(t.__u=t(e))}else t.current=e}catch(r){k.__e(r,n)}}function Ct(t,e,n){var i,r;if(k.unmount&&k.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||Ve(i,null,e)),(i=t.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){k.__e(o,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&Ct(i[r],e,n||typeof t.type!="function");n||Xe(t.__e),t.__c=t.__=t.__e=void 0}function Vt(t,e,n){return this.constructor(t,n)}function Yt(t,e,n){var i,r,o,l;e==document&&(e=document.documentElement),k.__&&k.__(t,e),r=(i=!1)?null:e.__k,o=[],l=[],Je(e,t=e.__k=zt(J,null,[t]),r||xe,xe,e.namespaceURI,r?null:e.firstChild?Ie.call(e.childNodes):null,o,r?r.__e:e.firstChild,i,l),St(o,t,l)}Ie=we.slice,k={__e:function(t,e,n,i){for(var r,o,l;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(t)),l=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,i||{}),l=r.__d),l)return r.__E=r}catch(a){t=a}throw t}},vt=0,mt=function(t){return t!=null&&t.constructor===void 0},ue.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=U({},this.state),typeof t=="function"&&(t=t(U({},n),this.props)),t&&U(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),et(this))},ue.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),et(this))},ue.prototype.render=J,F=[],gt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,yt=function(t,e){return t.__v.__b-e.__v.__b},ke.__r=0,Me=Math.random().toString(8),ge="__d"+Me,ce="__a"+Me,bt=/(PointerCapture)$|Capture$/i,Ke=0,qe=nt(!1),He=nt(!0);var Gt=0;function s(t,e,n,i,r,o){e||(e={});var l,a,d=e;if("ref"in d)for(a in d={},e)a=="ref"?l=e[a]:d[a]=e[a];var u={type:t,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Gt,__i:-1,__u:0,__source:r,__self:o};if(typeof t=="function"&&(l=t.defaultProps))for(a in l)d[a]===void 0&&(d[a]=l[a]);return k.vnode&&k.vnode(u),u}var fe,E,De,ot,_e=0,Et=[],A=k,it=A.__b,rt=A.__r,lt=A.diffed,at=A.__c,st=A.unmount,ct=A.__;function Ye(t,e){A.__h&&A.__h(E,t,_e||e),_e=0;var n=E.__H||(E.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function V(t){return _e=1,Zt(Tt,t)}function Zt(t,e,n){var i=Ye(fe++,2);if(i.t=t,!i.__c&&(i.__=[Tt(void 0,e),function(a){var d=i.__N?i.__N[0]:i.__[0],u=i.t(d,a);d!==u&&(i.__N=[u,i.__[1]],i.__c.setState({}))}],i.__c=E,!E.__f)){var r=function(a,d,u){if(!i.__c.__H)return!0;var y=i.__c.__H.__.filter(function(f){return f.__c});if(y.every(function(f){return!f.__N}))return!o||o.call(this,a,d,u);var c=i.__c.props!==a;return y.some(function(f){if(f.__N){var _=f.__[0];f.__=f.__N,f.__N=void 0,_!==f.__[0]&&(c=!0)}}),o&&o.call(this,a,d,u)||c};E.__f=!0;var o=E.shouldComponentUpdate,l=E.componentWillUpdate;E.componentWillUpdate=function(a,d,u){if(this.__e){var y=o;o=void 0,r(a,d,u),o=y}l&&l.call(this,a,d,u)},E.shouldComponentUpdate=r}return i.__N||i.__}function M(t,e){var n=Ye(fe++,3);!A.__s&&At(n.__H,e)&&(n.__=t,n.u=e,E.__H.__h.push(n))}function z(t){return _e=5,Re(function(){return{current:t}},[])}function Re(t,e){var n=Ye(fe++,7);return At(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Qt(t,e){return _e=8,Re(function(){return t},e)}function en(){for(var t;t=Et.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(be),e.__h.some(We),e.__h=[]}catch(n){e.__h=[],A.__e(n,t.__v)}}}A.__b=function(t){E=null,it&&it(t)},A.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),ct&&ct(t,e)},A.__r=function(t){rt&&rt(t),fe=0;var e=(E=t.__c).__H;e&&(De===E?(e.__h=[],E.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(be),e.__h.some(We),e.__h=[],fe=0)),De=E},A.diffed=function(t){lt&&lt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Et.push(e)!==1&&ot===A.requestAnimationFrame||((ot=A.requestAnimationFrame)||tn)(en)),e.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),De=E=null},A.__c=function(t,e){e.some(function(n){try{n.__h.some(be),n.__h=n.__h.filter(function(i){return!i.__||We(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],A.__e(i,n.__v)}}),at&&at(t,e)},A.unmount=function(t){st&&st(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(i){try{be(i)}catch(r){e=r}}),n.__H=void 0,e&&A.__e(e,n.__v))};var ut=typeof requestAnimationFrame=="function";function tn(t){var e,n=function(){clearTimeout(i),ut&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,35);ut&&(e=requestAnimationFrame(n))}function be(t){var e=E,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),E=e}function We(t){var e=E;t.__c=t.__(),E=e}function At(t,e){return!t||t.length!==e.length||e.some(function(n,i){return n!==t[i]})}function Tt(t,e){return typeof e=="function"?e(t):e}var nn=Symbol.for("preact-signals");function je(){if(q>1)q--;else{var t,e=!1;for((function(){var r=$e;for($e=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o})();de!==void 0;){var n=de;for(de=void 0,Se++;n!==void 0;){var i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&It(n))try{n.c()}catch(r){e||(t=r,e=!0)}n=i}}if(Se=0,q--,e)throw t}}function on(t){if(q>0)return t();ze=++rn,q++;try{return t()}finally{je()}}var w=void 0;function Nt(t){var e=w;w=void 0;try{return t()}finally{w=e}}var de=void 0,q=0,Se=0,rn=0,ze=0,$e=void 0,Ce=0;function Lt(t){if(w!==void 0){var e=t.n;if(e===void 0||e.t!==w)return e={i:0,S:t,p:w.s,n:void 0,t:w,e:void 0,x:void 0,r:e},w.s!==void 0&&(w.s.n=e),w.s=e,t.n=e,32&w.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=w.s,e.n=void 0,w.s.n=e,w.s=e),e}}function I(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}I.prototype.brand=nn;I.prototype.h=function(){return!0};I.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Nt(function(){var i;(i=e.W)==null||i.call(e)}))};I.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,i=t.x;n!==void 0&&(n.x=i,t.e=void 0),i!==void 0&&(i.e=n,t.x=void 0),t===this.t&&(this.t=i,i===void 0&&Nt(function(){var r;(r=e.Z)==null||r.call(e)}))}};I.prototype.subscribe=function(t){var e=this;return he(function(){var n=e.value,i=w;w=void 0;try{t(n)}finally{w=i}},{name:"sub"})};I.prototype.valueOf=function(){return this.value};I.prototype.toString=function(){return this.value+""};I.prototype.toJSON=function(){return this.value};I.prototype.peek=function(){var t=w;w=void 0;try{return this.value}finally{w=t}};Object.defineProperty(I.prototype,"value",{get:function(){var t=Lt(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Se>100)throw new Error("Cycle detected");(function(n){q!==0&&Se===0&&n.l!==ze&&(n.l=ze,$e={S:n,v:n.v,i:n.i,o:$e})})(this),this.v=t,this.i++,Ce++,q++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{je()}}}});function T(t,e){return new I(t,e)}function It(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Pt(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Rt(t){for(var e=t.s,n=void 0;e!==void 0;){var i=e.p;e.i===-1?(e.S.U(e),i!==void 0&&(i.n=e.n),e.n!==void 0&&(e.n.p=i)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}t.s=n}function ee(t,e){I.call(this,void 0),this.x=t,this.s=void 0,this.g=Ce-1,this.f=4,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}ee.prototype=new I;ee.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ce))return!0;if(this.g=Ce,this.f|=1,this.i>0&&!It(this))return this.f&=-2,!0;var t=w;try{Pt(this),w=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return w=t,Rt(this),this.f&=-2,!0};ee.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}I.prototype.S.call(this,t)};ee.prototype.U=function(t){if(this.t!==void 0&&(I.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};ee.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(ee.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Lt(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Y(t,e){return new ee(t,e)}function jt(t){var e=t.m;if(t.m=void 0,typeof e=="function"){q++;var n=w;w=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,Ge(t),i}finally{w=n,je()}}}function Ge(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,jt(t)}function ln(t){if(w!==this)throw new Error("Out-of-order effect");Rt(this),w=t,this.f&=-2,8&this.f&&Ge(this),je()}function re(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e==null?void 0:e.name}re.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};re.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,jt(this),Pt(this),q++;var t=w;return w=this,ln.bind(this,t)};re.prototype.N=function(){2&this.f||(this.f|=2,this.u=de,de=this)};re.prototype.d=function(){this.f|=8,1&this.f||Ge(this)};re.prototype.dispose=function(){this.d()};function he(t,e){var n=new re(t,e);try{n.c()}catch(r){throw n.d(),r}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}var Mt,me,an=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,Dt=[];he(function(){Mt=this.N})();function le(t,e){k[t]=e.bind(null,k[t]||function(){})}function Ee(t){if(me){var e=me;me=void 0,e()}me=t&&t.S()}function Ut(t){var e=this,n=t.data,i=cn(n);i.value=n;var r=Re(function(){for(var a=e,d=e.__v;d=d.__;)if(d.__c){d.__c.__$f|=4;break}var u=Y(function(){var _=i.value.value;return _===0?0:_===!0?"":_||""}),y=Y(function(){return!Array.isArray(u.value)&&!mt(u.value)}),c=he(function(){if(this.N=Ot,y.value){var _=u.value;a.__v&&a.__v.__e&&a.__v.__e.nodeType===3&&(a.__v.__e.data=_)}}),f=e.__$u.d;return e.__$u.d=function(){c(),f.call(this)},[y,u]},[]),o=r[0],l=r[1];return o.value?l.peek():l.value}Ut.displayName="ReactiveTextNode";Object.defineProperties(I.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Ut},props:{configurable:!0,get:function(){var t=this;return{data:{get value(){return t.value}}}}},__b:{configurable:!0,value:1}});le("__b",function(t,e){if(typeof e.type=="string"){var n,i=e.props;for(var r in i)if(r!=="children"){var o=i[r];o instanceof I&&(n||(e.__np=n={}),n[r]=o,i[r]=o.peek())}}t(e)});le("__r",function(t,e){if(t(e),e.type!==J){Ee();var n,i=e.__c;i&&(i.__$f&=-2,(n=i.__$u)===void 0&&(i.__$u=n=(function(r,o){var l;return he(function(){l=this},{name:o}),l.c=r,l})(function(){var r;an&&((r=n.y)==null||r.call(n)),i.__$f|=1,i.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),Ee(n)}});le("__e",function(t,e,n,i){Ee(),t(e,n,i)});le("diffed",function(t,e){Ee();var n;if(typeof e.type=="string"&&(n=e.__e)){var i=e.__np,r=e.props;if(i){var o=n.U;if(o)for(var l in o){var a=o[l];a!==void 0&&!(l in i)&&(a.d(),o[l]=void 0)}else o={},n.U=o;for(var d in i){var u=o[d],y=i[d];u===void 0?(u=sn(n,d,y),o[d]=u):u.o(y,r)}for(var c in i)r[c]=i[c]}}t(e)});function sn(t,e,n,i){var r=e in t&&t.ownerSVGElement===void 0,o=T(n),l=n.peek();return{o:function(a,d){o.value=a,l=a.peek()},d:he(function(){this.N=Ot;var a=o.value.value;l!==a?(l=void 0,r?t[e]=a:a!=null&&(a!==!1||e[4]==="-")?t.setAttribute(e,a):t.removeAttribute(e)):l=void 0})}}le("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var i=n.U;if(i){n.U=void 0;for(var r in i){var o=i[r];o&&o.d()}}}e.__np=void 0}else{var l=e.__c;if(l){var a=l.__$u;a&&(l.__$u=void 0,a.d())}}t(e)});le("__h",function(t,e,n,i){(i<3||i===9)&&(e.__$f|=2),t(e,n,i)});ue.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,i=n&&n.s!==void 0;for(var r in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(i||o||4&this.__$f)||1&this.__$f)return!0}else if(!(i||4&this.__$f)||3&this.__$f)return!0;for(var l in t)if(l!=="__source"&&t[l]!==this.props[l])return!0;for(var a in this.props)if(!(a in t))return!0;return!1};function cn(t,e){return Re(function(){return T(t,e)},[])}var un=function(t){queueMicrotask(function(){queueMicrotask(t)})};function dn(){on(function(){for(var t;t=Dt.shift();)Mt.call(t)})}function Ot(){Dt.push(this)===1&&(k.requestAnimationFrame||un)(dn)}const W=T([]),X=T(null),H=T(""),oe=T([]);T(null);const C=T([]),L=T([]),O=T(null),pe=T(!1),Ae=T(null),Te=T(null),B=T(localStorage.getItem("mdprobe-left-panel")!=="false"),K=T(localStorage.getItem("mdprobe-right-panel")!=="false"),Z=T(localStorage.getItem("mdprobe-theme")||"mocha"),Ne=T(!1);B.subscribe(t=>localStorage.setItem("mdprobe-left-panel",t));K.subscribe(t=>localStorage.setItem("mdprobe-right-panel",t));const Le=T("anonymous"),Ue=T(!1),Q=Y(()=>C.value.filter(t=>t.status==="open"));Y(()=>C.value.filter(t=>t.status==="resolved"));const Be=Y(()=>{let t=pe.value?C.value:C.value.filter(e=>e.status==="open");return Ae.value&&(t=t.filter(e=>e.tag===Ae.value)),Te.value&&(t=t.filter(e=>e.author===Te.value)),t}),fn=Y(()=>[...new Set(C.value.map(t=>t.tag))]),_n=Y(()=>[...new Set(C.value.map(t=>t.author))]),se=T(2),ne=Y(()=>{const t=se.value,e=L.value.filter(r=>r.level===t),n=e.length,i=e.filter(r=>r.status!=="pending").length;return{total:n,reviewed:i}}),dt=2e3,pn=3e4;function hn(){const t=z(null),e=z(dt),n=z(null),i=z(!1),r=Qt(()=>{if(i.current)return;const o=location.protocol==="https:"?"wss:":"ws:",l=new WebSocket(`${o}//${location.host}/ws`);t.current=l,l.onopen=()=>{e.current=dt},l.onmessage=a=>{let d;try{d=JSON.parse(a.data)}catch{console.warn("mdprobe: received non-JSON WebSocket message");return}switch(d.type){case"update":{const u=document.querySelector(".content-area"),y=u?u.scrollTop:0;H.value=d.html,oe.value=d.toc||[],u&&requestAnimationFrame(()=>{u.scrollTop=y});break}case"file-added":W.value.some(u=>u.path===d.file)||(W.value=[...W.value,{path:d.file,label:d.file.replace(/\.md$/,"")}]);break;case"file-removed":W.value=W.value.filter(u=>u.path!==d.file);break;case"annotations":(!d.file||d.file===X.value)&&(C.value=d.annotations||[],L.value=d.sections||[]);break;case"drift":Ne.value=d.warning||!0;break;case"error":console.warn("mdprobe:",d.message);break}},l.onerror=a=>{console.warn("mdprobe: WebSocket error",a)},l.onclose=()=>{if(t.current=null,i.current)return;const a=e.current;e.current=Math.min(a*2,pn);const d=Math.random()*a*.3;n.current=setTimeout(r,a+d)}},[]);return M(()=>(i.current=!1,r(),()=>{var o;i.current=!0,clearTimeout(n.current),(o=t.current)==null||o.close(),t.current=null}),[r]),t}function vn({onShowHelp:t}={}){M(()=>{function e(n){var r,o;const i=(r=document.activeElement)==null?void 0:r.tagName;if(!(i==="TEXTAREA"||i==="INPUT"||i==="SELECT")&&!((o=document.activeElement)!=null&&o.isContentEditable))switch(n.key){case"[":n.preventDefault(),B.value=!B.value;break;case"]":n.preventDefault(),K.value=!K.value;break;case"\\":{n.preventDefault();const l=B.value&&K.value;B.value=!l,K.value=!l;break}case"j":n.preventDefault(),ft(1);break;case"k":n.preventDefault(),ft(-1);break;case"r":break;case"e":break;case"?":n.preventDefault(),t==null||t();break}}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t])}function ft(t){const e=Be.value;if(e.length===0)return;const n=O.value,i=e.findIndex(d=>d.id===n);let r;i===-1?r=t>0?0:e.length-1:(r=i+t,r<0&&(r=e.length-1),r>=e.length&&(r=0));const o=e[r];O.value=o.id;const l=document.querySelector(`[data-annotation-id="${o.id}"]`);l==null||l.scrollIntoView({behavior:"smooth",block:"nearest"});const a=document.querySelector(`[data-highlight-id="${o.id}"]`);a==null||a.scrollIntoView({behavior:"smooth",block:"center"})}const mn=[{id:"mocha",label:"Mocha",color:"#1e1e2e"},{id:"macchiato",label:"Macchiato",color:"#24273a"},{id:"frappe",label:"Frappé",color:"#303446"},{id:"latte",label:"Latte",color:"#eff1f5"},{id:"light",label:"Light",color:"#ffffff"}],gn="mdprobe-theme";function yn(){M(()=>(_t(Z.value),Z.subscribe(n=>{_t(n)})),[]);function t(e){Z.value=e}return{theme:Z,setTheme:t,themes:mn}}function _t(t){document.documentElement.setAttribute("data-theme",t);try{localStorage.setItem(gn,t)}catch{}}const Oe="";function bn(){async function t(p){const h=await fetch(`${Oe}/api/annotations?path=${encodeURIComponent(p)}`);if(!h.ok)throw new Error(`Failed to fetch annotations: ${h.status}`);const v=await h.json();return C.value=v.annotations||[],L.value=v.sections||[],v.sectionLevel!=null&&(se.value=v.sectionLevel),Ne.value=v.drift||!1,v}async function e({selectors:p,comment:h,tag:v}){const m=await f("add",{selectors:p,comment:h,tag:v,author:Le.value});return C.value=m.annotations||C.value,m}async function n(p){const h=await f("resolve",{id:p});C.value=h.annotations||C.value}async function i(p){const h=await f("reopen",{id:p});C.value=h.annotations||C.value}async function r(p,{comment:h,tag:v}){const m=await f("update",{id:p,comment:h,tag:v});C.value=m.annotations||C.value}async function o(p){const h=await f("delete",{id:p});C.value=h.annotations||C.value}async function l(p,h){const v=await f("reply",{id:p,author:Le.value,comment:h});C.value=v.annotations||C.value}async function a(p){const h=await _("approve",{heading:p});L.value=h.sections||L.value,h.sectionLevel!=null&&(se.value=h.sectionLevel)}async function d(p){const h=await _("reject",{heading:p});L.value=h.sections||L.value,h.sectionLevel!=null&&(se.value=h.sectionLevel)}async function u(){const p=await _("approveAll");L.value=p.sections||L.value}async function y(p){const h=await _("reset",{heading:p});L.value=h.sections||L.value,h.sectionLevel!=null&&(se.value=h.sectionLevel)}async function c(){const p=await _("clearAll");L.value=p.sections||L.value}async function f(p,h){const v=await fetch(`${Oe}/api/annotations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:X.value,action:p,data:h})});if(!v.ok)throw new Error(`Annotation ${p} failed: ${v.status}`);return v.json()}async function _(p,h={}){const v=await fetch(`${Oe}/api/sections`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:X.value,action:p,...h})});if(!v.ok)throw new Error(`Section ${p} failed: ${v.status}`);return v.json()}return{fetchAnnotations:t,createAnnotation:e,resolveAnnotation:n,reopenAnnotation:i,updateAnnotation:r,deleteAnnotation:o,addReply:l,approveSection:a,rejectSection:d,resetSection:y,approveAllSections:u,clearAllSections:c}}const xn="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js",wn="https://cdn.jsdelivr.net/npm/katex@0.16/dist/katex.min.css",kn="https://cdn.jsdelivr.net/npm/katex@0.16/dist/katex.min.js";let pt=!1,ht=!1;function qt(t){return new Promise((e,n)=>{if(document.querySelector(`script[src="${t}"]`))return e();const i=document.createElement("script");i.src=t,i.onload=e,i.onerror=n,document.head.appendChild(i)})}function Sn(t){if(document.querySelector(`link[href="${t}"]`))return;const e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}function $n(){const t=z("");M(()=>{if(H.value===t.current)return;t.current=H.value;const e=document.querySelectorAll("pre.mermaid:not([data-processed])");e.length>0&&Cn(e);const n=document.querySelectorAll("[data-math], .math-inline, .math-display");n.length>0&&En(n)},[H.value,Z.value])}async function Cn(t){try{pt||(await qt(xn),pt=!0);const e=!["latte","light"].includes(Z.value);window.mermaid.initialize({startOnLoad:!1,theme:e?"dark":"default"});for(const n of t)n.setAttribute("data-processed","true");await window.mermaid.run({nodes:[...t]})}catch(e){console.warn("mdprobe: Mermaid rendering failed",e)}}async function En(t){try{ht||(Sn(wn),await qt(kn),ht=!0);for(const e of t){if(e.getAttribute("data-katex-rendered"))continue;const n=e.textContent,i=e.classList.contains("math-display");try{window.katex.render(n,e,{displayMode:i,throwOnError:!1}),e.setAttribute("data-katex-rendered","true")}catch{}}}catch(e){console.warn("mdprobe: KaTeX rendering failed",e)}}function An({onFileSelect:t}){const e=!B.value;function n(i){const r=oe.value,o=r[i];if(!o)return 0;const l=o.line;let a=1/0;for(let d=i+1;d<r.length;d++)if(r[d].level<=o.level){a=r[d].line;break}return Q.value.filter(d=>{var y,c;const u=(c=(y=d.selectors)==null?void 0:y.position)==null?void 0:c.startLine;return u!=null&&u>=l&&u<a}).length}return s("aside",{class:`left-panel ${e?"collapsed":""}`,children:e?s("div",{class:"panel-collapsed-indicator",onClick:()=>B.value=!0,children:[s("span",{children:"☰"}),s("span",{class:"shortcut-key",children:"["}),Q.value.length>0&&s("span",{class:"badge",children:Q.value.length})]}):s("div",{class:"panel-content",children:[s("div",{class:"panel-header",style:"padding: 12px; display: flex; justify-content: space-between; align-items: center",children:[s("span",{style:"font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted)",children:"Files & TOC"}),s("button",{class:"btn btn-sm btn-ghost",onClick:()=>B.value=!1,children:"×"})]}),W.value.length>1&&s("div",{style:"padding: 0 8px 8px",children:[s("div",{style:"font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 4px 4px 6px; font-weight: 600",children:"Files"}),W.value.map(i=>{const r=i.path||i,o=i.label||r.replace(".md",""),l=r===X.value;return s("div",{class:`file-item ${l?"active":""}`,onClick:()=>t(r),children:[s("span",{class:"icon",children:"📄"}),s("span",{children:o})]},r)})]}),s("div",{style:"padding: 0 8px",children:[s("div",{style:"font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 4px 4px 6px; font-weight: 600",children:"Sections"}),oe.value.length===0?s("div",{style:"padding: 8px; color: var(--text-muted); font-size: 13px",children:"No sections"}):oe.value.map((i,r)=>{const o=n(r),l=L.value.find(d=>d.heading===i.heading&&d.level===i.level),a=(l==null?void 0:l.status)==="approved"?"dot-approved":(l==null?void 0:l.status)==="rejected"?"dot-rejected":"";return s("div",{class:`toc-item level-${i.level}`,onClick:()=>{const d=document.querySelector(`[data-source-line="${i.line}"]`);d==null||d.scrollIntoView({behavior:"smooth",block:"start"})},children:[a&&s("span",{class:`toc-dot ${a}`}),i.heading,o>0&&s("span",{class:"badge",style:"margin-left: 6px",children:o})]},r)})]})]})})}const Tn=[{value:"question",label:"Question"},{value:"bug",label:"Bug"},{value:"suggestion",label:"Suggestion"},{value:"nitpick",label:"Nitpick"}];function Ht({annotation:t,selectors:e,exact:n,onSave:i,onCancel:r}){const o=!!t,[l,a]=V((t==null?void 0:t.comment)||""),[d,u]=V((t==null?void 0:t.tag)||"question");function y(f){f.preventDefault(),l.trim()&&i(o?{comment:l.trim(),tag:d}:{selectors:e,comment:l.trim(),tag:d})}function c(f){(f.metaKey||f.ctrlKey)&&f.key==="Enter"&&y(f),f.key==="Escape"&&r()}return s("form",{class:"annotation-form",onSubmit:y,onKeyDown:c,onClick:f=>f.stopPropagation(),children:[n&&s("div",{class:"annotation-form__quote",children:n}),s("div",{class:"annotation-form__tags",children:Tn.map(f=>s("button",{type:"button",class:`tag-pill tag-pill--${f.value}${d===f.value?" tag-pill--active":""}`,onClick:()=>u(f.value),children:f.label},f.value))}),s("textarea",{value:l,onInput:f=>a(f.target.value),placeholder:"Add your comment... (Ctrl+Enter to save)",autoFocus:!0}),s("div",{class:"annotation-form__actions",children:[s("span",{class:"annotation-form__hint",children:"Ctrl+Enter to save · Esc to close"}),s("button",{type:"button",class:"btn btn--ghost",onClick:r,children:"Cancel"}),s("button",{type:"submit",class:"btn btn--primary",disabled:!l.trim(),children:o?"Save":"Annotate"})]})]})}function Nn({replies:t}){return!t||t.length===0?null:s("div",{style:"margin-top: 8px",children:t.map((e,n)=>s("div",{class:"reply",children:[s("div",{class:"author",children:e.author}),s("div",{class:"text",children:e.comment}),s("div",{style:"font-size: 10px; color: var(--text-muted); margin-top: 2px",children:Ln(e.created_at)})]},n))})}function Ln(t){if(!t)return"";try{const e=new Date(t);return e.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}catch{return t}}function In({annotationOps:t}){const e=!K.value,[n,i]=V(null);function r(o){O.value=o.id;const l=document.querySelector(`[data-highlight-id="${o.id}"]`);l==null||l.scrollIntoView({behavior:"smooth",block:"center"})}return s("aside",{class:`right-panel ${e?"collapsed":""}`,children:e?s("div",{class:"panel-collapsed-indicator",onClick:()=>K.value=!0,children:[s("span",{children:"💬"}),s("span",{class:"shortcut-key",children:"]"}),Q.value.length>0&&s("span",{class:"badge",children:Q.value.length})]}):s("div",{class:"panel-content",children:[s("div",{class:"panel-header",style:"padding: 12px; display: flex; justify-content: space-between; align-items: center",children:[s("span",{style:"font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted)",children:["Annotations (",Q.value.length," open)"]}),s("button",{class:"btn btn-sm btn-ghost",onClick:()=>K.value=!1,children:"×"})]}),s("div",{style:"padding: 0 12px 8px; display: flex; gap: 6px; flex-wrap: wrap",children:[s("select",{class:"filter-select",value:Ae.value||"",onChange:o=>Ae.value=o.target.value||null,style:"padding: 3px 6px; font-size: 11px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-primary); color: var(--text-primary)",children:[s("option",{value:"",children:"All tags"}),fn.value.map(o=>s("option",{value:o,children:o},o))]}),s("select",{value:Te.value||"",onChange:o=>Te.value=o.target.value||null,style:"padding: 3px 6px; font-size: 11px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-primary); color: var(--text-primary)",children:[s("option",{value:"",children:"All authors"}),_n.value.map(o=>s("option",{value:o,children:o},o))]}),s("label",{style:"display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); cursor: pointer",children:[s("input",{type:"checkbox",checked:pe.value,onChange:o=>pe.value=o.target.checked}),"Show resolved"]})]}),s("div",{style:"overflow-y: auto; padding: 0 8px; flex: 1",children:Be.value.length===0?s("div",{style:"padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px",children:"No annotations"}):Be.value.map(o=>{var l,a,d;return s("div",{"data-annotation-id":o.id,class:`annotation-card ${O.value===o.id?"selected":""} ${o.status==="resolved"?"resolved":""}`,onClick:()=>r(o),children:[s("div",{style:"display: flex; align-items: center; gap: 6px; margin-bottom: 6px",children:[s("span",{class:`tag tag-${o.tag}`,children:o.tag}),s("span",{style:"font-size: 11px; color: var(--text-muted)",children:o.author}),o.status==="resolved"&&s("span",{style:"font-size: 10px; color: var(--status-approved)",children:"✓ resolved"})]}),((a=(l=o.selectors)==null?void 0:l.quote)==null?void 0:a.exact)&&s("div",{class:"quote",children:o.selectors.quote.exact}),s("div",{style:"font-size: 13px; margin-top: 4px",children:o.comment}),O.value===o.id&&s("div",{style:"margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap",children:[o.status==="open"?s("button",{class:"btn btn-sm",onClick:u=>{u.stopPropagation(),t.resolveAnnotation(o.id)},children:"Resolve"}):s("button",{class:"btn btn-sm",onClick:u=>{u.stopPropagation(),t.reopenAnnotation(o.id)},children:"Reopen"}),s("button",{class:"btn btn-sm",onClick:u=>{u.stopPropagation(),i(o.id)},children:"Edit"}),s("button",{class:"btn btn-sm btn-danger",onClick:u=>{u.stopPropagation(),confirm("Delete this annotation?")&&t.deleteAnnotation(o.id)},children:"Delete"})]}),n===o.id&&s(Ht,{annotation:o,onSave:u=>{t.updateAnnotation(o.id,u),i(null)},onCancel:()=>i(null)}),((d=o.replies)==null?void 0:d.length)>0&&s(Nn,{replies:o.replies}),O.value===o.id&&s(Pn,{annotationId:o.id,onReply:t.addReply})]},o.id)})})]})})}function Pn({annotationId:t,onReply:e}){const[n,i]=V("");function r(o){o.preventDefault(),n.trim()&&(e(t,n.trim()),i(""))}return s("form",{class:"reply-input",onSubmit:r,onClick:o=>o.stopPropagation(),children:[s("input",{type:"text",value:n,onInput:o=>i(o.target.value),placeholder:"Reply..."}),s("button",{type:"submit",class:"btn btn-sm btn-primary",disabled:!n.trim(),children:"Reply"})]})}function Rn({x:t,y:e,exact:n,selectors:i,onSave:r,onCancel:o}){const l=z(null),a=z({active:!1,startX:0,startY:0}),d=520,u=440,y=typeof window<"u"?window.innerWidth:800,_=(typeof window<"u"?window.innerHeight:800)-e<u,p=Math.max(16,Math.min(t-d/2,y-d-16)),h=_?Math.max(8,e-u-8):e,[v,m]=V({left:p,top:h});M(()=>{function b(x){x.key==="Escape"&&o()}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[o]),M(()=>{function b(S){a.current.active&&m({left:S.clientX-a.current.startX,top:S.clientY-a.current.startY})}function x(){a.current.active=!1}return document.addEventListener("mousemove",b),document.addEventListener("mouseup",x),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",x)}},[]);function g(b){b.button===0&&(a.current={active:!0,startX:b.clientX-v.left,startY:b.clientY-v.top},b.preventDefault())}const $={position:"fixed",left:`${v.left}px`,top:`${v.top}px`,width:`${d}px`,zIndex:101};return s("div",{class:"popover popover--enter",ref:l,style:$,children:[s("div",{class:"popover__header",onMouseDown:g,children:[s("span",{class:"popover__title",children:"New Annotation"}),s("button",{type:"button",class:"popover__close",onClick:o,"aria-label":"Close",children:"×"})]}),s(Ht,{exact:n,selectors:i,onSave:r,onCancel:o})]})}function jn({annotationOps:t}){const e=z(null),[n,i]=V(null);M(()=>{var p,h,v,m,g,$;const f=e.current;if(!f)return;f.querySelectorAll("mark[data-highlight-id]").forEach(b=>{const x=b.parentNode;for(;b.firstChild;)x.insertBefore(b.firstChild,b);x.removeChild(b)});const _=pe.value?C.value:C.value.filter(b=>b.status==="open");for(const b of _){const x=(h=(p=b.selectors)==null?void 0:p.position)==null?void 0:h.startLine;if(!x)continue;const S=f.querySelector(`[data-source-line="${x}"]`);if(!S)continue;const R=(m=(v=b.selectors)==null?void 0:v.quote)==null?void 0:m.exact;if(!R)continue;const j=`annotation-highlight tag-${b.tag}${b.status==="resolved"?" resolved":""}${O.value===b.id?" selected":""}`;if(r(S,R,b.id,j))continue;const P=(($=(g=b.selectors)==null?void 0:g.position)==null?void 0:$.endLine)||x;o(f,S,P,R,b.id,j)||x!==P&&l(f,x,P,b.id,j)}},[H.value,C.value,pe.value,O.value]),M(()=>{const f=e.current;!f||L.value.length===0||(f.querySelectorAll(".section-approval-injected").forEach(_=>_.remove()),f.querySelectorAll(":is(h1,h2,h3,h4,h5,h6)[data-source-line]").forEach(_=>{const p=_.textContent.trim(),h=L.value.find(S=>S.heading===p);if(!h)return;const v=h.computed||h.status,m=document.createElement("span");m.className="section-approval-injected";const g=document.createElement("button"),$=v==="approved"?" section-status approved":v==="indeterminate"?" section-status indeterminate":"";g.className=`btn btn-sm${$}`,g.textContent=v==="indeterminate"?"─":"✓",g.title=v==="indeterminate"?"Partially approved — click to approve all":"Approve section",g.onclick=S=>{S.stopPropagation(),h.status==="approved"?t.resetSection(p):t.approveSection(p)};const b=document.createElement("button");b.className=`btn btn-sm${v==="rejected"?" section-status rejected":""}`,b.textContent="✗",b.title="Reject section",b.onclick=S=>{S.stopPropagation(),h.status==="rejected"?t.resetSection(p):t.rejectSection(p)};const x=v!=="pending"?v:"";if(x){const S=document.createElement("span");S.className=`section-status-label ${v}`,S.style.cssText="font-size: 10px; margin-left: 4px",S.textContent=x,m.appendChild(S)}m.style.cssText="display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle",m.insertBefore(b,m.firstChild),m.insertBefore(g,m.firstChild),_.appendChild(m)}))},[H.value,L.value]);function r(f,_,p,h){const v=document.createTreeWalker(f,NodeFilter.SHOW_TEXT);let m;for(;m=v.nextNode();){const g=m.textContent.indexOf(_);if(g===-1)continue;const $=document.createRange();$.setStart(m,g),$.setEnd(m,g+_.length);const b=document.createElement("mark");b.setAttribute("data-highlight-id",p),b.className=h;try{$.surroundContents(b)}catch{return!1}return!0}return!1}function o(f,_,p,h,v,m){var D,Ze;const g=[],$=document.createTreeWalker(f,NodeFilter.SHOW_TEXT);let b,x=!1;for(;b=$.nextNode();){if(!x&&_.contains(b)&&(x=!0),!x)continue;g.push(b);const N=d(b,f);if(N&&parseInt(N.getAttribute("data-source-line"))>p)break}if(g.length===0)return!1;let S="";const R=[];for(let N=0;N<g.length;N++){if(N>0){const ae=(D=g[N-1].parentElement)==null?void 0:D.closest("[data-source-line]"),te=(Ze=g[N].parentElement)==null?void 0:Ze.closest("[data-source-line]");ae!==te&&(S+=`
2
- `)}const G=S.length;S+=g[N].textContent,R.push({node:g[N],startInConcat:G,endInConcat:S.length})}let j=S.indexOf(h);if(j===-1){const N=S.replace(/\s+/g," "),G=h.replace(/\s+/g," ");if(N.indexOf(G)===-1)return!1;for(const te of R)a(te.node,0,te.node.textContent.length,v,m);return!0}const P=j+h.length;for(const N of R){const G=Math.max(j,N.startInConcat),ae=Math.min(P,N.endInConcat);if(G>=ae)continue;const te=G-N.startInConcat,Ft=ae-N.startInConcat;a(N.node,te,Ft,v,m)}return!0}function l(f,_,p,h,v){const m=f.querySelectorAll("[data-source-line]");for(const g of m){const $=parseInt(g.getAttribute("data-source-line"));if($<_||$>p)continue;const b=document.createTreeWalker(g,NodeFilter.SHOW_TEXT);let x;for(;x=b.nextNode();)x.textContent.trim()!==""&&a(x,0,x.textContent.length,h,v)}}function a(f,_,p,h,v){if(!(_>=p||_>=f.textContent.length))try{const m=document.createRange();m.setStart(f,_),m.setEnd(f,Math.min(p,f.textContent.length));const g=document.createElement("mark");g.setAttribute("data-highlight-id",h),g.className=v,m.surroundContents(g)}catch{}}function d(f,_){var h;let p=f.nodeType===3?f.parentElement:f;for(;p&&p!==_;){if((h=p.hasAttribute)!=null&&h.call(p,"data-source-line"))return p;p=p.parentElement}return null}function u(f){const _=window.getSelection();if(!_||_.isCollapsed||_.toString().trim()==="")return;const p=_.toString(),h=_.getRangeAt(0),v=h.getBoundingClientRect(),m=y(h.startContainer),g=y(h.endContainer);if(m){const $=parseInt(m.getAttribute("data-source-line")),b=parseInt(m.getAttribute("data-source-col")||"1"),x=g?parseInt(g.getAttribute("data-source-line")):$,S=g?parseInt(g.getAttribute("data-source-col")||"1"):b+p.length;i({x:v.left+v.width/2,y:v.bottom+8,exact:p,selectors:{position:{startLine:$,startColumn:b,endLine:x,endColumn:S},quote:{exact:p,prefix:"",suffix:""}}})}}function y(f){var p;let _=f.nodeType===3?f.parentElement:f;for(;_&&_!==e.current;){if((p=_.hasAttribute)!=null&&p.call(_,"data-source-line"))return _;_=_.parentElement}return null}function c(f){const _=f.target.closest("[data-highlight-id]");_&&(O.value=_.getAttribute("data-highlight-id"))}return s("main",{class:"content-area-wrapper",children:[s("div",{class:"content-area",ref:e,onClick:c,onMouseUp:u,dangerouslySetInnerHTML:{__html:H.value||""}}),n&&s(Rn,{x:n.x,y:n.y,exact:n.exact,selectors:n.selectors,onSave:f=>{var _;t.createAnnotation(f),i(null),(_=window.getSelection())==null||_.removeAllRanges()},onCancel:()=>{var f;i(null),(f=window.getSelection())==null||f.removeAllRanges()}})]})}function Mn({themes:t,onSelect:e}){return s("div",{class:"theme-picker",title:"Switch theme",children:t.map(n=>s("button",{class:`theme-swatch ${Z.value===n.id?"active":""}`,style:`background: ${n.color}`,onClick:()=>e(n.id),title:n.label,"aria-label":`Switch to ${n.label} theme`},n.id))})}function Dn(){const[t,e]=V(!1);async function n(i){e(!1);const r=X.value;if(r)try{const o=await fetch(`/api/export?path=${encodeURIComponent(r)}&format=${i}`);if(!o.ok)throw new Error(await o.text());if(i==="report"){const l=await o.text(),a=new Blob([l],{type:"text/markdown"});window.open(URL.createObjectURL(a))}else{const l=await o.blob(),a={inline:".reviewed.md",json:".annotations.json",sarif:".annotations.sarif"}[i],d=document.createElement("a");d.href=URL.createObjectURL(l),d.download=r.replace(".md",a),d.click()}}catch(o){console.error("Export failed:",o),alert(`Export failed: ${o.message}`)}}return s("div",{style:"position: relative",children:[s("button",{class:"btn btn-sm",onClick:()=>e(!t),children:"Export"}),t&&s(J,{children:[s("div",{style:"position: fixed; inset: 0; z-index: 90",onClick:()=>e(!1)}),s("div",{style:"position: absolute; right: 0; top: 100%; margin-top: 4px; z-index: 100; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); min-width: 180px; overflow: hidden",children:[s("button",{class:"export-option",onClick:()=>n("report"),children:"Review Report (.md)"}),s("button",{class:"export-option",onClick:()=>n("inline"),children:"Inline Comments (.md)"}),s("button",{class:"export-option",onClick:()=>n("json"),children:"JSON (.json)"}),s("button",{class:"export-option",onClick:()=>n("sarif"),children:"SARIF (.sarif)"})]})]})]})}function Un(){const[t,e]=V(!1);hn();const{setTheme:n,themes:i}=yn(),r=bn();$n(),vn({onShowHelp:()=>e(l=>!l)}),M(()=>{if(!t)return;function l(a){a.key==="Escape"&&(a.preventDefault(),e(!1))}return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t]),M(()=>{fetch("/api/files").then(l=>l.json()).then(l=>{if(W.value=l,l.length>0){const a=l[0].path||l[0];X.value=a,fetch(`/api/file?path=${encodeURIComponent(a)}`).then(d=>d.json()).then(d=>{H.value=d.html,oe.value=d.toc||[]}),r.fetchAnnotations(a)}}),fetch("/api/config").then(l=>l.json()).then(l=>{Le.value=l.author||"anonymous"}),fetch("/api/review/status").then(l=>l.json()).then(l=>{l.mode==="once"&&(Ue.value=!0)}).catch(()=>{})},[]);function o(l){X.value=l,fetch(`/api/file?path=${encodeURIComponent(l)}`).then(a=>a.json()).then(a=>{H.value=a.html,oe.value=a.toc||[]}),r.fetchAnnotations(l)}return s(J,{children:[s("header",{class:"header",children:[s("h1",{children:"mdprobe"}),s("span",{class:"header-file",children:X.value||"No file selected"}),s("div",{style:"flex: 1"}),ne.value.total>0&&(Ue.value||ne.value.reviewed>0)&&s("div",{class:"progress-info",children:[s("span",{children:[ne.value.reviewed,"/",ne.value.total," sections reviewed"]}),s("div",{class:"progress-bar",style:"width: 100px",children:s("div",{class:"fill",style:`width: ${ne.value.reviewed/ne.value.total*100}%`})})]}),s(Dn,{}),s(Mn,{themes:i,onSelect:n}),Ue.value&&s("button",{class:"btn btn-primary btn-sm",onClick:async()=>{try{await fetch("/api/review/finish",{method:"POST"})}catch{}},children:"Finish Review"})]}),Ne.value&&s("div",{class:"drift-banner",children:["Arquivo modificado desde a ultima revisao. Algumas anotacoes podem estar desalinhadas.",s("button",{class:"btn btn-sm",style:"margin-left: 8px",onClick:()=>Ne.value=!1,children:"Dismiss"})]}),s(An,{onFileSelect:o}),s(jn,{annotationOps:r}),s(In,{annotationOps:r}),s("footer",{class:"status-bar",children:[s("span",{children:[Q.value.length," open"]}),s("span",{children:["Author: ",Le.value]}),s("span",{children:"Press ? for shortcuts"})]}),t&&s(J,{children:[s("div",{class:"shortcut-modal overlay",onClick:()=>e(!1)}),s("div",{class:"shortcut-modal",children:[s("h3",{style:"margin-bottom: 12px",children:"Keyboard Shortcuts"}),[["[","Toggle left panel (Files/TOC)"],["]","Toggle right panel (Annotations)"],["\\","Toggle both panels (focus mode)"],["j","Next annotation"],["k","Previous annotation"],["r","Resolve selected annotation"],["e","Edit selected annotation"],["?","Show/hide this help"]].map(([l,a])=>s("div",{class:"shortcut-row",children:[s("span",{children:a}),s("span",{class:"shortcut-key",children:l})]},l)),s("button",{class:"btn btn-sm",style:"margin-top: 12px",onClick:()=>e(!1),children:"Close"})]})]})]})}Yt(s(Un,{}),document.getElementById("app"));