@mcpc-tech/unplugin-dev-inspector-mcp 0.1.30 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import{o as e}from"./chunk-BbOf1w_A.js";import{$ as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,J as l,K as u,L as d,O as f,Q as p,R as m,S as h,T as g,U as _,V as v,W as y,X as b,Y as x,Z as S,a as C,at as w,c as T,d as E,et as D,f as O,h as k,i as A,it as j,j as M,l as N,m as P,n as F,nt as I,o as ee,ot as te,p as L,q as R,r as ne,rt as z,s as re,t as ie,tt as ae,u as B,w as V,x as oe,z as H}from"./PromptParamsDialog-D0TaQM5I.js";import"./katex-C3zESuch.js";import"./marked.esm-DUB0uiru.js";var U=e(te()),W=new TextEncoder;function se(e){return W.encode(e)}function ce(e,t){return new TextDecoder(t).decode(e)}function le(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function G(){if(typeof navigator<`u`&&navigator.product===`ReactNative`)return!0;if(typeof process<`u`){let e=process.type;return e===`renderer`||e===`worker`?!1:!!(process.versions&&process.versions.node)}return!1}var ue=/(%?)(%([sdijo]))/g;function de(e,t){switch(t){case`s`:return e;case`d`:case`i`:return Number(e);case`j`:return JSON.stringify(e);case`o`:{if(typeof e==`string`)return e;let t=JSON.stringify(e);return t===`{}`||t===`[]`||/^\[object .+?\]$/.test(t)?e:t}}}function K(e,...t){if(t.length===0)return e;let n=0,r=e.replace(ue,(e,r,i,a)=>{let o=t[n],s=de(o,a);return r?e:(n++,s)});return n<t.length&&(r+=` ${t.slice(n).join(` `)}`),r=r.replace(/%{2,2}/g,`%`),r}var fe=2;function pe(e){if(!e.stack)return;let t=e.stack.split(`
2
- `);t.splice(1,fe),e.stack=t.join(`
3
- `)}var me=class extends Error{constructor(e,...t){super(e),this.message=e,this.name=`Invariant Violation`,this.message=K(e,...t),pe(this)}},q=(e,t,...n)=>{if(!e)throw new me(t,...n)};q.as=(e,t,n,...r)=>{if(!t){let t=r.length===0?n:K(n,...r),i;try{i=Reflect.construct(e,[t])}catch{i=e(t)}throw i}};var J=Object.defineProperty,he=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},ge={};he(ge,{blue:()=>ve,gray:()=>ye,green:()=>xe,red:()=>be,yellow:()=>_e});function _e(e){return`\x1B[33m${e}\x1B[0m`}function ve(e){return`\x1B[34m${e}\x1B[0m`}function ye(e){return`\x1B[90m${e}\x1B[0m`}function be(e){return`\x1B[31m${e}\x1B[0m`}function xe(e){return`\x1B[32m${e}\x1B[0m`}var Se=G(),Ce=class{constructor(e){this.name=e,this.prefix=`[${this.name}]`;let t=Oe(`DEBUG`),n=Oe(`LOG_LEVEL`);t===`1`||t===`true`||t!==void 0&&this.name.startsWith(t)?(this.debug=ke(n,`debug`)?Te:this.debug,this.info=ke(n,`info`)?Te:this.info,this.success=ke(n,`success`)?Te:this.success,this.warning=ke(n,`warning`)?Te:this.warning,this.error=ke(n,`error`)?Te:this.error):(this.info=Te,this.success=Te,this.warning=Te,this.error=Te,this.only=Te)}prefix;extend(e){return new Ce(`${this.name}:${e}`)}debug(e,...t){this.logEntry({level:`debug`,message:ye(e),positionals:t,prefix:this.prefix,colors:{prefix:`gray`}})}info(e,...t){this.logEntry({level:`info`,message:e,positionals:t,prefix:this.prefix,colors:{prefix:`blue`}});let n=new we;return(e,...t)=>{n.measure(),this.logEntry({level:`info`,message:`${e} ${ye(`${n.deltaTime}ms`)}`,positionals:t,prefix:this.prefix,colors:{prefix:`blue`}})}}success(e,...t){this.logEntry({level:`info`,message:e,positionals:t,prefix:`\u2714 ${this.prefix}`,colors:{timestamp:`green`,prefix:`green`}})}warning(e,...t){this.logEntry({level:`warning`,message:e,positionals:t,prefix:`\u26A0 ${this.prefix}`,colors:{timestamp:`yellow`,prefix:`yellow`}})}error(e,...t){this.logEntry({level:`error`,message:e,positionals:t,prefix:`\u2716 ${this.prefix}`,colors:{timestamp:`red`,prefix:`red`}})}only(e){e()}createEntry(e,t){return{timestamp:new Date,level:e,message:t}}logEntry(e){let{level:t,message:n,prefix:r,colors:i,positionals:a=[]}=e,o=this.createEntry(t,n),s=i?.timestamp||`gray`,c=i?.prefix||`gray`,l={timestamp:ge[s],prefix:ge[c]};this.getWriter(t)([l.timestamp(this.formatTimestamp(o.timestamp))].concat(r==null?[]:l.prefix(r),Ae(n)).join(` `),...a.map(Ae))}formatTimestamp(e){return`${e.toLocaleTimeString(`en-GB`)}:${e.getMilliseconds()}`}getWriter(e){switch(e){case`debug`:case`success`:case`info`:return Y;case`warning`:return Ee;case`error`:return De}}},we=class{startTime;endTime;deltaTime;constructor(){this.startTime=performance.now()}measure(){this.endTime=performance.now(),this.deltaTime=(this.endTime-this.startTime).toFixed(2)}},Te=()=>void 0;function Y(e,...t){if(Se){process.stdout.write(K(e,...t)+`
4
- `);return}console.log(e,...t)}function Ee(e,...t){if(Se){process.stderr.write(K(e,...t)+`
5
- `);return}console.warn(e,...t)}function De(e,...t){if(Se){process.stderr.write(K(e,...t)+`
6
- `);return}console.error(e,...t)}function Oe(e){return Se?process.env[e]:globalThis[e]?.toString()}function ke(e,t){return e!==void 0&&e!==t}function Ae(e){return e===void 0?`undefined`:e===null?`null`:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):e.toString()}var je=class extends Error{constructor(e,t,n){super(`Possible EventEmitter memory leak detected. ${n} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=n,this.name=`MaxListenersExceededWarning`}},Me=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=Me.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,n){this.emit(e,t,n)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),[]}_wrapOnceListener(e,t){let n=(...r)=>(this.removeListener(e,n),t.apply(this,r));return Object.defineProperty(n,`name`,{value:t.name}),n}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){let n=this._getListeners(e);return n.forEach(e=>{e.apply(this,t)}),n.length>0}addListener(e,t){this._emitInternalEvent(`newListener`,e,t);let n=this._getListeners(e).concat(t);if(this.events.set(e,n),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;let t=new je(this,e,this.listenerCount(e));console.warn(t)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){let n=this._getListeners(e);if(n.length>0){let r=[t].concat(n);this.events.set(e,r)}else this.events.set(e,n.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){let n=this._getListeners(e);return n.length>0&&(this._removeListener(n,t),this.events.set(e,n),this._emitInternalEvent(`removeListener`,e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},Ne=Me;Ne.defaultMaxListeners=10;var Pe=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},Fe=(e,t,n)=>(Pe(e,t,`read from private field`),n?n.call(e):t.get(e)),Ie=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},Le=`x-interceptors-internal-request-id`;function Re(e){return globalThis[e]||void 0}function ze(e,t){globalThis[e]=t}function Be(e){delete globalThis[e]}var Ve=class{constructor(e){this.symbol=e,this.readyState=`INACTIVE`,this.emitter=new Ne,this.subscriptions=[],this.logger=new Ce(e.description),this.emitter.setMaxListeners(0),this.logger.info(`constructing the interceptor...`)}checkEnvironment(){return!0}apply(){let e=this.logger.extend(`apply`);if(e.info(`applying the interceptor...`),this.readyState===`APPLIED`){e.info(`intercepted already applied!`);return}if(!this.checkEnvironment()){e.info(`the interceptor cannot be applied in this environment!`);return}this.readyState=`APPLYING`;let t=this.getInstance();if(t){e.info(`found a running instance, reusing...`),this.on=(n,r)=>(e.info(`proxying the "%s" listener`,n),t.emitter.addListener(n,r),this.subscriptions.push(()=>{t.emitter.removeListener(n,r),e.info(`removed proxied "%s" listener!`,n)}),this),this.readyState=`APPLIED`;return}e.info(`no running instance found, setting up a new instance...`),this.setup(),this.setInstance(),this.readyState=`APPLIED`}setup(){}on(e,t){let n=this.logger.extend(`on`);return this.readyState===`DISPOSING`||this.readyState===`DISPOSED`?(n.info(`cannot listen to events, already disposed!`),this):(n.info(`adding "%s" event listener:`,e,t),this.emitter.on(e,t),this)}once(e,t){return this.emitter.once(e,t),this}off(e,t){return this.emitter.off(e,t),this}removeAllListeners(e){return this.emitter.removeAllListeners(e),this}dispose(){let e=this.logger.extend(`dispose`);if(this.readyState===`DISPOSED`){e.info(`cannot dispose, already disposed!`);return}if(e.info(`disposing the interceptor...`),this.readyState=`DISPOSING`,!this.getInstance()){e.info(`no interceptors running, skipping dispose...`);return}if(this.clearInstance(),e.info(`global symbol deleted:`,Re(this.symbol)),this.subscriptions.length>0){e.info(`disposing of %d subscriptions...`,this.subscriptions.length);for(let e of this.subscriptions)e();this.subscriptions=[],e.info(`disposed of all subscriptions!`,this.subscriptions.length)}this.emitter.removeAllListeners(),e.info(`destroyed the listener!`),this.readyState=`DISPOSED`}getInstance(){let e=Re(this.symbol);return this.logger.info(`retrieved global instance:`,e?.constructor?.name),e}setInstance(){ze(this.symbol,this),this.logger.info(`set global instance!`,this.symbol.description)}clearInstance(){Be(this.symbol),this.logger.info(`cleared global instance!`,this.symbol.description)}};function He(){return Math.random().toString(16).slice(2)}function Ue(){let e=(t,n)=>{e.state=`pending`,e.resolve=n=>e.state===`pending`?(e.result=n,t(n instanceof Promise?n:Promise.resolve(n).then(t=>(e.state=`fulfilled`,t)))):void 0,e.reject=t=>{if(e.state===`pending`)return queueMicrotask(()=>{e.state=`rejected`}),n(e.rejectionReason=t)}};return e}var We=class extends Promise{#e;resolve;reject;constructor(e=null){let t=Ue();super((n,r)=>{t(n,r),e?.(t.resolve,t.reject)}),this.#e=t,this.resolve=this.#e.resolve,this.reject=this.#e.reject}get state(){return this.#e.state}get rejectionReason(){return this.#e.rejectionReason}then(e,t){return this.#t(super.then(e,t))}catch(e){return this.#t(super.catch(e))}finally(e){return this.#t(super.finally(e))}#t(e){return Object.defineProperties(e,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})}},Ge=Symbol(`isPatchedModule`),Ke=class extends Error{constructor(e){super(e),this.name=`InterceptorError`,Object.setPrototypeOf(this,Ke.prototype)}},qe,Je,Ye=class{constructor(e,t){this.request=e,this.source=t,Ie(this,qe),this.readyState=Ye.PENDING,this.handled=new We}async passthrough(){q.as(Ke,this.readyState===Ye.PENDING,`Failed to passthrough the "%s %s" request: the request has already been handled`,this.request.method,this.request.url),this.readyState=Ye.PASSTHROUGH,await this.source.passthrough(),Fe(this,qe,Je).resolve()}respondWith(e){q.as(Ke,this.readyState===Ye.PENDING,`Failed to respond to the "%s %s" request with "%d %s": the request has already been handled (%d)`,this.request.method,this.request.url,e.status,e.statusText||`OK`,this.readyState),this.readyState=Ye.RESPONSE,Fe(this,qe,Je).resolve(),this.source.respondWith(e)}errorWith(e){q.as(Ke,this.readyState===Ye.PENDING,`Failed to error the "%s %s" request with "%s": the request has already been handled (%d)`,this.request.method,this.request.url,e?.toString(),this.readyState),this.readyState=Ye.ERROR,this.source.errorWith(e),Fe(this,qe,Je).resolve()}},Xe=Ye;qe=new WeakSet,Je=function(){return this.handled},Xe.PENDING=0,Xe.PASSTHROUGH=1,Xe.RESPONSE=2,Xe.ERROR=3;function Ze(e){try{return new URL(e),!0}catch{return!1}}function Qe(e,t){let n=Object.getOwnPropertySymbols(t).find(t=>t.description===e);if(n)return Reflect.get(t,n)}var $e=class extends Response{static isConfigurableStatusCode(e){return e>=200&&e<=599}static isRedirectResponse(e){return $e.STATUS_CODES_WITH_REDIRECT.includes(e)}static isResponseWithBody(e){return!$e.STATUS_CODES_WITHOUT_BODY.includes(e)}static setUrl(e,t){if(!e||e===`about:`||!Ze(e))return;let n=Qe(`state`,t);n?n.urlList.push(new URL(e)):Object.defineProperty(t,`url`,{value:e,enumerable:!0,configurable:!0,writable:!1})}static parseRawHeaders(e){let t=new Headers;for(let n=0;n<e.length;n+=2)t.append(e[n],e[n+1]);return t}constructor(e,t={}){let n=t.status??200,r=$e.isConfigurableStatusCode(n)?n:200,i=$e.isResponseWithBody(n)?e:null;if(super(i,{status:r,statusText:t.statusText,headers:t.headers}),n!==r){let e=Qe(`state`,this);e?e.status=n:Object.defineProperty(this,`status`,{value:n,enumerable:!0,configurable:!0,writable:!1})}$e.setUrl(t.url,this)}},et=$e;et.STATUS_CODES_WITHOUT_BODY=[101,103,204,205,304],et.STATUS_CODES_WITH_REDIRECT=[301,302,303,307,308];var tt=Symbol(`kRawRequest`);function nt(e,t){Reflect.set(e,tt,t)}var rt=class extends Ve{constructor(e){rt.symbol=Symbol(e.name),super(rt.symbol),this.interceptors=e.interceptors}setup(){let e=this.logger.extend(`setup`);e.info(`applying all %d interceptors...`,this.interceptors.length);for(let t of this.interceptors)e.info(`applying "%s" interceptor...`,t.constructor.name),t.apply(),e.info(`adding interceptor dispose subscription`),this.subscriptions.push(()=>t.dispose())}on(e,t){for(let n of this.interceptors)n.on(e,t);return this}once(e,t){for(let n of this.interceptors)n.once(e,t);return this}off(e,t){for(let n of this.interceptors)n.off(e,t);return this}removeAllListeners(e){for(let t of this.interceptors)t.removeAllListeners(e);return this}};async function it(e,t,...n){let r=e.listeners(t);if(r.length!==0)for(let t of r)await t.apply(e,n)}function at(e){let t=Object.getOwnPropertyDescriptor(globalThis,e);return t===void 0||typeof t.get==`function`&&t.get()===void 0||t.get===void 0&&t.value==null?!1:t.set===void 0&&!t.configurable?(console.error(`[MSW] Failed to apply interceptor: the global \`${e}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`),!1):!0}var ot=async e=>{try{return{error:null,data:await e().catch(e=>{throw e})}}catch(e){return{error:e,data:null}}};function st(e,t=!1){return t?Object.prototype.toString.call(e).startsWith(`[object `):Object.prototype.toString.call(e)===`[object Object]`}function ct(e,t){try{return e[t],!0}catch{return!1}}function lt(e){return new Response(JSON.stringify(e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:e),{status:500,statusText:`Unhandled Exception`,headers:{"Content-Type":`application/json`}})}function ut(e){return e!=null&&e instanceof Response&&ct(e,`type`)&&e.type===`error`}function dt(e){return st(e,!0)&&ct(e,`status`)&&ct(e,`statusText`)&&ct(e,`bodyUsed`)}function ft(e){return e==null||!(e instanceof Error)?!1:`code`in e&&`errno`in e}async function pt(e){let t=async t=>t instanceof Error?(await e.controller.errorWith(t),!0):ut(t)||dt(t)?(await e.controller.respondWith(t),!0):st(t)?(await e.controller.errorWith(t),!0):!1,n=async n=>{if(n instanceof Ke)throw i.error;return ft(n)?(await e.controller.errorWith(n),!0):n instanceof Response?await t(n):!1},r=new We;if(e.request.signal){if(e.request.signal.aborted){await e.controller.errorWith(e.request.signal.reason);return}e.request.signal.addEventListener(`abort`,()=>{r.reject(e.request.signal.reason)},{once:!0})}let i=await ot(async()=>{let t=it(e.emitter,`request`,{requestId:e.requestId,request:e.request,controller:e.controller});await Promise.race([r,t,e.controller.handled])});if(r.state===`rejected`){await e.controller.errorWith(r.rejectionReason);return}if(i.error){if(await n(i.error))return;if(e.emitter.listenerCount(`unhandledException`)>0){let n=new Xe(e.request,{passthrough(){},async respondWith(e){await t(e)},async errorWith(t){await e.controller.errorWith(t)}});if(await it(e.emitter,`unhandledException`,{error:i.error,request:e.request,requestId:e.requestId,controller:n}),n.readyState!==Xe.PENDING)return}await e.controller.respondWith(lt(i.error));return}return e.controller.readyState===Xe.PENDING?await e.controller.passthrough():e.controller.handled}function mt(e){return Object.assign(TypeError(`Failed to fetch`),{cause:e})}var ht=[`content-encoding`,`content-language`,`content-location`,`content-type`,`content-length`],gt=Symbol(`kRedirectCount`);async function _t(e,t){if(t.status!==303&&e.body!=null)return Promise.reject(mt());let n=new URL(e.url),r;try{r=new URL(t.headers.get(`location`),e.url)}catch(e){return Promise.reject(mt(e))}if(!(r.protocol===`http:`||r.protocol===`https:`))return Promise.reject(mt(`URL scheme must be a HTTP(S) scheme`));if(Reflect.get(e,gt)>20)return Promise.reject(mt(`redirect count exceeded`));if(Object.defineProperty(e,gt,{value:(Reflect.get(e,gt)||0)+1}),e.mode===`cors`&&(r.username||r.password)&&!vt(n,r))return Promise.reject(mt(`cross origin not allowed for request mode "cors"`));let i={};([301,302].includes(t.status)&&e.method===`POST`||t.status===303&&![`HEAD`,`GET`].includes(e.method))&&(i.method=`GET`,i.body=null,ht.forEach(t=>{e.headers.delete(t)})),vt(n,r)||(e.headers.delete(`authorization`),e.headers.delete(`proxy-authorization`),e.headers.delete(`cookie`),e.headers.delete(`host`)),i.headers=e.headers;let a=await fetch(new Request(r,i));return Object.defineProperty(a,`redirected`,{value:!0,configurable:!0}),a}function vt(e,t){return e.origin===t.origin&&e.origin===`null`||e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port}var yt=class extends TransformStream{constructor(){console.warn(`[Interceptors]: Brotli decompression of response streams is not supported in the browser`),super({transform(e,t){t.enqueue(e)}})}},bt=class extends TransformStream{constructor(e,...t){super({},...t);let n=[super.readable,...e].reduce((e,t)=>e.pipeThrough(t));Object.defineProperty(this,`readable`,{get(){return n}})}};function xt(e){return e.toLowerCase().split(`,`).map(e=>e.trim())}function St(e){if(e===``)return null;let t=xt(e);return t.length===0?null:new bt(t.reduceRight((e,t)=>t===`gzip`||t===`x-gzip`?e.concat(new DecompressionStream(`gzip`)):t===`deflate`?e.concat(new DecompressionStream(`deflate`)):t===`br`?e.concat(new yt):(e.length=0,e),[]))}function Ct(e){if(e.body===null)return null;let t=St(e.headers.get(`content-encoding`)||``);return t?(e.body.pipeTo(t.writable),t.readable):null}var wt=class extends Ve{constructor(){super(wt.symbol)}checkEnvironment(){return at(`fetch`)}async setup(){let e=globalThis.fetch;q(!e[Ge],`Failed to patch the "fetch" module: already patched.`),globalThis.fetch=async(t,n)=>{let r=He(),i=typeof t==`string`&&typeof location<`u`&&!Ze(t)?new URL(t,location.href):t,a=new Request(i,n);t instanceof Request&&nt(a,t);let o=new We,s=new Xe(a,{passthrough:async()=>{this.logger.info(`request has not been handled, passthrough...`);let t=a.clone(),{error:n,data:i}=await ot(()=>e(a));if(n)return o.reject(n);if(this.logger.info(`original fetch performed`,i),this.emitter.listenerCount(`response`)>0){this.logger.info(`emitting the "response" event...`);let e=i.clone();await it(this.emitter,`response`,{response:e,isMockedResponse:!1,request:t,requestId:r})}o.resolve(i)},respondWith:async e=>{if(ut(e)){this.logger.info(`request has errored!`,{response:e}),o.reject(mt(e));return}this.logger.info(`received mocked response!`,{rawResponse:e});let t=Ct(e),n=t===null?e:new et(t,e);if(et.setUrl(a.url,n),et.isRedirectResponse(n.status)){if(a.redirect===`error`){o.reject(mt(`unexpected redirect`));return}if(a.redirect===`follow`){_t(a,n).then(e=>{o.resolve(e)},e=>{o.reject(e)});return}}this.emitter.listenerCount(`response`)>0&&(this.logger.info(`emitting the "response" event...`),await it(this.emitter,`response`,{response:n.clone(),isMockedResponse:!0,request:a,requestId:r})),o.resolve(n)},errorWith:e=>{this.logger.info(`request has been aborted!`,{reason:e}),o.reject(e)}});return this.logger.info(`[%s] %s`,a.method,a.url),this.logger.info(`awaiting for the mocked response...`),this.logger.info(`emitting the "request" event for %s listener(s)...`,this.emitter.listenerCount(`request`)),await pt({request:a,requestId:r,emitter:this.emitter,controller:s}),o},Object.defineProperty(globalThis.fetch,Ge,{enumerable:!0,configurable:!0,value:!0}),this.subscriptions.push(()=>{Object.defineProperty(globalThis.fetch,Ge,{value:void 0}),globalThis.fetch=e,this.logger.info(`restored native "globalThis.fetch"!`,globalThis.fetch.name)})}},Tt=wt;Tt.symbol=Symbol(`fetch`);function Et(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}var Dt=class{constructor(e,t){this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.type=``,this.srcElement=null,this.currentTarget=null,this.eventPhase=0,this.isTrusted=!0,this.composed=!1,this.cancelable=!0,this.defaultPrevented=!1,this.bubbles=!0,this.lengthComputable=!0,this.loaded=0,this.total=0,this.cancelBubble=!1,this.returnValue=!0,this.type=e,this.target=t?.target||null,this.currentTarget=t?.currentTarget||null,this.timeStamp=Date.now()}composedPath(){return[]}initEvent(e,t,n){this.type=e,this.bubbles=!!t,this.cancelable=!!n}preventDefault(){this.defaultPrevented=!0}stopPropagation(){}stopImmediatePropagation(){}},Ot=class extends Dt{constructor(e,t){super(e),this.lengthComputable=t?.lengthComputable||!1,this.composed=t?.composed||!1,this.loaded=t?.loaded||0,this.total=t?.total||0}},kt=typeof ProgressEvent<`u`;function At(e,t,n){let r=[`error`,`progress`,`loadstart`,`loadend`,`load`,`timeout`,`abort`],i=kt?ProgressEvent:Ot;return r.includes(t)?new i(t,{lengthComputable:!0,loaded:n?.loaded||0,total:n?.total||0}):new Dt(t,{target:e,currentTarget:e})}function jt(e,t){if(!(t in e))return null;if(Object.prototype.hasOwnProperty.call(e,t))return e;let n=Reflect.getPrototypeOf(e);return n?jt(n,t):null}function Mt(e,t){return new Proxy(e,Nt(t))}function Nt(e){let{constructorCall:t,methodCall:n,getProperty:r,setProperty:i}=e,a={};return t!==void 0&&(a.construct=function(e,n,r){let i=Reflect.construct.bind(null,e,n,r);return t.call(r,n,i)}),a.set=function(e,t,n){let r=()=>{let r=jt(e,t)||e,i=Reflect.getOwnPropertyDescriptor(r,t);return i?.set===void 0?Reflect.defineProperty(r,t,{writable:!0,enumerable:!0,configurable:!0,value:n}):(i.set.apply(e,[n]),!0)};return i===void 0?r():i.call(e,[t,n],r)},a.get=function(e,t,i){let a=()=>e[t],o=r===void 0?a():r.call(e,[t,i],a);return typeof o==`function`?(...r)=>{let i=o.bind(e,...r);return n===void 0?i():n.call(e,[t,r],i)}:o},a}function Pt(e){return[`application/xhtml+xml`,`application/xml`,`image/svg+xml`,`text/html`,`text/xml`].some(t=>e.startsWith(t))}function Ft(e){try{return JSON.parse(e)}catch{return null}}function It(e,t){return new et(et.isResponseWithBody(e.status)?t:null,{url:e.responseURL,status:e.status,statusText:e.statusText,headers:Lt(e.getAllResponseHeaders())})}function Lt(e){let t=new Headers,n=e.split(/[\r\n]+/);for(let e of n){if(e.trim()===``)continue;let[n,...r]=e.split(`: `),i=r.join(`: `);t.append(n,i)}return t}async function Rt(e){let t=e.headers.get(`content-length`);return t!=null&&t!==``?Number(t):(await e.arrayBuffer()).byteLength}var zt=Symbol(`kIsRequestHandled`),Bt=G(),Vt=Symbol(`kFetchRequest`),Ht=class{constructor(e,t){this.initialRequest=e,this.logger=t,this.method=`GET`,this.url=null,this[zt]=!1,this.events=new Map,this.uploadEvents=new Map,this.requestId=He(),this.requestHeaders=new Headers,this.responseBuffer=new Uint8Array,this.request=Mt(e,{setProperty:([e,t],n)=>{switch(e){case`ontimeout`:{let r=e.slice(2);return this.request.addEventListener(r,t),n()}default:return n()}},methodCall:([e,t],n)=>{switch(e){case`open`:{let[e,r]=t;return r===void 0?(this.method=`GET`,this.url=Ut(e)):(this.method=e,this.url=Ut(r)),this.logger=this.logger.extend(`${this.method} ${this.url.href}`),this.logger.info(`open`,this.method,this.url.href),n()}case`addEventListener`:{let[e,r]=t;return this.registerEvent(e,r),this.logger.info(`addEventListener`,e,r),n()}case`setRequestHeader`:{let[e,r]=t;return this.requestHeaders.set(e,r),this.logger.info(`setRequestHeader`,e,r),n()}case`send`:{let[e]=t;this.request.addEventListener(`load`,()=>{if(this.onResponse!==void 0){let e=It(this.request,this.request.response);this.onResponse.call(this,{response:e,isMockedResponse:this[zt],request:i,requestId:this.requestId})}});let r=typeof e==`string`?se(e):e,i=this.toFetchApiRequest(r);this[Vt]=i.clone(),queueMicrotask(()=>{(this.onRequest?.call(this,{request:i,requestId:this.requestId})||Promise.resolve()).finally(()=>{if(!this[zt])return this.logger.info(`request callback settled but request has not been handled (readystate %d), performing as-is...`,this.request.readyState),Bt&&this.request.setRequestHeader(Le,this.requestId),n()})});break}default:return n()}}}),Wt(this.request,`upload`,Mt(this.request.upload,{setProperty:([e,t],n)=>{switch(e){case`onloadstart`:case`onprogress`:case`onaboart`:case`onerror`:case`onload`:case`ontimeout`:case`onloadend`:{let n=e.slice(2);this.registerUploadEvent(n,t)}}return n()},methodCall:([e,t],n)=>{switch(e){case`addEventListener`:{let[e,r]=t;return this.registerUploadEvent(e,r),this.logger.info(`upload.addEventListener`,e,r),n()}}}}))}registerEvent(e,t){let n=(this.events.get(e)||[]).concat(t);this.events.set(e,n),this.logger.info(`registered event "%s"`,e,t)}registerUploadEvent(e,t){let n=(this.uploadEvents.get(e)||[]).concat(t);this.uploadEvents.set(e,n),this.logger.info(`registered upload event "%s"`,e,t)}async respondWith(e){if(this[zt]=!0,this[Vt]){let e=await Rt(this[Vt]);this.trigger(`loadstart`,this.request.upload,{loaded:0,total:e}),this.trigger(`progress`,this.request.upload,{loaded:e,total:e}),this.trigger(`load`,this.request.upload,{loaded:e,total:e}),this.trigger(`loadend`,this.request.upload,{loaded:e,total:e})}this.logger.info(`responding with a mocked response: %d %s`,e.status,e.statusText),Wt(this.request,`status`,e.status),Wt(this.request,`statusText`,e.statusText),Wt(this.request,`responseURL`,this.url.href),this.request.getResponseHeader=new Proxy(this.request.getResponseHeader,{apply:(t,n,r)=>{if(this.logger.info(`getResponseHeader`,r[0]),this.request.readyState<this.request.HEADERS_RECEIVED)return this.logger.info(`headers not received yet, returning null`),null;let i=e.headers.get(r[0]);return this.logger.info(`resolved response header "%s" to`,r[0],i),i}}),this.request.getAllResponseHeaders=new Proxy(this.request.getAllResponseHeaders,{apply:()=>{if(this.logger.info(`getAllResponseHeaders`),this.request.readyState<this.request.HEADERS_RECEIVED)return this.logger.info(`headers not received yet, returning empty string`),``;let t=Array.from(e.headers.entries()).map(([e,t])=>`${e}: ${t}`).join(`\r
7
- `);return this.logger.info(`resolved all response headers to`,t),t}}),Object.defineProperties(this.request,{response:{enumerable:!0,configurable:!1,get:()=>this.response},responseText:{enumerable:!0,configurable:!1,get:()=>this.responseText},responseXML:{enumerable:!0,configurable:!1,get:()=>this.responseXML}});let t=await Rt(e.clone());this.logger.info(`calculated response body length`,t),this.trigger(`loadstart`,this.request,{loaded:0,total:t}),this.setReadyState(this.request.HEADERS_RECEIVED),this.setReadyState(this.request.LOADING);let n=()=>{this.logger.info(`finalizing the mocked response...`),this.setReadyState(this.request.DONE),this.trigger(`load`,this.request,{loaded:this.responseBuffer.byteLength,total:t}),this.trigger(`loadend`,this.request,{loaded:this.responseBuffer.byteLength,total:t})};if(e.body){this.logger.info(`mocked response has body, streaming...`);let r=e.body.getReader(),i=async()=>{let{value:e,done:a}=await r.read();if(a){this.logger.info(`response body stream done!`),n();return}e&&(this.logger.info(`read response body chunk:`,e),this.responseBuffer=Et(this.responseBuffer,e),this.trigger(`progress`,this.request,{loaded:this.responseBuffer.byteLength,total:t})),i()};i()}else n()}responseBufferToText(){return ce(this.responseBuffer)}get response(){if(this.logger.info(`getResponse (responseType: %s)`,this.request.responseType),this.request.readyState!==this.request.DONE)return null;switch(this.request.responseType){case`json`:{let e=Ft(this.responseBufferToText());return this.logger.info(`resolved response JSON`,e),e}case`arraybuffer`:{let e=le(this.responseBuffer);return this.logger.info(`resolved response ArrayBuffer`,e),e}case`blob`:{let e=this.request.getResponseHeader(`Content-Type`)||`text/plain`,t=new Blob([this.responseBufferToText()],{type:e});return this.logger.info(`resolved response Blob (mime type: %s)`,t,e),t}default:{let e=this.responseBufferToText();return this.logger.info(`resolving "%s" response type as text`,this.request.responseType,e),e}}}get responseText(){if(q(this.request.responseType===``||this.request.responseType===`text`,`InvalidStateError: The object is in invalid state.`),this.request.readyState!==this.request.LOADING&&this.request.readyState!==this.request.DONE)return``;let e=this.responseBufferToText();return this.logger.info(`getResponseText: "%s"`,e),e}get responseXML(){if(q(this.request.responseType===``||this.request.responseType===`document`,`InvalidStateError: The object is in invalid state.`),this.request.readyState!==this.request.DONE)return null;let e=this.request.getResponseHeader(`Content-Type`)||``;return typeof DOMParser>`u`?(console.warn(`Cannot retrieve XMLHttpRequest response body as XML: DOMParser is not defined. You are likely using an environment that is not browser or does not polyfill browser globals correctly.`),null):Pt(e)?new DOMParser().parseFromString(this.responseBufferToText(),e):null}errorWith(e){this[zt]=!0,this.logger.info(`responding with an error`),this.setReadyState(this.request.DONE),this.trigger(`error`,this.request),this.trigger(`loadend`,this.request)}setReadyState(e){if(this.logger.info(`setReadyState: %d -> %d`,this.request.readyState,e),this.request.readyState===e){this.logger.info(`ready state identical, skipping transition...`);return}Wt(this.request,`readyState`,e),this.logger.info(`set readyState to: %d`,e),e!==this.request.UNSENT&&(this.logger.info(`triggering "readystatechange" event...`),this.trigger(`readystatechange`,this.request))}trigger(e,t,n){let r=t[`on${e}`],i=At(t,e,n);this.logger.info(`trigger "%s"`,e,n||``),typeof r==`function`&&(this.logger.info(`found a direct "%s" callback, calling...`,e),r.call(t,i));let a=t instanceof XMLHttpRequestUpload?this.uploadEvents:this.events;for(let[n,r]of a)n===e&&(this.logger.info(`found %d listener(s) for "%s" event, calling...`,r.length,e),r.forEach(e=>e.call(t,i)))}toFetchApiRequest(e){this.logger.info(`converting request to a Fetch API Request...`);let t=e instanceof Document?e.documentElement.innerText:e,n=new Request(this.url.href,{method:this.method,headers:this.requestHeaders,credentials:this.request.withCredentials?`include`:`same-origin`,body:[`GET`,`HEAD`].includes(this.method.toUpperCase())?null:t});return Wt(n,`headers`,Mt(n.headers,{methodCall:([e,t],r)=>{switch(e){case`append`:case`set`:{let[e,n]=t;this.request.setRequestHeader(e,n);break}case`delete`:{let[e]=t;console.warn(`XMLHttpRequest: Cannot remove a "${e}" header from the Fetch API representation of the "${n.method} ${n.url}" request. XMLHttpRequest headers cannot be removed.`);break}}return r()}})),nt(n,this.request),this.logger.info(`converted request to a Fetch API Request!`,n),n}};function Ut(e){return typeof location>`u`?new URL(e):new URL(e.toString(),location.href)}function Wt(e,t,n){Reflect.defineProperty(e,t,{writable:!0,enumerable:!0,value:n})}function Gt({emitter:e,logger:t}){return new Proxy(globalThis.XMLHttpRequest,{construct(n,r,i){t.info(`constructed new XMLHttpRequest`);let a=Reflect.construct(n,r,i),o=Object.getOwnPropertyDescriptors(n.prototype);for(let e in o)Reflect.defineProperty(a,e,o[e]);let s=new Ht(a,t);return s.onRequest=async function({request:t,requestId:n}){let r=new Xe(t,{passthrough:()=>{this.logger.info(`no mocked response received, performing request as-is...`)},respondWith:async e=>{if(ut(e)){this.errorWith(TypeError(`Network error`));return}await this.respondWith(e)},errorWith:e=>{this.logger.info(`request errored!`,{error:e}),e instanceof Error&&this.errorWith(e)}});this.logger.info(`awaiting mocked response...`),this.logger.info(`emitting the "request" event for %s listener(s)...`,e.listenerCount(`request`)),await pt({request:t,requestId:n,controller:r,emitter:e})},s.onResponse=async function({response:t,isMockedResponse:n,request:r,requestId:i}){this.logger.info(`emitting the "response" event for %s listener(s)...`,e.listenerCount(`response`)),e.emit(`response`,{response:t,isMockedResponse:n,request:r,requestId:i})},s.request}})}var Kt=class extends Ve{constructor(){super(Kt.interceptorSymbol)}checkEnvironment(){return at(`XMLHttpRequest`)}setup(){let e=this.logger.extend(`setup`);e.info(`patching "XMLHttpRequest" module...`);let t=globalThis.XMLHttpRequest;q(!t[Ge],`Failed to patch the "XMLHttpRequest" module: already patched.`),globalThis.XMLHttpRequest=Gt({emitter:this.emitter,logger:this.logger}),e.info(`native "XMLHttpRequest" module patched!`,globalThis.XMLHttpRequest.name),Object.defineProperty(globalThis.XMLHttpRequest,Ge,{enumerable:!0,configurable:!0,value:!0}),this.subscriptions.push(()=>{Object.defineProperty(globalThis.XMLHttpRequest,Ge,{value:void 0}),globalThis.XMLHttpRequest=t,e.info(`native "XMLHttpRequest" module restored!`,globalThis.XMLHttpRequest.name)})}},qt=Kt;qt.interceptorSymbol=Symbol(`xhr`);const Jt=1e4;function Yt(e){if(!e?.disableChrome)return;let t=`${I()}/__inspector__/log`,n={log:console.log,warn:console.warn,error:console.error,info:console.info,debug:console.debug};[`log`,`warn`,`error`,`info`,`debug`].forEach(e=>{console[e]=(...r)=>{n[e].apply(console,r);let i=r.map(e=>{try{if(typeof e==`object`&&e){let t=new Set;return JSON.parse(JSON.stringify(e,(e,n)=>{if(typeof n==`object`&&n){if(t.has(n))return`[Circular]`;t.add(n)}return n}))}return e}catch{return String(e)}});fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`console`,data:{type:e,args:i}}),keepalive:!0}).catch(()=>{})}});let r=new rt({name:`dev-inspector-interceptor`,interceptors:[new Tt,new qt]});r.apply(),r.on(`response`,async({request:e,response:n})=>{if(!(e.url.includes(`/__inspector__`)||e.url.includes(`/__mcp__`)||e.url.includes(`/api/acp/chat`)))try{let r={};e.headers.forEach((e,t)=>{r[t]=e});let i={};n.headers.forEach((e,t)=>{i[t]=e});let a=``;try{let e=n.clone(),t=n.headers.get(`content-type`)||``;if(t.includes(`application/json`)){let t=await e.json();a=JSON.stringify(t,null,2)}else a=t.includes(`text/`)?await e.text():`<Binary data, ${t}>`;a.length>Jt&&(a=a.substring(0,Jt)+`
1
+ import{o as e}from"./chunk-BbOf1w_A.js";import{$ as t,B as n,C as r,D as i,E as a,G as o,H as s,I as c,J as l,K as u,M as d,O as f,Q as p,R as m,S as h,T as g,U as _,V as v,W as y,X as b,Y as x,Z as S,a as C,at as w,c as T,d as E,et as D,f as O,g as k,h as A,i as j,it as M,k as N,l as P,m as F,n as I,nt as L,o as R,ot as ee,p as z,q as te,r as ne,rt as re,s as B,st as ie,t as V,tt as ae,u as H,w as U,z as W}from"./PromptParamsDialog-B0YpiWEk.js";import"./katex-C3zESuch.js";import"./marked.esm-DUB0uiru.js";var G=e(ie()),oe=new TextEncoder;function se(e){return oe.encode(e)}function ce(e,t){return new TextDecoder(t).decode(e)}function K(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function le(){if(typeof navigator<`u`&&navigator.product===`ReactNative`)return!0;if(typeof process<`u`){let e=process.type;return e===`renderer`||e===`worker`?!1:!!(process.versions&&process.versions.node)}return!1}var ue=/(%?)(%([sdijo]))/g;function q(e,t){switch(t){case`s`:return e;case`d`:case`i`:return Number(e);case`j`:return JSON.stringify(e);case`o`:{if(typeof e==`string`)return e;let t=JSON.stringify(e);return t===`{}`||t===`[]`||/^\[object .+?\]$/.test(t)?e:t}}}function de(e,...t){if(t.length===0)return e;let n=0,r=e.replace(ue,(e,r,i,a)=>{let o=t[n],s=q(o,a);return r?e:(n++,s)});return n<t.length&&(r+=` ${t.slice(n).join(` `)}`),r=r.replace(/%{2,2}/g,`%`),r}var J=2;function fe(e){if(!e.stack)return;let t=e.stack.split(`
2
+ `);t.splice(1,J),e.stack=t.join(`
3
+ `)}var pe=class extends Error{constructor(e,...t){super(e),this.message=e,this.name=`Invariant Violation`,this.message=de(e,...t),fe(this)}},Y=(e,t,...n)=>{if(!e)throw new pe(t,...n)};Y.as=(e,t,n,...r)=>{if(!t){let t=r.length===0?n:de(n,...r),i;try{i=Reflect.construct(e,[t])}catch{i=e(t)}throw i}};var me=Object.defineProperty,he=(e,t)=>{for(var n in t)me(e,n,{get:t[n],enumerable:!0})},ge={};he(ge,{blue:()=>_e,gray:()=>ve,green:()=>be,red:()=>ye,yellow:()=>X});function X(e){return`\x1B[33m${e}\x1B[0m`}function _e(e){return`\x1B[34m${e}\x1B[0m`}function ve(e){return`\x1B[90m${e}\x1B[0m`}function ye(e){return`\x1B[31m${e}\x1B[0m`}function be(e){return`\x1B[32m${e}\x1B[0m`}var xe=le(),Se=class{constructor(e){this.name=e,this.prefix=`[${this.name}]`;let t=De(`DEBUG`),n=De(`LOG_LEVEL`);t===`1`||t===`true`||t!==void 0&&this.name.startsWith(t)?(this.debug=Oe(n,`debug`)?Z:this.debug,this.info=Oe(n,`info`)?Z:this.info,this.success=Oe(n,`success`)?Z:this.success,this.warning=Oe(n,`warning`)?Z:this.warning,this.error=Oe(n,`error`)?Z:this.error):(this.info=Z,this.success=Z,this.warning=Z,this.error=Z,this.only=Z)}prefix;extend(e){return new Se(`${this.name}:${e}`)}debug(e,...t){this.logEntry({level:`debug`,message:ve(e),positionals:t,prefix:this.prefix,colors:{prefix:`gray`}})}info(e,...t){this.logEntry({level:`info`,message:e,positionals:t,prefix:this.prefix,colors:{prefix:`blue`}});let n=new Ce;return(e,...t)=>{n.measure(),this.logEntry({level:`info`,message:`${e} ${ve(`${n.deltaTime}ms`)}`,positionals:t,prefix:this.prefix,colors:{prefix:`blue`}})}}success(e,...t){this.logEntry({level:`info`,message:e,positionals:t,prefix:`\u2714 ${this.prefix}`,colors:{timestamp:`green`,prefix:`green`}})}warning(e,...t){this.logEntry({level:`warning`,message:e,positionals:t,prefix:`\u26A0 ${this.prefix}`,colors:{timestamp:`yellow`,prefix:`yellow`}})}error(e,...t){this.logEntry({level:`error`,message:e,positionals:t,prefix:`\u2716 ${this.prefix}`,colors:{timestamp:`red`,prefix:`red`}})}only(e){e()}createEntry(e,t){return{timestamp:new Date,level:e,message:t}}logEntry(e){let{level:t,message:n,prefix:r,colors:i,positionals:a=[]}=e,o=this.createEntry(t,n),s=i?.timestamp||`gray`,c=i?.prefix||`gray`,l={timestamp:ge[s],prefix:ge[c]};this.getWriter(t)([l.timestamp(this.formatTimestamp(o.timestamp))].concat(r==null?[]:l.prefix(r),ke(n)).join(` `),...a.map(ke))}formatTimestamp(e){return`${e.toLocaleTimeString(`en-GB`)}:${e.getMilliseconds()}`}getWriter(e){switch(e){case`debug`:case`success`:case`info`:return we;case`warning`:return Te;case`error`:return Ee}}},Ce=class{startTime;endTime;deltaTime;constructor(){this.startTime=performance.now()}measure(){this.endTime=performance.now(),this.deltaTime=(this.endTime-this.startTime).toFixed(2)}},Z=()=>void 0;function we(e,...t){if(xe){process.stdout.write(de(e,...t)+`
4
+ `);return}console.log(e,...t)}function Te(e,...t){if(xe){process.stderr.write(de(e,...t)+`
5
+ `);return}console.warn(e,...t)}function Ee(e,...t){if(xe){process.stderr.write(de(e,...t)+`
6
+ `);return}console.error(e,...t)}function De(e){return xe?process.env[e]:globalThis[e]?.toString()}function Oe(e,t){return e!==void 0&&e!==t}function ke(e){return e===void 0?`undefined`:e===null?`null`:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):e.toString()}var Ae=class extends Error{constructor(e,t,n){super(`Possible EventEmitter memory leak detected. ${n} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=n,this.name=`MaxListenersExceededWarning`}},je=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=je.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,n){this.emit(e,t,n)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),[]}_wrapOnceListener(e,t){let n=(...r)=>(this.removeListener(e,n),t.apply(this,r));return Object.defineProperty(n,`name`,{value:t.name}),n}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){let n=this._getListeners(e);return n.forEach(e=>{e.apply(this,t)}),n.length>0}addListener(e,t){this._emitInternalEvent(`newListener`,e,t);let n=this._getListeners(e).concat(t);if(this.events.set(e,n),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;let t=new Ae(this,e,this.listenerCount(e));console.warn(t)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){let n=this._getListeners(e);if(n.length>0){let r=[t].concat(n);this.events.set(e,r)}else this.events.set(e,n.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){let n=this._getListeners(e);return n.length>0&&(this._removeListener(n,t),this.events.set(e,n),this._emitInternalEvent(`removeListener`,e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},Me=je;Me.defaultMaxListeners=10;var Ne=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},Pe=(e,t,n)=>(Ne(e,t,`read from private field`),n?n.call(e):t.get(e)),Fe=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},Ie=`x-interceptors-internal-request-id`;function Le(e){return globalThis[e]||void 0}function Re(e,t){globalThis[e]=t}function ze(e){delete globalThis[e]}var Be=class{constructor(e){this.symbol=e,this.readyState=`INACTIVE`,this.emitter=new Me,this.subscriptions=[],this.logger=new Se(e.description),this.emitter.setMaxListeners(0),this.logger.info(`constructing the interceptor...`)}checkEnvironment(){return!0}apply(){let e=this.logger.extend(`apply`);if(e.info(`applying the interceptor...`),this.readyState===`APPLIED`){e.info(`intercepted already applied!`);return}if(!this.checkEnvironment()){e.info(`the interceptor cannot be applied in this environment!`);return}this.readyState=`APPLYING`;let t=this.getInstance();if(t){e.info(`found a running instance, reusing...`),this.on=(n,r)=>(e.info(`proxying the "%s" listener`,n),t.emitter.addListener(n,r),this.subscriptions.push(()=>{t.emitter.removeListener(n,r),e.info(`removed proxied "%s" listener!`,n)}),this),this.readyState=`APPLIED`;return}e.info(`no running instance found, setting up a new instance...`),this.setup(),this.setInstance(),this.readyState=`APPLIED`}setup(){}on(e,t){let n=this.logger.extend(`on`);return this.readyState===`DISPOSING`||this.readyState===`DISPOSED`?(n.info(`cannot listen to events, already disposed!`),this):(n.info(`adding "%s" event listener:`,e,t),this.emitter.on(e,t),this)}once(e,t){return this.emitter.once(e,t),this}off(e,t){return this.emitter.off(e,t),this}removeAllListeners(e){return this.emitter.removeAllListeners(e),this}dispose(){let e=this.logger.extend(`dispose`);if(this.readyState===`DISPOSED`){e.info(`cannot dispose, already disposed!`);return}if(e.info(`disposing the interceptor...`),this.readyState=`DISPOSING`,!this.getInstance()){e.info(`no interceptors running, skipping dispose...`);return}if(this.clearInstance(),e.info(`global symbol deleted:`,Le(this.symbol)),this.subscriptions.length>0){e.info(`disposing of %d subscriptions...`,this.subscriptions.length);for(let e of this.subscriptions)e();this.subscriptions=[],e.info(`disposed of all subscriptions!`,this.subscriptions.length)}this.emitter.removeAllListeners(),e.info(`destroyed the listener!`),this.readyState=`DISPOSED`}getInstance(){let e=Le(this.symbol);return this.logger.info(`retrieved global instance:`,e?.constructor?.name),e}setInstance(){Re(this.symbol,this),this.logger.info(`set global instance!`,this.symbol.description)}clearInstance(){ze(this.symbol),this.logger.info(`cleared global instance!`,this.symbol.description)}};function Ve(){return Math.random().toString(16).slice(2)}function He(){let e=(t,n)=>{e.state=`pending`,e.resolve=n=>e.state===`pending`?(e.result=n,t(n instanceof Promise?n:Promise.resolve(n).then(t=>(e.state=`fulfilled`,t)))):void 0,e.reject=t=>{if(e.state===`pending`)return queueMicrotask(()=>{e.state=`rejected`}),n(e.rejectionReason=t)}};return e}var Ue=class extends Promise{#e;resolve;reject;constructor(e=null){let t=He();super((n,r)=>{t(n,r),e?.(t.resolve,t.reject)}),this.#e=t,this.resolve=this.#e.resolve,this.reject=this.#e.reject}get state(){return this.#e.state}get rejectionReason(){return this.#e.rejectionReason}then(e,t){return this.#t(super.then(e,t))}catch(e){return this.#t(super.catch(e))}finally(e){return this.#t(super.finally(e))}#t(e){return Object.defineProperties(e,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})}},We=Symbol(`isPatchedModule`),Ge=class extends Error{constructor(e){super(e),this.name=`InterceptorError`,Object.setPrototypeOf(this,Ge.prototype)}},Ke,qe,Je=class{constructor(e,t){this.request=e,this.source=t,Fe(this,Ke),this.readyState=Je.PENDING,this.handled=new Ue}async passthrough(){Y.as(Ge,this.readyState===Je.PENDING,`Failed to passthrough the "%s %s" request: the request has already been handled`,this.request.method,this.request.url),this.readyState=Je.PASSTHROUGH,await this.source.passthrough(),Pe(this,Ke,qe).resolve()}respondWith(e){Y.as(Ge,this.readyState===Je.PENDING,`Failed to respond to the "%s %s" request with "%d %s": the request has already been handled (%d)`,this.request.method,this.request.url,e.status,e.statusText||`OK`,this.readyState),this.readyState=Je.RESPONSE,Pe(this,Ke,qe).resolve(),this.source.respondWith(e)}errorWith(e){Y.as(Ge,this.readyState===Je.PENDING,`Failed to error the "%s %s" request with "%s": the request has already been handled (%d)`,this.request.method,this.request.url,e?.toString(),this.readyState),this.readyState=Je.ERROR,this.source.errorWith(e),Pe(this,Ke,qe).resolve()}},Ye=Je;Ke=new WeakSet,qe=function(){return this.handled},Ye.PENDING=0,Ye.PASSTHROUGH=1,Ye.RESPONSE=2,Ye.ERROR=3;function Xe(e){try{return new URL(e),!0}catch{return!1}}function Ze(e,t){let n=Object.getOwnPropertySymbols(t).find(t=>t.description===e);if(n)return Reflect.get(t,n)}var Qe=class extends Response{static isConfigurableStatusCode(e){return e>=200&&e<=599}static isRedirectResponse(e){return Qe.STATUS_CODES_WITH_REDIRECT.includes(e)}static isResponseWithBody(e){return!Qe.STATUS_CODES_WITHOUT_BODY.includes(e)}static setUrl(e,t){if(!e||e===`about:`||!Xe(e))return;let n=Ze(`state`,t);n?n.urlList.push(new URL(e)):Object.defineProperty(t,`url`,{value:e,enumerable:!0,configurable:!0,writable:!1})}static parseRawHeaders(e){let t=new Headers;for(let n=0;n<e.length;n+=2)t.append(e[n],e[n+1]);return t}constructor(e,t={}){let n=t.status??200,r=Qe.isConfigurableStatusCode(n)?n:200,i=Qe.isResponseWithBody(n)?e:null;if(super(i,{status:r,statusText:t.statusText,headers:t.headers}),n!==r){let e=Ze(`state`,this);e?e.status=n:Object.defineProperty(this,`status`,{value:n,enumerable:!0,configurable:!0,writable:!1})}Qe.setUrl(t.url,this)}},$e=Qe;$e.STATUS_CODES_WITHOUT_BODY=[101,103,204,205,304],$e.STATUS_CODES_WITH_REDIRECT=[301,302,303,307,308];var et=Symbol(`kRawRequest`);function tt(e,t){Reflect.set(e,et,t)}var nt=class extends Be{constructor(e){nt.symbol=Symbol(e.name),super(nt.symbol),this.interceptors=e.interceptors}setup(){let e=this.logger.extend(`setup`);e.info(`applying all %d interceptors...`,this.interceptors.length);for(let t of this.interceptors)e.info(`applying "%s" interceptor...`,t.constructor.name),t.apply(),e.info(`adding interceptor dispose subscription`),this.subscriptions.push(()=>t.dispose())}on(e,t){for(let n of this.interceptors)n.on(e,t);return this}once(e,t){for(let n of this.interceptors)n.once(e,t);return this}off(e,t){for(let n of this.interceptors)n.off(e,t);return this}removeAllListeners(e){for(let t of this.interceptors)t.removeAllListeners(e);return this}};async function rt(e,t,...n){let r=e.listeners(t);if(r.length!==0)for(let t of r)await t.apply(e,n)}function it(e){let t=Object.getOwnPropertyDescriptor(globalThis,e);return t===void 0||typeof t.get==`function`&&t.get()===void 0||t.get===void 0&&t.value==null?!1:t.set===void 0&&!t.configurable?(console.error(`[MSW] Failed to apply interceptor: the global \`${e}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`),!1):!0}var at=async e=>{try{return{error:null,data:await e().catch(e=>{throw e})}}catch(e){return{error:e,data:null}}};function ot(e,t=!1){return t?Object.prototype.toString.call(e).startsWith(`[object `):Object.prototype.toString.call(e)===`[object Object]`}function st(e,t){try{return e[t],!0}catch{return!1}}function ct(e){return new Response(JSON.stringify(e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:e),{status:500,statusText:`Unhandled Exception`,headers:{"Content-Type":`application/json`}})}function lt(e){return e!=null&&e instanceof Response&&st(e,`type`)&&e.type===`error`}function ut(e){return ot(e,!0)&&st(e,`status`)&&st(e,`statusText`)&&st(e,`bodyUsed`)}function dt(e){return e==null||!(e instanceof Error)?!1:`code`in e&&`errno`in e}async function ft(e){let t=async t=>t instanceof Error?(await e.controller.errorWith(t),!0):lt(t)||ut(t)?(await e.controller.respondWith(t),!0):ot(t)?(await e.controller.errorWith(t),!0):!1,n=async n=>{if(n instanceof Ge)throw i.error;return dt(n)?(await e.controller.errorWith(n),!0):n instanceof Response?await t(n):!1},r=new Ue;if(e.request.signal){if(e.request.signal.aborted){await e.controller.errorWith(e.request.signal.reason);return}e.request.signal.addEventListener(`abort`,()=>{r.reject(e.request.signal.reason)},{once:!0})}let i=await at(async()=>{let t=rt(e.emitter,`request`,{requestId:e.requestId,request:e.request,controller:e.controller});await Promise.race([r,t,e.controller.handled])});if(r.state===`rejected`){await e.controller.errorWith(r.rejectionReason);return}if(i.error){if(await n(i.error))return;if(e.emitter.listenerCount(`unhandledException`)>0){let n=new Ye(e.request,{passthrough(){},async respondWith(e){await t(e)},async errorWith(t){await e.controller.errorWith(t)}});if(await rt(e.emitter,`unhandledException`,{error:i.error,request:e.request,requestId:e.requestId,controller:n}),n.readyState!==Ye.PENDING)return}await e.controller.respondWith(ct(i.error));return}return e.controller.readyState===Ye.PENDING?await e.controller.passthrough():e.controller.handled}function pt(e){return Object.assign(TypeError(`Failed to fetch`),{cause:e})}var mt=[`content-encoding`,`content-language`,`content-location`,`content-type`,`content-length`],ht=Symbol(`kRedirectCount`);async function gt(e,t){if(t.status!==303&&e.body!=null)return Promise.reject(pt());let n=new URL(e.url),r;try{r=new URL(t.headers.get(`location`),e.url)}catch(e){return Promise.reject(pt(e))}if(!(r.protocol===`http:`||r.protocol===`https:`))return Promise.reject(pt(`URL scheme must be a HTTP(S) scheme`));if(Reflect.get(e,ht)>20)return Promise.reject(pt(`redirect count exceeded`));if(Object.defineProperty(e,ht,{value:(Reflect.get(e,ht)||0)+1}),e.mode===`cors`&&(r.username||r.password)&&!_t(n,r))return Promise.reject(pt(`cross origin not allowed for request mode "cors"`));let i={};([301,302].includes(t.status)&&e.method===`POST`||t.status===303&&![`HEAD`,`GET`].includes(e.method))&&(i.method=`GET`,i.body=null,mt.forEach(t=>{e.headers.delete(t)})),_t(n,r)||(e.headers.delete(`authorization`),e.headers.delete(`proxy-authorization`),e.headers.delete(`cookie`),e.headers.delete(`host`)),i.headers=e.headers;let a=await fetch(new Request(r,i));return Object.defineProperty(a,`redirected`,{value:!0,configurable:!0}),a}function _t(e,t){return e.origin===t.origin&&e.origin===`null`||e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port}var vt=class extends TransformStream{constructor(){console.warn(`[Interceptors]: Brotli decompression of response streams is not supported in the browser`),super({transform(e,t){t.enqueue(e)}})}},yt=class extends TransformStream{constructor(e,...t){super({},...t);let n=[super.readable,...e].reduce((e,t)=>e.pipeThrough(t));Object.defineProperty(this,`readable`,{get(){return n}})}};function bt(e){return e.toLowerCase().split(`,`).map(e=>e.trim())}function xt(e){if(e===``)return null;let t=bt(e);return t.length===0?null:new yt(t.reduceRight((e,t)=>t===`gzip`||t===`x-gzip`?e.concat(new DecompressionStream(`gzip`)):t===`deflate`?e.concat(new DecompressionStream(`deflate`)):t===`br`?e.concat(new vt):(e.length=0,e),[]))}function St(e){if(e.body===null)return null;let t=xt(e.headers.get(`content-encoding`)||``);return t?(e.body.pipeTo(t.writable),t.readable):null}var Ct=class extends Be{constructor(){super(Ct.symbol)}checkEnvironment(){return it(`fetch`)}async setup(){let e=globalThis.fetch;Y(!e[We],`Failed to patch the "fetch" module: already patched.`),globalThis.fetch=async(t,n)=>{let r=Ve(),i=typeof t==`string`&&typeof location<`u`&&!Xe(t)?new URL(t,location.href):t,a=new Request(i,n);t instanceof Request&&tt(a,t);let o=new Ue,s=new Ye(a,{passthrough:async()=>{this.logger.info(`request has not been handled, passthrough...`);let t=a.clone(),{error:n,data:i}=await at(()=>e(a));if(n)return o.reject(n);if(this.logger.info(`original fetch performed`,i),this.emitter.listenerCount(`response`)>0){this.logger.info(`emitting the "response" event...`);let e=i.clone();await rt(this.emitter,`response`,{response:e,isMockedResponse:!1,request:t,requestId:r})}o.resolve(i)},respondWith:async e=>{if(lt(e)){this.logger.info(`request has errored!`,{response:e}),o.reject(pt(e));return}this.logger.info(`received mocked response!`,{rawResponse:e});let t=St(e),n=t===null?e:new $e(t,e);if($e.setUrl(a.url,n),$e.isRedirectResponse(n.status)){if(a.redirect===`error`){o.reject(pt(`unexpected redirect`));return}if(a.redirect===`follow`){gt(a,n).then(e=>{o.resolve(e)},e=>{o.reject(e)});return}}this.emitter.listenerCount(`response`)>0&&(this.logger.info(`emitting the "response" event...`),await rt(this.emitter,`response`,{response:n.clone(),isMockedResponse:!0,request:a,requestId:r})),o.resolve(n)},errorWith:e=>{this.logger.info(`request has been aborted!`,{reason:e}),o.reject(e)}});return this.logger.info(`[%s] %s`,a.method,a.url),this.logger.info(`awaiting for the mocked response...`),this.logger.info(`emitting the "request" event for %s listener(s)...`,this.emitter.listenerCount(`request`)),await ft({request:a,requestId:r,emitter:this.emitter,controller:s}),o},Object.defineProperty(globalThis.fetch,We,{enumerable:!0,configurable:!0,value:!0}),this.subscriptions.push(()=>{Object.defineProperty(globalThis.fetch,We,{value:void 0}),globalThis.fetch=e,this.logger.info(`restored native "globalThis.fetch"!`,globalThis.fetch.name)})}},wt=Ct;wt.symbol=Symbol(`fetch`);function Tt(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}var Et=class{constructor(e,t){this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.type=``,this.srcElement=null,this.currentTarget=null,this.eventPhase=0,this.isTrusted=!0,this.composed=!1,this.cancelable=!0,this.defaultPrevented=!1,this.bubbles=!0,this.lengthComputable=!0,this.loaded=0,this.total=0,this.cancelBubble=!1,this.returnValue=!0,this.type=e,this.target=t?.target||null,this.currentTarget=t?.currentTarget||null,this.timeStamp=Date.now()}composedPath(){return[]}initEvent(e,t,n){this.type=e,this.bubbles=!!t,this.cancelable=!!n}preventDefault(){this.defaultPrevented=!0}stopPropagation(){}stopImmediatePropagation(){}},Dt=class extends Et{constructor(e,t){super(e),this.lengthComputable=t?.lengthComputable||!1,this.composed=t?.composed||!1,this.loaded=t?.loaded||0,this.total=t?.total||0}},Ot=typeof ProgressEvent<`u`;function kt(e,t,n){let r=[`error`,`progress`,`loadstart`,`loadend`,`load`,`timeout`,`abort`],i=Ot?ProgressEvent:Dt;return r.includes(t)?new i(t,{lengthComputable:!0,loaded:n?.loaded||0,total:n?.total||0}):new Et(t,{target:e,currentTarget:e})}function At(e,t){if(!(t in e))return null;if(Object.prototype.hasOwnProperty.call(e,t))return e;let n=Reflect.getPrototypeOf(e);return n?At(n,t):null}function jt(e,t){return new Proxy(e,Mt(t))}function Mt(e){let{constructorCall:t,methodCall:n,getProperty:r,setProperty:i}=e,a={};return t!==void 0&&(a.construct=function(e,n,r){let i=Reflect.construct.bind(null,e,n,r);return t.call(r,n,i)}),a.set=function(e,t,n){let r=()=>{let r=At(e,t)||e,i=Reflect.getOwnPropertyDescriptor(r,t);return i?.set===void 0?Reflect.defineProperty(r,t,{writable:!0,enumerable:!0,configurable:!0,value:n}):(i.set.apply(e,[n]),!0)};return i===void 0?r():i.call(e,[t,n],r)},a.get=function(e,t,i){let a=()=>e[t],o=r===void 0?a():r.call(e,[t,i],a);return typeof o==`function`?(...r)=>{let i=o.bind(e,...r);return n===void 0?i():n.call(e,[t,r],i)}:o},a}function Nt(e){return[`application/xhtml+xml`,`application/xml`,`image/svg+xml`,`text/html`,`text/xml`].some(t=>e.startsWith(t))}function Pt(e){try{return JSON.parse(e)}catch{return null}}function Ft(e,t){return new $e($e.isResponseWithBody(e.status)?t:null,{url:e.responseURL,status:e.status,statusText:e.statusText,headers:It(e.getAllResponseHeaders())})}function It(e){let t=new Headers,n=e.split(/[\r\n]+/);for(let e of n){if(e.trim()===``)continue;let[n,...r]=e.split(`: `),i=r.join(`: `);t.append(n,i)}return t}async function Lt(e){let t=e.headers.get(`content-length`);return t!=null&&t!==``?Number(t):(await e.arrayBuffer()).byteLength}var Rt=Symbol(`kIsRequestHandled`),zt=le(),Bt=Symbol(`kFetchRequest`),Vt=class{constructor(e,t){this.initialRequest=e,this.logger=t,this.method=`GET`,this.url=null,this[Rt]=!1,this.events=new Map,this.uploadEvents=new Map,this.requestId=Ve(),this.requestHeaders=new Headers,this.responseBuffer=new Uint8Array,this.request=jt(e,{setProperty:([e,t],n)=>{switch(e){case`ontimeout`:{let r=e.slice(2);return this.request.addEventListener(r,t),n()}default:return n()}},methodCall:([e,t],n)=>{switch(e){case`open`:{let[e,r]=t;return r===void 0?(this.method=`GET`,this.url=Ht(e)):(this.method=e,this.url=Ht(r)),this.logger=this.logger.extend(`${this.method} ${this.url.href}`),this.logger.info(`open`,this.method,this.url.href),n()}case`addEventListener`:{let[e,r]=t;return this.registerEvent(e,r),this.logger.info(`addEventListener`,e,r),n()}case`setRequestHeader`:{let[e,r]=t;return this.requestHeaders.set(e,r),this.logger.info(`setRequestHeader`,e,r),n()}case`send`:{let[e]=t;this.request.addEventListener(`load`,()=>{if(this.onResponse!==void 0){let e=Ft(this.request,this.request.response);this.onResponse.call(this,{response:e,isMockedResponse:this[Rt],request:i,requestId:this.requestId})}});let r=typeof e==`string`?se(e):e,i=this.toFetchApiRequest(r);this[Bt]=i.clone(),queueMicrotask(()=>{(this.onRequest?.call(this,{request:i,requestId:this.requestId})||Promise.resolve()).finally(()=>{if(!this[Rt])return this.logger.info(`request callback settled but request has not been handled (readystate %d), performing as-is...`,this.request.readyState),zt&&this.request.setRequestHeader(Ie,this.requestId),n()})});break}default:return n()}}}),Ut(this.request,`upload`,jt(this.request.upload,{setProperty:([e,t],n)=>{switch(e){case`onloadstart`:case`onprogress`:case`onaboart`:case`onerror`:case`onload`:case`ontimeout`:case`onloadend`:{let n=e.slice(2);this.registerUploadEvent(n,t)}}return n()},methodCall:([e,t],n)=>{switch(e){case`addEventListener`:{let[e,r]=t;return this.registerUploadEvent(e,r),this.logger.info(`upload.addEventListener`,e,r),n()}}}}))}registerEvent(e,t){let n=(this.events.get(e)||[]).concat(t);this.events.set(e,n),this.logger.info(`registered event "%s"`,e,t)}registerUploadEvent(e,t){let n=(this.uploadEvents.get(e)||[]).concat(t);this.uploadEvents.set(e,n),this.logger.info(`registered upload event "%s"`,e,t)}async respondWith(e){if(this[Rt]=!0,this[Bt]){let e=await Lt(this[Bt]);this.trigger(`loadstart`,this.request.upload,{loaded:0,total:e}),this.trigger(`progress`,this.request.upload,{loaded:e,total:e}),this.trigger(`load`,this.request.upload,{loaded:e,total:e}),this.trigger(`loadend`,this.request.upload,{loaded:e,total:e})}this.logger.info(`responding with a mocked response: %d %s`,e.status,e.statusText),Ut(this.request,`status`,e.status),Ut(this.request,`statusText`,e.statusText),Ut(this.request,`responseURL`,this.url.href),this.request.getResponseHeader=new Proxy(this.request.getResponseHeader,{apply:(t,n,r)=>{if(this.logger.info(`getResponseHeader`,r[0]),this.request.readyState<this.request.HEADERS_RECEIVED)return this.logger.info(`headers not received yet, returning null`),null;let i=e.headers.get(r[0]);return this.logger.info(`resolved response header "%s" to`,r[0],i),i}}),this.request.getAllResponseHeaders=new Proxy(this.request.getAllResponseHeaders,{apply:()=>{if(this.logger.info(`getAllResponseHeaders`),this.request.readyState<this.request.HEADERS_RECEIVED)return this.logger.info(`headers not received yet, returning empty string`),``;let t=Array.from(e.headers.entries()).map(([e,t])=>`${e}: ${t}`).join(`\r
7
+ `);return this.logger.info(`resolved all response headers to`,t),t}}),Object.defineProperties(this.request,{response:{enumerable:!0,configurable:!1,get:()=>this.response},responseText:{enumerable:!0,configurable:!1,get:()=>this.responseText},responseXML:{enumerable:!0,configurable:!1,get:()=>this.responseXML}});let t=await Lt(e.clone());this.logger.info(`calculated response body length`,t),this.trigger(`loadstart`,this.request,{loaded:0,total:t}),this.setReadyState(this.request.HEADERS_RECEIVED),this.setReadyState(this.request.LOADING);let n=()=>{this.logger.info(`finalizing the mocked response...`),this.setReadyState(this.request.DONE),this.trigger(`load`,this.request,{loaded:this.responseBuffer.byteLength,total:t}),this.trigger(`loadend`,this.request,{loaded:this.responseBuffer.byteLength,total:t})};if(e.body){this.logger.info(`mocked response has body, streaming...`);let r=e.body.getReader(),i=async()=>{let{value:e,done:a}=await r.read();if(a){this.logger.info(`response body stream done!`),n();return}e&&(this.logger.info(`read response body chunk:`,e),this.responseBuffer=Tt(this.responseBuffer,e),this.trigger(`progress`,this.request,{loaded:this.responseBuffer.byteLength,total:t})),i()};i()}else n()}responseBufferToText(){return ce(this.responseBuffer)}get response(){if(this.logger.info(`getResponse (responseType: %s)`,this.request.responseType),this.request.readyState!==this.request.DONE)return null;switch(this.request.responseType){case`json`:{let e=Pt(this.responseBufferToText());return this.logger.info(`resolved response JSON`,e),e}case`arraybuffer`:{let e=K(this.responseBuffer);return this.logger.info(`resolved response ArrayBuffer`,e),e}case`blob`:{let e=this.request.getResponseHeader(`Content-Type`)||`text/plain`,t=new Blob([this.responseBufferToText()],{type:e});return this.logger.info(`resolved response Blob (mime type: %s)`,t,e),t}default:{let e=this.responseBufferToText();return this.logger.info(`resolving "%s" response type as text`,this.request.responseType,e),e}}}get responseText(){if(Y(this.request.responseType===``||this.request.responseType===`text`,`InvalidStateError: The object is in invalid state.`),this.request.readyState!==this.request.LOADING&&this.request.readyState!==this.request.DONE)return``;let e=this.responseBufferToText();return this.logger.info(`getResponseText: "%s"`,e),e}get responseXML(){if(Y(this.request.responseType===``||this.request.responseType===`document`,`InvalidStateError: The object is in invalid state.`),this.request.readyState!==this.request.DONE)return null;let e=this.request.getResponseHeader(`Content-Type`)||``;return typeof DOMParser>`u`?(console.warn(`Cannot retrieve XMLHttpRequest response body as XML: DOMParser is not defined. You are likely using an environment that is not browser or does not polyfill browser globals correctly.`),null):Nt(e)?new DOMParser().parseFromString(this.responseBufferToText(),e):null}errorWith(e){this[Rt]=!0,this.logger.info(`responding with an error`),this.setReadyState(this.request.DONE),this.trigger(`error`,this.request),this.trigger(`loadend`,this.request)}setReadyState(e){if(this.logger.info(`setReadyState: %d -> %d`,this.request.readyState,e),this.request.readyState===e){this.logger.info(`ready state identical, skipping transition...`);return}Ut(this.request,`readyState`,e),this.logger.info(`set readyState to: %d`,e),e!==this.request.UNSENT&&(this.logger.info(`triggering "readystatechange" event...`),this.trigger(`readystatechange`,this.request))}trigger(e,t,n){let r=t[`on${e}`],i=kt(t,e,n);this.logger.info(`trigger "%s"`,e,n||``),typeof r==`function`&&(this.logger.info(`found a direct "%s" callback, calling...`,e),r.call(t,i));let a=t instanceof XMLHttpRequestUpload?this.uploadEvents:this.events;for(let[n,r]of a)n===e&&(this.logger.info(`found %d listener(s) for "%s" event, calling...`,r.length,e),r.forEach(e=>e.call(t,i)))}toFetchApiRequest(e){this.logger.info(`converting request to a Fetch API Request...`);let t=e instanceof Document?e.documentElement.innerText:e,n=new Request(this.url.href,{method:this.method,headers:this.requestHeaders,credentials:this.request.withCredentials?`include`:`same-origin`,body:[`GET`,`HEAD`].includes(this.method.toUpperCase())?null:t});return Ut(n,`headers`,jt(n.headers,{methodCall:([e,t],r)=>{switch(e){case`append`:case`set`:{let[e,n]=t;this.request.setRequestHeader(e,n);break}case`delete`:{let[e]=t;console.warn(`XMLHttpRequest: Cannot remove a "${e}" header from the Fetch API representation of the "${n.method} ${n.url}" request. XMLHttpRequest headers cannot be removed.`);break}}return r()}})),tt(n,this.request),this.logger.info(`converted request to a Fetch API Request!`,n),n}};function Ht(e){return typeof location>`u`?new URL(e):new URL(e.toString(),location.href)}function Ut(e,t,n){Reflect.defineProperty(e,t,{writable:!0,enumerable:!0,value:n})}function Wt({emitter:e,logger:t}){return new Proxy(globalThis.XMLHttpRequest,{construct(n,r,i){t.info(`constructed new XMLHttpRequest`);let a=Reflect.construct(n,r,i),o=Object.getOwnPropertyDescriptors(n.prototype);for(let e in o)Reflect.defineProperty(a,e,o[e]);let s=new Vt(a,t);return s.onRequest=async function({request:t,requestId:n}){let r=new Ye(t,{passthrough:()=>{this.logger.info(`no mocked response received, performing request as-is...`)},respondWith:async e=>{if(lt(e)){this.errorWith(TypeError(`Network error`));return}await this.respondWith(e)},errorWith:e=>{this.logger.info(`request errored!`,{error:e}),e instanceof Error&&this.errorWith(e)}});this.logger.info(`awaiting mocked response...`),this.logger.info(`emitting the "request" event for %s listener(s)...`,e.listenerCount(`request`)),await ft({request:t,requestId:n,controller:r,emitter:e})},s.onResponse=async function({response:t,isMockedResponse:n,request:r,requestId:i}){this.logger.info(`emitting the "response" event for %s listener(s)...`,e.listenerCount(`response`)),e.emit(`response`,{response:t,isMockedResponse:n,request:r,requestId:i})},s.request}})}var Gt=class extends Be{constructor(){super(Gt.interceptorSymbol)}checkEnvironment(){return it(`XMLHttpRequest`)}setup(){let e=this.logger.extend(`setup`);e.info(`patching "XMLHttpRequest" module...`);let t=globalThis.XMLHttpRequest;Y(!t[We],`Failed to patch the "XMLHttpRequest" module: already patched.`),globalThis.XMLHttpRequest=Wt({emitter:this.emitter,logger:this.logger}),e.info(`native "XMLHttpRequest" module patched!`,globalThis.XMLHttpRequest.name),Object.defineProperty(globalThis.XMLHttpRequest,We,{enumerable:!0,configurable:!0,value:!0}),this.subscriptions.push(()=>{Object.defineProperty(globalThis.XMLHttpRequest,We,{value:void 0}),globalThis.XMLHttpRequest=t,e.info(`native "XMLHttpRequest" module restored!`,globalThis.XMLHttpRequest.name)})}},Kt=Gt;Kt.interceptorSymbol=Symbol(`xhr`);const qt=1e4;function Jt(e){if(!e?.disableChrome)return;let t=`${re()}/__inspector__/log`,n={log:console.log,warn:console.warn,error:console.error,info:console.info,debug:console.debug};[`log`,`warn`,`error`,`info`,`debug`].forEach(e=>{console[e]=(...r)=>{n[e].apply(console,r);let i=r.map(e=>{try{if(typeof e==`object`&&e){let t=new Set;return JSON.parse(JSON.stringify(e,(e,n)=>{if(typeof n==`object`&&n){if(t.has(n))return`[Circular]`;t.add(n)}return n}))}return e}catch{return String(e)}});fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`console`,data:{type:e,args:i}}),keepalive:!0}).catch(()=>{})}});let r=new nt({name:`dev-inspector-interceptor`,interceptors:[new wt,new Kt]});r.apply(),r.on(`response`,async({request:e,response:n})=>{if(!(e.url.includes(`/__inspector__`)||e.url.includes(`/__mcp__`)||e.url.includes(`/api/acp/chat`)))try{let r={};e.headers.forEach((e,t)=>{r[t]=e});let i={};n.headers.forEach((e,t)=>{i[t]=e});let a=``;try{let e=n.clone(),t=n.headers.get(`content-type`)||``;if(t.includes(`application/json`)){let t=await e.json();a=JSON.stringify(t,null,2)}else a=t.includes(`text/`)?await e.text():`<Binary data, ${t}>`;a.length>qt&&(a=a.substring(0,qt)+`
8
8
  ... (truncated)`)}catch{a=`<Failed to read response body>`}let o=`Request:
9
9
  Method: ${e.method}
10
10
  URL: ${e.url}
@@ -18,18 +18,18 @@ Response:
18
18
  ${Object.entries(i).map(([e,t])=>` ${e}: ${t}`).join(`
19
19
  `)}
20
20
  Body:
21
- ${a}`;fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`network`,data:{method:e.method,url:e.url,status:n.status,duration:0,details:o}}),keepalive:!0}).catch(()=>{})}catch{fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`network`,data:{method:e.method,url:e.url,status:n.status,duration:0}}),keepalive:!0}).catch(()=>{})}})}var X=D();const Xt=({message:e})=>(0,X.jsx)(`div`,{className:`fixed top-5 right-5 z-[1000000] animate-in slide-in-from-right duration-300`,children:(0,X.jsx)(`div`,{className:`bg-background border border-border rounded-lg shadow-lg px-4 py-3 text-sm font-medium text-foreground backdrop-blur-sm`,children:e})}),Zt=t(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Qt=t(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),$t=t(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),en=t(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),tn=t(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),nn=t(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),rn=t(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),an=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),on=t(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),sn=t(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),cn=t(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),ln=t(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),un=t(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),dn=t(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),fn=t(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),pn=t(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),mn=t(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),hn=t(`square-dashed`,[[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M21 14v1`,key:`169vum`}]]),gn=t(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),_n=t(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),vn=t(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),yn=({children:e,className:t,...n})=>(0,X.jsx)(`div`,{className:_(`text-muted-foreground text-sm`,t),...n,children:e}),bn=({defaultOpen:e=!0,className:t,...n})=>(0,X.jsx)(a,{className:_(t),defaultOpen:e,...n}),xn=({children:e,className:t,title:n,...r})=>(0,X.jsx)(f,{asChild:!0,className:_(`group`,t),...r,children:e??(0,X.jsxs)(`div`,{className:`flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,children:[(0,X.jsx)(pn,{className:`size-4`}),(0,X.jsx)(`p`,{className:`text-sm`,children:n}),(0,X.jsx)(p,{className:`size-4 transition-transform group-data-[state=open]:rotate-180`})]})}),Sn=({children:e,className:t,...n})=>(0,X.jsx)(i,{className:_(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,t),...n,children:(0,X.jsx)(`div`,{className:`mt-4 space-y-2 border-muted border-l-2 pl-4`,children:e})}),Cn=e=>e===`completed`?(0,X.jsx)(S,{className:`size-4 text-green-500`}):e===`in-progress`?(0,X.jsx)(cn,{className:`size-4 text-blue-500 animate-spin`}):e===`failed`?(0,X.jsx)(tn,{className:`size-4 text-red-500`}):(0,X.jsx)(x,{className:`size-4 text-gray-400`}),wn=e=>e===`completed`?`Completed`:e===`in-progress`?`In Progress`:e===`failed`?`Failed`:`Pending`;function Tn({plan:e}){let[t,n]=(0,U.useState)(!0);if(!e||!e.steps||e.steps.length===0)return null;let r=e.steps.filter(e=>e.status===`completed`).length,i=e.steps.length;return(0,X.jsx)(`div`,{className:`w-full space-y-2`,children:(0,X.jsxs)(bn,{defaultOpen:t,children:[(0,X.jsx)(xn,{title:`Plan Progress: ${r}/${i} (${Math.round(r/i*100)}%)`,onClick:()=>n(!t)}),(0,X.jsx)(Sn,{children:(0,X.jsx)(`div`,{className:`space-y-3`,children:e.steps.map(e=>(0,X.jsx)(yn,{children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[Cn(e.status),(0,X.jsxs)(`div`,{className:`flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:wn(e.status)})]}),e.description&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.description})]})]})},e.id))})})]})})}function En(){let[e,t]=(0,U.useState)(null);return(0,U.useEffect)(()=>{function e(e){t(e.detail.plan)}return window.addEventListener(`plan-progress-reported`,e),()=>window.removeEventListener(`plan-progress-reported`,e)},[]),e}function Dn(e,t,n=!0){let[r,i]=(0,U.useState)({consoleMessages:[],networkRequests:[],stdioMessages:[],loading:!1,error:null}),a=(0,U.useCallback)(async()=>{if(n){if(!e||!t){i(e=>({...e,error:`MCP client not ready`}));return}i(e=>({...e,loading:!0,error:null}));try{let t=``,n=``,r=[];try{let r=await e.callTool({name:`chrome_devtools`,arguments:{useTool:`chrome_list_console_messages`,hasDefinitions:[`chrome_list_console_messages`],chrome_list_console_messages:{}}}),i=await e.callTool({name:`chrome_devtools`,arguments:{useTool:`chrome_list_network_requests`,hasDefinitions:[`chrome_list_network_requests`],chrome_list_network_requests:{}}});t=(r?.content)?.map(e=>e.text).join(`
21
+ ${a}`;fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`network`,data:{method:e.method,url:e.url,status:n.status,duration:0,details:o}}),keepalive:!0}).catch(()=>{})}catch{fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`network`,data:{method:e.method,url:e.url,status:n.status,duration:0}}),keepalive:!0}).catch(()=>{})}})}var Q=ae();const Yt=({message:e})=>(0,Q.jsx)(`div`,{className:`fixed top-5 right-5 z-[1000000] animate-in slide-in-from-right duration-300`,children:(0,Q.jsx)(`div`,{className:`bg-background border border-border rounded-lg shadow-lg px-4 py-3 text-sm font-medium text-foreground backdrop-blur-sm`,children:e})}),Xt=D(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Zt=D(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Qt=D(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),$t=D(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),en=D(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),tn=D(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),nn=D(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),rn=D(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),an=D(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),on=D(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),sn=D(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),cn=D(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),ln=D(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),un=D(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),dn=D(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),fn=D(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),pn=D(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),mn=D(`square-dashed`,[[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M21 14v1`,key:`169vum`}]]),hn=D(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),gn=D(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),_n=D(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),vn=({children:e,className:t,...n})=>(0,Q.jsx)(`div`,{className:y(`text-muted-foreground text-sm`,t),...n,children:e}),yn=({defaultOpen:e=!0,className:t,...n})=>(0,Q.jsx)(i,{className:y(t),defaultOpen:e,...n}),bn=({children:e,className:n,title:r,...i})=>(0,Q.jsx)(N,{asChild:!0,className:y(`group`,n),...i,children:e??(0,Q.jsxs)(`div`,{className:`flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,children:[(0,Q.jsx)(fn,{className:`size-4`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:r}),(0,Q.jsx)(t,{className:`size-4 transition-transform group-data-[state=open]:rotate-180`})]})}),xn=({children:e,className:t,...n})=>(0,Q.jsx)(f,{className:y(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,t),...n,children:(0,Q.jsx)(`div`,{className:`mt-4 space-y-2 border-muted border-l-2 pl-4`,children:e})}),Sn=e=>e===`completed`?(0,Q.jsx)(p,{className:`size-4 text-green-500`}):e===`in-progress`?(0,Q.jsx)(sn,{className:`size-4 text-blue-500 animate-spin`}):e===`failed`?(0,Q.jsx)(en,{className:`size-4 text-red-500`}):(0,Q.jsx)(b,{className:`size-4 text-gray-400`}),Cn=e=>e===`completed`?`Completed`:e===`in-progress`?`In Progress`:e===`failed`?`Failed`:`Pending`;function wn({plan:e}){let[t,n]=(0,G.useState)(!0);if(!e||!e.steps||e.steps.length===0)return null;let r=e.steps.filter(e=>e.status===`completed`).length,i=e.steps.length;return(0,Q.jsx)(`div`,{className:`w-full space-y-2`,children:(0,Q.jsxs)(yn,{defaultOpen:t,children:[(0,Q.jsx)(bn,{title:`Plan Progress: ${r}/${i} (${Math.round(r/i*100)}%)`,onClick:()=>n(!t)}),(0,Q.jsx)(xn,{children:(0,Q.jsx)(`div`,{className:`space-y-3`,children:e.steps.map(e=>(0,Q.jsx)(vn,{children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[Sn(e.status),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Cn(e.status)})]}),e.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.description})]})]})},e.id))})})]})})}function Tn(){let[e,t]=(0,G.useState)(null);return(0,G.useEffect)(()=>{function e(e){t(e.detail.plan)}return window.addEventListener(`plan-progress-reported`,e),()=>window.removeEventListener(`plan-progress-reported`,e)},[]),e}function En(e,t,n=!0){let[r,i]=(0,G.useState)({consoleMessages:[],networkRequests:[],stdioMessages:[],loading:!1,error:null}),a=(0,G.useCallback)(async()=>{if(n){if(!e||!t){i(e=>({...e,error:`MCP client not ready`}));return}i(e=>({...e,loading:!0,error:null}));try{let t=``,n=``,r=[];try{let r=await e.callTool({name:`chrome_devtools`,arguments:{useTool:`chrome_list_console_messages`,hasDefinitions:[`chrome_list_console_messages`],chrome_list_console_messages:{}}}),i=await e.callTool({name:`chrome_devtools`,arguments:{useTool:`chrome_list_network_requests`,hasDefinitions:[`chrome_list_network_requests`],chrome_list_network_requests:{}}});t=(r?.content)?.map(e=>e.text).join(`
22
22
  `)||``,n=(i?.content)?.map(e=>e.text).join(`
23
23
  `)||``}catch(r){try{let r=await e.getPrompt({name:`get_console_messages`}),i=await e.getPrompt({name:`get_network_requests`}),a=r.messages[0]?.content,o=i.messages[0]?.content,s=(a?.type===`text`?a.text:``)+`
24
- `+(o?.type===`text`?o.text:``);t=s,n=s}catch(e){throw console.error(`[useContextData] Prompts fallback failed:`,e),r}}try{let e=typeof window<`u`?window.__DEV_INSPECTOR_CONFIG__:null,t=``;e&&(t=e.baseUrl||`http://${e.host}:${e.port}${e.base||`/`}`,t.endsWith(`/`)&&(t=t.slice(0,-1)));let n=await fetch(`${t}/__inspector__/stdio`);n.ok&&(r=(await n.json()).map(e=>({stdioid:e.id,stream:e.stream,data:e.data})).reverse())}catch(e){console.warn(`[useContextData] Failed to fetch stdio messages:`,e)}i({consoleMessages:On(t),networkRequests:kn(n),stdioMessages:r,loading:!1,error:null})}catch(e){console.error(`[useContextData] Failed to fetch context data:`,e),i(t=>({...t,loading:!1,error:e instanceof Error?e.message:String(e)}))}}},[e,t]);return{...r,refresh:a}}function On(e){if(!e)return[];let t=[],n=e.split(`
25
- `);for(let e of n){let n=e.match(/msgid=(\d+)\s+\[([^\]]+)\]\s+(.+)/);if(n){let[,e,r,i]=n;t.push({msgid:parseInt(e),level:r,text:i})}}return t}function kn(e){if(!e)return[];let t=[],n=e.split(`
26
- `);for(let e of n){let n=e.match(/reqid=(\d+)\s+(GET|POST|PUT|DELETE|PATCH)\s+([^\s]+)\s+\[([^\]]+)\]/);if(n){let[,e,r,i,a]=n;t.push({reqid:parseInt(e),method:r,url:i,status:An(a)})}}return t}function An(e){let t=e.match(/\b(\d{3})\b/);return t?t[1]:e}function jn(){let[e,t]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let e=()=>({url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight},language:document.documentElement.lang||navigator.language});t(e());let n=()=>t(e());return window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n)}},[]),e}const Mn=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`}},Nn=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`},Pn=({request:e,client:t,isClientReady:n,mode:r=`view`,isSelected:i=!1,onSelectionChange:a,onDetailsFetched:o,cachedDetails:s})=>{let[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(s??null),[f,m]=(0,U.useState)(!1);(0,U.useEffect)(()=>{s&&!u&&d(s)},[s,u]);let h=async()=>{if(u===null){m(!0);try{let r=typeof window<`u`?window.__DEV_INSPECTOR_CONFIG__:null;if(r&&!r.disableChrome&&r.isAutomated&&t&&n)try{let n=((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(`
27
- `)||`No details`;d(n),o?.(e.reqid,n);return}catch{console.log(`[NetworkRequestItem] 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){let t=await a.text();d(t),o?.(e.reqid,t)}else throw Error(`Failed to fetch: ${a.status} ${a.statusText}`)}catch(e){d(`Failed to fetch details: ${e instanceof Error?e.message:String(e)}`)}finally{m(!1)}}},g=e=>{e.stopPropagation(),c||h(),l(!c)},v=()=>{r===`select`&&a&&(!i&&!u&&h(),a(e.reqid,!i))};return(0,X.jsxs)(`div`,{className:`rounded hover:bg-accent/50 transition-colors`,children:[(0,X.jsxs)(`div`,{className:_(`flex items-start gap-2 p-2 cursor-pointer`,c&&`border-b border-border/50`),onClick:r===`view`?g:v,children:[r===`select`&&(0,X.jsx)(`input`,{type:`checkbox`,checked:i,onChange:v,onClick:e=>e.stopPropagation(),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`button`,{type:`button`,onClick:g,className:`flex-shrink-0 text-muted-foreground hover:text-foreground`,children:f?(0,X.jsx)(R,{className:`w-3.5 h-3.5 animate-spin`}):c?(0,X.jsx)(p,{className:`w-3.5 h-3.5`}):(0,X.jsx)($t,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`span`,{className:_(`px-1.5 py-0.5 text-[10px] font-medium rounded flex-shrink-0`,Mn(e.method)),children:e.method}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/90 flex-1 font-mono truncate`,title:e.url,children:e.url}),(0,X.jsx)(`span`,{className:_(`text-[10px] font-medium flex-shrink-0`,Nn(e.status)),children:e.status})]}),c&&(0,X.jsx)(`div`,{className:`p-2 bg-accent/30`,children:f?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(R,{className:`w-3.5 h-3.5 animate-spin`}),`Loading...`]}):u?(0,X.jsx)(`pre`,{className:`text-[10px] text-muted-foreground font-mono whitespace-pre-wrap break-all max-h-[150px] overflow-auto`,children:u}):null})]})};function Fn(e){let t=e;if(!t.parts||!Array.isArray(t.parts))return null;for(let e of t.parts){let t=e;if(typeof t.type==`string`&&t.type.startsWith(`tool-`)&&t.input&&typeof t.input.toolName==`string`&&t.input.toolName.includes(`context_selector`))return t.input.args}return null}const In=({tab:e,isActive:t,onClick:n})=>(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:_(`px-3 py-1.5 text-xs font-medium transition-colors relative`,t?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.label,e.totalCount!==void 0&&e.totalCount>0&&(0,X.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:[`(`,e.totalCount,`)`]}),e.selectedCount!==void 0&&e.selectedCount>0&&(0,X.jsx)(`span`,{className:`ml-1.5 inline-flex items-center justify-center min-w-[16px] h-4 px-1 text-[10px] font-medium bg-primary text-primary-foreground rounded-full`,children:e.selectedCount}),t&&(0,X.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-foreground`})]}),Ln=({client:e,isClientReady:t,sourceInfo:n,selectedContext:i,onSelectionChange:a,screenshot:o,onDataReady:s,userInput:c,selectedAgent:l=w})=>{let[d,f]=(0,U.useState)(`code`),[p,m]=(0,U.useState)(``),[v,b]=(0,U.useState)(``),[x,S]=(0,U.useState)({}),[C,T]=(0,U.useState)(null),E=jn(),{consoleMessages:D,networkRequests:O,stdioMessages:k,loading:A,error:M,refresh:N}=Dn(e,t,!0),F=p?D.filter(e=>e.text.toLowerCase().includes(p.toLowerCase())||e.level.toLowerCase().includes(p.toLowerCase())):D,ee=v?O.filter(e=>e.url.toLowerCase().includes(v.toLowerCase())||e.method.toLowerCase().includes(v.toLowerCase())):O;(0,U.useEffect)(()=>{t&&N()},[t,N]),(0,U.useEffect)(()=>{s&&(D.length>0||O.length>0||k.length>0)&&s({consoleMessages:D,networkRequests:O,stdioMessages:k,networkDetails:x})},[D,O,k,x,s]);let te=(e,t)=>{S(n=>({...n,[e]:t}))},L=(e,t)=>{let n=t?[...i.networkIds,e]:i.networkIds.filter(t=>t!==e);a({...i,networkIds:n})},ne=(i.includeElement?1:0)+(i.includeStyles?1:0)+(i.includeScreenshot?1:0)+(i.includePageInfo?1:0)+i.consoleIds.length+i.networkIds.length+i.stdioIds.length+i.relatedElementIds.length,z=()=>{a({...i,includeElement:!i.includeElement})},re=()=>{a({...i,includeStyles:!i.includeStyles})},ie=()=>{a({...i,includeScreenshot:!i.includeScreenshot})},ae=()=>{a({...i,includePageInfo:!i.includePageInfo})},B=e=>{let t=i.consoleIds.includes(e)?i.consoleIds.filter(t=>t!==e):[...i.consoleIds,e];a({...i,consoleIds:t})},oe=e=>{let t=i.stdioIds.includes(e)?i.stdioIds.filter(t=>t!==e):[...i.stdioIds,e];a({...i,stdioIds:t})},H=e=>{let t=i.relatedElementIds.includes(e)?i.relatedElementIds.filter(t=>t!==e):[...i.relatedElementIds,e];a({...i,relatedElementIds:t})},{messages:W,status:se,sendMessage:ce,setMessages:le}=V({transport:new g({api:`${I()}/api/acp/chat`})}),G=se===`submitted`||se===`streaming`;(0,U.useEffect)(()=>{if(se===`streaming`||se===`submitted`)return;let e=W[W.length-1];if(!e)return;let t=Fn(e);if(t)try{let e=t;if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){console.error(`Failed to parse tool args JSON`,e)}let n=e;console.log(`[ContextPicker] Tool call detected:`,{args:n}),a(e=>({...e,consoleIds:n?.consoleIds||[],networkIds:n?.networkIds||[],stdioIds:n?.stdioIds||[],includeElement:n?.includeElement??!0,includeStyles:n?.includeStyles??!1,reasoning:n?.reasoning,elementNotes:e.elementNotes}))}catch(e){console.error(`Failed to process context inference args`,e)}},[W,se,a]);let ue=async()=>{if(!n||G)return;le([]);let e=(e,t)=>e.length>t?e.slice(0,t)+`...`:e,t=D.slice(-50).map(t=>`[${t.msgid}] ${t.level}: ${e(t.text,200)}`).join(`
24
+ `+(o?.type===`text`?o.text:``);t=s,n=s}catch(e){throw console.error(`[useContextData] Prompts fallback failed:`,e),r}}try{let e=typeof window<`u`?window.__DEV_INSPECTOR_CONFIG__:null,t=``;e&&(t=e.baseUrl||`http://${e.host}:${e.port}${e.base||`/`}`,t.endsWith(`/`)&&(t=t.slice(0,-1)));let n=await fetch(`${t}/__inspector__/stdio`);n.ok&&(r=(await n.json()).map(e=>({stdioid:e.id,stream:e.stream,data:e.data})).reverse())}catch(e){console.warn(`[useContextData] Failed to fetch stdio messages:`,e)}i({consoleMessages:Dn(t),networkRequests:On(n),stdioMessages:r,loading:!1,error:null})}catch(e){console.error(`[useContextData] Failed to fetch context data:`,e),i(t=>({...t,loading:!1,error:e instanceof Error?e.message:String(e)}))}}},[e,t]);return{...r,refresh:a}}function Dn(e){if(!e)return[];let t=[],n=e.split(`
25
+ `);for(let e of n){let n=e.match(/msgid=(\d+)\s+\[([^\]]+)\]\s+(.+)/);if(n){let[,e,r,i]=n;t.push({msgid:parseInt(e),level:r,text:i})}}return t}function On(e){if(!e)return[];let t=[],n=e.split(`
26
+ `);for(let e of n){let n=e.match(/reqid=(\d+)\s+(GET|POST|PUT|DELETE|PATCH)\s+([^\s]+)\s+\[([^\]]+)\]/);if(n){let[,e,r,i,a]=n;t.push({reqid:parseInt(e),method:r,url:i,status:kn(a)})}}return t}function kn(e){let t=e.match(/\b(\d{3})\b/);return t?t[1]:e}function An(){let[e,t]=(0,G.useState)(null);return(0,G.useEffect)(()=>{let e=()=>({url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight},language:document.documentElement.lang||navigator.language});t(e());let n=()=>t(e());return window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n)}},[]),e}const jn=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`}},Mn=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`},Nn=({request:e,client:n,isClientReady:r,mode:i=`view`,isSelected:a=!1,onSelectionChange:o,onDetailsFetched:s,cachedDetails:c})=>{let[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(c??null),[m,h]=(0,G.useState)(!1);(0,G.useEffect)(()=>{c&&!f&&p(c)},[c,f]);let g=async()=>{if(f===null){h(!0);try{let t=typeof window<`u`?window.__DEV_INSPECTOR_CONFIG__:null;if(t&&!t.disableChrome&&t.isAutomated&&n&&r)try{let t=((await n.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(`
27
+ `)||`No details`;p(t),s?.(e.reqid,t);return}catch{console.log(`[NetworkRequestItem] Chrome DevTools failed, using local storage`)}let i=t?(()=>{let e=t.baseUrl||`http://${t.host}:${t.port}${t.base||`/`}`;return e.endsWith(`/`)?e.slice(0,-1):e})():``,a=await fetch(`${i}/__inspector__/request-details/${e.reqid}`);if(a.ok){let t=await a.text();p(t),s?.(e.reqid,t)}else throw Error(`Failed to fetch: ${a.status} ${a.statusText}`)}catch(e){p(`Failed to fetch details: ${e instanceof Error?e.message:String(e)}`)}finally{h(!1)}}},_=e=>{e.stopPropagation(),u||g(),d(!u)},v=()=>{i===`select`&&o&&(!a&&!f&&g(),o(e.reqid,!a))};return(0,Q.jsxs)(`div`,{className:`rounded hover:bg-accent/50 transition-colors`,children:[(0,Q.jsxs)(`div`,{className:y(`flex items-start gap-2 p-2 cursor-pointer`,u&&`border-b border-border/50`),onClick:i===`view`?_:v,children:[i===`select`&&(0,Q.jsx)(`input`,{type:`checkbox`,checked:a,onChange:v,onClick:e=>e.stopPropagation(),className:`mt-0.5 rounded border-border`}),(0,Q.jsx)(`button`,{type:`button`,onClick:_,className:`flex-shrink-0 text-muted-foreground hover:text-foreground`,children:m?(0,Q.jsx)(l,{className:`w-3.5 h-3.5 animate-spin`}):u?(0,Q.jsx)(t,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(Qt,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`span`,{className:y(`px-1.5 py-0.5 text-[10px] font-medium rounded flex-shrink-0`,jn(e.method)),children:e.method}),(0,Q.jsx)(`span`,{className:`text-xs text-foreground/90 flex-1 font-mono truncate`,title:e.url,children:e.url}),(0,Q.jsx)(`span`,{className:y(`text-[10px] font-medium flex-shrink-0`,Mn(e.status)),children:e.status})]}),u&&(0,Q.jsx)(`div`,{className:`p-2 bg-accent/30`,children:m?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(l,{className:`w-3.5 h-3.5 animate-spin`}),`Loading...`]}):f?(0,Q.jsx)(`pre`,{className:`text-[10px] text-muted-foreground font-mono whitespace-pre-wrap break-all max-h-[150px] overflow-auto`,children:f}):null})]})};function Pn(e){let t=e;if(!t.parts||!Array.isArray(t.parts))return null;for(let e of t.parts){let t=e;if(typeof t.type==`string`&&t.type.startsWith(`tool-`)&&t.input&&typeof t.input.toolName==`string`&&t.input.toolName.includes(`context_selector`))return t.input.args}return null}const Fn=({tab:e,isActive:t,onClick:n})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:y(`px-3 py-1.5 text-xs font-medium transition-colors relative`,t?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.label,e.totalCount!==void 0&&e.totalCount>0&&(0,Q.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:[`(`,e.totalCount,`)`]}),e.selectedCount!==void 0&&e.selectedCount>0&&(0,Q.jsx)(`span`,{className:`ml-1.5 inline-flex items-center justify-center min-w-[16px] h-4 px-1 text-[10px] font-medium bg-primary text-primary-foreground rounded-full`,children:e.selectedCount}),t&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-foreground`})]}),In=({client:e,isClientReady:t,sourceInfo:n,selectedContext:i,onSelectionChange:s,screenshot:c,onDataReady:u,userInput:d,selectedAgent:f=ee})=>{let[p,m]=(0,G.useState)(`code`),[h,_]=(0,G.useState)(``),[v,b]=(0,G.useState)(``),[x,S]=(0,G.useState)({}),[C,T]=(0,G.useState)(null),E=An(),{consoleMessages:D,networkRequests:O,stdioMessages:k,loading:j,error:M,refresh:N}=En(e,t,!0),P=h?D.filter(e=>e.text.toLowerCase().includes(h.toLowerCase())||e.level.toLowerCase().includes(h.toLowerCase())):D,F=v?O.filter(e=>e.url.toLowerCase().includes(v.toLowerCase())||e.method.toLowerCase().includes(v.toLowerCase())):O;(0,G.useEffect)(()=>{t&&N()},[t,N]),(0,G.useEffect)(()=>{u&&(D.length>0||O.length>0||k.length>0)&&u({consoleMessages:D,networkRequests:O,stdioMessages:k,networkDetails:x})},[D,O,k,x,u]);let I=(e,t)=>{S(n=>({...n,[e]:t}))},L=(e,t)=>{let n=t?[...i.networkIds,e]:i.networkIds.filter(t=>t!==e);s({...i,networkIds:n})},R=(i.includeElement?1:0)+(i.includeStyles?1:0)+(i.includeScreenshot?1:0)+(i.includePageInfo?1:0)+i.consoleIds.length+i.networkIds.length+i.stdioIds.length+i.relatedElementIds.length,z=()=>{s({...i,includeElement:!i.includeElement})},ne=()=>{s({...i,includeStyles:!i.includeStyles})},B=()=>{s({...i,includeScreenshot:!i.includeScreenshot})},ie=()=>{s({...i,includePageInfo:!i.includePageInfo})},V=e=>{let t=i.consoleIds.includes(e)?i.consoleIds.filter(t=>t!==e):[...i.consoleIds,e];s({...i,consoleIds:t})},ae=e=>{let t=i.stdioIds.includes(e)?i.stdioIds.filter(t=>t!==e):[...i.stdioIds,e];s({...i,stdioIds:t})},H=e=>{let t=i.relatedElementIds.includes(e)?i.relatedElementIds.filter(t=>t!==e):[...i.relatedElementIds,e];s({...i,relatedElementIds:t})},{messages:W,status:oe,sendMessage:se,setMessages:ce}=g({transport:new a({api:`${re()}/api/acp/chat`})}),K=oe===`submitted`||oe===`streaming`;(0,G.useEffect)(()=>{if(oe===`streaming`||oe===`submitted`)return;let e=W[W.length-1];if(!e)return;let t=Pn(e);if(t)try{let e=t;if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){console.error(`Failed to parse tool args JSON`,e)}let n=e;console.log(`[ContextPicker] Tool call detected:`,{args:n}),s(e=>({...e,consoleIds:n?.consoleIds||[],networkIds:n?.networkIds||[],stdioIds:n?.stdioIds||[],includeElement:n?.includeElement??!0,includeStyles:n?.includeStyles??!1,reasoning:n?.reasoning,elementNotes:e.elementNotes}))}catch(e){console.error(`Failed to process context inference args`,e)}},[W,oe,s]);let le=async()=>{if(!n||K)return;ce([]);let e=(e,t)=>e.length>t?e.slice(0,t)+`...`:e,t=D.slice(-50).map(t=>`[${t.msgid}] ${t.level}: ${e(t.text,200)}`).join(`
28
28
  `),r=O.slice(-50).map(e=>`[${e.reqid}] ${e.method} ${e.url} (${e.status})`).join(`
29
29
  `),i=k.slice(-50).map(t=>`[${t.stdioid}] ${t.stream}: ${e(t.data,200)}`).join(`
30
30
  `),a=`
31
31
  I am inspecting the following element:
32
- ${c?`Context/Interests: ${c}`:``}
32
+ ${d?`Context/Interests: ${d}`:``}
33
33
  Tag: ${n.elementInfo?.tagName}
34
34
  File: ${n.file}:${n.line}
35
35
  Component: ${n.component}
@@ -44,12 +44,11 @@ Available Terminal Logs (Recent 50):
44
44
  ${i||`None`}
45
45
 
46
46
  IMPORTANT: For this task, you MUST call the "context_selector" tool to return your selection. Do NOT use inspector tools like list_inspections, capture_element_context, update_inspection_status, or execute_page_script - the context is already provided above. You may read files if needed to understand the context better. Even if you select nothing, still call context_selector with empty arrays. Do not reply with text only. Note: You can ignore logs from dev-inspector itself.
47
- `,o=j.find(e=>e.name===l)||j[0];await ce({text:a},{body:{agent:o,envVars:{},inferContext:!0,isAutomated:!0}})},de=e=>{switch(e){case`error`:return`bg-red-500/20 text-red-500`;case`warn`:return`bg-yellow-500/20 text-yellow-600`;case`info`:return`bg-blue-500/20 text-blue-500`;case`debug`:return`bg-purple-500/20 text-purple-500`;default:return`bg-muted text-muted-foreground`}},K=n?.elementInfo?.computedStyles?.typography,fe=[{id:`code`,label:`Code`,selectedCount:i.includeElement?1:0},{id:`styles`,label:`Styles`,selectedCount:i.includeStyles?1:0},{id:`page`,label:`Page`,selectedCount:i.includePageInfo?1:0},{id:`screenshot`,label:`Visual`,selectedCount:i.includeScreenshot?1:0},{id:`console`,label:`Console`,totalCount:D.length,selectedCount:i.consoleIds.length},{id:`network`,label:`Network`,totalCount:O.length,selectedCount:i.networkIds.length},{id:`stdio`,label:`Terminal`,totalCount:k.length,selectedCount:i.stdioIds.length}];return(0,X.jsxs)(`div`,{className:`border border-border rounded-md overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`w-full flex items-center justify-between px-3 py-2 text-sm bg-muted/30 border-b border-border`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground font-medium`,children:[(0,X.jsx)(`span`,{children:`Context`}),ne>0&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs bg-primary text-primary-foreground rounded-full`,children:ne})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ue()},disabled:A||G,className:_(`flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded transition-colors border shadow-sm`,G?`bg-blue-100 text-blue-700 border-blue-200`:`bg-blue-50 text-blue-600 border-blue-200 hover:bg-blue-100 hover:text-blue-700 hover:border-blue-300`),title:`Let AI analyze logs and network to select relevant context`,children:[(0,X.jsx)(mn,{className:_(`w-3.5 h-3.5`,G&&`animate-pulse`)}),(0,X.jsx)(`span`,{children:G?`Analyzing...`:`Smart Select`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),N()},disabled:A,className:`p-1 hover:bg-accent rounded transition-colors`,title:`Refresh`,children:(0,X.jsx)(u,{className:_(`w-3.5 h-3.5`,A&&`animate-spin`)})})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`flex gap-1 border-b border-border px-2 pt-1`,children:fe.map(e=>(0,X.jsx)(In,{tab:e,isActive:d===e.id,onClick:()=>f(e.id)},e.id))}),(0,X.jsxs)(`div`,{className:`max-h-[200px] overflow-auto relative ${G?`min-h-[150px]`:``}`,children:[G&&(()=>{let e=W[W.length-1],t=e?.role===`assistant`?h(e):``,n=e?.role===`assistant`?r(e):null;return(0,X.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background/95 backdrop-blur-sm flex flex-col items-center justify-center p-4 min-h-[120px]`,children:[(0,X.jsx)(mn,{className:`w-6 h-6 text-blue-500 animate-pulse mb-3`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-foreground text-center max-w-full truncate px-2`,children:n?`Running: ${P(n)}`:`Analyzing context...`}),t&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed text-center mt-2 line-clamp-2 max-w-[280px]`,children:t})]})})(),M&&(d===`console`||d===`network`)&&(0,X.jsx)(`div`,{className:`p-2 text-xs text-destructive`,children:M}),i.reasoning&&!G&&(0,X.jsx)(`div`,{className:`bg-blue-50/50 p-2 border-b border-border`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(mn,{className:`w-3.5 h-3.5 text-blue-500 mt-0.5 flex-shrink-0`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed italic`,children:i.reasoning})]})}),d===`code`&&(0,X.jsx)(`div`,{className:`p-2 space-y-1`,children:(()=>{let e=n?.relatedElements&&n.relatedElements.length>0?n.relatedElements:n?[n]:[],t=n?.relatedElements&&n.relatedElements.length>0,r=e.reduce((e,t,n)=>{let r=t.file||`unknown`;return e[r]||(e[r]=[]),e[r].push({el:t,idx:n}),e},{});return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 mb-2`,children:[(0,X.jsx)(nn,{className:t?`w-3.5 h-3.5 text-muted-foreground`:`w-4 h-4 text-blue-500`}),(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:t?`Related Elements`:`Source Location`}),t&&(0,X.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 text-[10px] bg-muted text-muted-foreground rounded-full`,children:e.length})]}),(0,X.jsx)(`div`,{className:`space-y-2 max-h-60 overflow-y-auto`,children:Object.entries(r).map(([e,n])=>(0,X.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-muted-foreground/70 bg-muted/30 rounded sticky top-0`,children:[e,` (`,n.length,`)`]}),n.map(({el:e,idx:n})=>(0,X.jsxs)(`div`,{className:`group relative`,children:[(0,X.jsxs)(`label`,{className:`flex items-start gap-2 pl-4 pr-8 py-1.5 rounded hover:bg-accent/50 cursor-pointer transition-colors relative`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t?i.relatedElementIds.includes(n):i.includeElement,onChange:()=>t?H(n):z(),className:`mt-0.5 rounded border-border`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 text-xs font-mono`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-foreground/80 font-medium`,children:e.component}),(0,X.jsx)(`span`,{className:`text-muted-foreground/50`,children:`•`}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.line,`:`,e.column]})]}),e.elementInfo&&(0,X.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/60 mt-0.5 space-x-2`,children:[typeof e.elementInfo.className==`string`&&e.elementInfo.className&&(0,X.jsxs)(`span`,{children:[`.`,e.elementInfo.className.split(` `)[0]]}),e.elementInfo.id&&(0,X.jsxs)(`span`,{children:[`#`,e.elementInfo.id]}),e.elementInfo.textContent&&(0,X.jsxs)(`span`,{className:`italic`,children:[`"`,e.elementInfo.textContent.trim().slice(0,20),e.elementInfo.textContent.length>20?`...`:``,`"`]})]}),i.elementNotes[n]&&(0,X.jsxs)(`div`,{className:`mt-1.5 text-[11px] text-yellow-600 dark:text-yellow-500 bg-yellow-50 dark:bg-yellow-900/20 px-1.5 py-0.5 rounded border border-yellow-200 dark:border-yellow-900/40 flex items-start gap-1`,children:[(0,X.jsx)(ln,{className:`w-3 h-3 mt-0.5 flex-shrink-0`}),(0,X.jsx)(`span`,{className:`break-words`,children:i.elementNotes[n]})]})]})]}),(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),e.preventDefault(),T(n)},className:_(`absolute right-1 top-1.5 p-1 rounded transition-colors`,i.elementNotes[n]?`text-yellow-600 hover:bg-yellow-100 opacity-100`:`text-muted-foreground/40 hover:text-foreground hover:bg-accent opacity-0 group-hover:opacity-100`),title:`Add note to element`,children:(0,X.jsx)(ln,{className:`w-3.5 h-3.5`})}),C===n&&(0,X.jsx)(`div`,{className:`px-4 py-2 bg-muted/30 border-t border-b border-border`,children:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{type:`text`,autoFocus:!0,placeholder:`Describe issue with this element...`,className:`flex-1 text-xs bg-background border border-input rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-primary`,defaultValue:i.elementNotes[n]||``,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=e.currentTarget.value.trim();a(e=>{let r={...e.elementNotes};return t?r[n]=t:delete r[n],{...e,elementNotes:r}}),T(null)}else e.key===`Escape`&&T(null)},onBlur:e=>{let t=e.currentTarget.value.trim();t!==(i.elementNotes[n]||``)&&a(e=>{let r={...e.elementNotes};return t?r[n]=t:delete r[n],{...e,elementNotes:r}}),T(null)}}),(0,X.jsx)(`button`,{onClick:()=>T(null),className:`text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(y,{className:`w-3.5 h-3.5`})})]})})]},n))]},e))})]})})()}),d===`styles`&&(0,X.jsx)(`div`,{className:`p-2 space-y-1`,children:(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.includeStyles,onChange:re,className:`mt-0.5 rounded border-border`}),(0,X.jsx)(vn,{className:`w-4 h-4 text-purple-500 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:`Computed Styles`}),K&&(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5 mt-1`,children:[(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Font:`}),(0,X.jsx)(`span`,{className:`font-mono truncate`,children:K.fontFamily})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Size:`}),(0,X.jsx)(`span`,{className:`font-mono`,children:K.fontSize}),(0,X.jsx)(`span`,{className:`text-muted-foreground/70 ml-2`,children:`Weight:`}),(0,X.jsx)(`span`,{className:`font-mono`,children:K.fontWeight})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Color:`}),(0,X.jsxs)(`span`,{className:`font-mono flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`inline-block w-3 h-3 rounded border border-border`,style:{backgroundColor:K.color}}),K.color]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Line Height:`}),(0,X.jsx)(`span`,{className:`font-mono`,children:K.lineHeight})]})]}),!K&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground/50 italic`,children:`No style data available`})]})]})}),d===`screenshot`&&(0,X.jsx)(`div`,{className:`p-2 space-y-1`,children:o?(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.includeScreenshot,onChange:ie,className:`mt-0.5 rounded border-border`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-foreground mb-1`,children:`Element Visual`}),(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mb-2`,children:`Note: Copy & Go only copies text (IDEs don't support mixed text/image paste). To include the image, please right-click and copy it manually.`}),(0,X.jsx)(`div`,{className:`rounded border border-border overflow-hidden bg-muted/30`,children:(0,X.jsx)(`img`,{src:o,alt:`Element Visual`,className:`w-full h-auto max-h-[150px] object-contain`})})]})]}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No visual available`})}),d===`page`&&(0,X.jsx)(`div`,{className:`p-2 space-y-1`,children:E?(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.includePageInfo,onChange:ae,className:`mt-0.5 rounded border-border`}),(0,X.jsx)(on,{className:`w-4 h-4 text-green-500 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-foreground mb-1`,children:`Page Information`}),(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),(0,X.jsx)(`span`,{className:`font-mono truncate`,children:E.url})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Title:`}),(0,X.jsx)(`span`,{className:`truncate`,children:E.title})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Viewport:`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[E.viewport.width,` × `,E.viewport.height]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Language:`}),(0,X.jsx)(`span`,{className:`font-mono`,children:E.language})]})]})]})]}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`Loading page info...`})}),A&&d!==`code`&&d!==`styles`&&d!==`screenshot`&&d!==`page`&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,X.jsx)(R,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),!A&&d===`console`&&(0,X.jsxs)(`div`,{className:`p-2 space-y-1`,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=>m(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`}),p&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(``),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`})})]}),F.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:p?`No matching logs`:`No console logs`}):F.map(e=>(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.consoleIds.includes(e.msgid),onChange:()=>B(e.msgid),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`span`,{className:_(`px-1.5 py-0.5 text-[10px] font-medium rounded flex-shrink-0`,de(e.level)),children:e.level}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/90 flex-1 font-mono break-all line-clamp-2`,children:e.text})]},e.msgid))]}),!A&&d===`network`&&(0,X.jsxs)(`div`,{className:`p-2 space-y-1`,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:v,onChange:e=>b(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`}),v&&(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`})})]}),ee.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:v?`No matching requests`:`No network requests`}):ee.map(n=>(0,X.jsx)(Pn,{request:n,client:e,isClientReady:t,mode:`select`,isSelected:i.networkIds.includes(n.reqid),onSelectionChange:L,onDetailsFetched:te,cachedDetails:x[n.reqid]},n.reqid))]}),!A&&d===`stdio`&&(0,X.jsx)(`div`,{className:`p-2 space-y-1`,children:k.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No terminal logs`}):k.map(e=>(0,X.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.stdioIds.includes(e.stdioid),onChange:()=>oe(e.stdioid),className:`mt-0.5 rounded border-border`}),(0,X.jsx)(`span`,{className:_(`px-1.5 py-0.5 text-[10px] font-medium rounded flex-shrink-0 border`,e.stream===`stderr`?`bg-red-500/10 text-red-500 border-red-500/20`:`bg-zinc-500/10 text-zinc-500 border-zinc-500/20`),children:e.stream}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/90 flex-1 font-mono break-all whitespace-pre-wrap`,children:e.data})]},e.stdioid))})]})]})]})},Rn=({sourceInfo:e,screenshot:t=``,onClose:r,mode:i,onSubmit:a,resultMessage:s,client:l=null,isClientReady:u=!1,selectedAgent:f})=>{let p=En(),[h,g]=(0,U.useState)(``),[_,y]=(0,U.useState)(!0),x=jn(),[C,w]=(0,U.useState)(()=>{let t=e?.relatedElements?.length||0;return{includeElement:!0,includeStyles:!0,includeScreenshot:t>0,includePageInfo:!0,consoleIds:[],networkIds:[],stdioIds:[],relatedElementIds:t>0?Array.from({length:t},(e,t)=>t):[],elementNotes:e.relatedElements?.reduce((e,t,n)=>(t.note&&(e[n]=t.note),e),{})||{}}}),[T,E]=(0,U.useState)({consoleMessages:[],networkRequests:[],stdioMessages:[],networkDetails:{}}),D=(0,U.useMemo)(()=>C.includeElement||C.includeStyles||C.consoleIds.length>0||C.networkIds.length>0||C.stdioIds.length>0,[C]),O=e=>{E(e)};(0,U.useEffect)(()=>{_||r()},[_,r]);let k=e=>{if(e.key===`Enter`&&a){e.preventDefault(),e.currentTarget.blur();let t=D?A():void 0;a(h,e.shiftKey,t)}},A=()=>{let e=T.consoleMessages.filter(e=>C.consoleIds.includes(e.msgid)),n=T.stdioMessages.filter(e=>C.stdioIds.includes(e.stdioid)),r=T.networkRequests.filter(e=>C.networkIds.includes(e.reqid)).map(e=>({...e,details:T.networkDetails[e.reqid]||null}));return{...C,consoleMessages:e,networkRequests:r,stdioMessages:n,screenshot:C.includeScreenshot?t:void 0}},j=async()=>{let t=A(),n=L({sourceInfo:t.includeElement||t.includeStyles?e:void 0,includeElement:t.includeElement,includeStyles:t.includeStyles,includePageInfo:t.includePageInfo,pageInfo:t.includePageInfo&&x?x:void 0,feedback:h||void 0,consoleMessages:t.consoleMessages.length>0?t.consoleMessages:void 0,networkRequests:t.networkRequests.length>0?t.networkRequests:void 0,stdioMessages:t.stdioMessages?.length?t.stdioMessages:void 0,relatedElements:e?.relatedElements,relatedElementIds:t.relatedElementIds,elementNotes:t.elementNotes});try{if(t.screenshot&&t.includeScreenshot){if(!(t.screenshot?.startsWith(`data:image/`)??!1)){console.warn(`Invalid screenshot data URL, skipping image in clipboard`),await navigator.clipboard.writeText(n),y(!1);return}let e=`<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
47
+ `,o=w.find(e=>e.name===f)||w[0];await se({text:a},{body:{agent:o,envVars:{},inferContext:!0,isAutomated:!0}})},ue=e=>{switch(e){case`error`:return`bg-red-500/20 text-red-500`;case`warn`:return`bg-yellow-500/20 text-yellow-600`;case`info`:return`bg-blue-500/20 text-blue-500`;case`debug`:return`bg-purple-500/20 text-purple-500`;default:return`bg-muted text-muted-foreground`}},q=n?.elementInfo?.computedStyles?.typography,de=[{id:`code`,label:`Code`,selectedCount:i.includeElement?1:0},{id:`styles`,label:`Styles`,selectedCount:i.includeStyles?1:0},{id:`page`,label:`Page`,selectedCount:i.includePageInfo?1:0},{id:`screenshot`,label:`Visual`,selectedCount:i.includeScreenshot?1:0},{id:`console`,label:`Console`,totalCount:D.length,selectedCount:i.consoleIds.length},{id:`network`,label:`Network`,totalCount:O.length,selectedCount:i.networkIds.length},{id:`stdio`,label:`Terminal`,totalCount:k.length,selectedCount:i.stdioIds.length}];return(0,Q.jsxs)(`div`,{className:`border border-border rounded-md overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`w-full flex items-center justify-between px-3 py-2 text-sm bg-muted/30 border-b border-border`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground font-medium`,children:[(0,Q.jsx)(`span`,{children:`Context`}),R>0&&(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs bg-primary text-primary-foreground rounded-full`,children:R})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),le()},disabled:j||K,className:y(`flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded transition-colors border shadow-sm`,K?`bg-blue-100 text-blue-700 border-blue-200`:`bg-blue-50 text-blue-600 border-blue-200 hover:bg-blue-100 hover:text-blue-700 hover:border-blue-300`),title:`Let AI analyze logs and network to select relevant context`,children:[(0,Q.jsx)(pn,{className:y(`w-3.5 h-3.5`,K&&`animate-pulse`)}),(0,Q.jsx)(`span`,{children:K?`Analyzing...`:`Smart Select`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),N()},disabled:j,className:`p-1 hover:bg-accent rounded transition-colors`,title:`Refresh`,children:(0,Q.jsx)(te,{className:y(`w-3.5 h-3.5`,j&&`animate-spin`)})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border px-2 pt-1`,children:de.map(e=>(0,Q.jsx)(Fn,{tab:e,isActive:p===e.id,onClick:()=>m(e.id)},e.id))}),(0,Q.jsxs)(`div`,{className:`max-h-[200px] overflow-auto relative ${K?`min-h-[150px]`:``}`,children:[K&&(()=>{let e=W[W.length-1],t=e?.role===`assistant`?r(e):``,n=e?.role===`assistant`?U(e):null;return(0,Q.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background/95 backdrop-blur-sm flex flex-col items-center justify-center p-4 min-h-[120px]`,children:[(0,Q.jsx)(pn,{className:`w-6 h-6 text-blue-500 animate-pulse mb-3`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground text-center max-w-full truncate px-2`,children:n?`Running: ${A(n)}`:`Analyzing context...`}),t&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed text-center mt-2 line-clamp-2 max-w-[280px]`,children:t})]})})(),M&&(p===`console`||p===`network`)&&(0,Q.jsx)(`div`,{className:`p-2 text-xs text-destructive`,children:M}),i.reasoning&&!K&&(0,Q.jsx)(`div`,{className:`bg-blue-50/50 p-2 border-b border-border`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(pn,{className:`w-3.5 h-3.5 text-blue-500 mt-0.5 flex-shrink-0`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed italic`,children:i.reasoning})]})}),p===`code`&&(0,Q.jsx)(`div`,{className:`p-2 space-y-1`,children:(()=>{let e=n?.relatedElements&&n.relatedElements.length>0?n.relatedElements:n?[n]:[],t=n?.relatedElements&&n.relatedElements.length>0,r=e.reduce((e,t,n)=>{let r=t.file||`unknown`;return e[r]||(e[r]=[]),e[r].push({el:t,idx:n}),e},{});return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 mb-2`,children:[(0,Q.jsx)(tn,{className:t?`w-3.5 h-3.5 text-muted-foreground`:`w-4 h-4 text-blue-500`}),(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:t?`Related Elements`:`Source Location`}),t&&(0,Q.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 text-[10px] bg-muted text-muted-foreground rounded-full`,children:e.length})]}),(0,Q.jsx)(`div`,{className:`space-y-2 max-h-60 overflow-y-auto`,children:Object.entries(r).map(([e,n])=>(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-muted-foreground/70 bg-muted/30 rounded sticky top-0`,children:[e,` (`,n.length,`)`]}),n.map(({el:e,idx:n})=>(0,Q.jsxs)(`div`,{className:`group relative`,children:[(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 pl-4 pr-8 py-1.5 rounded hover:bg-accent/50 cursor-pointer transition-colors relative`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t?i.relatedElementIds.includes(n):i.includeElement,onChange:()=>t?H(n):z(),className:`mt-0.5 rounded border-border`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 text-xs font-mono`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/80 font-medium`,children:e.component}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`•`}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.line,`:`,e.column]})]}),e.elementInfo&&(0,Q.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/60 mt-0.5 space-x-2`,children:[typeof e.elementInfo.className==`string`&&e.elementInfo.className&&(0,Q.jsxs)(`span`,{children:[`.`,e.elementInfo.className.split(` `)[0]]}),e.elementInfo.id&&(0,Q.jsxs)(`span`,{children:[`#`,e.elementInfo.id]}),e.elementInfo.textContent&&(0,Q.jsxs)(`span`,{className:`italic`,children:[`"`,e.elementInfo.textContent.trim().slice(0,20),e.elementInfo.textContent.length>20?`...`:``,`"`]})]}),i.elementNotes[n]&&(0,Q.jsxs)(`div`,{className:`mt-1.5 text-[11px] text-yellow-600 dark:text-yellow-500 bg-yellow-50 dark:bg-yellow-900/20 px-1.5 py-0.5 rounded border border-yellow-200 dark:border-yellow-900/40 flex items-start gap-1`,children:[(0,Q.jsx)(cn,{className:`w-3 h-3 mt-0.5 flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`break-words`,children:i.elementNotes[n]})]})]})]}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),e.preventDefault(),T(n)},className:y(`absolute right-1 top-1.5 p-1 rounded transition-colors`,i.elementNotes[n]?`text-yellow-600 hover:bg-yellow-100 opacity-100`:`text-muted-foreground/40 hover:text-foreground hover:bg-accent opacity-0 group-hover:opacity-100`),title:`Add note to element`,children:(0,Q.jsx)(cn,{className:`w-3.5 h-3.5`})}),C===n&&(0,Q.jsx)(`div`,{className:`px-4 py-2 bg-muted/30 border-t border-b border-border`,children:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,autoFocus:!0,placeholder:`Describe issue with this element...`,className:`flex-1 text-xs bg-background border border-input rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-primary`,defaultValue:i.elementNotes[n]||``,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=e.currentTarget.value.trim();s(e=>{let r={...e.elementNotes};return t?r[n]=t:delete r[n],{...e,elementNotes:r}}),T(null)}else e.key===`Escape`&&T(null)},onBlur:e=>{let t=e.currentTarget.value.trim();t!==(i.elementNotes[n]||``)&&s(e=>{let r={...e.elementNotes};return t?r[n]=t:delete r[n],{...e,elementNotes:r}}),T(null)}}),(0,Q.jsx)(`button`,{onClick:()=>T(null),className:`text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(o,{className:`w-3.5 h-3.5`})})]})})]},n))]},e))})]})})()}),p===`styles`&&(0,Q.jsx)(`div`,{className:`p-2 space-y-1`,children:(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.includeStyles,onChange:ne,className:`mt-0.5 rounded border-border`}),(0,Q.jsx)(_n,{className:`w-4 h-4 text-purple-500 flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:`Computed Styles`}),q&&(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5 mt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Font:`}),(0,Q.jsx)(`span`,{className:`font-mono truncate`,children:q.fontFamily})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Size:`}),(0,Q.jsx)(`span`,{className:`font-mono`,children:q.fontSize}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/70 ml-2`,children:`Weight:`}),(0,Q.jsx)(`span`,{className:`font-mono`,children:q.fontWeight})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Color:`}),(0,Q.jsxs)(`span`,{className:`font-mono flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`inline-block w-3 h-3 rounded border border-border`,style:{backgroundColor:q.color}}),q.color]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Line Height:`}),(0,Q.jsx)(`span`,{className:`font-mono`,children:q.lineHeight})]})]}),!q&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground/50 italic`,children:`No style data available`})]})]})}),p===`screenshot`&&(0,Q.jsx)(`div`,{className:`p-2 space-y-1`,children:c?(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.includeScreenshot,onChange:B,className:`mt-0.5 rounded border-border`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground mb-1`,children:`Element Visual`}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mb-2`,children:`Note: Copy & Go only copies text (IDEs don't support mixed text/image paste). To include the image, please right-click and copy it manually.`}),(0,Q.jsx)(`div`,{className:`rounded border border-border overflow-hidden bg-muted/30`,children:(0,Q.jsx)(`img`,{src:c,alt:`Element Visual`,className:`w-full h-auto max-h-[150px] object-contain`})})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No visual available`})}),p===`page`&&(0,Q.jsx)(`div`,{className:`p-2 space-y-1`,children:E?(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.includePageInfo,onChange:ie,className:`mt-0.5 rounded border-border`}),(0,Q.jsx)(an,{className:`w-4 h-4 text-green-500 flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground mb-1`,children:`Page Information`}),(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),(0,Q.jsx)(`span`,{className:`font-mono truncate`,children:E.url})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Title:`}),(0,Q.jsx)(`span`,{className:`truncate`,children:E.title})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Viewport:`}),(0,Q.jsxs)(`span`,{className:`font-mono`,children:[E.viewport.width,` × `,E.viewport.height]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Language:`}),(0,Q.jsx)(`span`,{className:`font-mono`,children:E.language})]})]})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`Loading page info...`})}),j&&p!==`code`&&p!==`styles`&&p!==`screenshot`&&p!==`page`&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,Q.jsx)(l,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),!j&&p===`console`&&(0,Q.jsxs)(`div`,{className:`p-2 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`relative mb-2`,children:[(0,Q.jsx)(fn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,Q.jsx)(`input`,{type:`text`,value:h,onChange:e=>_(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`}),h&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(o,{className:`w-3.5 h-3.5`})})]}),P.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:h?`No matching logs`:`No console logs`}):P.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.consoleIds.includes(e.msgid),onChange:()=>V(e.msgid),className:`mt-0.5 rounded border-border`}),(0,Q.jsx)(`span`,{className:y(`px-1.5 py-0.5 text-[10px] font-medium rounded flex-shrink-0`,ue(e.level)),children:e.level}),(0,Q.jsx)(`span`,{className:`text-xs text-foreground/90 flex-1 font-mono break-all line-clamp-2`,children:e.text})]},e.msgid))]}),!j&&p===`network`&&(0,Q.jsxs)(`div`,{className:`p-2 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`relative mb-2`,children:[(0,Q.jsx)(fn,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,Q.jsx)(`input`,{type:`text`,value:v,onChange:e=>b(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`}),v&&(0,Q.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,Q.jsx)(o,{className:`w-3.5 h-3.5`})})]}),F.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:v?`No matching requests`:`No network requests`}):F.map(n=>(0,Q.jsx)(Nn,{request:n,client:e,isClientReady:t,mode:`select`,isSelected:i.networkIds.includes(n.reqid),onSelectionChange:L,onDetailsFetched:I,cachedDetails:x[n.reqid]},n.reqid))]}),!j&&p===`stdio`&&(0,Q.jsx)(`div`,{className:`p-2 space-y-1`,children:k.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No terminal logs`}):k.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded hover:bg-accent/50 cursor-pointer transition-colors`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.stdioIds.includes(e.stdioid),onChange:()=>ae(e.stdioid),className:`mt-0.5 rounded border-border`}),(0,Q.jsx)(`span`,{className:y(`px-1.5 py-0.5 text-[10px] font-medium rounded flex-shrink-0 border`,e.stream===`stderr`?`bg-red-500/10 text-red-500 border-red-500/20`:`bg-zinc-500/10 text-zinc-500 border-zinc-500/20`),children:e.stream}),(0,Q.jsx)(`span`,{className:`text-xs text-foreground/90 flex-1 font-mono break-all whitespace-pre-wrap`,children:e.data})]},e.stdioid))})]})]})]})},Ln=({sourceInfo:e,screenshot:t=``,onClose:r,mode:i,onSubmit:a,resultMessage:o,client:u=null,isClientReady:d=!1,selectedAgent:f})=>{let h=Tn(),[g,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(!0),C=An(),[w,T]=(0,G.useState)(()=>{let t=e?.relatedElements?.length||0;return{includeElement:!0,includeStyles:!0,includeScreenshot:t>0,includePageInfo:!0,consoleIds:[],networkIds:[],stdioIds:[],relatedElementIds:t>0?Array.from({length:t},(e,t)=>t):[],elementNotes:e.relatedElements?.reduce((e,t,n)=>(t.note&&(e[n]=t.note),e),{})||{}}}),[E,D]=(0,G.useState)({consoleMessages:[],networkRequests:[],stdioMessages:[],networkDetails:{}}),O=(0,G.useMemo)(()=>w.includeElement||w.includeStyles||w.consoleIds.length>0||w.networkIds.length>0||w.stdioIds.length>0,[w]),k=e=>{D(e)};(0,G.useEffect)(()=>{b||r()},[b,r]);let A=e=>{if(e.key===`Enter`&&a){e.preventDefault(),e.currentTarget.blur();let t=O?j():void 0;a(g,e.shiftKey,t)}},j=()=>{let e=E.consoleMessages.filter(e=>w.consoleIds.includes(e.msgid)),n=E.stdioMessages.filter(e=>w.stdioIds.includes(e.stdioid)),r=E.networkRequests.filter(e=>w.networkIds.includes(e.reqid)).map(e=>({...e,details:E.networkDetails[e.reqid]||null}));return{...w,consoleMessages:e,networkRequests:r,stdioMessages:n,screenshot:w.includeScreenshot?t:void 0}},M=async()=>{let t=j(),n=F({sourceInfo:t.includeElement||t.includeStyles?e:void 0,includeElement:t.includeElement,includeStyles:t.includeStyles,includePageInfo:t.includePageInfo,pageInfo:t.includePageInfo&&C?C:void 0,feedback:g||void 0,consoleMessages:t.consoleMessages.length>0?t.consoleMessages:void 0,networkRequests:t.networkRequests.length>0?t.networkRequests:void 0,stdioMessages:t.stdioMessages?.length?t.stdioMessages:void 0,relatedElements:e?.relatedElements,relatedElementIds:t.relatedElementIds,elementNotes:t.elementNotes});try{if(t.screenshot&&t.includeScreenshot){if(!(t.screenshot?.startsWith(`data:image/`)??!1)){console.warn(`Invalid screenshot data URL, skipping image in clipboard`),await navigator.clipboard.writeText(n),x(!1);return}let e=`<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
48
48
  <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);">
49
49
  <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,`&lt;`).replace(/>/g,`&gt;`)}</pre>
50
- </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)(R,{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)(H,{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=U.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=U.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,U.useState)(null);return{notification:t,showNotif:(0,U.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,U.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,U.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})=>U.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},U.createElement(`div`,{className:`sonner-spinner`},Xn.map((e,t)=>U.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Qn=U.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},U.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=U.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},U.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=U.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},U.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=U.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},U.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=U.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`},U.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),U.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),rr=()=>{let[e,t]=U.useState(document.hidden);return U.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],U.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`&&!U.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`&&!U.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`&&!U.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`&&!U.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]=U.useState(null),[O,k]=U.useState(null),[A,j]=U.useState(!1),[M,N]=U.useState(!1),[P,F]=U.useState(!1),[I,ee]=U.useState(!1),[te,L]=U.useState(!1),[R,ne]=U.useState(0),[z,re]=U.useState(0),ie=U.useRef(n.duration||y||lr),ae=U.useRef(null),B=U.useRef(null),V=c===0,oe=c+1<=o,H=n.type,W=n.dismissible!==!1,se=n.className||``,ce=n.descriptionClassName||``,le=U.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),G=U.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ue=U.useMemo(()=>n.duration||y||lr,[n.duration,y]),de=U.useRef(0),K=U.useRef(0),fe=U.useRef(0),pe=U.useRef(null),[me,q]=b.split(`-`),J=U.useMemo(()=>s.reduce((e,t,n)=>n>=le?e:e+t.height,0),[s,le]),he=rr(),ge=n.invert||t,_e=H===`loading`;K.current=U.useMemo(()=>le*x+J,[le,J]),U.useEffect(()=>{ie.current=ue},[ue]),U.useEffect(()=>{j(!0)},[]),U.useEffect(()=>{let e=B.current;if(e){let t=e.getBoundingClientRect().height;return re(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),U.useLayoutEffect(()=>{if(!A)return;let e=B.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,re(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=U.useCallback(()=>{N(!0),ne(K.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},200)},[n,d,a,K]);U.useEffect(()=>{if(n.promise&&H===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||he?(()=>{if(fe.current<de.current){let e=new Date().getTime()-de.current;ie.current-=e}fe.current=new Date().getTime()})():ie.current!==1/0&&(de.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),ve()},ie.current)),()=>clearTimeout(e)},[u,i,n,H,he,ve]),U.useEffect(()=>{n.delete&&(ve(),n.onDismiss==null||n.onDismiss.call(n,n))},[ve,n.delete]);function ye(){return w?.loading?U.createElement(`div`,{className:ur(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":H===`loading`},w.loading):U.createElement(Zn,{className:ur(C?.loader,n?.classNames?.loader),visible:H===`loading`})}let be=n.icon||w?.[H]||Yn(H);return U.createElement(`li`,{tabIndex:0,ref:B,className:ur(_,se,C?.toast,n?.classNames?.toast,C?.default,C?.[H],n?.classNames?.[H]),"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":te,"data-removed":M,"data-visible":oe,"data-y-position":me,"data-x-position":q,"data-index":c,"data-front":V,"data-swiping":P,"data-dismissible":W,"data-type":H,"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?R:K.current}px`,"--initial-height":S?`auto`:`${z}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),pe.current=null},onPointerDown:e=>{e.button!==2&&(_e||!W||(ae.current=new Date,ne(K.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),pe.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!W)return;pe.current=null;let e=Number(B.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(B.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ae.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=45||a>.11){ne(K.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),ve(),ee(!0);return}else{var o,s;(o=B.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=B.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}L(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!pe.current||!W||window.getSelection()?.toString().length>0)return;let i=t.clientY-pe.current.y,a=t.clientX-pe.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)&&L(!0),(n=B.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=B.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},G&&!n.jsx&&H!==`loading`?U.createElement(`button`,{"aria-label":T,"data-disabled":_e,"data-close-button":!0,onClick:_e||!W?()=>{}:()=>{ve(),n.onDismiss==null||n.onDismiss.call(n,n)},className:ur(C?.closeButton,n?.classNames?.closeButton)},w?.close??nr):null,(H||n.icon||n.promise)&&n.icon!==null&&(w?.[H]!==null||n.icon)?U.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,U.createElement(`div`,{"data-content":``,className:ur(C?.content,n?.classNames?.content)},U.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?U.createElement(`div`,{"data-description":``,className:ur(v,ce,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),U.isValidElement(n.cancel)?n.cancel:n.cancel&&cr(n.cancel)?U.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{cr(n.cancel)&&W&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),ve())},className:ur(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,U.isValidElement(n.action)?n.action:n.action&&cr(n.action)?U.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=U.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]=U.useState([]),C=U.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=U.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=U.useState([]),[D,O]=U.useState(!1),[k,A]=U.useState(!1),[j,M]=U.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=U.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=U.useRef(null),I=U.useRef(!1),ee=U.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||Z.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return U.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]),U.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]),U.useEffect(()=>{x.length<=1&&O(!1)},[x]),U.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]),U.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),U.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?U.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)=>U.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:ee,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)(R,{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,U.createContext)(null),vr=()=>(0,U.useContext)(_r),yr=vr,br=`inspector-inspection-items`;function xr(){let[e,t]=(0,U.useState)(()=>{try{let e=localStorage.getItem(br);return e?JSON.parse(e):[]}catch{return[]}});return(0,U.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,U.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(`
51
- `)}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),``}}var Hi=e(ee());const Ui=({request:e,client:t,isClientReady:n})=>{let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),[s,c]=(0,U.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(`
52
- `)||`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)(R,{className:`w-4 h-4 animate-spin`}),`Loading...`]});if(!a)return null;let e=a,t=null;try{let n=a.split(`
50
+ </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);x(!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),x(!1)}catch{console.error(`Failed to copy to clipboard`)}}},N=e=>{a&&a(g,e,O?j():void 0)},P=h?.steps.every(e=>e.status===`completed`);return(0,Q.jsx)(m,{open:b,onOpenChange:x,children:(0,Q.jsxs)(W,{onClose:()=>x(!1),className:`max-w-2xl`,children:[(0,Q.jsxs)(s,{children:[(0,Q.jsxs)(_,{className:`flex items-center gap-2`,children:[i===`success`||i===`loading`&&P?(0,Q.jsx)(p,{className:`h-5 w-5 text-green-600 dark:text-green-500`}):i===`error`?(0,Q.jsx)(S,{className:`h-5 w-5 text-red-600 dark:text-red-500`}):i===`loading`?(0,Q.jsx)(l,{className:`h-5 w-5 animate-spin text-blue-600 dark:text-blue-500`}):null,i===`success`?`Success`:i===`error`?`Error`:i===`loading`&&P?`Success`:i===`loading`?`Processing...`:`Tell the AI`]}),(0,Q.jsx)(n,{className:`text-xs text-muted-foreground`,children:i===`input`?`Describe what you want to fix or improve, then add context below`:(0,Q.jsxs)(`span`,{className:`font-mono`,children:[e.component,` • `,e.file,`:`,e.line,`:`,e.column]})})]}),i===`input`&&(0,Q.jsxs)(`div`,{className:`py-5 space-y-5`,children:[(0,Q.jsx)(`textarea`,{autoFocus:!0,value:g,onChange:e=>y(e.target.value),onKeyDown:A,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,Q.jsx)(`div`,{className:`border-t border-border`}),(0,Q.jsx)(In,{client:u,isClientReady:d,sourceInfo:e,selectedContext:w,onSelectionChange:T,screenshot:t,onDataReady:k,isAutomated:!!e.automated,userInput:g,selectedAgent:f})]}),i===`loading`&&h&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)(wn,{plan:h})}),(i===`success`||i===`error`)&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-foreground`,children:o}),h&&(0,Q.jsx)(wn,{plan:h})]}),(0,Q.jsx)(v,{className:`flex items-center gap-3 pt-2`,children:i===`input`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:M,className:`mr-auto`,children:[(0,Q.jsx)(nn,{className:`w-4 h-4 mr-1.5`}),`Copy & Go`]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(c,{variant:`outline`,onClick:()=>N(!0),children:`Submit & Continue`}),(0,Q.jsx)(c,{onClick:()=>N(!1),children:`Submit`})]})]}):(0,Q.jsx)(c,{onClick:()=>x(!1),className:`w-full`,children:`Close`})})]})})},Rn=G.forwardRef(({visible:e},t)=>(0,Q.jsx)(`div`,{ref:t,className:y(`fixed pointer-events-none border-2 border-blue-500 bg-blue-500/10 z-[999997]`,e?`block`:`hidden`)}));Rn.displayName=`Overlay`;const zn=G.forwardRef(({visible:e},t)=>(0,Q.jsx)(`div`,{ref:t,className:y(`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`)}));zn.displayName=`Tooltip`;const Bn=(e=2500)=>{let[t,n]=(0,G.useState)(null);return{notification:t,showNotif:(0,G.useCallback)(t=>{n(t),setTimeout(()=>{n(null)},e)},[e])}};function Vn(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 Hn(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:Vn(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 Un=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:Hn(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:Hn(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:Hn(e)}:{file:`unknown`,component:t,apis:[],line:0,column:0,element:e,elementInfo:Hn(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:Hn(e)}},Wn=({isActive:e,isWaitingForFeedback:t,overlayRef:n,tooltipRef:r,btnRef:i})=>{(0,G.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=Un(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])},Gn=({isActive:e,isWaitingForFeedback:t,onElementInspected:n,btnRef:r})=>{(0,G.useEffect)(()=>{if(!e||t)return;let i=e=>{e.target!==r.current&&(e.preventDefault(),e.stopPropagation(),n(Un(e.target),e.target))};return document.addEventListener(`click`,i,!0),()=>document.removeEventListener(`click`,i,!0)},[e,t,n,r])};var Kn=e(d(),1);function qn(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 Jn=e=>{switch(e){case`success`:return Zn;case`info`:return $n;case`warning`:return Qn;case`error`:return er;default:return null}},Yn=Array(12).fill(0),Xn=({visible:e,className:t})=>G.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},G.createElement(`div`,{className:`sonner-spinner`},Yn.map((e,t)=>G.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Zn=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},G.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`})),Qn=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},G.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`})),$n=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},G.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`})),er=G.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},G.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`})),tr=G.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`},G.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),G.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),nr=()=>{let[e,t]=G.useState(document.hidden);return G.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e};let rr=1;const $=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:rr++,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],G.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(ar(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`&&!G.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`&&!G.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`&&!G.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`&&!G.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||rr++;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}},ir=(e,t)=>{let n=t?.id||rr++;return $.addToast({title:e,...t,id:n}),n},ar=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,or=ir;Object.assign(or,{success:$.success,info:$.info,warning:$.warning,error:$.error,custom:$.custom,message:$.message,promise:$.promise,dismiss:$.dismiss,loading:$.loading},{getHistory:()=>$.toasts,getToasts:()=>$.getActiveToasts()}),qn(`[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 sr(e){return e.label!==void 0}const cr=4e3;function lr(...e){return e.filter(Boolean).join(` `)}function ur(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}const dr=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]=G.useState(null),[O,k]=G.useState(null),[A,j]=G.useState(!1),[M,N]=G.useState(!1),[P,F]=G.useState(!1),[I,L]=G.useState(!1),[R,ee]=G.useState(!1),[z,te]=G.useState(0),[ne,re]=G.useState(0),B=G.useRef(n.duration||y||cr),ie=G.useRef(null),V=G.useRef(null),ae=c===0,H=c+1<=o,U=n.type,W=n.dismissible!==!1,oe=n.className||``,se=n.descriptionClassName||``,ce=G.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),K=G.useMemo(()=>n.closeButton??p,[n.closeButton,p]),le=G.useMemo(()=>n.duration||y||cr,[n.duration,y]),ue=G.useRef(0),q=G.useRef(0),de=G.useRef(0),J=G.useRef(null),[fe,pe]=b.split(`-`),Y=G.useMemo(()=>s.reduce((e,t,n)=>n>=ce?e:e+t.height,0),[s,ce]),me=nr(),he=n.invert||t,ge=U===`loading`;q.current=G.useMemo(()=>ce*x+Y,[ce,Y]),G.useEffect(()=>{B.current=le},[le]),G.useEffect(()=>{j(!0)},[]),G.useEffect(()=>{let e=V.current;if(e){let t=e.getBoundingClientRect().height;return re(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),G.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,re(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 X=G.useCallback(()=>{N(!0),te(q.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},200)},[n,d,a,q]);G.useEffect(()=>{if(n.promise&&U===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||me?(()=>{if(de.current<ue.current){let e=new Date().getTime()-ue.current;B.current-=e}de.current=new Date().getTime()})():B.current!==1/0&&(ue.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),X()},B.current)),()=>clearTimeout(e)},[u,i,n,U,me,X]),G.useEffect(()=>{n.delete&&(X(),n.onDismiss==null||n.onDismiss.call(n,n))},[X,n.delete]);function _e(){return w?.loading?G.createElement(`div`,{className:lr(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":U===`loading`},w.loading):G.createElement(Xn,{className:lr(C?.loader,n?.classNames?.loader),visible:U===`loading`})}let ve=n.icon||w?.[U]||Jn(U);return G.createElement(`li`,{tabIndex:0,ref:V,className:lr(_,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":R,"data-removed":M,"data-visible":H,"data-y-position":fe,"data-x-position":pe,"data-index":c,"data-front":ae,"data-swiping":P,"data-dismissible":W,"data-type":U,"data-invert":he,"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`:`${ne}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),J.current=null},onPointerDown:e=>{e.button!==2&&(ge||!W||(ie.current=new Date,te(q.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),J.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!W)return;J.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`),X(),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`)}ee(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!J.current||!W||window.getSelection()?.toString().length>0)return;let i=t.clientY-J.current.y,a=t.clientX-J.current.x,o=e.swipeDirections??ur(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)&&ee(!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`?G.createElement(`button`,{"aria-label":T,"data-disabled":ge,"data-close-button":!0,onClick:ge||!W?()=>{}:()=>{X(),n.onDismiss==null||n.onDismiss.call(n,n)},className:lr(C?.closeButton,n?.classNames?.closeButton)},w?.close??tr):null,(U||n.icon||n.promise)&&n.icon!==null&&(w?.[U]!==null||n.icon)?G.createElement(`div`,{"data-icon":``,className:lr(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||_e():null,n.type===`loading`?null:ve):null,G.createElement(`div`,{"data-content":``,className:lr(C?.content,n?.classNames?.content)},G.createElement(`div`,{"data-title":``,className:lr(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?G.createElement(`div`,{"data-description":``,className:lr(v,se,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),G.isValidElement(n.cancel)?n.cancel:n.cancel&&sr(n.cancel)?G.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{sr(n.cancel)&&W&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),X())},className:lr(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,G.isValidElement(n.action)?n.action:n.action&&sr(n.action)?G.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{sr(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&X())},className:lr(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function fr(){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 pr(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 mr=G.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:_=fr(),gap:v=14,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=G.useState([]),C=G.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=G.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=G.useState([]),[D,O]=G.useState(!1),[k,A]=G.useState(!1),[j,M]=G.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=G.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=G.useRef(null),I=G.useRef(!1),L=G.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||$.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return G.useEffect(()=>$.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Kn.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]),G.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]),G.useEffect(()=>{x.length<=1&&O(!1)},[x]),G.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]),G.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),G.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?G.createElement(`ol`,{key:t,dir:_===`auto`?fr():_,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,...pr(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)=>G.createElement(dr,{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}))}),hr=({...e})=>{let{resolvedTheme:t}=P(),n=vr();return(0,Q.jsx)(mr,{theme:t,className:`toaster group`,icons:{success:(0,Q.jsx)(p,{className:`size-4`}),info:(0,Q.jsx)(on,{className:`size-4`}),warning:(0,Q.jsx)(gn,{className:`size-4`}),error:(0,Q.jsx)(ln,{className:`size-4`}),loading:(0,Q.jsx)(l,{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})},gr=(0,G.createContext)(null),_r=()=>(0,G.useContext)(gr),vr=_r,yr=`inspector-inspection-items`;function br(){let[e,t]=(0,G.useState)(()=>{try{let e=localStorage.getItem(yr);return e?JSON.parse(e):[]}catch{return[]}});return(0,G.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,G.useEffect)(()=>{try{localStorage.setItem(yr,JSON.stringify(e))}catch{console.warn(`Failed to save inspections to localStorage`)}},[e]),{inspections:e,setInspections:t}}var xr=e(R());const Sr=({request:e,client:n,isClientReady:r})=>{let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,u]=(0,G.useState)(!1),d=async()=>{if(o===null){u(!0);try{let t=typeof window<`u`?window.__DEV_INSPECTOR_CONFIG__:null;if(t&&!t.disableChrome&&t.isAutomated&&n&&r)try{s(((await n.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(`
51
+ `)||`No details`);return}catch{console.log(`[ContextDialog] Chrome DevTools failed, using local storage`)}let i=t?(()=>{let e=t.baseUrl||`http://${t.host}:${t.port}${t.base||`/`}`;return e.endsWith(`/`)?e.slice(0,-1):e})():``,a=await fetch(`${i}/__inspector__/request-details/${e.reqid}`);if(a.ok)s(await a.text());else throw Error(`Failed to fetch: ${a.status} ${a.statusText}`)}catch(e){s(`Failed to fetch details: ${e instanceof Error?e.message:String(e)}`)}finally{u(!1)}}};return(0,Q.jsxs)(`div`,{className:`rounded-md bg-muted/50 hover:bg-muted/70 transition-colors overflow-hidden`,children:[(0,Q.jsxs)(`button`,{onClick:()=>{i||d(),a(!i)},className:`w-full p-3 text-left flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex-shrink-0`,children:i?(0,Q.jsx)(t,{className:`w-4 h-4 text-muted-foreground`}):(0,Q.jsx)(Qt,{className:`w-4 h-4 text-muted-foreground`})}),(0,Q.jsx)(`span`,{className:y(`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,Q.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`text-sm text-foreground font-mono truncate`,title:e.url,children:e.url}),(0,Q.jsxs)(`div`,{className:y(`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]})]})]}),i&&(0,Q.jsx)(`div`,{className:`px-3 pb-3 pl-10`,children:(()=>{if(c)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(l,{className:`w-4 h-4 animate-spin`}),`Loading...`]});if(!o)return null;let e=o,t=null;try{let n=o.split(`
53
52
  `).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):**
54
53
  \`\`\`json
55
54
  ${JSON.stringify(t,null,2)}
@@ -57,9 +56,9 @@ ${JSON.stringify(t,null,2)}
57
56
 
58
57
  **Raw Content:**
59
58
  \`\`\`
60
- ${a}
59
+ ${o}
61
60
  \`\`\`
62
- `}}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})})})()})]})},Wi=({open:e,onOpenChange:t,inspectionItems:n,onRemoveInspection:r,client:i,isClientReady:a})=>{let[o,s]=(0,U.useState)(`inspections`),l=jn(),{consoleMessages:f,networkRequests:p,stdioMessages:h,loading:g,error:y,refresh:b}=Dn(i,a);(0,U.useEffect)(()=>{e&&b()},[e,b]);let x=[{id:`inspections`,label:`Inspections`,count:n.length},{id:`console`,label:`Console`,count:f.length},{id:`network`,label:`Network`,count:p.length},{id:`page`,label:`Page`},{id:`stdio`,label:`Terminal`,count:h.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.jsx)(`button`,{type:`button`,onClick:()=>b(),disabled:g,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`,g&&`animate-spin`)})})]})}),(0,X.jsx)(`div`,{className:`flex gap-1 border-b border-border flex-shrink-0`,children:x.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:[y&&(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:y})]}),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:[g&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(R,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!g&&f.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:`No console logs`})}),!g&&f.map(e=>(0,X.jsx)(`div`,{className:`p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(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:[g&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(R,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!g&&p.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:`No network requests`})}),!g&&p.map(e=>(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:[g&&(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(R,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!g&&h.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:`No stdio messages`})}),!g&&h.map(e=>(0,X.jsx)(`div`,{className:`p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(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:l?(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:l.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:l.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:[l.viewport.width,` × `,l.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:l.language})]})]})]})]})}):(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(R,{className:`w-6 h-6 animate-spin text-muted-foreground`})})})]})]})})};function Gi({initialOffset:e={x:0,y:0}}={}){let t=(0,U.useRef)(null),[n,r]=(0,U.useState)(!1),i=(0,U.useRef)(e),a=(0,U.useRef)({x:0,y:0}),o=(0,U.useRef)({x:0,y:0}),s=(0,U.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,U.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,U.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,U.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,U.useState)(!1),[k,M]=(0,U.useState)(``),[N,P]=(0,U.useState)(`none`),[ee,te]=(0,U.useState)(!0),[L,R]=(0,U.useState)(!1),{agent:z,setAgent:re,isReady:B}=ne(w),[V,W]=(0,U.useState)(j),[se,ce]=(0,U.useState)(!1),[le,G]=(0,U.useState)(null),[ue,de]=(0,U.useState)(!1),{prompts:K}=F(g||null);(0,U.useEffect)(()=>{ae().then(e=>{W(e)})},[]),(0,U.useEffect)(()=>{B&&z&&y?.(z)},[z,B,y]);let{uiState:fe,chatStatus:pe,toolName:me,displayText:q}=A(a,o,D),J=pe===`submitted`||pe===`streaming`,he=fe===`expanded`&&!J,ge=a.length>0&&pe!==`error`||J,[_e,ve]=(0,U.useState)(null),ye=(0,U.useRef)(null),be=(0,U.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,U.useEffect)(()=>{if(!B||!h)return;let e=!0,t=V.find(e=>e.name===z)||V[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}},[z,B,h,V]),(0,U.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,U.useEffect)(()=>()=>{let e=ye.current;!e||be.current||(be.current=!0,console.log(`[InspectorBar] Cleaning up session on unmount: ${e}`),xe(e))},[]);let Se=V.find(e=>e.name===z)||V[0]||j[0],{elementRef:Ce,isDragging:we,handleMouseDown:Te}=Gi(),[Y,Ee]=(0,U.useState)(null),De=(0,U.useRef)(null);(0,U.useEffect)(()=>{D&&De.current&&De.current.focus()},[D]),(0,U.useEffect)(()=>{if(!J&&!ee){let e=setTimeout(()=>{te(!0)},2e3);return()=>clearTimeout(e)}},[J,ee]),(0,U.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,U.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,V.find(e=>e.name===z)||V[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)(ie,{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&&!L&&(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&&ee&&O(!0)},onMouseLeave:()=>{L||(!k.trim()&&!we&&(O(!1),P(`none`)),te(!0))},children:[(0,X.jsx)(Ki,{prompts:K,visible:D&&!J&&N===`none`&&K.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:z,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:z,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}):me?(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:me})]}):(0,X.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:J&&!q?(0,X.jsx)(oe,{duration:2,spread:2,children:o===`submitted`&&Se?.command===`npx`?`Starting ${Se.name}... This may take a moment.`:`Thinking...`}):q||`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:()=>de(!0),className:_(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,`hover:bg-accent/50`,ue&&`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:()=>ce(!se),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:V.find(e=>e.name===z)?.meta?.icon,alt:z,className:`w-3.5 h-3.5`})}),se&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>ce(!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:V.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`,z===e.name&&`bg-accent/50 font-medium`),children:[(0,X.jsxs)(`button`,{onClick:()=>{re(e.name),ce(!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(),G(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 ${z}...`,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(),R(!L)},className:_(`absolute top-3 left-3 z-10 flex items-center justify-center w-8 h-8 rounded-full transition-all`,L?`bg-black text-white shadow-md hover:bg-gray-800`:`bg-muted/80 text-muted-foreground hover:bg-accent hover:text-foreground`),title:L?`Unpin inspector`:`Pin inspector`,children:L?(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:z})})]})})]}),(0,X.jsx)(Wi,{open:ue,onOpenChange:de,inspectionItems:f,onRemoveInspection:p,client:g,isClientReady:h}),le&&(()=>{let e=V.find(e=>e.name===le);return e?(0,X.jsx)(d,{open:!!le,onOpenChange:()=>G(null),children:(0,X.jsxs)(m,{onClose:()=>G(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)(H,{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,U.useState)(null),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)([]),[g,v]=(0,U.useState)(null),[b,x]=(0,U.useState)(``),S=(0,U.useRef)(null),C=(0,U.useRef)(null);(0,U.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,U.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}=B(),{resolvedTheme:i}=N(),a=z(),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(null),{inspections:m,setInspections:h}=xr(),[v,y]=(0,U.useState)([]),[b,x]=(0,U.useState)(null),[S,C]=(0,U.useState)(!1),{messages:w,sendMessage:T,status:E,stop:D}=V({transport:new g({api:`${I()}/api/acp/chat`})}),O=()=>{D()},k=(0,U.useRef)(null),A=(0,U.useRef)(null),j=(0,U.useRef)(null),{notification:M,showNotif:P}=Vn();(0,U.useEffect)(()=>{e&&e.host&&(i===`dark`?e.host.classList.add(`dark`):e.host.classList.remove(`dark`))},[i,e]),(0,U.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,U.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]),ee=(0,U.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`)},[]),te=(0,U.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,U.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&o){ee();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(),te())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,F,ee,te]),(0,U.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]),Gn({isActive:o&&!S,isWaitingForFeedback:f!==null,overlayRef:k,tooltipRef:A,btnRef:j});let L=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,U.useEffect)(()=>{let e=e=>{let t=e;if(t.detail){let e=t.detail.info||t.detail;e&&e.file&&L({...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:L,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:te,isRegionModeActive:S})}),o&&S&&(0,X.jsx)(Yi,{isActive:!0,onSelectionComplete:async e=>{e.element&&e.element.isConnected?d(await Vi(e.element)):d(``),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:ee,client:n,isClientReady:r,selectedAgent:b||void 0})}),(0,X.jsx)(gr,{})]})})};var Zi=class extends HTMLElement{connectedCallback(){this.style.cssText=`
61
+ `}}catch{}return!t&&!o.includes(`###`)&&(o.trim().startsWith(`{`)||o.trim().startsWith(`[`))&&(e=`\`\`\`json\n${o}\n\`\`\``),(0,Q.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,Q.jsx)(k,{children:e})})})()})]})},Cr=({open:e,onOpenChange:t,inspectionItems:n,onRemoveInspection:r,client:i,isClientReady:a})=>{let[o,c]=(0,G.useState)(`inspections`),u=An(),{consoleMessages:d,networkRequests:f,stdioMessages:p,loading:h,error:g,refresh:v}=En(i,a);(0,G.useEffect)(()=>{e&&v()},[e,v]);let b=[{id:`inspections`,label:`Inspections`,count:n.length},{id:`console`,label:`Console`,count:d.length},{id:`network`,label:`Network`,count:f.length},{id:`page`,label:`Page`},{id:`stdio`,label:`Terminal`,count:p.length}];return(0,Q.jsx)(m,{open:e,onOpenChange:t,children:(0,Q.jsxs)(W,{className:`w-[70vw] max-w-[70vw] h-[80vh] max-h-[80vh] flex flex-col`,onClose:()=>t(!1),children:[(0,Q.jsx)(s,{className:`flex-shrink-0 pr-8`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(_,{children:`Full Page Context`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(),disabled:h,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,Q.jsx)(te,{className:y(`w-3.5 h-3.5`,h&&`animate-spin`)})})]})}),(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border flex-shrink-0`,children:b.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>c(e.id),className:y(`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,Q.jsx)(`span`,{className:`ml-2 px-1.5 py-0.5 text-xs bg-muted rounded-full`,children:e.count}),o===e.id&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-foreground`})]},e.id))}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-auto min-h-0`,children:[g&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-destructive bg-destructive/10 rounded-md m-4`,children:[(0,Q.jsx)(en,{className:`w-4 h-4 flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`break-all`,children:g})]}),o===`inspections`&&(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:n.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:[(0,Q.jsx)(`p`,{className:`text-sm`,children:`No inspections`}),(0,Q.jsx)(`p`,{className:`text-xs mt-1`,children:`Use ⌥I to inspect elements`})]}):(0,Q.jsx)(z,{items:n,onRemove:r})}),o===`console`&&(0,Q.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[h&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(l,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!h&&d.length===0&&(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,Q.jsx)(`p`,{className:`text-sm`,children:`No console logs`})}),!h&&d.map(e=>(0,Q.jsx)(`div`,{className:`p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:y(`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,Q.jsx)(`span`,{className:`text-sm text-foreground/90 flex-1 font-mono break-all overflow-hidden`,children:e.text})]})},e.msgid))]}),o===`network`&&(0,Q.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[h&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(l,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!h&&f.length===0&&(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,Q.jsx)(`p`,{className:`text-sm`,children:`No network requests`})}),!h&&f.map(e=>(0,Q.jsx)(Sr,{request:e,client:i,isClientReady:a},e.reqid))]}),o===`stdio`&&(0,Q.jsxs)(`div`,{className:`p-4 space-y-2 h-full overflow-auto`,children:[h&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(l,{className:`w-6 h-6 animate-spin text-muted-foreground`})}),!h&&p.length===0&&(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:(0,Q.jsx)(`p`,{className:`text-sm`,children:`No stdio messages`})}),!h&&p.map(e=>(0,Q.jsx)(`div`,{className:`p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:y(`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,Q.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,Q.jsx)(`div`,{className:`p-4 h-full overflow-auto`,children:u?(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-md bg-muted/50`,children:[(0,Q.jsx)(an,{className:`w-5 h-5 text-primary mt-0.5 flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`URL`}),(0,Q.jsx)(`div`,{className:`text-sm text-foreground font-mono break-all`,children:u.url})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Title`}),(0,Q.jsx)(`div`,{className:`text-sm text-foreground`,children:u.title})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Viewport`}),(0,Q.jsxs)(`div`,{className:`text-sm text-foreground`,children:[u.viewport.width,` × `,u.viewport.height]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Language`}),(0,Q.jsx)(`div`,{className:`text-sm text-foreground`,children:u.language})]})]})]})]})}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(l,{className:`w-6 h-6 animate-spin text-muted-foreground`})})})]})]})})};function wr({initialOffset:e={x:0,y:0}}={}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(e),a=(0,G.useRef)({x:0,y:0}),o=(0,G.useRef)({x:0,y:0}),s=(0,G.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,G.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,G.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,G.useEffect)(()=>{s()},[s]),{elementRef:t,isDragging:n,handleMouseDown:c}}const Tr=({prompts:e,onSelect:t,visible:n})=>!n||e.length===0?null:(0,Q.jsx)(`div`,{className:y(`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,Q.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:y(`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,Q.jsx)(`span`,{children:e.title||e.name})},e.name))}),Er=({isActive:e,onToggleInspector:t,onSubmitAgent:r,onCancel:i,isAgentWorking:a,messages:o,status:c,inspectionCount:l=0,inspectionItems:d=[],onRemoveInspection:f=()=>{},toolsReady:g=!0,mcpClient:v=null,onAgentChange:b,onToggleRegionMode:T,isRegionModeActive:E=!1})=>{let[D,k]=(0,G.useState)(!1),[A,M]=(0,G.useState)(``),[N,P]=(0,G.useState)(`none`),[F,R]=(0,G.useState)(!0),[z,te]=(0,G.useState)(!1),{agent:B,setAgent:ie,isReady:ae}=ne(ee),[H,U]=(0,G.useState)(w),[oe,se]=(0,G.useState)(!1),[ce,K]=(0,G.useState)(null),[le,ue]=(0,G.useState)(!1),{prompts:q}=I(v||null);(0,G.useEffect)(()=>{L().then(e=>{U(e)})},[]),(0,G.useEffect)(()=>{ae&&B&&b?.(B)},[B,ae,b]);let{uiState:de,chatStatus:J,toolName:fe,displayText:pe}=j(o,c,D),Y=J===`submitted`||J===`streaming`,me=de===`expanded`&&!Y,he=o.length>0&&J!==`error`||Y,[ge,X]=(0,G.useState)(null),_e=(0,G.useRef)(null),ve=(0,G.useRef)(!1),ye=e=>{let t=`${re()}/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,G.useEffect)(()=>{if(!ae||!g)return;let e=!0,t=H.find(e=>e.name===B)||H[0]||w[0];return(async()=>{if(_e.current){try{await fetch(`${re()}/api/acp/cleanup-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:_e.current})})}catch(e){console.warn(`[InspectorBar] Failed to cleanup previous session:`,e)}_e.current=null,e&&X(null)}console.log(`[InspectorBar] Initializing session for ${t.name}...`);try{let n=await fetch(`${re()}/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}`),X(r.sessionId),_e.current=r.sessionId,ve.current=!1)}catch(e){console.error(`[InspectorBar] Failed to initialize session:`,e)}})(),()=>{e=!1}},[B,ae,g,H]),(0,G.useEffect)(()=>{let e=()=>{let e=_e.current;!e||ve.current||(ve.current=!0,ye(e))};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e)}},[]),(0,G.useEffect)(()=>()=>{let e=_e.current;!e||ve.current||(ve.current=!0,console.log(`[InspectorBar] Cleaning up session on unmount: ${e}`),ye(e))},[]);let be=H.find(e=>e.name===B)||H[0]||w[0],{elementRef:xe,isDragging:Se,handleMouseDown:Ce}=wr(),[Z,we]=(0,G.useState)(null),Te=(0,G.useRef)(null);(0,G.useEffect)(()=>{D&&Te.current&&Te.current.focus()},[D]),(0,G.useEffect)(()=>{if(!Y&&!F){let e=setTimeout(()=>{R(!0)},2e3);return()=>clearTimeout(e)}},[Y,F]),(0,G.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;we({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;we({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[Ee,De]=(0,G.useState)(null),Oe=async(e,t={})=>{if(v)try{let n=(await v.request({method:`prompts/get`,params:{name:e.name,arguments:t}},O)).messages?.[0];if(n?.content?.type===`text`&&n.content.text){M(n.content.text),Te.current?.focus();return}}catch(e){console.error(`Failed to execute prompt:`,e)}M(e.template||e.description||e.name),Te.current?.focus()},ke=async e=>{if(e.arguments&&e.arguments.length>0){De(e);return}await Oe(e)},Ae=e=>{Ee&&(Oe(Ee,e),De(null))},je=e=>{e.preventDefault(),A.trim()&&(we(null),r(A,H.find(e=>e.name===B)||H[0]||w[0],ge||void 0),M(``),P(`chat`))},Me=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),je(e)),e.key===`Escape`&&(k(!1),Te.current?.blur())},Ne=c===`error`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{prompt:Ee,isOpen:!!Ee,onOpenChange:e=>!e&&De(null),onSubmit:Ae}),(D||N!==`none`)&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[999998] bg-transparent`,onClick:()=>{!Y&&!z&&(k(!1),P(`none`))}}),(0,Q.jsxs)(`div`,{ref:xe,className:y(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,D?`w-[480px]`:he?`w-auto min-w-[200px] max-w-[480px]`:`w-[190px]`,Se?`cursor-grabbing`:`cursor-grab`),onMouseDown:Ce,onMouseEnter:()=>{!Se&&F&&k(!0)},onMouseLeave:()=>{z||(!A.trim()&&!Se&&(k(!1),P(`none`)),R(!0))},children:[(0,Q.jsx)(Tr,{prompts:q,visible:D&&!Y&&N===`none`&&q.length>0,onSelect:ke}),(0,Q.jsxs)(`div`,{className:y(`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`,Ne&&!D&&`bg-destructive/10 border-destructive/20`),children:[(0,Q.jsxs)(`div`,{className:y(`flex items-center transition-opacity duration-150 w-full relative`,me?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[o.length===0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:(0,Q.jsx)(`img`,{src:be?.meta?.icon,alt:B,className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3 whitespace-nowrap`,children:`⌥I or hover to inspect`})]}),he&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,Q.jsx)(`div`,{className:`relative flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:Y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`absolute inset-1 rounded-full border-2 border-current opacity-20 animate-ping text-foreground`}),(0,Q.jsx)(`img`,{src:be?.meta?.icon,alt:B,className:`w-3.5 h-3.5 animate-pulse`})]}):Z?Z.status===`in-progress`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`absolute inset-1 rounded-full border-2 border-current opacity-20 animate-ping text-blue-500`}),(0,Q.jsx)(u,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):Z.status===`completed`?(0,Q.jsx)(p,{className:`w-5 h-5 text-green-500`}):(0,Q.jsx)(S,{className:`w-5 h-5 text-red-500`}):Ne?(0,Q.jsx)(S,{className:`w-5 h-5 text-red-500`}):(0,Q.jsx)(p,{className:`w-5 h-5 text-green-500`})}),(0,Q.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,Q.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0 pl-2`,children:(0,Q.jsx)(`div`,{className:`flex flex-col min-w-0 max-w-full pr-2 max-h-[24px] overflow-hidden`,children:Z&&Z.status===`in-progress`&&Z.currentStep?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,Q.jsx)(u,{className:`w-4 h-4 flex-shrink-0`}),(0,Q.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,Z.currentStep.index,`/`,Z.currentStep.total,`: `,Z.currentStep.title]})]}):Z?.message?(0,Q.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:Z.message}):fe?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,Q.jsx)(u,{className:`w-4 h-4 flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate min-w-0`,children:fe})]}):(0,Q.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:Y&&!pe?(0,Q.jsx)(h,{duration:2,spread:2,children:c===`submitted`&&be?.command===`npx`?`Starting ${be.name}... This may take a moment.`:`Thinking...`}):pe||`Processing...`})})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>P(e=>e===`chat`?`none`:`chat`),className:y(`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,Q.jsx)($t,{className:y(`w-3.5 h-3.5 transition-transform duration-300`,N===`chat`&&`rotate-180`)})}),Y&&(0,Q.jsx)(`button`,{type:`button`,onClick:i,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,Q.jsx)(hn,{className:`w-3 h-3`})})]})]})]}),(0,Q.jsxs)(`div`,{className:y(`flex items-center w-full gap-3 transition-all duration-150`,me?`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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ue(!0),className:y(`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,Q.jsx)(x,{className:`w-3.5 h-3.5`}),l>0&&(0,Q.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:l>99?`99+`:l})]}),(0,Q.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,Q.jsx)(`button`,{onClick:T,className:y(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,E?`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,Q.jsx)(mn,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`button`,{onClick:t,className:y(`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,Q.jsx)(rn,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`}),(0,Q.jsxs)(`form`,{onSubmit:je,className:`flex-1 flex items-center gap-2 min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,Q.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,Q.jsx)(`img`,{src:H.find(e=>e.name===B)?.meta?.icon,alt:B,className:`w-3.5 h-3.5`})}),oe&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>se(!1)}),(0,Q.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,Q.jsxs)(`div`,{className:y(`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,Q.jsxs)(`button`,{onClick:()=>{ie(e.name),se(!1)},className:`flex items-center gap-2 flex-1 text-left`,children:[e.meta?.icon&&(0,Q.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4 flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:e.name})]}),(e.configHint||e.configLink)&&(0,Q.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,Q.jsx)(on,{className:`w-3.5 h-3.5 text-muted-foreground`})})]},e.name))})]})]}),(0,Q.jsx)(`input`,{ref:Te,type:`text`,value:A,onChange:e=>M(e.target.value),onKeyDown:Me,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:Y}),(o.length>0||Y)&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>P(e=>e===`chat`?`none`:`chat`),className:y(`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,Q.jsx)($t,{className:y(`w-3.5 h-3.5 transition-transform duration-300`,N===`chat`&&`rotate-180`)})}),Y?(0,Q.jsx)(`button`,{type:`button`,onClick:i,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,Q.jsx)(hn,{className:`w-3 h-3`})}):(0,Q.jsx)(`button`,{type:`submit`,disabled:!A.trim(),className:y(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,A.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,Q.jsx)(Xt,{className:`w-3.5 h-3.5`})})]})]})]}),N!==`none`&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[480px] mx-auto animate-panel-in`,children:(0,Q.jsxs)(`div`,{className:`bg-muted/95 backdrop-blur-xl rounded-t-xl border border-border border-b-0 shadow-2xl overflow-hidden relative`,children:[he&&(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),te(!z)},className:y(`absolute top-3 left-3 z-10 flex items-center justify-center w-8 h-8 rounded-full transition-all`,z?`bg-black text-white shadow-md hover:bg-gray-800`:`bg-muted/80 text-muted-foreground hover:bg-accent hover:text-foreground`),title:z?`Unpin inspector`:`Pin inspector`,children:z?(0,Q.jsx)(dn,{className:`w-3.5 h-3.5 fill-current`}):(0,Q.jsx)(dn,{className:`w-3.5 h-3.5`})}),N===`chat`&&(0,Q.jsx)(`div`,{className:`h-[500px]`,children:(0,Q.jsx)(C,{messages:o,status:c,selectedAgent:B})})]})})]}),(0,Q.jsx)(Cr,{open:le,onOpenChange:ue,inspectionItems:d,onRemoveInspection:f,client:v,isClientReady:g}),ce&&(()=>{let e=H.find(e=>e.name===ce);return e?(0,Q.jsx)(m,{open:!!ce,onOpenChange:()=>K(null),children:(0,Q.jsxs)(W,{onClose:()=>K(null),className:`w-80`,children:[(0,Q.jsxs)(s,{children:[(0,Q.jsxs)(_,{className:`flex items-center gap-3`,children:[e.meta?.icon&&(0,Q.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-6 h-6`}),e.name]}),e.configHint&&(0,Q.jsx)(n,{children:e.configHint})]}),e.configLink&&(0,Q.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})()]})},Dr=(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},Or=({isActive:e,onSelectionComplete:t,onCancel:n,onClose:r})=>{let[i,a]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(null),[b,x]=(0,G.useState)(``),S=(0,G.useRef)(null),C=(0,G.useRef)(null);(0,G.useEffect)(()=>{_!==null&&C.current&&C.current.focus()},[_]);let w=()=>{f(!1),m(null),g([]),a(null),c(null),u(!1),v(null),x(``)};(0,G.useEffect)(()=>{if(!e){w();return}let t=e=>{e.key===`Escape`&&(_===null?d?w():n():v(null))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n,d,_]);let T=()=>!i||!s?null:{left:Math.min(i.x,s.x),top:Math.min(i.y,s.y),width:Math.abs(s.x-i.x),height:Math.abs(s.y-i.y)},E=e=>{d||e.button===0&&(e.stopPropagation(),e.preventDefault(),u(!0),a({x:e.clientX,y:e.clientY}),c({x:e.clientX,y:e.clientY}))},D=e=>{d||l&&(e.stopPropagation(),e.preventDefault(),c({x:e.clientX,y:e.clientY}))},O=e=>{if(d||!l||!i||!s)return;e.stopPropagation(),e.preventDefault(),u(!1);let t=T();t&&t.width>5&&t.height>5?(m(t),k(t),f(!0)):(a(null),c(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=Dr(s,e,r);n.push({el:a,rect:s,iou:u})}if(n.length===0){f(!1),a(null),c(null);return}n.sort((e,t)=>t.iou-e.iou);let i=n[0].el;for(let e of n){let t=Un(e.el);if(t.file&&t.file!==`unknown`){i=e.el;break}}let o=[],s=Un(i);o.push({el:i,rect:i.getBoundingClientRect(),info:s,isPrimary:!0});let l=0;for(let e of n){if(e.el===i)continue;if(l>=50)break;let t=Un(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}),g(o)},A=e=>{if(_===null)return;let t=typeof e==`string`?e:b,n=[...h];n[_].note=t.trim()||void 0,g(n),v(null)},j=()=>{if(h.length===0)return;let e=h.find(e=>e.isPrimary)||h[0],n={...e.info};e.note&&(n.note=e.note),n.relatedElements=h.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=d?p:T();return(0,Q.jsxs)(`div`,{ref:S,className:y(`fixed inset-0 z-[2147483646]`,d?`cursor-default pointer-events-auto`:`cursor-crosshair pointer-events-auto`),onMouseDown:E,onMouseMove:D,onMouseUp:O,children:[M&&(0,Q.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,Q.jsxs)(`div`,{className:`absolute -top-10 left-0 flex gap-2 pointer-events-auto`,children:[(0,Q.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)]}),d&&(0,Q.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,Q.jsx)(Zt,{className:`w-3.5 h-3.5`}),`Finish & Inspect`]}),d&&(0,Q.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,Q.jsx)(o,{className:`w-3.5 h-3.5`}),`Close`]})]})}),d&&h.map((e,t)=>(0,Q.jsxs)(`div`,{className:y(`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,Q.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,Q.jsx)(cn,{className:`w-3 h-3`})}),!e.note&&(0,Q.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,Q.jsx)(un,{className:`w-3 h-3 text-slate-600`})})]},t)),_!==null&&h[_]&&(0,Q.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,h[_].rect.right+10)),top:Math.min(window.innerHeight-250,Math.max(10,h[_].rect.top))},onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Q.jsxs)(`span`,{className:`text-xs font-semibold text-slate-600 flex items-center gap-1.5`,children:[(0,Q.jsx)(cn,{className:`w-3.5 h-3.5`}),`Add Annotation`]}),(0,Q.jsx)(`button`,{onClick:()=>v(null),className:`text-slate-400 hover:text-slate-600`,children:(0,Q.jsx)(o,{className:`w-3.5 h-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`text-[10px] text-slate-400 font-mono mb-2 truncate`,children:[(0,Q.jsx)(`span`,{className:`font-semibold text-slate-600`,children:h[_].info.component||`Element`}),(0,Q.jsx)(`span`,{className:`mx-1.5 opacity-50`,children:`•`}),h[_].info.file?`${h[_].info.file.split(`/`).pop()}:${h[_].info.line}`:`Unknown Location`]}),(0,Q.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,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(`button`,{onClick:()=>{x(``),A(``)},className:`text-xs text-slate-500 hover:text-slate-700 px-2 py-1`,children:`Clear`}),(0,Q.jsx)(`button`,{onClick:()=>A(),className:`text-xs bg-zinc-900 hover:bg-zinc-800 text-white px-2 py-1 rounded`,children:`Save`})]})]})]})},kr=({shadowRoot:e,mountPoint:t})=>{let{client:n,isClientReady:r}=H(),{resolvedTheme:i}=P(),o=M(),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(null),{inspections:h,setInspections:_}=br(),[v,b]=(0,G.useState)([]),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(!1),{messages:T,sendMessage:D,status:O,stop:k}=g({transport:new a({api:`${re()}/api/acp/chat`})}),A=()=>{k()},j=(0,G.useRef)(null),N=(0,G.useRef)(null),F=(0,G.useRef)(null),{notification:I,showNotif:L}=Bn();(0,G.useEffect)(()=>{e&&e.host&&(i===`dark`?e.host.classList.add(`dark`):e.host.classList.remove(`dark`))},[i,e]),(0,G.useEffect)(()=>{let e=sessionStorage.getItem(`inspector-current-inspection-id`);e&&(h.some(t=>t.id===e)||sessionStorage.removeItem(`inspector-current-inspection-id`))},[h]);let R=(0,G.useCallback)(()=>{let e=!s;c(e),w(!1),document.body.style.cursor=e?`crosshair`:``,e?m(null):(j.current&&(j.current.style.display=`none`),N.current&&(N.current.style.display=`none`),m(null)),L(e?`Inspector ON`:`Inspector OFF`)},[s,L]),ee=(0,G.useCallback)(()=>{m(null),c(!1),w(!1),document.body.style.cursor=``,j.current&&(j.current.style.display=`none`),N.current&&(N.current.style.display=`none`)},[]),z=(0,G.useCallback)(()=>{if(!s){c(!0),w(!0),m(null),L(`Region Mode: ON`);return}let e=!C;w(e),e?(m(null),document.body.style.cursor=`default`):document.body.style.cursor=`crosshair`},[s,C,L]);(0,G.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&s){ee();return}e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyI`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),R()),e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyS`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),z())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[s,R,ee,z]),(0,G.useEffect)(()=>{let e=()=>{s||(c(!0),document.body.style.cursor=`crosshair`,m(null),L(`Inspector ON`))};return window.addEventListener(`activate-inspector`,e),()=>window.removeEventListener(`activate-inspector`,e)},[s,L]),(0,G.useEffect)(()=>{let e=()=>{c(!0),w(!0),m(null),document.body.style.cursor=`default`,L(`Area Mode: ON`)};return window.addEventListener(`activate-area-select`,e),()=>window.removeEventListener(`activate-area-select`,e)},[L]),Wn({isActive:s&&!C,isWaitingForFeedback:p!==null,overlayRef:j,tooltipRef:N,btnRef:F});let te=async e=>{if(e.element){let t=e.element;await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,50)})}),t.isConnected?f(await E(t)):f(``)}if(u(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()};_(e=>[...e,t]),window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:[t]}})),c(!1),document.body.style.cursor=``,j.current&&(j.current.style.display=`none`),N.current&&(N.current.style.display=`none`)}else m(`input`),j.current&&(j.current.style.display=`none`),N.current&&(N.current.style.display=`none`)};return(0,G.useEffect)(()=>{let e=e=>{let t=e;if(t.detail){let e=t.detail.info||t.detail;e&&e.file&&te({...e,automated:!0})}};return window.addEventListener(`dev-inspector:inspect-element`,e),()=>window.removeEventListener(`dev-inspector:inspect-element`,e)},[]),Gn({isActive:s&&!C,isWaitingForFeedback:p!==null,onElementInspected:te,btnRef:F}),(0,Q.jsx)(`div`,{className:y(`font-sans antialiased w-full h-full pointer-events-none fixed inset-0`,i===`dark`&&`dark`),children:(0,Q.jsxs)(gr.Provider,{value:t||null,children:[(0,Q.jsx)(`div`,{className:`pointer-events-auto`,children:o&&(0,Q.jsx)(Er,{toolsReady:r,mcpClient:n,isActive:s,onToggleInspector:R,onSubmitAgent:(e,t,n)=>{D({text:e},{body:{agent:t,envVars:{},sessionId:n}})},onCancel:A,isAgentWorking:O===`streaming`||O===`submitted`,messages:T,status:O,inspectionCount:h.length,inspectionItems:h,onRemoveInspection:e=>{_(t=>t.filter(t=>t.id!==e))},onAgentChange:S,onToggleRegionMode:z,isRegionModeActive:C})}),s&&C&&(0,Q.jsx)(Or,{isActive:!0,onSelectionComplete:async e=>{e.element&&e.element.isConnected?f(await E(e.element)):f(``),window.dispatchEvent(new CustomEvent(`area-selection-complete`,{detail:{sourceInfo:e}})),u(e),m(`input`),w(!1),c(!1),L(`Region: ${(e.relatedElements?.length||0)+1} elements`)},onCancel:()=>w(!1),onClose:R}),(0,Q.jsx)(Rn,{ref:j,visible:s&&p===null&&!C}),(0,Q.jsx)(zn,{ref:N,visible:s&&p===null&&!C}),I&&(0,Q.jsx)(Yt,{message:I}),p&&l&&(0,Q.jsx)(`div`,{className:`pointer-events-auto`,children:(0,Q.jsx)(Ln,{sourceInfo:l,screenshot:d,mode:p,onSubmit:(e,t=!1,n)=>{if(!l)return;let r=l.relatedElements&&l.relatedElements.length>0,i=e;!i&&r&&(i=`Region: ${(l.relatedElements?.length||0)+1} elements (primary: ${l.elementInfo?.tagName.toLowerCase()||`element`})${l.note||l.relatedElements?.some(e=>e.note)?`. Please read notes on these elements.`:``}`);let a=i||e,o={id:`inspection-${Date.now()}`,sourceInfo:{file:l.file,component:l.component,line:l.line,column:l.column,elementInfo:l.elementInfo,relatedElements:l.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};_(e=>[...e,o]);let s=[...v,o];b(s),m(null),t?(c(!0),document.body.style.cursor=`crosshair`,L(`Saved (${s.length})`)):(window.dispatchEvent(new CustomEvent(`element-inspected`,{detail:{inspections:s}})),b([]),c(!1),document.body.style.cursor=``,L(`${s.length} inspection${s.length>1?`s`:``} saved`))},onClose:ee,client:n,isClientReady:r,selectedAgent:x||void 0})}),(0,Q.jsx)(hr,{})]})})};var Ar=class extends HTMLElement{connectedCallback(){this.style.cssText=`
63
62
  position: fixed !important;
64
63
  top: 0 !important;
65
64
  left: 0 !important;
@@ -67,4 +66,4 @@ ${a}
67
66
  height: 100% !important;
68
67
  pointer-events: none !important;
69
68
  z-index: 2147483647 !important;
70
- `;let e=this.attachShadow({mode:`open`}),t=document.createElement(`style`);t.textContent=re,e.appendChild(t);let n=document.createElement(`div`);e.appendChild(n),Hi.createRoot(n).render(U.createElement(T,null,U.createElement(Xi,{shadowRoot:e,mountPoint:n})));let r=window.__DEV_INSPECTOR_CONFIG__;Yt({disableChrome:r?.disableChrome})}};function Qi(){customElements.get(`dev-inspector-mcp`)||customElements.define(`dev-inspector-mcp`,Zi)}Qi();export{_r as InspectorContainerContext,Qi as registerDevInspector,vr as useInspectorContainer,yr as useShadowRoot};
69
+ `;let e=this.attachShadow({mode:`open`}),t=document.createElement(`style`);t.textContent=B,e.appendChild(t);let n=document.createElement(`div`);e.appendChild(n),xr.createRoot(n).render(G.createElement(T,null,G.createElement(kr,{shadowRoot:e,mountPoint:n})));let r=window.__DEV_INSPECTOR_CONFIG__;Jt({disableChrome:r?.disableChrome})}};function jr(){customElements.get(`dev-inspector-mcp`)||customElements.define(`dev-inspector-mcp`,Ar)}jr();export{gr as InspectorContainerContext,jr as registerDevInspector,_r as useInspectorContainer,vr as useShadowRoot};