@puth/gui 0.2.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.
@@ -85,7 +85,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
85
85
  `],a,u=0;u<this.diffs.length;u++){switch(this.diffs[u][0]){case r:a="+";break;case n:a="-";break;case i:a=" ";break}l[u+1]=a+encodeURI(this.diffs[u][1])+`
86
86
  `}return l.join("").replace(/%20/g," ")},e.exports=t,e.exports.diff_match_patch=t,e.exports.DIFF_DELETE=n,e.exports.DIFF_INSERT=r,e.exports.DIFF_EQUAL=i})(X0);var G2=X0.exports;new G2.diff_match_patch;class Q2{constructor(){I(this,"value",0);Uf(this)}}new Q2;function Z0(e){var n,r,i,o,s,l;let t=[0,0,0,0];return t&&((n=e==null?void 0:e.html)!=null&&n.src&&(t[1]+=(r=e.html)==null?void 0:r.src.length),((o=(i=e==null?void 0:e.html)==null?void 0:i.untracked)==null?void 0:o.length)===2&&((s=e==null?void 0:e.html)==null||s.untracked[0].forEach(a=>{var u;t[2]+=(u=a==null?void 0:a.content)==null?void 0:u.length}),(l=e==null?void 0:e.html)==null||l.untracked[1].forEach(a=>{var u;t[3]+=(u=a==null?void 0:a.value)==null?void 0:u.length})),t[0]=t[1]+t[2]+t[3],t)}function Y2(e){let t={total:0,before:[0,0,0,0],after:[0,0,0,0]};for(let n in e)t[n]=Z0(e[n]),t.total+=t[n][0];return t}function J0(e){Array.isArray(e)?e.forEach(t=>cp(t)):cp(e)}function cp(e){e.type==="command"?X2(e):e.type==="request"?J2(e):e.type==="response"?q2(e):e.type==="log"?eA(e):e.type==="context"?tA(e):console.warn(e)}function X2(e){var a,u;let t="";((a=e.snapshots)!=null&&a.after||(u=e.snapshots)!=null&&u.before)&&(t+="S");let n=Y2(e.snapshots),r=(n.total/1e3).toFixed(2),i=(((n==null?void 0:n.before[1])+(n==null?void 0:n.after[1]))/1e3).toFixed(2),o=(((n==null?void 0:n.before[2])+(n==null?void 0:n.after[2]))/1e3).toFixed(2),s=(((n==null?void 0:n.before[3])+(n==null?void 0:n.after[3]))/1e3).toFixed(2),l=["color: #18c0d1","kb","color: #d2d3d3"];console.groupCollapsed("%s %s %s %c%s %c%s%c%s%c [%s%c%s%c, %s%c%s%c, %s%c%s%c] %s",e.context.id,e.type,e.func.padEnd(10),"color: #bada55",t.length===0?"-":t,"color: #d2d3d3",r,...l,i,...l,o,...l,s,...l,e.func),console.group("Snapshots");for(let c in e.snapshots)Z2(c,e.snapshots[c]);console.groupEnd(),console.log("source",e),console.groupEnd()}function Z2(e,t){if(!t)return;let n=Z0(t);console.group(e),console.log("Url:",t.url),console.log("Size total:",(n[0]/1e3).toFixed(2),"kb"),console.log("Size html:",(n[1]/1e3).toFixed(2),"kb"),console.log("Size css:",(n[2]/1e3).toFixed(2),"kb"),console.log("Size js:",(n[3]/1e3).toFixed(2),"kb"),console.log("Viewport:",t.viewport),console.log("Version:",t.version),console.log(t),console.groupEnd()}function J2(e){console.groupCollapsed(e.context.id,e.type.substring(0,3),e.resourceType.padEnd(10),e.method.padEnd(6),e.url.length>64?e.url.substring(0,60)+"...":e.url),console.log("Headers"),console.table(e.headers),console.log("source",e),console.groupEnd()}function q2(e){var n;let t=((n=e.content)==null?void 0:n.byteLength)??e.contentLength??0;console.groupCollapsed(e.context.id,e.type.substring(0,3),e.resourceType.padEnd(10),e.method.padEnd(6),e.url.length>64?e.url.substring(0,60)+"...":e.url,(t/1e3).toFixed(2),"kb"),console.log("Headers"),console.table(e.headers),console.log("source",e),console.groupEnd()}function eA(e){console.groupCollapsed(e.context.id,e.type,e.messageType,e.args),console.log("source",e),console.groupEnd()}function tA(e){console.groupCollapsed(e.id,e.type),console.log("source",e),console.groupEnd()}let Ml=()=>{};function nA(e){Ml(()=>{console.group("Packet received"),console.groupCollapsed("Events",Array.isArray(e)?e.length:1),J0(e),console.groupEnd(),console.groupEnd()})}class Ll{constructor(){I(this,"_debug",!1);I(this,"_connectAutomatically",!1);I(this,"_originalDebugFunc");Uf(this),this._originalDebugFunc=console.debug,this.debug=localStorage.getItem("debug.enabled")==="true",this.connectAutomatically=localStorage.getItem("connectAutomatically.enabled")==="true"}get debug(){return this._debug}set debug(t){this._debug=t,localStorage.setItem("debug.enabled",t?"true":"false"),t?this.enable():this.disable()}get connectAutomatically(){return this._connectAutomatically}set connectAutomatically(t){this._connectAutomatically=t,localStorage.setItem("connectAutomatically.enabled",t?"true":"false")}enable(){console.debug=this._originalDebugFunc,Ml=t=>t(),Ar.on("*",Ll.eventLogger),this.printPerformanceWarning()}disable(){this._originalDebugFunc=console.debug,console.debug=()=>{},Ml=()=>{},Ar.off("*",Ll.eventLogger)}static eventLogger(t,n){console.log("[EventLogger]",t,n)}printPerformanceWarning(){console.warn("[Puth] Performance is affected by debug")}}const fp=new Ll;var rA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const iA=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ae=(e,t)=>{const n=x.forwardRef(({color:r="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,children:l,...a},u)=>x.createElement("svg",{ref:u,...rA,width:i,height:i,stroke:r,strokeWidth:s?Number(o)*24/Number(i):o,className:`lucide lucide-${iA(e)}`,...a},[...t.map(([c,f])=>x.createElement(c,f)),...(Array.isArray(l)?l:[l])||[]]));return n.displayName=`${e}`,n},oA=Ae("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),sA=Ae("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),lA=Ae("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),aA=Ae("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),uA=Ae("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),cA=Ae("CircleDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}]]),fA=Ae("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]),dA=Ae("Compass",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76",key:"m9r19z"}]]),hA=Ae("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),pA=Ae("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),vA=Ae("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),gA=Ae("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),mA=Ae("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),yA=Ae("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),wA=Ae("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),xA=Ae("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),_A=Ae("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),bA=Ae("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),SA={bolt:bA,cancel:xA,check:lA,check_circle:sA,close:_A,cloud_off:fA,download:hA,error:oA,expand_less:uA,expand_more:aA,explore:dA,folder:pA,history:vA,pending:cA,progress_activity:gA,refresh:mA,settings:yA,timer:wA},Pt=({name:e,size:t,className:n,onClick:r,...i})=>{const o=SA[e];return h.jsx(o,{size:t??"1rem",className:"inline-block "+(n??""),onClick:r,...i})},q0=Se(function({onConnected:t}){const{app:n}=x.useContext(Ee),[r,i]=x.useState(!1),[o,s]=x.useState(""),[l,a]=x.useState(null),u=x.useCallback(c=>{i(!0),n.tryConnectingTo(c).then(()=>{s(""),a(null),t==null||t()}).finally(()=>{i(!1)}).catch(f=>a(f))},[t]);return h.jsxs("div",{className:"flex flex-col gap-3.5",children:[h.jsxs("label",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"font-mono text-[11.5px] text-ink-muted",children:"Address"}),h.jsx("input",{className:"h-10 w-full rounded-lg border border-shell-control bg-shell-main px-3 font-mono text-[13px] text-ink outline-none focus:border-accent-blue/50",placeholder:"ws://host:7345/websocket",onChange:c=>s(c.target.value),onKeyDown:c=>c.key==="Enter"&&o!==""&&u(o),value:o})]}),l&&h.jsxs("div",{role:"alert",className:"flex gap-2.5 rounded-lg border border-red-400/30 bg-red-500/[0.08] px-3 py-2.5",children:[h.jsx(Pt,{name:"bolt",className:"mt-0.5 flex-none text-red-300"}),h.jsx("span",{className:"font-mono text-xs text-red-300",children:(l==null?void 0:l.reason)??"Unknown error"})]}),n.connectionSuggestions.length>0&&h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"font-mono text-[11.5px] text-ink-muted",children:"Suggestions"}),n.connectionSuggestions.map((c,f)=>h.jsx("button",{type:"button",disabled:r,className:"flex min-h-[44px] w-full items-center rounded-lg border border-white/[0.12] bg-shell-main px-3 text-left font-mono text-[12.5px] text-ink hover:border-accent-blue/45 hover:bg-blue-600/10",onClick:()=>u(c),children:c},f))]}),h.jsxs("div",{className:"flex items-center justify-end gap-3",children:[r&&h.jsxs("span",{className:"flex items-center gap-2 font-mono text-xs text-ink-muted",children:[h.jsx(Pt,{name:"progress_activity",className:"animate-spin text-accent-blue"})," Connecting"]}),h.jsx("button",{type:"button",onClick:()=>u(o),disabled:r||o==="",className:"inline-flex min-h-[40px] items-center gap-2 bg-blue-600 px-4 font-mono text-[13px] font-medium text-white hover:bg-blue-500 disabled:opacity-50",children:"Connect"})]})]})}),EA=Se(function(){const{app:t}=x.useContext(Ee),[n,r]=x.useState(!1),[i,o]=x.useState(!1),s=t.connections[0],l=s?s.isConnected?"connected":"closed":"none",a=async()=>{o(!0),await(s==null?void 0:s.retry().catch(()=>{}).finally(()=>o(!1)))},u={none:"No connection",connected:"Connected",closed:"Connection closed"}[l];return h.jsxs(G0,{open:n,onOpenChange:r,children:[h.jsx(Q0,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":`${u}. Connection details`,title:s?`${u} · ${s.uri}`:u,className:ae("flex h-10 w-10 items-center justify-center rounded-[10px] border",n?"border-accent-blue/35 bg-blue-600/[0.16]":"border-transparent hover:bg-white/[0.05]"),children:h.jsx("span",{"aria-hidden":!0,className:ae("h-[9px] w-[9px] rounded-full",l==="connected"&&"bg-green-500 shadow-[0_0_0_4px_rgba(34,197,94,0.18)]",l==="closed"&&"bg-red-400 shadow-[0_0_0_4px_rgba(248,113,113,0.18)]",l==="none"&&"border-[1.5px] border-ink-muted")})})}),h.jsxs(nd,{side:"right",align:"end",sideOffset:10,className:"w-[420px] max-w-[calc(100vw-80px)] overflow-hidden rounded-xl border-white/[0.16] bg-[#151515] p-0 text-ink shadow-[0_24px_60px_rgba(0,0,0,0.65)]",children:[h.jsxs("div",{className:"flex justify-between border-b border-dashed border-neutral-800 px-[18px] py-3 font-mono text-xs",children:[h.jsx("span",{className:"text-accent-blue",children:"Connection"}),h.jsx("span",{className:ae(l==="connected"?"text-green-300":l==="closed"?"text-red-300":"text-ink-muted"),children:u})]}),h.jsxs("div",{className:"flex flex-col gap-3.5 p-[18px]",children:[s&&h.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-white/[0.12] bg-shell-main px-3 py-2.5",children:[h.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px] text-ink-body",children:s.uri}),l==="closed"&&h.jsxs("button",{type:"button",onClick:a,disabled:i,className:"flex min-h-[30px] items-center gap-1.5 rounded-md border border-white/20 px-2.5 text-xs text-ink-body hover:bg-white/[0.08]",children:[h.jsx(Pt,{name:"refresh",className:i?"animate-spin":""})," Reconnect"]})]}),h.jsx("div",{className:"text-[13px] text-ink-muted",children:s?"Switch to another instance":"Connect to a Puth instance"}),h.jsx(q0,{onConnected:()=>r(!1)})]})]})]})}),qi=({d:e})=>h.jsx("svg",{"aria-hidden":!0,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:e})}),hu=({label:e,active:t,onClick:n,children:r,badge:i})=>h.jsxs("button",{type:"button","aria-label":i!==void 0?`${e}, ${i}`:e,"aria-current":t?"page":void 0,title:e,onClick:n,className:ae("relative flex h-10 w-10 items-center justify-center rounded-[10px] border",t?"border-accent-blue/35 bg-blue-600/[0.16] text-accent-sky":"border-transparent text-ink-muted hover:bg-white/[0.05] hover:text-ink"),children:[r,i!==void 0&&h.jsx("span",{className:"absolute right-[3px] top-1 flex h-[15px] min-w-[15px] items-center justify-center rounded-full bg-neutral-800 px-[3px] font-mono text-[10px] text-ink-body",children:i})]}),dp=({id:e,label:t,checked:n,onChange:r})=>h.jsxs("label",{htmlFor:e,className:"flex min-h-[44px] cursor-pointer items-center gap-2.5 rounded-md px-2 text-sm text-ink-body hover:bg-white/[0.04]",children:[h.jsx("input",{id:e,type:"checkbox",checked:n,onChange:i=>r(i.target.checked),className:"m-0 h-4 w-4 accent-blue-600"}),t]}),AA=Se(function(){const{app:t}=x.useContext(Ee);return h.jsxs(G0,{children:[h.jsx(Q0,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Settings",title:"Settings",className:"flex h-10 w-10 items-center justify-center rounded-[10px] border border-transparent text-ink-muted hover:bg-white/[0.05] hover:text-ink data-[state=open]:border-accent-blue/35 data-[state=open]:bg-blue-600/[0.16] data-[state=open]:text-accent-sky",children:h.jsx(qi,{d:"M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12"})})}),h.jsxs(nd,{side:"right",align:"end",sideOffset:10,className:"w-[260px] overflow-hidden rounded-[10px] border-white/[0.16] bg-[#151515] p-0 text-ink shadow-[0_20px_50px_rgba(0,0,0,0.6)]",children:[h.jsx("div",{className:"border-b border-dashed border-neutral-800 px-3.5 py-2.5 font-mono text-[11.5px] text-accent-blue",children:"Settings"}),h.jsxs("div",{className:"flex flex-col p-1.5",children:[h.jsx(dp,{id:"darken-preview",label:"Darken preview",checked:t.settings.preview.darken,onChange:n=>t.setDarkenPreview(n)}),h.jsx(dp,{id:"debug-mode",label:"Debug mode",checked:fp.debug,onChange:n=>fp.debug=n})]})]})]})}),CA=Se(function(){const{app:t}=x.useContext(Ee);return h.jsxs("nav",{"aria-label":"App",className:"flex w-14 flex-none flex-col items-center gap-1.5 border-r border-shell-line bg-shell-rail py-3",children:[h.jsxs("div",{className:"flex flex-col items-center gap-0.5",title:t.name.suffix?`Puth ${t.name.suffix}`:"Puth",children:[h.jsx("img",{src:fb,alt:"Puth",className:"h-6 w-6 object-contain"}),t.name.suffix&&h.jsx("span",{className:"font-mono text-[9px] text-accent-sky",children:t.name.suffix})]}),h.jsx("span",{"aria-hidden":!0,className:"my-1 w-6 border-t border-dashed border-neutral-700"}),h.jsx(hu,{label:"Instance",active:t.view==="instance",onClick:()=>t.setView("instance"),children:h.jsx(qi,{d:"M4 5h16v11H4zM8 20h8M12 16v4"})}),t.isConnected&&h.jsx(hu,{label:"Agents",active:t.view==="agents",onClick:()=>t.setView("agents"),badge:t.liveAgents||void 0,children:h.jsx(qi,{d:"M12 3v3M8 6h8a3 3 0 0 1 3 3v6a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3V9a3 3 0 0 1 3-3ZM9.5 11.5v1M14.5 11.5v1M2 12h3M19 12h3"})}),t.hasLocalContexts&&h.jsx(hu,{label:"Local snapshots",active:t.view==="local",onClick:()=>t.setView("local"),badge:t.dragAndDropped.contexts.length,children:h.jsx(qi,{d:"M4 7h6l2 2h8v10H4z"})}),h.jsx("span",{className:"flex-1"}),h.jsx("a",{href:"https://puth.io/guide/getting-started",target:"_blank",rel:"noreferrer","aria-label":"Documentation, opens puth.io",title:"Documentation",puth:"docs",className:"flex h-10 w-10 items-center justify-center rounded-[10px] border border-transparent text-ink-muted hover:bg-white/[0.05] hover:text-ink",children:h.jsx(qi,{d:"M4 5.5A2.5 2.5 0 0 1 6.5 3H20v15H6.5A2.5 2.5 0 0 0 4 20.5zM4 20.5A2.5 2.5 0 0 0 6.5 23H20v-5"})}),h.jsx(AA,{}),h.jsx(EA,{})]})});var fo=(e=>(e.SUCCESSFUL="successful",e.FAILED="failed",e.PENDING="pending",e))(fo||{}),ey=(e=>(e.FRAME="frame",e.DOM="dom",e))(ey||{}),ye=(e=>(e.BEFORE="before",e.AFTER="after",e.REPLAY="replay",e))(ye||{});const ho={Page:"CdpPage",Browser:"CdpBrowser",ElementHandle:"CdpElementHandle"},hp=1,kA=500,OA=150;function Il({content:e,children:t,className:n}){const[r,i]=x.useState(!1),o=x.useRef(),s=x.useRef();x.useEffect(()=>()=>{window.clearTimeout(o.current),window.clearTimeout(s.current)},[]);const l=()=>{window.clearTimeout(s.current),r||(window.clearTimeout(o.current),o.current=window.setTimeout(()=>i(!0),kA))},a=()=>{window.clearTimeout(o.current),s.current=window.setTimeout(()=>i(!1),OA)},u=()=>window.clearTimeout(s.current);return h.jsxs(z0,{open:r,onOpenChange:i,children:[h.jsx(d2,{asChild:!0,children:h.jsx("div",{className:n,onMouseEnter:l,onMouseMove:l,onMouseLeave:a,onMouseDown:()=>{window.clearTimeout(o.current),i(!1)},children:t})}),h.jsx(U0,{children:h.jsx(ed,{side:"right",align:"start",sideOffset:10,collisionPadding:8,onMouseEnter:u,onMouseLeave:a,onOpenAutoFocus:c=>c.preventDefault(),onCloseAutoFocus:c=>c.preventDefault(),puth:"detail",className:"z-50 w-[440px] max-w-[calc(100vw-24px)] overflow-hidden rounded-[10px] border border-white/[0.16] bg-[#151515] text-ink shadow-[0_20px_50px_rgba(0,0,0,0.6)] outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0",children:e()})})]})}const Fl=({children:e})=>h.jsx("div",{className:"flex items-center gap-2 border-b border-dashed border-neutral-800 px-3.5 py-2.5 font-mono text-[11.5px]",children:e}),fr=({label:e,children:t})=>h.jsxs("div",{className:"px-3.5 py-2.5",children:[e&&h.jsx("div",{className:"mb-1.5 font-mono text-[11px] text-ink-muted",children:e}),h.jsx("div",{className:"max-h-[280px] overflow-auto whitespace-pre-wrap font-mono text-xs leading-relaxed text-ink-body [overflow-wrap:anywhere]",children:t})]});function ty({status:e,className:t,...n}){let r="pending";return e==="failed"?(r="error",t="text-red-400 "+(t??"")):e==="successful"?(r="check_circle",t="text-green-400 "+(t??"")):t="text-amber-300 "+(t??""),h.jsx(Pt,{name:r,className:t,...n})}function PA({resolver:e,name:t}){const n=x.useRef(null),r=async()=>{if(!n.current)return;let i=await e();n.current.href=URL.createObjectURL(i),n.current.download=t??"snapshot.puth",n.current.click(),URL.revokeObjectURL(n.current.href)};return h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",puth:"export-snapshot","aria-label":"Export snapshot",title:"Export snapshot",className:"flex h-8 w-8 items-center justify-center rounded-md border border-shell-control bg-shell-main text-ink-body hover:border-accent-blue/40 hover:text-ink",onClick:r,children:h.jsx(Pt,{name:"download"})}),h.jsx("a",{href:"",style:{display:"none"},ref:n})]})}function ny(e){return e===ho.ElementHandle?"Element":e===ho.Page?"Page":e===ho.Browser?"Browser":e}function ry(e){return(e??[]).map(t=>typeof t=="string"?`'${t}'`:JSON.stringify(t)).join(", ")}function iy(e){return e.messageType==="error"&&(e.args??[]).length===0?e.text??"":(e.args??[]).map(t=>typeof t=="object"?JSON.stringify(t):t).join(" ")}function rd(e){var n,r,i,o;const t=(n=e.errors)==null?void 0:n[0];if(t)return{title:t.type==="error"?((r=t.error)==null?void 0:r.name)??"Error":"Expectation missed",message:t.type==="error"?((i=t.error)==null?void 0:i.message)??"":((o=t.expectation)==null?void 0:o.message)??""}}function oy(e){var t,n,r;return((t=e.time)==null?void 0:t.took)??Math.max(0,(((n=e.time)==null?void 0:n.finished)??0)-(((r=e.time)==null?void 0:r.started)??0))}const un=e=>e.type==="log",sy=e=>e.type==="response"||e.type==="update",Lo=e=>un(e)?e.messageType==="error"||e.messageType==="warning":e.status==="failed"||Number(e.status)>=400,NA=["visit","setContent","blank","refresh","reload","back","forward","goto"];function jA(e,t){if(e.initiator==="setContent")return{label:e.title||"Page content",detail:"setContent",url:`${e.url}#${e.title}`};try{const n=new URL(e.url),r=t&&t.url.startsWith(n.origin),i=n.pathname+n.search+n.hash;return n.protocol.startsWith("http")?{label:r?i:n.host+i,url:e.url}:{label:n.hash||e.url,url:e.url}}catch{return{label:e.url,url:e.url}}}function ly(e){var u;const t=[],n=[],r=[],i=e.some(c=>c.type==="annotation"||c.type==="handoff");let o=!1,s,l;const a=()=>(r.length===0&&r.push({drafts:[],steps:[]}),r[r.length-1]);for(const c of e)if(c.type==="navigation"){if(c.url==="about:blank"&&c.initiator!=="setContent"&&s===void 0)continue;const f=jA(c,s);if(f.url===(s==null?void 0:s.url)&&f.label===(s==null?void 0:s.label))continue;s=f;const d=n[n.length-1],p=d&&c.timestamp<=(((u=d.command.time)==null?void 0:u.finished)||1/0);d&&p&&NA.includes(d.command.func)?d.page=f:l=f}else if(c.type==="handoff")c.state==="ended"&&(o=!1,r.push({label:"After the handoff",drafts:[],steps:[]}));else if(c.type==="annotation")c.kind==="quiet"?o=c.quiet===!0:c.kind==="tool"?r.push({tool:c,drafts:[],steps:[]}):c.kind==="draft"&&a().drafts.push(c);else if(c.type==="command"){if(o||i&&c.func==="setTimeout")continue;const f={command:c,events:[],page:l};l=void 0,n.push(f),a().steps.push(f)}else(un(c)||sy(c))&&(n.length===0?t:n[n.length-1].events).push(c);return{leading:t,steps:n,sections:r}}function ay(e){const t=n=>(n<10?"0":"")+n;return`${t(e.minutes)}:${t(e.seconds)}s`}function TA(e){if(!e)return"";try{const t=new URL(e);return t.pathname+t.search}catch{return e}}function uy(e){return un(e)?iy(e):`${e.method??""} ${e.status==="failed"?`failed ${e.errorText??""}`:e.status??""} ${TA(e.url)}`.trim()}const RA={failed:["Failed","text-red-300"],successful:["Passed","text-green-300"]},DA=e=>{if(un(e)){const t=(e.stackTrace??[]).map(n=>`${n.url??""}${n.lineNumber!=null?":"+n.lineNumber:""}${n.columnNumber!=null?":"+n.columnNumber:""}`).filter(Boolean);return h.jsxs(h.Fragment,{children:[h.jsx(Fl,{children:h.jsxs("span",{className:Lo(e)?"text-amber-300":"text-ink-muted",children:["console.",e.messageType]})}),h.jsx(fr,{children:iy(e)}),t.length>0&&h.jsx(fr,{label:"Stack",children:t.join(`
87
87
  `)})]})}return h.jsxs(h.Fragment,{children:[h.jsxs(Fl,{children:[h.jsxs("span",{className:Lo(e)?"text-amber-300":"text-accent-sky",children:[e.method??"GET"," ",e.status==="failed"?"failed":e.status]}),h.jsx("span",{className:"ml-auto text-ink-muted",children:e.resourceType})]}),h.jsx(fr,{label:"URL",children:e.url}),e.errorText&&h.jsx(fr,{label:"Error",children:e.errorText})]})},cy=({event:e})=>{const t=un(e);return h.jsx("li",{puth:t?"console-message":"network-request","data-level":t?e.messageType:void 0,children:h.jsxs(Il,{content:()=>DA(e),className:"flex min-h-[24px] items-center gap-2 rounded px-1 font-mono text-[11.5px] hover:bg-white/[0.04]",children:[h.jsx("span",{className:ae("flex-none",Lo(e)?"text-amber-300":"text-ink-muted"),children:t?`console.${e.messageType}`:e.resourceType??"request"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-ink-body",children:uy(e)})]})})};function pp(e){const t=e.filter(un).length,n=e.length-t;return[t&&`${t} console`,n&&`${n} ${n===1?"request":"requests"}`].filter(Boolean).join(" · ")}const fy=({events:e,open:t,onToggle:n,label:r})=>{if(e.length===0)return null;const i=e.some(Lo);return h.jsxs("div",{className:"ml-10 border-l border-dashed border-neutral-700 pl-2",children:[h.jsxs("button",{type:"button",puth:"step-events","aria-expanded":t,"aria-label":`${t?"Hide":"Show"} ${pp(e)} ${r}`,onClick:n,className:ae("flex min-h-[22px] w-full items-center gap-1 rounded px-1 text-left font-mono text-[11px] hover:bg-white/[0.04]",i?"text-amber-300":"text-ink-muted"),children:[h.jsx(Pt,{name:"expand_more",size:"0.7rem",className:ae("flex-none transition-transform",!t&&"-rotate-90")}),pp(e)]}),t&&h.jsx("ul",{className:"pb-1 pl-4",children:e.map(o=>h.jsx(cy,{event:o},o.id))})]})},MA=["visit","setContent","blank","refresh","reload","back","forward","goto","clickLink"],LA=/^(evaluate|value|text|attribute|url|title|screenshot|viewport|first|find|get|element|has|is|count|wait$|pause)/;function IA(e){return MA.includes(e)?"navigation":/^(assert|waitFor|waitUntil|waitUsing|expect)/.test(e)?"check":LA.test(e)?"read":"action"}const FA={navigation:"text-teal-300",action:"text-accent-sky",check:"text-violet-300",read:"text-ink-muted"},zA=({page:e})=>h.jsxs("li",{className:"flex items-center gap-2 px-3 pb-1 pt-2.5 font-mono text-[11px] text-ink-muted",puth:"page-divider",title:e.url,children:[h.jsx("span",{"aria-hidden":!0,children:"→"}),h.jsx("span",{className:"max-w-[70%] truncate text-ink-body",children:e.label}),e.detail&&h.jsx("span",{children:e.detail}),h.jsx("span",{"aria-hidden":!0,className:"flex-1 border-t border-dashed border-neutral-700"})]}),dy=e=>e>=1e3?(e/1e3).toFixed(1)+"s":Math.round(e)+"ms",UA=e=>typeof e=="string"?`'${e}'`:JSON.stringify(e,null,2),vp=(e,t,n)=>{var o;const r=rd(e),i=e.args??[];return h.jsxs(h.Fragment,{children:[h.jsxs(Fl,{children:[h.jsxs("span",{className:"text-accent-sky",children:[ny((o=e.on)==null?void 0:o.type),".",e.func]}),h.jsxs("span",{className:"ml-auto text-ink-muted",children:["step ",t+1," of ",n," · ",dy(oy(e))]})]}),i.length>0&&h.jsx(fr,{label:i.length===1?"Argument":"Arguments",children:i.map(UA).join(`,
88
- `)}),r&&h.jsx(fr,{label:r.title,children:r.message})]})},BA=Se(function({context:t,step:n,index:r,count:i,open:o,onToggle:s}){var m;const{command:l,events:a}=n,u=t.preview,c=((m=u==null?void 0:u.activeCommand)==null?void 0:m.id)===l.id,f=(l.errors??[]).length>0,d=oy(l),p=c||f||d>=1e3,y=f&&t.isAgent?rd(l):void 0;return h.jsxs("li",{onMouseEnter:()=>u==null?void 0:u.highlightCommand(l),onMouseLeave:()=>u==null?void 0:u.unhighlightCommand(l),children:[h.jsx(Il,{content:()=>vp(l,r,i),children:h.jsxs("button",{type:"button",puth:"step","data-active":c?"true":void 0,"data-failed":f?"true":void 0,"aria-pressed":c,className:ae("flex h-[34px] w-full items-center gap-2.5 rounded-lg border px-3 text-left",c?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent hover:bg-white/[0.04]"),onClick:()=>u==null?void 0:u.toggleCommand(l),children:[h.jsx("span",{className:ae("w-[18px] flex-none text-right font-mono text-[11px]",c?"text-accent-sky":f?"text-red-300":"text-[#8f8f8f]"),children:String(r+1).padStart(2,"0")}),h.jsx("span",{className:ae("flex-none font-mono text-[13px]",FA[IA(l.func)]),children:l.func}),h.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-ink-body",children:ry(l.args)}),p&&h.jsx("span",{className:ae("flex-none font-mono text-[11px]",f?"text-red-300":d>=1e3?"text-amber-300":"text-ink-muted"),children:dy(d)})]})}),y&&h.jsx(Il,{content:()=>vp(l,r,i),className:"ml-10 border-l border-dashed border-red-400/40 pl-2",children:h.jsxs("div",{className:"flex min-h-[22px] items-center gap-1.5 px-1 text-[12px] text-red-200","data-messagetype":"error",children:[h.jsxs("span",{className:"flex-none text-red-300/80",children:[y.title,"."]}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.message})]})}),h.jsx(fy,{events:a,open:o,onToggle:s,label:`after ${l.func}`})]})}),$A=Se(function({context:t}){const{app:n}=x.useContext(Ee),[r,i]=x.useState(!1);if(!t.group)return null;const o=n.history.filter(l=>l.group===t.group);if(o.length<2)return h.jsx("div",{className:"mt-1 font-mono text-xs text-ink-muted",children:t.group});const s=o.filter(l=>l.test.status==="failed").length;return h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(!r),className:"mt-1 flex min-h-[28px] flex-wrap items-center gap-1.5 text-left font-mono text-xs text-ink-muted",children:[h.jsx("span",{children:t.group}),h.jsxs("span",{className:"text-ink-body",children:["· ",o.length," tests"]}),s>0&&h.jsxs("span",{children:["· ",s," failed"]}),h.jsx(Pt,{name:"expand_more",size:"0.7rem",className:ae("transition-transform",r&&"rotate-180")})]}),r&&h.jsx("ul",{"aria-label":`Tests in ${t.group}`,className:"mt-2 flex flex-col gap-0.5 rounded-lg border border-white/[0.08] bg-shell-main p-1",children:o.map(l=>h.jsx("li",{children:h.jsxs("button",{type:"button","aria-current":l===t,onClick:()=>n.setActive(l),className:ae("flex min-h-[36px] w-full items-center gap-2.5 rounded-md border px-2.5 text-left text-[13px] hover:bg-white/[0.04]",l===t?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent"),children:[h.jsx(ty,{status:l.test.status,size:"0.8rem"}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.test.name}),h.jsx("span",{className:"font-mono text-[11.5px] text-ink-muted",children:ay(l.took)})]})},l.id))})]})});function VA(e,t){x.useEffect(()=>{const n=r=>{const i=r.target;if(r.altKey||r.ctrlKey||r.metaKey||i!=null&&i.closest('input, textarea, select, [contenteditable="true"]'))return;const o=e.preview;if(!o||t.length===0)return;if(r.key==="ArrowLeft"||r.key==="ArrowRight"){o.state=r.key==="ArrowLeft"?ye.BEFORE:ye.AFTER,r.preventDefault();return}if(r.key!=="ArrowUp"&&r.key!=="ArrowDown")return;const s=t.findIndex(a=>{var u;return a.id===((u=o.activeCommand)==null?void 0:u.id)}),l=s===-1?r.key==="ArrowDown"?0:t.length-1:Math.min(t.length-1,Math.max(0,s+(r.key==="ArrowDown"?1:-1)));l!==s&&o.toggleCommand(t[l]),r.preventDefault()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t])}const WA=({tool:e,steps:t})=>{const n=t.some(r=>(r.command.errors??[]).length>0);return h.jsxs("div",{className:"flex items-baseline gap-2 px-3 pb-1 pt-3 font-mono text-[11.5px]",puth:"tool-call",children:[h.jsx("span",{className:n?"text-red-300":"text-accent-sky",children:e.tool}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-ink-muted",title:e.summary,children:e.summary}),t.length>0&&h.jsxs("span",{className:"flex-none text-ink-muted",children:[t.length," ",t.length===1?"step":"steps"]})]})},HA=({draft:e})=>{const[t,n]=x.useState(!1),r=()=>{var i;(i=navigator.clipboard)==null||i.writeText(e.code??"").then(()=>{n(!0),setTimeout(()=>n(!1),1500)}).catch(()=>{})};return h.jsx("div",{className:"mx-1 my-1 rounded-lg border border-white/[0.12] bg-shell-main",puth:"draft",children:h.jsxs(Il,{className:"flex h-[34px] items-center gap-2 pl-3 pr-1.5 font-mono text-[11.5px]",content:()=>h.jsxs(h.Fragment,{children:[h.jsxs(Fl,{children:[h.jsx("span",{className:"text-indigo-300",children:"Draft"}),h.jsxs("span",{className:"text-ink-body",children:[e.format," · ",e.name]}),h.jsx("span",{className:"ml-auto text-amber-300",children:"unverified until the suite passed it"})]}),h.jsx(fr,{children:e.code})]}),children:[h.jsx("span",{className:"flex-none text-indigo-300",children:"Draft"}),h.jsxs("span",{className:"min-w-0 flex-1 truncate text-ink-body",children:[e.format," · ",e.name]}),h.jsx("span",{className:"flex-none rounded bg-amber-500/[0.14] px-1.5 text-[10.5px] text-amber-300",children:"unverified"}),h.jsx("button",{type:"button",onClick:r,className:"min-h-[26px] flex-none rounded-md border border-white/20 px-2 text-ink-body hover:bg-white/[0.08]",children:t?"Copied":"Copy"})]})})},KA={waiting:"Waiting for an agent to take over",claimed:"An agent drives this test",ended:"Handed back to the test"},GA=Se(function({context:t}){var D;const{app:n}=x.useContext(Ee),r=x.useRef(null),[i,o]=x.useState("steps"),[s,l]=x.useState({}),{leading:a,steps:u,sections:c}=ly(t.renderedEvents),f=u.map(k=>k.command),d=t.renderedEvents.filter(un),p=t.renderedEvents.filter(sy);VA(t,f);const y=t.isAgent,m=t.handoff,b=y?-1:u.findIndex(k=>(k.command.errors??[]).length>0),v=b===-1?void 0:u[b],g=v&&rd(v.command),w=v&&[...a,...u.slice(0,b).flatMap(k=>k.events)].reverse().find(k=>un(k)?k.messageType==="error":Lo(k)),[_,S]=y?t.isLive?["Live","text-green-300"]:["Closed","text-ink-muted"]:RA[t.test.status??""]??["Running","text-amber-300"];x.useLayoutEffect(()=>{r.current&&t.followIncoming&&t.renderedEvents.length!==0&&(r.current.scrollTop=r.current.scrollHeight)},[t,t.renderedEvents.length]);const E=()=>jn(()=>{var z,B,K;t.followIncoming=!t.followIncoming;const k=f[f.length-1];t.followIncoming&&k&&((B=(z=t.preview)==null?void 0:z.activeCommand)==null?void 0:B.id)!==k.id&&((K=t.preview)==null||K.toggleCommand(k))}),A=()=>{var k,z,B;o("steps"),v&&((z=(k=t.preview)==null?void 0:k.activeCommand)==null?void 0:z.id)!==v.command.id&&((B=t.preview)==null||B.toggleCommand(v.command))},C=k=>ae("flex min-h-[32px] items-center gap-1.5 rounded-md border px-2.5 text-[13px]",k?"border-white/20 bg-neutral-800 text-ink":"border-transparent text-ink-muted hover:text-ink"),j=k=>ae("flex h-8 items-center gap-1.5 rounded-md border px-2.5 font-mono text-[11.5px]",k?"border-accent-blue/45 bg-blue-600/[0.14] text-accent-sky":"border-shell-control bg-shell-main text-ink-body hover:text-ink"),P=k=>{const z=u.indexOf(k),B=s[k.command.id]??!1;return h.jsxs(x.Fragment,{children:[k.page&&h.jsx(zA,{page:k.page}),h.jsx(BA,{context:t,step:k,index:z,count:u.length,open:B,onToggle:()=>l({...s,[k.command.id]:!B})})]},k.command.id)};return h.jsxs("section",{"aria-label":y?"Agent session":"Test run",className:"flex min-h-0 flex-1 flex-col",children:[h.jsxs("div",{className:"flex items-center gap-2 border-b border-dashed border-neutral-800 py-2 pl-4 pr-3 font-mono text-xs",children:[h.jsxs("span",{className:ae("flex items-center gap-1.5",S),children:[y&&t.isLive&&h.jsx("span",{"aria-hidden":!0,className:"h-[7px] w-[7px] animate-pulse rounded-full bg-green-500"}),_]}),h.jsxs("span",{className:"ml-auto mr-1 text-ink-muted",children:[y&&`${t.toolCalls} ${t.toolCalls===1?"call":"calls"} · `,u.length," ",u.length===1?"step":"steps"," · ",ay(t.took)]}),y&&t.isLive&&h.jsx("button",{type:"button",puth:"follow","aria-pressed":t.followIncoming,onClick:E,className:j(t.followIncoming),children:"Follow"}),y&&h.jsx("button",{type:"button","aria-pressed":n.pinned.includes(t.id),onClick:()=>n.togglePinned(t),className:j(n.pinned.includes(t.id)),title:"Keep this session listed after it closed",children:n.pinned.includes(t.id)?"Pinned":"Pin"}),h.jsx(PA,{name:`snapshot-${t.createdAt}-${t.id}.puth`,resolver:()=>t.blob()})]}),h.jsxs("div",{className:"px-4 pb-3 pt-3.5",children:[h.jsx("div",{className:"break-words text-[17px] font-medium tracking-[-0.01em]",children:t.test.name}),y?h.jsx("div",{className:"mt-1 font-mono text-xs text-ink-muted",children:"Agent session"}):h.jsx($A,{context:t})]}),m&&h.jsxs("div",{className:"mx-3 mb-3 flex items-center gap-2.5 rounded-[10px] border border-indigo-300/25 bg-indigo-500/[0.08] px-3 py-2 text-[12.5px]",puth:"handoff",children:[h.jsx("span",{"aria-hidden":!0,className:ae("h-[7px] w-[7px] flex-none rounded-full",m.state==="claimed"?"animate-pulse bg-indigo-300":"bg-indigo-300/50")}),h.jsxs("span",{className:"min-w-0 flex-1 text-ink-body",children:[KA[m.state],m.name&&h.jsxs("span",{className:"font-mono text-ink-muted",children:[" · ",m.name]})]}),m.state==="ended"&&m.reason&&h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:m.reason})]}),v&&g&&h.jsxs("div",{className:"mx-3 mb-3 overflow-hidden rounded-[10px] border border-white/[0.14] bg-shell-main","data-messagetype":"error",children:[h.jsxs("div",{className:"flex items-center gap-2 border-b border-dashed border-neutral-800 py-2 pl-3 pr-2 font-mono text-[11.5px]",children:[h.jsxs("span",{className:"min-w-0 flex-1 truncate text-red-300",children:["Failed at ",v.command.func," ",(D=v.command.args)!=null&&D.length?ry(v.command.args.slice(0,1)):""]}),h.jsx("button",{type:"button",onClick:A,className:"min-h-[28px] flex-none rounded-md border border-white/20 px-2.5 text-ink-body hover:bg-white/[0.08]",children:"Show step"})]}),h.jsxs("div",{className:"px-3 py-2.5 text-[13px] leading-relaxed text-neutral-200",children:[h.jsxs("span",{className:"text-ink-muted",children:[g.title,"."]})," ",g.message]}),w&&h.jsxs("div",{className:"px-3 pb-2.5 text-[12.5px] leading-normal text-ink-muted",children:[un(w)?"Console error":"Request"," before this step: ",h.jsx("span",{className:"font-mono text-ink-body",children:uy(w)})]})]}),h.jsxs("div",{role:"tablist","aria-label":"Events",className:"flex gap-1 border-b border-dashed border-neutral-800 px-3 pb-2.5",children:[h.jsxs("button",{type:"button",role:"tab",puth:"tab-steps","aria-selected":i==="steps",className:C(i==="steps"),onClick:()=>o("steps"),children:["Steps ",h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:u.length})]}),h.jsxs("button",{type:"button",role:"tab",puth:"tab-console","aria-selected":i==="console",className:C(i==="console"),onClick:()=>o("console"),children:["Console ",h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:d.length})]}),p.length>0&&h.jsxs("button",{type:"button",role:"tab",puth:"tab-network","aria-selected":i==="network",className:C(i==="network"),onClick:()=>o("network"),children:["Network ",h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:p.length})]})]}),h.jsx("div",{ref:r,className:"min-h-0 flex-1 overflow-y-auto p-2",children:i==="steps"?h.jsxs(h.Fragment,{children:[h.jsx(fy,{events:a,open:s.leading??!1,onToggle:()=>l({...s,leading:!s.leading}),label:"before the first step"}),c.map((k,z)=>{var B;return h.jsxs("div",{children:[k.tool&&h.jsx(WA,{tool:k.tool,steps:k.steps}),!k.tool&&(k.label||z===0&&c.length>1&&t.handoff)&&h.jsx("div",{className:"px-3 pb-1 pt-3 font-mono text-[11.5px] text-ink-muted",children:k.label??"Before the handoff"}),h.jsx("ol",{className:"flex flex-col",children:k.steps.map(P)}),k.drafts.map(K=>h.jsx(HA,{draft:K},K.id))]},((B=k.tool)==null?void 0:B.id)??z)}),u.length===0&&a.length===0&&c.length===0&&h.jsx("div",{className:"px-3 py-4 text-[13px] text-ink-muted",children:"No steps recorded yet."})]}):h.jsxs("ul",{className:"px-3",children:[(i==="console"?d:p).map(k=>h.jsx(cy,{event:k},k.id)),i==="console"&&d.length===0&&h.jsx("li",{className:"py-4 text-[13px] text-ink-muted",children:"No console output."})]})}),h.jsx("div",{className:"border-t border-shell-line px-4 py-2 font-mono text-[11.5px] text-ink-muted",children:"↑ ↓ step · ← → before / after"})]})}),QA=Se(function(){const{app:t}=x.useContext(Ee);return t.activeContext?h.jsx(GA,{context:t.activeContext},t.activeContext.id):h.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center text-sm text-ink-muted",children:[h.jsx(Pt,{name:"explore",size:"2rem"}),t.view==="agents"?"Select an agent session below.":"Select a test in the history list below."]})});function YA(e){let t=new Date(e),n=""+(t.getMonth()+1),r=""+t.getDate(),i=t.getFullYear();return n.length<2&&(n="0"+n),r.length<2&&(r="0"+r),[i,n,r].join("-")}function XA(e){const t=n=>(n<10?"0":"")+n;return`${t(e.minutes)}:${t(e.seconds)}s`}const ZA=Se(function({context:t}){var i,o;const{app:n}=x.useContext(Ee),r=n.activeContext===t;return h.jsx("li",{children:h.jsxs("button",{type:"button",puth:"history-item","aria-current":r,className:ae("flex w-full items-start gap-2.5 rounded-lg border px-2.5 py-2 text-left hover:bg-white/[0.04]",r?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent"),onClick:()=>n.setActive(t),children:[h.jsx(ty,{status:t.test.status,size:"0.95rem",className:"mt-0.5 flex-none"}),h.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-[3px]",children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"truncate text-sm text-ink",children:t.test.name}),(((i=t.handoff)==null?void 0:i.state)==="waiting"||((o=t.handoff)==null?void 0:o.state)==="claimed")&&h.jsx("span",{className:"flex-none rounded bg-indigo-500/[0.16] px-1.5 font-mono text-[10.5px] text-indigo-200",children:t.handoff.state==="claimed"?"agent":"handoff"})]}),t.group&&h.jsx("span",{className:"truncate font-mono text-[11.5px] text-ink-muted",children:t.group})]}),h.jsxs("span",{className:"flex flex-none flex-col items-end gap-[3px] font-mono text-[11.5px] text-ink-muted",children:[h.jsx("span",{children:XA(t.took)}),h.jsx("span",{children:YA(t.lastActivity)})]})]})})}),JA=[["","All"],[fo.FAILED,"Failed"],[fo.SUCCESSFUL,"Passed"],[fo.PENDING,"Running"]],qA=Se(function(){const{app:t}=x.useContext(Ee),[n,r]=x.useState(!0),[i,o]=x.useState(""),[s,l]=x.useState("");if(t.empty)return h.jsx(h.Fragment,{});let a=t.history;if(i!==""){let u=i.toLowerCase();a=a.filter(c=>c.test.name.toLowerCase().includes(u)||(c.group??"").toLowerCase().includes(u))}return s!==""&&(a=a.filter(u=>(u.test.status??fo.PENDING)===s)),h.jsxs("section",{"aria-label":"History",className:ae("flex flex-col border-t border-shell-line",n&&"max-h-[40vh]"),children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(!n),className:"flex min-h-[44px] flex-none items-center gap-2.5 border-b border-dashed border-neutral-800 px-4 font-mono text-xs",children:[h.jsx("span",{className:"text-accent-sky",children:"History"}),h.jsx("span",{className:"text-ink-muted",children:t.history.length}),h.jsx(Pt,{name:"expand_more",className:ae("ml-auto text-ink-muted transition-transform",n&&"rotate-180")})]}),n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-none flex-wrap gap-2 px-3 pb-1 pt-2.5",children:[h.jsxs("label",{className:"flex h-[34px] min-w-[160px] flex-1 items-center gap-2 rounded-lg border border-shell-control bg-shell-main px-2.5 text-ink-muted",children:[h.jsxs("svg",{"aria-hidden":!0,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"m20 20-3.5-3.5"})]}),h.jsx("input",{type:"search","aria-label":"Filter history",placeholder:"Filter tests",value:i,onChange:u=>o(u.target.value),className:"min-w-0 flex-1 border-0 bg-transparent text-[13px] text-ink outline-none"})]}),h.jsx("div",{role:"group","aria-label":"Status",className:"flex h-[34px] rounded-lg border border-shell-control bg-shell-main p-0.5",children:JA.map(([u,c])=>h.jsx("button",{type:"button","aria-pressed":s===u,onClick:()=>l(u),className:ae("rounded-md px-2.5 font-mono text-[11.5px]",s===u?"bg-neutral-800 text-ink":"text-ink-muted hover:text-ink"),children:c},c))})]}),h.jsxs("ul",{className:"flex min-h-0 flex-col gap-0.5 overflow-y-auto px-2 pb-2.5 pt-1.5",children:[a.length===0&&h.jsx("li",{className:"px-2.5 py-3.5 text-[13px] text-ink-muted",children:t.history.length===0?"No tests have run on this instance yet.":"No tests match this filter."}),a.map(u=>h.jsx(ZA,{context:u},u.id))]})]})]})}),eC=10*60*1e3;function tC(e){const t=n=>(n<10?"0":"")+n;return`${t(e.minutes)}:${t(e.seconds)}s`}function nC(e,t){const n=Math.round((t-e)/6e4);return n<1?"just now":n<60?`${n} min ago`:`${Math.round(n/60)} h ago`}const gp=Se(function({context:t,now:n}){const{app:r}=x.useContext(Ee),i=r.activeContext===t,o=r.pinned.includes(t.id),s=!t.isAgent;return h.jsx("li",{children:h.jsxs("button",{type:"button",puth:"agent-item","aria-current":i,onClick:()=>r.setActive(t),className:ae("flex w-full items-start gap-2.5 rounded-lg border px-2.5 py-2 text-left hover:bg-white/[0.04]",i?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent"),children:[h.jsx("span",{"aria-hidden":!0,className:ae("mt-[7px] h-[7px] w-[7px] flex-none rounded-full",t.isLive?"animate-pulse bg-green-500":"border border-ink-muted")}),h.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-[3px]",children:[h.jsx("span",{className:"truncate text-sm text-ink",children:t.test.name}),h.jsxs("span",{className:"truncate font-mono text-[11.5px] text-ink-muted",children:[s?`handoff · ${t.group}`:`${t.toolCalls} ${t.toolCalls===1?"call":"calls"}`,o&&" · pinned"]})]}),h.jsxs("span",{className:"flex flex-none flex-col items-end gap-[3px] font-mono text-[11.5px] text-ink-muted",children:[h.jsx("span",{className:t.isLive?"text-green-300":void 0,children:t.isLive?"live":tC(t.took)}),!t.isLive&&h.jsx("span",{children:nC(t.lastActivity,n)})]})]})})}),rC=Se(function(){const{app:t}=x.useContext(Ee),[n,r]=x.useState(!1),[i,o]=x.useState(Date.now());x.useEffect(()=>{const d=setInterval(()=>o(Date.now()),3e4);return()=>clearInterval(d)},[]);const s=t.agents,l=d=>d.isLive||t.pinned.includes(d.id)||t.activeContext===d||i-d.lastActivity<eC,a=n?s:s.filter(l),u=s.length-s.filter(l).length,c=a.filter(d=>d.isLive),f=a.filter(d=>!d.isLive);return h.jsxs("section",{"aria-label":"Agent sessions",className:"flex max-h-[45vh] flex-col border-t border-shell-line",children:[h.jsxs("div",{className:"flex min-h-[44px] flex-none items-center gap-2.5 border-b border-dashed border-neutral-800 px-4 font-mono text-xs",children:[h.jsx("span",{className:"text-accent-sky",children:"Agent sessions"}),h.jsx("span",{className:"text-ink-muted",children:s.length}),t.liveAgents>0&&h.jsxs("span",{className:"ml-auto text-green-300",children:[t.liveAgents," live"]})]}),h.jsxs("ul",{className:"flex min-h-0 flex-col gap-0.5 overflow-y-auto px-2 pb-2.5 pt-1.5",children:[s.length===0&&h.jsxs("li",{className:"px-2.5 py-3.5 text-[13px] leading-relaxed text-ink-muted",children:["No agent sessions yet. Agents connected through the Puth MCP server show up here while they work."," ",h.jsx("a",{href:"https://puth.io/guide/mcp",target:"_blank",rel:"noreferrer",className:"text-accent-sky hover:text-blue-200",children:"Set up the MCP server"})]}),c.map(d=>h.jsx(gp,{context:d,now:i},d.id)),f.length>0&&c.length>0&&h.jsx("li",{"aria-hidden":!0,className:"mx-2.5 my-1 border-t border-dashed border-neutral-800"}),f.map(d=>h.jsx(gp,{context:d,now:i},d.id)),u>0&&h.jsx("li",{children:h.jsx("button",{type:"button",onClick:()=>r(!n),className:"w-full rounded-md px-2.5 py-2 text-left font-mono text-[11.5px] text-ink-muted hover:text-ink",children:n?"Hide older sessions":`Show ${u} older ${u===1?"session":"sessions"}`})})]})]})}),mp=e=>ae("min-w-[64px] rounded-md px-3 font-mono text-xs",e?"bg-blue-600 text-white":"text-ink-muted hover:text-ink"),iC=Se(function(){var s;const{app:t}=x.useContext(Ee),n=t.previewStore,r=(n==null?void 0:n.visibleHighlightState)??(n==null?void 0:n.state),i=(s=n==null?void 0:n.visibleScreencast)==null?void 0:s.page,o=l=>{n&&(n.state=l)};return h.jsxs("div",{className:"flex flex-none flex-wrap items-center gap-2.5 border-b border-shell-line bg-shell-bar px-3 py-2.5",children:[h.jsxs("div",{role:"group","aria-label":"Snapshot",className:"flex h-8 rounded-lg border border-shell-control bg-shell-main p-0.5",children:[h.jsx("button",{type:"button","aria-pressed":r===ye.BEFORE,className:mp(r===ye.BEFORE),onClick:()=>o(ye.BEFORE),children:"Before"}),h.jsx("button",{type:"button","aria-pressed":r===ye.AFTER,className:mp(r===ye.AFTER),onClick:()=>o(ye.AFTER),children:"After"})]}),h.jsxs("div",{className:"flex h-8 min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-white/[0.12] bg-shell-main px-3 font-mono text-xs text-ink-body",children:[h.jsxs("svg",{"aria-hidden":!0,width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#a3a3a3",strokeWidth:"2",children:[h.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),h.jsx("path",{d:"M8 11V8a4 4 0 0 1 8 0v3"})]}),h.jsx("span",{className:"truncate","aria-label":"Page URL",children:(i==null?void 0:i.url)??""})]}),(i==null?void 0:i.viewport)&&h.jsxs("span",{className:"font-mono text-xs text-ink-muted",children:[i.viewport.width," × ",i.viewport.height]})]})}),oC=Se(function(){var l,a;const{app:t}=x.useContext(Ee),n=t.previewStore,r=n==null?void 0:n.visibleCommand,i=ly(((l=t.activeContext)==null?void 0:l.renderedEvents)??[]).steps.map(u=>u.command),o=r?i.findIndex(u=>u.id===r.id):-1,s=u=>(u<10?"0":"")+u;return h.jsxs("div",{className:"flex flex-none flex-wrap justify-between gap-x-6 gap-y-2 border-t border-shell-line bg-shell-bar px-4 py-3 font-mono text-xs text-ink-muted",children:[r&&o!==-1?h.jsxs("span",{children:["Step ",h.jsx("span",{className:"text-ink",children:s(o+1)})," / ",s(i.length)," · ",h.jsxs("span",{className:"text-accent-sky",children:[ny((a=r.on)==null?void 0:a.type),".",r.func]})," · ",n==null?void 0:n.visibleHighlightState]}):h.jsx("span",{children:"Latest frame"}),h.jsx("span",{children:n!=null&&n.isVisibleHighlight?"Previewing · click to pin":"Hover a step to preview it"})]})}),sC=Se(function(){var n,r,i;const{app:t}=x.useContext(Ee);return(n=t.previewStore)!=null&&n.activeScreencastUrl?h.jsxs("div",{className:"relative w-full overflow-hidden rounded-lg border border-white/[0.18] shadow-[0_24px_60px_rgba(0,0,0,0.5)]",style:{maxWidth:`${(r=t.previewStore)==null?void 0:r.visibleScreencast.page.viewport.width}px`},children:[h.jsx("img",{src:(i=t.previewStore)==null?void 0:i.activeScreencastUrl,alt:"Page at the selected step",className:"block w-full"}),t.settings.preview.darken&&h.jsx("div",{className:"pointer-events-none absolute inset-0 bg-black/50"})]}):h.jsx("div",{className:"mt-16 font-mono text-xs text-ink-muted",children:"No frame recorded for this step."})}),yp="https://puth.io/guide",pu=({label:e,labelClass:t,children:n,link:r})=>h.jsxs("section",{className:"overflow-hidden rounded-xl border border-white/[0.12] bg-gradient-to-b from-[#191919] to-[#141414] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[h.jsx("div",{className:"border-b border-dashed border-neutral-800 px-5 py-3 font-mono text-xs",children:h.jsx("span",{className:t,children:e})}),h.jsx("div",{className:"p-5",children:n}),r&&h.jsx("div",{className:"flex justify-end border-t border-dashed border-neutral-800 px-5 py-3 font-mono text-[12.5px]",children:h.jsxs("a",{href:r[1],target:"_blank",rel:"noreferrer",className:"text-accent-sky hover:text-blue-200",children:[r[0]," →"]})})]}),wp=()=>h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:h.jsxs("div",{className:"mx-auto flex max-w-[1200px] flex-col gap-4 px-4 pb-8 pt-4",children:[h.jsxs("section",{className:"shell-hero relative flex min-h-[300px] flex-col justify-end overflow-hidden rounded-xl px-10 pb-9 pt-12",children:[h.jsx("div",{"aria-hidden":!0,className:"shell-hero-dots absolute inset-0"}),h.jsx("div",{"aria-hidden":!0,className:"shell-hero-grain absolute inset-0"}),h.jsx("div",{"aria-hidden":!0,className:"shell-hero-scrim absolute inset-0"}),h.jsxs("div",{className:"relative max-w-[620px]",children:[h.jsx("div",{className:"font-mono text-xs text-blue-100",children:"No instance connected"}),h.jsx("h1",{className:"mt-3 text-4xl font-medium leading-tight tracking-[-0.02em] text-white",children:"Connect to a server, or drop in a snapshot."}),h.jsxs("p",{className:"mt-3.5 text-[15px] leading-relaxed text-blue-50",children:["Tests show up here as they run. A ",h.jsx("code",{className:"rounded bg-white/15 px-1.5 py-px font-mono text-[13px] text-white",children:".puth"})," file from CI works without any connection."]})]})]}),h.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(300px,1fr))] gap-4",children:[h.jsx(pu,{label:"Connect",labelClass:"text-accent-blue",children:h.jsx(q0,{})}),h.jsxs("div",{className:"flex flex-col gap-4",children:[h.jsxs(pu,{label:"Start a server",labelClass:"text-accent-blue",link:["Getting started",`${yp}/getting-started`],children:[h.jsx("p",{className:"text-sm leading-relaxed text-ink-muted",children:"One container serves the browser API and this GUI."}),h.jsx("code",{className:"mt-3.5 block overflow-x-auto whitespace-nowrap rounded-lg border border-white/10 bg-shell-main px-3.5 py-3 font-mono text-[12.5px] text-ink-body",children:"docker run -it --rm -p 127.0.0.1:7345:7345 puthio/puth"})]}),h.jsx(pu,{label:"Replay from CI",labelClass:"text-indigo-300",link:["Snapshots in CI",`${yp}/ci-cd`],children:h.jsxs("p",{className:"text-sm leading-relaxed text-ink-muted",children:["Drag a ",h.jsx("code",{className:"rounded bg-white/[0.12] px-1.5 py-px font-mono text-[12.5px] text-ink",children:".puth"})," snapshot anywhere into this window to step through a recorded test."]})})]})]})]})}),lC=Se(function(){const{app:t}=x.useContext(Ee),n=t.view!=="local"&&t.history.length===0;return h.jsx("div",{className:"shell-dots flex flex-1 items-center justify-center p-8 text-center font-mono text-xs text-ink-muted",children:t.view==="agents"?n?"No agent sessions yet.":"Select an agent session to watch it.":n?"Connected. Tests show up here as they run.":"Select a test in the history to inspect it."})}),aC=Se(function(){const{app:t}=x.useContext(Ee),n=t.view!=="local"&&!t.isConnected;return h.jsxs("div",{className:"flex h-screen w-screen bg-shell-main text-ink",children:[h.jsx(CA,{}),t.empty?h.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:h.jsx(wp,{})}):h.jsxs("div",{className:"flex min-w-0 flex-1",children:[h.jsxs("aside",{"aria-label":"Test",className:"flex w-[440px] min-w-[320px] flex-shrink flex-col border-r border-shell-line bg-shell-side",children:[h.jsx(QA,{}),t.view==="agents"?h.jsx(rC,{}):h.jsx(qA,{})]}),h.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:t.previewStore?h.jsxs(h.Fragment,{children:[h.jsx(iC,{}),h.jsx("div",{className:"shell-dots flex min-h-0 flex-1 items-start justify-center overflow-auto p-4",children:h.jsx(sC,{})}),h.jsx(oC,{})]}):n?h.jsx(wp,{}):h.jsx(lC,{})})]})]})});var hy={exports:{}},uC="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",cC=uC,fC=cC;function py(){}function vy(){}vy.resetWarningCache=py;var dC=function(){function e(r,i,o,s,l,a){if(a!==fC){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:vy,resetWarningCache:py};return n.PropTypes=n,n};hy.exports=dC();var hC=hy.exports;const ee=Fc(hC);var pC=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function rs(e,t){var n=vC(e);if(typeof n.path!="string"){var r=e.webkitRelativePath;Object.defineProperty(n,"path",{value:typeof t=="string"?t:typeof r=="string"&&r.length>0?r:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function vC(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var r=t.split(".").pop().toLowerCase(),i=pC.get(r);i&&Object.defineProperty(e,"type",{value:i,writable:!1,configurable:!1,enumerable:!0})}return e}var gC=[".DS_Store","Thumbs.db"];function mC(e){return Pi(this,void 0,void 0,function(){return Ni(this,function(t){return zl(e)&&yC(e)?[2,bC(e.dataTransfer,e.type)]:wC(e)?[2,xC(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,_C(e)]:[2,[]]})})}function yC(e){return zl(e.dataTransfer)}function wC(e){return zl(e)&&zl(e.target)}function zl(e){return typeof e=="object"&&e!==null}function xC(e){return Tc(e.target.files).map(function(t){return rs(t)})}function _C(e){return Pi(this,void 0,void 0,function(){var t;return Ni(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(r){return r.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(r){return rs(r)})]}})})}function bC(e,t){return Pi(this,void 0,void 0,function(){var n,r;return Ni(this,function(i){switch(i.label){case 0:return e===null?[2,[]]:e.items?(n=Tc(e.items).filter(function(o){return o.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(SC))]):[3,2];case 1:return r=i.sent(),[2,xp(gy(r))];case 2:return[2,xp(Tc(e.files).map(function(o){return rs(o)}))]}})})}function xp(e){return e.filter(function(t){return gC.indexOf(t.name)===-1})}function Tc(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r)}return t}function SC(e){if(typeof e.webkitGetAsEntry!="function")return _p(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?my(t):_p(e)}function gy(e){return e.reduce(function(t,n){return xE(t,Array.isArray(n)?gy(n):[n])},[])}function _p(e){var t=e.getAsFile();if(!t)return Promise.reject(e+" is not a File");var n=rs(t);return Promise.resolve(n)}function EC(e){return Pi(this,void 0,void 0,function(){return Ni(this,function(t){return[2,e.isDirectory?my(e):AC(e)]})})}function my(e){var t=e.createReader();return new Promise(function(n,r){var i=[];function o(){var s=this;t.readEntries(function(l){return Pi(s,void 0,void 0,function(){var a,u,c;return Ni(this,function(f){switch(f.label){case 0:if(l.length)return[3,5];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Promise.all(i)];case 2:return a=f.sent(),n(a),[3,4];case 3:return u=f.sent(),r(u),[3,4];case 4:return[3,6];case 5:c=Promise.all(l.map(EC)),i.push(c),o(),f.label=6;case 6:return[2]}})})},function(l){r(l)})}o()})}function AC(e){return Pi(this,void 0,void 0,function(){return Ni(this,function(t){return[2,new Promise(function(n,r){e.file(function(i){var o=rs(i,e.fullPath);n(o)},function(i){r(i)})})]})})}var CC=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var r=e.name||"",i=(e.type||"").toLowerCase(),o=i.replace(/\/.*$/,"");return n.some(function(s){var l=s.trim().toLowerCase();return l.charAt(0)==="."?r.toLowerCase().endsWith(l):l.endsWith("/*")?o===l.replace(/\/.*$/,""):i===l})}return!0};function bp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Sp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?bp(Object(n),!0).forEach(function(r){yy(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function yy(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ep(e,t){return NC(e)||PC(e,t)||OC(e,t)||kC()}function kC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
88
+ `)}),r&&h.jsx(fr,{label:r.title,children:r.message})]})},BA=Se(function({context:t,step:n,index:r,count:i,open:o,onToggle:s}){var m;const{command:l,events:a}=n,u=t.preview,c=((m=u==null?void 0:u.activeCommand)==null?void 0:m.id)===l.id,f=(l.errors??[]).length>0,d=oy(l),p=c||f||d>=1e3,y=f&&t.isAgent?rd(l):void 0;return h.jsxs("li",{onMouseEnter:()=>u==null?void 0:u.highlightCommand(l),onMouseLeave:()=>u==null?void 0:u.unhighlightCommand(l),children:[h.jsx(Il,{content:()=>vp(l,r,i),children:h.jsxs("button",{type:"button",puth:"step","data-active":c?"true":void 0,"data-failed":f?"true":void 0,"aria-pressed":c,className:ae("flex h-[34px] w-full items-center gap-2.5 rounded-lg border px-3 text-left",c?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent hover:bg-white/[0.04]"),onClick:()=>u==null?void 0:u.toggleCommand(l),children:[h.jsx("span",{className:ae("w-[18px] flex-none text-right font-mono text-[11px]",c?"text-accent-sky":f?"text-red-300":"text-[#8f8f8f]"),children:String(r+1).padStart(2,"0")}),h.jsx("span",{className:ae("flex-none font-mono text-[13px]",FA[IA(l.func)]),children:l.func}),h.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-ink-body",children:ry(l.args)}),p&&h.jsx("span",{className:ae("flex-none font-mono text-[11px]",f?"text-red-300":d>=1e3?"text-amber-300":"text-ink-muted"),children:dy(d)})]})}),y&&h.jsx(Il,{content:()=>vp(l,r,i),className:"ml-10 border-l border-dashed border-red-400/40 pl-2",children:h.jsxs("div",{className:"flex min-h-[22px] items-center gap-1.5 px-1 text-[12px] text-red-200","data-messagetype":"error",children:[h.jsxs("span",{className:"flex-none text-red-300/80",children:[y.title,"."]}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.message})]})}),h.jsx(fy,{events:a,open:o,onToggle:s,label:`after ${l.func}`})]})}),$A=Se(function({context:t}){const{app:n}=x.useContext(Ee),[r,i]=x.useState(!1);if(!t.group)return null;const o=n.history.filter(l=>l.group===t.group);if(o.length<2)return h.jsx("div",{className:"mt-1 font-mono text-xs text-ink-muted",children:t.group});const s=o.filter(l=>l.test.status==="failed").length;return h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(!r),className:"mt-1 flex min-h-[28px] flex-wrap items-center gap-1.5 text-left font-mono text-xs text-ink-muted",children:[h.jsx("span",{children:t.group}),h.jsxs("span",{className:"text-ink-body",children:["· ",o.length," tests"]}),s>0&&h.jsxs("span",{children:["· ",s," failed"]}),h.jsx(Pt,{name:"expand_more",size:"0.7rem",className:ae("transition-transform",r&&"rotate-180")})]}),r&&h.jsx("ul",{"aria-label":`Tests in ${t.group}`,className:"mt-2 flex flex-col gap-0.5 rounded-lg border border-white/[0.08] bg-shell-main p-1",children:o.map(l=>h.jsx("li",{children:h.jsxs("button",{type:"button","aria-current":l===t,onClick:()=>n.setActive(l),className:ae("flex min-h-[36px] w-full items-center gap-2.5 rounded-md border px-2.5 text-left text-[13px] hover:bg-white/[0.04]",l===t?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent"),children:[h.jsx(ty,{status:l.test.status,size:"0.8rem"}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.test.name}),h.jsx("span",{className:"font-mono text-[11.5px] text-ink-muted",children:ay(l.took)})]})},l.id))})]})});function VA(e,t){x.useEffect(()=>{const n=r=>{const i=r.target;if(r.altKey||r.ctrlKey||r.metaKey||i!=null&&i.closest('input, textarea, select, [contenteditable="true"]'))return;const o=e.preview;if(!o||t.length===0)return;if(r.key==="ArrowLeft"||r.key==="ArrowRight"){o.state=r.key==="ArrowLeft"?ye.BEFORE:ye.AFTER,r.preventDefault();return}if(r.key!=="ArrowUp"&&r.key!=="ArrowDown")return;const s=t.findIndex(a=>{var u;return a.id===((u=o.activeCommand)==null?void 0:u.id)}),l=s===-1?r.key==="ArrowDown"?0:t.length-1:Math.min(t.length-1,Math.max(0,s+(r.key==="ArrowDown"?1:-1)));l!==s&&o.toggleCommand(t[l]),r.preventDefault()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t])}const WA=({tool:e,steps:t})=>{const n=t.some(r=>(r.command.errors??[]).length>0);return h.jsxs("div",{className:"flex items-baseline gap-2 px-3 pb-1 pt-3 font-mono text-[11.5px]",puth:"tool-call",children:[h.jsx("span",{className:n?"text-red-300":"text-accent-sky",children:e.tool}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-ink-muted",title:e.summary,children:e.summary}),t.length>0&&h.jsxs("span",{className:"flex-none text-ink-muted",children:[t.length," ",t.length===1?"step":"steps"]})]})},HA=({draft:e})=>{const[t,n]=x.useState(!1),r=()=>{var i;(i=navigator.clipboard)==null||i.writeText(e.code??"").then(()=>{n(!0),setTimeout(()=>n(!1),1500)}).catch(()=>{})};return h.jsx("div",{className:"mx-1 my-1 rounded-lg border border-white/[0.12] bg-shell-main",puth:"draft",children:h.jsxs(Il,{className:"flex h-[34px] items-center gap-2 pl-3 pr-1.5 font-mono text-[11.5px]",content:()=>h.jsxs(h.Fragment,{children:[h.jsxs(Fl,{children:[h.jsx("span",{className:"text-indigo-300",children:"Draft"}),h.jsxs("span",{className:"text-ink-body",children:[e.format," · ",e.name]}),h.jsx("span",{className:"ml-auto text-amber-300",children:"unverified until the suite passed it"})]}),h.jsx(fr,{children:e.code})]}),children:[h.jsx("span",{className:"flex-none text-indigo-300",children:"Draft"}),h.jsxs("span",{className:"min-w-0 flex-1 truncate text-ink-body",children:[e.format," · ",e.name]}),h.jsx("span",{className:"flex-none rounded bg-amber-500/[0.14] px-1.5 text-[10.5px] text-amber-300",children:"unverified"}),h.jsx("button",{type:"button",onClick:r,className:"min-h-[26px] flex-none rounded-md border border-white/20 px-2 text-ink-body hover:bg-white/[0.08]",children:t?"Copied":"Copy"})]})})},KA={waiting:"Waiting for an agent to take over",claimed:"An agent drives this test",ended:"Handed back to the test"},GA=Se(function({context:t}){var D;const{app:n}=x.useContext(Ee),r=x.useRef(null),[i,o]=x.useState("steps"),[s,l]=x.useState({}),{leading:a,steps:u,sections:c}=ly(t.renderedEvents),f=u.map(k=>k.command),d=t.renderedEvents.filter(un),p=t.renderedEvents.filter(sy);VA(t,f);const y=t.isAgent,m=t.handoff,b=y?-1:u.findIndex(k=>(k.command.errors??[]).length>0),v=b===-1?void 0:u[b],g=v&&rd(v.command),w=v&&[...a,...u.slice(0,b).flatMap(k=>k.events)].reverse().find(k=>un(k)?k.messageType==="error":Lo(k)),[_,S]=y?t.isLive?["Live","text-green-300"]:["Closed","text-ink-muted"]:RA[t.test.status??""]??["Running","text-amber-300"];x.useLayoutEffect(()=>{r.current&&t.followIncoming&&t.renderedEvents.length!==0&&(r.current.scrollTop=r.current.scrollHeight)},[t,t.renderedEvents.length]);const E=()=>jn(()=>{var z,B,K;t.followIncoming=!t.followIncoming;const k=f[f.length-1];t.followIncoming&&k&&((B=(z=t.preview)==null?void 0:z.activeCommand)==null?void 0:B.id)!==k.id&&((K=t.preview)==null||K.toggleCommand(k))}),A=()=>{var k,z,B;o("steps"),v&&((z=(k=t.preview)==null?void 0:k.activeCommand)==null?void 0:z.id)!==v.command.id&&((B=t.preview)==null||B.toggleCommand(v.command))},C=k=>ae("flex min-h-[32px] items-center gap-1.5 rounded-md border px-2.5 text-[13px]",k?"border-white/20 bg-neutral-800 text-ink":"border-transparent text-ink-muted hover:text-ink"),j=k=>ae("flex h-8 items-center gap-1.5 rounded-md border px-2.5 font-mono text-[11.5px]",k?"border-accent-blue/45 bg-blue-600/[0.14] text-accent-sky":"border-shell-control bg-shell-main text-ink-body hover:text-ink"),P=k=>{const z=u.indexOf(k),B=s[k.command.id]??!1;return h.jsxs(x.Fragment,{children:[k.page&&h.jsx(zA,{page:k.page}),h.jsx(BA,{context:t,step:k,index:z,count:u.length,open:B,onToggle:()=>l({...s,[k.command.id]:!B})})]},k.command.id)};return h.jsxs("section",{"aria-label":y?"Agent session":"Test run",className:"flex min-h-0 flex-1 flex-col",children:[h.jsxs("div",{className:"flex items-center gap-2 border-b border-dashed border-neutral-800 py-2 pl-4 pr-3 font-mono text-xs",children:[h.jsxs("span",{className:ae("flex items-center gap-1.5",S),children:[y&&t.isLive&&h.jsx("span",{"aria-hidden":!0,className:"h-[7px] w-[7px] animate-pulse rounded-full bg-green-500"}),_]}),h.jsxs("span",{className:"ml-auto mr-1 text-ink-muted",children:[y&&`${t.toolCalls} ${t.toolCalls===1?"call":"calls"} · `,u.length," ",u.length===1?"step":"steps"," · ",ay(t.took)]}),y&&t.isLive&&h.jsx("button",{type:"button",puth:"follow","aria-pressed":t.followIncoming,onClick:E,className:j(t.followIncoming),children:"Follow"}),y&&h.jsx("button",{type:"button","aria-pressed":n.pinned.includes(t.id),onClick:()=>n.togglePinned(t),className:j(n.pinned.includes(t.id)),title:"Keep this session listed after it closed",children:n.pinned.includes(t.id)?"Pinned":"Pin"}),h.jsx(PA,{name:`snapshot-${t.createdAt}-${t.id}.puth`,resolver:()=>t.blob()})]}),h.jsxs("div",{className:"px-4 pb-3 pt-3.5",children:[h.jsx("div",{className:"break-words text-[17px] font-medium tracking-[-0.01em]",children:t.test.name}),y?h.jsx("div",{className:"mt-1 font-mono text-xs text-ink-muted",children:"Agent session"}):h.jsx($A,{context:t})]}),m&&h.jsxs("div",{className:"mx-3 mb-3 flex items-center gap-2.5 rounded-[10px] border border-indigo-300/25 bg-indigo-500/[0.08] px-3 py-2 text-[12.5px]",puth:"handoff",children:[h.jsx("span",{"aria-hidden":!0,className:ae("h-[7px] w-[7px] flex-none rounded-full",m.state==="claimed"?"animate-pulse bg-indigo-300":"bg-indigo-300/50")}),h.jsxs("span",{className:"min-w-0 flex-1 text-ink-body",children:[KA[m.state],m.name&&h.jsxs("span",{className:"font-mono text-ink-muted",children:[" · ",m.name]})]}),m.state==="ended"&&m.reason&&h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:m.reason})]}),v&&g&&h.jsxs("div",{className:"mx-3 mb-3 overflow-hidden rounded-[10px] border border-white/[0.14] bg-shell-main","data-messagetype":"error",children:[h.jsxs("div",{className:"flex items-center gap-2 border-b border-dashed border-neutral-800 py-2 pl-3 pr-2 font-mono text-[11.5px]",children:[h.jsxs("span",{className:"min-w-0 flex-1 truncate text-red-300",children:["Failed at ",v.command.func," ",(D=v.command.args)!=null&&D.length?ry(v.command.args.slice(0,1)):""]}),h.jsx("button",{type:"button",onClick:A,className:"min-h-[28px] flex-none rounded-md border border-white/20 px-2.5 text-ink-body hover:bg-white/[0.08]",children:"Show step"})]}),h.jsxs("div",{className:"px-3 py-2.5 text-[13px] leading-relaxed text-neutral-200",children:[h.jsxs("span",{className:"text-ink-muted",children:[g.title,"."]})," ",g.message]}),w&&h.jsxs("div",{className:"px-3 pb-2.5 text-[12.5px] leading-normal text-ink-muted",children:[un(w)?"Console error":"Request"," before this step: ",h.jsx("span",{className:"font-mono text-ink-body",children:uy(w)})]})]}),h.jsxs("div",{role:"tablist","aria-label":"Events",className:"flex gap-1 border-b border-dashed border-neutral-800 px-3 pb-2.5",children:[h.jsxs("button",{type:"button",role:"tab",puth:"tab-steps","aria-selected":i==="steps",className:C(i==="steps"),onClick:()=>o("steps"),children:["Steps ",h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:u.length})]}),h.jsxs("button",{type:"button",role:"tab",puth:"tab-console","aria-selected":i==="console",className:C(i==="console"),onClick:()=>o("console"),children:["Console ",h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:d.length})]}),p.length>0&&h.jsxs("button",{type:"button",role:"tab",puth:"tab-network","aria-selected":i==="network",className:C(i==="network"),onClick:()=>o("network"),children:["Network ",h.jsx("span",{className:"font-mono text-[11px] text-ink-muted",children:p.length})]})]}),h.jsx("div",{ref:r,className:"min-h-0 flex-1 overflow-y-auto p-2",children:i==="steps"?h.jsxs(h.Fragment,{children:[h.jsx(fy,{events:a,open:s.leading??!1,onToggle:()=>l({...s,leading:!s.leading}),label:"before the first step"}),c.map((k,z)=>{var B;return h.jsxs("div",{children:[k.tool&&h.jsx(WA,{tool:k.tool,steps:k.steps}),!k.tool&&(k.label||z===0&&c.length>1&&t.handoff)&&h.jsx("div",{className:"px-3 pb-1 pt-3 font-mono text-[11.5px] text-ink-muted",children:k.label??"Before the handoff"}),h.jsx("ol",{className:"flex flex-col",children:k.steps.map(P)}),k.drafts.map(K=>h.jsx(HA,{draft:K},K.id))]},((B=k.tool)==null?void 0:B.id)??z)}),u.length===0&&a.length===0&&c.length===0&&h.jsx("div",{className:"px-3 py-4 text-[13px] text-ink-muted",children:"No steps recorded yet."})]}):h.jsxs("ul",{className:"px-3",children:[(i==="console"?d:p).map(k=>h.jsx(cy,{event:k},k.id)),i==="console"&&d.length===0&&h.jsx("li",{className:"py-4 text-[13px] text-ink-muted",children:"No console output."})]})}),h.jsx("div",{className:"border-t border-shell-line px-4 py-2 font-mono text-[11.5px] text-ink-muted",children:"↑ ↓ step · ← → before / after"})]})}),QA=Se(function(){const{app:t}=x.useContext(Ee);return t.activeContext?h.jsx(GA,{context:t.activeContext},t.activeContext.id):h.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center text-sm text-ink-muted",children:[h.jsx(Pt,{name:"explore",size:"2rem"}),t.view==="agents"?"Select an agent session below.":"Select a test in the history list below."]})});function YA(e){let t=new Date(e),n=""+(t.getMonth()+1),r=""+t.getDate(),i=t.getFullYear();return n.length<2&&(n="0"+n),r.length<2&&(r="0"+r),[i,n,r].join("-")}function XA(e){const t=n=>(n<10?"0":"")+n;return`${t(e.minutes)}:${t(e.seconds)}s`}const ZA=Se(function({context:t}){var i,o;const{app:n}=x.useContext(Ee),r=n.activeContext===t;return h.jsx("li",{children:h.jsxs("button",{type:"button",puth:"history-item","aria-current":r,className:ae("flex w-full items-start gap-2.5 rounded-lg border px-2.5 py-2 text-left hover:bg-white/[0.04]",r?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent"),onClick:()=>n.setActive(t),children:[h.jsx(ty,{status:t.test.status,size:"0.95rem",className:"mt-0.5 flex-none"}),h.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-[3px]",children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"truncate text-sm text-ink",children:t.test.name}),(((i=t.handoff)==null?void 0:i.state)==="waiting"||((o=t.handoff)==null?void 0:o.state)==="claimed")&&h.jsx("span",{className:"flex-none rounded bg-indigo-500/[0.16] px-1.5 font-mono text-[10.5px] text-indigo-200",children:t.handoff.state==="claimed"?"agent":"handoff"})]}),t.group&&h.jsx("span",{className:"truncate font-mono text-[11.5px] text-ink-muted",children:t.group})]}),h.jsxs("span",{className:"flex flex-none flex-col items-end gap-[3px] font-mono text-[11.5px] text-ink-muted",children:[h.jsx("span",{children:XA(t.took)}),h.jsx("span",{children:YA(t.lastActivity)})]})]})})}),JA=[["","All"],[fo.FAILED,"Failed"],[fo.SUCCESSFUL,"Passed"],[fo.PENDING,"Running"]],qA=Se(function(){const{app:t}=x.useContext(Ee),[n,r]=x.useState(!0),[i,o]=x.useState(""),[s,l]=x.useState("");if(t.empty)return h.jsx(h.Fragment,{});let a=t.history;if(i!==""){let u=i.toLowerCase();a=a.filter(c=>c.test.name.toLowerCase().includes(u)||(c.group??"").toLowerCase().includes(u))}return s!==""&&(a=a.filter(u=>(u.test.status??fo.PENDING)===s)),h.jsxs("section",{"aria-label":"History",className:ae("flex flex-col border-t border-shell-line",n&&"max-h-[40vh]"),children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(!n),className:"flex min-h-[44px] flex-none items-center gap-2.5 border-b border-dashed border-neutral-800 px-4 font-mono text-xs",children:[h.jsx("span",{className:"text-accent-sky",children:"History"}),h.jsx("span",{className:"text-ink-muted",children:t.history.length}),h.jsx(Pt,{name:"expand_more",className:ae("ml-auto text-ink-muted transition-transform",n&&"rotate-180")})]}),n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-none flex-wrap gap-2 px-3 pb-1 pt-2.5",children:[h.jsxs("label",{className:"flex h-[34px] min-w-[160px] flex-1 items-center gap-2 rounded-lg border border-shell-control bg-shell-main px-2.5 text-ink-muted",children:[h.jsxs("svg",{"aria-hidden":!0,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"m20 20-3.5-3.5"})]}),h.jsx("input",{type:"search","aria-label":"Filter history",placeholder:"Filter tests",value:i,onChange:u=>o(u.target.value),className:"min-w-0 flex-1 border-0 bg-transparent text-[13px] text-ink outline-none"})]}),h.jsx("div",{role:"group","aria-label":"Status",className:"flex h-[34px] rounded-lg border border-shell-control bg-shell-main p-0.5",children:JA.map(([u,c])=>h.jsx("button",{type:"button","aria-pressed":s===u,onClick:()=>l(u),className:ae("rounded-md px-2.5 font-mono text-[11.5px]",s===u?"bg-neutral-800 text-ink":"text-ink-muted hover:text-ink"),children:c},c))})]}),h.jsxs("ul",{className:"flex min-h-0 flex-col gap-0.5 overflow-y-auto px-2 pb-2.5 pt-1.5",children:[a.length===0&&h.jsx("li",{className:"px-2.5 py-3.5 text-[13px] text-ink-muted",children:t.history.length===0?"No tests have run on this instance yet.":"No tests match this filter."}),a.map(u=>h.jsx(ZA,{context:u},u.id))]})]})]})}),eC=10*60*1e3;function tC(e){const t=n=>(n<10?"0":"")+n;return`${t(e.minutes)}:${t(e.seconds)}s`}function nC(e,t){const n=Math.round((t-e)/6e4);return n<1?"just now":n<60?`${n} min ago`:`${Math.round(n/60)} h ago`}const gp=Se(function({context:t,now:n}){const{app:r}=x.useContext(Ee),i=r.activeContext===t,o=r.pinned.includes(t.id),s=!t.isAgent;return h.jsx("li",{children:h.jsxs("button",{type:"button",puth:"agent-item","aria-current":i,onClick:()=>r.setActive(t),className:ae("flex w-full items-start gap-2.5 rounded-lg border px-2.5 py-2 text-left hover:bg-white/[0.04]",i?"border-accent-blue/45 bg-blue-600/[0.12]":"border-transparent"),children:[h.jsx("span",{"aria-hidden":!0,className:ae("mt-[7px] h-[7px] w-[7px] flex-none rounded-full",t.isLive?"animate-pulse bg-green-500":"border border-ink-muted")}),h.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-[3px]",children:[h.jsx("span",{className:"truncate text-sm text-ink",children:t.test.name}),h.jsxs("span",{className:"truncate font-mono text-[11.5px] text-ink-muted",children:[s?`handoff · ${t.group}`:`${t.toolCalls} ${t.toolCalls===1?"call":"calls"}`,o&&" · pinned"]})]}),h.jsxs("span",{className:"flex flex-none flex-col items-end gap-[3px] font-mono text-[11.5px] text-ink-muted",children:[h.jsx("span",{className:t.isLive?"text-green-300":void 0,children:t.isLive?"live":tC(t.took)}),!t.isLive&&h.jsx("span",{children:nC(t.lastActivity,n)})]})]})})}),rC=Se(function(){const{app:t}=x.useContext(Ee),[n,r]=x.useState(!1),[i,o]=x.useState(Date.now());x.useEffect(()=>{const d=setInterval(()=>o(Date.now()),3e4);return()=>clearInterval(d)},[]);const s=t.agents,l=d=>d.isLive||t.pinned.includes(d.id)||t.activeContext===d||i-d.lastActivity<eC,a=n?s:s.filter(l),u=s.length-s.filter(l).length,c=a.filter(d=>d.isLive),f=a.filter(d=>!d.isLive);return h.jsxs("section",{"aria-label":"Agent sessions",className:"flex max-h-[45vh] flex-col border-t border-shell-line",children:[h.jsxs("div",{className:"flex min-h-[44px] flex-none items-center gap-2.5 border-b border-dashed border-neutral-800 px-4 font-mono text-xs",children:[h.jsx("span",{className:"text-accent-sky",children:"Agent sessions"}),h.jsx("span",{className:"text-ink-muted",children:s.length}),t.liveAgents>0&&h.jsxs("span",{className:"ml-auto text-green-300",children:[t.liveAgents," live"]})]}),h.jsxs("ul",{className:"flex min-h-0 flex-col gap-0.5 overflow-y-auto px-2 pb-2.5 pt-1.5",children:[s.length===0&&h.jsxs("li",{className:"px-2.5 py-3.5 text-[13px] leading-relaxed text-ink-muted",children:["No agent sessions yet. Agents connected through the Puth MCP server show up here while they work."," ",h.jsx("a",{href:"https://puth.io/guide/mcp",target:"_blank",rel:"noreferrer",className:"text-accent-sky hover:text-blue-200",children:"Set up the MCP server"})]}),c.map(d=>h.jsx(gp,{context:d,now:i},d.id)),f.length>0&&c.length>0&&h.jsx("li",{"aria-hidden":!0,className:"mx-2.5 my-1 border-t border-dashed border-neutral-800"}),f.map(d=>h.jsx(gp,{context:d,now:i},d.id)),u>0&&h.jsx("li",{children:h.jsx("button",{type:"button",onClick:()=>r(!n),className:"w-full rounded-md px-2.5 py-2 text-left font-mono text-[11.5px] text-ink-muted hover:text-ink",children:n?"Hide older sessions":`Show ${u} older ${u===1?"session":"sessions"}`})})]})]})}),mp=e=>ae("min-w-[64px] rounded-md px-3 font-mono text-xs",e?"bg-blue-600 text-white":"text-ink-muted hover:text-ink"),iC=Se(function(){var s;const{app:t}=x.useContext(Ee),n=t.previewStore,r=(n==null?void 0:n.visibleHighlightState)??(n==null?void 0:n.state),i=(s=n==null?void 0:n.visibleScreencast)==null?void 0:s.page,o=l=>{n&&(n.state=l)};return h.jsxs("div",{className:"flex flex-none flex-wrap items-center gap-2.5 border-b border-shell-line bg-shell-bar px-3 py-2.5",children:[h.jsxs("div",{role:"group","aria-label":"Snapshot",className:"flex h-8 rounded-lg border border-shell-control bg-shell-main p-0.5",children:[h.jsx("button",{type:"button","aria-pressed":r===ye.BEFORE,className:mp(r===ye.BEFORE),onClick:()=>o(ye.BEFORE),children:"Before"}),h.jsx("button",{type:"button","aria-pressed":r===ye.AFTER,className:mp(r===ye.AFTER),onClick:()=>o(ye.AFTER),children:"After"})]}),h.jsxs("div",{className:"flex h-8 min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-white/[0.12] bg-shell-main px-3 font-mono text-xs text-ink-body",children:[h.jsxs("svg",{"aria-hidden":!0,width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#a3a3a3",strokeWidth:"2",children:[h.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),h.jsx("path",{d:"M8 11V8a4 4 0 0 1 8 0v3"})]}),h.jsx("span",{className:"truncate","aria-label":"Page URL",children:(i==null?void 0:i.url)??""})]}),(i==null?void 0:i.viewport)&&h.jsxs("span",{className:"font-mono text-xs text-ink-muted",children:[i.viewport.width," × ",i.viewport.height]})]})}),oC=Se(function(){var l,a;const{app:t}=x.useContext(Ee),n=t.previewStore,r=n==null?void 0:n.visibleCommand,i=ly(((l=t.activeContext)==null?void 0:l.renderedEvents)??[]).steps.map(u=>u.command),o=r?i.findIndex(u=>u.id===r.id):-1,s=u=>(u<10?"0":"")+u;return h.jsxs("div",{className:"flex flex-none flex-wrap justify-between gap-x-6 gap-y-2 border-t border-shell-line bg-shell-bar px-4 py-3 font-mono text-xs text-ink-muted",children:[r&&o!==-1?h.jsxs("span",{children:["Step ",h.jsx("span",{className:"text-ink",children:s(o+1)})," / ",s(i.length)," · ",h.jsxs("span",{className:"text-accent-sky",children:[ny((a=r.on)==null?void 0:a.type),".",r.func]})," · ",n==null?void 0:n.visibleHighlightState]}):h.jsx("span",{children:"Latest frame"}),h.jsx("span",{children:n!=null&&n.isVisibleHighlight?"Previewing · click to pin":"Hover a step to preview it"})]})}),sC=Se(function(){var n,r,i;const{app:t}=x.useContext(Ee);return(n=t.previewStore)!=null&&n.activeScreencastUrl?h.jsxs("div",{className:"relative w-full overflow-hidden rounded-lg border border-white/[0.18] shadow-[0_24px_60px_rgba(0,0,0,0.5)]",style:{maxWidth:`${(r=t.previewStore)==null?void 0:r.visibleScreencast.page.viewport.width}px`},children:[h.jsx("img",{src:(i=t.previewStore)==null?void 0:i.activeScreencastUrl,alt:"Page at the selected step",className:"block w-full"}),t.settings.preview.darken&&h.jsx("div",{className:"pointer-events-none absolute inset-0 bg-black/50"})]}):h.jsx("div",{className:"mt-16 font-mono text-xs text-ink-muted",children:"No frame recorded for this step."})}),yp="https://puth.io/guide",pu=({label:e,labelClass:t,children:n,link:r})=>h.jsxs("section",{className:"overflow-hidden rounded-xl border border-white/[0.12] bg-gradient-to-b from-[#191919] to-[#141414] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[h.jsx("div",{className:"border-b border-dashed border-neutral-800 px-5 py-3 font-mono text-xs",children:h.jsx("span",{className:t,children:e})}),h.jsx("div",{className:"p-5",children:n}),r&&h.jsx("div",{className:"flex justify-end border-t border-dashed border-neutral-800 px-5 py-3 font-mono text-[12.5px]",children:h.jsxs("a",{href:r[1],target:"_blank",rel:"noreferrer",className:"text-accent-sky hover:text-blue-200",children:[r[0]," →"]})})]}),wp=()=>h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:h.jsxs("div",{className:"mx-auto flex max-w-[1200px] flex-col gap-4 px-4 pb-8 pt-4",children:[h.jsxs("section",{className:"shell-hero relative flex min-h-[300px] flex-col justify-end overflow-hidden rounded-xl px-10 pb-9 pt-12",children:[h.jsx("div",{"aria-hidden":!0,className:"shell-hero-dots absolute inset-0"}),h.jsx("div",{"aria-hidden":!0,className:"shell-hero-grain absolute inset-0"}),h.jsx("div",{"aria-hidden":!0,className:"shell-hero-scrim absolute inset-0"}),h.jsxs("div",{className:"relative max-w-[620px]",children:[h.jsx("div",{className:"font-mono text-xs text-blue-100",children:"No instance connected"}),h.jsx("h1",{className:"mt-3 text-4xl font-medium leading-tight tracking-[-0.02em] text-white",children:"Connect to a server, or drop in a snapshot."}),h.jsxs("p",{className:"mt-3.5 text-[15px] leading-relaxed text-blue-50",children:["Tests show up here as they run. A ",h.jsx("code",{className:"rounded bg-white/15 px-1.5 py-px font-mono text-[13px] text-white",children:".puth"})," file from CI works without any connection."]})]})]}),h.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(300px,1fr))] gap-4",children:[h.jsx(pu,{label:"Connect",labelClass:"text-accent-blue",children:h.jsx(q0,{})}),h.jsxs("div",{className:"flex flex-col gap-4",children:[h.jsxs(pu,{label:"Start a server",labelClass:"text-accent-blue",link:["Getting started",`${yp}/getting-started`],children:[h.jsx("p",{className:"text-sm leading-relaxed text-ink-muted",children:"One container serves the browser API and this GUI."}),h.jsx("code",{className:"mt-3.5 block overflow-x-auto whitespace-nowrap rounded-lg border border-white/10 bg-shell-main px-3.5 py-3 font-mono text-[12.5px] text-ink-body",children:"docker run -it --rm -p 127.0.0.1:7345:7345 ghcr.io/puth-io/puth"})]}),h.jsx(pu,{label:"Replay from CI",labelClass:"text-indigo-300",link:["Snapshots in CI",`${yp}/ci-cd`],children:h.jsxs("p",{className:"text-sm leading-relaxed text-ink-muted",children:["Drag a ",h.jsx("code",{className:"rounded bg-white/[0.12] px-1.5 py-px font-mono text-[12.5px] text-ink",children:".puth"})," snapshot anywhere into this window to step through a recorded test."]})})]})]})]})}),lC=Se(function(){const{app:t}=x.useContext(Ee),n=t.view!=="local"&&t.history.length===0;return h.jsx("div",{className:"shell-dots flex flex-1 items-center justify-center p-8 text-center font-mono text-xs text-ink-muted",children:t.view==="agents"?n?"No agent sessions yet.":"Select an agent session to watch it.":n?"Connected. Tests show up here as they run.":"Select a test in the history to inspect it."})}),aC=Se(function(){const{app:t}=x.useContext(Ee),n=t.view!=="local"&&!t.isConnected;return h.jsxs("div",{className:"flex h-screen w-screen bg-shell-main text-ink",children:[h.jsx(CA,{}),t.empty?h.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:h.jsx(wp,{})}):h.jsxs("div",{className:"flex min-w-0 flex-1",children:[h.jsxs("aside",{"aria-label":"Test",className:"flex w-[440px] min-w-[320px] flex-shrink flex-col border-r border-shell-line bg-shell-side",children:[h.jsx(QA,{}),t.view==="agents"?h.jsx(rC,{}):h.jsx(qA,{})]}),h.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:t.previewStore?h.jsxs(h.Fragment,{children:[h.jsx(iC,{}),h.jsx("div",{className:"shell-dots flex min-h-0 flex-1 items-start justify-center overflow-auto p-4",children:h.jsx(sC,{})}),h.jsx(oC,{})]}):n?h.jsx(wp,{}):h.jsx(lC,{})})]})]})});var hy={exports:{}},uC="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",cC=uC,fC=cC;function py(){}function vy(){}vy.resetWarningCache=py;var dC=function(){function e(r,i,o,s,l,a){if(a!==fC){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:vy,resetWarningCache:py};return n.PropTypes=n,n};hy.exports=dC();var hC=hy.exports;const ee=Fc(hC);var pC=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function rs(e,t){var n=vC(e);if(typeof n.path!="string"){var r=e.webkitRelativePath;Object.defineProperty(n,"path",{value:typeof t=="string"?t:typeof r=="string"&&r.length>0?r:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function vC(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var r=t.split(".").pop().toLowerCase(),i=pC.get(r);i&&Object.defineProperty(e,"type",{value:i,writable:!1,configurable:!1,enumerable:!0})}return e}var gC=[".DS_Store","Thumbs.db"];function mC(e){return Pi(this,void 0,void 0,function(){return Ni(this,function(t){return zl(e)&&yC(e)?[2,bC(e.dataTransfer,e.type)]:wC(e)?[2,xC(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,_C(e)]:[2,[]]})})}function yC(e){return zl(e.dataTransfer)}function wC(e){return zl(e)&&zl(e.target)}function zl(e){return typeof e=="object"&&e!==null}function xC(e){return Tc(e.target.files).map(function(t){return rs(t)})}function _C(e){return Pi(this,void 0,void 0,function(){var t;return Ni(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(r){return r.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(r){return rs(r)})]}})})}function bC(e,t){return Pi(this,void 0,void 0,function(){var n,r;return Ni(this,function(i){switch(i.label){case 0:return e===null?[2,[]]:e.items?(n=Tc(e.items).filter(function(o){return o.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(SC))]):[3,2];case 1:return r=i.sent(),[2,xp(gy(r))];case 2:return[2,xp(Tc(e.files).map(function(o){return rs(o)}))]}})})}function xp(e){return e.filter(function(t){return gC.indexOf(t.name)===-1})}function Tc(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r)}return t}function SC(e){if(typeof e.webkitGetAsEntry!="function")return _p(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?my(t):_p(e)}function gy(e){return e.reduce(function(t,n){return xE(t,Array.isArray(n)?gy(n):[n])},[])}function _p(e){var t=e.getAsFile();if(!t)return Promise.reject(e+" is not a File");var n=rs(t);return Promise.resolve(n)}function EC(e){return Pi(this,void 0,void 0,function(){return Ni(this,function(t){return[2,e.isDirectory?my(e):AC(e)]})})}function my(e){var t=e.createReader();return new Promise(function(n,r){var i=[];function o(){var s=this;t.readEntries(function(l){return Pi(s,void 0,void 0,function(){var a,u,c;return Ni(this,function(f){switch(f.label){case 0:if(l.length)return[3,5];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Promise.all(i)];case 2:return a=f.sent(),n(a),[3,4];case 3:return u=f.sent(),r(u),[3,4];case 4:return[3,6];case 5:c=Promise.all(l.map(EC)),i.push(c),o(),f.label=6;case 6:return[2]}})})},function(l){r(l)})}o()})}function AC(e){return Pi(this,void 0,void 0,function(){return Ni(this,function(t){return[2,new Promise(function(n,r){e.file(function(i){var o=rs(i,e.fullPath);n(o)},function(i){r(i)})})]})})}var CC=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var r=e.name||"",i=(e.type||"").toLowerCase(),o=i.replace(/\/.*$/,"");return n.some(function(s){var l=s.trim().toLowerCase();return l.charAt(0)==="."?r.toLowerCase().endsWith(l):l.endsWith("/*")?o===l.replace(/\/.*$/,""):i===l})}return!0};function bp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Sp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?bp(Object(n),!0).forEach(function(r){yy(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function yy(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ep(e,t){return NC(e)||PC(e,t)||OC(e,t)||kC()}function kC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
89
89
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OC(e,t){if(e){if(typeof e=="string")return Ap(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ap(e,t)}}function Ap(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function PC(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,s,l;try{for(n=n.call(e);!(i=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));i=!0);}catch(a){o=!0,l=a}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw l}}return r}}function NC(e){if(Array.isArray(e))return e}var jC="file-invalid-type",TC="file-too-large",RC="file-too-small",DC="too-many-files",MC=function(t){t=Array.isArray(t)&&t.length===1?t[0]:t;var n=Array.isArray(t)?"one of ".concat(t.join(", ")):t;return{code:jC,message:"File type must be ".concat(n)}},Cp=function(t){return{code:TC,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},kp=function(t){return{code:RC,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},LC={code:DC,message:"Too many files"};function wy(e,t){var n=e.type==="application/x-moz-file"||CC(e,t);return[n,n?null:MC(t)]}function xy(e,t,n){if(Gi(e.size))if(Gi(t)&&Gi(n)){if(e.size>n)return[!1,Cp(n)];if(e.size<t)return[!1,kp(t)]}else{if(Gi(t)&&e.size<t)return[!1,kp(t)];if(Gi(n)&&e.size>n)return[!1,Cp(n)]}return[!0,null]}function Gi(e){return e!=null}function IC(e){var t=e.files,n=e.accept,r=e.minSize,i=e.maxSize,o=e.multiple,s=e.maxFiles;return!o&&t.length>1||o&&s>=1&&t.length>s?!1:t.every(function(l){var a=wy(l,n),u=Ep(a,1),c=u[0],f=xy(l,r,i),d=Ep(f,1),p=d[0];return c&&p})}function Ul(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Ts(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Op(e){e.preventDefault()}function FC(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function zC(e){return e.indexOf("Edge/")!==-1}function UC(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return FC(e)||zC(e)}function Rt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){for(var i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];return t.some(function(l){return!Ul(r)&&l&&l.apply(void 0,[r].concat(o)),Ul(r)})}}function Pp(){return"showOpenFilePicker"in window}function BC(e){return e=typeof e=="string"?e.split(","):e,[{description:"everything",accept:Array.isArray(e)?e.filter(function(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||/\w+\/[-+.\w]+/g.test(t)}).reduce(function(t,n){return Sp(Sp({},t),{},yy({},n,[]))},{}):{}}]}var $C=["children"],VC=["open"],WC=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],HC=["refKey","onChange","onClick"];function KC(e){return YC(e)||QC(e)||_y(e)||GC()}function GC(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
90
90
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QC(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function YC(e){if(Array.isArray(e))return Rc(e)}function vu(e,t){return JC(e)||ZC(e,t)||_y(e,t)||XC()}function XC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
91
91
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _y(e,t){if(e){if(typeof e=="string")return Rc(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Rc(e,t)}}function Rc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ZC(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,s,l;try{for(n=n.call(e);!(i=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));i=!0);}catch(a){o=!0,l=a}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw l}}return r}}function JC(e){if(Array.isArray(e))return e}function Np(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function fe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Np(Object(n),!0).forEach(function(r){Dc(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Np(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Dc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bl(e,t){if(e==null)return{};var n=qC(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function qC(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var id=x.forwardRef(function(e,t){var n=e.children,r=Bl(e,$C),i=Sy(r),o=i.open,s=Bl(i,VC);return x.useImperativeHandle(t,function(){return{open:o}},[o]),Cn.createElement(x.Fragment,null,n(fe(fe({},s),{},{open:o})))});id.displayName="Dropzone";var by={disabled:!1,getFilesFromEvent:mC,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1};id.defaultProps=by;id.propTypes={children:ee.func,accept:ee.oneOfType([ee.string,ee.arrayOf(ee.string)]),multiple:ee.bool,preventDropOnDocument:ee.bool,noClick:ee.bool,noKeyboard:ee.bool,noDrag:ee.bool,noDragEventsBubbling:ee.bool,minSize:ee.number,maxSize:ee.number,maxFiles:ee.number,disabled:ee.bool,getFilesFromEvent:ee.func,onFileDialogCancel:ee.func,onFileDialogOpen:ee.func,useFsAccessApi:ee.bool,onDragEnter:ee.func,onDragLeave:ee.func,onDragOver:ee.func,onDrop:ee.func,onDropAccepted:ee.func,onDropRejected:ee.func,validator:ee.func};var Mc={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,draggedFiles:[],acceptedFiles:[],fileRejections:[]};function Sy(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=fe(fe({},by),e),n=t.accept,r=t.disabled,i=t.getFilesFromEvent,o=t.maxSize,s=t.minSize,l=t.multiple,a=t.maxFiles,u=t.onDragEnter,c=t.onDragLeave,f=t.onDragOver,d=t.onDrop,p=t.onDropAccepted,y=t.onDropRejected,m=t.onFileDialogCancel,b=t.onFileDialogOpen,v=t.useFsAccessApi,g=t.preventDropOnDocument,w=t.noClick,_=t.noKeyboard,S=t.noDrag,E=t.noDragEventsBubbling,A=t.validator,C=x.useMemo(function(){return typeof b=="function"?b:jp},[b]),j=x.useMemo(function(){return typeof m=="function"?m:jp},[m]),P=x.useRef(null),D=x.useRef(null),k=x.useReducer(ek,Mc),z=vu(k,2),B=z[0],K=z[1],Z=B.isFocused,J=B.isFileDialogActive,O=B.draggedFiles,R=function(){J&&setTimeout(function(){if(D.current){var W=D.current.files;W.length||(K({type:"closeDialog"}),j())}},300)};x.useEffect(function(){return v&&Pp()?function(){}:(window.addEventListener("focus",R,!1),function(){window.removeEventListener("focus",R,!1)})},[D,J,j,v]);var F=x.useRef([]),H=function(W){P.current&&P.current.contains(W.target)||(W.preventDefault(),F.current=[])};x.useEffect(function(){return g&&(document.addEventListener("dragover",Op,!1),document.addEventListener("drop",H,!1)),function(){g&&(document.removeEventListener("dragover",Op),document.removeEventListener("drop",H))}},[P,g]);var ce=x.useCallback(function(L){L.preventDefault(),L.persist(),Nr(L),F.current=[].concat(KC(F.current),[L.target]),Ts(L)&&Promise.resolve(i(L)).then(function(W){Ul(L)&&!E||(K({draggedFiles:W,isDragActive:!0,type:"setDraggedFiles"}),u&&u(L))})},[i,u,E]),Yt=x.useCallback(function(L){L.preventDefault(),L.persist(),Nr(L);var W=Ts(L);if(W&&L.dataTransfer)try{L.dataTransfer.dropEffect="copy"}catch{}return W&&f&&f(L),!1},[f,E]),rt=x.useCallback(function(L){L.preventDefault(),L.persist(),Nr(L);var W=F.current.filter(function(Ue){return P.current&&P.current.contains(Ue)}),Ce=W.indexOf(L.target);Ce!==-1&&W.splice(Ce,1),F.current=W,!(W.length>0)&&(K({isDragActive:!1,type:"setDraggedFiles",draggedFiles:[]}),Ts(L)&&c&&c(L))},[P,c,E]),jt=x.useCallback(function(L,W){var Ce=[],Ue=[];L.forEach(function(pt){var Li=wy(pt,n),jr=vu(Li,2),xa=jr[0],_a=jr[1],ba=xy(pt,s,o),is=vu(ba,2),Sa=is[0],Ea=is[1],Aa=A?A(pt):null;if(xa&&Sa&&!Aa)Ce.push(pt);else{var Ca=[_a,Ea];Aa&&(Ca=Ca.concat(Aa)),Ue.push({file:pt,errors:Ca.filter(function(Ny){return Ny})})}}),(!l&&Ce.length>1||l&&a>=1&&Ce.length>a)&&(Ce.forEach(function(pt){Ue.push({file:pt,errors:[LC]})}),Ce.splice(0)),K({acceptedFiles:Ce,fileRejections:Ue,type:"setFiles"}),d&&d(Ce,Ue,W),Ue.length>0&&y&&y(Ue,W),Ce.length>0&&p&&p(Ce,W)},[K,l,n,s,o,a,d,p,y,A]),Fe=x.useCallback(function(L){L.preventDefault(),L.persist(),Nr(L),F.current=[],Ts(L)&&Promise.resolve(i(L)).then(function(W){Ul(L)&&!E||jt(W,L)}),K({type:"reset"})},[i,jt,E]),ze=x.useCallback(function(){if(v&&Pp()){K({type:"openDialog"}),C();var L={multiple:l,types:BC(n)};window.showOpenFilePicker(L).then(function(W){return i(W)}).then(function(W){return jt(W,null)}).catch(function(W){return j(W)}).finally(function(){return K({type:"closeDialog"})});return}D.current&&(K({type:"openDialog"}),C(),D.current.value=null,D.current.click())},[K,C,j,v,jt,n,l]),Ti=x.useCallback(function(L){!P.current||!P.current.isEqualNode(L.target)||(L.keyCode===32||L.keyCode===13)&&(L.preventDefault(),ze())},[P,D,ze]),Ri=x.useCallback(function(){K({type:"focus"})},[]),Di=x.useCallback(function(){K({type:"blur"})},[]),Mi=x.useCallback(function(){w||(UC()?setTimeout(ze,0):ze())},[D,w,ze]),Xt=function(W){return r?null:W},Zt=function(W){return _?null:Xt(W)},rr=function(W){return S?null:Xt(W)},Nr=function(W){E&&W.stopPropagation()},ma=x.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},W=L.refKey,Ce=W===void 0?"ref":W,Ue=L.role,pt=L.onKeyDown,Li=L.onFocus,jr=L.onBlur,xa=L.onClick,_a=L.onDragEnter,ba=L.onDragOver,is=L.onDragLeave,Sa=L.onDrop,Ea=Bl(L,WC);return fe(fe(Dc({onKeyDown:Zt(Rt(pt,Ti)),onFocus:Zt(Rt(Li,Ri)),onBlur:Zt(Rt(jr,Di)),onClick:Xt(Rt(xa,Mi)),onDragEnter:rr(Rt(_a,ce)),onDragOver:rr(Rt(ba,Yt)),onDragLeave:rr(Rt(is,rt)),onDrop:rr(Rt(Sa,Fe)),role:typeof Ue=="string"&&Ue!==""?Ue:"button"},Ce,P),!r&&!_?{tabIndex:0}:{}),Ea)}},[P,Ti,Ri,Di,Mi,ce,Yt,rt,Fe,_,S,r]),ya=x.useCallback(function(L){L.stopPropagation()},[]),wa=x.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},W=L.refKey,Ce=W===void 0?"ref":W,Ue=L.onChange,pt=L.onClick,Li=Bl(L,HC),jr=Dc({accept:n,multiple:l,type:"file",style:{display:"none"},onChange:Xt(Rt(Ue,Fe)),onClick:Xt(Rt(pt,ya)),autoComplete:"off",tabIndex:-1},Ce,D);return fe(fe({},jr),Li)}},[D,n,l,Fe,r]),ir=O.length,ad=ir>0&&IC({files:O,accept:n,minSize:s,maxSize:o,multiple:l,maxFiles:a}),Py=ir>0&&!ad;return fe(fe({},B),{},{isDragAccept:ad,isDragReject:Py,isFocused:Z&&!r,getRootProps:ma,getInputProps:wa,rootRef:P,inputRef:D,open:Xt(ze)})}function ek(e,t){switch(t.type){case"focus":return fe(fe({},e),{},{isFocused:!0});case"blur":return fe(fe({},e),{},{isFocused:!1});case"openDialog":return fe(fe({},Mc),{},{isFileDialogActive:!0});case"closeDialog":return fe(fe({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":var n=t.isDragActive,r=t.draggedFiles;return fe(fe({},e),{},{draggedFiles:r,isDragActive:n});case"setFiles":return fe(fe({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case"reset":return fe({},Mc);default:return e}}function jp(){}const Io=U({active:0});var lr=4294967295;function tk(e,t,n){var r=n/4294967296,i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function Ey(e,t,n){var r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function Ay(e,t){var n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function nk(e,t){var n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var od={},gu,mu,yu,ga=(typeof process>"u"||((gu=process==null?void 0:od)===null||gu===void 0?void 0:gu.TEXT_ENCODING)!=="never")&&typeof TextEncoder<"u"&&typeof TextDecoder<"u";function Tp(e){for(var t=e.length,n=0,r=0;r<t;){var i=e.charCodeAt(r++);if(i&4294967168)if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&r<t){var o=e.charCodeAt(r);(o&64512)===56320&&(++r,i=((i&1023)<<10)+(o&1023)+65536)}i&4294901760?n+=4:n+=3}else{n++;continue}}return n}function rk(e,t,n){for(var r=e.length,i=n,o=0;o<r;){var s=e.charCodeAt(o++);if(s&4294967168)if(!(s&4294965248))t[i++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<r){var l=e.charCodeAt(o);(l&64512)===56320&&(++o,s=((s&1023)<<10)+(l&1023)+65536)}s&4294901760?(t[i++]=s>>18&7|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128):(t[i++]=s>>12&15|224,t[i++]=s>>6&63|128)}else{t[i++]=s;continue}t[i++]=s&63|128}}var po=ga?new TextEncoder:void 0,ik=ga?typeof process<"u"&&((mu=process==null?void 0:od)===null||mu===void 0?void 0:mu.TEXT_ENCODING)!=="force"?200:0:lr;function ok(e,t,n){t.set(po.encode(e),n)}function sk(e,t,n){po.encodeInto(e,t.subarray(n))}var lk=po!=null&&po.encodeInto?sk:ok,ak=4096;function Cy(e,t,n){for(var r=t,i=r+n,o=[],s="";r<i;){var l=e[r++];if(!(l&128))o.push(l);else if((l&224)===192){var a=e[r++]&63;o.push((l&31)<<6|a)}else if((l&240)===224){var a=e[r++]&63,u=e[r++]&63;o.push((l&31)<<12|a<<6|u)}else if((l&248)===240){var a=e[r++]&63,u=e[r++]&63,c=e[r++]&63,f=(l&7)<<18|a<<12|u<<6|c;f>65535&&(f-=65536,o.push(f>>>10&1023|55296),f=56320|f&1023),o.push(f)}else o.push(l);o.length>=ak&&(s+=String.fromCharCode.apply(String,o),o.length=0)}return o.length>0&&(s+=String.fromCharCode.apply(String,o)),s}var uk=ga?new TextDecoder:null,ck=ga?typeof process<"u"&&((yu=process==null?void 0:od)===null||yu===void 0?void 0:yu.TEXT_DECODER)!=="force"?200:0:lr;function fk(e,t,n){var r=e.subarray(t,t+n);return uk.decode(r)}var Rs=function(){function e(t,n){this.type=t,this.data=n}return e}(),dk=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Dt=function(e){dk(t,e);function t(n){var r=e.call(this,n)||this,i=Object.create(t.prototype);return Object.setPrototypeOf(r,i),Object.defineProperty(r,"name",{configurable:!0,enumerable:!1,value:t.name}),r}return t}(Error),hk=-1,pk=4294967296-1,vk=17179869184-1;function gk(e){var t=e.sec,n=e.nsec;if(t>=0&&n>=0&&t<=vk)if(n===0&&t<=pk){var r=new Uint8Array(4),i=new DataView(r.buffer);return i.setUint32(0,t),r}else{var o=t/4294967296,s=t&4294967295,r=new Uint8Array(8),i=new DataView(r.buffer);return i.setUint32(0,n<<2|o&3),i.setUint32(4,s),r}else{var r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,n),Ey(i,4,t),r}}function mk(e){var t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function yk(e){if(e instanceof Date){var t=mk(e);return gk(t)}else return null}function wk(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:{var n=t.getUint32(0),r=0;return{sec:n,nsec:r}}case 8:{var i=t.getUint32(0),o=t.getUint32(4),n=(i&3)*4294967296+o,r=i>>>2;return{sec:n,nsec:r}}case 12:{var n=Ay(t,4),r=t.getUint32(0);return{sec:n,nsec:r}}default:throw new Dt("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}function xk(e){var t=wk(e);return new Date(t.sec*1e3+t.nsec/1e6)}var _k={type:hk,encode:yk,decode:xk},sd=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(_k)}return e.prototype.register=function(t){var n=t.type,r=t.encode,i=t.decode;if(n>=0)this.encoders[n]=r,this.decoders[n]=i;else{var o=1+n;this.builtInEncoders[o]=r,this.builtInDecoders[o]=i}},e.prototype.tryToEncode=function(t,n){for(var r=0;r<this.builtInEncoders.length;r++){var i=this.builtInEncoders[r];if(i!=null){var o=i(t,n);if(o!=null){var s=-1-r;return new Rs(s,o)}}}for(var r=0;r<this.encoders.length;r++){var i=this.encoders[r];if(i!=null){var o=i(t,n);if(o!=null){var s=r;return new Rs(s,o)}}}return t instanceof Rs?t:null},e.prototype.decode=function(t,n,r){var i=n<0?this.builtInDecoders[-1-n]:this.decoders[n];return i?i(t,n,r):new Rs(n,t)},e.defaultCodec=new e,e}();function $l(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}function bk(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=$l(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}var Sk=100,Ek=2048,Ak=function(){function e(t,n,r,i,o,s,l,a){t===void 0&&(t=sd.defaultCodec),n===void 0&&(n=void 0),r===void 0&&(r=Sk),i===void 0&&(i=Ek),o===void 0&&(o=!1),s===void 0&&(s=!1),l===void 0&&(l=!1),a===void 0&&(a=!1),this.extensionCodec=t,this.context=n,this.maxDepth=r,this.initialBufferSize=i,this.sortKeys=o,this.forceFloat32=s,this.ignoreUndefined=l,this.forceIntegerToFloat=a,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.reinitializeState=function(){this.pos=0},e.prototype.encodeSharedRef=function(t){return this.reinitializeState(),this.doEncode(t,1),this.bytes.subarray(0,this.pos)},e.prototype.encode=function(t){return this.reinitializeState(),this.doEncode(t,1),this.bytes.slice(0,this.pos)},e.prototype.doEncode=function(t,n){if(n>this.maxDepth)throw new Error("Too deep objects in depth ".concat(n));t==null?this.encodeNil():typeof t=="boolean"?this.encodeBoolean(t):typeof t=="number"?this.encodeNumber(t):typeof t=="string"?this.encodeString(t):this.encodeObject(t,n)},e.prototype.ensureBufferSizeToWrite=function(t){var n=this.pos+t;this.view.byteLength<n&&this.resizeBuffer(n*2)},e.prototype.resizeBuffer=function(t){var n=new ArrayBuffer(t),r=new Uint8Array(n),i=new DataView(n);r.set(this.bytes),this.view=i,this.bytes=r},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeBoolean=function(t){t===!1?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(t){Number.isSafeInteger(t)&&!this.forceIntegerToFloat?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):(this.writeU8(211),this.writeI64(t)):this.forceFloat32?(this.writeU8(202),this.writeF32(t)):(this.writeU8(203),this.writeF64(t))},e.prototype.writeStringHeader=function(t){if(t<32)this.writeU8(160+t);else if(t<256)this.writeU8(217),this.writeU8(t);else if(t<65536)this.writeU8(218),this.writeU16(t);else if(t<4294967296)this.writeU8(219),this.writeU32(t);else throw new Error("Too long string: ".concat(t," bytes in UTF-8"))},e.prototype.encodeString=function(t){var n=5,r=t.length;if(r>ik){var i=Tp(t);this.ensureBufferSizeToWrite(n+i),this.writeStringHeader(i),lk(t,this.bytes,this.pos),this.pos+=i}else{var i=Tp(t);this.ensureBufferSizeToWrite(n+i),this.writeStringHeader(i),rk(t,this.bytes,this.pos),this.pos+=i}},e.prototype.encodeObject=function(t,n){var r=this.extensionCodec.tryToEncode(t,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(t))this.encodeArray(t,n);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if(typeof t=="object")this.encodeMap(t,n);else throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(t)))},e.prototype.encodeBinary=function(t){var n=t.byteLength;if(n<256)this.writeU8(196),this.writeU8(n);else if(n<65536)this.writeU8(197),this.writeU16(n);else if(n<4294967296)this.writeU8(198),this.writeU32(n);else throw new Error("Too large binary: ".concat(n));var r=$l(t);this.writeU8a(r)},e.prototype.encodeArray=function(t,n){var r=t.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error("Too large array: ".concat(r));for(var i=0,o=t;i<o.length;i++){var s=o[i];this.doEncode(s,n+1)}},e.prototype.countWithoutUndefined=function(t,n){for(var r=0,i=0,o=n;i<o.length;i++){var s=o[i];t[s]!==void 0&&r++}return r},e.prototype.encodeMap=function(t,n){var r=Object.keys(t);this.sortKeys&&r.sort();var i=this.ignoreUndefined?this.countWithoutUndefined(t,r):r.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error("Too large map object: ".concat(i));for(var o=0,s=r;o<s.length;o++){var l=s[o],a=t[l];this.ignoreUndefined&&a===void 0||(this.encodeString(l),this.doEncode(a,n+1))}},e.prototype.encodeExtension=function(t){var n=t.data.length;if(n===1)this.writeU8(212);else if(n===2)this.writeU8(213);else if(n===4)this.writeU8(214);else if(n===8)this.writeU8(215);else if(n===16)this.writeU8(216);else if(n<256)this.writeU8(199),this.writeU8(n);else if(n<65536)this.writeU8(200),this.writeU16(n);else if(n<4294967296)this.writeU8(201),this.writeU32(n);else throw new Error("Too large extension object: ".concat(n));this.writeI8(t.type),this.writeU8a(t.data)},e.prototype.writeU8=function(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++},e.prototype.writeU8a=function(t){var n=t.length;this.ensureBufferSizeToWrite(n),this.bytes.set(t,this.pos),this.pos+=n},e.prototype.writeI8=function(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++},e.prototype.writeU16=function(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2},e.prototype.writeI16=function(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2},e.prototype.writeU32=function(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4},e.prototype.writeI32=function(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4},e.prototype.writeF32=function(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4},e.prototype.writeF64=function(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8},e.prototype.writeU64=function(t){this.ensureBufferSizeToWrite(8),tk(this.view,this.pos,t),this.pos+=8},e.prototype.writeI64=function(t){this.ensureBufferSizeToWrite(8),Ey(this.view,this.pos,t),this.pos+=8},e}(),Ck={};function ky(e,t){t===void 0&&(t=Ck);var n=new Ak(t.extensionCodec,t.context,t.maxDepth,t.initialBufferSize,t.sortKeys,t.forceFloat32,t.ignoreUndefined,t.forceIntegerToFloat);return n.encodeSharedRef(e)}function wu(e){return"".concat(e<0?"-":"","0x").concat(Math.abs(e).toString(16).padStart(2,"0"))}var kk=16,Ok=16,Pk=function(){function e(t,n){t===void 0&&(t=kk),n===void 0&&(n=Ok),this.maxKeyLength=t,this.maxLengthPerKey=n,this.hit=0,this.miss=0,this.caches=[];for(var r=0;r<this.maxKeyLength;r++)this.caches.push([])}return e.prototype.canBeCached=function(t){return t>0&&t<=this.maxKeyLength},e.prototype.find=function(t,n,r){var i=this.caches[r-1];e:for(var o=0,s=i;o<s.length;o++){for(var l=s[o],a=l.bytes,u=0;u<r;u++)if(a[u]!==t[n+u])continue e;return l.str}return null},e.prototype.store=function(t,n){var r=this.caches[t.length-1],i={bytes:t,str:n};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)},e.prototype.decode=function(t,n,r){var i=this.find(t,n,r);if(i!=null)return this.hit++,i;this.miss++;var o=Cy(t,n,r),s=Uint8Array.prototype.slice.call(t,n,n+r);return this.store(s,o),o},e}(),Nk=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function l(c){try{u(r.next(c))}catch(f){s(f)}}function a(c){try{u(r.throw(c))}catch(f){s(f)}}function u(c){c.done?o(c.value):i(c.value).then(l,a)}u((r=r.apply(e,t||[])).next())})},xu=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(u){return function(c){return a([u,c])}}function a(u){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){n.label=u[1];break}if(u[0]===6&&n.label<o[1]){n.label=o[1],o=u;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(u);break}o[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(c){u=[6,c],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},Rp=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(s){return new Promise(function(l,a){s=e[o](s),i(l,a,s.done,s.value)})}}function i(o,s,l,a){Promise.resolve(a).then(function(u){o({value:u,done:l})},s)}},li=function(e){return this instanceof li?(this.v=e,this):new li(e)},jk=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(d){r[d]&&(i[d]=function(p){return new Promise(function(y,m){o.push([d,p,y,m])>1||l(d,p)})})}function l(d,p){try{a(r[d](p))}catch(y){f(o[0][3],y)}}function a(d){d.value instanceof li?Promise.resolve(d.value.v).then(u,c):f(o[0][2],d)}function u(d){l("next",d)}function c(d){l("throw",d)}function f(d,p){d(p),o.shift(),o.length&&l(o[0][0],o[0][1])}},Tk=function(e){var t=typeof e;return t==="string"||t==="number"},Qi=-1,ld=new DataView(new ArrayBuffer(0)),Rk=new Uint8Array(ld.buffer),Lc=function(){try{ld.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),Dp=new Lc("Insufficient data"),Dk=new Pk,Mk=function(){function e(t,n,r,i,o,s,l,a){t===void 0&&(t=sd.defaultCodec),n===void 0&&(n=void 0),r===void 0&&(r=lr),i===void 0&&(i=lr),o===void 0&&(o=lr),s===void 0&&(s=lr),l===void 0&&(l=lr),a===void 0&&(a=Dk),this.extensionCodec=t,this.context=n,this.maxStrLength=r,this.maxBinLength=i,this.maxArrayLength=o,this.maxMapLength=s,this.maxExtLength=l,this.keyDecoder=a,this.totalPos=0,this.pos=0,this.view=ld,this.bytes=Rk,this.headByte=Qi,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=Qi,this.stack.length=0},e.prototype.setBuffer=function(t){this.bytes=$l(t),this.view=bk(this.bytes),this.pos=0},e.prototype.appendBuffer=function(t){if(this.headByte===Qi&&!this.hasRemaining(1))this.setBuffer(t);else{var n=this.bytes.subarray(this.pos),r=$l(t),i=new Uint8Array(n.length+r.length);i.set(n),i.set(r,n.length),this.setBuffer(i)}},e.prototype.hasRemaining=function(t){return this.view.byteLength-this.pos>=t},e.prototype.createExtraByteError=function(t){var n=this,r=n.view,i=n.pos;return new RangeError("Extra ".concat(r.byteLength-i," of ").concat(r.byteLength," byte(s) found at buffer[").concat(t,"]"))},e.prototype.decode=function(t){this.reinitializeState(),this.setBuffer(t);var n=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return n},e.prototype.decodeMulti=function(t){return xu(this,function(n){switch(n.label){case 0:this.reinitializeState(),this.setBuffer(t),n.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return n.sent(),[3,1];case 3:return[2]}})},e.prototype.decodeAsync=function(t){var n,r,i,o;return Nk(this,void 0,void 0,function(){var s,l,a,u,c,f,d,p;return xu(this,function(y){switch(y.label){case 0:s=!1,y.label=1;case 1:y.trys.push([1,6,7,12]),n=Rp(t),y.label=2;case 2:return[4,n.next()];case 3:if(r=y.sent(),!!r.done)return[3,5];if(a=r.value,s)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{l=this.doDecodeSync(),s=!0}catch(m){if(!(m instanceof Lc))throw m}this.totalPos+=this.pos,y.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return u=y.sent(),i={error:u},[3,12];case 7:return y.trys.push([7,,10,11]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,9];case 8:y.sent(),y.label=9;case 9:return[3,11];case 10:if(i)throw i.error;return[7];case 11:return[7];case 12:if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,l]}throw c=this,f=c.headByte,d=c.pos,p=c.totalPos,new RangeError("Insufficient data in parsing ".concat(wu(f)," at ").concat(p," (").concat(d," in the current buffer)"))}})})},e.prototype.decodeArrayStream=function(t){return this.decodeMultiAsync(t,!0)},e.prototype.decodeStream=function(t){return this.decodeMultiAsync(t,!1)},e.prototype.decodeMultiAsync=function(t,n){return jk(this,arguments,function(){var i,o,s,l,a,u,c,f,d;return xu(this,function(p){switch(p.label){case 0:i=n,o=-1,p.label=1;case 1:p.trys.push([1,13,14,19]),s=Rp(t),p.label=2;case 2:return[4,li(s.next())];case 3:if(l=p.sent(),!!l.done)return[3,12];if(a=l.value,n&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),i&&(o=this.readArraySize(),i=!1,this.complete()),p.label=4;case 4:p.trys.push([4,9,,10]),p.label=5;case 5:return[4,li(this.doDecodeSync())];case 6:return[4,p.sent()];case 7:return p.sent(),--o===0?[3,8]:[3,5];case 8:return[3,10];case 9:if(u=p.sent(),!(u instanceof Lc))throw u;return[3,10];case 10:this.totalPos+=this.pos,p.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return c=p.sent(),f={error:c},[3,19];case 14:return p.trys.push([14,,17,18]),l&&!l.done&&(d=s.return)?[4,li(d.call(s))]:[3,16];case 15:p.sent(),p.label=16;case 16:return[3,18];case 17:if(f)throw f.error;return[7];case 18:return[7];case 19:return[2]}})})},e.prototype.doDecodeSync=function(){e:for(;;){var t=this.readHeadByte(),n=void 0;if(t>=224)n=t-256;else if(t<192)if(t<128)n=t;else if(t<144){var r=t-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else n={}}else if(t<160){var r=t-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else n=[]}else{var i=t-160;n=this.decodeUtf8String(i,0)}else if(t===192)n=null;else if(t===194)n=!1;else if(t===195)n=!0;else if(t===202)n=this.readF32();else if(t===203)n=this.readF64();else if(t===204)n=this.readU8();else if(t===205)n=this.readU16();else if(t===206)n=this.readU32();else if(t===207)n=this.readU64();else if(t===208)n=this.readI8();else if(t===209)n=this.readI16();else if(t===210)n=this.readI32();else if(t===211)n=this.readI64();else if(t===217){var i=this.lookU8();n=this.decodeUtf8String(i,1)}else if(t===218){var i=this.lookU16();n=this.decodeUtf8String(i,2)}else if(t===219){var i=this.lookU32();n=this.decodeUtf8String(i,4)}else if(t===220){var r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else n=[]}else if(t===221){var r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else n=[]}else if(t===222){var r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else n={}}else if(t===223){var r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else n={}}else if(t===196){var r=this.lookU8();n=this.decodeBinary(r,1)}else if(t===197){var r=this.lookU16();n=this.decodeBinary(r,2)}else if(t===198){var r=this.lookU32();n=this.decodeBinary(r,4)}else if(t===212)n=this.decodeExtension(1,0);else if(t===213)n=this.decodeExtension(2,0);else if(t===214)n=this.decodeExtension(4,0);else if(t===215)n=this.decodeExtension(8,0);else if(t===216)n=this.decodeExtension(16,0);else if(t===199){var r=this.lookU8();n=this.decodeExtension(r,1)}else if(t===200){var r=this.lookU16();n=this.decodeExtension(r,2)}else if(t===201){var r=this.lookU32();n=this.decodeExtension(r,4)}else throw new Dt("Unrecognized type byte: ".concat(wu(t)));this.complete();for(var o=this.stack;o.length>0;){var s=o[o.length-1];if(s.type===0)if(s.array[s.position]=n,s.position++,s.position===s.size)o.pop(),n=s.array;else continue e;else if(s.type===1){if(!Tk(n))throw new Dt("The type of key must be string or number but "+typeof n);if(n==="__proto__")throw new Dt("The key __proto__ is not allowed");s.key=n,s.type=2;continue e}else if(s.map[s.key]=n,s.readCount++,s.readCount===s.size)o.pop(),n=s.map;else{s.key=null,s.type=1;continue e}}return n}},e.prototype.readHeadByte=function(){return this.headByte===Qi&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=Qi},e.prototype.readArraySize=function(){var t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new Dt("Unrecognized array type byte: ".concat(wu(t)))}}},e.prototype.pushMapState=function(t){if(t>this.maxMapLength)throw new Dt("Max length exceeded: map length (".concat(t,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:t,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(t){if(t>this.maxArrayLength)throw new Dt("Max length exceeded: array length (".concat(t,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:t,array:new Array(t),position:0})},e.prototype.decodeUtf8String=function(t,n){var r;if(t>this.maxStrLength)throw new Dt("Max length exceeded: UTF-8 byte length (".concat(t,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+n+t)throw Dp;var i=this.pos+n,o;return this.stateIsMapKey()&&(!((r=this.keyDecoder)===null||r===void 0)&&r.canBeCached(t))?o=this.keyDecoder.decode(this.bytes,i,t):t>ck?o=fk(this.bytes,i,t):o=Cy(this.bytes,i,t),this.pos+=n+t,o},e.prototype.stateIsMapKey=function(){if(this.stack.length>0){var t=this.stack[this.stack.length-1];return t.type===1}return!1},e.prototype.decodeBinary=function(t,n){if(t>this.maxBinLength)throw new Dt("Max length exceeded: bin length (".concat(t,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(t+n))throw Dp;var r=this.pos+n,i=this.bytes.subarray(r,r+t);return this.pos+=n+t,i},e.prototype.decodeExtension=function(t,n){if(t>this.maxExtLength)throw new Dt("Max length exceeded: ext length (".concat(t,") > maxExtLength (").concat(this.maxExtLength,")"));var r=this.view.getInt8(this.pos+n),i=this.decodeBinary(t,n+1);return this.extensionCodec.decode(i,r,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var t=this.view.getUint8(this.pos);return this.pos++,t},e.prototype.readI8=function(){var t=this.view.getInt8(this.pos);return this.pos++,t},e.prototype.readU16=function(){var t=this.view.getUint16(this.pos);return this.pos+=2,t},e.prototype.readI16=function(){var t=this.view.getInt16(this.pos);return this.pos+=2,t},e.prototype.readU32=function(){var t=this.view.getUint32(this.pos);return this.pos+=4,t},e.prototype.readI32=function(){var t=this.view.getInt32(this.pos);return this.pos+=4,t},e.prototype.readU64=function(){var t=nk(this.view,this.pos);return this.pos+=8,t},e.prototype.readI64=function(){var t=Ay(this.view,this.pos);return this.pos+=8,t},e.prototype.readF32=function(){var t=this.view.getFloat32(this.pos);return this.pos+=4,t},e.prototype.readF64=function(){var t=this.view.getFloat64(this.pos);return this.pos+=8,t},e}(),Lk={};function Oy(e,t){t===void 0&&(t=Lk);var n=new Mk(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength);return n.decode(e)}class Ik{constructor(t){I(this,"context");I(this,"_activeContext");I(this,"_activeCommand");I(this,"_highlightCommand");I(this,"highlightState",ye.AFTER);I(this,"highlightScreencast",null);I(this,"highlightInterval");I(this,"_darken",!1);I(this,"screencast",{lastFrameBeforeSector:null,inBetween:[]});I(this,"defaults",{highlightCommandState:ye.AFTER});I(this,"_mode",ey.FRAME);I(this,"_state",ye.AFTER);I(this,"_lastActiveScreencastUrl",null);this.context=t,ua(this,{_activeContext:U,_activeCommand:U,_highlightCommand:U,highlightState:U,highlightScreencast:U,highlightInterval:U,_darken:U,screencast:U,_mode:U,_state:U,clear:te,resetHighlightInterval:te,toggleHighlightState:te,findLastEventUntil:te,findEventsBetween:te,findLastScreencastForCommand:te,registerEvents:te,toggleCommand:te,highlightCommand:te,unhighlightCommand:te,activeScreencast:ne,visibleScreencast:ne,activeScreencastUrl:ne,visibleCommand:ne,visibleHighlightState:ne,isVisibleHighlight:ne,mode:ne,state:ne}),this.registerEvents()}get mode(){return this._mode}set mode(t){this._mode=t}get state(){return this._state}set state(t){this._state=t}get activeScreencast(){if(!this._activeCommand){const t=this.context.screencasts;return t[t.length-1]??null}return this.state===ye.AFTER&&this.screencast.inBetween.length>0?this.screencast.inBetween[this.screencast.inBetween.length-1]:this.state===ye.BEFORE?this.screencast.lastFrameBeforeSector:this.screencast.lastFrameBeforeSector}get visibleScreencast(){return this._highlightCommand?this.highlightScreencast:this.activeScreencast}get activeScreencastUrl(){return this._lastActiveScreencastUrl&&URL.revokeObjectURL(this._lastActiveScreencastUrl),this.visibleScreencast?(this._lastActiveScreencastUrl=URL.createObjectURL(new Blob([this.visibleScreencast.frame],{type:"image/jpeg"})),this._lastActiveScreencastUrl):null}clear(){this._highlightCommand=void 0,this.highlightScreencast=void 0,this.highlightState=ye.AFTER,this._activeCommand=void 0,this._activeContext=void 0,this.screencast.lastFrameBeforeSector=null,this.screencast.inBetween=[],this._lastActiveScreencastUrl!==null&&(URL.revokeObjectURL(this._lastActiveScreencastUrl),this._lastActiveScreencastUrl=null)}set darken(t){this._darken=t}get darken(){return this._darken}resetHighlightInterval(){clearInterval(this.highlightInterval),this.highlightState=ye.AFTER}toggleHighlightState(){this.highlightState=this.highlightState===ye.BEFORE?ye.AFTER:ye.BEFORE}get visibleCommand(){return this._highlightCommand??this.activeCommand}get visibleHighlightState(){return this._highlightCommand?this.defaults.highlightCommandState:this.state}get isVisibleHighlight(){return this._highlightCommand!==void 0}set activeCommand(t){t&&(this.activeContext=t.context),this._activeCommand=t}get activeCommand(){return this._activeCommand}set activeContext(t){this._activeContext=t}get activeContext(){return this._activeContext}findLastEventUntil(t,n){let r=null;for(let i of n){if(i.timestamp>=t)break;r=i}return r}findEventsBetween(t,n,r){let i=[];for(let o of r)o.timestamp>t&&o.timestamp<n&&i.push(o);return i}findLastScreencastForCommand(t){let n=t.context.commands.findIndex(r=>t.id===r.id);if(n===t.context.commands.length-1)return{screencast:t.context.screencasts[t.context.screencasts.length-1],until:t.timestamp};{let r=t.context.commands[n+1].time.started;return{screencast:this.findLastEventUntil(r,t.context.screencasts),until:r}}}toggleCommand(t){var i,o;if(((i=this.activeCommand)==null?void 0:i.id)===(t==null?void 0:t.id)){this.activeCommand=void 0,this.screencast.lastFrameBeforeSector=void 0,this.screencast.inBetween=[],Ar.emit("command:active",void 0);return}((o=this._highlightCommand)==null?void 0:o.id)===(t==null?void 0:t.id)&&(this._highlightCommand=void 0,this.highlightScreencast=null),this.activeCommand=t;let n=t.context.commands.findIndex(s=>t.id===s.id),r=n===t.context.commands.length-1?t.time.finished+100:t.context.commands[n+1].time.started;this.screencast.inBetween=this.findEventsBetween(t.time.started,r,t.context.screencasts),this.screencast.lastFrameBeforeSector=this.findLastEventUntil(t.time.started,t.context.screencasts),Ar.emit("command:active",t)}highlightCommand(t){var r,i;if(((r=this.visibleCommand)==null?void 0:r.id)===(t==null?void 0:t.id)||((i=this.activeCommand)==null?void 0:i.id)===(t==null?void 0:t.id))return;this._highlightCommand=t,this.resetHighlightInterval();let n=this.findLastScreencastForCommand(t);this.highlightScreencast=n.screencast,console.debug("[Preview] highlightCommand",t,n)}unhighlightCommand(t){var n;((n=this._highlightCommand)==null?void 0:n.id)===(t==null?void 0:t.id)&&(console.debug("[Preview] unhighlightCommand",t),this._highlightCommand=void 0,this.highlightScreencast=null)}registerEvents(){}}class ai{constructor(t,n,r){I(this,"id");I(this,"commands",[]);I(this,"logs",[]);I(this,"network",[]);I(this,"annotations",[]);I(this,"handoffs",[]);I(this,"navigations",[]);I(this,"screencasts",[]);I(this,"unspecific",[]);I(this,"renderedEvents",[]);I(this,"responseContentByPacketId",new Map);I(this,"group","");I(this,"test",{name:"",status:void 0});I(this,"options");I(this,"capabilities");I(this,"createdAt");I(this,"lastActivity");I(this,"original");I(this,"app");I(this,"connection");I(this,"preview",null);I(this,"followIncoming",!0);this.original=t,this.app=n,this.connection=r;let{id:i,options:o,test:s,group:l,capabilities:a,timestamp:u}=t;this.id=i,this.options=o,this.test=s,this.group=l,this.capabilities=a,this.createdAt=u,this.lastActivity=u,this.preview=null,this.initializePreviewStore(),ua(this,{commands:U,logs:U,network:U,annotations:U,handoffs:U,navigations:U,screencasts:U,unspecific:U,group:U,test:U,options:U,capabilities:U,lastActivity:U,connection:U,followIncoming:U,renderedEvents:U,initializePreviewStore:te,received:te,getEventTime:te,packets:te,blob:te,took:ne,isForeground:ne,isAgent:ne,isLive:ne,handoff:ne,toolCalls:ne})}initializePreviewStore(){if(this.preview!==null){console.warn("[Context] Already initialized preview store");return}this.preview=new Ik(this),this.renderedEvents.length!==0&&this.preview.toggleCommand(this.renderedEvents[this.renderedEvents.length-1])}received(t){var r;t.context=this,this.registerResponseContent(t),t.type==="command"?(this.commands.push(t),[ho.Page,ho.ElementHandle,"Browser"].includes(t.on.type)&&this.pushRenderedPacket(t)):t.type==="log"?(this.logs.push(t),this.pushRenderedPacket(t)):t.type==="request"||t.type==="response"||t.type==="update"&&t.specific==="request.failed"?(this.network.push(t),t.type!=="request"&&this.pushRenderedPacket(t)):t.type==="annotation"?(this.annotations.push(t),this.pushRenderedPacket(t)):t.type==="navigation"?(this.navigations.push(t),this.pushRenderedPacket(t)):t.type==="handoff"?(this.handoffs.push(t),this.pushRenderedPacket(t)):t.type==="test"?(t.specific==="status"&&(this.test.status=t.status),this.unspecific.push(t)):t.type==="screencasts"?this.screencasts.push(t):(console.log("unhandled event packet",t),this.unspecific.push(t));let n=((r=t==null?void 0:t.time)==null?void 0:r.finished)>t.timestamp?t.time.finished:t.timestamp;n>this.lastActivity&&(this.lastActivity=n)}static eventTime(t){var n;return t.timestamp??((n=t.time)==null?void 0:n.finished)??t.time??0}pushRenderedPacket(t){var i;const n=ai.eventTime(t),r=this.renderedEvents.length;if(r===0||ai.eventTime(this.renderedEvents[r-1])<=n)this.renderedEvents.push(t);else{let o=this.renderedEvents.findIndex(s=>ai.eventTime(s)>n);this.renderedEvents.splice(o,0,t)}if(t.type==="command"&&this.isForeground&&this.followIncoming&&this.preview!==null){const o=this.renderedEvents.filter(l=>l.type==="command"),s=o.length;s>1&&o[s-2].id===((i=this.preview.activeCommand)==null?void 0:i.id)&&this.preview.toggleCommand(o[s-1])}}getEventTime(t){var n,r;return((n=t==null?void 0:t.time)==null?void 0:n.started)??((r=t==null?void 0:t.time)==null?void 0:r.created)??(t==null?void 0:t.timestamp)??(t==null?void 0:t.time)}packets(){let t=[structuredClone(Sh(this.original)),...this.commands,...this.logs,...this.network,...this.annotations,...this.handoffs,...this.navigations,...this.screencasts,...this.unspecific];for(let n=1;n<t.length;n++){let r=t[n];r.context=t[0].context,t[n]=structuredClone(Sh(r)),r.context=this}return t}responseContent(t){return t.content??(t.contentReference==null?void 0:this.responseContentByPacketId.get(t.contentReference))}registerResponseContent(t){if(t.type==="response"){if(t.content instanceof Uint8Array){this.responseContentByPacketId.set(t.id,t.content);return}t.contentReference!=null&&!this.responseContentByPacketId.has(t.contentReference)&&console.warn("Response content reference could not be resolved",t)}}blob(){return new Blob([ky(this.packets(),{extensionCodec:Fo})])}get took(){const t=this.lastActivity-this.createdAt,n=Math.floor(t/1e3/60),r=Math.ceil(t/1e3%60);return{ms:t,minutes:n,seconds:r}}get isAgent(){return this.group==="mcp"}get isLive(){return(this.test.status??"pending")==="pending"}get handoff(){return this.handoffs[this.handoffs.length-1]}get toolCalls(){return this.annotations.filter(t=>t.kind==="tool").length}get isForeground(){var t;return((t=this.app.activeContext)==null?void 0:t.id)===this.id}}const Fo=new sd;Fo.register({type:0,encode:e=>e instanceof Function?new TextEncoder().encode(e.toString()):null,decode:e=>new TextDecoder().decode(e)});class Mp{constructor(t){I(this,"app");I(this,"websocket");I(this,"uri","");I(this,"connectionTimeout",2e3);I(this,"connectionState",WebSocket.CLOSED);I(this,"totalBytesReceived",0);I(this,"contexts",[]);I(this,"emitter",Y0());I(this,"active",{context:void 0});Uf(this),this.app=t}setActiveContext(t){t.initializePreviewStore(),this.active.context=t}retry(){return new Promise((t,n)=>{if(this.connectionState!==WebSocket.CLOSED){t(this);return}if(this.uri===""){console.warn("[Connection] No uri set. Hint: call connect() before retrying.",this),n({code:"missing",reason:"Missing uri"});return}t(this.connect(this.uri))})}destroy(){this.websocket.close()}connect(t){return new Promise((n,r)=>{this.uri=t,this.websocket=new WebSocket(this.uri),this.websocket.binaryType="arraybuffer",this.connectionState=this.websocket.readyState;const i=()=>{clearTimeout(a),this.connectionState=this.websocket.readyState,n(this)},o=()=>{clearTimeout(a),l(),this.connectionState=this.websocket.readyState,r({code:"closed",reason:"Connection closed"})},s=u=>{this.received(u.data)};this.websocket.addEventListener("open",i),this.websocket.addEventListener("close",o),this.websocket.addEventListener("message",s);const l=()=>{this.websocket.removeEventListener("open",i),this.websocket.removeEventListener("close",o),this.websocket.removeEventListener("message",s)},a=setTimeout(()=>{this.websocket.readyState===WebSocket.CONNECTING&&(l(),this.websocket.close(),r({code:"timeout",reason:"Connection timeout reached (2s)"}))},this.connectionTimeout)})}send(t){if(this.websocket.readyState!==WebSocket.OPEN){console.error("Did not send packet because websocket was not open",t);return}let n=ky(t,{extensionCodec:Fo});this.websocket.send(n)}received(t){this.totalBytesReceived+=t.byteLength;let n=Date.now(),r=Oy(t,{extensionCodec:Fo}),i=Date.now();if(Array.isArray(r))for(let s of r)this.receivedPacket(s);else this.receivedPacket(r);let o=Date.now();Ml(()=>{let s=(t.byteLength/1e3/1e3).toFixed(2);console.group("Packet received"),console.groupCollapsed("Events",Array.isArray(r)?r.length:1),J0(r),console.groupEnd(),console.log("Size",s,"mb"),console.log("Delta time parse",i-n,"ms"),console.log("Delta time proc.",o-i,"ms"),console.log("Delta time debug",Date.now()-o,"ms"),console.groupEnd()})}receivedPacket(t){if(t.type==="context"){let r=new ai(t,this.app,this);this.contexts.unshift(r),Ar.emit("context:created",r),this.emit("context:created",r);return}let n=this.getContext(t.context.id);if(!n){console.log("ignored packet because no context was initialized",t);return}n.received(t),Ar.emit("context:received",{context:n,packet:t}),this.emit("context:received",{context:n,packet:t})}getContext(t){return this.contexts.find(n=>n.id===t)}get hasNoContexts(){return this.contexts.length===0}get isForeground(){return this.app.active.connection===this}get isConnected(){return this.connectionState===WebSocket.OPEN}getTotalBytesReceived(){return this.totalBytesReceived}getMetrics(){let t={contexts:this.contexts.length,events:0};return this.contexts.forEach(n=>{t.events+=n.commands.length,t.events+=n.logs.length}),t}clear(){}on(t,n){return this.emitter.on(t,n)}off(t,n){return this.emitter.on(t,n)}emit(t,n){return this.emitter.emit(t,n)}}class dr extends Error{}function Fk(e){try{return Oy(e,{extensionCodec:Fo})}catch{throw new dr("This file is not a Puth snapshot or it is damaged.")}}function zk(e){var s;const t=Fk(e);if(!Array.isArray(t)||t.length===0)throw new dr("This snapshot does not contain any packets.");const[n]=t;if((n==null?void 0:n.type)!=="context"||((s=n==null?void 0:n.context)==null?void 0:s.id)==null)throw new dr("This snapshot does not start with a context packet.");const r=n.snapshotVersion??1;if(!Number.isInteger(r)||r<1||r>hp)throw new dr(`Snapshot version ${r} is not supported. This GUI reads versions up to ${hp}.`);const i=new Set(t.filter(l=>(l==null?void 0:l.content)!=null).map(l=>l.id)),o=t.find(l=>(l==null?void 0:l.contentReference)!=null&&!i.has(l.contentReference));if(o!==void 0)throw new dr(`Response ${o.id} references content that is missing from this snapshot.`);return t}const Uk=Se(()=>{const{app:e}=x.useContext(Ee),[t,n]=x.useState(!1),r=async l=>{const a=zk(await l.arrayBuffer());if(nA(a),e.dragAndDropped.contexts.some(c=>c.id===a[0].context.id))throw new dr("This snapshot is already imported.");let u=new ai(a[0],e);for(let c=1;c<a.length;c++)u.received(a[c]);jn(()=>e.dragAndDropped.contexts.unshift(u))};let i=async l=>{n(!0),jn(()=>e.importErrors=[]);const u=(await Promise.allSettled(l.map(r))).flatMap((c,f)=>{if(c.status==="fulfilled")return[];console.warn("Could not import snapshot",c.reason);const d=c.reason instanceof dr?c.reason.message:"This snapshot contains packets that could not be read.";return[`${l[f].name}: ${d}`]});jn(()=>{e.importErrors=u,u.length!==l.length&&(e.setView("local"),e.dragAndDropped.active=e.dragAndDropped.contexts[0]),Io.active=0}),n(!1)};const{getRootProps:o,getInputProps:s}=Sy({accept:".puth",onDropAccepted:i,noDragEventsBubbling:!0});return h.jsxs(h.Fragment,{children:[h.jsxs("div",{...o({className:`dropzone-wrapper ${Io.active>0?"active":""}`}),children:[h.jsx("input",{...s()}),h.jsxs("div",{className:"dropzone shell-hero relative overflow-hidden",children:[h.jsx("div",{"aria-hidden":!0,className:"shell-hero-dots absolute inset-0"}),h.jsx("div",{"aria-hidden":!0,className:"shell-hero-grain absolute inset-0"}),h.jsx("div",{"aria-hidden":!0,className:"shell-hero-scrim absolute inset-0"}),h.jsx("div",{className:"relative flex flex-col items-center gap-3.5",children:t?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{name:"progress_activity",size:"2rem",className:"animate-spin text-blue-100"}),h.jsx("div",{role:"status",className:"text-[22px] font-medium text-blue-50",children:"Importing snapshot..."})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:"flex h-[60px] w-[60px] items-center justify-center rounded-[14px] border border-blue-200/45 bg-blue-950/50 text-blue-100",children:h.jsx(Pt,{name:"download",size:"1.6rem",className:"rotate-180"})}),h.jsx("p",{className:"text-[26px] font-medium tracking-[-0.01em] text-blue-50",children:"Drag and drop a snapshot"}),h.jsx("em",{className:"font-mono text-[12.5px] not-italic text-blue-50",children:"Only .puth files · stays on this machine"})]})})]})]}),e.importErrors.length>0&&h.jsx("div",{className:"fixed left-1/2 top-4 z-[110] w-[min(520px,calc(100%-32px))] -translate-x-1/2",children:h.jsxs("button",{type:"button",puth:"import-errors",role:"alert","aria-label":"Import failed, click to dismiss",className:"flex w-full flex-col overflow-hidden rounded-[10px] border border-red-400/35 bg-gradient-to-b from-[#2a1414] to-[#1c1010] text-left shadow-[0_20px_50px_rgba(0,0,0,0.6)]",onClick:()=>jn(()=>e.importErrors=[]),children:[h.jsxs("span",{className:"flex w-full justify-between border-b border-dashed border-red-400/25 px-3.5 py-2.5 font-mono text-xs",children:[h.jsxs("span",{className:"text-red-300",children:["Import failed · ",e.importErrors.length," ",e.importErrors.length===1?"file":"files"]}),h.jsx("span",{className:"text-ink-body",children:"Dismiss"})]}),h.jsx("span",{className:"flex flex-col gap-1.5 px-3.5 py-3 text-[13px] leading-normal text-red-100",children:e.importErrors.map((l,a)=>h.jsx("span",{children:l},a))})]})})]})}),Bk=()=>h.jsxs(h.Fragment,{children:[h.jsx(aC,{}),h.jsx(Uk,{})]});class $k{constructor(){I(this,"name",{suffix:""});I(this,"connections",[]);I(this,"connectionSuggestions",[(document.location.protocol==="https:"?"wss://":"ws://")+window.location.host+"/websocket"]);I(this,"active",{connection:void 0});I(this,"modals",{connectionViewer:!0});I(this,"mode","default");I(this,"classes",{Connection:Mp});I(this,"dragAndDropped",{contexts:[],active:null});I(this,"settings",{preview:{darken:!1}});I(this,"view","instance");I(this,"agentsActive",null);I(this,"pinned",[]);I(this,"importErrors",[]);this.settings.preview.darken=this.readLocalStorageBoolean("previewStore.darken"),ua(this,{name:U,connections:U,connectionSuggestions:U,active:U,modals:U,mode:U,classes:U,dragAndDropped:U,settings:U,view:U,agentsActive:U,pinned:U,togglePinned:te,agents:ne,liveAgents:ne,importErrors:U,tryConnectingTo:te,setActive:te,setView:te,setDarkenPreview:te,history:ne,activeContext:ne,previewStore:ne,empty:ne,hasLocalContexts:ne,isConnected:ne})}async tryConnectingTo(t){return new Mp(this).connect(t).then(n=>(this.connections.length!==0&&(this.connections[0].destroy(),this.connections=[]),this.connections.push(n),this.active.connection=n,n))}get history(){var t;return this.view==="instance"?(((t=this.active.connection)==null?void 0:t.contexts)??[]).filter(n=>!n.isAgent):this.view==="agents"?this.agents:this.dragAndDropped.contexts}get agents(){var t;return(((t=this.active.connection)==null?void 0:t.contexts)??[]).filter(n=>n.isAgent||n.handoffs.some(r=>r.state==="claimed"))}get liveAgents(){return this.agents.filter(t=>t.isLive).length}get activeContext(){var t;return this.view==="instance"?(t=this.active.connection)==null?void 0:t.active.context:this.view==="agents"?this.agentsActive??void 0:this.dragAndDropped.active}togglePinned(t){this.pinned=this.pinned.includes(t.id)?this.pinned.filter(n=>n!==t.id):[...this.pinned,t.id]}get previewStore(){var t;return(t=this.activeContext)==null?void 0:t.preview}get empty(){return!this.hasLocalContexts&&!this.isConnected}get hasLocalContexts(){return this.dragAndDropped.contexts.length!==0}get isConnected(){return this.connections.length!==0}setActive(t){if(this.view==="agents"){this.agentsActive=t;return}if(this.view==="instance"){if(!this.active.connection||this.active.connection.active.context===t)return;this.active.connection.setActiveContext(t);return}this.dragAndDropped.active=t}setView(t){this.view=t}setDarkenPreview(t){this.settings.preview.darken=t,this.writeLocalStorageBoolean("previewStore.darken",t)}readLocalStorageBoolean(t){return localStorage.getItem(t)==="true"}writeLocalStorageBoolean(t,n){localStorage.setItem(t,n?"true":"false")}}const Ic=new $k;Ar.on("command:active",e=>{Ic.mode==="follow"&&(Ic.mode="default")});_u.createRoot(document.getElementById("root")).render(h.jsx(Cn.StrictMode,{children:h.jsx(Ee.Provider,{value:{app:Ic},children:h.jsx(Bk,{})})}));let cn=document.getElementById("root");cn==null||cn.addEventListener("dragenter",()=>{jn(()=>Io.active++)});cn==null||cn.addEventListener("dragleave",()=>{jn(()=>Io.active--)});cn==null||cn.addEventListener("drop",()=>{jn(()=>Io.active--)});
package/dist/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3c83f6">
13
13
  <meta name="msapplication-TileColor" content="#2b5797">
14
14
  <meta name="theme-color" content="#ffffff">
15
- <script type="module" crossorigin src="/assets/index-DzPtSSAU.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-heyt6w4C.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-BEYR92by.css">
17
17
  </head>
18
18
  <body class="dark">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@puth/gui",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/puth-io/puth.git",