@codewithdan/zingit 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/zingit-client.js +75 -16
- package/package.json +1 -1
|
@@ -32,7 +32,11 @@
|
|
|
32
32
|
|
|
33
33
|
<div class="divider"></div>
|
|
34
34
|
|
|
35
|
-
<div
|
|
35
|
+
<div
|
|
36
|
+
class="count ${0===this.annotationCount?"disabled":""}"
|
|
37
|
+
title="${this.annotationCount>0?"Click to highlight annotations":""}"
|
|
38
|
+
@click=${this.handleCountClick}
|
|
39
|
+
>
|
|
36
40
|
${this.annotationCount} annotation${1!==this.annotationCount?"s":""}
|
|
37
41
|
</div>
|
|
38
42
|
|
|
@@ -139,7 +143,7 @@
|
|
|
139
143
|
</svg>
|
|
140
144
|
</button>
|
|
141
145
|
</div>
|
|
142
|
-
`}handleAgentButton(){this.annotationCount>0&&!this.processing?this.dispatchEvent(new CustomEvent("send",{bubbles:!0,composed:!0})):this.dispatchEvent(new CustomEvent("toggle-response",{bubbles:!0,composed:!0}))}handleExport(){this.dispatchEvent(new CustomEvent("export",{bubbles:!0,composed:!0}))}handleClear(){this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0}))}handleHelp(){this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0}))}handleSettings(){this.dispatchEvent(new CustomEvent("settings",{bubbles:!0,composed:!0}))}handleClose(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}handleReconnect(){this.dispatchEvent(new CustomEvent("reconnect",{bubbles:!0,composed:!0}))}handleToggle(){this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,composed:!0}))}handleHistory(){this.dispatchEvent(new CustomEvent("toggle-history",{bubbles:!0,composed:!0}))}handleAgentClick(){this.connected&&this.agent&&this.dispatchEvent(new CustomEvent("change-agent",{bubbles:!0,composed:!0}))}handleDragStart(A){A.preventDefault(),this.dispatchEvent(new CustomEvent("drag-start",{bubbles:!0,composed:!0,detail:{clientX:A.clientX,clientY:A.clientY}}))}handleDragReset(A){A.preventDefault(),A.stopPropagation(),this.dispatchEvent(new CustomEvent("drag-reset",{bubbles:!0,composed:!0}))}};ma.styles=o`
|
|
146
|
+
`}handleAgentButton(){this.annotationCount>0&&!this.processing?this.dispatchEvent(new CustomEvent("send",{bubbles:!0,composed:!0})):this.dispatchEvent(new CustomEvent("toggle-response",{bubbles:!0,composed:!0}))}handleExport(){this.dispatchEvent(new CustomEvent("export",{bubbles:!0,composed:!0}))}handleClear(){this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0}))}handleHelp(){this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0}))}handleSettings(){this.dispatchEvent(new CustomEvent("settings",{bubbles:!0,composed:!0}))}handleClose(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}handleReconnect(){this.dispatchEvent(new CustomEvent("reconnect",{bubbles:!0,composed:!0}))}handleToggle(){this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,composed:!0}))}handleHistory(){this.dispatchEvent(new CustomEvent("toggle-history",{bubbles:!0,composed:!0}))}handleCountClick(){this.annotationCount>0&&this.dispatchEvent(new CustomEvent("highlight-annotations",{bubbles:!0,composed:!0}))}handleAgentClick(){this.connected&&this.agent&&this.dispatchEvent(new CustomEvent("change-agent",{bubbles:!0,composed:!0}))}handleDragStart(A){A.preventDefault(),this.dispatchEvent(new CustomEvent("drag-start",{bubbles:!0,composed:!0,detail:{clientX:A.clientX,clientY:A.clientY}}))}handleDragReset(A){A.preventDefault(),A.stopPropagation(),this.dispatchEvent(new CustomEvent("drag-reset",{bubbles:!0,composed:!0}))}};ma.styles=o`
|
|
143
147
|
:host {
|
|
144
148
|
display: block;
|
|
145
149
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
@@ -211,6 +215,24 @@
|
|
|
211
215
|
font-size: 12px;
|
|
212
216
|
color: #d1d5db;
|
|
213
217
|
min-width: 80px;
|
|
218
|
+
cursor: pointer;
|
|
219
|
+
padding: 4px 8px;
|
|
220
|
+
margin: -4px -8px;
|
|
221
|
+
border-radius: 4px;
|
|
222
|
+
transition: background 0.15s ease;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.count:hover {
|
|
226
|
+
background: #374151;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.count.disabled {
|
|
230
|
+
cursor: default;
|
|
231
|
+
opacity: 0.5;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.count.disabled:hover {
|
|
235
|
+
background: transparent;
|
|
214
236
|
}
|
|
215
237
|
|
|
216
238
|
button {
|
|
@@ -318,14 +340,14 @@
|
|
|
318
340
|
.drag-handle:active {
|
|
319
341
|
cursor: grabbing;
|
|
320
342
|
}
|
|
321
|
-
`,Fa([hA({type:Boolean})],ma.prototype,"active",2),Fa([hA({type:Boolean})],ma.prototype,"connected",2),Fa([hA({type:Boolean})],ma.prototype,"processing",2),Fa([hA({type:Boolean})],ma.prototype,"maxAttemptsReached",2),Fa([hA({type:Number})],ma.prototype,"annotationCount",2),Fa([hA({type:String})],ma.prototype,"agent",2),Fa([hA({type:String})],ma.prototype,"model",2),Fa([hA({type:Boolean})],ma.prototype,"responseOpen",2),Fa([hA({type:Boolean})],ma.prototype,"historyOpen",2),ma=Fa([cA("zing-toolbar")],ma);var ya=Object.defineProperty,ba=Object.getOwnPropertyDescriptor,va=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?ba(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ya(e,t,r),r};let Ha=class extends iA{constructor(){super(...arguments),this.top=0,this.left=0,this.width=0,this.height=0,this.label="",this.visible=!1}get labelAlignment(){const A=this.left+this.width,e=window.innerWidth;return A>e-220||this.left>e-250?"align-right":"align-left"}render(){return this.
|
|
343
|
+
`,Fa([hA({type:Boolean})],ma.prototype,"active",2),Fa([hA({type:Boolean})],ma.prototype,"connected",2),Fa([hA({type:Boolean})],ma.prototype,"processing",2),Fa([hA({type:Boolean})],ma.prototype,"maxAttemptsReached",2),Fa([hA({type:Number})],ma.prototype,"annotationCount",2),Fa([hA({type:String})],ma.prototype,"agent",2),Fa([hA({type:String})],ma.prototype,"model",2),Fa([hA({type:Boolean})],ma.prototype,"responseOpen",2),Fa([hA({type:Boolean})],ma.prototype,"historyOpen",2),ma=Fa([cA("zing-toolbar")],ma);var ya=Object.defineProperty,ba=Object.getOwnPropertyDescriptor,va=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?ba(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ya(e,t,r),r};let Ha=class extends iA{constructor(){super(...arguments),this.top=0,this.left=0,this.width=0,this.height=0,this.label="",this.visible=!1}get fillsViewport(){return this.height>window.innerHeight-100}get labelVerticalPosition(){return this.fillsViewport?"position-top":this.top<30?"position-bottom":"position-top"}get labelAlignment(){const A=this.left+this.width,e=window.innerWidth;return A>e-220||this.left>e-250?"align-right":"align-left"}render(){if(!this.visible)return N``;const A=[this.labelVerticalPosition,this.labelAlignment,this.fillsViewport?"fills-viewport":""].filter(A=>A).join(" ");return N`
|
|
322
344
|
<div
|
|
323
345
|
class="highlight"
|
|
324
346
|
style="top: ${this.top}px; left: ${this.left}px; width: ${this.width}px; height: ${this.height}px;"
|
|
325
347
|
>
|
|
326
|
-
${this.label?N`<span class="label ${
|
|
348
|
+
${this.label?N`<span class="label ${A}">${this.label}</span>`:""}
|
|
327
349
|
</div>
|
|
328
|
-
|
|
350
|
+
`}};Ha.styles=o`
|
|
329
351
|
:host {
|
|
330
352
|
display: block;
|
|
331
353
|
position: absolute;
|
|
@@ -335,28 +357,45 @@
|
|
|
335
357
|
|
|
336
358
|
.highlight {
|
|
337
359
|
position: absolute;
|
|
338
|
-
border:
|
|
339
|
-
background: rgba(251, 191, 36, 0.
|
|
360
|
+
border: 3px dashed var(--highlight-color, #fbbf24);
|
|
361
|
+
background: rgba(251, 191, 36, 0.15);
|
|
340
362
|
border-radius: 4px;
|
|
341
363
|
transition: all 0.1s ease;
|
|
364
|
+
box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.3);
|
|
342
365
|
}
|
|
343
366
|
|
|
344
367
|
.label {
|
|
345
368
|
position: absolute;
|
|
346
|
-
top: -24px;
|
|
347
369
|
padding: 2px 8px;
|
|
348
370
|
background: var(--highlight-color, #fbbf24);
|
|
349
371
|
color: #1f2937;
|
|
350
372
|
font-size: 11px;
|
|
351
373
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
352
374
|
font-weight: 500;
|
|
353
|
-
border-radius: 4px 4px 0 0;
|
|
354
375
|
white-space: nowrap;
|
|
355
376
|
max-width: 200px;
|
|
356
377
|
overflow: hidden;
|
|
357
378
|
text-overflow: ellipsis;
|
|
358
379
|
}
|
|
359
380
|
|
|
381
|
+
/* Default: label above element */
|
|
382
|
+
.label.position-top {
|
|
383
|
+
top: -24px;
|
|
384
|
+
border-radius: 4px 4px 0 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/* When element fills viewport: label inside at top */
|
|
388
|
+
.label.position-top.fills-viewport {
|
|
389
|
+
top: 4px;
|
|
390
|
+
border-radius: 4px;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/* When near top edge: label below element */
|
|
394
|
+
.label.position-bottom {
|
|
395
|
+
bottom: -24px;
|
|
396
|
+
border-radius: 0 0 4px 4px;
|
|
397
|
+
}
|
|
398
|
+
|
|
360
399
|
/* Default: label on the left */
|
|
361
400
|
.label.align-left {
|
|
362
401
|
left: 0;
|
|
@@ -368,10 +407,10 @@
|
|
|
368
407
|
left: auto;
|
|
369
408
|
right: 0;
|
|
370
409
|
}
|
|
371
|
-
`,va([hA({type:Number})],Ha.prototype,"top",2),va([hA({type:Number})],Ha.prototype,"left",2),va([hA({type:Number})],Ha.prototype,"width",2),va([hA({type:Number})],Ha.prototype,"height",2),va([hA({type:String})],Ha.prototype,"label",2),va([hA({type:Boolean})],Ha.prototype,"visible",2),Ha=va([cA("zing-highlight")],Ha);var Ea=Object.defineProperty,xa=Object.getOwnPropertyDescriptor,Ia=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?xa(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ea(e,t,r),r};let Ka=class extends iA{constructor(){super(),this.annotations=[],this.positions=[],this.scrollHandler=this.updatePositions.bind(this),this.resizeHandler=this.updatePositions.bind(this)}connectedCallback(){super.connectedCallback(),window.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.resizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("resize",this.resizeHandler)}updated(A){A.has("annotations")&&this.updatePositions()}updatePositions(){const A={top:window.scrollY,left:window.scrollX,width:window.innerWidth,height:window.innerHeight,bottom:window.scrollY+window.innerHeight,right:window.scrollX+window.innerWidth};this.positions=this.annotations.map((e,t)=>{const n=ca(e.selector);if(!n)return{id:e.id,number:t+1,top:0,left:0,visible:!1,status:e.status||"pending"};const s=Ca(n),r=function(A,e){let t=A.top-12,n=A.left-12;return e&&(n<4?n=4:n+24>e.width-4&&(n=e.width-24-4),t<4?t=4:t+24>e.height-4&&(t=e.height-24-4)),{top:t,left:n}}(s,{width:A.width,height:A.height}),o=s.bottom>0&&s.top<A.height&&s.right>0&&s.left<A.width;return{id:e.id,number:t+1,top:r.top,left:r.left,visible:o,status:e.status||"pending"}})}render(){return N`
|
|
410
|
+
`,va([hA({type:Number})],Ha.prototype,"top",2),va([hA({type:Number})],Ha.prototype,"left",2),va([hA({type:Number})],Ha.prototype,"width",2),va([hA({type:Number})],Ha.prototype,"height",2),va([hA({type:String})],Ha.prototype,"label",2),va([hA({type:Boolean})],Ha.prototype,"visible",2),Ha=va([cA("zing-highlight")],Ha);var Ea=Object.defineProperty,xa=Object.getOwnPropertyDescriptor,Ia=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?xa(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ea(e,t,r),r};let Ka=class extends iA{constructor(){super(),this.annotations=[],this.positions=[],this.highlighting=!1,this.scrollHandler=this.updatePositions.bind(this),this.resizeHandler=this.updatePositions.bind(this)}connectedCallback(){super.connectedCallback(),window.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.resizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("resize",this.resizeHandler)}updated(A){A.has("annotations")&&this.updatePositions()}updatePositions(){const A={top:window.scrollY,left:window.scrollX,width:window.innerWidth,height:window.innerHeight,bottom:window.scrollY+window.innerHeight,right:window.scrollX+window.innerWidth};this.positions=this.annotations.map((e,t)=>{const n=ca(e.selector);if(!n)return{id:e.id,number:t+1,top:0,left:0,visible:!1,status:e.status||"pending"};const s=Ca(n),r=function(A,e){let t=A.top-12,n=A.left-12;return e&&(n<4?n=4:n+24>e.width-4&&(n=e.width-24-4),t<4?t=4:t+24>e.height-4&&(t=e.height-24-4)),{top:t,left:n}}(s,{width:A.width,height:A.height}),o=s.bottom>0&&s.top<A.height&&s.right>0&&s.left<A.width;return{id:e.id,number:t+1,top:r.top,left:r.left,visible:o,status:e.status||"pending"}})}render(){return N`
|
|
372
411
|
${this.positions.filter(A=>A.visible).map(A=>N`
|
|
373
412
|
<div
|
|
374
|
-
class="marker ${A.status}"
|
|
413
|
+
class="marker ${A.status} ${this.highlighting?"highlight":""}"
|
|
375
414
|
style="top: ${A.top}px; left: ${A.left}px;"
|
|
376
415
|
@click=${()=>this.handleMarkerClick(A.id)}
|
|
377
416
|
>
|
|
@@ -383,7 +422,7 @@
|
|
|
383
422
|
>×</button>
|
|
384
423
|
</div>
|
|
385
424
|
`)}
|
|
386
|
-
`}handleMarkerClick(A){this.dispatchEvent(new CustomEvent("marker-click",{detail:{id:A},bubbles:!0,composed:!0}))}handleDelete(A,e){A.stopPropagation(),this.dispatchEvent(new CustomEvent("marker-delete",{detail:{id:e},bubbles:!0,composed:!0}))}};Ka.styles=o`
|
|
425
|
+
`}handleMarkerClick(A){this.dispatchEvent(new CustomEvent("marker-click",{detail:{id:A},bubbles:!0,composed:!0}))}handleDelete(A,e){A.stopPropagation(),this.dispatchEvent(new CustomEvent("marker-delete",{detail:{id:e},bubbles:!0,composed:!0}))}highlightMarkers(){this.highlightTimeout&&window.clearTimeout(this.highlightTimeout),this.highlighting=!0,this.highlightTimeout=window.setTimeout(()=>{this.highlighting=!1},2e3)}};Ka.styles=o`
|
|
387
426
|
:host {
|
|
388
427
|
display: block;
|
|
389
428
|
position: absolute;
|
|
@@ -442,6 +481,25 @@
|
|
|
442
481
|
}
|
|
443
482
|
}
|
|
444
483
|
|
|
484
|
+
.marker.highlight {
|
|
485
|
+
animation: highlight 2s ease-in-out;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
@keyframes highlight {
|
|
489
|
+
0%, 100% {
|
|
490
|
+
transform: scale(1);
|
|
491
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
492
|
+
}
|
|
493
|
+
25%, 75% {
|
|
494
|
+
transform: scale(1.3);
|
|
495
|
+
box-shadow: 0 0 16px #3b82f6, 0 0 8px #3b82f6;
|
|
496
|
+
}
|
|
497
|
+
50% {
|
|
498
|
+
transform: scale(1.15);
|
|
499
|
+
box-shadow: 0 0 12px #3b82f6;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
445
503
|
.marker.completed {
|
|
446
504
|
background: var(--completed-color, #22c55e);
|
|
447
505
|
}
|
|
@@ -473,7 +531,7 @@
|
|
|
473
531
|
.delete-btn:hover {
|
|
474
532
|
background: #dc2626;
|
|
475
533
|
}
|
|
476
|
-
`,Ia([hA({type:Array})],Ka.prototype,"annotations",2),Ia([gA()],Ka.prototype,"positions",2),Ka=Ia([cA("zing-markers")],Ka);var ka=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,La=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?Sa(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ka(e,t,r),r};let Da=class extends iA{constructor(){super(...arguments),this.open=!1,this.editMode=!1,this.annotationId="",this.selector="",this.identifier="",this.selectedText="",this.notes="",this.captureScreenshot=!1,this.screenshotPreview="",this.screenshotLoading=!1,this.showConfirmation=!1,this.localNotes="",this.isSelecting=!1,this.handleKeydown=A=>{"Escape"===A.key?this.handleCancel():(A.metaKey||A.ctrlKey)&&"Enter"===A.key&&this.handleSave()},this.handleGlobalMouseUp=()=>{setTimeout(()=>{this.isSelecting=!1},50)}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("mouseup",this.handleGlobalMouseUp)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("mouseup",this.handleGlobalMouseUp)}updated(A){A.has("open")&&this.open&&(this.showConfirmation=!1,this.localNotes=this.notes,requestAnimationFrame(()=>{this.textarea?.focus()}))}render(){return this.open?N`
|
|
534
|
+
`,Ia([hA({type:Array})],Ka.prototype,"annotations",2),Ia([gA()],Ka.prototype,"positions",2),Ia([gA()],Ka.prototype,"highlighting",2),Ka=Ia([cA("zing-markers")],Ka);var ka=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,La=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?Sa(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ka(e,t,r),r};let Da=class extends iA{constructor(){super(...arguments),this.open=!1,this.editMode=!1,this.annotationId="",this.selector="",this.identifier="",this.selectedText="",this.notes="",this.captureScreenshot=!1,this.screenshotPreview="",this.screenshotLoading=!1,this.showConfirmation=!1,this.localNotes="",this.isSelecting=!1,this.handleKeydown=A=>{"Escape"===A.key?this.handleCancel():(A.metaKey||A.ctrlKey)&&"Enter"===A.key&&this.handleSave()},this.handleGlobalMouseUp=()=>{setTimeout(()=>{this.isSelecting=!1},50)}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("mouseup",this.handleGlobalMouseUp)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("mouseup",this.handleGlobalMouseUp)}updated(A){A.has("open")&&this.open&&(this.showConfirmation=!1,this.localNotes=this.notes,requestAnimationFrame(()=>{this.textarea?.focus()}))}render(){return this.open?N`
|
|
477
535
|
<div class="overlay" @click=${this.handleOverlayClick}>
|
|
478
536
|
<div class="modal" @click=${A=>A.stopPropagation()}>
|
|
479
537
|
<div class="header">
|
|
@@ -2688,7 +2746,7 @@
|
|
|
2688
2746
|
font-family: inherit;
|
|
2689
2747
|
border: 1px solid #4b5563;
|
|
2690
2748
|
}
|
|
2691
|
-
`,ac([hA({type:Boolean})],cc.prototype,"visible",2),ac([hA({type:String})],cc.prototype,"message",2),ac([hA({type:Number})],cc.prototype,"filesModified",2),ac([hA({type:Number})],cc.prototype,"timeout",2),ac([gA()],cc.prototype,"remainingTime",2),cc=ac([cA("zing-undo-bar")],cc);var lc=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,hc=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?Bc(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&lc(e,t,r),r};let gc=class extends iA{constructor(){super(),this.annotations=[],this.settings=Qa(),this.wsConnected=!1,this.wsMaxAttemptsReached=!1,this.processing=!1,this.agentName="",this.agentModel="",this.serverProjectDir="",this.annotationActive=function(){try{const A=localStorage.getItem(ha);return null===A||JSON.parse(A)}catch{return!0}}(),this.availableAgents=[],this.agentPickerOpen=!1,this.agentPickerLoading=!1,this.agentPickerError="",this.highlightVisible=!1,this.highlightRect={top:0,left:0,width:0,height:0},this.highlightLabel="",this.modalOpen=!1,this.modalEditMode=!1,this.modalAnnotationId="",this.modalSelector="",this.modalIdentifier="",this.modalSelectedText="",this.modalNotes="",this.pendingElement=null,this.modalCaptureScreenshot=!1,this.modalScreenshotPreview="",this.modalScreenshotLoading=!1,this.settingsOpen=!1,this.helpOpen=!1,this.isHidden=!1,this.responseOpen=!1,this.responseContent="",this.responseToolStatus="",this.responseError="",this.responseScreenshotCount=0,this.isFollowUpMessage=!1,this.undoStack=[],this.historyOpen=!1,this.historyCheckpoints=[],this.historyLoading=!1,this.undoBarVisible=!1,this.undoBarFilesModified=0,this.pendingAnnotationRemovals=new Set,this.undoInProgress=!1,this.recentlyDeletedAnnotation=null,this.deleteUndoTimeout=null,this.processingTimeout=null,this.PROCESSING_TIMEOUT_MS=6e4,this.toolbarPosition=function(){try{const A=localStorage.getItem(ga);return A?JSON.parse(A):null}catch{return null}}(),this.isDragging=!1,this.dragOffset={x:0,y:0},this.ws=null,this.clickHandler=this.handleDocumentClick.bind(this),this.mouseMoveHandler=this.handleDocumentMouseMove.bind(this),this.keydownHandler=this.handleDocumentKeydown.bind(this),this.dragMoveHandler=this.handleDragMove.bind(this),this.dragEndHandler=this.handleDragEnd.bind(this)}connectedCallback(){super.connectedCallback(),this.annotations=function(){try{const A=localStorage.getItem(la);if(!A)return[];const e=JSON.parse(A);return e.url!==window.location.href?[]:Array.isArray(e.annotations)?e.annotations:[]}catch{return[]}}();try{const A=this.annotations.filter(A=>{try{return null!==ca(A.selector)}catch(e){return console.warn(`[ZingIt] Invalid selector "${A.selector}":`,e),!1}});if(A.length<this.annotations.length){const e=this.annotations.length-A.length;console.log(`[ZingIt] Removed ${e} orphaned annotation(s) - elements no longer exist`),this.annotations=A,ua(this.annotations),this.updateComplete.then(()=>{this.toast?.info(`Removed ${e} stale annotation${e>1?"s":""}`)})}}catch(e){console.warn("[ZingIt] Error cleaning up orphaned annotations:",e)}const A=function(){try{const A=sessionStorage.getItem(da);return A?JSON.parse(A):null}catch{return null}}();A&&A.content&&(this.responseOpen=!0,this.responseContent=A.content,this.responseError=A.error,this.responseScreenshotCount=A.screenshotCount,function(){try{sessionStorage.removeItem(da)}catch(e){console.warn("ZingIt: Failed to clear response state",e)}}(),this.requestUpdate()),this.initWebSocket(),document.addEventListener("click",this.clickHandler,!0),document.addEventListener("mousemove",this.mouseMoveHandler,!0),document.addEventListener("keydown",this.keydownHandler)}disconnectedCallback(){super.disconnectedCallback(),this.ws&&(this.ws.disconnect(),this.ws=null),this.deleteUndoTimeout&&(clearTimeout(this.deleteUndoTimeout),this.deleteUndoTimeout=null),this.processingTimeout&&(clearTimeout(this.processingTimeout),this.processingTimeout=null),document.removeEventListener("click",this.clickHandler,!0),document.removeEventListener("mousemove",this.mouseMoveHandler,!0),document.removeEventListener("keydown",this.keydownHandler)}initWebSocket(){this.ws=new ji(this.settings.wsUrl),this.ws.on("open",()=>{this.wsConnected=!0,this.wsMaxAttemptsReached=!1;this.annotations.some(A=>"processing"===A.status)?(console.log("[ZingIt] Reconnected with processing annotations - marking as completed"),this.annotations=this.annotations.map(A=>"processing"===A.status?{...A,status:"completed"}:A),ua(this.annotations),this.toast.success("Connected - changes completed")):this.toast.success("Connected to server"),this.ws?.requestAgents()}),this.ws.on("close",()=>{this.wsConnected=!1}),this.ws.on("max_attempts",()=>{this.wsMaxAttemptsReached=!0,this.toast.error("Connection failed - click Reconnect to retry")}),this.ws.on("message",A=>{this.handleWSMessage(A)}),this.ws.connect()}handleWSMessage(A){switch(A.type){case"connected":this.agentName=A.agent||"",this.agentModel=A.model||"",this.serverProjectDir=A.projectDir||"";break;case"processing":this.processing=!0,this.responseOpen=!0,this.isFollowUpMessage||(this.responseContent=""),this.responseError="",this.startProcessingTimeout();break;case"delta":this.responseContent+=A.content||"",this.settings.autoRefresh&&this.responseContent&&this.saveCurrentResponseState();break;case"tool_start":this.responseToolStatus=A.tool||"";break;case"tool_end":this.responseToolStatus="";break;case"idle":this.clearProcessingTimeout(),this.processing=!1,this.responseToolStatus="",this.isFollowUpMessage=!1,this.updateAnnotationStatuses("processing","completed"),this.settings.playSoundOnComplete&&this.playCompletionSound(),setTimeout(()=>{this.ws&&this.wsConnected&&this.ws.send({type:"get_history"})},500),this.settings.autoRefresh&&(this.saveCurrentResponseState(),this.toast.info("Refreshing page..."),setTimeout(()=>window.location.reload(),1e3));break;case"error":this.clearProcessingTimeout(),this.responseError=A.message||"Unknown error",this.processing=!1,this.responseToolStatus="",this.isFollowUpMessage=!1,this.undoInProgress=!1,this.pendingAnnotationRemovals.clear(),this.updateAnnotationStatuses("processing","pending"),this.toast.error(A.message||"An error occurred");break;case"reset_complete":this.responseContent="",this.responseError="";break;case"agents":if(this.availableAgents=A.agents||[],this.agentPickerLoading=!1,this.agentPickerError="",!this.agentName&&this.availableAgents.length>0)if(this.settings.selectedAgent){const A=this.availableAgents.find(A=>A.name===this.settings.selectedAgent);A?.available?this.ws?.selectAgent(this.settings.selectedAgent):this.agentPickerOpen=!0}else this.agentPickerOpen=!0;break;case"agent_selected":this.agentName=A.agent||"",this.agentModel=A.model||"",this.agentPickerOpen=!1,this.settings={...this.settings,selectedAgent:this.agentName},wa(this.settings),this.toast.success(`Using ${A.agent||"agent"}`);break;case"agent_error":this.agentPickerError=A.message||"Failed to select agent",this.toast.error(A.message||"Failed to select agent");break;case"checkpoint_created":if(A.checkpoint){const e=this.historyCheckpoints.findIndex(e=>e.id===A.checkpoint.id);this.historyCheckpoints=e>=0?[...this.historyCheckpoints.slice(0,e),A.checkpoint,...this.historyCheckpoints.slice(e+1)]:[...this.historyCheckpoints,A.checkpoint],"applied"===A.checkpoint.status&&A.checkpoint.filesModified>0&&this.settings.showUndoBar&&(this.undoBarFilesModified=A.checkpoint.filesModified,this.undoBarVisible=!0)}break;case"history":this.historyCheckpoints=A.checkpoints||[],this.historyLoading=!1;break;case"undo_complete":this.handleCheckpointRestored("Change undone");break;case"revert_complete":this.handleCheckpointRestored("Reverted to checkpoint");break;case"history_cleared":this.historyCheckpoints=[],this.toast.info("History cleared")}}handleDocumentClick(A){if(!this.annotationActive)return;if(!this.agentName)return;if(this.modalOpen||this.settingsOpen||this.agentPickerOpen||this.historyOpen)return;const e=this.getTargetElement(A);if(!e)return;A.preventDefault(),A.stopPropagation(),this.pendingElement=e,this.modalEditMode=!1,this.modalAnnotationId="",this.modalSelector=ea(e),this.modalIdentifier=na(e),this.modalNotes="",this.modalCaptureScreenshot=!1,this.modalScreenshotPreview="";const t=window.getSelection();this.modalSelectedText=t?.toString().trim()||"",this.modalOpen=!0}handleDocumentMouseMove(A){if(!this.annotationActive)return void(this.highlightVisible=!1);if(!this.agentName)return void(this.highlightVisible=!1);if(this.modalOpen||this.settingsOpen||this.agentPickerOpen)return void(this.highlightVisible=!1);const e=this.getTargetElement(A);if(!e)return void(this.highlightVisible=!1);const t=Ca(e);this.highlightRect=t,this.highlightLabel=na(e),this.highlightVisible=!0}isEditableTarget(A){const e=A.composedPath();for(const t of e)if(t instanceof HTMLElement){const A=t.tagName?.toLowerCase();if("input"===A||"textarea"===A||t.isContentEditable)return!0}return!1}handleDocumentKeydown(A){if("Escape"===A.key&&(this.helpOpen?this.helpOpen=!1:this.modalOpen?this.modalOpen=!1:this.settingsOpen?this.settingsOpen=!1:this.historyOpen?this.historyOpen=!1:this.responseOpen?this.responseOpen=!1:this.undoBarVisible&&(this.undoBarVisible=!1)),this.isEditableTarget(A))return;const e=this.historyCheckpoints.some(A=>A.canUndo);(A.metaKey||A.ctrlKey)&&"z"===A.key&&!A.shiftKey&&(this.undoStack.length>0||e)&&(A.preventDefault(),this.handleUndo()),"z"!==A.key&&"Z"!==A.key||this.handleToggle(),"?"===A.key&&(this.helpOpen=!this.helpOpen),"`"===A.key&&(this.isHidden=!this.isHidden,this.isHidden||this.toast.info("ZingIt visible"))}isOwnElement(A){let e=A;for(;e;){if(e instanceof Element&&e.tagName?.toLowerCase().startsWith("zing-"))return!0;if(e instanceof Element&&e.parentElement)e=e.parentElement;else{const A=e.getRootNode();e=A instanceof ShadowRoot?A.host:null}}return!1}isEventFromOwnElement(A){const e=A.composedPath();for(const t of e)if(t instanceof Element&&t.tagName?.toLowerCase().startsWith("zing-"))return!0;return!1}getTargetElement(A){if(this.isEventFromOwnElement(A))return null;const e=A.composedPath();for(const n of e){if(!(n instanceof Element))continue;const A=n.tagName.toLowerCase();if("body"===A||"html"===A)break;if(!this.isOwnElement(n))return n}const t=document.elementsFromPoint(A.clientX,A.clientY);for(const n of t){const A=n.tagName.toLowerCase();if("body"!==A&&"html"!==A&&!this.isOwnElement(n))return n}return null}render(){return this.isHidden?N`<zing-toast></zing-toast>`:N`
|
|
2749
|
+
`,ac([hA({type:Boolean})],cc.prototype,"visible",2),ac([hA({type:String})],cc.prototype,"message",2),ac([hA({type:Number})],cc.prototype,"filesModified",2),ac([hA({type:Number})],cc.prototype,"timeout",2),ac([gA()],cc.prototype,"remainingTime",2),cc=ac([cA("zing-undo-bar")],cc);var lc=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,hc=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?Bc(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&lc(e,t,r),r};let gc=class extends iA{constructor(){super(),this.annotations=[],this.settings=Qa(),this.wsConnected=!1,this.wsMaxAttemptsReached=!1,this.processing=!1,this.agentName="",this.agentModel="",this.serverProjectDir="",this.annotationActive=function(){try{const A=localStorage.getItem(ha);return null===A||JSON.parse(A)}catch{return!0}}(),this.availableAgents=[],this.agentPickerOpen=!1,this.agentPickerLoading=!1,this.agentPickerError="",this.highlightVisible=!1,this.highlightRect={top:0,left:0,width:0,height:0},this.highlightLabel="",this.modalOpen=!1,this.modalEditMode=!1,this.modalAnnotationId="",this.modalSelector="",this.modalIdentifier="",this.modalSelectedText="",this.modalNotes="",this.pendingElement=null,this.modalCaptureScreenshot=!1,this.modalScreenshotPreview="",this.modalScreenshotLoading=!1,this.settingsOpen=!1,this.helpOpen=!1,this.isHidden=!1,this.responseOpen=!1,this.responseContent="",this.responseToolStatus="",this.responseError="",this.responseScreenshotCount=0,this.isFollowUpMessage=!1,this.undoStack=[],this.historyOpen=!1,this.historyCheckpoints=[],this.historyLoading=!1,this.undoBarVisible=!1,this.undoBarFilesModified=0,this.pendingAnnotationRemovals=new Set,this.undoInProgress=!1,this.recentlyDeletedAnnotation=null,this.deleteUndoTimeout=null,this.processingTimeout=null,this.PROCESSING_TIMEOUT_MS=6e4,this.toolbarPosition=function(){try{const A=localStorage.getItem(ga);return A?JSON.parse(A):null}catch{return null}}(),this.isDragging=!1,this.dragOffset={x:0,y:0},this.ws=null,this.clickHandler=this.handleDocumentClick.bind(this),this.mouseMoveHandler=this.handleDocumentMouseMove.bind(this),this.keydownHandler=this.handleDocumentKeydown.bind(this),this.dragMoveHandler=this.handleDragMove.bind(this),this.dragEndHandler=this.handleDragEnd.bind(this)}connectedCallback(){super.connectedCallback(),this.annotations=function(){try{const A=localStorage.getItem(la);if(!A)return[];const e=JSON.parse(A);return e.url!==window.location.href?[]:Array.isArray(e.annotations)?e.annotations:[]}catch{return[]}}();try{const A=this.annotations.filter(A=>{try{return null!==ca(A.selector)}catch(e){return console.warn(`[ZingIt] Invalid selector "${A.selector}":`,e),!1}});if(A.length<this.annotations.length){const e=this.annotations.length-A.length;console.log(`[ZingIt] Removed ${e} orphaned annotation(s) - elements no longer exist`),this.annotations=A,ua(this.annotations),this.updateComplete.then(()=>{this.toast?.info(`Removed ${e} stale annotation${e>1?"s":""}`)})}}catch(e){console.warn("[ZingIt] Error cleaning up orphaned annotations:",e)}const A=function(){try{const A=sessionStorage.getItem(da);return A?JSON.parse(A):null}catch{return null}}();A&&A.content&&(this.responseOpen=!0,this.responseContent=A.content,this.responseError=A.error,this.responseScreenshotCount=A.screenshotCount,function(){try{sessionStorage.removeItem(da)}catch(e){console.warn("ZingIt: Failed to clear response state",e)}}(),this.requestUpdate()),this.initWebSocket(),document.addEventListener("click",this.clickHandler,!0),document.addEventListener("mousemove",this.mouseMoveHandler,!0),document.addEventListener("keydown",this.keydownHandler)}disconnectedCallback(){super.disconnectedCallback(),this.ws&&(this.ws.disconnect(),this.ws=null),this.deleteUndoTimeout&&(clearTimeout(this.deleteUndoTimeout),this.deleteUndoTimeout=null),this.processingTimeout&&(clearTimeout(this.processingTimeout),this.processingTimeout=null),document.removeEventListener("click",this.clickHandler,!0),document.removeEventListener("mousemove",this.mouseMoveHandler,!0),document.removeEventListener("keydown",this.keydownHandler)}initWebSocket(){this.ws=new ji(this.settings.wsUrl),this.ws.on("open",()=>{this.wsConnected=!0,this.wsMaxAttemptsReached=!1;this.annotations.some(A=>"processing"===A.status)?(console.log("[ZingIt] Reconnected with processing annotations - marking as completed"),this.annotations=this.annotations.map(A=>"processing"===A.status?{...A,status:"completed"}:A),ua(this.annotations),this.toast.success("Connected - changes completed")):this.toast.success("Connected to server"),this.ws?.requestAgents()}),this.ws.on("close",()=>{this.wsConnected=!1}),this.ws.on("max_attempts",()=>{this.wsMaxAttemptsReached=!0,this.toast.error("Connection failed - click Reconnect to retry")}),this.ws.on("message",A=>{this.handleWSMessage(A)}),this.ws.connect()}handleWSMessage(A){switch(A.type){case"connected":this.agentName=A.agent||"",this.agentModel=A.model||"",this.serverProjectDir=A.projectDir||"";break;case"processing":this.processing=!0,this.responseOpen=!0,this.isFollowUpMessage||(this.responseContent=""),this.responseError="",this.startProcessingTimeout();break;case"delta":this.responseContent+=A.content||"",this.settings.autoRefresh&&this.responseContent&&this.saveCurrentResponseState();break;case"tool_start":this.responseToolStatus=A.tool||"";break;case"tool_end":this.responseToolStatus="";break;case"idle":this.clearProcessingTimeout(),this.processing=!1,this.responseToolStatus="",this.isFollowUpMessage=!1,this.updateAnnotationStatuses("processing","completed"),this.settings.playSoundOnComplete&&this.playCompletionSound(),setTimeout(()=>{this.ws&&this.wsConnected&&this.ws.send({type:"get_history"})},500),this.settings.autoRefresh&&(this.saveCurrentResponseState(),this.toast.info("Refreshing page..."),setTimeout(()=>window.location.reload(),1e3));break;case"error":this.clearProcessingTimeout(),this.responseError=A.message||"Unknown error",this.processing=!1,this.responseToolStatus="",this.isFollowUpMessage=!1,this.undoInProgress=!1,this.pendingAnnotationRemovals.clear(),this.updateAnnotationStatuses("processing","pending"),this.toast.error(A.message||"An error occurred");break;case"reset_complete":this.responseContent="",this.responseError="";break;case"agents":if(this.availableAgents=A.agents||[],this.agentPickerLoading=!1,this.agentPickerError="",!this.agentName&&this.availableAgents.length>0)if(this.settings.selectedAgent){const A=this.availableAgents.find(A=>A.name===this.settings.selectedAgent);A?.available?this.ws?.selectAgent(this.settings.selectedAgent):this.agentPickerOpen=!0}else this.agentPickerOpen=!0;break;case"agent_selected":this.agentName=A.agent||"",this.agentModel=A.model||"",this.agentPickerOpen=!1,this.settings={...this.settings,selectedAgent:this.agentName},wa(this.settings),this.toast.success(`Using ${A.agent||"agent"}`);break;case"agent_error":this.agentPickerError=A.message||"Failed to select agent",this.toast.error(A.message||"Failed to select agent");break;case"checkpoint_created":if(A.checkpoint){const e=this.historyCheckpoints.findIndex(e=>e.id===A.checkpoint.id);this.historyCheckpoints=e>=0?[...this.historyCheckpoints.slice(0,e),A.checkpoint,...this.historyCheckpoints.slice(e+1)]:[...this.historyCheckpoints,A.checkpoint],"applied"===A.checkpoint.status&&A.checkpoint.filesModified>0&&this.settings.showUndoBar&&(this.undoBarFilesModified=A.checkpoint.filesModified,this.undoBarVisible=!0)}break;case"history":this.historyCheckpoints=A.checkpoints||[],this.historyLoading=!1;break;case"undo_complete":this.handleCheckpointRestored("Change undone");break;case"revert_complete":this.handleCheckpointRestored("Reverted to checkpoint");break;case"history_cleared":this.historyCheckpoints=[],this.toast.info("History cleared")}}handleDocumentClick(A){if(!this.annotationActive)return;if(!this.agentName)return;if(this.modalOpen||this.settingsOpen||this.agentPickerOpen||this.historyOpen)return;const e=this.getTargetElement(A);if(!e)return;A.preventDefault(),A.stopPropagation(),this.pendingElement=e,this.modalEditMode=!1,this.modalAnnotationId="",this.modalSelector=ea(e),this.modalIdentifier=na(e),this.modalNotes="",this.modalCaptureScreenshot=!1,this.modalScreenshotPreview="";const t=window.getSelection();this.modalSelectedText=t?.toString().trim()||"",this.modalOpen=!0}handleDocumentMouseMove(A){if(!this.annotationActive)return void(this.highlightVisible=!1);if(!this.agentName)return void(this.highlightVisible=!1);if(this.modalOpen||this.settingsOpen||this.agentPickerOpen)return void(this.highlightVisible=!1);const e=this.getTargetElement(A);if(!e)return void(this.highlightVisible=!1);const t=Ca(e);this.highlightRect=function(A){const e={top:4,left:4,bottom:window.innerHeight-8,right:window.innerWidth-20},t=A.top<e.top?e.top:A.top,n=A.left<e.left?e.left:A.left,s=A.bottom>e.bottom-30?e.bottom:A.bottom,r=A.right>e.right-30?e.right:A.right;return{top:t,left:n,width:Math.max(0,r-n),height:Math.max(0,s-t),bottom:s,right:r}}(t),this.highlightLabel=na(e),this.highlightVisible=!0}isEditableTarget(A){const e=A.composedPath();for(const t of e)if(t instanceof HTMLElement){const A=t.tagName?.toLowerCase();if("input"===A||"textarea"===A||t.isContentEditable)return!0}return!1}handleDocumentKeydown(A){if("Escape"===A.key&&(this.helpOpen?this.helpOpen=!1:this.modalOpen?this.modalOpen=!1:this.settingsOpen?this.settingsOpen=!1:this.historyOpen?this.historyOpen=!1:this.responseOpen?this.responseOpen=!1:this.undoBarVisible&&(this.undoBarVisible=!1)),this.isEditableTarget(A))return;const e=this.historyCheckpoints.some(A=>A.canUndo);(A.metaKey||A.ctrlKey)&&"z"===A.key&&!A.shiftKey&&(this.undoStack.length>0||e)&&(A.preventDefault(),this.handleUndo()),"z"!==A.key&&"Z"!==A.key||this.handleToggle(),"?"===A.key&&(this.helpOpen=!this.helpOpen),"`"===A.key&&(this.isHidden=!this.isHidden,this.isHidden||this.toast.info("ZingIt visible"))}isOwnElement(A){let e=A;for(;e;){if(e instanceof Element&&e.tagName?.toLowerCase().startsWith("zing-"))return!0;if(e instanceof Element&&e.parentElement)e=e.parentElement;else{const A=e.getRootNode();e=A instanceof ShadowRoot?A.host:null}}return!1}isEventFromOwnElement(A){const e=A.composedPath();for(const t of e)if(t instanceof Element&&t.tagName?.toLowerCase().startsWith("zing-"))return!0;return!1}getTargetElement(A){if(this.isEventFromOwnElement(A))return null;const e=A.composedPath();for(const n of e){if(!(n instanceof Element))continue;if("html"===n.tagName.toLowerCase())break;if(!this.isOwnElement(n))return n}const t=document.elementsFromPoint(A.clientX,A.clientY);for(const n of t){if("html"!==n.tagName.toLowerCase()&&!this.isOwnElement(n))return n}return null}render(){return this.isHidden?N`<zing-toast></zing-toast>`:N`
|
|
2692
2750
|
<zing-highlight
|
|
2693
2751
|
.top=${this.highlightRect.top}
|
|
2694
2752
|
.left=${this.highlightRect.left}
|
|
@@ -2731,6 +2789,7 @@
|
|
|
2731
2789
|
@toggle-response=${()=>this.responseOpen=!this.responseOpen}
|
|
2732
2790
|
@toggle-history=${this.handleToggleHistory}
|
|
2733
2791
|
@change-agent=${()=>this.agentPickerOpen=!0}
|
|
2792
|
+
@highlight-annotations=${this.handleHighlightAnnotations}
|
|
2734
2793
|
@drag-start=${this.handleToolbarDragStart}
|
|
2735
2794
|
@drag-reset=${this.handleToolbarDragReset}
|
|
2736
2795
|
></zing-toolbar>
|
|
@@ -2811,7 +2870,7 @@
|
|
|
2811
2870
|
></zing-undo-bar>
|
|
2812
2871
|
|
|
2813
2872
|
<zing-toast></zing-toast>
|
|
2814
|
-
`}handleModalCancel(){this.modalOpen=!1,this.pendingElement=null,this.modalCaptureScreenshot=!1,this.modalScreenshotPreview="",this.modalScreenshotLoading=!1}compressScreenshot(A){const e=[1,.9,.8,.6,.4];for(const s of e){const e=A.toDataURL("image/jpeg",s),t=e.split(",")[1]?.length||0;if(t<=48e5)return console.log(`ZingIt: Screenshot compressed to ${Math.round(t/1e3)}KB (quality: ${s})`),e}console.warn("ZingIt: Screenshot still too large, resizing...");const t=document.createElement("canvas");t.width=.7*A.width,t.height=.7*A.height;const n=t.getContext("2d");if(n){n.drawImage(A,0,0,t.width,t.height);const e=t.toDataURL("image/jpeg",.6),s=e.split(",")[1]?.length||0;return console.log(`ZingIt: Screenshot resized and compressed to ${Math.round(s/1e3)}KB`),e}return A.toDataURL("image/jpeg",.3)}async handleScreenshotToggle(A){if(this.modalCaptureScreenshot=A.detail.enabled,A.detail.enabled&&this.pendingElement){this.modalScreenshotLoading=!0;try{const A=await(e=this.pendingElement,t={logging:!1,useCORS:!0,allowTaint:!0,backgroundColor:null,scale:1},void 0===t&&(t={}),Zi(e,t));this.modalScreenshotPreview=this.compressScreenshot(A)}catch(n){console.warn("ZingIt: Failed to capture screenshot preview",n),this.modalScreenshotPreview=""}this.modalScreenshotLoading=!1}else A.detail.enabled||(this.modalScreenshotPreview="");var e,t}handleModalSave(A){try{const{notes:e,editMode:t,annotationId:n,captureScreenshot:s}=A.detail;if(t){const A=s&&this.modalScreenshotPreview?this.modalScreenshotPreview:void 0;this.annotations=this.annotations.map(t=>{if(t.id===n){const n={...t,notes:e,status:"pending"};return A?n.screenshot=A:delete n.screenshot,n}return t}),ua(this.annotations),this.undoStack=this.undoStack.map(t=>{if(t.id===n){const n={...t,notes:e,status:"pending"};return A?n.screenshot=A:delete n.screenshot,n}return t}),this.handleModalCancel(),this.toast.success("Annotation updated")}else{if(!this.pendingElement)return;const A=s&&this.modalScreenshotPreview?this.modalScreenshotPreview:void 0,t={id:crypto.randomUUID(),selector:this.modalSelector,identifier:this.modalIdentifier,html:aa(this.pendingElement),notes:e,parentContext:sa(this.pendingElement),textContent:ia(this.pendingElement),siblingContext:ra(this.pendingElement),parentHtml:oa(this.pendingElement),status:"pending",...this.modalSelectedText?{selectedText:this.modalSelectedText}:{},...A?{screenshot:A}:{}};this.annotations=[...this.annotations,t],ua(this.annotations),this.undoStack=[...this.undoStack,t],this.handleModalCancel(),this.toast.success(A?"Annotation saved with screenshot":"Annotation saved")}}catch(e){console.error("ZingIt: Error saving annotation",e),this.toast.error("Failed to save annotation")}}handleMarkerClick(A){try{const e=this.annotations.find(e=>e.id===A.detail.id);e&&(this.modalEditMode=!0,this.modalAnnotationId=e.id,this.modalSelector=e.selector,this.modalIdentifier=e.identifier,this.modalSelectedText=e.selectedText||"",this.modalNotes=e.notes,this.modalCaptureScreenshot=!!e.screenshot,this.modalScreenshotPreview=e.screenshot||"",this.pendingElement=ca(e.selector),this.pendingElement||this.toast.info("Element no longer exists on page"),this.modalOpen=!0)}catch(e){console.error("ZingIt: Error handling marker click",e),this.toast.error("Failed to open annotation")}}handleMarkerDelete(A){const e=A.detail.id,t=this.annotations.find(A=>A.id===e);t&&(this.deleteUndoTimeout&&(clearTimeout(this.deleteUndoTimeout),this.deleteUndoTimeout=null),this.recentlyDeletedAnnotation=t,this.annotations=this.annotations.filter(A=>A.id!==e),this.undoStack=this.undoStack.filter(A=>A.id!==e),ua(this.annotations),this.toast.info("Annotation deleted",5e3,{label:"Undo",callback:()=>this.undoDelete()}),this.deleteUndoTimeout=setTimeout(()=>{this.recentlyDeletedAnnotation=null,this.deleteUndoTimeout=null},5e3))}undoDelete(){this.recentlyDeletedAnnotation&&this.isConnected&&(this.annotations=[...this.annotations,this.recentlyDeletedAnnotation],this.undoStack=[...this.undoStack,this.recentlyDeletedAnnotation],ua(this.annotations),this.recentlyDeletedAnnotation=null,this.deleteUndoTimeout&&(clearTimeout(this.deleteUndoTimeout),this.deleteUndoTimeout=null),this.toast?.success("Annotation restored"))}handleSend(){if(this.responseOpen=!0,this.isFollowUpMessage=!1,!this.ws||!this.wsConnected||0===this.annotations.length)return;const A=this.settings.projectDir||void 0;if(0===this.annotations.filter(A=>"completed"!==A.status).length)return;this.updateAnnotationStatuses("pending","processing");const e=this.annotations.filter(A=>"processing"===A.status),t=e.filter(A=>A.screenshot).length;this.responseScreenshotCount=t;if(this.ws.sendBatch({pageUrl:window.location.href,pageTitle:document.title,annotations:e},A,void 0,()=>{this.updateAnnotationStatuses("processing","pending"),this.toast.error("Failed to send annotations - will retry on reconnection")})){let A=`Sent ${e.length} annotation${e.length>1?"s":""}`;t>0&&(A+=` (${t} with screenshot${t>1?"s":""})`),A+=" to agent",this.toast.info(A)}else this.toast.info("Connection lost - annotations queued for retry")}handleExport(){const A=function(A,e,t){let n="# UI Annotations\n\n";return n+=`**Page:** ${t}\n`,n+=`**URL:** ${e}\n`,n+=`**Date:** ${(new Date).toISOString()}\n\n`,n+="---\n\n",A.forEach((A,e)=>{n+=`## ${e+1}. ${A.identifier}\n\n`,n+=`**Selector:** \`${A.selector}\`\n\n`,n+=`**Notes:** ${A.notes}\n\n`,A.selectedText&&(n+=`**Selected Text:** "${A.selectedText}"\n\n`),n+=`**HTML:**\n\`\`\`html\n${A.html}\n\`\`\`\n\n`,n+="---\n\n"}),n}(this.annotations,window.location.href,document.title);var e;(e=A,navigator.clipboard?navigator.clipboard.writeText(e):new Promise((A,t)=>{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();try{document.execCommand("copy"),A()}catch(s){t(s)}finally{document.body.removeChild(n)}})).then(()=>{this.toast.success("Copied to clipboard")}).catch(()=>{this.toast.error("Failed to copy to clipboard")})}handleUndo(){if(this.historyCheckpoints.some(A=>A.canUndo))return void this.handleGitUndo();if(0===this.undoStack.length)return;const A=this.undoStack[this.undoStack.length-1];this.undoStack=this.undoStack.slice(0,-1),this.annotations=this.annotations.filter(e=>e.id!==A.id),ua(this.annotations),this.toast.info("Annotation removed")}handleGitUndo(){if(!this.ws||!this.wsConnected)return void this.toast.error("Not connected to server");if(this.undoInProgress)return void this.toast.info("Undo already in progress...");const A=this.historyCheckpoints.find(A=>A.canUndo);A&&(this.pendingAnnotationRemovals=new Set(A.annotations.map(A=>A.id))),this.undoInProgress=!0,this.ws.send({type:"undo"}),this.undoBarVisible=!1}handleRevertTo(A){if(!this.ws||!this.wsConnected)return void this.toast.error("Not connected to server");if(this.undoInProgress)return void this.toast.info("Revert already in progress...");const e=this.historyCheckpoints.findIndex(e=>e.id===A.detail.checkpointId);if(e>=0){const A=this.historyCheckpoints.slice(0,e);this.pendingAnnotationRemovals=new Set(A.flatMap(A=>A.annotations.map(A=>A.id)))}this.undoInProgress=!0,this.ws.send({type:"revert_to",checkpointId:A.detail.checkpointId})}handleClearHistory(){this.ws&&this.wsConnected?this.ws.send({type:"clear_history"}):this.toast.error("Not connected to server")}handleToggleHistory(){this.historyOpen=!this.historyOpen,this.historyOpen&&this.ws&&this.wsConnected&&(this.historyLoading=!0,this.ws.send({type:"get_history"}))}handleClear(){this.annotations=[],this.undoStack=[],function(){try{localStorage.removeItem(la)}catch(A){console.warn("ZingIt: Failed to clear annotations",A)}}(),this.ws?.sendReset(),this.responseContent="",this.responseError="",this.responseToolStatus="",this.responseScreenshotCount=0,this.processing=!1,this.toast.info("Annotations cleared")}handleClose(){this.isHidden=!0,this.toast.info("Press ` to show ZingIt")}handleReconnect(){this.ws?.forceReconnect()}handleToggle(){this.annotationActive=!this.annotationActive,function(A){try{localStorage.setItem(ha,JSON.stringify(A))}catch(e){console.warn("ZingIt: Failed to save active state",e)}}(this.annotationActive),this.annotationActive||(this.highlightVisible=!1)}handleSettingsSave(A){this.settings=A.detail.settings,wa(this.settings),this.settingsOpen=!1,this.ws&&(this.ws.setUrl(this.settings.wsUrl),this.ws.forceReconnect())}handleAgentPickerSelect(A){const e=A.detail.agent;this.ws&&this.wsConnected&&this.ws.selectAgent(e)}handleAgentChange(A){const e=A.detail.agent;this.ws&&this.wsConnected&&e!==this.agentName&&this.ws.selectAgent(e)}handleFollowUp(A){this.ws&&this.wsConnected&&(this.isFollowUpMessage=!0,this.processing=!0,this.responseContent+=`\n\n---\n**You:** ${A.detail.message}\n\n`,this.responseError="",this.responseToolStatus="",this.startProcessingTimeout(),this.ws.sendMessage(A.detail.message,window.location.href))}handleStop(){this.ws&&this.wsConnected&&(this.clearProcessingTimeout(),this.ws.sendStop(),this.processing=!1,this.responseToolStatus="",this.updateAnnotationStatuses("processing","pending"),this.toast.info("Agent stopped"))}playCompletionSound(){try{const A=new(window.AudioContext||window.webkitAudioContext),e=(e,t,n)=>{const s=A.createOscillator(),r=A.createGain();s.connect(r),r.connect(A.destination),s.frequency.value=e,s.type="sine",r.gain.setValueAtTime(0,t),r.gain.linearRampToValueAtTime(.3,t+.01),r.gain.exponentialRampToValueAtTime(.01,t+n),s.start(t),s.stop(t+n)},t=A.currentTime;e(1047,t,.15),e(1319,t+.1,.2),setTimeout(()=>A.close(),500)}catch(A){console.warn("ZingIt: Could not play completion sound",A)}}get agentDisplayName(){if(!this.agentName)return"";const A=this.availableAgents.find(A=>A.name===this.agentName);return A?.displayName||this.agentName}startProcessingTimeout(){this.clearProcessingTimeout(),this.processingTimeout=setTimeout(()=>{console.warn("[ZingIt] Processing timeout - agent may have hung"),this.processing=!1,this.responseToolStatus="",this.isFollowUpMessage=!1,this.responseError="The AI agent took too long to respond. This can happen occasionally. Please try submitting your annotations again.",this.updateAnnotationStatuses("processing","pending"),this.toast.error("Request timed out - please try again")},this.PROCESSING_TIMEOUT_MS)}clearProcessingTimeout(){this.processingTimeout&&(clearTimeout(this.processingTimeout),this.processingTimeout=null)}saveCurrentResponseState(){!function(A){try{sessionStorage.setItem(da,JSON.stringify(A))}catch(e){console.warn("ZingIt: Failed to save response state",e)}}({open:this.responseOpen,content:this.responseContent,error:this.responseError,screenshotCount:this.responseScreenshotCount})}updateAnnotationStatuses(A,e){this.annotations=this.annotations.map(t=>t.status===A?{...t,status:e}:t),ua(this.annotations)}handleCheckpointRestored(A){this.historyPanel?.undoComplete(),this.undoBarVisible=!1,this.undoInProgress=!1,this.pendingAnnotationRemovals.size>0&&(this.annotations=this.annotations.filter(A=>!this.pendingAnnotationRemovals.has(A.id)),this.undoStack=this.undoStack.filter(A=>!this.pendingAnnotationRemovals.has(A.id)),ua(this.annotations),this.pendingAnnotationRemovals.clear()),this.toast.success(A),this.ws?.send({type:"get_history"}),this.settings.autoRefresh&&setTimeout(()=>window.location.reload(),500)}handleToolbarDragStart(A){const{clientX:e,clientY:t}=A.detail,n=this.shadowRoot?.querySelector(".toolbar-container");if(!n)return;const s=n.getBoundingClientRect();this.dragOffset={x:e-s.left,y:t-s.top},this.isDragging=!0,document.addEventListener("mousemove",this.dragMoveHandler),document.addEventListener("mouseup",this.dragEndHandler)}handleDragMove(A){if(!this.isDragging)return;const e=A.clientX-this.dragOffset.x,t=A.clientY-this.dragOffset.y,n=this.shadowRoot?.querySelector(".toolbar-container");if(!n)return;const s=n.getBoundingClientRect(),r=window.innerWidth-s.width,o=window.innerHeight-s.height;this.toolbarPosition={x:Math.max(0,Math.min(e,r)),y:Math.max(0,Math.min(t,o))}}handleDragEnd(){this.isDragging&&(this.isDragging=!1,document.removeEventListener("mousemove",this.dragMoveHandler),document.removeEventListener("mouseup",this.dragEndHandler),this.toolbarPosition&&function(A){try{localStorage.setItem(ga,JSON.stringify(A))}catch(e){console.warn("ZingIt: Failed to save toolbar position",e)}}(this.toolbarPosition))}handleToolbarDragReset(){this.toolbarPosition=null,function(){try{localStorage.removeItem(ga)}catch(A){console.warn("ZingIt: Failed to clear toolbar position",A)}}(),this.toast.info("Toolbar position reset")}};gc.styles=o`
|
|
2873
|
+
`}handleModalCancel(){this.modalOpen=!1,this.pendingElement=null,this.modalCaptureScreenshot=!1,this.modalScreenshotPreview="",this.modalScreenshotLoading=!1}compressScreenshot(A){const e=[1,.9,.8,.6,.4];for(const s of e){const e=A.toDataURL("image/jpeg",s),t=e.split(",")[1]?.length||0;if(t<=48e5)return console.log(`ZingIt: Screenshot compressed to ${Math.round(t/1e3)}KB (quality: ${s})`),e}console.warn("ZingIt: Screenshot still too large, resizing...");const t=document.createElement("canvas");t.width=.7*A.width,t.height=.7*A.height;const n=t.getContext("2d");if(n){n.drawImage(A,0,0,t.width,t.height);const e=t.toDataURL("image/jpeg",.6),s=e.split(",")[1]?.length||0;return console.log(`ZingIt: Screenshot resized and compressed to ${Math.round(s/1e3)}KB`),e}return A.toDataURL("image/jpeg",.3)}async handleScreenshotToggle(A){if(this.modalCaptureScreenshot=A.detail.enabled,A.detail.enabled&&this.pendingElement){this.modalScreenshotLoading=!0;try{const A=await(e=this.pendingElement,t={logging:!1,useCORS:!0,allowTaint:!0,backgroundColor:null,scale:1},void 0===t&&(t={}),Zi(e,t));this.modalScreenshotPreview=this.compressScreenshot(A)}catch(n){console.warn("ZingIt: Failed to capture screenshot preview",n),this.modalScreenshotPreview=""}this.modalScreenshotLoading=!1}else A.detail.enabled||(this.modalScreenshotPreview="");var e,t}handleModalSave(A){try{const{notes:e,editMode:t,annotationId:n,captureScreenshot:s}=A.detail;if(t){const A=s&&this.modalScreenshotPreview?this.modalScreenshotPreview:void 0;this.annotations=this.annotations.map(t=>{if(t.id===n){const n={...t,notes:e,status:"pending"};return A?n.screenshot=A:delete n.screenshot,n}return t}),ua(this.annotations),this.undoStack=this.undoStack.map(t=>{if(t.id===n){const n={...t,notes:e,status:"pending"};return A?n.screenshot=A:delete n.screenshot,n}return t}),this.handleModalCancel(),this.toast.success("Annotation updated")}else{if(!this.pendingElement)return;const A=s&&this.modalScreenshotPreview?this.modalScreenshotPreview:void 0,t={id:crypto.randomUUID(),selector:this.modalSelector,identifier:this.modalIdentifier,html:aa(this.pendingElement),notes:e,parentContext:sa(this.pendingElement),textContent:ia(this.pendingElement),siblingContext:ra(this.pendingElement),parentHtml:oa(this.pendingElement),status:"pending",...this.modalSelectedText?{selectedText:this.modalSelectedText}:{},...A?{screenshot:A}:{}};this.annotations=[...this.annotations,t],ua(this.annotations),this.undoStack=[...this.undoStack,t],this.handleModalCancel(),this.toast.success(A?"Annotation saved with screenshot":"Annotation saved")}}catch(e){console.error("ZingIt: Error saving annotation",e),this.toast.error("Failed to save annotation")}}handleMarkerClick(A){try{const e=this.annotations.find(e=>e.id===A.detail.id);e&&(this.modalEditMode=!0,this.modalAnnotationId=e.id,this.modalSelector=e.selector,this.modalIdentifier=e.identifier,this.modalSelectedText=e.selectedText||"",this.modalNotes=e.notes,this.modalCaptureScreenshot=!!e.screenshot,this.modalScreenshotPreview=e.screenshot||"",this.pendingElement=ca(e.selector),this.pendingElement||this.toast.info("Element no longer exists on page"),this.modalOpen=!0)}catch(e){console.error("ZingIt: Error handling marker click",e),this.toast.error("Failed to open annotation")}}handleMarkerDelete(A){const e=A.detail.id,t=this.annotations.find(A=>A.id===e);t&&(this.deleteUndoTimeout&&(clearTimeout(this.deleteUndoTimeout),this.deleteUndoTimeout=null),this.recentlyDeletedAnnotation=t,this.annotations=this.annotations.filter(A=>A.id!==e),this.undoStack=this.undoStack.filter(A=>A.id!==e),ua(this.annotations),this.toast.info("Annotation deleted",5e3,{label:"Undo",callback:()=>this.undoDelete()}),this.deleteUndoTimeout=setTimeout(()=>{this.recentlyDeletedAnnotation=null,this.deleteUndoTimeout=null},5e3))}undoDelete(){this.recentlyDeletedAnnotation&&this.isConnected&&(this.annotations=[...this.annotations,this.recentlyDeletedAnnotation],this.undoStack=[...this.undoStack,this.recentlyDeletedAnnotation],ua(this.annotations),this.recentlyDeletedAnnotation=null,this.deleteUndoTimeout&&(clearTimeout(this.deleteUndoTimeout),this.deleteUndoTimeout=null),this.toast?.success("Annotation restored"))}handleSend(){if(this.responseOpen=!0,this.isFollowUpMessage=!1,!this.ws||!this.wsConnected||0===this.annotations.length)return;const A=this.settings.projectDir||void 0;if(0===this.annotations.filter(A=>"completed"!==A.status).length)return;this.updateAnnotationStatuses("pending","processing");const e=this.annotations.filter(A=>"processing"===A.status),t=e.filter(A=>A.screenshot).length;this.responseScreenshotCount=t;if(this.ws.sendBatch({pageUrl:window.location.href,pageTitle:document.title,annotations:e},A,void 0,()=>{this.updateAnnotationStatuses("processing","pending"),this.toast.error("Failed to send annotations - will retry on reconnection")})){let A=`Sent ${e.length} annotation${e.length>1?"s":""}`;t>0&&(A+=` (${t} with screenshot${t>1?"s":""})`),A+=" to agent",this.toast.info(A)}else this.toast.info("Connection lost - annotations queued for retry")}handleExport(){const A=function(A,e,t){let n="# UI Annotations\n\n";return n+=`**Page:** ${t}\n`,n+=`**URL:** ${e}\n`,n+=`**Date:** ${(new Date).toISOString()}\n\n`,n+="---\n\n",A.forEach((A,e)=>{n+=`## ${e+1}. ${A.identifier}\n\n`,n+=`**Selector:** \`${A.selector}\`\n\n`,n+=`**Notes:** ${A.notes}\n\n`,A.selectedText&&(n+=`**Selected Text:** "${A.selectedText}"\n\n`),n+=`**HTML:**\n\`\`\`html\n${A.html}\n\`\`\`\n\n`,n+="---\n\n"}),n}(this.annotations,window.location.href,document.title);var e;(e=A,navigator.clipboard?navigator.clipboard.writeText(e):new Promise((A,t)=>{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();try{document.execCommand("copy"),A()}catch(s){t(s)}finally{document.body.removeChild(n)}})).then(()=>{this.toast.success("Copied to clipboard")}).catch(()=>{this.toast.error("Failed to copy to clipboard")})}handleUndo(){if(this.historyCheckpoints.some(A=>A.canUndo))return void this.handleGitUndo();if(0===this.undoStack.length)return;const A=this.undoStack[this.undoStack.length-1];this.undoStack=this.undoStack.slice(0,-1),this.annotations=this.annotations.filter(e=>e.id!==A.id),ua(this.annotations),this.toast.info("Annotation removed")}handleGitUndo(){if(!this.ws||!this.wsConnected)return void this.toast.error("Not connected to server");if(this.undoInProgress)return void this.toast.info("Undo already in progress...");const A=this.historyCheckpoints.find(A=>A.canUndo);A&&(this.pendingAnnotationRemovals=new Set(A.annotations.map(A=>A.id))),this.undoInProgress=!0,this.ws.send({type:"undo"}),this.undoBarVisible=!1}handleRevertTo(A){if(!this.ws||!this.wsConnected)return void this.toast.error("Not connected to server");if(this.undoInProgress)return void this.toast.info("Revert already in progress...");const e=this.historyCheckpoints.findIndex(e=>e.id===A.detail.checkpointId);if(e>=0){const A=this.historyCheckpoints.slice(0,e);this.pendingAnnotationRemovals=new Set(A.flatMap(A=>A.annotations.map(A=>A.id)))}this.undoInProgress=!0,this.ws.send({type:"revert_to",checkpointId:A.detail.checkpointId})}handleClearHistory(){this.ws&&this.wsConnected?this.ws.send({type:"clear_history"}):this.toast.error("Not connected to server")}handleToggleHistory(){this.historyOpen=!this.historyOpen,this.historyOpen&&this.ws&&this.wsConnected&&(this.historyLoading=!0,this.ws.send({type:"get_history"}))}handleClear(){this.annotations=[],this.undoStack=[],function(){try{localStorage.removeItem(la)}catch(A){console.warn("ZingIt: Failed to clear annotations",A)}}(),this.ws?.sendReset(),this.responseContent="",this.responseError="",this.responseToolStatus="",this.responseScreenshotCount=0,this.processing=!1,this.toast.info("Annotations cleared")}handleHighlightAnnotations(){this.markers&&this.markers.highlightMarkers()}handleClose(){this.isHidden=!0,this.toast.info("Press ` to show ZingIt")}handleReconnect(){this.ws?.forceReconnect()}handleToggle(){this.annotationActive=!this.annotationActive,function(A){try{localStorage.setItem(ha,JSON.stringify(A))}catch(e){console.warn("ZingIt: Failed to save active state",e)}}(this.annotationActive),this.annotationActive||(this.highlightVisible=!1)}handleSettingsSave(A){this.settings=A.detail.settings,wa(this.settings),this.settingsOpen=!1,this.ws&&(this.ws.setUrl(this.settings.wsUrl),this.ws.forceReconnect())}handleAgentPickerSelect(A){const e=A.detail.agent;this.ws&&this.wsConnected&&this.ws.selectAgent(e)}handleAgentChange(A){const e=A.detail.agent;this.ws&&this.wsConnected&&e!==this.agentName&&this.ws.selectAgent(e)}handleFollowUp(A){this.ws&&this.wsConnected&&(this.isFollowUpMessage=!0,this.processing=!0,this.responseContent+=`\n\n---\n**You:** ${A.detail.message}\n\n`,this.responseError="",this.responseToolStatus="",this.startProcessingTimeout(),this.ws.sendMessage(A.detail.message,window.location.href))}handleStop(){this.ws&&this.wsConnected&&(this.clearProcessingTimeout(),this.ws.sendStop(),this.processing=!1,this.responseToolStatus="",this.updateAnnotationStatuses("processing","pending"),this.toast.info("Agent stopped"))}playCompletionSound(){try{const A=new(window.AudioContext||window.webkitAudioContext),e=(e,t,n)=>{const s=A.createOscillator(),r=A.createGain();s.connect(r),r.connect(A.destination),s.frequency.value=e,s.type="sine",r.gain.setValueAtTime(0,t),r.gain.linearRampToValueAtTime(.3,t+.01),r.gain.exponentialRampToValueAtTime(.01,t+n),s.start(t),s.stop(t+n)},t=A.currentTime;e(1047,t,.15),e(1319,t+.1,.2),setTimeout(()=>A.close(),500)}catch(A){console.warn("ZingIt: Could not play completion sound",A)}}get agentDisplayName(){if(!this.agentName)return"";const A=this.availableAgents.find(A=>A.name===this.agentName);return A?.displayName||this.agentName}startProcessingTimeout(){this.clearProcessingTimeout(),this.processingTimeout=setTimeout(()=>{console.warn("[ZingIt] Processing timeout - agent may have hung"),this.processing=!1,this.responseToolStatus="",this.isFollowUpMessage=!1,this.responseError="The AI agent took too long to respond. This can happen occasionally. Please try submitting your annotations again.",this.updateAnnotationStatuses("processing","pending"),this.toast.error("Request timed out - please try again")},this.PROCESSING_TIMEOUT_MS)}clearProcessingTimeout(){this.processingTimeout&&(clearTimeout(this.processingTimeout),this.processingTimeout=null)}saveCurrentResponseState(){!function(A){try{sessionStorage.setItem(da,JSON.stringify(A))}catch(e){console.warn("ZingIt: Failed to save response state",e)}}({open:this.responseOpen,content:this.responseContent,error:this.responseError,screenshotCount:this.responseScreenshotCount})}updateAnnotationStatuses(A,e){this.annotations=this.annotations.map(t=>t.status===A?{...t,status:e}:t),ua(this.annotations)}handleCheckpointRestored(A){this.historyPanel?.undoComplete(),this.undoBarVisible=!1,this.undoInProgress=!1,this.pendingAnnotationRemovals.size>0&&(this.annotations=this.annotations.filter(A=>!this.pendingAnnotationRemovals.has(A.id)),this.undoStack=this.undoStack.filter(A=>!this.pendingAnnotationRemovals.has(A.id)),ua(this.annotations),this.pendingAnnotationRemovals.clear()),this.toast.success(A),this.ws?.send({type:"get_history"}),this.settings.autoRefresh&&setTimeout(()=>window.location.reload(),500)}handleToolbarDragStart(A){const{clientX:e,clientY:t}=A.detail,n=this.shadowRoot?.querySelector(".toolbar-container");if(!n)return;const s=n.getBoundingClientRect();this.dragOffset={x:e-s.left,y:t-s.top},this.isDragging=!0,document.addEventListener("mousemove",this.dragMoveHandler),document.addEventListener("mouseup",this.dragEndHandler)}handleDragMove(A){if(!this.isDragging)return;const e=A.clientX-this.dragOffset.x,t=A.clientY-this.dragOffset.y,n=this.shadowRoot?.querySelector(".toolbar-container");if(!n)return;const s=n.getBoundingClientRect(),r=window.innerWidth-s.width,o=window.innerHeight-s.height;this.toolbarPosition={x:Math.max(0,Math.min(e,r)),y:Math.max(0,Math.min(t,o))}}handleDragEnd(){this.isDragging&&(this.isDragging=!1,document.removeEventListener("mousemove",this.dragMoveHandler),document.removeEventListener("mouseup",this.dragEndHandler),this.toolbarPosition&&function(A){try{localStorage.setItem(ga,JSON.stringify(A))}catch(e){console.warn("ZingIt: Failed to save toolbar position",e)}}(this.toolbarPosition))}handleToolbarDragReset(){this.toolbarPosition=null,function(){try{localStorage.removeItem(ga)}catch(A){console.warn("ZingIt: Failed to clear toolbar position",A)}}(),this.toast.info("Toolbar position reset")}};gc.styles=o`
|
|
2815
2874
|
:host {
|
|
2816
2875
|
display: block;
|
|
2817
2876
|
position: fixed;
|
|
@@ -2843,7 +2902,7 @@
|
|
|
2843
2902
|
.toolbar-container.dragging {
|
|
2844
2903
|
user-select: none;
|
|
2845
2904
|
}
|
|
2846
|
-
`,hc([gA()],gc.prototype,"annotations",2),hc([gA()],gc.prototype,"settings",2),hc([gA()],gc.prototype,"wsConnected",2),hc([gA()],gc.prototype,"wsMaxAttemptsReached",2),hc([gA()],gc.prototype,"processing",2),hc([gA()],gc.prototype,"agentName",2),hc([gA()],gc.prototype,"agentModel",2),hc([gA()],gc.prototype,"serverProjectDir",2),hc([gA()],gc.prototype,"annotationActive",2),hc([gA()],gc.prototype,"availableAgents",2),hc([gA()],gc.prototype,"agentPickerOpen",2),hc([gA()],gc.prototype,"agentPickerLoading",2),hc([gA()],gc.prototype,"agentPickerError",2),hc([dA("zing-toast")],gc.prototype,"toast",2),hc([dA("zing-history-panel")],gc.prototype,"historyPanel",2),hc([gA()],gc.prototype,"highlightVisible",2),hc([gA()],gc.prototype,"highlightRect",2),hc([gA()],gc.prototype,"highlightLabel",2),hc([gA()],gc.prototype,"modalOpen",2),hc([gA()],gc.prototype,"modalEditMode",2),hc([gA()],gc.prototype,"modalAnnotationId",2),hc([gA()],gc.prototype,"modalSelector",2),hc([gA()],gc.prototype,"modalIdentifier",2),hc([gA()],gc.prototype,"modalSelectedText",2),hc([gA()],gc.prototype,"modalNotes",2),hc([gA()],gc.prototype,"pendingElement",2),hc([gA()],gc.prototype,"modalCaptureScreenshot",2),hc([gA()],gc.prototype,"modalScreenshotPreview",2),hc([gA()],gc.prototype,"modalScreenshotLoading",2),hc([gA()],gc.prototype,"settingsOpen",2),hc([gA()],gc.prototype,"helpOpen",2),hc([gA()],gc.prototype,"isHidden",2),hc([gA()],gc.prototype,"responseOpen",2),hc([gA()],gc.prototype,"responseContent",2),hc([gA()],gc.prototype,"responseToolStatus",2),hc([gA()],gc.prototype,"responseError",2),hc([gA()],gc.prototype,"responseScreenshotCount",2),hc([gA()],gc.prototype,"historyOpen",2),hc([gA()],gc.prototype,"historyCheckpoints",2),hc([gA()],gc.prototype,"historyLoading",2),hc([gA()],gc.prototype,"undoBarVisible",2),hc([gA()],gc.prototype,"undoBarFilesModified",2),hc([gA()],gc.prototype,"toolbarPosition",2),hc([gA()],gc.prototype,"isDragging",2),gc=hc([cA("zing-ui")],gc);var dc=Object.defineProperty,uc=Object.getOwnPropertyDescriptor,pc=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?uc(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&dc(e,t,r),r};let wc=class extends iA{constructor(){super(...arguments),this.activePage=""}render(){return N`
|
|
2905
|
+
`,hc([gA()],gc.prototype,"annotations",2),hc([gA()],gc.prototype,"settings",2),hc([gA()],gc.prototype,"wsConnected",2),hc([gA()],gc.prototype,"wsMaxAttemptsReached",2),hc([gA()],gc.prototype,"processing",2),hc([gA()],gc.prototype,"agentName",2),hc([gA()],gc.prototype,"agentModel",2),hc([gA()],gc.prototype,"serverProjectDir",2),hc([gA()],gc.prototype,"annotationActive",2),hc([gA()],gc.prototype,"availableAgents",2),hc([gA()],gc.prototype,"agentPickerOpen",2),hc([gA()],gc.prototype,"agentPickerLoading",2),hc([gA()],gc.prototype,"agentPickerError",2),hc([dA("zing-toast")],gc.prototype,"toast",2),hc([dA("zing-history-panel")],gc.prototype,"historyPanel",2),hc([dA("zing-markers")],gc.prototype,"markers",2),hc([gA()],gc.prototype,"highlightVisible",2),hc([gA()],gc.prototype,"highlightRect",2),hc([gA()],gc.prototype,"highlightLabel",2),hc([gA()],gc.prototype,"modalOpen",2),hc([gA()],gc.prototype,"modalEditMode",2),hc([gA()],gc.prototype,"modalAnnotationId",2),hc([gA()],gc.prototype,"modalSelector",2),hc([gA()],gc.prototype,"modalIdentifier",2),hc([gA()],gc.prototype,"modalSelectedText",2),hc([gA()],gc.prototype,"modalNotes",2),hc([gA()],gc.prototype,"pendingElement",2),hc([gA()],gc.prototype,"modalCaptureScreenshot",2),hc([gA()],gc.prototype,"modalScreenshotPreview",2),hc([gA()],gc.prototype,"modalScreenshotLoading",2),hc([gA()],gc.prototype,"settingsOpen",2),hc([gA()],gc.prototype,"helpOpen",2),hc([gA()],gc.prototype,"isHidden",2),hc([gA()],gc.prototype,"responseOpen",2),hc([gA()],gc.prototype,"responseContent",2),hc([gA()],gc.prototype,"responseToolStatus",2),hc([gA()],gc.prototype,"responseError",2),hc([gA()],gc.prototype,"responseScreenshotCount",2),hc([gA()],gc.prototype,"historyOpen",2),hc([gA()],gc.prototype,"historyCheckpoints",2),hc([gA()],gc.prototype,"historyLoading",2),hc([gA()],gc.prototype,"undoBarVisible",2),hc([gA()],gc.prototype,"undoBarFilesModified",2),hc([gA()],gc.prototype,"toolbarPosition",2),hc([gA()],gc.prototype,"isDragging",2),gc=hc([cA("zing-ui")],gc);var dc=Object.defineProperty,uc=Object.getOwnPropertyDescriptor,pc=(A,e,t,n)=>{for(var s,r=n>1?void 0:n?uc(e,t):e,o=A.length-1;o>=0;o--)(s=A[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&dc(e,t,r),r};let wc=class extends iA{constructor(){super(...arguments),this.activePage=""}render(){return N`
|
|
2847
2906
|
<nav class="site-nav">
|
|
2848
2907
|
<a href="/" class="brand">
|
|
2849
2908
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|