@mcpc-tech/unplugin-dev-inspector-mcp 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/inspector.js +4 -4
- package/dist/index.d.cts +4 -4
- package/package.json +1 -1
package/client/dist/inspector.js
CHANGED
|
@@ -57,7 +57,7 @@ IMPORTANT: For this task, you MUST call the "context_selector" tool to return yo
|
|
|
57
57
|
<img src="${t.screenshot}" alt="Element Screenshot" style="max-width: min(100%, 37.5rem); display: block; margin-bottom: 1rem; border-radius: 0.5rem; box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.1);">
|
|
58
58
|
<pre style="font-family: 'SF Mono', Monaco, 'Courier New', monospace; font-size: 0.75rem; white-space: pre-wrap; background: #f6f8fa; padding: 1rem; border-radius: 0.375rem; border: 1px solid #e1e4e8; overflow-x: auto;">${n.replace(/</g,`<`).replace(/>/g,`>`)}</pre>
|
|
59
59
|
</div>`;await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:`text/html`}),"text/plain":new Blob([n],{type:`text/plain`})})])}else await navigator.clipboard.writeText(n);y(!1)}catch(e){console.warn(`Clipboard copy failed, falling back to text-only:`,e);try{await navigator.clipboard.writeText(n);let e=new CustomEvent(`inspector-notification`,{detail:{message:`⚠️ Screenshot not copied - only text was copied to clipboard`}});window.dispatchEvent(e),y(!1)}catch{console.error(`Failed to copy to clipboard`)}}},M=e=>{a&&a(h,e,D?A():void 0)},N=p?.steps.every(e=>e.status===`completed`);return(0,X.jsx)(d,{open:_,onOpenChange:y,children:(0,X.jsxs)(m,{onClose:()=>y(!1),className:`max-w-2xl`,children:[(0,X.jsxs)(v,{children:[(0,X.jsxs)(c,{className:`flex items-center gap-2`,children:[i===`success`||i===`loading`&&N?(0,X.jsx)(S,{className:`h-5 w-5 text-green-600 dark:text-green-500`}):i===`error`?(0,X.jsx)(b,{className:`h-5 w-5 text-red-600 dark:text-red-500`}):i===`loading`?(0,X.jsx)(z,{className:`h-5 w-5 animate-spin text-blue-600 dark:text-blue-500`}):null,i===`success`?`Success`:i===`error`?`Error`:i===`loading`&&N?`Success`:i===`loading`?`Processing...`:`Tell the AI`]}),(0,X.jsx)(U,{className:`text-xs text-muted-foreground`,children:i===`input`?`Describe what you want to fix or improve, then add context below`:(0,X.jsxs)(`span`,{className:`font-mono`,children:[e.component,` • `,e.file,`:`,e.line,`:`,e.column]})})]}),i===`input`&&(0,X.jsxs)(`div`,{className:`py-5 space-y-5`,children:[(0,X.jsx)(`textarea`,{autoFocus:!0,value:h,onChange:e=>g(e.target.value),onKeyDown:k,placeholder:`What should the AI do with this?`,className:`w-full min-h-[120px] px-4 py-3 rounded-lg border border-input bg-background text-sm resize-y focus:outline-none focus:ring-2 focus:ring-ring`}),(0,X.jsx)(`div`,{className:`border-t border-border`}),(0,X.jsx)(Ln,{client:l,isClientReady:u,sourceInfo:e,selectedContext:C,onSelectionChange:w,screenshot:t,onDataReady:O,isAutomated:!!e.automated,userInput:h,selectedAgent:f})]}),i===`loading`&&p&&(0,X.jsx)(`div`,{className:`space-y-4`,children:(0,X.jsx)(Tn,{plan:p})}),(i===`success`||i===`error`)&&(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:s}),p&&(0,X.jsx)(Tn,{plan:p})]}),(0,X.jsx)(n,{className:`flex items-center gap-3 pt-2`,children:i===`input`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(o,{variant:`ghost`,size:`sm`,onClick:j,className:`mr-auto`,children:[(0,X.jsx)(rn,{className:`w-4 h-4 mr-1.5`}),`Copy & Go`]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(o,{variant:`outline`,onClick:()=>M(!0),children:`Submit & Continue`}),(0,X.jsx)(o,{onClick:()=>M(!1),children:`Submit`})]})]}):(0,X.jsx)(o,{onClick:()=>y(!1),className:`w-full`,children:`Close`})})]})})},zn=W.forwardRef(({visible:e},t)=>(0,X.jsx)(`div`,{ref:t,className:_(`fixed pointer-events-none border-2 border-blue-500 bg-blue-500/10 z-[999997]`,e?`block`:`hidden`)}));zn.displayName=`Overlay`;const Bn=W.forwardRef(({visible:e},t)=>(0,X.jsx)(`div`,{ref:t,className:_(`fixed bg-white text-slate-700 py-2 px-3 rounded-md text-xs z-[999999]`,`pointer-events-none shadow-xl font-medium border border-blue-500`,e?`block`:`hidden`)}));Bn.displayName=`Tooltip`;const Vn=(e=2500)=>{let[t,n]=(0,W.useState)(null);return{notification:t,showNotif:(0,W.useCallback)(t=>{n(t),setTimeout(()=>{n(null)},e)},[e])}};function Hn(e){let t=[],n=e;for(;n&&n.nodeType===Node.ELEMENT_NODE;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${n.id}`,t.unshift(e);break}else if(n.className&&typeof n.className==`string`){let t=n.className.trim().split(/\s+/).slice(0,2);t.length>0&&t[0]&&(e+=`.${t.join(`.`)}`)}if(t.unshift(e),n=n.parentElement,t.length>=10)break}return t.join(` > `)}function Un(e){let t=window.getComputedStyle(e),n=e.getBoundingClientRect(),r={display:t.display,position:t.position,width:t.width,height:t.height,backgroundColor:t.backgroundColor,color:t.color,fontSize:t.fontSize,padding:t.padding,margin:t.margin,border:t.border};return{tagName:e.tagName.toLowerCase(),textContent:e.textContent?.trim().slice(0,100)||``,className:e.className||``,id:e.id||``,attributes:Array.from(e.attributes).reduce((e,t)=>(!t.name.startsWith(`data-`)&&t.name!==`class`&&t.name!==`id`&&(e[t.name]=t.value),e),{}),styles:r,domPath:Hn(e),boundingBox:{top:n.top,left:n.left,width:n.width,height:n.height,right:n.right,bottom:n.bottom,x:n.x,y:n.y},computedStyles:{layout:{display:t.display,position:t.position,width:t.width,height:t.height,overflow:t.overflow,overflowX:t.overflowX,overflowY:t.overflowY,float:t.float,clear:t.clear,zIndex:t.zIndex},typography:{fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight,fontStyle:t.fontStyle,lineHeight:t.lineHeight,textAlign:t.textAlign,textDecoration:t.textDecoration,textTransform:t.textTransform,letterSpacing:t.letterSpacing,wordSpacing:t.wordSpacing,color:t.color},spacing:{padding:t.padding,paddingTop:t.paddingTop,paddingRight:t.paddingRight,paddingBottom:t.paddingBottom,paddingLeft:t.paddingLeft,margin:t.margin,marginTop:t.marginTop,marginRight:t.marginRight,marginBottom:t.marginBottom,marginLeft:t.marginLeft},background:{backgroundColor:t.backgroundColor,backgroundImage:t.backgroundImage,backgroundSize:t.backgroundSize,backgroundPosition:t.backgroundPosition,backgroundRepeat:t.backgroundRepeat},border:{border:t.border,borderTop:t.borderTop,borderRight:t.borderRight,borderBottom:t.borderBottom,borderLeft:t.borderLeft,borderRadius:t.borderRadius,borderColor:t.borderColor,borderWidth:t.borderWidth,borderStyle:t.borderStyle},effects:{opacity:t.opacity,visibility:t.visibility,boxShadow:t.boxShadow,textShadow:t.textShadow,filter:t.filter,transform:t.transform,transition:t.transition,animation:t.animation},flexbox:{flexDirection:t.flexDirection,flexWrap:t.flexWrap,justifyContent:t.justifyContent,alignItems:t.alignItems,alignContent:t.alignContent,flex:t.flex,flexGrow:t.flexGrow,flexShrink:t.flexShrink,flexBasis:t.flexBasis,order:t.order},grid:{gridTemplateColumns:t.gridTemplateColumns,gridTemplateRows:t.gridTemplateRows,gridTemplateAreas:t.gridTemplateAreas,gridGap:t.gap,gridColumnGap:t.columnGap,gridRowGap:t.rowGap,gridAutoFlow:t.gridAutoFlow,gridAutoColumns:t.gridAutoColumns,gridAutoRows:t.gridAutoRows}}}}const Wn=e=>{let t=e,n=0;for(;t&&n<20;){let r=t.getAttribute(`data-source`),i=t.getAttribute(`data-insp-path`);if(i){let t=i.split(`:`);if(t.length>=4){let n=t.pop()||``,r=t.pop()||`0`,i=t.pop()||`0`;return{file:t.join(`:`),component:n||e.tagName.toLowerCase(),apis:[],line:parseInt(i,10),column:parseInt(r,10),element:e,elementInfo:Un(e)}}}if(r){let t=r.split(`:`);if(t.length>=3){let n=t.pop()||`0`,r=t.pop()||`0`;return{file:t.join(`:`),component:e.tagName.toLowerCase(),apis:[],line:parseInt(r,10),column:parseInt(n,10),element:e,elementInfo:Un(e)}}}t=t.parentElement,n++}for(t=e,n=0;t&&n<20;){let r=Object.keys(t).find(e=>e.startsWith(`__reactInternalInstance`)||e.startsWith(`__reactFiber`)||e.startsWith(`__react`));if(r){let n=t[r];for(;n;){if(n.type&&typeof n.type==`function`){let t=n.type.name||n.type.displayName||`Anonymous`;if(t&&t!==`Anonymous`&&t!==``){let n=window.__SOURCE_INSPECTOR__&&window.__SOURCE_INSPECTOR__[t];return n?{...n,element:e,elementInfo:Un(e)}:{file:`unknown`,component:t,apis:[],line:0,column:0,element:e,elementInfo:Un(e)}}}n=n._owner||n.return}}t=t.parentElement,n++}return{file:`unknown`,component:e.tagName.toLowerCase(),apis:[],line:0,column:0,element:e,elementInfo:Un(e)}},Gn=({isActive:e,isWaitingForFeedback:t,overlayRef:n,tooltipRef:r,btnRef:i})=>{(0,W.useEffect)(()=>{if(!e||t){n.current&&(n.current.style.display=`none`),r.current&&(r.current.style.display=`none`);return}let a=e=>{let t=e.target;if(t===i.current||t===n.current||t===r.current)return;let a=t.getBoundingClientRect();if(n.current&&(n.current.style.display=`block`,n.current.style.top=a.top+`px`,n.current.style.left=a.left+`px`,n.current.style.width=a.width+`px`,n.current.style.height=a.height+`px`),r.current){let e=Wn(t),n=e.component||t.tagName.toLowerCase(),i=e.file?`${e.file.split(`/`).pop()}:${e.line}`:``;r.current.replaceChildren();let o=document.createElement(`div`);o.className=`flex items-center gap-2`;let s=document.createElement(`span`);if(s.className=`font-bold text-blue-600`,s.textContent=n,o.appendChild(s),i){let e=document.createElement(`span`);e.className=`text-slate-400 text-[10px]`,e.textContent=i,o.appendChild(e)}r.current.appendChild(o),r.current.style.display=`block`;let c=r.current.offsetHeight,l=a.top>c+4;r.current.style.left=a.left+`px`,l?(r.current.style.top=a.top-4+`px`,r.current.style.transform=`translateY(-100%)`):(r.current.style.top=a.bottom+4+`px`,r.current.style.transform=`none`);let u=r.current.getBoundingClientRect();u.right>window.innerWidth&&(r.current.style.left=window.innerWidth-u.width-10+`px`)}};return document.addEventListener(`mousemove`,a),()=>document.removeEventListener(`mousemove`,a)},[e,t,n,r,i])},Kn=({isActive:e,isWaitingForFeedback:t,onElementInspected:n,btnRef:r})=>{(0,W.useEffect)(()=>{if(!e||t)return;let i=e=>{e.target!==r.current&&(e.preventDefault(),e.stopPropagation(),n(Wn(e.target),e.target))};return document.addEventListener(`click`,i,!0),()=>document.removeEventListener(`click`,i,!0)},[e,t,n,r])};var qn=e(M(),1);function Jn(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const Yn=e=>{switch(e){case`success`:return Qn;case`info`:return er;case`warning`:return $n;case`error`:return tr;default:return null}},Xn=Array(12).fill(0),Zn=({visible:e,className:t})=>W.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},W.createElement(`div`,{className:`sonner-spinner`},Xn.map((e,t)=>W.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Qn=W.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},W.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),$n=W.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},W.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),er=W.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},W.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),tr=W.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},W.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),nr=W.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},W.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),W.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),rr=()=>{let[e,t]=W.useState(document.hidden);return W.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e};let ir=1;const Z=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:ir++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],W.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(or(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!W.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!W.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!W.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!W.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||ir++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},ar=(e,t)=>{let n=t?.id||ir++;return Z.addToast({title:e,...t,id:n}),n},or=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,sr=ar;Object.assign(sr,{success:Z.success,info:Z.info,warning:Z.warning,error:Z.error,custom:Z.custom,message:Z.message,promise:Z.promise,dismiss:Z.dismiss,loading:Z.loading},{getHistory:()=>Z.toasts,getToasts:()=>Z.getActiveToasts()}),Jn(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function cr(e){return e.label!==void 0}const lr=4e3;function ur(...e){return e.filter(Boolean).join(` `)}function dr(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}const fr=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=W.useState(null),[O,k]=W.useState(null),[A,j]=W.useState(!1),[M,N]=W.useState(!1),[P,F]=W.useState(!1),[I,L]=W.useState(!1),[ee,R]=W.useState(!1),[z,te]=W.useState(0),[B,ne]=W.useState(0),re=W.useRef(n.duration||y||lr),ie=W.useRef(null),V=W.useRef(null),H=c===0,ae=c+1<=o,U=n.type,G=n.dismissible!==!1,oe=n.className||``,se=n.descriptionClassName||``,ce=W.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),K=W.useMemo(()=>n.closeButton??p,[n.closeButton,p]),le=W.useMemo(()=>n.duration||y||lr,[n.duration,y]),ue=W.useRef(0),q=W.useRef(0),de=W.useRef(0),fe=W.useRef(null),[pe,me]=b.split(`-`),J=W.useMemo(()=>s.reduce((e,t,n)=>n>=ce?e:e+t.height,0),[s,ce]),he=rr(),ge=n.invert||t,_e=U===`loading`;q.current=W.useMemo(()=>ce*x+J,[ce,J]),W.useEffect(()=>{re.current=le},[le]),W.useEffect(()=>{j(!0)},[]),W.useEffect(()=>{let e=V.current;if(e){let t=e.getBoundingClientRect().height;return ne(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),W.useLayoutEffect(()=>{if(!A)return;let e=V.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ne(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let ve=W.useCallback(()=>{N(!0),te(q.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},200)},[n,d,a,q]);W.useEffect(()=>{if(n.promise&&U===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||he?(()=>{if(de.current<ue.current){let e=new Date().getTime()-ue.current;re.current-=e}de.current=new Date().getTime()})():re.current!==1/0&&(ue.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),ve()},re.current)),()=>clearTimeout(e)},[u,i,n,U,he,ve]),W.useEffect(()=>{n.delete&&(ve(),n.onDismiss==null||n.onDismiss.call(n,n))},[ve,n.delete]);function ye(){return w?.loading?W.createElement(`div`,{className:ur(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":U===`loading`},w.loading):W.createElement(Zn,{className:ur(C?.loader,n?.classNames?.loader),visible:U===`loading`})}let be=n.icon||w?.[U]||Yn(U);return W.createElement(`li`,{tabIndex:0,ref:V,className:ur(_,oe,C?.toast,n?.classNames?.toast,C?.default,C?.[U],n?.classNames?.[U]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":M,"data-visible":ae,"data-y-position":pe,"data-x-position":me,"data-index":c,"data-front":H,"data-swiping":P,"data-dismissible":G,"data-type":U,"data-invert":ge,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?z:q.current}px`,"--initial-height":S?`auto`:`${B}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),fe.current=null},onPointerDown:e=>{e.button!==2&&(_e||!G||(ie.current=new Date,te(q.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),fe.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!G)return;fe.current=null;let e=Number(V.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(V.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ie.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=45||a>.11){te(q.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),ve(),L(!0);return}else{var o,s;(o=V.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=V.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}R(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!fe.current||!G||window.getSelection()?.toString().length>0)return;let i=t.clientY-fe.current.y,a=t.clientX-fe.current.x,o=e.swipeDirections??dr(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&R(!0),(n=V.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=V.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},K&&!n.jsx&&U!==`loading`?W.createElement(`button`,{"aria-label":T,"data-disabled":_e,"data-close-button":!0,onClick:_e||!G?()=>{}:()=>{ve(),n.onDismiss==null||n.onDismiss.call(n,n)},className:ur(C?.closeButton,n?.classNames?.closeButton)},w?.close??nr):null,(U||n.icon||n.promise)&&n.icon!==null&&(w?.[U]!==null||n.icon)?W.createElement(`div`,{"data-icon":``,className:ur(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||ye():null,n.type===`loading`?null:be):null,W.createElement(`div`,{"data-content":``,className:ur(C?.content,n?.classNames?.content)},W.createElement(`div`,{"data-title":``,className:ur(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?W.createElement(`div`,{"data-description":``,className:ur(v,se,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),W.isValidElement(n.cancel)?n.cancel:n.cancel&&cr(n.cancel)?W.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{cr(n.cancel)&&G&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),ve())},className:ur(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,W.isValidElement(n.action)?n.action:n.action&&cr(n.action)?W.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{cr(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&ve())},className:ur(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function pr(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function mr(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?`16px`:`24px`;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}const hr=W.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=3,toastOptions:g,dir:_=pr(),gap:v=14,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=W.useState([]),C=W.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=W.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=W.useState([]),[D,O]=W.useState(!1),[k,A]=W.useState(!1),[j,M]=W.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=W.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=W.useRef(null),I=W.useRef(!1),L=W.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||Z.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return W.useEffect(()=>Z.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{qn.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),W.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),W.useEffect(()=>{x.length<=1&&O(!1)},[x]),W.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),W.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),W.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?W.createElement(`ol`,{key:t,dir:_===`auto`?pr():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":j,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`356px`,"--gap":`${v}px`,...m,...mr(l,u)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>W.createElement(fr,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:L,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),gr=({...e})=>{let{resolvedTheme:t}=N(),n=yr();return(0,X.jsx)(hr,{theme:t,className:`toaster group`,icons:{success:(0,X.jsx)(S,{className:`size-4`}),info:(0,X.jsx)(sn,{className:`size-4`}),warning:(0,X.jsx)(_n,{className:`size-4`}),error:(0,X.jsx)(un,{className:`size-4`}),loading:(0,X.jsx)(z,{className:`size-4 animate-spin`})},style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`},container:n,...e})},_r=(0,W.createContext)(null),vr=()=>(0,W.useContext)(_r),yr=vr,br=`inspector-inspection-items`;function xr(){let[e,t]=(0,W.useState)(()=>{try{let e=localStorage.getItem(br);return e?JSON.parse(e):[]}catch{return[]}});return(0,W.useEffect)(()=>{function e(e){let{plan:n,inspectionId:r}=e.detail;t(e=>e.map(e=>e.id===r?{...e,status:`in-progress`,progress:n}:e))}function n(e){let{status:n,result:r,inspectionId:i}=e.detail;t(e=>e.map(e=>e.id===i?{...e,status:n,result:r?.message||r,progress:void 0}:e))}function r(e){let{inspectionId:n}=e.detail;t(e=>e.filter(e=>e.id!==n))}return window.addEventListener(`plan-progress-reported`,e),window.addEventListener(`inspection-result-received`,n),window.addEventListener(`inspection-deleted`,r),()=>{window.removeEventListener(`plan-progress-reported`,e),window.removeEventListener(`inspection-result-received`,n),window.removeEventListener(`inspection-deleted`,r)}},[]),(0,W.useEffect)(()=>{try{localStorage.setItem(br,JSON.stringify(e))}catch{console.warn(`Failed to save inspections to localStorage`)}},[e]),{inspections:e,setInspections:t}}function Sr(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const Cr=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function wr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let Tr=null;function Er(e={}){return Tr||(e.includeStyleProperties?(Tr=e.includeStyleProperties,Tr):(Tr=wr(window.getComputedStyle(document.documentElement)),Tr))}function Dr(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function Or(e){let t=Dr(e,`border-left-width`),n=Dr(e,`border-right-width`);return e.clientWidth+t+n}function kr(e){let t=Dr(e,`border-top-width`),n=Dr(e,`border-bottom-width`);return e.clientHeight+t+n}function Ar(e,t={}){return{width:t.width||Or(e),height:t.height||kr(e)}}function jr(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const Q=16384;function Mr(e){(e.width>Q||e.height>Q)&&(e.width>Q&&e.height>Q?e.width>e.height?(e.height*=Q/e.width,e.width=Q):(e.width*=Q/e.height,e.height=Q):e.width>Q?(e.height*=Q/e.width,e.width=Q):(e.width*=Q/e.height,e.height=Q))}function Nr(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function Pr(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function Fr(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),Pr(i)}const $=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||$(n,t)};function Ir(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function Lr(e,t){return Er(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function Rr(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?Ir(n):Lr(n,r);return document.createTextNode(`${i}{${a}}`)}function zr(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=Cr();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(Rr(o,n,i,r)),t.appendChild(s)}function Br(e,t,n){zr(e,t,`:before`,n),zr(e,t,`:after`,n)}const Vr=`application/font-woff`,Hr=`image/jpeg`,Ur={woff:Vr,woff2:Vr,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:Hr,jpeg:Hr,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function Wr(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function Gr(e){return Ur[Wr(e).toLowerCase()]||``}function Kr(e){return e.split(/,/)[1]}function qr(e){return e.search(/^(data:)/)!==-1}function Jr(e,t){return`data:${t};base64,${e}`}async function Yr(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}const Xr={};function Zr(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function Qr(e,t,n){let r=Zr(e,t,n.includeQueryParams);if(Xr[r]!=null)return Xr[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=Jr(await Yr(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,Kr(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return Xr[r]=i,i}async function $r(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):Nr(t)}async function ei(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),Nr(t.toDataURL())}let n=e.poster;return Nr(await Qr(n,Gr(n),t))}async function ti(e,t){try{if(e?.contentDocument?.body)return await di(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function ni(e,t){return $(e,HTMLCanvasElement)?$r(e):$(e,HTMLVideoElement)?ei(e,t):$(e,HTMLIFrameElement)?ti(e,t):e.cloneNode(ii(e))}const ri=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,ii=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function ai(e,t,n){if(ii(t))return t;let r=[];return r=ri(e)&&e.assignedNodes?wr(e.assignedNodes()):$(e,HTMLIFrameElement)&&e.contentDocument?.body?wr(e.contentDocument.body.childNodes):wr((e.shadowRoot??e).childNodes),r.length===0||$(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>di(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function oi(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Er(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),$(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function si(e,t){$(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),$(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function ci(e,t){if($(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function li(e,t,n){return $(t,Element)&&(oi(e,t,n),Br(e,t,n),si(e,t),ci(e,t)),t}async function ui(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await di(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function di(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>ni(e,t)).then(n=>ai(e,n,t)).then(n=>li(e,n,t)).then(e=>ui(e,t))}const fi=/url\((['"]?)([^'"]+?)\1\)/g,pi=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,mi=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function hi(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function gi(e){let t=[];return e.replace(fi,(e,n,r)=>(t.push(r),e)),t.filter(e=>!qr(e))}async function _i(e,t,n,r,i){try{let a=n?Sr(t,n):t,o=Gr(t),s;return s=i?Jr(await i(a),o):await Qr(a,o,r),e.replace(hi(t),`$1${s}$3`)}catch{}return e}function vi(e,{preferredFontFormat:t}){return t?e.replace(mi,e=>{for(;;){let[n,,r]=pi.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function yi(e){return e.search(fi)!==-1}async function bi(e,t,n){if(!yi(e))return e;let r=vi(e,n);return gi(r).reduce((e,r)=>e.then(e=>_i(e,r,t,n)),Promise.resolve(r))}async function xi(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await bi(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function Si(e,t){await xi(`background`,e,t)||await xi(`background-image`,e,t),await xi(`mask`,e,t)||await xi(`-webkit-mask`,e,t)||await xi(`mask-image`,e,t)||await xi(`-webkit-mask-image`,e,t)}async function Ci(e,t){let n=$(e,HTMLImageElement);if(!(n&&!qr(e.src))&&!($(e,SVGImageElement)&&!qr(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await Qr(r,Gr(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function wi(e,t){let n=wr(e.childNodes).map(e=>Ti(e,t));await Promise.all(n).then(()=>e)}async function Ti(e,t){$(e,Element)&&(await Si(e,t),await Ci(e,t),await wi(e,t))}function Ei(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}const Di={};async function Oi(e){let t=Di[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},Di[e]=t,t)}async function ki(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),Yr(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function Ai(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function ji(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{wr(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=Oi(o).then(e=>ki(e,t)).then(e=>Ai(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(Oi(n.href).then(e=>ki(e,t)).then(e=>Ai(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{wr(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function Mi(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>yi(e.style.getPropertyValue(`src`)))}async function Ni(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return Mi(await ji(wr(e.ownerDocument.styleSheets),t))}function Pi(e){return e.trim().replace(/["']/g,``)}function Fi(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(Pi(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function Ii(e,t){let n=await Ni(e,t),r=Fi(e);return(await Promise.all(n.filter(e=>r.has(Pi(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return bi(e.cssText,n,t)}))).join(`
|
|
60
|
-
`)}async function Li(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await Ii(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function Ri(e,t={}){let{width:n,height:r}=Ar(e,t),i=await di(e,t,!0);return await Li(i,t),await Ti(i,t),Ei(i,t),await Fr(i,n,r)}async function zi(e,t={}){let{width:n,height:r}=Ar(e,t),i=await Nr(await Ri(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||jr(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||Mr(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function Bi(e,t={}){return(await zi(e,t)).toDataURL()}async function Vi(e,t={}){let{quality:n=.95,maxWidth:r=1200,maxHeight:i=800}=t;try{let t=e.getBoundingClientRect();return await Bi(e,{quality:n,pixelRatio:Math.min(1,r/t.width,i/t.height)*(window.devicePixelRatio||1),cacheBust:!0,width:t.width,height:t.height,style:{margin:`0`,transform:`none`},filter:e=>{if(e instanceof HTMLElement){let t=e.tagName.toLowerCase();if(t===`iframe`||t===`script`||t===`link`||t===`video`||t===`audio`||t===`object`||t===`embed`)return!1;if(t===`img`){let t=e;if(!t.complete||t.naturalWidth===0)return!1}}return!0},fontEmbedCSS:``})}catch(e){return console.error(`[screenshot] Failed to capture element:`,e),``}}
|
|
60
|
+
`)}async function Li(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await Ii(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function Ri(e,t={}){let{width:n,height:r}=Ar(e,t),i=await di(e,t,!0);return await Li(i,t),await Ti(i,t),Ei(i,t),await Fr(i,n,r)}async function zi(e,t={}){let{width:n,height:r}=Ar(e,t),i=await Nr(await Ri(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||jr(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||Mr(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function Bi(e,t={}){return(await zi(e,t)).toDataURL()}async function Vi(e,t={}){let{quality:n=.95,maxWidth:r=1200,maxHeight:i=800}=t;try{let t=e.getBoundingClientRect();return await Bi(e,{quality:n,pixelRatio:Math.min(1,r/t.width,i/t.height)*(window.devicePixelRatio||1),cacheBust:!0,width:t.width,height:t.height,style:{margin:`0`,transform:`none`},filter:e=>{if(e instanceof HTMLElement){let t=e.tagName.toLowerCase();if(t===`iframe`||t===`script`||t===`link`||t===`video`||t===`audio`||t===`object`||t===`embed`)return!1;if(t===`img`){let t=e;if(!t.complete||t.naturalWidth===0)return!1}}return!0},fontEmbedCSS:``})}catch(e){return console.error(`[screenshot] Failed to capture element:`,e),``}}const Hi=`inspector-inspection-items`;function Ui(){try{let e=localStorage.getItem(Hi);return e?JSON.parse(e):[]}catch{return[]}}function Wi(e){try{localStorage.setItem(Hi,JSON.stringify(e))}catch{console.warn(`Failed to save inspection items`)}}var Gi=e(L());const Ki=({request:e,client:t,isClientReady:n})=>{let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!1),l=async()=>{if(a===null){c(!0);try{let r=typeof window<`u`?window.__DEV_INSPECTOR_CONFIG__:null;if(r&&!r.disableChrome&&r.isAutomated&&t&&n)try{o(((await t.callTool({name:`chrome_devtools`,arguments:{useTool:`chrome_get_network_request`,hasDefinitions:[`chrome_get_network_request`],chrome_get_network_request:{reqid:e.reqid}}}))?.content)?.map(e=>e.text).join(`
|
|
61
61
|
`)||`No details`);return}catch{console.log(`[ContextDialog] Chrome DevTools failed, using local storage`)}let i=r?(()=>{let e=r.baseUrl||`http://${r.host}:${r.port}${r.base||`/`}`;return e.endsWith(`/`)?e.slice(0,-1):e})():``,a=await fetch(`${i}/__inspector__/request-details/${e.reqid}`);if(a.ok)o(await a.text());else throw Error(`Failed to fetch: ${a.status} ${a.statusText}`)}catch(e){o(`Failed to fetch details: ${e instanceof Error?e.message:String(e)}`)}finally{c(!1)}}};return(0,X.jsxs)(`div`,{className:`rounded-md bg-muted/50 hover:bg-muted/70 transition-colors overflow-hidden`,children:[(0,X.jsxs)(`button`,{onClick:()=>{r||l(),i(!r)},className:`w-full p-3 text-left flex items-start gap-3`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex-shrink-0`,children:r?(0,X.jsx)(p,{className:`w-4 h-4 text-muted-foreground`}):(0,X.jsx)($t,{className:`w-4 h-4 text-muted-foreground`})}),(0,X.jsx)(`span`,{className:_(`px-2 py-0.5 text-xs font-medium rounded flex-shrink-0`,(e=>{switch(e.toUpperCase()){case`GET`:return`bg-green-500/20 text-green-600`;case`POST`:return`bg-blue-500/20 text-blue-500`;case`PUT`:return`bg-yellow-500/20 text-yellow-600`;case`DELETE`:return`bg-red-500/20 text-red-500`;case`PATCH`:return`bg-purple-500/20 text-purple-500`;default:return`bg-muted text-muted-foreground`}})(e.method)),children:e.method}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`text-sm text-foreground font-mono truncate`,title:e.url,children:e.url}),(0,X.jsxs)(`div`,{className:_(`text-xs mt-1`,(e=>{let t=e.match(/\b(\d{3})\b/),n=t?parseInt(t[1]):0;return n>=200&&n<300?`text-green-600`:n>=300&&n<400?`text-yellow-600`:n>=400?`text-red-500`:e.includes(`success`)?`text-green-600`:e.includes(`failed`)?`text-red-500`:e.includes(`pending`)?`text-yellow-600`:`text-muted-foreground`})(e.status)),children:[`Status: `,e.status]})]})]}),r&&(0,X.jsx)(`div`,{className:`px-3 pb-3 pl-10`,children:(()=>{if(s)return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(z,{className:`w-4 h-4 animate-spin`}),`Loading...`]});if(!a)return null;let e=a,t=null;try{let n=a.split(`
|
|
62
62
|
`).find(e=>e.trim().startsWith(`//# sourceMappingURL=data:application/json;base64,`));if(n){let r=n.trim().substring(50),i=atob(r);t=JSON.parse(i),e=`**Source Map (Decoded):**
|
|
63
63
|
\`\`\`json
|
|
@@ -68,12 +68,12 @@ ${JSON.stringify(t,null,2)}
|
|
|
68
68
|
\`\`\`
|
|
69
69
|
${a}
|
|
70
70
|
\`\`\`
|
|
71
|
-
`}}catch{}return!t&&!a.includes(`###`)&&(a.trim().startsWith(`{`)||a.trim().startsWith(`[`))&&(e=`\`\`\`json\n${a}\n\`\`\``),(0,X.jsx)(`div`,{className:`text-xs text-foreground/90 bg-background/50 p-3 rounded overflow-x-auto max-h-[400px] overflow-y-auto border border-border`,children:(0,X.jsx)(k,{children:e})})})()})]})},
|
|
71
|
+
`}}catch{}return!t&&!a.includes(`###`)&&(a.trim().startsWith(`{`)||a.trim().startsWith(`[`))&&(e=`\`\`\`json\n${a}\n\`\`\``),(0,X.jsx)(`div`,{className:`text-xs text-foreground/90 bg-background/50 p-3 rounded overflow-x-auto max-h-[400px] overflow-y-auto border border-border`,children:(0,X.jsx)(k,{children:e})})})()})]})},qi=({open:e,onOpenChange:t,inspectionItems:n,onRemoveInspection:r,client:i,isClientReady:a})=>{let[o,s]=(0,W.useState)(`inspections`),[l,f]=(0,W.useState)(``),[p,h]=(0,W.useState)(``),[g,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(new Set),[T,E]=(0,W.useState)(new Set),[D,k]=(0,W.useState)(new Set),A=jn(),{consoleMessages:j,networkRequests:M,stdioMessages:N,loading:P,error:F,refresh:I}=Dn(i,a),L=l?j.filter(e=>e.text.toLowerCase().includes(l.toLowerCase())||e.level.toLowerCase().includes(l.toLowerCase())):j,ee=p?M.filter(e=>e.url.toLowerCase().includes(p.toLowerCase())||e.method.toLowerCase().includes(p.toLowerCase())):M,R=g?N.filter(e=>e.data.toLowerCase().includes(g.toLowerCase())||e.stream.toLowerCase().includes(g.toLowerCase())):N,te=(e,t)=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},B=async()=>{let e=[],t=C.size>0?j.filter(e=>C.has(e.msgid)):j;t.length>0&&e.push(`## Console (${t.length})\n${t.map(e=>`[${e.level}] ${e.text}`).join(`
|
|
72
72
|
`)}`);let n=T.size>0?M.filter(e=>T.has(e.reqid)):M;n.length>0&&e.push(`## Network (${n.length})\n${n.map(e=>`${e.method} ${e.url} (${e.status})`).join(`
|
|
73
73
|
`)}`);let r=D.size>0?N.filter(e=>D.has(e.stdioid)):N;r.length>0&&e.push(`## Terminal (${r.length})\n${r.map(e=>`[${e.stream}] ${e.data}`).join(`
|
|
74
74
|
`)}`),A&&e.push(`## Page\nURL: ${A.url}\nTitle: ${A.title}\nViewport: ${A.viewport.width} × ${A.viewport.height}\nLanguage: ${A.language}`);let i=e.join(`
|
|
75
75
|
|
|
76
|
-
`);i&&(await navigator.clipboard.writeText(i),S(!0),setTimeout(()=>S(!1),2e3))},ne=()=>C.size+T.size+D.size;(0,W.useEffect)(()=>{e&&I()},[e,I]);let re=[{id:`inspections`,label:`Inspections`,count:n.length},{id:`console`,label:`Console`,count:j.length},{id:`network`,label:`Network`,count:M.length},{id:`page`,label:`Page`},{id:`stdio`,label:`Terminal`,count:N.length}];return(0,X.jsx)(d,{open:e,onOpenChange:t,children:(0,X.jsxs)(m,{className:`w-[70vw] max-w-[70vw] h-[80vh] max-h-[80vh] flex flex-col`,onClose:()=>t(!1),children:[(0,X.jsx)(v,{className:`flex-shrink-0 pr-8`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsx)(c,{children:`Full Page Context`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:B,disabled:P,className:`flex items-center gap-1.5 px-2 h-8 text-xs border border-border bg-background hover:bg-accent rounded-md transition-colors disabled:opacity-50`,title:ne()>0?`Copy ${ne()} selected items`:`Copy all context`,children:[x?(0,X.jsx)(Qt,{className:`w-3.5 h-3.5 text-green-500`}):(0,X.jsx)(rn,{className:`w-3.5 h-3.5`}),(0,X.jsx)(`span`,{children:ne()>0?`Copy (${ne()})`:`Copy All`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>I(),disabled:P,className:`flex items-center justify-center w-8 h-8 text-sm border border-border bg-background hover:bg-accent rounded-md transition-colors disabled:opacity-50`,title:`Refresh Data`,children:(0,X.jsx)(u,{className:_(`w-3.5 h-3.5`,P&&`animate-spin`)})})]})]})}),(0,X.jsx)(`div`,{className:`flex gap-1 border-b border-border flex-shrink-0`,children:re.map(e=>(0,X.jsxs)(`button`,{onClick:()=>s(e.id),className:_(`px-4 py-2 text-sm font-medium transition-colors relative`,o===e.id?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.label,e.count!==void 0&&e.count>0&&(0,X.jsx)(`span`,{className:`ml-2 px-1.5 py-0.5 text-xs bg-muted rounded-full`,children:e.count}),o===e.id&&(0,X.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-foreground`})]},e.id))}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-auto min-h-0`,children:[F&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-destructive bg-destructive/10 rounded-md m-4`,children:[(0,X.jsx)(tn,{className:`w-4 h-4 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`break-all`,children:F})]}),o===`inspections`&&(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:n.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:[(0,X.jsx)(`p`,{className:`text-sm`,children:`No inspections`}),(0,X.jsx)(`p`,{className:`text-xs mt-1`,children:`Use ⌥I to inspect elements`})]}):(0,X.jsx)(O,{items:n,onRemove:r})}),o===`console`&&(0,X.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[(0,X.jsxs)(`div`,{className:`relative mb-2`,children:[(0,X.jsx)(pn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`text`,value:l,onChange:e=>f(e.target.value),placeholder:`Filter logs...`,className:`w-full pl-7 pr-7 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),l&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),P&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!P&&L.length===0&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,X.jsx)(`p`,{className:`text-sm`,children:l?`No matching logs`:`No console logs`})}),!P&&L.map(e=>(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors cursor-pointer`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:C.has(e.msgid),onChange:()=>te(e.msgid,w),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`span`,{className:_(`px-2 py-0.5 text-xs font-medium rounded flex-shrink-0`,e.level===`error`&&`bg-red-500/20 text-red-500`,e.level===`warn`&&`bg-yellow-500/20 text-yellow-600`,e.level===`info`&&`bg-blue-500/20 text-blue-500`,e.level===`log`&&`bg-muted text-muted-foreground`,e.level===`debug`&&`bg-purple-500/20 text-purple-500`),children:e.level}),(0,X.jsx)(`span`,{className:`text-sm text-foreground/90 flex-1 font-mono break-all overflow-hidden`,children:e.text})]},e.msgid))]}),o===`network`&&(0,X.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[(0,X.jsxs)(`div`,{className:`relative mb-2`,children:[(0,X.jsx)(pn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`text`,value:p,onChange:e=>h(e.target.value),placeholder:`Filter requests...`,className:`w-full pl-7 pr-7 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),p&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),P&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!P&&ee.length===0&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,X.jsx)(`p`,{className:`text-sm`,children:p?`No matching requests`:`No network requests`})}),!P&&ee.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:T.has(e.reqid),onChange:()=>te(e.reqid,E),className:`mt-3 rounded border-border flex-shrink-0`}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,X.jsx)(Ui,{request:e,client:i,isClientReady:a})})]},e.reqid))]}),o===`stdio`&&(0,X.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[(0,X.jsxs)(`div`,{className:`relative mb-2`,children:[(0,X.jsx)(pn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`text`,value:g,onChange:e=>b(e.target.value),placeholder:`Filter terminal...`,className:`w-full pl-7 pr-7 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),g&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>b(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),P&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!P&&R.length===0&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,X.jsx)(`p`,{className:`text-sm`,children:g?`No matching messages`:`No terminal messages`})}),!P&&R.map(e=>(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors cursor-pointer`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:D.has(e.stdioid),onChange:()=>te(e.stdioid,k),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`span`,{className:_(`px-2 py-0.5 text-xs font-medium rounded flex-shrink-0 uppercase`,e.stream===`stderr`?`bg-red-500/20 text-red-500`:`bg-blue-500/20 text-blue-500`),children:e.stream}),(0,X.jsx)(`pre`,{className:`text-sm text-foreground/90 flex-1 font-mono break-all overflow-hidden whitespace-pre-wrap`,children:e.data})]},e.stdioid))]}),o===`page`&&(0,X.jsx)(`div`,{className:`p-4 h-full overflow-auto`,children:A?(0,X.jsx)(`div`,{className:`space-y-4`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-md bg-muted/50`,children:[(0,X.jsx)(on,{className:`w-5 h-5 text-primary mt-0.5 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`URL`}),(0,X.jsx)(`div`,{className:`text-sm text-foreground font-mono break-all`,children:A.url})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Title`}),(0,X.jsx)(`div`,{className:`text-sm text-foreground`,children:A.title})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Viewport`}),(0,X.jsxs)(`div`,{className:`text-sm text-foreground`,children:[A.viewport.width,` × `,A.viewport.height]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Language`}),(0,X.jsx)(`div`,{className:`text-sm text-foreground`,children:A.language})]})]})]})]})}):(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})})})]})]})})};function Gi({initialOffset:e={x:0,y:0}}={}){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(e),a=(0,W.useRef)({x:0,y:0}),o=(0,W.useRef)({x:0,y:0}),s=(0,W.useCallback)(()=>{if(t.current){let{x:e,y:n}=i.current;t.current.style.transform=`translate3d(calc(-50% + ${e}px), ${n}px, 0)`}},[]),c=(0,W.useCallback)(e=>{e.target.closest(`button, input, a, [data-no-drag]`)||(e.preventDefault(),r(!0),a.current={x:e.clientX,y:e.clientY},o.current={...i.current})},[]);return(0,W.useEffect)(()=>{let e=e=>{if(!n)return;let t=e.clientX-a.current.x,r=e.clientY-a.current.y;i.current={x:o.current.x+t,y:o.current.y+r},s()},t=()=>{r(!1)};return n&&(window.addEventListener(`mousemove`,e,{passive:!0}),window.addEventListener(`mouseup`,t)),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[n,s]),(0,W.useEffect)(()=>{s()},[s]),{elementRef:t,isDragging:n,handleMouseDown:c}}const Ki=({prompts:e,onSelect:t,visible:n})=>!n||e.length===0?null:(0,X.jsx)(`div`,{className:_(`absolute bottom-full left-0 pb-3 ml-1 flex flex-wrap gap-2 max-w-[480px]`,`origin-bottom-left`),children:e.map((e,n)=>(0,X.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(e)},style:{animationDelay:`${n*50}ms`,opacity:0,animation:`prompt-fade-in 0.3s ease-out ${n*50}ms forwards`},className:_(`flex items-center gap-1.5 px-3 py-1.5 rounded-full`,`bg-muted/90 backdrop-blur-md border border-border shadow-sm`,`text-xs font-medium text-foreground`,`hover:bg-accent hover:border-accent-foreground/20 hover:scale-105 active:scale-95`,`transition-all duration-200`),title:e.description||e.title||e.name,children:(0,X.jsx)(`span`,{children:e.title||e.name})},e.name))}),qi=({isActive:e,onToggleInspector:t,onSubmitAgent:n,onCancel:r,isAgentWorking:i,messages:a,status:o,inspectionCount:u=0,inspectionItems:f=[],onRemoveInspection:p=()=>{},toolsReady:h=!0,mcpClient:g=null,onAgentChange:y,onToggleRegionMode:x,isRegionModeActive:T=!1})=>{let[D,O]=(0,W.useState)(!1),[k,M]=(0,W.useState)(``),[N,P]=(0,W.useState)(`none`),[L,ee]=(0,W.useState)(!0),[R,z]=(0,W.useState)(!1),{agent:B,setAgent:ne,isReady:V}=te(w),[H,G]=(0,W.useState)(j),[oe,se]=(0,W.useState)(!1),[ce,K]=(0,W.useState)(null),[le,ue]=(0,W.useState)(!1),{prompts:q}=F(g||null);(0,W.useEffect)(()=>{ie().then(e=>{G(e)})},[]),(0,W.useEffect)(()=>{V&&B&&y?.(B)},[B,V,y]);let{uiState:de,chatStatus:fe,toolName:pe,displayText:me}=A(a,o,D),J=fe===`submitted`||fe===`streaming`,he=de===`expanded`&&!J,ge=a.length>0&&fe!==`error`||J,[_e,ve]=(0,W.useState)(null),ye=(0,W.useRef)(null),be=(0,W.useRef)(!1),xe=e=>{let t=`${I()}/api/acp/cleanup-session`,n=JSON.stringify({sessionId:e});try{if(navigator.sendBeacon){let e=new Blob([n],{type:`application/json`});navigator.sendBeacon(t,e);return}}catch{}fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0}).catch(()=>{})};(0,W.useEffect)(()=>{if(!V||!h)return;let e=!0,t=H.find(e=>e.name===B)||H[0]||j[0];return(async()=>{if(ye.current){try{await fetch(`${I()}/api/acp/cleanup-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:ye.current})})}catch(e){console.warn(`[InspectorBar] Failed to cleanup previous session:`,e)}ye.current=null,e&&ve(null)}console.log(`[InspectorBar] Initializing session for ${t.name}...`);try{let n=await fetch(`${I()}/api/acp/init-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agent:t,envVars:{}})});if(!n.ok)throw Error(`Failed to init session`);let r=await n.json();e&&r.sessionId&&(console.log(`[InspectorBar] Session initialized: ${r.sessionId}`),ve(r.sessionId),ye.current=r.sessionId,be.current=!1)}catch(e){console.error(`[InspectorBar] Failed to initialize session:`,e)}})(),()=>{e=!1}},[B,V,h,H]),(0,W.useEffect)(()=>{let e=()=>{let e=ye.current;!e||be.current||(be.current=!0,xe(e))};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e)}},[]),(0,W.useEffect)(()=>()=>{let e=ye.current;!e||be.current||(be.current=!0,console.log(`[InspectorBar] Cleaning up session on unmount: ${e}`),xe(e))},[]);let Se=H.find(e=>e.name===B)||H[0]||j[0],{elementRef:Ce,isDragging:we,handleMouseDown:Te}=Gi(),[Y,Ee]=(0,W.useState)(null),De=(0,W.useRef)(null);(0,W.useEffect)(()=>{D&&De.current&&De.current.focus()},[D]),(0,W.useEffect)(()=>{if(!J&&!L){let e=setTimeout(()=>{ee(!0)},2e3);return()=>clearTimeout(e)}},[J,L]),(0,W.useEffect)(()=>{function e(e){let{plan:t,inspectionId:n}=e.detail;if(t?.steps){let e=t.steps.find(e=>e.status===`in-progress`),r=t.steps.filter(e=>e.status===`completed`).length;Ee({id:n,status:`in-progress`,currentStep:e?{title:e.title,index:r+1,total:t.steps.length}:void 0})}}function t(e){let{status:t,result:n,inspectionId:r}=e.detail;Ee({id:r,status:t,message:n?.message||n})}return window.addEventListener(`plan-progress-reported`,e),window.addEventListener(`inspection-result-received`,t),()=>{window.removeEventListener(`plan-progress-reported`,e),window.removeEventListener(`inspection-result-received`,t)}},[]);let[Oe,ke]=(0,W.useState)(null),Ae=async(e,t={})=>{if(g)try{let n=(await g.request({method:`prompts/get`,params:{name:e.name,arguments:t}},E)).messages?.[0];if(n?.content?.type===`text`&&n.content.text){M(n.content.text),De.current?.focus();return}}catch(e){console.error(`Failed to execute prompt:`,e)}M(e.template||e.description||e.name),De.current?.focus()},je=async e=>{if(e.arguments&&e.arguments.length>0){ke(e);return}await Ae(e)},Me=e=>{Oe&&(Ae(Oe,e),ke(null))},Ne=e=>{e.preventDefault(),k.trim()&&(Ee(null),n(k,H.find(e=>e.name===B)||H[0]||j[0],_e||void 0),M(``),P(`chat`))},Pe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ne(e)),e.key===`Escape`&&(O(!1),De.current?.blur())},Fe=o===`error`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(re,{prompt:Oe,isOpen:!!Oe,onOpenChange:e=>!e&&ke(null),onSubmit:Me}),(D||N!==`none`)&&(0,X.jsx)(`div`,{className:`fixed inset-0 z-[999998] bg-transparent`,onClick:()=>{!J&&!R&&(O(!1),P(`none`))}}),(0,X.jsxs)(`div`,{ref:Ce,className:_(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,D?`w-[480px]`:ge?`w-auto min-w-[200px] max-w-[480px]`:`w-[190px]`,we?`cursor-grabbing`:`cursor-grab`),onMouseDown:Te,onMouseEnter:()=>{!we&&L&&O(!0)},onMouseLeave:()=>{R||(!k.trim()&&!we&&(O(!1),P(`none`)),ee(!0))},children:[(0,X.jsx)(Ki,{prompts:q,visible:D&&!J&&N===`none`&&q.length>0,onSelect:je}),(0,X.jsxs)(`div`,{className:_(`relative flex items-center backdrop-blur-xl shadow-2xl border border-border`,`transition-[width,height,padding,background-color,border-color] duration-200 ease-out`,D?`h-12 p-2 pl-4`:`h-9 px-2 py-1`,N===`none`?`bg-muted/90 rounded-full`:`bg-muted/95 rounded-b-lg rounded-t-none border-t-0`,Fe&&!D&&`bg-destructive/10 border-destructive/20`),children:[(0,X.jsxs)(`div`,{className:_(`flex items-center transition-opacity duration-150 w-full relative`,he?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[a.length===0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:(0,X.jsx)(`img`,{src:Se?.meta?.icon,alt:B,className:`w-3.5 h-3.5`})}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3 whitespace-nowrap`,children:`⌥I or hover to inspect`})]}),ge&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,X.jsx)(`div`,{className:`relative flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:J?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-1 rounded-full border-2 border-current opacity-20 animate-ping text-foreground`}),(0,X.jsx)(`img`,{src:Se?.meta?.icon,alt:B,className:`w-3.5 h-3.5 animate-pulse`})]}):Y?Y.status===`in-progress`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-1 rounded-full border-2 border-current opacity-20 animate-ping text-blue-500`}),(0,X.jsx)(s,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):Y.status===`completed`?(0,X.jsx)(S,{className:`w-5 h-5 text-green-500`}):(0,X.jsx)(b,{className:`w-5 h-5 text-red-500`}):Fe?(0,X.jsx)(b,{className:`w-5 h-5 text-red-500`}):(0,X.jsx)(S,{className:`w-5 h-5 text-green-500`})}),(0,X.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,X.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0 pl-2`,children:(0,X.jsx)(`div`,{className:`flex flex-col min-w-0 max-w-full pr-2 max-h-[24px] overflow-hidden`,children:Y&&Y.status===`in-progress`&&Y.currentStep?(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,X.jsx)(s,{className:`w-4 h-4 flex-shrink-0`}),(0,X.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,Y.currentStep.index,`/`,Y.currentStep.total,`: `,Y.currentStep.title]})]}):Y?.message?(0,X.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:Y.message}):pe?(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,X.jsx)(s,{className:`w-4 h-4 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`truncate min-w-0`,children:pe})]}):(0,X.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:J&&!me?(0,X.jsx)(ae,{duration:2,spread:2,children:o===`submitted`&&Se?.command===`npx`?`Starting ${Se.name}... This may take a moment.`:`Thinking...`}):me||`Processing...`})})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>P(e=>e===`chat`?`none`:`chat`),className:_(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,N===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:N===`chat`?`Collapse`:`Expand messages`,children:(0,X.jsx)(en,{className:_(`w-3.5 h-3.5 transition-transform duration-300`,N===`chat`&&`rotate-180`)})}),J&&(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-7 h-7 rounded-full bg-destructive text-destructive-foreground transition-all flex-shrink-0 hover:bg-destructive/90`,title:`Cancel request`,children:(0,X.jsx)(gn,{className:`w-3 h-3`})})]})]})]}),(0,X.jsxs)(`div`,{className:_(`flex items-center w-full gap-3 transition-all duration-150`,he?`opacity-100 translate-y-0 relative pointer-events-auto`:`opacity-0 translate-y-4 pointer-events-none absolute top-2 left-4 right-2`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ue(!0),className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,`hover:bg-accent/50`,le&&`bg-accent/50 text-foreground`),title:`Context`,children:[(0,X.jsx)(l,{className:`w-3.5 h-3.5`}),u>0&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center min-w-[12px] h-[12px] px-0.5 text-[8px] font-bold text-white bg-red-500 rounded-full border border-background shadow-sm leading-none`,children:u>99?`99+`:u})]}),(0,X.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,X.jsx)(`button`,{onClick:x,className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,T?`bg-purple-500 text-white shadow-[0_0_15px_rgba(168,85,247,0.5)]`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:`Region Select Mode`,children:(0,X.jsx)(hn,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{onClick:t,className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,e?`bg-blue-500 text-white shadow-[0_0_15px_rgba(59,130,246,0.5)]`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:`Toggle Inspector (⌥I)`,children:(0,X.jsx)(an,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`}),(0,X.jsxs)(`form`,{onSubmit:Ne,className:`flex-1 flex items-center gap-2 min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>se(!oe),className:`flex items-center justify-center w-7 h-7 rounded-full hover:bg-accent/50 transition-colors`,title:`Select Agent`,children:(0,X.jsx)(`img`,{src:H.find(e=>e.name===B)?.meta?.icon,alt:B,className:`w-3.5 h-3.5`})}),oe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>se(!1)}),(0,X.jsx)(`div`,{className:`absolute bottom-full left-0 mb-2 w-64 bg-popover border border-border rounded-lg shadow-lg overflow-hidden z-[999999] animate-in fade-in zoom-in-95 duration-200`,children:H.map(e=>(0,X.jsxs)(`div`,{className:_(`w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-accent transition-colors group`,B===e.name&&`bg-accent/50 font-medium`),children:[(0,X.jsxs)(`button`,{onClick:()=>{ne(e.name),se(!1)},className:`flex items-center gap-2 flex-1 text-left`,children:[e.meta?.icon&&(0,X.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`flex-1`,children:e.name})]}),(e.configHint||e.configLink)&&(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),K(e.name)},className:`p-1 rounded hover:bg-accent-foreground/10 transition-colors`,title:`Configuration info`,children:(0,X.jsx)(sn,{className:`w-3.5 h-3.5 text-muted-foreground`})})]},e.name))})]})]}),(0,X.jsx)(`input`,{ref:De,type:`text`,value:k,onChange:e=>M(e.target.value),onKeyDown:Pe,placeholder:`Ask ${B}...`,className:`w-full bg-transparent border-none outline-none text-foreground placeholder-muted-foreground text-sm h-7 disabled:opacity-50`,tabIndex:0,disabled:J}),(a.length>0||J)&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>P(e=>e===`chat`?`none`:`chat`),className:_(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,N===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:N===`chat`?`Collapse`:`Expand messages`,children:(0,X.jsx)(en,{className:_(`w-3.5 h-3.5 transition-transform duration-300`,N===`chat`&&`rotate-180`)})}),J?(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-7 h-7 rounded-full bg-destructive text-destructive-foreground transition-all flex-shrink-0 hover:bg-destructive/90`,title:`Cancel request`,children:(0,X.jsx)(gn,{className:`w-3 h-3`})}):(0,X.jsx)(`button`,{type:`submit`,disabled:!k.trim(),className:_(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,k.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,X.jsx)(Zt,{className:`w-3.5 h-3.5`})})]})]})]}),N!==`none`&&(0,X.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[480px] mx-auto animate-panel-in`,children:(0,X.jsxs)(`div`,{className:`bg-muted/95 backdrop-blur-xl rounded-t-xl border border-border border-b-0 shadow-2xl overflow-hidden relative`,children:[ge&&(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),z(!R)},className:_(`absolute top-3 left-3 z-10 flex items-center justify-center w-8 h-8 rounded-full transition-all`,R?`bg-black text-white shadow-md hover:bg-gray-800`:`bg-muted/80 text-muted-foreground hover:bg-accent hover:text-foreground`),title:R?`Unpin inspector`:`Pin inspector`,children:R?(0,X.jsx)(fn,{className:`w-3.5 h-3.5 fill-current`}):(0,X.jsx)(fn,{className:`w-3.5 h-3.5`})}),N===`chat`&&(0,X.jsx)(`div`,{className:`h-[500px]`,children:(0,X.jsx)(C,{messages:a,status:o,selectedAgent:B})})]})})]}),(0,X.jsx)(Wi,{open:le,onOpenChange:ue,inspectionItems:f,onRemoveInspection:p,client:g,isClientReady:h}),ce&&(()=>{let e=H.find(e=>e.name===ce);return e?(0,X.jsx)(d,{open:!!ce,onOpenChange:()=>K(null),children:(0,X.jsxs)(m,{onClose:()=>K(null),className:`w-80`,children:[(0,X.jsxs)(v,{children:[(0,X.jsxs)(c,{className:`flex items-center gap-3`,children:[e.meta?.icon&&(0,X.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-6 h-6`}),e.name]}),e.configHint&&(0,X.jsx)(U,{children:e.configHint})]}),e.configLink&&(0,X.jsx)(`a`,{href:e.configLink,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-blue-500 hover:text-blue-600 underline`,children:`View ACP Documentation →`})]})}):null})()]})},Ji=(e,t,n)=>{let r=Math.max(e.left,t.left),i=Math.max(e.top,t.top),a=Math.min(e.right,t.left+t.width),o=Math.min(e.bottom,t.top+t.height),s=Math.max(0,a-r)*Math.max(0,o-i),c=e.width*e.height+n-s;return c>0?s/c:0},Yi=({isActive:e,onSelectionComplete:t,onCancel:n,onClose:r})=>{let[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)([]),[g,v]=(0,W.useState)(null),[b,x]=(0,W.useState)(``),S=(0,W.useRef)(null),C=(0,W.useRef)(null);(0,W.useEffect)(()=>{g!==null&&C.current&&C.current.focus()},[g]);let w=()=>{d(!1),p(null),h([]),a(null),s(null),l(!1),v(null),x(``)};(0,W.useEffect)(()=>{if(!e){w();return}let t=e=>{e.key===`Escape`&&(g===null?u?w():n():v(null))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n,u,g]);let T=()=>!i||!o?null:{left:Math.min(i.x,o.x),top:Math.min(i.y,o.y),width:Math.abs(o.x-i.x),height:Math.abs(o.y-i.y)},E=e=>{u||e.button===0&&(e.stopPropagation(),e.preventDefault(),l(!0),a({x:e.clientX,y:e.clientY}),s({x:e.clientX,y:e.clientY}))},D=e=>{u||c&&(e.stopPropagation(),e.preventDefault(),s({x:e.clientX,y:e.clientY}))},O=e=>{if(u||!c||!i||!o)return;e.stopPropagation(),e.preventDefault(),l(!1);let t=T();t&&t.width>5&&t.height>5?(p(t),k(t),d(!0)):(a(null),s(null))},k=e=>{let t=document.body.querySelectorAll(`*`),n=[],r=e.width*e.height;for(let i=0;i<t.length;i++){let a=t[i];if(a===S.current||S.current?.contains(a))continue;let o=a.tagName.toLowerCase();if(o===`dev-inspector-mcp`||o===`html`||o===`body`)continue;let s=a.getBoundingClientRect();if(s.right<e.left||s.left>e.left+e.width||s.bottom<e.top||s.top>e.top+e.height)continue;let c=s.left+s.width/2,l=s.top+s.height/2;if(!(c>=e.left&&c<=e.left+e.width&&l>=e.top&&l<=e.top+e.height))continue;if(a.checkVisibility){if(!a.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))continue}else{if(s.width===0||s.height===0)continue;let e=window.getComputedStyle(a);if(e.display===`none`||e.visibility===`hidden`||e.opacity===`0`)continue}let u=Ji(s,e,r);n.push({el:a,rect:s,iou:u})}if(n.length===0){d(!1),a(null),s(null);return}n.sort((e,t)=>t.iou-e.iou);let i=n[0].el;for(let e of n){let t=Wn(e.el);if(t.file&&t.file!==`unknown`){i=e.el;break}}let o=[],c=Wn(i);o.push({el:i,rect:i.getBoundingClientRect(),info:c,isPrimary:!0});let l=0;for(let e of n){if(e.el===i)continue;if(l>=50)break;let t=Wn(e.el);t.file&&t.file!==`unknown`&&(o.push({el:e.el,rect:e.rect,info:t,isPrimary:!1}),l++)}o.sort((e,t)=>{let n=e.rect.width*e.rect.height;return t.rect.width*t.rect.height-n}),h(o)},A=e=>{if(g===null)return;let t=typeof e==`string`?e:b,n=[...m];n[g].note=t.trim()||void 0,h(n),v(null)},j=()=>{if(m.length===0)return;let e=m.find(e=>e.isPrimary)||m[0],n={...e.info};e.note&&(n.note=e.note),n.relatedElements=m.filter(t=>t!==e).map(e=>{let{computedStyles:t,styles:n,...r}=e.info.elementInfo||{};return{...e.info,elementInfo:r,note:e.note}}),t(n)};if(!e)return null;let M=u?f:T();return(0,X.jsxs)(`div`,{ref:S,className:_(`fixed inset-0 z-[2147483646]`,u?`cursor-default pointer-events-auto`:`cursor-crosshair pointer-events-auto`),onMouseDown:E,onMouseMove:D,onMouseUp:O,children:[M&&(0,X.jsx)(`div`,{className:`absolute border-2 border-blue-500 bg-blue-500/5 z-50 pointer-events-none`,style:{left:M.left,top:M.top,width:M.width,height:M.height},children:(0,X.jsxs)(`div`,{className:`absolute -top-10 left-0 flex gap-2 pointer-events-auto`,children:[(0,X.jsxs)(`div`,{className:`bg-blue-600 text-white text-xs px-2 py-1.5 rounded shadow-sm font-medium`,children:[Math.round(M.width),` x `,Math.round(M.height)]}),u&&(0,X.jsxs)(`button`,{onClick:j,className:`bg-zinc-900 hover:bg-zinc-800 text-white text-xs px-3 py-1.5 rounded shadow-sm font-medium flex items-center gap-1.5 transition-colors`,children:[(0,X.jsx)(Qt,{className:`w-3.5 h-3.5`}),`Finish & Inspect`]}),u&&(0,X.jsxs)(`button`,{onClick:r,className:`bg-white text-zinc-700 hover:bg-zinc-50 border border-zinc-200 text-xs px-3 py-1.5 rounded shadow-sm font-medium transition-colors flex items-center gap-1.5`,children:[(0,X.jsx)(y,{className:`w-3.5 h-3.5`}),`Close`]})]})}),u&&m.map((e,t)=>(0,X.jsxs)(`div`,{className:_(`absolute border transition-all duration-200 cursor-pointer group`,e.note?`border-yellow-400 bg-yellow-400/10 z-20`:e.isPrimary?`border-blue-400/50 hover:border-blue-500 bg-blue-500/5 hover:bg-blue-500/10`:`border-slate-300/30 hover:border-blue-400 hover:bg-blue-400/10`),style:{left:e.rect.left,top:e.rect.top,width:e.rect.width,height:e.rect.height},onClick:n=>{n.stopPropagation(),v(t),x(e.note||``)},children:[e.note&&(0,X.jsx)(`div`,{className:`absolute -top-2.5 -right-2.5 w-5 h-5 bg-yellow-400 text-yellow-900 rounded-full flex items-center justify-center shadow-sm z-30`,children:(0,X.jsx)(ln,{className:`w-3 h-3`})}),!e.note&&(0,X.jsx)(`div`,{className:`absolute top-1 right-1 opacity-0 group-hover:opacity-100 transition-opacity bg-white/90 p-1 rounded shadow-sm`,children:(0,X.jsx)(dn,{className:`w-3 h-3 text-slate-600`})})]},t)),g!==null&&m[g]&&(0,X.jsxs)(`div`,{className:`absolute z-50 bg-white rounded-lg shadow-xl border border-slate-200 p-3 w-64 animate-in fade-in zoom-in-95 duration-100`,style:{left:Math.min(window.innerWidth-280,Math.max(10,m[g].rect.right+10)),top:Math.min(window.innerHeight-250,Math.max(10,m[g].rect.top))},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsxs)(`span`,{className:`text-xs font-semibold text-slate-600 flex items-center gap-1.5`,children:[(0,X.jsx)(ln,{className:`w-3.5 h-3.5`}),`Add Annotation`]}),(0,X.jsx)(`button`,{onClick:()=>v(null),className:`text-slate-400 hover:text-slate-600`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),(0,X.jsxs)(`div`,{className:`text-[10px] text-slate-400 font-mono mb-2 truncate`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-slate-600`,children:m[g].info.component||`Element`}),(0,X.jsx)(`span`,{className:`mx-1.5 opacity-50`,children:`•`}),m[g].info.file?`${m[g].info.file.split(`/`).pop()}:${m[g].info.line}`:`Unknown Location`]}),(0,X.jsx)(`input`,{ref:C,type:`text`,value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&A(),e.key===`Escape`&&v(null)},placeholder:`E.g. Wrong color, missing padding...`,className:`w-full text-xs border border-slate-200 rounded px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 mb-2`}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{onClick:()=>{x(``),A(``)},className:`text-xs text-slate-500 hover:text-slate-700 px-2 py-1`,children:`Clear`}),(0,X.jsx)(`button`,{onClick:()=>A(),className:`text-xs bg-zinc-900 hover:bg-zinc-800 text-white px-2 py-1 rounded`,children:`Save`})]})]})]})},Xi=({shadowRoot:e,mountPoint:t})=>{let{client:n,isClientReady:r}=V(),{resolvedTheme:i}=N(),a=B(),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(null),{inspections:m,setInspections:h}=xr(),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)(!1),{messages:w,sendMessage:T,status:E,stop:D}=H({transport:new g({api:`${I()}/api/acp/chat`})}),O=()=>{D()},k=(0,W.useRef)(null),A=(0,W.useRef)(null),j=(0,W.useRef)(null),{notification:M,showNotif:P}=Vn();(0,W.useEffect)(()=>{e&&e.host&&(i===`dark`?e.host.classList.add(`dark`):e.host.classList.remove(`dark`))},[i,e]),(0,W.useEffect)(()=>{let e=sessionStorage.getItem(`inspector-current-inspection-id`);e&&(m.some(t=>t.id===e)||sessionStorage.removeItem(`inspector-current-inspection-id`))},[m]);let F=(0,W.useCallback)(()=>{let e=!o;s(e),C(!1),document.body.style.cursor=e?`crosshair`:``,e?p(null):(k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`),p(null)),P(e?`Inspector ON`:`Inspector OFF`)},[o,P]),L=(0,W.useCallback)(()=>{p(null),s(!1),C(!1),document.body.style.cursor=``,k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`)},[]),ee=(0,W.useCallback)(()=>{if(!o){s(!0),C(!0),p(null),P(`Region Mode: ON`);return}let e=!S;C(e),e?(p(null),document.body.style.cursor=`default`):document.body.style.cursor=`crosshair`},[o,S,P]);(0,W.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&o){L();return}e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyI`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),F()),e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyS`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),ee())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,F,L,ee]),(0,W.useEffect)(()=>{let e=()=>{o||(s(!0),document.body.style.cursor=`crosshair`,p(null),P(`Inspector ON`))};return window.addEventListener(`activate-inspector`,e),()=>window.removeEventListener(`activate-inspector`,e)},[o,P]),(0,W.useEffect)(()=>{let e=()=>{s(!0),C(!0),p(null),document.body.style.cursor=`default`,P(`Area Mode: ON`)};return window.addEventListener(`activate-area-select`,e),()=>window.removeEventListener(`activate-area-select`,e)},[P]),(0,W.useEffect)(()=>{let e=async e=>{let{selector:t,containerSelector:n,bounds:r}=e.detail||{},i=[],a=null;try{if(t){let e=document.querySelector(t);e&&(a=e,i=[e])}else if(n){let e=document.querySelector(n);if(e){a=e;let t=e.querySelectorAll(`*`);i=[e,...Array.from(t).filter(e=>{let t=e.tagName.toLowerCase(),n=[`button`,`a`,`input`,`select`,`textarea`,`img`,`video`,`audio`].includes(t),r=e.textContent?.trim(),i=e.id,a=e.className;return n||r||i||a}).slice(0,50)]}}else if(r){let{x:e,y:t,width:n,height:o}=r,s=document.querySelectorAll(`*`);i=Array.from(s).filter(r=>{let i=r.getBoundingClientRect();return i.left<e+n&&i.right>e&&i.top<t+o&&i.bottom>t&&i.width>0&&i.height>0}).slice(0,50),a=i[0]||null}if(!a||i.length===0){window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{error:`No elements found matching the criteria`}}));return}let e=Wn(a),o=i.slice(1).map(e=>{let t=Wn(e);return{file:t.file,component:t.component,line:t.line,column:t.column,elementInfo:t.elementInfo}}),s;a.isConnected&&(s=await Vi(a));let c=`inspection-${Date.now()}`,l=t?`Auto-captured: ${t}`:n?`Auto-captured container: ${n} (${i.length} elements)`:`Auto-captured bounds: ${r?.width}x${r?.height} at (${r?.x}, ${r?.y}) (${i.length} elements)`,u={id:c,sourceInfo:{file:e.file,component:e.component,line:e.line,column:e.column,elementInfo:e.elementInfo,relatedElements:o.length>0?o:void 0},description:l,status:`pending`,timestamp:Date.now(),selectedContext:{includeElement:!0,includeStyles:!1,consoleIds:[],networkIds:[],screenshot:s}};h(e=>[...e,u]),window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:[u]}}))}catch(e){let t=e instanceof Error?e.message:String(e);window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{error:`Automated capture failed: ${t}`}}))}};return window.addEventListener(`automated-capture`,e),()=>window.removeEventListener(`automated-capture`,e)},[h]),Gn({isActive:o&&!S,isWaitingForFeedback:f!==null,overlayRef:k,tooltipRef:A,btnRef:j});let R=async e=>{if(e.element){let t=e.element;await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,50)})}),t.isConnected?d(await Vi(t)):d(``)}if(l(e),e.automated){let t={id:`inspection-${Date.now()}`,sourceInfo:{file:e.file,component:e.component,line:e.line,column:e.column,elementInfo:e.elementInfo},description:`Auto-captured via automation`,status:`pending`,timestamp:Date.now()};h(e=>[...e,t]),window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:[t]}})),s(!1),document.body.style.cursor=``,k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`)}else p(`input`),k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`)};return(0,W.useEffect)(()=>{let e=e=>{let t=e;if(t.detail){let e=t.detail.info||t.detail;e&&e.file&&R({...e,automated:!0})}};return window.addEventListener(`dev-inspector:inspect-element`,e),()=>window.removeEventListener(`dev-inspector:inspect-element`,e)},[]),Kn({isActive:o&&!S,isWaitingForFeedback:f!==null,onElementInspected:R,btnRef:j}),(0,X.jsx)(`div`,{className:_(`font-sans antialiased w-full h-full pointer-events-none fixed inset-0`,i===`dark`&&`dark`),children:(0,X.jsxs)(_r.Provider,{value:t||null,children:[(0,X.jsx)(`div`,{className:`pointer-events-auto`,children:a&&(0,X.jsx)(qi,{toolsReady:r,mcpClient:n,isActive:o,onToggleInspector:F,onSubmitAgent:(e,t,n)=>{T({text:e},{body:{agent:t,envVars:{},sessionId:n}})},onCancel:O,isAgentWorking:E===`streaming`||E===`submitted`,messages:w,status:E,inspectionCount:m.length,inspectionItems:m,onRemoveInspection:e=>{h(t=>t.filter(t=>t.id!==e))},onAgentChange:x,onToggleRegionMode:ee,isRegionModeActive:S})}),o&&S&&(0,X.jsx)(Yi,{isActive:!0,onSelectionComplete:async e=>{e.element&&e.element.isConnected?d(await Vi(e.element)):d(``),window.dispatchEvent(new CustomEvent(`area-selection-complete`,{detail:{sourceInfo:e}})),l(e),p(`input`),C(!1),s(!1),P(`Region: ${(e.relatedElements?.length||0)+1} elements`)},onCancel:()=>C(!1),onClose:F}),(0,X.jsx)(zn,{ref:k,visible:o&&f===null&&!S}),(0,X.jsx)(Bn,{ref:A,visible:o&&f===null&&!S}),M&&(0,X.jsx)(Xt,{message:M}),f&&c&&(0,X.jsx)(`div`,{className:`pointer-events-auto`,children:(0,X.jsx)(Rn,{sourceInfo:c,screenshot:u,mode:f,onSubmit:(e,t=!1,n)=>{if(!c)return;let r=c.relatedElements&&c.relatedElements.length>0,i=e;!i&&r&&(i=`Region: ${(c.relatedElements?.length||0)+1} elements (primary: ${c.elementInfo?.tagName.toLowerCase()||`element`})${c.note||c.relatedElements?.some(e=>e.note)?`. Please read notes on these elements.`:``}`);let a=i||e,o={id:`inspection-${Date.now()}`,sourceInfo:{file:c.file,component:c.component,line:c.line,column:c.column,elementInfo:c.elementInfo,relatedElements:c.relatedElements?.map(e=>({file:e.file,component:e.component,line:e.line,column:e.column,elementInfo:e.elementInfo?{tagName:e.elementInfo.tagName,textContent:e.elementInfo.textContent,className:e.elementInfo.className,id:e.elementInfo.id,styles:e.elementInfo.styles||{}}:void 0,note:e.note}))},description:a,status:`pending`,timestamp:Date.now(),selectedContext:n};h(e=>[...e,o]);let l=[...v,o];y(l),p(null),t?(s(!0),document.body.style.cursor=`crosshair`,P(`Saved (${l.length})`)):(window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:l}})),y([]),s(!1),document.body.style.cursor=``,P(`${l.length} inspection${l.length>1?`s`:``} saved`))},onClose:L,client:n,isClientReady:r,selectedAgent:b||void 0})}),(0,X.jsx)(gr,{})]})})};var Zi=class extends HTMLElement{connectedCallback(){this.style.cssText=`
|
|
76
|
+
`);i&&(await navigator.clipboard.writeText(i),S(!0),setTimeout(()=>S(!1),2e3))},ne=()=>C.size+T.size+D.size;(0,W.useEffect)(()=>{e&&I()},[e,I]);let re=[{id:`inspections`,label:`Inspections`,count:n.length},{id:`console`,label:`Console`,count:j.length},{id:`network`,label:`Network`,count:M.length},{id:`page`,label:`Page`},{id:`stdio`,label:`Terminal`,count:N.length}];return(0,X.jsx)(d,{open:e,onOpenChange:t,children:(0,X.jsxs)(m,{className:`w-[70vw] max-w-[70vw] h-[80vh] max-h-[80vh] flex flex-col`,onClose:()=>t(!1),children:[(0,X.jsx)(v,{className:`flex-shrink-0 pr-8`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsx)(c,{children:`Full Page Context`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:B,disabled:P,className:`flex items-center gap-1.5 px-2 h-8 text-xs border border-border bg-background hover:bg-accent rounded-md transition-colors disabled:opacity-50`,title:ne()>0?`Copy ${ne()} selected items`:`Copy all context`,children:[x?(0,X.jsx)(Qt,{className:`w-3.5 h-3.5 text-green-500`}):(0,X.jsx)(rn,{className:`w-3.5 h-3.5`}),(0,X.jsx)(`span`,{children:ne()>0?`Copy (${ne()})`:`Copy All`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>I(),disabled:P,className:`flex items-center justify-center w-8 h-8 text-sm border border-border bg-background hover:bg-accent rounded-md transition-colors disabled:opacity-50`,title:`Refresh Data`,children:(0,X.jsx)(u,{className:_(`w-3.5 h-3.5`,P&&`animate-spin`)})})]})]})}),(0,X.jsx)(`div`,{className:`flex gap-1 border-b border-border flex-shrink-0`,children:re.map(e=>(0,X.jsxs)(`button`,{onClick:()=>s(e.id),className:_(`px-4 py-2 text-sm font-medium transition-colors relative`,o===e.id?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.label,e.count!==void 0&&e.count>0&&(0,X.jsx)(`span`,{className:`ml-2 px-1.5 py-0.5 text-xs bg-muted rounded-full`,children:e.count}),o===e.id&&(0,X.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-foreground`})]},e.id))}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-auto min-h-0`,children:[F&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-destructive bg-destructive/10 rounded-md m-4`,children:[(0,X.jsx)(tn,{className:`w-4 h-4 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`break-all`,children:F})]}),o===`inspections`&&(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:n.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:[(0,X.jsx)(`p`,{className:`text-sm`,children:`No inspections`}),(0,X.jsx)(`p`,{className:`text-xs mt-1`,children:`Use ⌥I to inspect elements`})]}):(0,X.jsx)(O,{items:n,onRemove:r})}),o===`console`&&(0,X.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[(0,X.jsxs)(`div`,{className:`relative mb-2`,children:[(0,X.jsx)(pn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`text`,value:l,onChange:e=>f(e.target.value),placeholder:`Filter logs...`,className:`w-full pl-7 pr-7 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),l&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),P&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!P&&L.length===0&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,X.jsx)(`p`,{className:`text-sm`,children:l?`No matching logs`:`No console logs`})}),!P&&L.map(e=>(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors cursor-pointer`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:C.has(e.msgid),onChange:()=>te(e.msgid,w),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`span`,{className:_(`px-2 py-0.5 text-xs font-medium rounded flex-shrink-0`,e.level===`error`&&`bg-red-500/20 text-red-500`,e.level===`warn`&&`bg-yellow-500/20 text-yellow-600`,e.level===`info`&&`bg-blue-500/20 text-blue-500`,e.level===`log`&&`bg-muted text-muted-foreground`,e.level===`debug`&&`bg-purple-500/20 text-purple-500`),children:e.level}),(0,X.jsx)(`span`,{className:`text-sm text-foreground/90 flex-1 font-mono break-all overflow-hidden`,children:e.text})]},e.msgid))]}),o===`network`&&(0,X.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[(0,X.jsxs)(`div`,{className:`relative mb-2`,children:[(0,X.jsx)(pn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`text`,value:p,onChange:e=>h(e.target.value),placeholder:`Filter requests...`,className:`w-full pl-7 pr-7 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),p&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),P&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!P&&ee.length===0&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,X.jsx)(`p`,{className:`text-sm`,children:p?`No matching requests`:`No network requests`})}),!P&&ee.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:T.has(e.reqid),onChange:()=>te(e.reqid,E),className:`mt-3 rounded border-border flex-shrink-0`}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,X.jsx)(Ki,{request:e,client:i,isClientReady:a})})]},e.reqid))]}),o===`stdio`&&(0,X.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[(0,X.jsxs)(`div`,{className:`relative mb-2`,children:[(0,X.jsx)(pn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`text`,value:g,onChange:e=>b(e.target.value),placeholder:`Filter terminal...`,className:`w-full pl-7 pr-7 py-1.5 text-xs rounded border border-border bg-background focus:outline-none focus:ring-1 focus:ring-ring`}),g&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>b(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),P&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!P&&R.length===0&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,X.jsx)(`p`,{className:`text-sm`,children:g?`No matching messages`:`No terminal messages`})}),!P&&R.map(e=>(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors cursor-pointer`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:D.has(e.stdioid),onChange:()=>te(e.stdioid,k),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`span`,{className:_(`px-2 py-0.5 text-xs font-medium rounded flex-shrink-0 uppercase`,e.stream===`stderr`?`bg-red-500/20 text-red-500`:`bg-blue-500/20 text-blue-500`),children:e.stream}),(0,X.jsx)(`pre`,{className:`text-sm text-foreground/90 flex-1 font-mono break-all overflow-hidden whitespace-pre-wrap`,children:e.data})]},e.stdioid))]}),o===`page`&&(0,X.jsx)(`div`,{className:`p-4 h-full overflow-auto`,children:A?(0,X.jsx)(`div`,{className:`space-y-4`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-md bg-muted/50`,children:[(0,X.jsx)(on,{className:`w-5 h-5 text-primary mt-0.5 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`URL`}),(0,X.jsx)(`div`,{className:`text-sm text-foreground font-mono break-all`,children:A.url})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Title`}),(0,X.jsx)(`div`,{className:`text-sm text-foreground`,children:A.title})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Viewport`}),(0,X.jsxs)(`div`,{className:`text-sm text-foreground`,children:[A.viewport.width,` × `,A.viewport.height]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Language`}),(0,X.jsx)(`div`,{className:`text-sm text-foreground`,children:A.language})]})]})]})]})}):(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(z,{className:`w-6 h-6 animate-spin text-muted-foreground`})})})]})]})})};function Ji({initialOffset:e={x:0,y:0}}={}){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(e),a=(0,W.useRef)({x:0,y:0}),o=(0,W.useRef)({x:0,y:0}),s=(0,W.useCallback)(()=>{if(t.current){let{x:e,y:n}=i.current;t.current.style.transform=`translate3d(calc(-50% + ${e}px), ${n}px, 0)`}},[]),c=(0,W.useCallback)(e=>{e.target.closest(`button, input, a, [data-no-drag]`)||(e.preventDefault(),r(!0),a.current={x:e.clientX,y:e.clientY},o.current={...i.current})},[]);return(0,W.useEffect)(()=>{let e=e=>{if(!n)return;let t=e.clientX-a.current.x,r=e.clientY-a.current.y;i.current={x:o.current.x+t,y:o.current.y+r},s()},t=()=>{r(!1)};return n&&(window.addEventListener(`mousemove`,e,{passive:!0}),window.addEventListener(`mouseup`,t)),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[n,s]),(0,W.useEffect)(()=>{s()},[s]),{elementRef:t,isDragging:n,handleMouseDown:c}}const Yi=({prompts:e,onSelect:t,visible:n})=>!n||e.length===0?null:(0,X.jsx)(`div`,{className:_(`absolute bottom-full left-0 pb-3 ml-1 flex flex-wrap gap-2 max-w-[480px]`,`origin-bottom-left`),children:e.map((e,n)=>(0,X.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(e)},style:{animationDelay:`${n*50}ms`,opacity:0,animation:`prompt-fade-in 0.3s ease-out ${n*50}ms forwards`},className:_(`flex items-center gap-1.5 px-3 py-1.5 rounded-full`,`bg-muted/90 backdrop-blur-md border border-border shadow-sm`,`text-xs font-medium text-foreground`,`hover:bg-accent hover:border-accent-foreground/20 hover:scale-105 active:scale-95`,`transition-all duration-200`),title:e.description||e.title||e.name,children:(0,X.jsx)(`span`,{children:e.title||e.name})},e.name))}),Xi=({isActive:e,onToggleInspector:t,onSubmitAgent:n,onCancel:r,isAgentWorking:i,messages:a,status:o,inspectionCount:u=0,inspectionItems:f=[],onRemoveInspection:p=()=>{},toolsReady:h=!0,mcpClient:g=null,onAgentChange:y,onToggleRegionMode:x,isRegionModeActive:T=!1})=>{let[D,O]=(0,W.useState)(!1),[k,M]=(0,W.useState)(``),[N,P]=(0,W.useState)(`none`),[L,ee]=(0,W.useState)(!0),[R,z]=(0,W.useState)(!1),{agent:B,setAgent:ne,isReady:V}=te(w),[H,G]=(0,W.useState)(j),[oe,se]=(0,W.useState)(!1),[ce,K]=(0,W.useState)(null),[le,ue]=(0,W.useState)(!1),{prompts:q}=F(g||null);(0,W.useEffect)(()=>{ie().then(e=>{G(e)})},[]),(0,W.useEffect)(()=>{V&&B&&y?.(B)},[B,V,y]);let{uiState:de,chatStatus:fe,toolName:pe,displayText:me}=A(a,o,D),J=fe===`submitted`||fe===`streaming`,he=de===`expanded`&&!J,ge=a.length>0&&fe!==`error`||J,[_e,ve]=(0,W.useState)(null),ye=(0,W.useRef)(null),be=(0,W.useRef)(!1),xe=e=>{let t=`${I()}/api/acp/cleanup-session`,n=JSON.stringify({sessionId:e});try{if(navigator.sendBeacon){let e=new Blob([n],{type:`application/json`});navigator.sendBeacon(t,e);return}}catch{}fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0}).catch(()=>{})};(0,W.useEffect)(()=>{if(!V||!h)return;let e=!0,t=H.find(e=>e.name===B)||H[0]||j[0];return(async()=>{if(ye.current){try{await fetch(`${I()}/api/acp/cleanup-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:ye.current})})}catch(e){console.warn(`[InspectorBar] Failed to cleanup previous session:`,e)}ye.current=null,e&&ve(null)}console.log(`[InspectorBar] Initializing session for ${t.name}...`);try{let n=await fetch(`${I()}/api/acp/init-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agent:t,envVars:{}})});if(!n.ok)throw Error(`Failed to init session`);let r=await n.json();e&&r.sessionId&&(console.log(`[InspectorBar] Session initialized: ${r.sessionId}`),ve(r.sessionId),ye.current=r.sessionId,be.current=!1)}catch(e){console.error(`[InspectorBar] Failed to initialize session:`,e)}})(),()=>{e=!1}},[B,V,h,H]),(0,W.useEffect)(()=>{let e=()=>{let e=ye.current;!e||be.current||(be.current=!0,xe(e))};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e)}},[]),(0,W.useEffect)(()=>()=>{let e=ye.current;!e||be.current||(be.current=!0,console.log(`[InspectorBar] Cleaning up session on unmount: ${e}`),xe(e))},[]);let Se=H.find(e=>e.name===B)||H[0]||j[0],{elementRef:Ce,isDragging:we,handleMouseDown:Te}=Ji(),[Y,Ee]=(0,W.useState)(null),De=(0,W.useRef)(null);(0,W.useEffect)(()=>{D&&De.current&&De.current.focus()},[D]),(0,W.useEffect)(()=>{if(!J&&!L){let e=setTimeout(()=>{ee(!0)},2e3);return()=>clearTimeout(e)}},[J,L]),(0,W.useEffect)(()=>{function e(e){let{plan:t,inspectionId:n}=e.detail;if(t?.steps){let e=t.steps.find(e=>e.status===`in-progress`),r=t.steps.filter(e=>e.status===`completed`).length;Ee({id:n,status:`in-progress`,currentStep:e?{title:e.title,index:r+1,total:t.steps.length}:void 0})}}function t(e){let{status:t,result:n,inspectionId:r}=e.detail;Ee({id:r,status:t,message:n?.message||n})}return window.addEventListener(`plan-progress-reported`,e),window.addEventListener(`inspection-result-received`,t),()=>{window.removeEventListener(`plan-progress-reported`,e),window.removeEventListener(`inspection-result-received`,t)}},[]);let[Oe,ke]=(0,W.useState)(null),Ae=async(e,t={})=>{if(g)try{let n=(await g.request({method:`prompts/get`,params:{name:e.name,arguments:t}},E)).messages?.[0];if(n?.content?.type===`text`&&n.content.text){M(n.content.text),De.current?.focus();return}}catch(e){console.error(`Failed to execute prompt:`,e)}M(e.template||e.description||e.name),De.current?.focus()},je=async e=>{if(e.arguments&&e.arguments.length>0){ke(e);return}await Ae(e)},Me=e=>{Oe&&(Ae(Oe,e),ke(null))},Ne=e=>{e.preventDefault(),k.trim()&&(Ee(null),n(k,H.find(e=>e.name===B)||H[0]||j[0],_e||void 0),M(``),P(`chat`))},Pe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ne(e)),e.key===`Escape`&&(O(!1),De.current?.blur())},Fe=o===`error`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(re,{prompt:Oe,isOpen:!!Oe,onOpenChange:e=>!e&&ke(null),onSubmit:Me}),(D||N!==`none`)&&(0,X.jsx)(`div`,{className:`fixed inset-0 z-[999998] bg-transparent`,onClick:()=>{!J&&!R&&(O(!1),P(`none`))}}),(0,X.jsxs)(`div`,{ref:Ce,className:_(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,D?`w-[480px]`:ge?`w-auto min-w-[200px] max-w-[480px]`:`w-[190px]`,we?`cursor-grabbing`:`cursor-grab`),onMouseDown:Te,onMouseEnter:()=>{!we&&L&&O(!0)},onMouseLeave:()=>{R||(!k.trim()&&!we&&(O(!1),P(`none`)),ee(!0))},children:[(0,X.jsx)(Yi,{prompts:q,visible:D&&!J&&N===`none`&&q.length>0,onSelect:je}),(0,X.jsxs)(`div`,{className:_(`relative flex items-center backdrop-blur-xl shadow-2xl border border-border`,`transition-[width,height,padding,background-color,border-color] duration-200 ease-out`,D?`h-12 p-2 pl-4`:`h-9 px-2 py-1`,N===`none`?`bg-muted/90 rounded-full`:`bg-muted/95 rounded-b-lg rounded-t-none border-t-0`,Fe&&!D&&`bg-destructive/10 border-destructive/20`),children:[(0,X.jsxs)(`div`,{className:_(`flex items-center transition-opacity duration-150 w-full relative`,he?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[a.length===0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:(0,X.jsx)(`img`,{src:Se?.meta?.icon,alt:B,className:`w-3.5 h-3.5`})}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3 whitespace-nowrap`,children:`⌥I or hover to inspect`})]}),ge&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,X.jsx)(`div`,{className:`relative flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:J?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-1 rounded-full border-2 border-current opacity-20 animate-ping text-foreground`}),(0,X.jsx)(`img`,{src:Se?.meta?.icon,alt:B,className:`w-3.5 h-3.5 animate-pulse`})]}):Y?Y.status===`in-progress`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-1 rounded-full border-2 border-current opacity-20 animate-ping text-blue-500`}),(0,X.jsx)(s,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):Y.status===`completed`?(0,X.jsx)(S,{className:`w-5 h-5 text-green-500`}):(0,X.jsx)(b,{className:`w-5 h-5 text-red-500`}):Fe?(0,X.jsx)(b,{className:`w-5 h-5 text-red-500`}):(0,X.jsx)(S,{className:`w-5 h-5 text-green-500`})}),(0,X.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,X.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0 pl-2`,children:(0,X.jsx)(`div`,{className:`flex flex-col min-w-0 max-w-full pr-2 max-h-[24px] overflow-hidden`,children:Y&&Y.status===`in-progress`&&Y.currentStep?(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,X.jsx)(s,{className:`w-4 h-4 flex-shrink-0`}),(0,X.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,Y.currentStep.index,`/`,Y.currentStep.total,`: `,Y.currentStep.title]})]}):Y?.message?(0,X.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:Y.message}):pe?(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,X.jsx)(s,{className:`w-4 h-4 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`truncate min-w-0`,children:pe})]}):(0,X.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:J&&!me?(0,X.jsx)(ae,{duration:2,spread:2,children:o===`submitted`&&Se?.command===`npx`?`Starting ${Se.name}... This may take a moment.`:`Thinking...`}):me||`Processing...`})})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>P(e=>e===`chat`?`none`:`chat`),className:_(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,N===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:N===`chat`?`Collapse`:`Expand messages`,children:(0,X.jsx)(en,{className:_(`w-3.5 h-3.5 transition-transform duration-300`,N===`chat`&&`rotate-180`)})}),J&&(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-7 h-7 rounded-full bg-destructive text-destructive-foreground transition-all flex-shrink-0 hover:bg-destructive/90`,title:`Cancel request`,children:(0,X.jsx)(gn,{className:`w-3 h-3`})})]})]})]}),(0,X.jsxs)(`div`,{className:_(`flex items-center w-full gap-3 transition-all duration-150`,he?`opacity-100 translate-y-0 relative pointer-events-auto`:`opacity-0 translate-y-4 pointer-events-none absolute top-2 left-4 right-2`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ue(!0),className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,`hover:bg-accent/50`,le&&`bg-accent/50 text-foreground`),title:`Context`,children:[(0,X.jsx)(l,{className:`w-3.5 h-3.5`}),u>0&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center min-w-[12px] h-[12px] px-0.5 text-[8px] font-bold text-white bg-red-500 rounded-full border border-background shadow-sm leading-none`,children:u>99?`99+`:u})]}),(0,X.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,X.jsx)(`button`,{onClick:x,className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,T?`bg-purple-500 text-white shadow-[0_0_15px_rgba(168,85,247,0.5)]`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:`Region Select Mode`,children:(0,X.jsx)(hn,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{onClick:t,className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,e?`bg-blue-500 text-white shadow-[0_0_15px_rgba(59,130,246,0.5)]`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:`Toggle Inspector (⌥I)`,children:(0,X.jsx)(an,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`}),(0,X.jsxs)(`form`,{onSubmit:Ne,className:`flex-1 flex items-center gap-2 min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>se(!oe),className:`flex items-center justify-center w-7 h-7 rounded-full hover:bg-accent/50 transition-colors`,title:`Select Agent`,children:(0,X.jsx)(`img`,{src:H.find(e=>e.name===B)?.meta?.icon,alt:B,className:`w-3.5 h-3.5`})}),oe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>se(!1)}),(0,X.jsx)(`div`,{className:`absolute bottom-full left-0 mb-2 w-64 bg-popover border border-border rounded-lg shadow-lg overflow-hidden z-[999999] animate-in fade-in zoom-in-95 duration-200`,children:H.map(e=>(0,X.jsxs)(`div`,{className:_(`w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-accent transition-colors group`,B===e.name&&`bg-accent/50 font-medium`),children:[(0,X.jsxs)(`button`,{onClick:()=>{ne(e.name),se(!1)},className:`flex items-center gap-2 flex-1 text-left`,children:[e.meta?.icon&&(0,X.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`flex-1`,children:e.name})]}),(e.configHint||e.configLink)&&(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),K(e.name)},className:`p-1 rounded hover:bg-accent-foreground/10 transition-colors`,title:`Configuration info`,children:(0,X.jsx)(sn,{className:`w-3.5 h-3.5 text-muted-foreground`})})]},e.name))})]})]}),(0,X.jsx)(`input`,{ref:De,type:`text`,value:k,onChange:e=>M(e.target.value),onKeyDown:Pe,placeholder:`Ask ${B}...`,className:`w-full bg-transparent border-none outline-none text-foreground placeholder-muted-foreground text-sm h-7 disabled:opacity-50`,tabIndex:0,disabled:J}),(a.length>0||J)&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>P(e=>e===`chat`?`none`:`chat`),className:_(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,N===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:N===`chat`?`Collapse`:`Expand messages`,children:(0,X.jsx)(en,{className:_(`w-3.5 h-3.5 transition-transform duration-300`,N===`chat`&&`rotate-180`)})}),J?(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-7 h-7 rounded-full bg-destructive text-destructive-foreground transition-all flex-shrink-0 hover:bg-destructive/90`,title:`Cancel request`,children:(0,X.jsx)(gn,{className:`w-3 h-3`})}):(0,X.jsx)(`button`,{type:`submit`,disabled:!k.trim(),className:_(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,k.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,X.jsx)(Zt,{className:`w-3.5 h-3.5`})})]})]})]}),N!==`none`&&(0,X.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[480px] mx-auto animate-panel-in`,children:(0,X.jsxs)(`div`,{className:`bg-muted/95 backdrop-blur-xl rounded-t-xl border border-border border-b-0 shadow-2xl overflow-hidden relative`,children:[ge&&(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),z(!R)},className:_(`absolute top-3 left-3 z-10 flex items-center justify-center w-8 h-8 rounded-full transition-all`,R?`bg-black text-white shadow-md hover:bg-gray-800`:`bg-muted/80 text-muted-foreground hover:bg-accent hover:text-foreground`),title:R?`Unpin inspector`:`Pin inspector`,children:R?(0,X.jsx)(fn,{className:`w-3.5 h-3.5 fill-current`}):(0,X.jsx)(fn,{className:`w-3.5 h-3.5`})}),N===`chat`&&(0,X.jsx)(`div`,{className:`h-[500px]`,children:(0,X.jsx)(C,{messages:a,status:o,selectedAgent:B})})]})})]}),(0,X.jsx)(qi,{open:le,onOpenChange:ue,inspectionItems:f,onRemoveInspection:p,client:g,isClientReady:h}),ce&&(()=>{let e=H.find(e=>e.name===ce);return e?(0,X.jsx)(d,{open:!!ce,onOpenChange:()=>K(null),children:(0,X.jsxs)(m,{onClose:()=>K(null),className:`w-80`,children:[(0,X.jsxs)(v,{children:[(0,X.jsxs)(c,{className:`flex items-center gap-3`,children:[e.meta?.icon&&(0,X.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-6 h-6`}),e.name]}),e.configHint&&(0,X.jsx)(U,{children:e.configHint})]}),e.configLink&&(0,X.jsx)(`a`,{href:e.configLink,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-blue-500 hover:text-blue-600 underline`,children:`View ACP Documentation →`})]})}):null})()]})},Zi=(e,t,n)=>{let r=Math.max(e.left,t.left),i=Math.max(e.top,t.top),a=Math.min(e.right,t.left+t.width),o=Math.min(e.bottom,t.top+t.height),s=Math.max(0,a-r)*Math.max(0,o-i),c=e.width*e.height+n-s;return c>0?s/c:0},Qi=({isActive:e,onSelectionComplete:t,onCancel:n,onClose:r})=>{let[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)([]),[g,v]=(0,W.useState)(null),[b,x]=(0,W.useState)(``),S=(0,W.useRef)(null),C=(0,W.useRef)(null);(0,W.useEffect)(()=>{g!==null&&C.current&&C.current.focus()},[g]);let w=()=>{d(!1),p(null),h([]),a(null),s(null),l(!1),v(null),x(``)};(0,W.useEffect)(()=>{if(!e){w();return}let t=e=>{e.key===`Escape`&&(g===null?u?w():n():v(null))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n,u,g]);let T=()=>!i||!o?null:{left:Math.min(i.x,o.x),top:Math.min(i.y,o.y),width:Math.abs(o.x-i.x),height:Math.abs(o.y-i.y)},E=e=>{u||e.button===0&&(e.stopPropagation(),e.preventDefault(),l(!0),a({x:e.clientX,y:e.clientY}),s({x:e.clientX,y:e.clientY}))},D=e=>{u||c&&(e.stopPropagation(),e.preventDefault(),s({x:e.clientX,y:e.clientY}))},O=e=>{if(u||!c||!i||!o)return;e.stopPropagation(),e.preventDefault(),l(!1);let t=T();t&&t.width>5&&t.height>5?(p(t),k(t),d(!0)):(a(null),s(null))},k=e=>{let t=document.body.querySelectorAll(`*`),n=[],r=e.width*e.height;for(let i=0;i<t.length;i++){let a=t[i];if(a===S.current||S.current?.contains(a))continue;let o=a.tagName.toLowerCase();if(o===`dev-inspector-mcp`||o===`html`||o===`body`)continue;let s=a.getBoundingClientRect();if(s.right<e.left||s.left>e.left+e.width||s.bottom<e.top||s.top>e.top+e.height)continue;let c=s.left+s.width/2,l=s.top+s.height/2;if(!(c>=e.left&&c<=e.left+e.width&&l>=e.top&&l<=e.top+e.height))continue;if(a.checkVisibility){if(!a.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))continue}else{if(s.width===0||s.height===0)continue;let e=window.getComputedStyle(a);if(e.display===`none`||e.visibility===`hidden`||e.opacity===`0`)continue}let u=Zi(s,e,r);n.push({el:a,rect:s,iou:u})}if(n.length===0){d(!1),a(null),s(null);return}n.sort((e,t)=>t.iou-e.iou);let i=n[0].el;for(let e of n){let t=Wn(e.el);if(t.file&&t.file!==`unknown`){i=e.el;break}}let o=[],c=Wn(i);o.push({el:i,rect:i.getBoundingClientRect(),info:c,isPrimary:!0});let l=0;for(let e of n){if(e.el===i)continue;if(l>=50)break;let t=Wn(e.el);t.file&&t.file!==`unknown`&&(o.push({el:e.el,rect:e.rect,info:t,isPrimary:!1}),l++)}o.sort((e,t)=>{let n=e.rect.width*e.rect.height;return t.rect.width*t.rect.height-n}),h(o)},A=e=>{if(g===null)return;let t=typeof e==`string`?e:b,n=[...m];n[g].note=t.trim()||void 0,h(n),v(null)},j=()=>{if(m.length===0)return;let e=m.find(e=>e.isPrimary)||m[0],n={...e.info};e.note&&(n.note=e.note),n.relatedElements=m.filter(t=>t!==e).map(e=>{let{computedStyles:t,styles:n,...r}=e.info.elementInfo||{};return{...e.info,elementInfo:r,note:e.note}}),t(n)};if(!e)return null;let M=u?f:T();return(0,X.jsxs)(`div`,{ref:S,className:_(`fixed inset-0 z-[2147483646]`,u?`cursor-default pointer-events-auto`:`cursor-crosshair pointer-events-auto`),onMouseDown:E,onMouseMove:D,onMouseUp:O,children:[M&&(0,X.jsx)(`div`,{className:`absolute border-2 border-blue-500 bg-blue-500/5 z-50 pointer-events-none`,style:{left:M.left,top:M.top,width:M.width,height:M.height},children:(0,X.jsxs)(`div`,{className:`absolute -top-10 left-0 flex gap-2 pointer-events-auto`,children:[(0,X.jsxs)(`div`,{className:`bg-blue-600 text-white text-xs px-2 py-1.5 rounded shadow-sm font-medium`,children:[Math.round(M.width),` x `,Math.round(M.height)]}),u&&(0,X.jsxs)(`button`,{onClick:j,className:`bg-zinc-900 hover:bg-zinc-800 text-white text-xs px-3 py-1.5 rounded shadow-sm font-medium flex items-center gap-1.5 transition-colors`,children:[(0,X.jsx)(Qt,{className:`w-3.5 h-3.5`}),`Finish & Inspect`]}),u&&(0,X.jsxs)(`button`,{onClick:r,className:`bg-white text-zinc-700 hover:bg-zinc-50 border border-zinc-200 text-xs px-3 py-1.5 rounded shadow-sm font-medium transition-colors flex items-center gap-1.5`,children:[(0,X.jsx)(y,{className:`w-3.5 h-3.5`}),`Close`]})]})}),u&&m.map((e,t)=>(0,X.jsxs)(`div`,{className:_(`absolute border transition-all duration-200 cursor-pointer group`,e.note?`border-yellow-400 bg-yellow-400/10 z-20`:e.isPrimary?`border-blue-400/50 hover:border-blue-500 bg-blue-500/5 hover:bg-blue-500/10`:`border-slate-300/30 hover:border-blue-400 hover:bg-blue-400/10`),style:{left:e.rect.left,top:e.rect.top,width:e.rect.width,height:e.rect.height},onClick:n=>{n.stopPropagation(),v(t),x(e.note||``)},children:[e.note&&(0,X.jsx)(`div`,{className:`absolute -top-2.5 -right-2.5 w-5 h-5 bg-yellow-400 text-yellow-900 rounded-full flex items-center justify-center shadow-sm z-30`,children:(0,X.jsx)(ln,{className:`w-3 h-3`})}),!e.note&&(0,X.jsx)(`div`,{className:`absolute top-1 right-1 opacity-0 group-hover:opacity-100 transition-opacity bg-white/90 p-1 rounded shadow-sm`,children:(0,X.jsx)(dn,{className:`w-3 h-3 text-slate-600`})})]},t)),g!==null&&m[g]&&(0,X.jsxs)(`div`,{className:`absolute z-50 bg-white rounded-lg shadow-xl border border-slate-200 p-3 w-64 animate-in fade-in zoom-in-95 duration-100`,style:{left:Math.min(window.innerWidth-280,Math.max(10,m[g].rect.right+10)),top:Math.min(window.innerHeight-250,Math.max(10,m[g].rect.top))},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsxs)(`span`,{className:`text-xs font-semibold text-slate-600 flex items-center gap-1.5`,children:[(0,X.jsx)(ln,{className:`w-3.5 h-3.5`}),`Add Annotation`]}),(0,X.jsx)(`button`,{onClick:()=>v(null),className:`text-slate-400 hover:text-slate-600`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]}),(0,X.jsxs)(`div`,{className:`text-[10px] text-slate-400 font-mono mb-2 truncate`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-slate-600`,children:m[g].info.component||`Element`}),(0,X.jsx)(`span`,{className:`mx-1.5 opacity-50`,children:`•`}),m[g].info.file?`${m[g].info.file.split(`/`).pop()}:${m[g].info.line}`:`Unknown Location`]}),(0,X.jsx)(`input`,{ref:C,type:`text`,value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&A(),e.key===`Escape`&&v(null)},placeholder:`E.g. Wrong color, missing padding...`,className:`w-full text-xs border border-slate-200 rounded px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 mb-2`}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{onClick:()=>{x(``),A(``)},className:`text-xs text-slate-500 hover:text-slate-700 px-2 py-1`,children:`Clear`}),(0,X.jsx)(`button`,{onClick:()=>A(),className:`text-xs bg-zinc-900 hover:bg-zinc-800 text-white px-2 py-1 rounded`,children:`Save`})]})]})]})},$i=({shadowRoot:e,mountPoint:t})=>{let{client:n,isClientReady:r}=V(),{resolvedTheme:i}=N(),a=B(),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(null),{inspections:m,setInspections:h}=xr(),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)(!1),{messages:w,sendMessage:T,status:E,stop:D}=H({transport:new g({api:`${I()}/api/acp/chat`})}),O=()=>{D()},k=(0,W.useRef)(null),A=(0,W.useRef)(null),j=(0,W.useRef)(null),{notification:M,showNotif:P}=Vn();(0,W.useEffect)(()=>{e&&e.host&&(i===`dark`?e.host.classList.add(`dark`):e.host.classList.remove(`dark`))},[i,e]),(0,W.useEffect)(()=>{let e=sessionStorage.getItem(`inspector-current-inspection-id`);e&&(m.some(t=>t.id===e)||sessionStorage.removeItem(`inspector-current-inspection-id`))},[m]);let F=(0,W.useCallback)(()=>{let e=!o;s(e),C(!1),document.body.style.cursor=e?`crosshair`:``,e?p(null):(k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`),p(null)),P(e?`Inspector ON`:`Inspector OFF`)},[o,P]),L=(0,W.useCallback)(()=>{p(null),s(!1),C(!1),document.body.style.cursor=``,k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`)},[]),ee=(0,W.useCallback)(()=>{if(!o){s(!0),C(!0),p(null),P(`Region Mode: ON`);return}let e=!S;C(e),e?(p(null),document.body.style.cursor=`default`):document.body.style.cursor=`crosshair`},[o,S,P]);(0,W.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&o){L();return}e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyI`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),F()),e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyS`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),ee())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,F,L,ee]),(0,W.useEffect)(()=>{let e=()=>{o||(s(!0),document.body.style.cursor=`crosshair`,p(null),P(`Inspector ON`))};return window.addEventListener(`activate-inspector`,e),()=>window.removeEventListener(`activate-inspector`,e)},[o,P]),(0,W.useEffect)(()=>{let e=()=>{s(!0),C(!0),p(null),document.body.style.cursor=`default`,P(`Area Mode: ON`)};return window.addEventListener(`activate-area-select`,e),()=>window.removeEventListener(`activate-area-select`,e)},[P]),(0,W.useEffect)(()=>{let e=async e=>{let{selector:t,containerSelector:n,bounds:r}=e.detail||{},i=[],a=null;try{if(t){let e=document.querySelector(t);e&&(a=e,i=[e])}else if(n){let e=document.querySelector(n);if(e){a=e;let t=e.querySelectorAll(`*`);i=[e,...Array.from(t).filter(e=>{let t=e.tagName.toLowerCase(),n=[`button`,`a`,`input`,`select`,`textarea`,`img`,`video`,`audio`].includes(t),r=e.textContent?.trim(),i=e.id,a=e.className;return n||r||i||a}).slice(0,50)]}}else if(r){let{x:e,y:t,width:n,height:o}=r,s=document.querySelectorAll(`*`);i=Array.from(s).filter(r=>{let i=r.getBoundingClientRect();return i.left<e+n&&i.right>e&&i.top<t+o&&i.bottom>t&&i.width>0&&i.height>0}).slice(0,50),a=i[0]||null}if(!a||i.length===0){window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{error:`No elements found matching the criteria`}}));return}let e=Wn(a),o=i.slice(1).map(e=>{let t=Wn(e);return{file:t.file,component:t.component,line:t.line,column:t.column,elementInfo:t.elementInfo}}),s;a.isConnected&&(s=await Vi(a));let c=`inspection-${Date.now()}`,l=t?`Auto-captured: ${t}`:n?`Auto-captured container: ${n} (${i.length} elements)`:`Auto-captured bounds: ${r?.width}x${r?.height} at (${r?.x}, ${r?.y}) (${i.length} elements)`,u={id:c,sourceInfo:{file:e.file,component:e.component,line:e.line,column:e.column,elementInfo:e.elementInfo,relatedElements:o.length>0?o:void 0},description:l,status:`pending`,timestamp:Date.now(),selectedContext:{includeElement:!0,includeStyles:!1,consoleIds:[],networkIds:[],screenshot:s}};h(e=>[...e,u]),Wi([...Ui(),u]),window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:[u]}}))}catch(e){let t=e instanceof Error?e.message:String(e);window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{error:`Automated capture failed: ${t}`}}))}};return window.addEventListener(`automated-capture`,e),()=>window.removeEventListener(`automated-capture`,e)},[h]),Gn({isActive:o&&!S,isWaitingForFeedback:f!==null,overlayRef:k,tooltipRef:A,btnRef:j});let R=async e=>{if(e.element){let t=e.element;await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,50)})}),t.isConnected?d(await Vi(t)):d(``)}if(l(e),e.automated){let t={id:`inspection-${Date.now()}`,sourceInfo:{file:e.file,component:e.component,line:e.line,column:e.column,elementInfo:e.elementInfo},description:`Auto-captured via automation`,status:`pending`,timestamp:Date.now()};h(e=>[...e,t]),window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:[t]}})),s(!1),document.body.style.cursor=``,k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`)}else p(`input`),k.current&&(k.current.style.display=`none`),A.current&&(A.current.style.display=`none`)};return(0,W.useEffect)(()=>{let e=e=>{let t=e;if(t.detail){let e=t.detail.info||t.detail;e&&e.file&&R({...e,automated:!0})}};return window.addEventListener(`dev-inspector:inspect-element`,e),()=>window.removeEventListener(`dev-inspector:inspect-element`,e)},[]),Kn({isActive:o&&!S,isWaitingForFeedback:f!==null,onElementInspected:R,btnRef:j}),(0,X.jsx)(`div`,{className:_(`font-sans antialiased w-full h-full pointer-events-none fixed inset-0`,i===`dark`&&`dark`),children:(0,X.jsxs)(_r.Provider,{value:t||null,children:[(0,X.jsx)(`div`,{className:`pointer-events-auto`,children:a&&(0,X.jsx)(Xi,{toolsReady:r,mcpClient:n,isActive:o,onToggleInspector:F,onSubmitAgent:(e,t,n)=>{T({text:e},{body:{agent:t,envVars:{},sessionId:n}})},onCancel:O,isAgentWorking:E===`streaming`||E===`submitted`,messages:w,status:E,inspectionCount:m.length,inspectionItems:m,onRemoveInspection:e=>{h(t=>t.filter(t=>t.id!==e))},onAgentChange:x,onToggleRegionMode:ee,isRegionModeActive:S})}),o&&S&&(0,X.jsx)(Qi,{isActive:!0,onSelectionComplete:async e=>{e.element&&e.element.isConnected?d(await Vi(e.element)):d(``),window.dispatchEvent(new CustomEvent(`area-selection-complete`,{detail:{sourceInfo:e}})),l(e),p(`input`),C(!1),s(!1),P(`Region: ${(e.relatedElements?.length||0)+1} elements`)},onCancel:()=>C(!1),onClose:F}),(0,X.jsx)(zn,{ref:k,visible:o&&f===null&&!S}),(0,X.jsx)(Bn,{ref:A,visible:o&&f===null&&!S}),M&&(0,X.jsx)(Xt,{message:M}),f&&c&&(0,X.jsx)(`div`,{className:`pointer-events-auto`,children:(0,X.jsx)(Rn,{sourceInfo:c,screenshot:u,mode:f,onSubmit:(e,t=!1,n)=>{if(!c)return;let r=c.relatedElements&&c.relatedElements.length>0,i=e;!i&&r&&(i=`Region: ${(c.relatedElements?.length||0)+1} elements (primary: ${c.elementInfo?.tagName.toLowerCase()||`element`})${c.note||c.relatedElements?.some(e=>e.note)?`. Please read notes on these elements.`:``}`);let a=i||e,o={id:`inspection-${Date.now()}`,sourceInfo:{file:c.file,component:c.component,line:c.line,column:c.column,elementInfo:c.elementInfo,relatedElements:c.relatedElements?.map(e=>({file:e.file,component:e.component,line:e.line,column:e.column,elementInfo:e.elementInfo?{tagName:e.elementInfo.tagName,textContent:e.elementInfo.textContent,className:e.elementInfo.className,id:e.elementInfo.id,styles:e.elementInfo.styles||{}}:void 0,note:e.note}))},description:a,status:`pending`,timestamp:Date.now(),selectedContext:n};h(e=>[...e,o]);let l=[...v,o];y(l),p(null),t?(s(!0),document.body.style.cursor=`crosshair`,P(`Saved (${l.length})`)):(Wi([...Ui(),...l]),window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:l}})),y([]),s(!1),document.body.style.cursor=``,P(`${l.length} inspection${l.length>1?`s`:``} saved`))},onClose:L,client:n,isClientReady:r,selectedAgent:b||void 0})}),(0,X.jsx)(gr,{})]})})};var ea=class extends HTMLElement{connectedCallback(){this.style.cssText=`
|
|
77
77
|
position: fixed !important;
|
|
78
78
|
top: 0 !important;
|
|
79
79
|
left: 0 !important;
|
|
@@ -81,4 +81,4 @@ ${a}
|
|
|
81
81
|
height: 100% !important;
|
|
82
82
|
pointer-events: none !important;
|
|
83
83
|
z-index: 2147483647 !important;
|
|
84
|
-
`;let e=this.attachShadow({mode:`open`}),t=document.createElement(`style`);t.textContent=ne,e.appendChild(t);let n=document.createElement(`div`);e.appendChild(n),
|
|
84
|
+
`;let e=this.attachShadow({mode:`open`}),t=document.createElement(`style`);t.textContent=ne,e.appendChild(t);let n=document.createElement(`div`);e.appendChild(n),Gi.createRoot(n).render(W.createElement(T,null,W.createElement($i,{shadowRoot:e,mountPoint:n})));let r=window.__DEV_INSPECTOR_CONFIG__;Yt({disableChrome:r?.disableChrome})}};function ta(){customElements.get(`dev-inspector-mcp`)||customElements.define(`dev-inspector-mcp`,ea)}ta();export{_r as InspectorContainerContext,ta as registerDevInspector,vr as useInspectorContainer,yr as useShadowRoot};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as unplugin1 from "unplugin";
|
|
2
2
|
import { McpServer } from "@agentclientprotocol/sdk";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/config-updater.d.ts
|
|
@@ -243,10 +243,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/core.d.ts
|
|
246
|
-
declare const unplugin:
|
|
246
|
+
declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/core-external.d.ts
|
|
249
|
-
declare const unpluginExternal:
|
|
249
|
+
declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
250
250
|
//#endregion
|
|
251
251
|
//#region src/turbopack.d.ts
|
|
252
252
|
interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
@@ -271,7 +271,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
|
271
271
|
declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region src/index.d.ts
|
|
274
|
-
declare const external:
|
|
274
|
+
declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
275
275
|
declare module "virtual:dev-inspector-mcp" {}
|
|
276
276
|
//#endregion
|
|
277
277
|
export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
|
package/package.json
CHANGED