@spotpatch/vite 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -12
- package/dist/index.cjs +151 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +151 -51
- package/dist/index.js.map +1 -1
- package/dist/runtime-client.js +57 -157
- package/dist/runtime-data-flow-panel.js +3 -3
- package/dist/runtime-data-flow-prelude.js +1 -1
- package/dist/runtime-external-handoff-panel.js +5 -5
- package/dist/runtime-motion.js +461 -0
- package/dist/runtime-react-adapter.js +1 -1
- package/package.json +9 -8
package/dist/runtime-client.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import{createReact18Adapter as Ma}from"@spotpatch/react-adapter";var l={INVALID_REQUEST:"INVALID_REQUEST",INVALID_TOKEN:"INVALID_TOKEN",ORIGIN_NOT_ALLOWED:"ORIGIN_NOT_ALLOWED",SOURCE_NOT_FOUND:"SOURCE_NOT_FOUND",SOURCE_OUTSIDE_ROOT:"SOURCE_OUTSIDE_ROOT",SOURCE_TOO_LARGE:"SOURCE_TOO_LARGE",EDITOR_OPEN_FAILED:"EDITOR_OPEN_FAILED",DATA_FLOW_DISABLED:"DATA_FLOW_DISABLED",DATA_FLOW_SOURCE_STALE:"DATA_FLOW_SOURCE_STALE",DATA_FLOW_ANALYSIS_CANCELLED:"DATA_FLOW_ANALYSIS_CANCELLED",AI_DISABLED:"AI_DISABLED",PROVIDER_NOT_CONFIGURED:"PROVIDER_NOT_CONFIGURED",PROVIDER_AUTH_FAILED:"PROVIDER_AUTH_FAILED",PROVIDER_PROTOCOL_UNSUPPORTED:"PROVIDER_PROTOCOL_UNSUPPORTED",MODEL_NOT_ALLOWED:"MODEL_NOT_ALLOWED",MODEL_TOOL_CALL_UNSUPPORTED:"MODEL_TOOL_CALL_UNSUPPORTED",PROVIDER_RATE_LIMITED:"PROVIDER_RATE_LIMITED",AGENT_BUSY:"AGENT_BUSY",AGENT_LIMIT_EXCEEDED:"AGENT_LIMIT_EXCEEDED",AGENT_CANCELLED:"AGENT_CANCELLED",EXTERNAL_HANDOFF_DISABLED:"EXTERNAL_HANDOFF_DISABLED",EXTERNAL_HANDOFF_UNAVAILABLE:"EXTERNAL_HANDOFF_UNAVAILABLE",HANDOFF_VALIDATION_FAILED:"HANDOFF_VALIDATION_FAILED",HANDOFF_SOURCE_STALE:"HANDOFF_SOURCE_STALE",HANDOFF_NOT_FOUND:"HANDOFF_NOT_FOUND",HANDOFF_EXPIRED:"HANDOFF_EXPIRED",HANDOFF_CURSOR_INVALID:"HANDOFF_CURSOR_INVALID",HANDOFF_RESPONSE_TOO_LARGE:"HANDOFF_RESPONSE_TOO_LARGE",BRIDGE_UNAUTHORIZED:"BRIDGE_UNAUTHORIZED",BRIDGE_PROTOCOL_MISMATCH:"BRIDGE_PROTOCOL_MISMATCH",BRIDGE_BUSY:"BRIDGE_BUSY",EXTERNAL_AGENT_BUSY:"EXTERNAL_AGENT_BUSY",ACTIVE_ADAPTER_CONFLICT:"ACTIVE_ADAPTER_CONFLICT",ACTIVE_ADAPTER_LEASE_INVALID:"ACTIVE_ADAPTER_LEASE_INVALID",ACTIVE_DISPATCH_INVALID:"ACTIVE_DISPATCH_INVALID",SESSION_NOT_FOUND:"SESSION_NOT_FOUND",SESSION_AMBIGUOUS:"SESSION_AMBIGUOUS",SESSION_CLOSED:"SESSION_CLOSED",WORKTREE_DIRTY:"WORKTREE_DIRTY",WORKTREE_NOT_REPOSITORY:"WORKTREE_NOT_REPOSITORY",WORKTREE_OPERATION_IN_PROGRESS:"WORKTREE_OPERATION_IN_PROGRESS",WORKTREE_CONFLICTED:"WORKTREE_CONFLICTED",WORKTREE_LOCAL_CHANGES_TOO_LARGE:"WORKTREE_LOCAL_CHANGES_TOO_LARGE",WORKTREE_UNTRACKED_UNSUPPORTED:"WORKTREE_UNTRACKED_UNSUPPORTED",WORKTREE_LOCAL_CHANGES_UNSUPPORTED:"WORKTREE_LOCAL_CHANGES_UNSUPPORTED",TOOL_DENIED:"TOOL_DENIED",TOOL_INPUT_INVALID:"TOOL_INPUT_INVALID",TOOL_ARGUMENTS_INVALID:"TOOL_ARGUMENTS_INVALID",TOOL_CALL_ID_CONFLICT:"TOOL_CALL_ID_CONFLICT",TOOL_PATH_DENIED:"TOOL_PATH_DENIED",PATCH_REJECTED:"PATCH_REJECTED",VALIDATION_FAILED:"VALIDATION_FAILED",APPLY_CONFLICT:"APPLY_CONFLICT",INTERNAL_ERROR:"INTERNAL_ERROR"},Io=Object.freeze(Object.values(l));var Po=/data:[^\s"'<>]*;base64,[a-z0-9+/_=-]+/giu,Do=/blob:[^\s"'<>]+/giu,ko=/\bbearer\s+[a-z0-9._~+/-]+=*/giu,Mo=/\b(https?:\/\/)[^/\s:@]+:[^/\s@]+@/giu,Fo=/\b(authorization|cookie|set-cookie|api[-_]?key|(?:access[-_]?|refresh[-_]?|auth[-_]?)?token|secret|password|default[-_]?value|value)\b(\s*[:=]\s*)("(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|`(?:\\.|[^`\\\r\n])*`|[^\s,;"'<>]+)/giu,Ho=new Set(["authorization","cookie","defaultvalue","password","setcookie","value"]),$o=500;function Bo(e){return e.toLowerCase().replaceAll(/[-_:]/gu,"")}function Uo(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Ft(e){let t=Bo(e);return Ho.has(t)||t.includes("apikey")||t.includes("authorization")||t.includes("secret")||t.includes("token")}function V(e){return e.replace(Po,"[redacted inline data]").replace(Do,"[redacted blob URL]").replace(ko,"Bearer [redacted]").replace(Mo,"$1[redacted]@").replace(Fo,(t,o,n,i)=>{let c=i.at(0),r=c==='"'||c==="'"||c==="`";return`${o}${n}${r?c:""}[redacted]${r?c:""}`})}function zo(e){e.username="",e.password="";for(let[t,o]of e.searchParams)Ft(t)?e.searchParams.set(t,"[redacted]"):e.searchParams.set(t,V(o));return/token|secret|authorization|api[-_]?key/iu.test(e.hash)&&(e.hash="#[redacted]"),e.toString()}function ft(e,t){let o=e.trim();if(/^(?:blob|data|javascript):/iu.test(o))return"[redacted URL]";let n=V(o);try{let i=new URL(n,t),c=zo(i),r=new URL(t);return!/^[a-z][a-z\d+.-]*:/iu.test(n)&&i.origin===r.origin?`${i.pathname}${i.search}${i.hash}`:c}catch{return Uo(n,$o)}}var X="/__spotpatch/v1",Ht="X-SpotPatch-Token",nt=Object.freeze({bootstrap:`${X}/bootstrap`,sourceContext:`${X}/source-context`,openEditor:`${X}/open-editor`,dataFlowComponentReport:`${X}/data-flow/component-report`,dataFlowPageReport:`${X}/data-flow/page-report`,agentCapability:`${X}/agent/capability`,agentWorkspaceHealth:`${X}/agent/workspace-health`,agentJobs:`${X}/agent/jobs`,externalHandoffCapability:`${X}/external-handoff/capability`,externalHandoffPublish:`${X}/external-handoff/publish`,externalHandoffStatus:`${X}/external-handoff/status`,externalHandoffResolveDelivery:`${X}/external-handoff/resolve-delivery`,externalAgentControlStatus:`${X}/external-agent/control/status`,externalAgentControlConnect:`${X}/external-agent/control/connect`,externalAgentControlDisconnect:`${X}/external-agent/control/disconnect`,externalAgentControlCancel:`${X}/external-agent/control/cancel`,externalAgentEvents:`${X}/external-agent/events`,externalAgentResult:`${X}/external-agent/result`});function St(e,t){return`${nt.agentJobs}/${encodeURIComponent(e)}/${t}`}var jo=Object.freeze(["review","auto","trusted-auto"]),Vo=Object.freeze({maxTurns:20,maxToolCalls:80,maxChangedFiles:20,maxDiffBytes:512e3,maxReadBytesPerFile:256e3,maxToolOutputCharacters:4e4,maxProviderResponseBytes:2e6,providerConnectTimeoutMs:15e3,providerFirstByteTimeoutMs:3e4,providerIdleTimeoutMs:6e4,checkTimeoutMs:12e4,jobTimeoutMs:6e5}),nn=Object.freeze(["queued","preparing","running","validating","awaiting-review","applying","applied","completed","cancelling","cancelled","reverting","reverted","failed"]),on=Object.freeze(["unknown","probing","agent-ready","prompt-only","unavailable"]),Go=Object.freeze(["ready","consent-required","blocked"]),Wo=Object.freeze({maxUntrackedFiles:1e3,maxUntrackedBytes:20*1024*1024}),rn=Object.freeze(["added","modified","deleted"]),an=Object.freeze(["passed","failed","cancelled","timed-out"]);var sn="data-spotpatch-source",qo=/^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)$/;function cn(e){if(e===null)return;let t=qo.exec(e);if(t===null)return;let o=t[1],n=Number(t[2]),i=Number(t[3]);if(!(o===void 0||!Number.isSafeInteger(n)||!Number.isSafeInteger(i)))return Object.freeze({fileId:o,line:n,column:i})}var ln="https://github.com/huanglvjing/spotpatch";function Sn(e,t){return Object.freeze({...e,...e.relativePath===void 0&&t!==void 0?{relativePath:t.relativePath}:{}})}function Ko(e){return Object.freeze({...e,componentStack:Object.freeze([...e.componentStack]),...e.source===void 0?{}:{source:Sn(e.source)}})}function Xo(e){return Object.freeze({...e,rect:Object.freeze({...e.rect})})}function Yo(e){return Object.freeze({...e,classNames:Object.freeze([...e.classNames]),matchedRules:Object.freeze(e.matchedRules.map(t=>Object.freeze({...t}))),computed:Object.freeze({...e.computed}),warnings:Object.freeze([...e.warnings])})}function Zo(e){return Object.freeze({instruction:e.instruction.trim(),...e.page===void 0?{}:{page:Object.freeze({...e.page})},source:Sn(e.source,e.code),react:Ko(e.react),element:Xo(e.element),styles:Yo(e.styles),...e.code===void 0?{}:{code:Object.freeze({...e.code})},warnings:Object.freeze([...e.warnings])})}function An(e){if(e.targets.length<1||e.targets.length>20)throw new RangeError(`SpotPatch annotations require between 1 and ${String(20)} targets.`);let t=e.targets.map(o=>o.instruction.trim());if(t.some(o=>o.length===0||o.length>2e3)||t.reduce((o,n)=>o+n.length,0)>4e3)throw new RangeError("SpotPatch target instructions exceed the allowed bounds.");return Object.freeze({schemaVersion:3,id:e.id,locale:e.locale,page:Object.freeze({...e.page}),targets:Object.freeze(e.targets.map(Zo)),createdAt:e.createdAt})}var Qo=new Set(Object.values(l)),er=new Set(on),tr=new Set(an),nr=new Set(rn),Rn=new Set(nn),or=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,rr=/^[A-Za-z0-9_-]+$/,ar=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;function ot(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _e(e,t){return Object.keys(e).every(o=>t.includes(o))}function he(e,t,o=0){return typeof e=="string"&&e.length>=o&&e.length<=t}function _t(e){return he(e,64,1)&&typeof e=="string"&&or.test(e)}function dn(e){return he(e,128,22)&&typeof e=="string"&&rr.test(e)}function Lt(e){return typeof e=="string"&&ar.test(e)&&Number.isFinite(Date.parse(e))}function mt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Cn(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function xn(e,t){return e===void 0||he(e,t)}function Rt(e){return typeof e=="string"&&Qo.has(e)}function Tn(e){return!ot(e)||!_e(e,["providerProfileId","providerLabel","modelProfileId","modelLabel","protocol","state","authenticated","modelAvailable","toolCalling","toolResultContinuation","streaming","checkedAt","errorCode"])?!1:_t(e.providerProfileId)&&he(e.providerLabel,100)&&_t(e.modelProfileId)&&he(e.modelLabel,100)&&(e.protocol==="responses"||e.protocol==="chat-completions")&&typeof e.state=="string"&&er.has(e.state)&&typeof e.authenticated=="boolean"&&typeof e.modelAvailable=="boolean"&&typeof e.toolCalling=="boolean"&&typeof e.toolResultContinuation=="boolean"&&typeof e.streaming=="boolean"&&(e.checkedAt===void 0||Lt(e.checkedAt))&&(e.errorCode===void 0||Rt(e.errorCode))}function vn(e){if(!ot(e)||!_e(e,["state","checkedAt","changes","canIncludeLocalChanges","errorCode"])||e.state!=="ready"&&e.state!=="consent-required"&&e.state!=="blocked"||!Lt(e.checkedAt)||typeof e.canIncludeLocalChanges!="boolean"||e.errorCode!==void 0&&!Rt(e.errorCode)||!ot(e.changes)||!_e(e.changes,["staged","unstaged","untracked","conflicted","total"]))return!1;let t=e.changes,{staged:o,unstaged:n,untracked:i,conflicted:c,total:r}=t;return!mt(o)||!mt(n)||!mt(i)||!mt(c)||!mt(r)||r<o||r<n||r<i||r<c||r>o+n+i?!1:e.state==="ready"?r===0&&!e.canIncludeLocalChanges&&e.errorCode===void 0:e.state==="consent-required"?r>0&&c===0&&e.canIncludeLocalChanges&&e.errorCode===void 0:!e.canIncludeLocalChanges&&e.errorCode!==void 0}function Bt(e){return!ot(e)||!_e(e,["jobId","status","providerProfileId","providerLabel","modelProfileId","modelLabel","phaseMessage","createdAt","updatedAt","canCancel","canApply","canRevert","errorCode"])?!1:dn(e.jobId)&&typeof e.status=="string"&&Rn.has(e.status)&&_t(e.providerProfileId)&&he(e.providerLabel,100)&&_t(e.modelProfileId)&&he(e.modelLabel,100)&&he(e.phaseMessage,1024)&&Lt(e.createdAt)&&Lt(e.updatedAt)&&typeof e.canCancel=="boolean"&&typeof e.canApply=="boolean"&&typeof e.canRevert=="boolean"&&(e.errorCode===void 0||Rt(e.errorCode))}function ir(e){return ot(e)&&_e(e,["relativePath","kind","additions","deletions"])&&he(e.relativePath,1024)&&typeof e.kind=="string"&&nr.has(e.kind)&&mt(e.additions)&&mt(e.deletions)}function wn(e){return ot(e)&&_e(e,["checkId","label","status","durationMs","output"])&&_t(e.checkId)&&he(e.label,100)&&typeof e.status=="string"&&tr.has(e.status)&&mt(e.durationMs)&&he(e.output,8e4)}function sr(e){return ot(e)&&_e(e,["jobId","summary","diff","files","checks"])&&dn(e.jobId)&&he(e.summary,8e4)&&he(e.diff,1e6)&&Array.isArray(e.files)&&e.files.length<=100&&e.files.every(ir)&&Array.isArray(e.checks)&&e.checks.length<=100&&e.checks.every(wn)}function On(e){return ot(e)&&_e(e,["snapshot","result"])&&Bt(e.snapshot)&&(e.result===void 0||sr(e.result)&&e.result.jobId===e.snapshot.jobId)}function cr(e){return ot(e)&&_e(e,["schemaVersion","sequence","jobId","status","timestamp","type","data"])&&e.schemaVersion===2&&Cn(e.sequence)&&dn(e.jobId)&&typeof e.status=="string"&&Rn.has(e.status)&&Lt(e.timestamp)&&typeof e.type=="string"&&ot(e.data)}function _n(e){if(!cr(e))return!1;let t=e.data;switch(e.type){case"snapshot":return _e(t,["snapshot"])&&Bt(t.snapshot)&&t.snapshot.jobId===e.jobId&&t.snapshot.status===e.status;case"phase":return _e(t,["message"])&&he(t.message,1024);case"tool":return _e(t,["turn","toolCallId","toolName","state","relativePath","checkLabel"])&&Cn(t.turn)&&he(t.toolCallId,256)&&he(t.toolName,100)&&(t.state==="started"||t.state==="succeeded"||t.state==="failed")&&xn(t.relativePath,1024)&&xn(t.checkLabel,100);case"check":return _e(t,["result"])&&wn(t.result);case"result-ready":return _e(t,["hasResult"])&&t.hasResult===!0;case"error":return _e(t,["code","message"])&&Rt(t.code)&&he(t.message,1024);default:return!1}}var In=2e6,Ln=1e5,lr=4e6,D=class extends Error{code;constructor(t){super("SpotPatch local API request failed."),this.name="RuntimeApiError",this.code=t}};function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dr(e){if(!(!Le(e)||e.ok!==!1||!Le(e.error)))return Rt(e.error.code)?e.error.code:void 0}function pr(e){if(!Le(e)||e.ok!==!0||!("data"in e))throw new D;return e.data}function ur(e){return Le(e)&&typeof e.relativePath=="string"&&(e.language==="tsx"||e.language==="jsx")&&typeof e.startLine=="number"&&typeof e.endLine=="number"&&typeof e.excerpt=="string"&&(e.boundary==="component"||e.boundary==="nearby-lines")}function Pn(e){if(!(!Le(e)&&!Array.isArray(e))&&!Object.isFrozen(e)){for(let t of Object.values(e))Pn(t);Object.freeze(e)}}function At(e){return Pn(e),e}async function gr(e,t){let o=Number(e.headers.get("content-length"));if(Number.isFinite(o)&&o>t)throw new D;if(e.body===null)throw new D;let n=e.body.getReader(),i=new TextDecoder("utf-8",{fatal:!0}),c=0,r="";try{for(;;){let u=await n.read();if(u.done)return r+=i.decode(),r;if(c+=u.value.byteLength,c>t)throw await n.cancel(),new D;r+=i.decode(u.value,{stream:!0})}}catch(u){throw u instanceof D?u:new D}finally{n.releaseLock()}}function Dn(e){try{return JSON.parse(e)}catch{throw new D}}async function Nn(e,t=In){let o=Dn(await gr(e,t));if(!e.ok)throw new D(dr(o));return pr(o)}function zt(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function fr(e){return Le(e)&&typeof e.complete=="boolean"&&typeof e.visitedModules=="number"&&typeof e.visitedCallsites=="number"&&typeof e.frontierCount=="number"}function mr(e){return Le(e)&&typeof e.enabled=="boolean"&&(e.staticAnalysis==="available"||e.staticAnalysis==="partial"||e.staticAnalysis==="unavailable")&&e.runtimeObservation==="dispatch-only"&&e.responseShape==="consumed-fields-only"&&e.aiAssistance==="disabled"&&Array.isArray(e.reasons)}function hr(e){return Le(e)&&typeof e.id=="string"&&typeof e.kind=="string"&&typeof e.direction=="string"&&typeof e.execution=="string"&&typeof e.proof=="string"&&typeof e.association=="string"&&Array.isArray(e.parameters)&&Le(e.response)&&zt(e.response.consumedFields)&&zt(e.evidenceIds)&&zt(e.observationIds)}function kn(e){return Le(e)&&e.schemaVersion===1&&typeof e.reportId=="string"&&Le(e.baseline)&&typeof e.baseline.registryEpoch=="string"&&typeof e.baseline.analyzerVersion=="string"&&zt(e.baseline.analyzedSourceVersions)&&mr(e.capability)&&Array.isArray(e.dependencies)&&e.dependencies.every(hr)&&Array.isArray(e.evidence)&&Array.isArray(e.diagnostics)&&fr(e.completeness)}function br(e){return kn(e)&&Le(e)&&Le(e.component)&&Le(e.component.source)&&typeof e.component.source.fileId=="string"&&typeof e.component.source.sourceVersion=="string"}function yr(e){return kn(e)}function Er(e,t){if(!Tn(e)||e.providerProfileId!==t.providerProfileId||e.modelProfileId!==t.modelProfileId)throw new D;return At(e)}function Ut(e,t){if(!Bt(e)||t?.jobId!==void 0&&e.jobId!==t.jobId||t?.providerProfileId!==void 0&&e.providerProfileId!==t.providerProfileId||t?.modelProfileId!==void 0&&e.modelProfileId!==t.modelProfileId)throw new D;return At(e)}function Sr(e,t){if(!On(e)||e.snapshot.jobId!==t)throw new D;return At(e)}function Ar(e){if(!_n(e))throw new D;return At(e)}function xr(e){return{...e,annotation:{...e.annotation,targets:e.annotation.targets.map(t=>({instruction:t.instruction,source:t.source,react:t.react,element:t.element,styles:t.styles,warnings:t.warnings}))}}}function Mn(e){return e instanceof D?e.code:void 0}function Fn(e){let t=new Set;function o(){for(let r of t)r.abort();t.clear()}async function n(r,u,R,s=In){let A=new AbortController;t.add(A);try{let z=await e.fetch(r,{method:u,headers:{...R===void 0?{}:{"Content-Type":"application/json"},[Ht]:e.sessionToken},...R===void 0?{}:{body:JSON.stringify(R)},signal:A.signal});return await Nn(z,s)}finally{t.delete(A)}}async function i(r,u){let R=new AbortController;t.add(R);try{let s=await e.fetch(St(r,"events"),{method:"POST",headers:{"Content-Type":"application/json",[Ht]:e.sessionToken},body:JSON.stringify({}),signal:R.signal});if(!s.ok){await Nn(s);return}if(s.body===null)throw new D;let A=s.body.getReader(),z=new TextDecoder("utf-8",{fatal:!0}),m="",L=0,M=0,N=b=>{if(b.trim().length===0)return;if(new TextEncoder().encode(b).byteLength>Ln)throw new D;let T=Ar(Dn(b));if(T.jobId!==r||T.sequence<=M)throw new D;M=T.sequence,u(T)};try{for(;;){let b=await A.read();if(b.done){m+=z.decode(),N(m);return}if(L+=b.value.byteLength,L>lr)throw await A.cancel(),new D;m+=z.decode(b.value,{stream:!0});let T=m.split(`
|
|
2
|
-
`);if(
|
|
3
|
-
`).length}function
|
|
4
|
-
`),e.maxCharacters),...
|
|
1
|
+
import{createReact18Adapter as Qi}from"@spotpatch/react-adapter";var p={INVALID_REQUEST:"INVALID_REQUEST",INVALID_TOKEN:"INVALID_TOKEN",ORIGIN_NOT_ALLOWED:"ORIGIN_NOT_ALLOWED",SOURCE_NOT_FOUND:"SOURCE_NOT_FOUND",SOURCE_OUTSIDE_ROOT:"SOURCE_OUTSIDE_ROOT",SOURCE_TOO_LARGE:"SOURCE_TOO_LARGE",EDITOR_OPEN_FAILED:"EDITOR_OPEN_FAILED",DATA_FLOW_DISABLED:"DATA_FLOW_DISABLED",DATA_FLOW_SOURCE_STALE:"DATA_FLOW_SOURCE_STALE",DATA_FLOW_ANALYSIS_CANCELLED:"DATA_FLOW_ANALYSIS_CANCELLED",AI_DISABLED:"AI_DISABLED",PROVIDER_NOT_CONFIGURED:"PROVIDER_NOT_CONFIGURED",PROVIDER_AUTH_FAILED:"PROVIDER_AUTH_FAILED",PROVIDER_PROTOCOL_UNSUPPORTED:"PROVIDER_PROTOCOL_UNSUPPORTED",MODEL_NOT_ALLOWED:"MODEL_NOT_ALLOWED",MODEL_TOOL_CALL_UNSUPPORTED:"MODEL_TOOL_CALL_UNSUPPORTED",PROVIDER_RATE_LIMITED:"PROVIDER_RATE_LIMITED",AGENT_BUSY:"AGENT_BUSY",AGENT_LIMIT_EXCEEDED:"AGENT_LIMIT_EXCEEDED",AGENT_CANCELLED:"AGENT_CANCELLED",EXTERNAL_HANDOFF_DISABLED:"EXTERNAL_HANDOFF_DISABLED",EXTERNAL_HANDOFF_UNAVAILABLE:"EXTERNAL_HANDOFF_UNAVAILABLE",HANDOFF_VALIDATION_FAILED:"HANDOFF_VALIDATION_FAILED",HANDOFF_SOURCE_STALE:"HANDOFF_SOURCE_STALE",HANDOFF_NOT_FOUND:"HANDOFF_NOT_FOUND",HANDOFF_EXPIRED:"HANDOFF_EXPIRED",HANDOFF_CURSOR_INVALID:"HANDOFF_CURSOR_INVALID",HANDOFF_RESPONSE_TOO_LARGE:"HANDOFF_RESPONSE_TOO_LARGE",BRIDGE_UNAUTHORIZED:"BRIDGE_UNAUTHORIZED",BRIDGE_PROTOCOL_MISMATCH:"BRIDGE_PROTOCOL_MISMATCH",BRIDGE_BUSY:"BRIDGE_BUSY",EXTERNAL_AGENT_BUSY:"EXTERNAL_AGENT_BUSY",ACTIVE_ADAPTER_CONFLICT:"ACTIVE_ADAPTER_CONFLICT",ACTIVE_ADAPTER_LEASE_INVALID:"ACTIVE_ADAPTER_LEASE_INVALID",ACTIVE_DISPATCH_INVALID:"ACTIVE_DISPATCH_INVALID",SESSION_NOT_FOUND:"SESSION_NOT_FOUND",SESSION_AMBIGUOUS:"SESSION_AMBIGUOUS",SESSION_CLOSED:"SESSION_CLOSED",WORKTREE_DIRTY:"WORKTREE_DIRTY",WORKTREE_NOT_REPOSITORY:"WORKTREE_NOT_REPOSITORY",WORKTREE_OPERATION_IN_PROGRESS:"WORKTREE_OPERATION_IN_PROGRESS",WORKTREE_CONFLICTED:"WORKTREE_CONFLICTED",WORKTREE_LOCAL_CHANGES_TOO_LARGE:"WORKTREE_LOCAL_CHANGES_TOO_LARGE",WORKTREE_UNTRACKED_UNSUPPORTED:"WORKTREE_UNTRACKED_UNSUPPORTED",WORKTREE_LOCAL_CHANGES_UNSUPPORTED:"WORKTREE_LOCAL_CHANGES_UNSUPPORTED",TOOL_DENIED:"TOOL_DENIED",TOOL_INPUT_INVALID:"TOOL_INPUT_INVALID",TOOL_ARGUMENTS_INVALID:"TOOL_ARGUMENTS_INVALID",TOOL_CALL_ID_CONFLICT:"TOOL_CALL_ID_CONFLICT",TOOL_PATH_DENIED:"TOOL_PATH_DENIED",PATCH_REJECTED:"PATCH_REJECTED",VALIDATION_FAILED:"VALIDATION_FAILED",APPLY_CONFLICT:"APPLY_CONFLICT",INTERNAL_ERROR:"INTERNAL_ERROR"},Ir=Object.freeze(Object.values(p));var Nr=/data:[^\s"'<>]*;base64,[a-z0-9+/_=-]+/giu,kr=/blob:[^\s"'<>]+/giu,Dr=/\bbearer\s+[a-z0-9._~+/-]+=*/giu,Fr=/\b(https?:\/\/)[^/\s:@]+:[^/\s@]+@/giu,Mr=/\b(authorization|cookie|set-cookie|api[-_]?key|(?:access[-_]?|refresh[-_]?|auth[-_]?)?token|secret|password|default[-_]?value|value)\b(\s*[:=]\s*)("(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'|`(?:\\.|[^`\\\r\n])*`|[^\s,;"'<>]+)/giu,Hr=new Set(["authorization","cookie","defaultvalue","password","setcookie","value"]),$r=500;function Br(e){return e.toLowerCase().replaceAll(/[-_:]/gu,"")}function zr(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Zt(e){let t=Br(e);return Hr.has(t)||t.includes("apikey")||t.includes("authorization")||t.includes("secret")||t.includes("token")}function ee(e){return e.replace(Nr,"[redacted inline data]").replace(kr,"[redacted blob URL]").replace(Dr,"Bearer [redacted]").replace(Fr,"$1[redacted]@").replace(Mr,(t,o,n,s)=>{let d=s.at(0),i=d==='"'||d==="'"||d==="`";return`${o}${n}${i?d:""}[redacted]${i?d:""}`})}function jr(e){e.username="",e.password="";for(let[t,o]of e.searchParams)Zt(t)?e.searchParams.set(t,"[redacted]"):e.searchParams.set(t,ee(o));return/token|secret|authorization|api[-_]?key/iu.test(e.hash)&&(e.hash="#[redacted]"),e.toString()}function Tt(e,t){let o=e.trim();if(/^(?:blob|data|javascript):/iu.test(o))return"[redacted URL]";let n=ee(o);try{let s=new URL(n,t),d=jr(s),i=new URL(t);return!/^[a-z][a-z\d+.-]*:/iu.test(n)&&s.origin===i.origin?`${s.pathname}${s.search}${s.hash}`:d}catch{return zr(n,$r)}}var ce="/__spotpatch/v1",Qt="X-SpotPatch-Token",gt=Object.freeze({bootstrap:`${ce}/bootstrap`,sourceContext:`${ce}/source-context`,openEditor:`${ce}/open-editor`,dataFlowComponentReport:`${ce}/data-flow/component-report`,dataFlowPageReport:`${ce}/data-flow/page-report`,agentCapability:`${ce}/agent/capability`,agentWorkspaceHealth:`${ce}/agent/workspace-health`,agentJobs:`${ce}/agent/jobs`,externalHandoffCapability:`${ce}/external-handoff/capability`,externalHandoffPublish:`${ce}/external-handoff/publish`,externalHandoffStatus:`${ce}/external-handoff/status`,externalHandoffResolveDelivery:`${ce}/external-handoff/resolve-delivery`,externalAgentControlStatus:`${ce}/external-agent/control/status`,externalAgentControlConnect:`${ce}/external-agent/control/connect`,externalAgentControlDisconnect:`${ce}/external-agent/control/disconnect`,externalAgentControlCancel:`${ce}/external-agent/control/cancel`,externalAgentEvents:`${ce}/external-agent/events`,externalAgentResult:`${ce}/external-agent/result`});function It(e,t){return`${gt.agentJobs}/${encodeURIComponent(e)}/${t}`}var Ur=Object.freeze(["review","auto","trusted-auto"]),Vr=Object.freeze({maxTurns:20,maxToolCalls:80,maxChangedFiles:20,maxDiffBytes:512e3,maxReadBytesPerFile:256e3,maxToolOutputCharacters:4e4,maxProviderResponseBytes:2e6,providerConnectTimeoutMs:15e3,providerFirstByteTimeoutMs:3e4,providerIdleTimeoutMs:6e4,checkTimeoutMs:12e4,jobTimeoutMs:6e5}),Sn=Object.freeze(["queued","preparing","running","validating","awaiting-review","applying","applied","completed","cancelling","cancelled","reverting","reverted","failed"]),En=Object.freeze(["unknown","probing","agent-ready","prompt-only","unavailable"]),Wr=Object.freeze(["ready","consent-required","blocked"]),Gr=Object.freeze({maxUntrackedFiles:1e3,maxUntrackedBytes:20*1024*1024}),An=Object.freeze(["added","modified","deleted"]),xn=Object.freeze(["passed","failed","cancelled","timed-out"]);var Rn="data-spotpatch-source",qr=/^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)$/;function Cn(e){if(e===null)return;let t=qr.exec(e);if(t===null)return;let o=t[1],n=Number(t[2]),s=Number(t[3]);if(!(o===void 0||!Number.isSafeInteger(n)||!Number.isSafeInteger(s)))return Object.freeze({fileId:o,line:n,column:s})}var Tn="https://github.com/huanglvjing/spotpatch";function oo(e,t){return Object.freeze({...e,...e.relativePath===void 0&&t!==void 0?{relativePath:t.relativePath}:{}})}function Jr(e){return Object.freeze({...e,componentStack:Object.freeze([...e.componentStack]),...e.source===void 0?{}:{source:oo(e.source)}})}function Xr(e){return Object.freeze({...e,rect:Object.freeze({...e.rect})})}function Yr(e){return Object.freeze({...e,classNames:Object.freeze([...e.classNames]),matchedRules:Object.freeze(e.matchedRules.map(t=>Object.freeze({...t}))),computed:Object.freeze({...e.computed}),warnings:Object.freeze([...e.warnings])})}function Zr(e){return Object.freeze({instruction:e.instruction.trim(),...e.page===void 0?{}:{page:Object.freeze({...e.page})},source:oo(e.source,e.code),react:Jr(e.react),element:Xr(e.element),styles:Yr(e.styles),...e.code===void 0?{}:{code:Object.freeze({...e.code})},warnings:Object.freeze([...e.warnings])})}function ro(e){if(e.targets.length<1||e.targets.length>20)throw new RangeError(`SpotPatch annotations require between 1 and ${String(20)} targets.`);let t=e.targets.map(o=>o.instruction.trim());if(t.some(o=>o.length===0||o.length>2e3)||t.reduce((o,n)=>o+n.length,0)>4e3)throw new RangeError("SpotPatch target instructions exceed the allowed bounds.");return Object.freeze({schemaVersion:3,id:e.id,locale:e.locale,page:Object.freeze({...e.page}),targets:Object.freeze(e.targets.map(Zr)),createdAt:e.createdAt})}var Qr=new Set(Object.values(p)),ea=new Set(En),ta=new Set(xn),na=new Set(An),io=new Set(Sn),oa=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,ra=/^[A-Za-z0-9_-]+$/,aa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;function ft(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fe(e,t){return Object.keys(e).every(o=>t.includes(o))}function Se(e,t,o=0){return typeof e=="string"&&e.length>=o&&e.length<=t}function zt(e){return Se(e,64,1)&&typeof e=="string"&&oa.test(e)}function vn(e){return Se(e,128,22)&&typeof e=="string"&&ra.test(e)}function jt(e){return typeof e=="string"&&aa.test(e)&&Number.isFinite(Date.parse(e))}function vt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function so(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function ao(e,t){return e===void 0||Se(e,t)}function Ft(e){return typeof e=="string"&&Qr.has(e)}function co(e){return!ft(e)||!Fe(e,["providerProfileId","providerLabel","modelProfileId","modelLabel","protocol","state","authenticated","modelAvailable","toolCalling","toolResultContinuation","streaming","checkedAt","errorCode"])?!1:zt(e.providerProfileId)&&Se(e.providerLabel,100)&&zt(e.modelProfileId)&&Se(e.modelLabel,100)&&(e.protocol==="responses"||e.protocol==="chat-completions")&&typeof e.state=="string"&&ea.has(e.state)&&typeof e.authenticated=="boolean"&&typeof e.modelAvailable=="boolean"&&typeof e.toolCalling=="boolean"&&typeof e.toolResultContinuation=="boolean"&&typeof e.streaming=="boolean"&&(e.checkedAt===void 0||jt(e.checkedAt))&&(e.errorCode===void 0||Ft(e.errorCode))}function lo(e){if(!ft(e)||!Fe(e,["state","checkedAt","changes","canIncludeLocalChanges","errorCode"])||e.state!=="ready"&&e.state!=="consent-required"&&e.state!=="blocked"||!jt(e.checkedAt)||typeof e.canIncludeLocalChanges!="boolean"||e.errorCode!==void 0&&!Ft(e.errorCode)||!ft(e.changes)||!Fe(e.changes,["staged","unstaged","untracked","conflicted","total"]))return!1;let t=e.changes,{staged:o,unstaged:n,untracked:s,conflicted:d,total:i}=t;return!vt(o)||!vt(n)||!vt(s)||!vt(d)||!vt(i)||i<o||i<n||i<s||i<d||i>o+n+s?!1:e.state==="ready"?i===0&&!e.canIncludeLocalChanges&&e.errorCode===void 0:e.state==="consent-required"?i>0&&d===0&&e.canIncludeLocalChanges&&e.errorCode===void 0:!e.canIncludeLocalChanges&&e.errorCode!==void 0}function tn(e){return!ft(e)||!Fe(e,["jobId","status","providerProfileId","providerLabel","modelProfileId","modelLabel","phaseMessage","createdAt","updatedAt","canCancel","canApply","canRevert","errorCode"])?!1:vn(e.jobId)&&typeof e.status=="string"&&io.has(e.status)&&zt(e.providerProfileId)&&Se(e.providerLabel,100)&&zt(e.modelProfileId)&&Se(e.modelLabel,100)&&Se(e.phaseMessage,1024)&&jt(e.createdAt)&&jt(e.updatedAt)&&typeof e.canCancel=="boolean"&&typeof e.canApply=="boolean"&&typeof e.canRevert=="boolean"&&(e.errorCode===void 0||Ft(e.errorCode))}function ia(e){return ft(e)&&Fe(e,["relativePath","kind","additions","deletions"])&&Se(e.relativePath,1024)&&typeof e.kind=="string"&&na.has(e.kind)&&vt(e.additions)&&vt(e.deletions)}function po(e){return ft(e)&&Fe(e,["checkId","label","status","durationMs","output"])&&zt(e.checkId)&&Se(e.label,100)&&typeof e.status=="string"&&ta.has(e.status)&&vt(e.durationMs)&&Se(e.output,8e4)}function sa(e){return ft(e)&&Fe(e,["jobId","summary","diff","files","checks"])&&vn(e.jobId)&&Se(e.summary,8e4)&&Se(e.diff,1e6)&&Array.isArray(e.files)&&e.files.length<=100&&e.files.every(ia)&&Array.isArray(e.checks)&&e.checks.length<=100&&e.checks.every(po)}function uo(e){return ft(e)&&Fe(e,["snapshot","result"])&&tn(e.snapshot)&&(e.result===void 0||sa(e.result)&&e.result.jobId===e.snapshot.jobId)}function ca(e){return ft(e)&&Fe(e,["schemaVersion","sequence","jobId","status","timestamp","type","data"])&&e.schemaVersion===2&&so(e.sequence)&&vn(e.jobId)&&typeof e.status=="string"&&io.has(e.status)&&jt(e.timestamp)&&typeof e.type=="string"&&ft(e.data)}function go(e){if(!ca(e))return!1;let t=e.data;switch(e.type){case"snapshot":return Fe(t,["snapshot"])&&tn(t.snapshot)&&t.snapshot.jobId===e.jobId&&t.snapshot.status===e.status;case"phase":return Fe(t,["message"])&&Se(t.message,1024);case"tool":return Fe(t,["turn","toolCallId","toolName","state","relativePath","checkLabel"])&&so(t.turn)&&Se(t.toolCallId,256)&&Se(t.toolName,100)&&(t.state==="started"||t.state==="succeeded"||t.state==="failed")&&ao(t.relativePath,1024)&&ao(t.checkLabel,100);case"check":return Fe(t,["result"])&&po(t.result);case"result-ready":return Fe(t,["hasResult"])&&t.hasResult===!0;case"error":return Fe(t,["code","message"])&&Ft(t.code)&&Se(t.message,1024);default:return!1}}var ho=2e6,fo=1e5,da=4e6,q=class extends Error{code;constructor(t){super("SpotPatch local API request failed."),this.name="RuntimeApiError",this.code=t}};function Me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function la(e){if(!(!Me(e)||e.ok!==!1||!Me(e.error)))return Ft(e.error.code)?e.error.code:void 0}function pa(e){if(!Me(e)||e.ok!==!0||!("data"in e))throw new q;return e.data}function ua(e){return Me(e)&&typeof e.relativePath=="string"&&(e.language==="tsx"||e.language==="jsx")&&typeof e.startLine=="number"&&typeof e.endLine=="number"&&typeof e.excerpt=="string"&&(e.boundary==="component"||e.boundary==="nearby-lines")}function yo(e){if(!(!Me(e)&&!Array.isArray(e))&&!Object.isFrozen(e)){for(let t of Object.values(e))yo(t);Object.freeze(e)}}function Nt(e){return yo(e),e}async function ga(e,t){let o=Number(e.headers.get("content-length"));if(Number.isFinite(o)&&o>t)throw new q;if(e.body===null)throw new q;let n=e.body.getReader(),s=new TextDecoder("utf-8",{fatal:!0}),d=0,i="";try{for(;;){let l=await n.read();if(l.done)return i+=s.decode(),i;if(d+=l.value.byteLength,d>t)throw await n.cancel(),new q;i+=s.decode(l.value,{stream:!0})}}catch(l){throw l instanceof q?l:new q}finally{n.releaseLock()}}function bo(e){try{return JSON.parse(e)}catch{throw new q}}async function mo(e,t=ho){let o=bo(await ga(e,t));if(!e.ok)throw new q(la(o));return pa(o)}function on(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function fa(e){return Me(e)&&typeof e.complete=="boolean"&&typeof e.visitedModules=="number"&&typeof e.visitedCallsites=="number"&&typeof e.frontierCount=="number"}function ma(e){return Me(e)&&typeof e.enabled=="boolean"&&(e.staticAnalysis==="available"||e.staticAnalysis==="partial"||e.staticAnalysis==="unavailable")&&e.runtimeObservation==="dispatch-only"&&e.responseShape==="consumed-fields-only"&&e.aiAssistance==="disabled"&&Array.isArray(e.reasons)}function ha(e){return Me(e)&&typeof e.id=="string"&&typeof e.kind=="string"&&typeof e.direction=="string"&&typeof e.execution=="string"&&typeof e.proof=="string"&&typeof e.association=="string"&&Array.isArray(e.parameters)&&Me(e.response)&&on(e.response.consumedFields)&&on(e.evidenceIds)&&on(e.observationIds)}function So(e){return Me(e)&&e.schemaVersion===1&&typeof e.reportId=="string"&&Me(e.baseline)&&typeof e.baseline.registryEpoch=="string"&&typeof e.baseline.analyzerVersion=="string"&&on(e.baseline.analyzedSourceVersions)&&ma(e.capability)&&Array.isArray(e.dependencies)&&e.dependencies.every(ha)&&Array.isArray(e.evidence)&&Array.isArray(e.diagnostics)&&fa(e.completeness)}function ya(e){return So(e)&&Me(e)&&Me(e.component)&&Me(e.component.source)&&typeof e.component.source.fileId=="string"&&typeof e.component.source.sourceVersion=="string"}function ba(e){return So(e)}function Sa(e,t){if(!co(e)||e.providerProfileId!==t.providerProfileId||e.modelProfileId!==t.modelProfileId)throw new q;return Nt(e)}function nn(e,t){if(!tn(e)||t?.jobId!==void 0&&e.jobId!==t.jobId||t?.providerProfileId!==void 0&&e.providerProfileId!==t.providerProfileId||t?.modelProfileId!==void 0&&e.modelProfileId!==t.modelProfileId)throw new q;return Nt(e)}function Ea(e,t){if(!uo(e)||e.snapshot.jobId!==t)throw new q;return Nt(e)}function Aa(e){if(!go(e))throw new q;return Nt(e)}function xa(e){return{...e,annotation:{...e.annotation,targets:e.annotation.targets.map(t=>({instruction:t.instruction,source:t.source,react:t.react,element:t.element,styles:t.styles,warnings:t.warnings}))}}}function Eo(e){return e instanceof q?e.code:void 0}function Ao(e){let t=new Set;function o(){for(let i of t)i.abort();t.clear()}async function n(i,l,A,w=ho){let T=new AbortController;t.add(T);try{let N=await e.fetch(i,{method:l,headers:{...A===void 0?{}:{"Content-Type":"application/json"},[Qt]:e.sessionToken},...A===void 0?{}:{body:JSON.stringify(A)},signal:T.signal});return await mo(N,w)}finally{t.delete(T)}}async function s(i,l){let A=new AbortController;t.add(A);try{let w=await e.fetch(It(i,"events"),{method:"POST",headers:{"Content-Type":"application/json",[Qt]:e.sessionToken},body:JSON.stringify({}),signal:A.signal});if(!w.ok){await mo(w);return}if(w.body===null)throw new q;let T=w.body.getReader(),N=new TextDecoder("utf-8",{fatal:!0}),r="",F=0,M=0,I=b=>{if(b.trim().length===0)return;if(new TextEncoder().encode(b).byteLength>fo)throw new q;let x=Aa(bo(b));if(x.jobId!==i||x.sequence<=M)throw new q;M=x.sequence,l(x)};try{for(;;){let b=await T.read();if(b.done){r+=N.decode(),I(r);return}if(F+=b.value.byteLength,F>da)throw await T.cancel(),new q;r+=N.decode(b.value,{stream:!0});let x=r.split(`
|
|
2
|
+
`);if(r=x.pop()??"",new TextEncoder().encode(r).byteLength>fo)throw await T.cancel(),new q;for(let K of x)I(K)}}catch(b){throw b instanceof q||b instanceof DOMException&&b.name==="AbortError"?b:new q}finally{T.releaseLock()}}finally{t.delete(A)}}let d=Object.freeze({});return Object.freeze({cancelPending:o,async sourceContext(i){let l=await n(gt.sourceContext,"POST",i);if(!ua(l))throw new q;return Object.freeze({...l})},async componentDataFlowReport(i){let l=await n(gt.dataFlowComponentReport,"POST",i,e.dataFlowReportMaxBytes);if(!ya(l))throw new q;return Nt(l)},async pageDataFlowReport(i){let l=await n(gt.dataFlowPageReport,"POST",i,e.dataFlowReportMaxBytes);if(!ba(l))throw new q;return Nt(l)},async openEditor(i){let l=await n(gt.openEditor,"POST",i);if(!Me(l)||l.editor!=="auto"&&l.editor!=="vscode"&&l.editor!=="cursor")throw new q;return Object.freeze({editor:l.editor})},async agentCapability(i){return Sa(await n(gt.agentCapability,"POST",i),i)},async agentWorkspaceHealth(){let i=await n(gt.agentWorkspaceHealth,"POST",d);if(!lo(i))throw new q;return Nt(i)},async createAgentJob(i){let l=xa(i);return nn(await n(gt.agentJobs,"POST",l),i)},agentEvents:s,async agentResult(i){return Ea(await n(It(i,"result"),"POST",d),i)},async cancelAgentJob(i){return nn(await n(It(i,"cancel"),"POST",d),{jobId:i})},async applyAgentJob(i){return nn(await n(It(i,"apply"),"POST",d),{jobId:i})},async revertAgentJob(i){return nn(await n(It(i,"revert"),"POST",d),{jobId:i})},dispose(){o()}})}var Ra=500,xo=256;function Ca(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Ta(e){return Zt(e)}function Ro(e,t,o){if(!Ta(e))return e==="href"||e==="src"?Tt(t,o):e==="d"&&t.length>xo?`${t.slice(0,xo)}…`:Ca(ee(t),Ra)}function Ve(e){return ee(e)}var Co=Object.freeze(["display","position","inset","top","right","bottom","left","width","height","min-width","min-height","max-width","max-height","margin","padding","box-sizing","overflow","overflow-x","overflow-y","flex","flex-direction","flex-wrap","align-items","align-content","justify-content","gap","grid-template-columns","grid-template-rows","font-family","font-size","font-weight","line-height","text-align","white-space","color","background-color","border","border-radius","opacity","visibility","z-index","transform"]);var Ut=Object.freeze({cascade:"CSS shorthand and longhand cascade resolution is not available in v1.",cssInJs:"Runtime CSS-in-JS rules may not include original TypeScript source locations.",inaccessibleStylesheet:"A stylesheet could not be inspected because browser security denied access.",selector:"A stylesheet selector could not be evaluated and was skipped.",state:"Dynamic pseudo-class and pseudo-element rules may be unavailable in the current state."});function va(e){return"selectorText"in e&&"style"in e}function wa(e){return"cssRules"in e}function Oa(e){if(typeof e.conditionText=="string"&&e.conditionText.length>0)return e.conditionText;let t=e.cssText.indexOf("{"),o=t<0?"":e.cssText.slice(0,t).trim();return o.length===0?void 0:o}function _a(e,t,o,n,s){return e.join(" ").length+(t?.length??0)+o.reduce((d,i)=>d+i.selector.length+i.declarations.length+(i.source?.length??0)+(i.media?.length??0),0)+Object.entries(n).reduce((d,[i,l])=>d+i.length+l.length,0)+s.join(`
|
|
3
|
+
`).length}function La(e,t){return e.href===null?void 0:Tt(e.href,t)}function To(e,t,o,n,s,d){for(let i of t){if(va(i)){let l=!1;try{l=e.matches(i.selectorText)}catch{d.add(Ut.selector);continue}l&&s.push(Object.freeze({selector:Ve(i.selectorText),declarations:Ve(i.style.cssText),...o===void 0?{}:{source:o},...n.length===0?{}:{media:n.join(" and ")}}));continue}if(wa(i)){let l=Oa(i);To(e,i.cssRules,o,l===void 0?n:[...n,l],s,d)}}}function Pa(e,t){if(t===void 0)return{};let o=t(e),n={};for(let s of Co){let d=Ve(o.getPropertyValue(s).trim());d.length>0&&(n[s]=d)}return n}function vo(e){let t=new Set([Ut.state,Ut.cssInJs,Ut.cascade]),o=[],n=e.readCssRules??(T=>T.cssRules);for(let T of e.document.styleSheets){let N;try{N=n(T)}catch{t.add(Ut.inaccessibleStylesheet);continue}To(e.element,N,La(T,e.document.baseURI),[],o,t)}let s=Array.from(e.element.classList),d=e.element.getAttribute("style"),i=d===null?void 0:Ve(d),l=e.getComputedStyle??e.document.defaultView?.getComputedStyle.bind(e.document.defaultView),A=Object.entries(Pa(e.element,l)),w=Array.from(t);for(;_a(s,i,o,Object.fromEntries(A),w)>e.maxCharacters;){if(A.length>0){A.pop();continue}if(o.length>1){o.shift();continue}break}return Object.freeze({classNames:Object.freeze(s),...i===void 0?{}:{inlineStyle:i},matchedRules:Object.freeze(o),computed:Object.freeze(Object.fromEntries(A)),warnings:Object.freeze(w)})}var wt=Object.freeze({maxDepth:3,maxNodes:30,maxParentDepth:2,maxTextCharacters:200}),Ia=new Set(["alt","autocomplete","checked","class","colspan","contenteditable","d","disabled","download","draggable","for","height","hidden","href","id","max","maxlength","min","minlength","multiple","name","open","pattern","placeholder","readonly","rel","required","role","rowspan","selected","src","step","style","tabindex","target","title","type","width"]),Na=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Oo(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}function ka(e){return Ia.has(e)||e.startsWith("aria-")||e==="data-testid"}function _o(e){let t=e.tagName.toLowerCase(),o=[],n=e.ownerDocument.baseURI;for(let s of e.attributes){let d=s.name.toLowerCase();if(!ka(d))continue;let i=Ro(d,s.value,n);i!==void 0&&o.push(`${d}="${Oo(i)}"`)}return`<${t}${o.length===0?"":` ${o.join(" ")}`}>`}function Lo(e){return ee(e).replaceAll(/\s+/gu," ").trim()}function Po(e,t,o,n){if(o.nodeCount>=wt.maxNodes){o.truncated=!0;return}o.nodeCount+=1;let s=" ".repeat(t),d=e.tagName.toLowerCase();if(n.push(`${s}${_o(e)}`),!Na.has(d)){for(let i of e.childNodes){if(o.nodeCount>=wt.maxNodes){o.truncated=!0;break}if(i.nodeType===3){let l=Lo(i.textContent??"");if(l.length>0){o.nodeCount+=1;let A=l.length<=wt.maxTextCharacters?l:`${l.slice(0,wt.maxTextCharacters)}…`;n.push(`${" ".repeat(t+1)}${Oo(A)}`)}continue}if(i.nodeType===1){if(t>=wt.maxDepth){o.truncated=!0;continue}Po(i,t+1,o,n)}}o.truncated&&t===0&&n.push(" …"),n.push(`${s}</${d}>`)}}function Da(e){let t=[],o=e.parentElement;for(;o!==null&&t.length<wt.maxParentDepth;)t.push(_o(o)),o=o.parentElement;return t}function Fa(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function wo(e){return Array.from(e).map(t=>/[a-z\d_-]/iu.test(t)?t:`\\${t.charCodeAt(0).toString(16)} `).join("")}function Ma(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ha(e){let t=e.tagName.toLowerCase();if(e.id.length>0)return`${t}#${wo(e.id)}`;let o=e.getAttribute("data-testid");if(o!==null&&o.length>0)return`${t}[data-testid="${Ma(o)}"]`;let n=Array.from(e.classList).slice(0,2).map(l=>`.${wo(l)}`).join(""),s=e.parentElement===null?[]:Array.from(e.parentElement.children).filter(l=>l.tagName===e.tagName),d=s.indexOf(e),i=s.length>1&&d>=0?`:nth-of-type(${String(d+1)})`:"";return`${t}${n}${i}`}function $a(e){let t=[],o=e;for(;o!==null&&t.length<5;){let n=Ha(o);if(t.unshift(n),o.id.length>0||o.hasAttribute("data-testid"))break;o=o.parentElement}return t.join(" > ")}function Io(e){let t=["<!-- Selected element -->"],o={nodeCount:0,truncated:!1};Po(e.element,0,o,t);let n=Da(e.element);n.length>0&&t.push("<!-- Parent context: nearest first -->",...n);let s=Lo(e.element.textContent),d=e.element.getBoundingClientRect(),i=e.element.getAttribute("role");return Object.freeze({tagName:e.element.tagName.toLowerCase(),selector:$a(e.element),sanitizedHtml:Fa(t.join(`
|
|
4
|
+
`),e.maxCharacters),...s.length===0?{}:{textPreview:s.length<=wt.maxTextCharacters?s:`${s.slice(0,wt.maxTextCharacters)}…`},...i===null?{}:{role:i},rect:Object.freeze({x:d.x,y:d.y,width:d.width,height:d.height})})}function No(e){return/Mac|iPhone|iPad|iPod/i.test(e)}function Ba(e){return e.toLowerCase()}function ko(e){return e instanceof Element?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e.closest("[contenteditable]:not([contenteditable='false'])")!==null:!1}function Do(e,t,o){let n=t.split("+").map(T=>T.trim().toLowerCase()).filter(T=>T.length>0),s=n.find(T=>T!=="mod"&&T!=="meta"&&T!=="ctrl"&&T!=="control"&&T!=="alt"&&T!=="option"&&T!=="shift");if(s===void 0||Ba(e.key)!==s)return!1;let d=n.includes("mod"),i=n.includes("meta")||d&&No(o),l=n.includes("ctrl")||n.includes("control")||d&&!No(o),A=n.includes("alt")||n.includes("option"),w=n.includes("shift");return e.metaKey===i&&e.ctrlKey===l&&e.altKey===A&&e.shiftKey===w}function za(e){return Object.freeze({x:e.x,y:e.y,width:e.width,height:e.height})}function ja(e){let t=e.filter(l=>l.width>0&&l.height>0),o=t[0];if(o===void 0)return;let n=o.left,s=o.top,d=o.right,i=o.bottom;for(let l of t.slice(1))n=Math.min(n,l.left),s=Math.min(s,l.top),d=Math.max(d,l.right),i=Math.max(i,l.bottom);return Object.freeze({x:n,y:s,width:d-n,height:i-s})}function Fo(e,t){if(t.startsWith("inline")){let o=ja(Array.from(e.getClientRects()));if(o!==void 0)return o}return za(e.getBoundingClientRect())}function Mo(e,t){return Fo(e,t.getComputedStyle(e).display)}function an(e,t){let o=t.getComputedStyle(e);if(o.display==="none"||o.visibility==="hidden")return;let n=Fo(e,o.display);return n.width>0&&n.height>0?n:void 0}var kt="data-spotpatch-ui",sn=Object.freeze({highlight:2147483646,controls:2147483647}),Ot=Object.freeze({compactInset:8,compactViewportWidth:520,desktopInset:24,dragActivationDistance:6,edgeSnapDistance:20,workbenchMaxHeight:620,workbenchMaxWidth:460});function Ho(e){if(e.closest(`[${kt}]`)!==null)return!0;let t=e.getRootNode();return t instanceof ShadowRoot&&t.host.hasAttribute(kt)}function Ua(e,t){return an(e,t)!==void 0}function Va(e){return e.tagName==="HTML"||e.tagName==="BODY"}function wn(e,t,o,n){let s=e.elementsFromPoint(o,n).filter(d=>!Ho(d)&&Ua(d,t));return s.find(d=>!Va(d))??s[0]}function $o(e){return e instanceof Element&&Ho(e)}var On=Object.freeze({"en-US":Object.freeze({adapter:"Adapter",boundary:"Boundary",code:"Nearby code",component:"Component",computedStyles:"Key computed styles",confidence:"Confidence",devicePixelRatio:"Device pixel ratio",element:"Selected element",file:"File",modificationConstraint:"Determine the root cause first, then implement every target instruction as one consistent, minimum-scope change. Do not modify unrelated components. If context is insufficient, state exactly what additional information is required.",modificationRequirements:"Change requirements",origin:"Origin",pageEnvironment:"Page environment",pathname:"Pathname",reactContext:"React context",reactVersion:"React",requestedChange:"Requested change",selectedTargets:e=>`Selected targets (${String(e)})`,source:"Source",stack:"Stack",styles:"Relevant styles",supported:"supported",target:e=>`Target ${String(e)}`,title:"Title",unavailable:"Unavailable",unsupported:"unsupported",url:"URL",viewport:"Viewport",warnings:"Collection warnings",none:"None"}),"zh-CN":Object.freeze({adapter:"适配器",boundary:"代码边界",code:"附近代码",component:"组件",computedStyles:"关键计算样式",confidence:"置信度",devicePixelRatio:"设备像素比",element:"选中元素",file:"文件",modificationConstraint:"请先判断根因,再把每个目标各自的修改说明作为一个原子任务,完成一致且最小范围的修改。不要合并、忽略或扩大目标说明,不要改动无关组件;如果上下文不足,请明确说明需要哪些信息。",modificationRequirements:"修改要求",origin:"定位来源",pageEnvironment:"页面环境",pathname:"路径",reactContext:"React 上下文",reactVersion:"React",requestedChange:"修改说明",selectedTargets:e=>`已选目标(${String(e)})`,source:"源码定位",stack:"组件栈",styles:"相关样式",supported:"支持",target:e=>`目标 ${String(e)}`,title:"标题",unavailable:"不可用",unsupported:"不支持",url:"URL",viewport:"视口",warnings:"采集警告",none:"无"})});function Wa(e){return Math.max(0,...Array.from(e.matchAll(/`+/gu),t=>t[0].length))}function cn(e,t){let o="`".repeat(Math.max(3,Wa(t)+1));return`${o}${e}
|
|
5
5
|
${t}
|
|
6
|
-
${o}`}function
|
|
7
|
-
`).find(o=>/^\s*<[a-z][^>]*>/iu.test(o))?.trim()??t}function
|
|
8
|
-
${
|
|
6
|
+
${o}`}function zo(e,t){let o=e.code?.relativePath??e.source.relativePath,n=e.source.line,s=e.source.column;return o===void 0?t.unavailable:`${ee(o)}${n===void 0?"":`:${String(n)}`}${s===void 0?"":`:${String(s)}`}`}function jo(e,t){return e.split(`
|
|
7
|
+
`).find(o=>/^\s*<[a-z][^>]*>/iu.test(o))?.trim()??t}function Ga(e){let t=[e.source===void 0?void 0:`/* source: ${Ve(e.source)} */`,e.media===void 0?void 0:`/* condition: ${Ve(e.media)} */`].filter(n=>n!==void 0),o=`${Ve(e.selector)} {
|
|
8
|
+
${Ve(e.declarations)}
|
|
9
9
|
}`;return[...t,o].join(`
|
|
10
|
-
`)}function
|
|
10
|
+
`)}function qa(e,t,o){let s=[...[e.styles.classNames.length===0?void 0:`/* classes: ${e.styles.classNames.map(Ve).join(" ")} */`,e.styles.inlineStyle===void 0?void 0:`/* inline: ${Ve(e.styles.inlineStyle)} */`].filter(d=>d!==void 0),...t.map(Ga)];return s.length===0?o.unavailable:cn("css",s.join(`
|
|
11
11
|
|
|
12
|
-
`))}function
|
|
13
|
-
`))}function
|
|
12
|
+
`))}function Ka(e,t){return e.length===0?t.unavailable:cn("css",e.map(([o,n])=>`${Ve(o)}: ${Ve(n)};`).join(`
|
|
13
|
+
`))}function Ja(e,t,o,n){let s=[`- ${n.adapter}: ${e.react.supported?n.supported:n.unsupported}`,...e.react.version===void 0?[]:[`- ${n.reactVersion}: ${ee(e.react.version)}`],...e.react.componentName===void 0?[]:[`- ${n.component}: ${ee(e.react.componentName)}`],...t.reactStack.length===0?[]:[`- ${n.stack}: ${t.reactStack.map(ee).join(" > ")}`]],d=e.code===void 0||t.codeLines.length===0?n.unavailable:`- ${n.boundary}: ${e.code.boundary}
|
|
14
14
|
|
|
15
|
-
${
|
|
16
|
-
`)))}`;return[`### ${n.target(o+1)}`,`#### ${n.requestedChange}`,t.instruction,...e.page===void 0?[]:[`#### ${n.pageEnvironment}`,`- ${n.url}: <${
|
|
17
|
-
- ${n.pathname}: ${
|
|
18
|
-
- ${n.title}: ${
|
|
19
|
-
`),`#### ${n.source}`,`- ${n.file}: ${
|
|
15
|
+
${cn(e.code.language,ee(t.codeLines.join(`
|
|
16
|
+
`)))}`;return[`### ${n.target(o+1)}`,`#### ${n.requestedChange}`,t.instruction,...e.page===void 0?[]:[`#### ${n.pageEnvironment}`,`- ${n.url}: <${Tt(e.page.url,e.page.url)}>
|
|
17
|
+
- ${n.pathname}: ${ee(e.page.pathname)}
|
|
18
|
+
- ${n.title}: ${ee(e.page.title)||n.unavailable}`],`#### ${n.reactContext}`,s.join(`
|
|
19
|
+
`),`#### ${n.source}`,`- ${n.file}: ${zo(e,n)}
|
|
20
20
|
- ${n.origin}: ${e.source.origin}
|
|
21
|
-
- ${n.confidence}: ${e.source.confidence}`,`#### ${n.element}`,
|
|
21
|
+
- ${n.confidence}: ${e.source.confidence}`,`#### ${n.element}`,cn("html",ee(t.dom)),`#### ${n.styles}`,qa(e,t.matchedRules,n),`#### ${n.computedStyles}`,Ka(t.computedEntries,n),`#### ${n.code}`,d,`#### ${n.warnings}`,t.warnings.length===0?`- ${n.none}`:t.warnings.map(i=>`- ${ee(i)}`).join(`
|
|
22
22
|
`)].join(`
|
|
23
23
|
|
|
24
|
-
`)}function
|
|
25
|
-
- ${n.pathname}: ${
|
|
24
|
+
`)}function Bo(e,t){let o=Tt(e.page.url,e.page.url),n=On[e.locale];return[`## ${n.pageEnvironment}`,`- ${n.url}: <${o}>
|
|
25
|
+
- ${n.pathname}: ${ee(e.page.pathname)}
|
|
26
26
|
- ${n.title}: ${t.pageTitle.length===0?n.unavailable:t.pageTitle}
|
|
27
27
|
- ${n.viewport}: ${String(e.page.viewportWidth)} × ${String(e.page.viewportHeight)}
|
|
28
|
-
- ${n.devicePixelRatio}: ${String(e.page.devicePixelRatio)}`,`## ${n.selectedTargets(e.targets.length)}`,e.targets.map((
|
|
28
|
+
- ${n.devicePixelRatio}: ${String(e.page.devicePixelRatio)}`,`## ${n.selectedTargets(e.targets.length)}`,e.targets.map((s,d)=>{let i=t.targets[d];if(i===void 0)throw new RangeError("Prompt target draft is missing.");return Ja(s,i,d,n)}).join(`
|
|
29
29
|
|
|
30
30
|
`),`## ${n.modificationRequirements}`,n.modificationConstraint].join(`
|
|
31
31
|
|
|
32
|
-
`)}function
|
|
32
|
+
`)}function Xa(e,t){if(t.codeLines.length===0||e.code===void 0)return!1;if(t.codeLines.length===1){let i=t.codeLines[0]??"";return i.length<=120?t.codeLines=[]:t.codeLines=[`${i.slice(0,119)}…`],!0}let o=e.source.line??e.code.startLine,n=Math.abs(e.code.startLine-o),s=e.code.startLine+t.codeLines.length-1;return Math.abs(s-o)>=n?t.codeLines.pop():t.codeLines.shift(),!0}function Ya(e){return{instruction:ee(e.instruction.trim()),reactStack:[...e.react.componentStack],dom:e.element.sanitizedHtml,matchedRules:[...e.styles.matchedRules],computedEntries:Object.entries(e.styles.computed),codeLines:e.code?.excerpt.split(/\r?\n/u)??[],warnings:Array.from(new Set([...e.styles.warnings,...e.warnings]))}}function Za(e){return{pageTitle:ee(e.page.title),targets:e.targets.map(Ya)}}function Qa(e,t,o){let n=On[e.locale],s=[(d,i)=>i.computedEntries.pop()!==void 0,(d,i)=>i.reactStack.pop()!==void 0,(d,i)=>{let l=jo(i.dom,n.unavailable);return i.dom===l?!1:(i.dom=l,!0)},(d,i)=>i.matchedRules.shift()!==void 0,Xa,(d,i)=>i.warnings.pop()!==void 0];for(let d of s)for(let i=0;i<e.targets.length;i+=1){let l=(o+i)%e.targets.length,A=e.targets[l],w=t.targets[l];if(A!==void 0&&w!==void 0&&d(A,w))return(l+1)%e.targets.length}}function ei(e,t){let o=On[e.locale],n=e.targets.map((s,d)=>{let i=t.targets[d],l=s.react.componentName;return[`### ${o.target(d+1)}`,`- ${o.requestedChange}: ${i?.instruction??ee(s.instruction)}`,`- ${o.file}: ${zo(s,o)}`,...l===void 0?[]:[`- ${o.component}: ${ee(l)}`],`- ${o.element}: ${ee(jo(i?.dom??s.element.sanitizedHtml,o.unavailable))}`].join(`
|
|
33
33
|
`)});return[`## ${o.selectedTargets(e.targets.length)}`,n.join(`
|
|
34
34
|
|
|
35
35
|
`),`## ${o.modificationRequirements}`,o.modificationConstraint].join(`
|
|
36
36
|
|
|
37
|
-
`)}function
|
|
37
|
+
`)}function ti(e,t){let o=Za(e),n=Bo(e,o),s=0;for(;n.length>t;){let i=Qa(e,o,s);if(i===void 0)if(o.pageTitle.length>0)o.pageTitle="";else break;else s=i;n=Bo(e,o)}if(n.length<=t)return n;let d=ei(e,o);if(d.length>t)throw new RangeError("Prompt budget cannot preserve every target instruction and source location.");return d}function Uo(e){if(!Number.isSafeInteger(e.maxCharacters)||e.maxCharacters<=0)throw new RangeError("Prompt character budget must be a positive integer.");return Object.freeze({compose(t){return ti(t,e.maxCharacters)}})}var Oe=Object.freeze({idle:Object.freeze({status:"idle"}),inspecting:Object.freeze({status:"inspecting"}),selected:Object.freeze({status:"selected"}),previewing:Object.freeze({status:"previewing"})}),_n=Oe.idle;function ni(e){return e.type==="ACTIVATE"?Oe.inspecting:e.type==="RESTORE"?Oe.selected:Oe.idle}function oi(e){switch(e.type){case"HOVER":return Oe.inspecting;case"SELECT":return Oe.selected;case"CANCEL":return Oe.idle;default:return Oe.inspecting}}function ri(e){switch(e.type){case"RESELECT":return Oe.inspecting;case"CLOSE":return Oe.idle;case"PREVIEW":return Oe.previewing;case"OPEN_EDITOR":return Oe.selected;default:return Oe.selected}}function ai(e){switch(e.type){case"COPY_SUCCESS":case"BACK":return Oe.selected;case"COPY_FAILURE":return Oe.previewing;default:return Oe.previewing}}function Vo(e,t){switch(e.status){case"idle":return ni(t);case"inspecting":return oi(t);case"selected":return ri(t);case"previewing":return ai(t)}}var ii="spotpatch:selection:";function it(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function ge(e){return typeof e=="string"}function Et(e){return e===void 0||ge(e)}function Ln(e){return Array.isArray(e)&&e.length<=256&&e.every(ge)}function mt(e){return typeof e=="number"&&Number.isFinite(e)}function Wo(e){return e===void 0||mt(e)}function Go(e){let t=it(e);return t!==void 0&&ge(t.origin)&&ge(t.confidence)&&Et(t.fileId)&&Et(t.relativePath)&&Wo(t.line)&&Wo(t.column)}function si(e){let t=it(e);return t!==void 0&&typeof t.supported=="boolean"&&Et(t.version)&&Et(t.componentName)&&Ln(t.componentStack)&&(t.source===void 0||Go(t.source))}function ci(e){let t=it(e);return t!==void 0&&ge(t.url)&&ge(t.pathname)&&ge(t.title)&&mt(t.viewportWidth)&&mt(t.viewportHeight)&&mt(t.devicePixelRatio)}function di(e){let t=it(e),o=it(t?.rect);return t!==void 0&&ge(t.tagName)&&ge(t.selector)&&ge(t.sanitizedHtml)&&Et(t.textPreview)&&Et(t.role)&&o!==void 0&&mt(o.x)&&mt(o.y)&&mt(o.width)&&mt(o.height)}function li(e){let t=it(e),o=it(t?.computed);return t!==void 0&&Ln(t.classNames)&&Et(t.inlineStyle)&&Array.isArray(t.matchedRules)&&t.matchedRules.length<=256&&t.matchedRules.every(n=>{let s=it(n);return s!==void 0&&ge(s.selector)&&ge(s.declarations)&&Et(s.source)&&Et(s.media)})&&o!==void 0&&Object.values(o).every(ge)&&Ln(t.warnings)}function pi(e){let t=it(e);return t!==void 0&&ge(t.relativePath)&&ge(t.language)&&mt(t.startLine)&&mt(t.endLine)&&ge(t.excerpt)&&ge(t.boundary)}function ui(e){let t=it(e);return t!==void 0&&ge(t.id)&&ge(t.instruction)&&ci(t.page)&&Go(t.source)&&si(t.react)&&di(t.element)&&li(t.styles)&&(t.code===void 0||pi(t.code))}function gi(e,t){let o=it(e);if(o?.version!==1||typeof o.open!="boolean"||!Number.isSafeInteger(o.sequence)||Number(o.sequence)<0||o.activeTargetId!==void 0&&typeof o.activeTargetId!="string"||!Array.isArray(o.targets)||o.targets.length===0||o.targets.length>t||!o.targets.every(ui))return;let n=o.targets,s=n.map(({id:d})=>d);if(!(new Set(s).size!==s.length||o.activeTargetId!==void 0&&!s.includes(o.activeTargetId)))return{...o.activeTargetId===void 0?{}:{activeTargetId:o.activeTargetId},open:o.open,sequence:Number(o.sequence),targets:n}}function qo(e,t,o){let n=`${ii}${t}`,s;try{s=e.sessionStorage}catch{s=void 0}return Object.freeze({clear(){try{s?.removeItem(n)}catch{}},load(){let d;try{d=s?.getItem(n)??null}catch{return}if(!(d===null||d.length>1e6))try{return gi(JSON.parse(d),o)}catch{return}},save(d){try{s?.setItem(n,JSON.stringify({version:1,...d}))}catch{}}})}var Ko=Object.freeze({supported:!1,componentStack:Object.freeze([])});function Xo(e){return Cn(e.getAttribute(Rn))}function fi(e){let t=e.parentElement;for(;t!==null;){let o=Xo(t);if(o!==void 0)return o;t=t.parentElement}}function Jo(e,t,o){return Object.freeze({fileId:e.fileId,line:e.line,column:e.column,origin:t,confidence:o})}function mi(){return Object.freeze({origin:"none",confidence:"unknown"})}function Pn(e){return e.fileId===void 0||e.line===void 0||e.column===void 0?void 0:Object.freeze({fileId:e.fileId,line:e.line,column:e.column})}function Yo(e){let t=!0;function o(n){if(!t)return Ko;try{return e.adapter.inspect(n)}catch{return t=!1,e.onAdapterError?.(),Ko}}return Object.freeze({resolve(n){let s=Xo(n),d=o(n);if(s!==void 0)return Object.freeze({react:d,source:Jo(s,"jsx-host","exact")});if(d.source!==void 0)return Object.freeze({react:d,source:d.source});let i=fi(n);return Object.freeze(i!==void 0?{react:d,source:Jo(i,"dom-ancestor","approximate")}:{react:d,source:mi()})},dispose(){t=!1,e.adapter.dispose()}})}function g(e,t){let o=e.createElement(t);return o.setAttribute(kt,""),o}function oe(e,t,o=""){let n=g(e,"button");return n.type="button",n.className=o,n.textContent=t,n}var Zo=`
|
|
38
38
|
.spotpatch-agent {
|
|
39
39
|
margin-top: 10px;
|
|
40
40
|
overflow: hidden;
|
|
@@ -253,7 +253,7 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
253
253
|
.spotpatch-agent-selectors { grid-template-columns: 1fr; }
|
|
254
254
|
.spotpatch-agent-mode { grid-column: auto; }
|
|
255
255
|
}
|
|
256
|
-
`;function Pt(e,t,o,n){let i=e.createElement("option");return i.value=o,i.textContent=n,t.append(i),i}function ho(e,t,o){let n=o.messages(),i=d(e,"section");i.className="spotpatch-agent",i.hidden=!t.enabled;let c=d(e,"div");c.className="spotpatch-agent-head";let r=d(e,"span");r.className="spotpatch-agent-title";let u=d(e,"span");u.className="spotpatch-agent-badge",c.append(r,u);let R=d(e,"div");R.className="spotpatch-agent-setup";let s=d(e,"div");s.className="spotpatch-agent-selectors";let A=d(e,"label");A.className="spotpatch-agent-mode";let z=d(e,"span"),m=d(e,"select");A.append(z,m);let L=d(e,"label"),M=d(e,"span"),N=d(e,"select");L.append(M,N);let b=d(e,"label"),T=d(e,"span"),$=d(e,"select");b.append(T,$),s.append(A,L,b);let re=d(e,"label");re.className="spotpatch-consent";let H=d(e,"input");H.type="checkbox";let h=d(e,"span");re.append(H,h);let S=d(e,"label");S.className="spotpatch-consent spotpatch-workspace-consent",S.hidden=!0;let x=d(e,"input");x.type="checkbox";let I=d(e,"span"),G=d(e,"strong"),W=d(e,"small");I.append(G,W),S.append(x,I);let Z=d(e,"div");Z.className="spotpatch-agent-health-list";let Q=d(e,"p");Q.className="spotpatch-agent-workspace",Q.dataset.state="idle";let F=d(e,"p");F.className="spotpatch-agent-capability",F.dataset.state="idle",Z.append(Q,F),R.append(s,re,S,Z);let Re=d(e,"div");Re.className="spotpatch-agent-job",Re.hidden=!0;let Ne=d(e,"div");Ne.className="spotpatch-agent-job-meta";let ge=d(e,"span");ge.className="spotpatch-agent-model";let _=d(e,"span");_.className="spotpatch-agent-status",Ne.append(ge,_);let Ue=d(e,"p");Ue.className="spotpatch-agent-phase";let Ce=d(e,"p");Ce.className="spotpatch-agent-error",Ce.hidden=!0;let Te=d(e,"ul");Te.className="spotpatch-agent-activity";let be=d(e,"div");be.className="spotpatch-agent-result",be.hidden=!0;let pt=d(e,"p");pt.className="spotpatch-agent-summary";let ae=d(e,"ul");ae.className="spotpatch-agent-files";let ye=d(e,"div");ye.className="spotpatch-agent-checks";let q=d(e,"pre");q.className="spotpatch-agent-diff",q.tabIndex=0,q.setAttribute("aria-label",n.agent.diffAriaLabel),be.append(pt,ae,ye,q),Re.append(Ne,Ue,Ce,Te,be),i.append(c,R,Re);let Fe=Y(e,n.agent.testConnection),Ie=Y(e,n.agent.run,"spotpatch-run"),B=Y(e,n.agent.cancel),ee=Y(e,n.agent.apply,"spotpatch-primary"),Pe=Y(e,n.agent.revert),We=Y(e,n.agent.revise),at=t.enabled?t.providers:[],ze=t.enabled&&t.applyMode==="trusted-auto",De=t.enabled?t.applyMode:"review",v=new Map(at.map(f=>[f.id,f])),Ke=!1,J=!0,se=!1,fe=!1,O=!1,He=!1,Ee,ve,je=[],ke,ce="idle",Ve=n.agent.connectionNotTested,$e,le="idle",ut,me;for(let f of at)Pt(e,N,f.id,f.label);t.enabled&&(N.value=t.defaultProvider);let it,st,Be;De==="auto"?Be=Pt(e,m,"auto",n.agent.autoGated):(it=Pt(e,m,"review",n.agent.review),ze&&(st=Pt(e,m,"trusted-auto",n.agent.trustedFast)));let Xe=ze?"review":De;m.value=Xe,A.hidden=!ze;let Ye=()=>m.value==="trusted-auto"?"trusted-auto":Xe,qe=()=>Ye()==="trusted-auto",we=()=>v.get(N.value),Ze=f=>f===void 0?n.agent.providerUnavailable:qe()?n.agent.trustedFastConsent(f.label):n.agent.consent(f.label),Qe=()=>qe()?H.checked:x.checked,Se=()=>{let f=qe();re.classList.toggle("spotpatch-trusted-consent",f),u.textContent=f?n.agent.trustedFast:De==="auto"?n.agent.autoGated:n.agent.review,h.textContent=Ze(we()),S.hidden=f||le!=="consent-required"},et=()=>{let f=we();if($.replaceChildren(),f===void 0){h.textContent=Ze(f);return}for(let w of f.models)Pt(e,$,w.id,w.label);$.value=f.defaultModel,h.textContent=Ze(f)},te=()=>{let f=t.enabled&&se&&!fe;Ie.textContent=O?n.agent.verifying:n.agent.run,Ie.classList.toggle("spotpatch-primary",He),Fe.hidden=!f,Ie.hidden=!f,Fe.disabled=!J||O||we()===void 0,Ie.disabled=!J||O||!Ke||!H.checked||le==="idle"||le==="checking"||le==="blocked"||le==="consent-required"&&!Qe()||we()===void 0||$.value.length===0,(!fe||!se)&&(B.hidden=!0,ee.hidden=!0,Pe.hidden=!0,We.hidden=!0)},yt=()=>{if(le==="idle")Q.textContent=n.agent.workspaceNotChecked;else if(le==="checking")Q.textContent=n.agent.checkingWorkspace;else if(le==="ready")Q.textContent=n.agent.workspaceReady;else if(le==="consent-required"){let f=ut?.changes;Q.textContent=n.agent.workspaceDirty(f?.staged??0,f?.unstaged??0,f?.untracked??0)}else Q.textContent=me===void 0?n.errors.INTERNAL_ERROR:n.errors[me]};function a(){et(),H.checked=!1,F.dataset.state="idle",F.textContent=n.agent.connectionNotTested,ce="idle",Ve=n.agent.connectionNotTested,$e=void 0,He=!1,te()}function p(){F.dataset.state="idle",F.textContent=n.agent.connectionNotTested,ce="idle",Ve=n.agent.connectionNotTested,$e=void 0,He=!1,te()}function y(){H.checked=!1,x.checked=!1,Se(),te()}et(),m.addEventListener("change",y),N.addEventListener("change",a),$.addEventListener("change",p),H.addEventListener("change",te),x.addEventListener("change",te);function P(){if(Ee===void 0)return;let f=Ee,w=ve;ge.textContent=`${f.providerLabel} · ${f.modelLabel}`,_.textContent=n.agent.status(f.status),Ue.textContent=f.phaseMessage;let de=ke??f.errorCode;Ce.hidden=de===void 0,Ce.textContent=de===void 0?"":n.errors[de],Te.replaceChildren();for(let oe of je.slice(-8)){let Ge=d(e,"li");Ge.dataset.state=oe.state,Ge.textContent=oe.label,Te.append(Ge)}be.hidden=w===void 0,pt.textContent=w?.summary??"",ae.replaceChildren(),ye.replaceChildren(),q.textContent=w?.diff??"";for(let oe of w?.files??[]){let Ge=d(e,"li");Ge.textContent=`${oe.kind} ${oe.relativePath} (+${String(oe.additions)} / -${String(oe.deletions)})`,ae.append(Ge)}for(let oe of w?.checks??[]){let Ge=d(e,"details"),Ct=d(e,"summary");Ct.textContent=`${oe.label}: ${oe.status} · ${String(oe.durationMs)} ms`;let kt=d(e,"pre");kt.textContent=oe.output.length===0?n.agent.noOutput:oe.output,Ge.append(Ct,kt),ye.append(Ge)}Fe.hidden=!0,Ie.hidden=!0,B.hidden=!se||!f.canCancel,B.textContent=f.status==="awaiting-review"?n.agent.discard:n.agent.cancel,ee.hidden=!se||!f.canApply,Pe.hidden=!se||!f.canRevert,We.hidden=!se||!["completed","cancelled","reverted","failed"].includes(f.status)}function k(){n=o.messages(),r.textContent=n.agent.title,z.textContent=n.agent.mode,it!==void 0&&(it.textContent=n.agent.review),st!==void 0&&(st.textContent=n.agent.trustedFast),Be!==void 0&&(Be.textContent=n.agent.autoGated),M.textContent=n.agent.provider,T.textContent=n.agent.model,N.setAttribute("aria-label",n.agent.providerAriaLabel),$.setAttribute("aria-label",n.agent.modelAriaLabel),G.textContent=n.agent.includeLocalChanges,W.textContent=n.agent.includeLocalChangesHelp,q.setAttribute("aria-label",n.agent.diffAriaLabel),Fe.textContent=n.agent.testConnection,ee.textContent=n.agent.apply,Pe.textContent=n.agent.revert,We.textContent=n.agent.revise,Se(),ce==="idle"?F.textContent=n.agent.connectionNotTested:ce==="probing"?F.textContent=n.agent.testingCapability:ce==="ready"?F.textContent=`${n.agent.capabilityVerified} · ${n.agent.toolsReady}`:$e!==void 0?F.textContent=n.errors[$e]:we()===void 0?F.textContent=n.agent.providerUnavailable:F.textContent=Ve,yt(),te(),P()}let ne=o.subscribe(k);return k(),Object.freeze({root:i,modeSelect:m,providerSelect:N,modelSelect:$,consentCheckbox:H,workspaceConsentCheckbox:x,testButton:Fe,runButton:Ie,cancelButton:B,applyButton:ee,revertButton:Pe,resetButton:We,consentGranted(){return H.checked},workspaceConsentGranted(){return Qe()},readSelection(){let f=we(),w=f?.models.find(de=>de.id===$.value);return f===void 0||w===void 0?void 0:Object.freeze({applyMode:Ye(),providerProfileId:f.id,modelProfileId:w.id})},renderCapability(f,w,de,oe){ce=f,Ve=w,$e=oe,O=f==="probing",He=f==="ready"&&de?.state==="agent-ready",F.dataset.state=f,F.textContent=de?.state==="agent-ready"?`${w} · ${n.agent.toolsReady}`:w,te()},renderWorkspaceHealth(f,w,de){le=f,ut=w,me=de??w?.errorCode,Q.dataset.state=f,f!=="checking"&&(S.hidden=qe()||f!=="consent-required"),(f==="idle"||f==="ready"||f==="blocked")&&(x.checked=!1),yt(),te()},renderJob(f,w,de,oe){fe=!0,R.hidden=!0,Re.hidden=!1,N.disabled=!0,$.disabled=!0,m.disabled=!0,H.disabled=!0,x.disabled=!0,Ee=f,ve=w,je=de,ke=oe,P()},resetJob(){fe=!1,Ee=void 0,ve=void 0,je=[],ke=void 0,R.hidden=!1,Re.hidden=!0,N.disabled=!1,$.disabled=!1,m.disabled=!1,H.disabled=!1,x.disabled=!1,Te.replaceChildren(),ae.replaceChildren(),ye.replaceChildren(),q.textContent="",Ce.textContent="",Ce.hidden=!0,te()},setContextReady(f){Ke=f,te()},setEditingEnabled(f){J=f,N.disabled=!f||fe,$.disabled=!f||fe,m.disabled=!f||fe,H.disabled=!f||fe,x.disabled=!f||fe,te()},setProviderConsent(f){H.checked=f,te()},setSelectionVisible(f){se=f,te(),f||(B.hidden=!0,ee.hidden=!0,Pe.hidden=!0,We.hidden=!0)},dispose(){ne(),N.removeEventListener("change",a),$.removeEventListener("change",p),m.removeEventListener("change",y),H.removeEventListener("change",te),x.removeEventListener("change",te)}})}var bo="http://www.w3.org/2000/svg",ha="";function ba(e){if(e!==void 0)return{content:e,viewBox:"0 0 512 512"};let t=typeof __SPOTPATCH_BRAND_MARK_CONTENT__=="string"?__SPOTPATCH_BRAND_MARK_CONTENT__:void 0;return typeof t=="string"?{content:t,viewBox:"0 0 512 512"}:{content:ha,viewBox:"0 0 1 1"}}function ya(e,t,o){let n=e.createElementNS(bo,t);for(let[i,c]of Object.entries(o))n.setAttribute(i,c);return n}function yo(e,t){let o=ba(t),n=ya(e,"svg",{xmlns:bo,class:"spotpatch-brand-mark",viewBox:o.viewBox,"aria-hidden":"true",focusable:"false"});return n.innerHTML=o.content,n}var Ea=Symbol.for("spotpatch.data-flow.extension.v1");function Dt(e=globalThis){return e[Ea]}function bt(e,t,o){return Math.min(Math.max(e,t),Math.max(t,o))}function Eo({dialogHeight:e,dialogWidth:t,target:o,viewportHeight:n,viewportWidth:i}){let c=i-t-16,r=n-e-16,u=bt((i-t)/2,16,c),R=bt((n-e)/2,16,r);if(o===void 0)return Object.freeze({anchorX:bt(t/2,22,t-22),anchorY:bt(e/2,22,e-22),left:u,mode:"viewport",top:R});let s=o.x+o.width/2,A=o.y+o.height/2,z=bt(s-t/2,16,c),m=bt(A-e/2,16,r),L=z,M=m,N="viewport";return o.width>=t+48&&o.height>=e+48?N="center":o.y-e-14>=16?(M=o.y-e-14,N="above"):o.y+o.height+14+e<=n-16?(M=o.y+o.height+14,N="below"):o.x+o.width+14+t<=i-16?(L=o.x+o.width+14,N="right"):o.x-t-14>=16&&(L=o.x-t-14,N="left"),Object.freeze({anchorX:bt(s-L,22,t-22),anchorY:bt(A-M,22,e-22),left:L,mode:N,top:M})}var Sa=Symbol.for("spotpatch.external-handoff.v1");function Wt(){return globalThis[Sa]}var Aa=Object.freeze({queued:"Queued",preparing:"Preparing",running:"Running",validating:"Validating","awaiting-review":"Awaiting review",applying:"Applying",applied:"Applied",completed:"Completed",cancelling:"Cancelling",cancelled:"Cancelled",reverting:"Reverting",reverted:"Reverted",failed:"Failed"}),xa=Object.freeze({queued:"已排队",preparing:"准备中",running:"执行中",validating:"验证中","awaiting-review":"等待审阅",applying:"应用中",applied:"已应用",completed:"已完成",cancelling:"取消中",cancelled:"已取消",reverting:"撤销中",reverted:"已撤销",failed:"失败"}),pe="The external Agent handoff request failed.",ue="外部 Agent 交接请求失败。",Ra=Object.freeze({[l.INVALID_REQUEST]:"The Agent request was rejected as invalid.",[l.INVALID_TOKEN]:"The local SpotPatch session expired.",[l.ORIGIN_NOT_ALLOWED]:"The current page origin is not authorized.",[l.SOURCE_NOT_FOUND]:"The selected source is no longer available.",[l.SOURCE_OUTSIDE_ROOT]:"The selected source is outside the project.",[l.SOURCE_TOO_LARGE]:"The selected source exceeds the safety limit.",[l.EDITOR_OPEN_FAILED]:"The editor request failed.",[l.DATA_FLOW_DISABLED]:"Component data-flow analysis is disabled.",[l.DATA_FLOW_SOURCE_STALE]:"The selected source changed. Select the component again.",[l.DATA_FLOW_ANALYSIS_CANCELLED]:"Component data-flow analysis was cancelled.",[l.AI_DISABLED]:"AI execution is disabled in Vite configuration.",[l.PROVIDER_NOT_CONFIGURED]:"The provider Key environment variable is missing on the Vite process.",[l.PROVIDER_AUTH_FAILED]:"The provider rejected authentication. Check the server-side Key.",[l.PROVIDER_PROTOCOL_UNSUPPORTED]:"The relay does not match the configured OpenAI-compatible protocol.",[l.MODEL_NOT_ALLOWED]:"The selected model profile is not allowed.",[l.MODEL_TOOL_CALL_UNSUPPORTED]:"The selected model did not start or continue the required tool call.",[l.PROVIDER_RATE_LIMITED]:"The provider is rate limited. Wait and try again.",[l.AGENT_BUSY]:"Another write Agent job is still active.",[l.AGENT_LIMIT_EXCEEDED]:"The Agent stopped at a configured time, turn, output, or size limit.",[l.AGENT_CANCELLED]:"The Agent job was cancelled.",[l.EXTERNAL_HANDOFF_DISABLED]:pe,[l.EXTERNAL_HANDOFF_UNAVAILABLE]:pe,[l.HANDOFF_VALIDATION_FAILED]:pe,[l.HANDOFF_SOURCE_STALE]:pe,[l.HANDOFF_NOT_FOUND]:pe,[l.HANDOFF_EXPIRED]:pe,[l.HANDOFF_CURSOR_INVALID]:pe,[l.HANDOFF_RESPONSE_TOO_LARGE]:pe,[l.BRIDGE_UNAUTHORIZED]:pe,[l.BRIDGE_PROTOCOL_MISMATCH]:pe,[l.BRIDGE_BUSY]:pe,[l.EXTERNAL_AGENT_BUSY]:pe,[l.ACTIVE_ADAPTER_CONFLICT]:pe,[l.ACTIVE_ADAPTER_LEASE_INVALID]:pe,[l.ACTIVE_DISPATCH_INVALID]:pe,[l.SESSION_NOT_FOUND]:pe,[l.SESSION_AMBIGUOUS]:pe,[l.SESSION_CLOSED]:pe,[l.WORKTREE_DIRTY]:"Confirm inclusion of local changes before running AI.",[l.WORKTREE_NOT_REPOSITORY]:"Vite root must be an initialized Git repository root.",[l.WORKTREE_OPERATION_IN_PROGRESS]:"Finish the active merge, rebase, cherry-pick, or revert.",[l.WORKTREE_CONFLICTED]:"Resolve all Git conflicts before running AI.",[l.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"Reduce untracked files below the safe count and size limits.",[l.WORKTREE_UNTRACKED_UNSUPPORTED]:"An untracked path is missing, linked, or not a regular file.",[l.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"Local changes cannot be isolated safely.",[l.TOOL_DENIED]:"A tool request violated local safety policy.",[l.TOOL_INPUT_INVALID]:"Invalid tool request.",[l.TOOL_ARGUMENTS_INVALID]:"Tool arguments are invalid.",[l.TOOL_CALL_ID_CONFLICT]:"Tool ID conflicts in this turn.",[l.TOOL_PATH_DENIED]:"The model requested a protected or external path.",[l.PATCH_REJECTED]:"The patch violated local policy.",[l.VALIDATION_FAILED]:"Required checks failed; changes cannot be applied.",[l.APPLY_CONFLICT]:"Agent-touched files changed; nothing was overwritten.",[l.INTERNAL_ERROR]:"The Agent failed without exposing private details."}),Ca=Object.freeze({[l.INVALID_REQUEST]:"Agent 请求无效,已被拒绝。",[l.INVALID_TOKEN]:"本地 SpotPatch 会话已失效。",[l.ORIGIN_NOT_ALLOWED]:"当前页面来源未获授权。",[l.SOURCE_NOT_FOUND]:"选中目标对应的源码已不可用。",[l.SOURCE_OUTSIDE_ROOT]:"选中源码位于项目根目录之外。",[l.SOURCE_TOO_LARGE]:"选中源码超过安全大小限制。",[l.EDITOR_OPEN_FAILED]:"编辑器打开请求失败。",[l.DATA_FLOW_DISABLED]:"组件数据链路分析未启用。",[l.DATA_FLOW_SOURCE_STALE]:"选中源码已经变化,请重新选择组件。",[l.DATA_FLOW_ANALYSIS_CANCELLED]:"组件数据链路分析已取消。",[l.AI_DISABLED]:"Vite 配置未启用 AI 执行。",[l.PROVIDER_NOT_CONFIGURED]:"启动 Vite 的进程中缺少模型服务 Key 环境变量。",[l.PROVIDER_AUTH_FAILED]:"模型服务鉴权失败,请检查服务端 Key。",[l.PROVIDER_PROTOCOL_UNSUPPORTED]:"中转服务与配置的 OpenAI 兼容协议不一致。",[l.MODEL_NOT_ALLOWED]:"当前模型配置未获授权。",[l.MODEL_TOOL_CALL_UNSUPPORTED]:"当前模型未完成必要的工具调用或结果续接。",[l.PROVIDER_RATE_LIMITED]:"模型服务正在限流,请稍后重试。",[l.AGENT_BUSY]:"当前项目已有一个写入任务正在运行。",[l.AGENT_LIMIT_EXCEEDED]:"Agent 达到时间、轮次、输出或变更规模限制。",[l.AGENT_CANCELLED]:"Agent 任务已取消。",[l.EXTERNAL_HANDOFF_DISABLED]:ue,[l.EXTERNAL_HANDOFF_UNAVAILABLE]:ue,[l.HANDOFF_VALIDATION_FAILED]:ue,[l.HANDOFF_SOURCE_STALE]:ue,[l.HANDOFF_NOT_FOUND]:ue,[l.HANDOFF_EXPIRED]:ue,[l.HANDOFF_CURSOR_INVALID]:ue,[l.HANDOFF_RESPONSE_TOO_LARGE]:ue,[l.BRIDGE_UNAUTHORIZED]:ue,[l.BRIDGE_PROTOCOL_MISMATCH]:ue,[l.BRIDGE_BUSY]:ue,[l.EXTERNAL_AGENT_BUSY]:ue,[l.ACTIVE_ADAPTER_CONFLICT]:ue,[l.ACTIVE_ADAPTER_LEASE_INVALID]:ue,[l.ACTIVE_DISPATCH_INVALID]:ue,[l.SESSION_NOT_FOUND]:ue,[l.SESSION_AMBIGUOUS]:ue,[l.SESSION_CLOSED]:ue,[l.WORKTREE_DIRTY]:"运行 AI 前,请明确同意将当前本地修改纳入隔离基线。",[l.WORKTREE_NOT_REPOSITORY]:"Vite 根目录不是已初始化 Git 仓库的顶层目录。",[l.WORKTREE_OPERATION_IN_PROGRESS]:"请先完成当前 merge、rebase、cherry-pick 或 revert,再运行 AI。",[l.WORKTREE_CONFLICTED]:"请先解决全部 Git 冲突,再运行 AI。",[l.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"未跟踪文件超过安全数量或体积上限,请先精简。",[l.WORKTREE_UNTRACKED_UNSUPPORTED]:"未跟踪项已丢失、是符号链接或不是普通文件。",[l.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"当前本地修改无法安全隔离。",[l.TOOL_DENIED]:"工具请求违反本地安全策略。",[l.TOOL_INPUT_INVALID]:"工具请求无效。",[l.TOOL_ARGUMENTS_INVALID]:"工具参数无效。",[l.TOOL_CALL_ID_CONFLICT]:"本轮工具 ID 冲突。",[l.TOOL_PATH_DENIED]:"模型请求了受保护或项目外路径。",[l.PATCH_REJECTED]:"补丁违反本地策略。",[l.VALIDATION_FAILED]:"必需检查失败,无法应用变更。",[l.APPLY_CONFLICT]:"Agent 触及文件已变化,未覆盖。",[l.INTERNAL_ERROR]:"Agent 失败,未暴露私有细节。"}),Ta=Object.freeze({adapter:"React adapter",api:"API",apiStatuses:Object.freeze({connected:"connected",failed:"failed",loading:"loading","not-required":"not required"}),available:"available",boundary:"Boundary",boundaries:Object.freeze({component:"component","nearby-lines":"nearby lines"}),browserContext:"Browser context",collectionStatuses:Object.freeze({failed:"failed",loading:"loading",ready:"ready"}),component:"Component",confidence:"Confidence",confidenceLabels:Object.freeze({exact:"exact element source",probable:"probable owning component",approximate:"nearest business container",unknown:"source not found"}),cssWarnings:"CSS warnings",lineLocation:(e,t)=>`line ${String(e)}${t===void 0?"":`, column ${String(t)}`}`,origin:"Origin",source:"Source",sourceContext:"Source context",stack:"Stack",target:(e,t)=>`Target ${String(e)}${t?" (active)":""}`,unavailable:"unavailable",unsupported:"unsupported",warning:"Warning"}),va=Object.freeze({adapter:"React 适配器",api:"API",apiStatuses:Object.freeze({connected:"已连接",failed:"失败",loading:"加载中","not-required":"无需请求"}),available:"可用",boundary:"代码边界",boundaries:Object.freeze({component:"完整组件","nearby-lines":"附近代码"}),browserContext:"浏览器上下文",collectionStatuses:Object.freeze({failed:"失败",loading:"采集中",ready:"已就绪"}),component:"组件",confidence:"置信度",confidenceLabels:Object.freeze({exact:"精确元素源码",probable:"可能的所属组件",approximate:"最近业务容器",unknown:"未找到源码"}),cssWarnings:"CSS 警告",lineLocation:(e,t)=>`第 ${String(e)} 行${t===void 0?"":`,第 ${String(t)} 列`}`,origin:"定位来源",source:"源码",sourceContext:"源码上下文",stack:"组件栈",target:(e,t)=>`目标 ${String(e)}${t?"(当前)":""}`,unavailable:"不可用",unsupported:"不支持",warning:"警告"}),wa=Object.freeze({"en-US":Object.freeze({localeName:"EN",alternateLocaleName:"中",switchLocale:"Switch interface language to Chinese",brand:Object.freeze({name:"SpotPatch",context:"Live context",repository:"GitHub ↗",repositoryTitle:"Star SpotPatch on GitHub"}),trigger:Object.freeze({select:"Select element",stop:"Stop selecting",title:e=>`Toggle SpotPatch (${e})`}),dialog:Object.freeze({close:"Close SpotPatch",editTitle:"Plan the change",editSubtitle:"Give each selected target its own precise instruction.",previewTitle:"Review the request",previewSubtitle:"Verify the complete context before it leaves the browser."}),context:Object.freeze({collecting:"Collecting context",ready:"Context ready",partial:"Partial context",sourceUnavailable:"Source unavailable",selectedElement:"Selected element",selectedCount:e=>`${String(e)} elements selected`}),targets:Object.freeze({title:"Selected targets",ariaLabel:"Selected targets and change instructions",count:(e,t)=>`${String(e)} of ${String(t)}`,complete:(e,t)=>`${String(e)} of ${String(t)} described`,instructionBudget:(e,t)=>`${String(e)} / ${String(t)} characters`,instructionBudgetExceeded:(e,t)=>`${String(e)} / ${String(t)} characters — reduce the request`,statusReady:"Ready",statusPartial:"Partial",statusCollecting:"Collecting",instructionReady:"Instruction added",instructionMissing:"Needs instruction",instructionLabel:e=>`Change for ${e}`,instructionPlaceholder:"Describe the desired result for this target, including constraints…",instructionCount:(e,t)=>`${String(e)} / ${String(t)}`,activate:e=>`Edit target ${String(e)}`,remove:e=>`Remove target ${String(e)}`,removeTitle:"Remove target",addTitle:"Add another element to this request",limitTitle:e=>`Selection limit reached (${String(e)})`}),diagnostics:Object.freeze({title:"Captured context",resolving:"Resolving source…",noExactSource:"No exact source marker",promptAriaLabel:"Generated prompt"}),summary:Ta,actions:Object.freeze({addElement:"Add element",reselect:"Start over",openEditor:"Open source",openTarget:e=>`Open source for target ${String(e)}`,preview:"Preview prompt",copy:"Copy prompt",back:"Back to edit"}),agent:Object.freeze({title:"AI code agent",mode:"Execution mode",review:"Review",autoGated:"Auto gated",trustedFast:"Trusted direct",provider:"Provider",model:"Model",providerAriaLabel:"AI provider",modelAriaLabel:"AI model",providerUnavailable:"Provider configuration is unavailable.",consent:e=>`I understand selected context and allowed source may be sent to ${e}; its data policy is my responsibility.`,trustedFastConsent:e=>`Enable trusted direct mode for ${e}: send allowed project context, include current local changes, skip project validation checks, and immediately apply AI changes, including file deletions and configuration changes.`,connectionNotTested:"Optional connection check not run",workspaceNotChecked:"Local workspace not checked",checkingWorkspace:"Checking Git workspace and isolated execution…",workspaceReady:"Local workspace is ready for isolated execution",workspaceDirty:(e,t,o)=>`Local changes found · ${String(e)} staged · ${String(t)} unstaged · ${String(o)} untracked`,includeLocalChanges:"Allow the Agent to continue from my current local changes",includeLocalChangesHelp:"The Agent may edit these files. SpotPatch preserves the baseline and applies or reverts only the Agent delta.",localChangesConsentRequired:"Confirm inclusion of current local changes before running AI.",capabilityVerified:"Agent capability verified",capabilityVerifiedAnnouncement:"AI provider capability verified.",testingCapability:"Testing authentication, tools, continuation, and streaming…",applying:"Applying changes to the project.",cancelling:"Cancelling Agent job.",reverting:"Reverting the applied Agent change.",consentRequired:"Confirm remote provider data transmission before running AI.",toolsReady:"tools and streaming ready",testConnection:"Check environment",verifying:"Verifying…",run:"Run AI",cancel:"Cancel agent",discard:"Discard changes",apply:"Apply changes",revert:"Revert changes",revise:"Revise request",diffAriaLabel:"Proposed source diff",noOutput:"No output.",status:e=>Aa[e]}),announcements:Object.freeze({adapterDisabled:"React inspection was disabled after an adapter failure.",selectionEnabled:"Element selection enabled.",chooseAnother:"Choose another element.",reselectAfterChange:"Choose the current elements again after the file change.",sourceLoaded:"Source context loaded.",sourceFailed:"Source context could not be loaded.",addCancelled:"Additional selection cancelled.",selectionLimit:e=>`The selection limit of ${String(e)} elements has been reached.`,chooseAdditional:(e,t)=>`Choose another element. ${String(e)} of ${String(t)} selected.`,duplicate:"That source target is already selected.",sourceProbable:"A probable React component was found without an authorized file token.",sourceMissing:"No authorized source marker was found for the selected element.",noSelectable:"No selectable element was found.",allTargetsRemoved:"All targets were removed. Choose an element to continue.",targetRemoved:"Selected target removed.",detachedTargetPreserved:"The page element was unloaded; its collected context remains selected.",contextWarning:"Browser context collection completed with a warning.",contextCollected:"Browser context collected.",editorOpening:"Opening source…",editorOpened:"Source opened in the editor.",editorFailed:"Could not open the editor. Start it or configure editor.",completeInstructions:"Add an instruction for every target and wait for context collection to finish.",promptCopied:"Prompt copied to the clipboard.",clipboardUnavailable:"Clipboard access is unavailable. Select the prompt manually.",copyFailed:"Copy failed. Select the prompt manually.",appliedTargetsDetached:"Changes applied. Reselect page elements after HMR before creating another request."}),errors:Ra}),"zh-CN":Object.freeze({localeName:"中",alternateLocaleName:"EN",switchLocale:"将界面语言切换为英文",brand:Object.freeze({name:"SpotPatch",context:"实时上下文",repository:"GitHub ↗",repositoryTitle:"在 GitHub 上 Star SpotPatch"}),trigger:Object.freeze({select:"选择元素",stop:"停止选择",title:e=>`切换 SpotPatch(${e})`}),dialog:Object.freeze({close:"关闭 SpotPatch",editTitle:"规划本次修改",editSubtitle:"为每个选中目标分别写清楚修改要求。",previewTitle:"审阅修改请求",previewSubtitle:"发送给 AI 前,请核对完整上下文与每项目标说明。"}),context:Object.freeze({collecting:"正在采集上下文",ready:"上下文已就绪",partial:"部分上下文可用",sourceUnavailable:"源码位置不可用",selectedElement:"已选元素",selectedCount:e=>`已选择 ${String(e)} 个元素`}),targets:Object.freeze({title:"修改目标",ariaLabel:"已选目标与逐项目标说明",count:(e,t)=>`${String(e)} / ${String(t)}`,complete:(e,t)=>`已描述 ${String(e)} / ${String(t)}`,instructionBudget:(e,t)=>`说明字符 ${String(e)} / ${String(t)}`,instructionBudgetExceeded:(e,t)=>`说明字符 ${String(e)} / ${String(t)},请精简后继续`,statusReady:"已就绪",statusPartial:"部分可用",statusCollecting:"采集中",instructionReady:"已填写修改说明",instructionMissing:"待填写修改说明",instructionLabel:e=>`${e} 的修改说明`,instructionPlaceholder:"描述这个目标期望达到的结果,以及不能破坏的约束……",instructionCount:(e,t)=>`${String(e)} / ${String(t)}`,activate:e=>`编辑目标 ${String(e)}`,remove:e=>`移除目标 ${String(e)}`,removeTitle:"移除目标",addTitle:"继续为本次请求选择元素",limitTitle:e=>`已达到 ${String(e)} 个目标的上限`}),diagnostics:Object.freeze({title:"已采集上下文",resolving:"正在解析源码……",noExactSource:"没有精确源码标记",promptAriaLabel:"生成的 Prompt"}),summary:va,actions:Object.freeze({addElement:"添加元素",reselect:"重新开始",openEditor:"打开源码",openTarget:e=>`打开目标 ${String(e)} 的源码`,preview:"预览 Prompt",copy:"复制 Prompt",back:"返回编辑"}),agent:Object.freeze({title:"AI 代码 Agent",mode:"执行方式",review:"审阅模式",autoGated:"受控自动模式",trustedFast:"可信极速模式",provider:"模型服务",model:"模型",providerAriaLabel:"AI 模型服务",modelAriaLabel:"AI 模型",providerUnavailable:"模型服务配置不可用。",consent:e=>`我了解选中上下文与获准源码可能发送到 ${e},并自行负责其数据策略。`,trustedFastConsent:e=>`为 ${e} 启用可信极速模式:发送获准的项目上下文、纳入当前本地修改、跳过项目验证检查,并立即应用 AI 变更,包括删除文件与配置变更。`,connectionNotTested:"尚未执行可选连接检查",workspaceNotChecked:"尚未检查本地工作区",checkingWorkspace:"正在检查 Git 工作区与隔离执行环境……",workspaceReady:"本地工作区已满足隔离执行条件",workspaceDirty:(e,t,o)=>`发现本地修改 · 暂存 ${String(e)} · 未暂存 ${String(t)} · 未跟踪 ${String(o)}`,includeLocalChanges:"允许 Agent 基于我当前的本地修改继续",includeLocalChangesHelp:"Agent 可能继续修改这些文件;SpotPatch 会保留原基线,仅应用或撤销 Agent 自己的增量。",localChangesConsentRequired:"运行 AI 前,请确认允许纳入当前本地修改。",capabilityVerified:"Agent 能力验证通过",capabilityVerifiedAnnouncement:"AI 模型服务能力验证通过。",testingCapability:"正在验证鉴权、工具调用、连续调用与流式响应……",applying:"正在将变更应用到项目。",cancelling:"正在取消 Agent 任务。",reverting:"正在撤销已应用的 Agent 变更。",consentRequired:"运行 AI 前,请先确认允许向远程模型服务传输数据。",toolsReady:"工具调用与流式响应已就绪",testConnection:"检查运行环境",verifying:"验证中……",run:"运行 AI",cancel:"取消 Agent",discard:"放弃变更",apply:"应用变更",revert:"撤销变更",revise:"修改请求",diffAriaLabel:"建议的源码差异",noOutput:"没有输出。",status:e=>xa[e]}),announcements:Object.freeze({adapterDisabled:"React 适配器异常,本次会话已停用 React 检查。",selectionEnabled:"元素选择已启用。",chooseAnother:"请选择另一个元素。",reselectAfterChange:"文件变更后,请重新选择当前页面元素。",sourceLoaded:"源码上下文已加载。",sourceFailed:"源码上下文加载失败。",addCancelled:"已取消追加选择。",selectionLimit:e=>`已达到 ${String(e)} 个元素的选择上限。`,chooseAdditional:(e,t)=>`请选择另一个元素,当前已选 ${String(e)} / ${String(t)}。`,duplicate:"该源码目标已经在当前选择中。",sourceProbable:"找到可能的 React 组件,但没有获授权的源码标记。",sourceMissing:"选中元素没有获授权的源码标记。",noSelectable:"当前位置没有可选择的元素。",allTargetsRemoved:"已移除全部目标,请重新选择元素。",targetRemoved:"已移除选中目标。",detachedTargetPreserved:"页面元素已卸载,已采集的上下文仍保留在选择中。",contextWarning:"浏览器上下文采集完成,但存在警告。",contextCollected:"浏览器上下文采集完成。",editorOpening:"正在打开源码……",editorOpened:"源码已在编辑器中打开。",editorFailed:"无法打开编辑器。请先启动编辑器或检查 editor 配置。",completeInstructions:"请为每个目标填写修改说明,并等待上下文采集完成。",promptCopied:"Prompt 已复制到剪贴板。",clipboardUnavailable:"无法访问剪贴板,请手动选择并复制 Prompt。",copyFailed:"复制失败,请手动选择并复制 Prompt。",appliedTargetsDetached:"变更已应用;HMR 后请重新选择页面元素再发起新请求。"}),errors:Ca})});function So(e){if(e===void 0||e.trim().length===0)return;let t=e.trim().toLowerCase();return t==="zh"||t.startsWith("zh-")?"zh-CN":t==="en"||t.startsWith("en-")?"en-US":void 0}function Oa(e,t){if(e!=="auto")return e;let o=So(t.documentElement.lang);return o!==void 0?o:t.defaultView?.navigator.languages.map(So).find(i=>i!==void 0)??"en-US"}function Ao(e,t="auto"){let o=Oa(t,e),n=new Set;return Object.freeze({locale:()=>o,messages:()=>wa[o],subscribe(i){return n.add(i),()=>{n.delete(i)}},toggle(){o=o==="en-US"?"zh-CN":"en-US";for(let i of n)i()}})}var xo=460,Ro=620,_a=Object.freeze({previewing:560,selected:Ro});function La(e){let t=new Set([...e.querySelectorAll("script[nonce]")].map(o=>o.nonce?.trim()??"").filter(Boolean));if(t.size===1)return t.values().next().value}function Na(e){let t=e.createElement("style");return t.textContent=`
|
|
256
|
+
`;function Vt(e,t,o,n){let s=e.createElement("option");return s.value=o,s.textContent=n,t.append(s),s}function Qo(e,t,o){let n=o.messages(),s=g(e,"section");s.className="spotpatch-agent",s.hidden=!t.enabled;let d=g(e,"div");d.className="spotpatch-agent-head",d.setAttribute("data-spotpatch-agent-identity","");let i=g(e,"span");i.className="spotpatch-agent-title";let l=g(e,"span");l.className="spotpatch-agent-badge",d.append(i,l);let A=g(e,"div");A.className="spotpatch-agent-setup";let w=g(e,"div");w.className="spotpatch-agent-selectors";let T=g(e,"label");T.className="spotpatch-agent-mode";let N=g(e,"span"),r=g(e,"select");T.append(N,r);let F=g(e,"label"),M=g(e,"span"),I=g(e,"select");F.append(M,I);let b=g(e,"label"),x=g(e,"span"),K=g(e,"select");b.append(x,K),w.append(T,F,b);let J=g(e,"label");J.className="spotpatch-consent";let G=g(e,"input");G.type="checkbox";let h=g(e,"span");J.append(G,h);let R=g(e,"label");R.className="spotpatch-consent spotpatch-workspace-consent",R.hidden=!0;let O=g(e,"input");O.type="checkbox";let _=g(e,"span"),U=g(e,"strong"),S=g(e,"small");_.append(U,S),R.append(O,_);let C=g(e,"div");C.className="spotpatch-agent-health-list";let v=g(e,"p");v.className="spotpatch-agent-workspace",v.dataset.state="idle";let L=g(e,"p");L.className="spotpatch-agent-capability",L.dataset.state="idle",C.append(v,L),A.append(w,J,R,C);let te=g(e,"div");te.className="spotpatch-agent-job",te.hidden=!0;let Ee=g(e,"div");Ee.className="spotpatch-agent-job-meta";let $=g(e,"span");$.className="spotpatch-agent-model";let k=g(e,"span");k.className="spotpatch-agent-status",Ee.append($,k);let He=g(e,"p");He.className="spotpatch-agent-phase";let de=g(e,"p");de.className="spotpatch-agent-error",de.hidden=!0;let $e=g(e,"ul");$e.className="spotpatch-agent-activity";let Ae=g(e,"div");Ae.className="spotpatch-agent-result",Ae.hidden=!0;let ht=g(e,"p");ht.className="spotpatch-agent-summary";let le=g(e,"ul");le.className="spotpatch-agent-files";let We=g(e,"div");We.className="spotpatch-agent-checks";let xe=g(e,"pre");xe.className="spotpatch-agent-diff",xe.tabIndex=0,xe.setAttribute("aria-label",n.agent.diffAriaLabel),Ae.append(ht,le,We,xe),te.append(Ee,He,de,$e,Ae),s.append(d,A,te);let be=oe(e,n.agent.testConnection),Re=oe(e,n.agent.run,"spotpatch-run"),Y=oe(e,n.agent.cancel),_e=oe(e,n.agent.apply,"spotpatch-primary"),Ke=oe(e,n.agent.revert),Je=oe(e,n.agent.revise),Qe=t.enabled?t.providers:[],Xe=t.enabled&&t.applyMode==="trusted-auto",ne=t.enabled?t.applyMode:"review",xt=new Map(Qe.map(y=>[y.id,y])),et=!1,tt=!0,Be=!1,ze=!1,j=!1,Ce=!1,Te,nt,st=[],yt,fe="idle",je=n.agent.connectionNotTested,ot,ve="idle",rt,Le;for(let y of Qe)Vt(e,I,y.id,y.label);t.enabled&&(I.value=t.defaultProvider);let P,ct,re;ne==="auto"?re=Vt(e,r,"auto",n.agent.autoGated):(P=Vt(e,r,"review",n.agent.review),Xe&&(ct=Vt(e,r,"trusted-auto",n.agent.trustedFast)));let Z=Xe?"review":ne;r.value=Z,T.hidden=!Xe;let Ge=()=>r.value==="trusted-auto"?"trusted-auto":Z,qe=()=>Ge()==="trusted-auto",me=()=>xt.get(I.value),bt=y=>y===void 0?n.agent.providerUnavailable:qe()?n.agent.trustedFastConsent(y.label):n.agent.consent(y.label),Pe=()=>qe()?G.checked:O.checked,Ie=()=>{let y=qe();J.classList.toggle("spotpatch-trusted-consent",y),l.textContent=y?n.agent.trustedFast:ne==="auto"?n.agent.autoGated:n.agent.review,h.textContent=bt(me()),R.hidden=y||ve!=="consent-required"},Ye=()=>{let y=me();if(K.replaceChildren(),y===void 0){h.textContent=bt(y);return}for(let W of y.models)Vt(e,K,W.id,W.label);K.value=y.defaultModel,h.textContent=bt(y)},Q=()=>{let y=t.enabled&&Be&&!ze;Re.textContent=j?n.agent.verifying:n.agent.run,Re.classList.toggle("spotpatch-primary",Ce),be.hidden=!y,Re.hidden=!y,be.disabled=!tt||j||me()===void 0,Re.disabled=!tt||j||!et||!G.checked||ve==="idle"||ve==="checking"||ve==="blocked"||ve==="consent-required"&&!Pe()||me()===void 0||K.value.length===0,(!ze||!Be)&&(Y.hidden=!0,_e.hidden=!0,Ke.hidden=!0,Je.hidden=!0)},Ue=()=>{if(ve==="idle")v.textContent=n.agent.workspaceNotChecked;else if(ve==="checking")v.textContent=n.agent.checkingWorkspace;else if(ve==="ready")v.textContent=n.agent.workspaceReady;else if(ve==="consent-required"){let y=rt?.changes;v.textContent=n.agent.workspaceDirty(y?.staged??0,y?.unstaged??0,y?.untracked??0)}else v.textContent=Le===void 0?n.errors.INTERNAL_ERROR:n.errors[Le]};function c(){Ye(),G.checked=!1,L.dataset.state="idle",L.textContent=n.agent.connectionNotTested,fe="idle",je=n.agent.connectionNotTested,ot=void 0,Ce=!1,Q()}function u(){L.dataset.state="idle",L.textContent=n.agent.connectionNotTested,fe="idle",je=n.agent.connectionNotTested,ot=void 0,Ce=!1,Q()}function E(){G.checked=!1,O.checked=!1,Ie(),Q()}Ye(),r.addEventListener("change",E),I.addEventListener("change",c),K.addEventListener("change",u),G.addEventListener("change",Q),O.addEventListener("change",Q);function H(){if(Te===void 0)return;let y=Te,W=nt;$.textContent=`${y.providerLabel} · ${y.modelLabel}`,k.textContent=n.agent.status(y.status),He.textContent=y.phaseMessage;let pe=yt??y.errorCode;de.hidden=pe===void 0,de.textContent=pe===void 0?"":n.errors[pe],$e.replaceChildren();for(let se of st.slice(-8)){let Ne=g(e,"li");Ne.dataset.state=se.state,Ne.textContent=se.label,$e.append(Ne)}Ae.hidden=W===void 0,ht.textContent=W?.summary??"",le.replaceChildren(),We.replaceChildren(),xe.textContent=W?.diff??"";for(let se of W?.files??[]){let Ne=g(e,"li");Ne.textContent=`${se.kind} ${se.relativePath} (+${String(se.additions)} / -${String(se.deletions)})`,le.append(Ne)}for(let se of W?.checks??[]){let Ne=g(e,"details"),_t=g(e,"summary");_t.textContent=`${se.label}: ${se.status} · ${String(se.durationMs)} ms`;let Lt=g(e,"pre");Lt.textContent=se.output.length===0?n.agent.noOutput:se.output,Ne.append(_t,Lt),We.append(Ne)}be.hidden=!0,Re.hidden=!0,Y.hidden=!Be||!y.canCancel,Y.textContent=y.status==="awaiting-review"?n.agent.discard:n.agent.cancel,_e.hidden=!Be||!y.canApply,Ke.hidden=!Be||!y.canRevert,Je.hidden=!Be||!["completed","cancelled","reverted","failed"].includes(y.status)}function V(){n=o.messages(),i.textContent=n.agent.title,N.textContent=n.agent.mode,P!==void 0&&(P.textContent=n.agent.review),ct!==void 0&&(ct.textContent=n.agent.trustedFast),re!==void 0&&(re.textContent=n.agent.autoGated),M.textContent=n.agent.provider,x.textContent=n.agent.model,I.setAttribute("aria-label",n.agent.providerAriaLabel),K.setAttribute("aria-label",n.agent.modelAriaLabel),U.textContent=n.agent.includeLocalChanges,S.textContent=n.agent.includeLocalChangesHelp,xe.setAttribute("aria-label",n.agent.diffAriaLabel),be.textContent=n.agent.testConnection,_e.textContent=n.agent.apply,Ke.textContent=n.agent.revert,Je.textContent=n.agent.revise,Ie(),fe==="idle"?L.textContent=n.agent.connectionNotTested:fe==="probing"?L.textContent=n.agent.testingCapability:fe==="ready"?L.textContent=`${n.agent.capabilityVerified} · ${n.agent.toolsReady}`:ot!==void 0?L.textContent=n.errors[ot]:me()===void 0?L.textContent=n.agent.providerUnavailable:L.textContent=je,Ue(),Q(),H()}let ie=o.subscribe(V);return V(),Object.freeze({root:s,modeSelect:r,providerSelect:I,modelSelect:K,consentCheckbox:G,workspaceConsentCheckbox:O,testButton:be,runButton:Re,cancelButton:Y,applyButton:_e,revertButton:Ke,resetButton:Je,consentGranted(){return G.checked},workspaceConsentGranted(){return Pe()},readSelection(){let y=me(),W=y?.models.find(pe=>pe.id===K.value);return y===void 0||W===void 0?void 0:Object.freeze({applyMode:Ge(),providerProfileId:y.id,modelProfileId:W.id})},renderCapability(y,W,pe,se){fe=y,je=W,ot=se,j=y==="probing",Ce=y==="ready"&&pe?.state==="agent-ready",L.dataset.state=y,L.textContent=pe?.state==="agent-ready"?`${W} · ${n.agent.toolsReady}`:W,Q()},renderWorkspaceHealth(y,W,pe){ve=y,rt=W,Le=pe??W?.errorCode,v.dataset.state=y,y!=="checking"&&(R.hidden=qe()||y!=="consent-required"),(y==="idle"||y==="ready"||y==="blocked")&&(O.checked=!1),Ue(),Q()},renderJob(y,W,pe,se){ze=!0,A.hidden=!0,te.hidden=!1,I.disabled=!0,K.disabled=!0,r.disabled=!0,G.disabled=!0,O.disabled=!0,Te=y,nt=W,st=pe,yt=se,H()},resetJob(){ze=!1,Te=void 0,nt=void 0,st=[],yt=void 0,A.hidden=!1,te.hidden=!0,I.disabled=!1,K.disabled=!1,r.disabled=!1,G.disabled=!1,O.disabled=!1,$e.replaceChildren(),le.replaceChildren(),We.replaceChildren(),xe.textContent="",de.textContent="",de.hidden=!0,Q()},setContextReady(y){et=y,Q()},setEditingEnabled(y){tt=y,I.disabled=!y||ze,K.disabled=!y||ze,r.disabled=!y||ze,G.disabled=!y||ze,O.disabled=!y||ze,Q()},setProviderConsent(y){G.checked=y,Q()},setSelectionVisible(y){Be=y,Q(),y||(Y.hidden=!0,_e.hidden=!0,Ke.hidden=!0,Je.hidden=!0)},dispose(){ie(),I.removeEventListener("change",c),K.removeEventListener("change",u),r.removeEventListener("change",E),G.removeEventListener("change",Q),O.removeEventListener("change",Q)}})}var er="http://www.w3.org/2000/svg",hi="";function yi(e){if(e!==void 0)return{content:e,viewBox:"0 0 512 512"};let t=typeof __SPOTPATCH_BRAND_MARK_CONTENT__=="string"?__SPOTPATCH_BRAND_MARK_CONTENT__:void 0;return typeof t=="string"?{content:t,viewBox:"0 0 512 512"}:{content:hi,viewBox:"0 0 1 1"}}function bi(e,t,o){let n=e.createElementNS(er,t);for(let[s,d]of Object.entries(o))n.setAttribute(s,d);return n}function Si(e,t){let o=t.replace(/[^a-zA-Z0-9_-]/gu,"-"),n=new Map;for(let s of e.querySelectorAll("[id]")){let d=s.id,i=`${o}-${d}`;n.set(d,i),s.id=i}for(let s of[e,...e.querySelectorAll("*")])for(let d of[...s.attributes]){let i=d.value;for(let[l,A]of n)i=i.replaceAll(`url(#${l})`,`url(#${A})`),i===`#${l}`&&(i=`#${A}`);i!==d.value&&s.setAttribute(d.name,i)}}function In(e,t,o){let n=yi(t),s=bi(e,"svg",{xmlns:er,class:"spotpatch-brand-mark",viewBox:n.viewBox,"aria-hidden":"true",focusable:"false"});return s.innerHTML=n.content,o!==void 0&&Si(s,o),s}var Ei=Symbol.for("spotpatch.data-flow.extension.v1");function Wt(e=globalThis){return e[Ei]}var Ai=Symbol.for("spotpatch.external-handoff.v1");function dn(){return globalThis[Ai]}var xi=Symbol.for("spotpatch.motion.v1");function tr(){return globalThis[xi]}var Ri=Object.freeze({queued:"Queued",preparing:"Preparing",running:"Running",validating:"Validating","awaiting-review":"Awaiting review",applying:"Applying",applied:"Applied",completed:"Completed",cancelling:"Cancelling",cancelled:"Cancelled",reverting:"Reverting",reverted:"Reverted",failed:"Failed"}),Ci=Object.freeze({queued:"已排队",preparing:"准备中",running:"执行中",validating:"验证中","awaiting-review":"等待审阅",applying:"应用中",applied:"已应用",completed:"已完成",cancelling:"取消中",cancelled:"已取消",reverting:"撤销中",reverted:"已撤销",failed:"失败"}),Ti=Object.freeze({prepare:"Preparing context",dispatch:"Dispatching context",discover:"Discovering project files",search:"Searching source",read:"Reading",patch:"Generating a minimal patch",check:"Running",audit:"Auditing proposed changes",apply:"Applying verified changes",sync:"Returning results to SpotPatch",unknown:"Processing the current task"}),vi=Object.freeze({prepare:"正在准备上下文",dispatch:"正在派发上下文",discover:"正在查找项目文件",search:"正在搜索源码",read:"正在读取",patch:"正在生成最小修改补丁",check:"正在运行",audit:"正在审计候选修改",apply:"正在应用已验证修改",sync:"正在将结果回流 SpotPatch",unknown:"正在处理当前任务"}),nr=Object.freeze({prepare:"prepare",dispatch:"dispatch",discover:"list",search:"search",read:"read",patch:"patch",check:"check",audit:"audit",apply:"apply",sync:"sync",unknown:"agent"});function or(e,t,o){return o===void 0||o.length===0?e[t]:`${e[t]} ${o}`}function rr(e,t){return t===void 0||t.length===0?nr[e]:`${nr[e]} · ${t}`}var he="The external Agent handoff request failed.",ye="外部 Agent 交接请求失败。",wi=Object.freeze({[p.INVALID_REQUEST]:"The Agent request was rejected as invalid.",[p.INVALID_TOKEN]:"The local SpotPatch session expired.",[p.ORIGIN_NOT_ALLOWED]:"The current page origin is not authorized.",[p.SOURCE_NOT_FOUND]:"The selected source is no longer available.",[p.SOURCE_OUTSIDE_ROOT]:"The selected source is outside the project.",[p.SOURCE_TOO_LARGE]:"The selected source exceeds the safety limit.",[p.EDITOR_OPEN_FAILED]:"The editor request failed.",[p.DATA_FLOW_DISABLED]:"Component data-flow analysis is disabled.",[p.DATA_FLOW_SOURCE_STALE]:"The selected source changed. Select the component again.",[p.DATA_FLOW_ANALYSIS_CANCELLED]:"Component data-flow analysis was cancelled.",[p.AI_DISABLED]:"AI execution is disabled in Vite configuration.",[p.PROVIDER_NOT_CONFIGURED]:"The provider Key environment variable is missing on the Vite process.",[p.PROVIDER_AUTH_FAILED]:"The provider rejected authentication. Check the server-side Key.",[p.PROVIDER_PROTOCOL_UNSUPPORTED]:"The relay does not match the configured OpenAI-compatible protocol.",[p.MODEL_NOT_ALLOWED]:"The selected model profile is not allowed.",[p.MODEL_TOOL_CALL_UNSUPPORTED]:"The selected model did not start or continue the required tool call.",[p.PROVIDER_RATE_LIMITED]:"The provider is rate limited. Wait and try again.",[p.AGENT_BUSY]:"Another write Agent job is still active.",[p.AGENT_LIMIT_EXCEEDED]:"The Agent stopped at a configured time, turn, output, or size limit.",[p.AGENT_CANCELLED]:"The Agent job was cancelled.",[p.EXTERNAL_HANDOFF_DISABLED]:he,[p.EXTERNAL_HANDOFF_UNAVAILABLE]:he,[p.HANDOFF_VALIDATION_FAILED]:he,[p.HANDOFF_SOURCE_STALE]:he,[p.HANDOFF_NOT_FOUND]:he,[p.HANDOFF_EXPIRED]:he,[p.HANDOFF_CURSOR_INVALID]:he,[p.HANDOFF_RESPONSE_TOO_LARGE]:he,[p.BRIDGE_UNAUTHORIZED]:he,[p.BRIDGE_PROTOCOL_MISMATCH]:he,[p.BRIDGE_BUSY]:he,[p.EXTERNAL_AGENT_BUSY]:he,[p.ACTIVE_ADAPTER_CONFLICT]:he,[p.ACTIVE_ADAPTER_LEASE_INVALID]:he,[p.ACTIVE_DISPATCH_INVALID]:he,[p.SESSION_NOT_FOUND]:he,[p.SESSION_AMBIGUOUS]:he,[p.SESSION_CLOSED]:he,[p.WORKTREE_DIRTY]:"Confirm inclusion of local changes before running AI.",[p.WORKTREE_NOT_REPOSITORY]:"Vite root must be an initialized Git repository root.",[p.WORKTREE_OPERATION_IN_PROGRESS]:"Finish the active merge, rebase, cherry-pick, or revert.",[p.WORKTREE_CONFLICTED]:"Resolve all Git conflicts before running AI.",[p.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"Reduce untracked files below the safe count and size limits.",[p.WORKTREE_UNTRACKED_UNSUPPORTED]:"An untracked path is missing, linked, or not a regular file.",[p.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"Local changes cannot be isolated safely.",[p.TOOL_DENIED]:"A tool request violated local safety policy.",[p.TOOL_INPUT_INVALID]:"Invalid tool request.",[p.TOOL_ARGUMENTS_INVALID]:"Tool arguments are invalid.",[p.TOOL_CALL_ID_CONFLICT]:"Tool ID conflicts in this turn.",[p.TOOL_PATH_DENIED]:"The model requested a protected or external path.",[p.PATCH_REJECTED]:"The patch violated local policy.",[p.VALIDATION_FAILED]:"Required checks failed; changes cannot be applied.",[p.APPLY_CONFLICT]:"Agent-touched files changed; nothing was overwritten.",[p.INTERNAL_ERROR]:"The Agent failed without exposing private details."}),Oi=Object.freeze({[p.INVALID_REQUEST]:"Agent 请求无效,已被拒绝。",[p.INVALID_TOKEN]:"本地 SpotPatch 会话已失效。",[p.ORIGIN_NOT_ALLOWED]:"当前页面来源未获授权。",[p.SOURCE_NOT_FOUND]:"选中目标对应的源码已不可用。",[p.SOURCE_OUTSIDE_ROOT]:"选中源码位于项目根目录之外。",[p.SOURCE_TOO_LARGE]:"选中源码超过安全大小限制。",[p.EDITOR_OPEN_FAILED]:"编辑器打开请求失败。",[p.DATA_FLOW_DISABLED]:"组件数据链路分析未启用。",[p.DATA_FLOW_SOURCE_STALE]:"选中源码已经变化,请重新选择组件。",[p.DATA_FLOW_ANALYSIS_CANCELLED]:"组件数据链路分析已取消。",[p.AI_DISABLED]:"Vite 配置未启用 AI 执行。",[p.PROVIDER_NOT_CONFIGURED]:"启动 Vite 的进程中缺少模型服务 Key 环境变量。",[p.PROVIDER_AUTH_FAILED]:"模型服务鉴权失败,请检查服务端 Key。",[p.PROVIDER_PROTOCOL_UNSUPPORTED]:"中转服务与配置的 OpenAI 兼容协议不一致。",[p.MODEL_NOT_ALLOWED]:"当前模型配置未获授权。",[p.MODEL_TOOL_CALL_UNSUPPORTED]:"当前模型未完成必要的工具调用或结果续接。",[p.PROVIDER_RATE_LIMITED]:"模型服务正在限流,请稍后重试。",[p.AGENT_BUSY]:"当前项目已有一个写入任务正在运行。",[p.AGENT_LIMIT_EXCEEDED]:"Agent 达到时间、轮次、输出或变更规模限制。",[p.AGENT_CANCELLED]:"Agent 任务已取消。",[p.EXTERNAL_HANDOFF_DISABLED]:ye,[p.EXTERNAL_HANDOFF_UNAVAILABLE]:ye,[p.HANDOFF_VALIDATION_FAILED]:ye,[p.HANDOFF_SOURCE_STALE]:ye,[p.HANDOFF_NOT_FOUND]:ye,[p.HANDOFF_EXPIRED]:ye,[p.HANDOFF_CURSOR_INVALID]:ye,[p.HANDOFF_RESPONSE_TOO_LARGE]:ye,[p.BRIDGE_UNAUTHORIZED]:ye,[p.BRIDGE_PROTOCOL_MISMATCH]:ye,[p.BRIDGE_BUSY]:ye,[p.EXTERNAL_AGENT_BUSY]:ye,[p.ACTIVE_ADAPTER_CONFLICT]:ye,[p.ACTIVE_ADAPTER_LEASE_INVALID]:ye,[p.ACTIVE_DISPATCH_INVALID]:ye,[p.SESSION_NOT_FOUND]:ye,[p.SESSION_AMBIGUOUS]:ye,[p.SESSION_CLOSED]:ye,[p.WORKTREE_DIRTY]:"运行 AI 前,请明确同意将当前本地修改纳入隔离基线。",[p.WORKTREE_NOT_REPOSITORY]:"Vite 根目录不是已初始化 Git 仓库的顶层目录。",[p.WORKTREE_OPERATION_IN_PROGRESS]:"请先完成当前 merge、rebase、cherry-pick 或 revert,再运行 AI。",[p.WORKTREE_CONFLICTED]:"请先解决全部 Git 冲突,再运行 AI。",[p.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"未跟踪文件超过安全数量或体积上限,请先精简。",[p.WORKTREE_UNTRACKED_UNSUPPORTED]:"未跟踪项已丢失、是符号链接或不是普通文件。",[p.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"当前本地修改无法安全隔离。",[p.TOOL_DENIED]:"工具请求违反本地安全策略。",[p.TOOL_INPUT_INVALID]:"工具请求无效。",[p.TOOL_ARGUMENTS_INVALID]:"工具参数无效。",[p.TOOL_CALL_ID_CONFLICT]:"本轮工具 ID 冲突。",[p.TOOL_PATH_DENIED]:"模型请求了受保护或项目外路径。",[p.PATCH_REJECTED]:"补丁违反本地策略。",[p.VALIDATION_FAILED]:"必需检查失败,无法应用变更。",[p.APPLY_CONFLICT]:"Agent 触及文件已变化,未覆盖。",[p.INTERNAL_ERROR]:"Agent 失败,未暴露私有细节。"}),_i=Object.freeze({adapter:"React adapter",api:"API",apiStatuses:Object.freeze({connected:"connected",failed:"failed",loading:"loading","not-required":"not required"}),available:"available",boundary:"Boundary",boundaries:Object.freeze({component:"component","nearby-lines":"nearby lines"}),browserContext:"Browser context",collectionStatuses:Object.freeze({failed:"failed",loading:"loading",ready:"ready"}),component:"Component",confidence:"Confidence",confidenceLabels:Object.freeze({exact:"exact element source",probable:"probable owning component",approximate:"nearest business container",unknown:"source not found"}),cssWarnings:"CSS warnings",lineLocation:(e,t)=>`line ${String(e)}${t===void 0?"":`, column ${String(t)}`}`,origin:"Origin",source:"Source",sourceContext:"Source context",stack:"Stack",target:(e,t)=>`Target ${String(e)}${t?" (active)":""}`,unavailable:"unavailable",unsupported:"unsupported",warning:"Warning"}),Li=Object.freeze({adapter:"React 适配器",api:"API",apiStatuses:Object.freeze({connected:"已连接",failed:"失败",loading:"加载中","not-required":"无需请求"}),available:"可用",boundary:"代码边界",boundaries:Object.freeze({component:"完整组件","nearby-lines":"附近代码"}),browserContext:"浏览器上下文",collectionStatuses:Object.freeze({failed:"失败",loading:"采集中",ready:"已就绪"}),component:"组件",confidence:"置信度",confidenceLabels:Object.freeze({exact:"精确元素源码",probable:"可能的所属组件",approximate:"最近业务容器",unknown:"未找到源码"}),cssWarnings:"CSS 警告",lineLocation:(e,t)=>`第 ${String(e)} 行${t===void 0?"":`,第 ${String(t)} 列`}`,origin:"定位来源",source:"源码",sourceContext:"源码上下文",stack:"组件栈",target:(e,t)=>`目标 ${String(e)}${t?"(当前)":""}`,unavailable:"不可用",unsupported:"不支持",warning:"警告"}),Pi=Object.freeze({"en-US":Object.freeze({localeName:"EN",alternateLocaleName:"中",switchLocale:"Switch interface language to Chinese",brand:Object.freeze({name:"SpotPatch",context:"Live context",repository:"GitHub ↗",repositoryTitle:"Star SpotPatch on GitHub"}),trigger:Object.freeze({select:"Select element",stop:"Stop selecting",title:e=>`Toggle SpotPatch (${e})`}),dialog:Object.freeze({close:"Close SpotPatch",editTitle:"Plan the change",editSubtitle:"Give each selected target its own precise instruction.",previewTitle:"Review the request",previewSubtitle:"Verify the complete context before it leaves the browser."}),floatingSurface:Object.freeze({dragHandle:"Drag to move the SpotPatch workbench",resetPosition:"Reset workbench position",positionReset:"SpotPatch position reset to the lower-right corner."}),context:Object.freeze({collecting:"Collecting context",ready:"Context ready",partial:"Partial context",sourceUnavailable:"Source unavailable",selectedElement:"Selected element",selectedCount:e=>`${String(e)} elements selected`}),targets:Object.freeze({title:"Selected targets",ariaLabel:"Selected targets and change instructions",count:(e,t)=>`${String(e)} of ${String(t)}`,complete:(e,t)=>`${String(e)} of ${String(t)} described`,instructionBudget:(e,t)=>`${String(e)} / ${String(t)} characters`,instructionBudgetExceeded:(e,t)=>`${String(e)} / ${String(t)} characters — reduce the request`,statusReady:"Ready",statusPartial:"Partial",statusCollecting:"Collecting",instructionReady:"Instruction added",instructionMissing:"Needs instruction",instructionLabel:e=>`Change for ${e}`,instructionPlaceholder:"Describe the desired result for this target, including constraints…",instructionCount:(e,t)=>`${String(e)} / ${String(t)}`,activate:e=>`Edit target ${String(e)}`,remove:e=>`Remove target ${String(e)}`,removeTitle:"Remove target",addTitle:"Add another element to this request",limitTitle:e=>`Selection limit reached (${String(e)})`}),diagnostics:Object.freeze({title:"Captured context",resolving:"Resolving source…",noExactSource:"No exact source marker",promptAriaLabel:"Generated prompt"}),summary:_i,actions:Object.freeze({addElement:"Add element",reselect:"Start over",openEditor:"Open source",openTarget:e=>`Open source for target ${String(e)}`,preview:"Preview prompt",copy:"Copy prompt",back:"Back to edit"}),agent:Object.freeze({title:"AI code agent",mode:"Execution mode",review:"Review",autoGated:"Auto gated",trustedFast:"Trusted direct",provider:"Provider",model:"Model",providerAriaLabel:"AI provider",modelAriaLabel:"AI model",providerUnavailable:"Provider configuration is unavailable.",consent:e=>`I understand selected context and allowed source may be sent to ${e}; its data policy is my responsibility.`,trustedFastConsent:e=>`Enable trusted direct mode for ${e}: send allowed project context, include current local changes, skip project validation checks, and immediately apply AI changes, including file deletions and configuration changes.`,connectionNotTested:"Optional connection check not run",workspaceNotChecked:"Local workspace not checked",checkingWorkspace:"Checking Git workspace and isolated execution…",workspaceReady:"Local workspace is ready for isolated execution",workspaceDirty:(e,t,o)=>`Local changes found · ${String(e)} staged · ${String(t)} unstaged · ${String(o)} untracked`,includeLocalChanges:"Allow the Agent to continue from my current local changes",includeLocalChangesHelp:"The Agent may edit these files. SpotPatch preserves the baseline and applies or reverts only the Agent delta.",localChangesConsentRequired:"Confirm inclusion of current local changes before running AI.",capabilityVerified:"Agent capability verified",capabilityVerifiedAnnouncement:"AI provider capability verified.",testingCapability:"Testing authentication, tools, continuation, and streaming…",applying:"Applying changes to the project.",cancelling:"Cancelling Agent job.",reverting:"Reverting the applied Agent change.",consentRequired:"Confirm remote provider data transmission before running AI.",toolsReady:"tools and streaming ready",testConnection:"Check environment",verifying:"Verifying…",run:"Run AI",cancel:"Cancel agent",discard:"Discard changes",apply:"Apply changes",revert:"Revert changes",revise:"Revise request",diffAriaLabel:"Proposed source diff",noOutput:"No output.",status:e=>Ri[e]}),execution:Object.freeze({claude:"Claude",codex:"Codex",receivingTitle:"Receiving context",dispatchingTitle:e=>`Handing off to ${e}`,runningTitle:e=>`Modifying ${e}`,expandedRunningTitle:e=>`${e} is making changes`,completedTitle:"Change complete",expandedCompletedTitle:"Changes complete",failedTitle:"Execution failed",receivingStatus:"Receiving",dispatchingStatus:"Dispatching",runningStatus:"Running",checkingStatus:"Checking",completedStatus:"Done",failedStatus:"Failed",resultReturned:"The result is back in SpotPatch",resultSummary:e=>`${String(e)} ${e===1?"file":"files"}`,activityAction:(e,t)=>or(Ti,e,t),activityLane:rr}),announcements:Object.freeze({adapterDisabled:"React inspection was disabled after an adapter failure.",selectionEnabled:"Element selection enabled.",chooseAnother:"Choose another element.",reselectAfterChange:"Choose the current elements again after the file change.",sourceLoaded:"Source context loaded.",sourceFailed:"Source context could not be loaded.",addCancelled:"Additional selection cancelled.",selectionLimit:e=>`The selection limit of ${String(e)} elements has been reached.`,chooseAdditional:(e,t)=>`Choose another element. ${String(e)} of ${String(t)} selected.`,duplicate:"That source target is already selected.",sourceProbable:"A probable React component was found without an authorized file token.",sourceMissing:"No authorized source marker was found for the selected element.",noSelectable:"No selectable element was found.",allTargetsRemoved:"All targets were removed. Choose an element to continue.",targetRemoved:"Selected target removed.",detachedTargetPreserved:"The page element was unloaded; its collected context remains selected.",contextWarning:"Browser context collection completed with a warning.",contextCollected:"Browser context collected.",editorOpening:"Opening source…",editorOpened:"Source opened in the editor.",editorFailed:"Could not open the editor. Start it or configure editor.",completeInstructions:"Add an instruction for every target and wait for context collection to finish.",promptCopied:"Prompt copied to the clipboard.",clipboardUnavailable:"Clipboard access is unavailable. Select the prompt manually.",copyFailed:"Copy failed. Select the prompt manually.",appliedTargetsDetached:"Changes applied. Reselect page elements after HMR before creating another request."}),errors:wi}),"zh-CN":Object.freeze({localeName:"中",alternateLocaleName:"EN",switchLocale:"将界面语言切换为英文",brand:Object.freeze({name:"SpotPatch",context:"实时上下文",repository:"GitHub ↗",repositoryTitle:"在 GitHub 上 Star SpotPatch"}),trigger:Object.freeze({select:"选择元素",stop:"停止选择",title:e=>`切换 SpotPatch(${e})`}),dialog:Object.freeze({close:"关闭 SpotPatch",editTitle:"规划本次修改",editSubtitle:"为每个选中目标分别写清楚修改要求。",previewTitle:"审阅修改请求",previewSubtitle:"发送给 AI 前,请核对完整上下文与每项目标说明。"}),floatingSurface:Object.freeze({dragHandle:"拖拽以移动 SpotPatch 工作台",resetPosition:"重置工作台位置",positionReset:"SpotPatch 已恢复到右下角。"}),context:Object.freeze({collecting:"正在采集上下文",ready:"上下文已就绪",partial:"部分上下文可用",sourceUnavailable:"源码位置不可用",selectedElement:"已选元素",selectedCount:e=>`已选择 ${String(e)} 个元素`}),targets:Object.freeze({title:"修改目标",ariaLabel:"已选目标与逐项目标说明",count:(e,t)=>`${String(e)} / ${String(t)}`,complete:(e,t)=>`已描述 ${String(e)} / ${String(t)}`,instructionBudget:(e,t)=>`说明字符 ${String(e)} / ${String(t)}`,instructionBudgetExceeded:(e,t)=>`说明字符 ${String(e)} / ${String(t)},请精简后继续`,statusReady:"已就绪",statusPartial:"部分可用",statusCollecting:"采集中",instructionReady:"已填写修改说明",instructionMissing:"待填写修改说明",instructionLabel:e=>`${e} 的修改说明`,instructionPlaceholder:"描述这个目标期望达到的结果,以及不能破坏的约束……",instructionCount:(e,t)=>`${String(e)} / ${String(t)}`,activate:e=>`编辑目标 ${String(e)}`,remove:e=>`移除目标 ${String(e)}`,removeTitle:"移除目标",addTitle:"继续为本次请求选择元素",limitTitle:e=>`已达到 ${String(e)} 个目标的上限`}),diagnostics:Object.freeze({title:"已采集上下文",resolving:"正在解析源码……",noExactSource:"没有精确源码标记",promptAriaLabel:"生成的 Prompt"}),summary:Li,actions:Object.freeze({addElement:"添加元素",reselect:"重新开始",openEditor:"打开源码",openTarget:e=>`打开目标 ${String(e)} 的源码`,preview:"预览 Prompt",copy:"复制 Prompt",back:"返回编辑"}),agent:Object.freeze({title:"AI 代码 Agent",mode:"执行方式",review:"审阅模式",autoGated:"受控自动模式",trustedFast:"可信极速模式",provider:"模型服务",model:"模型",providerAriaLabel:"AI 模型服务",modelAriaLabel:"AI 模型",providerUnavailable:"模型服务配置不可用。",consent:e=>`我了解选中上下文与获准源码可能发送到 ${e},并自行负责其数据策略。`,trustedFastConsent:e=>`为 ${e} 启用可信极速模式:发送获准的项目上下文、纳入当前本地修改、跳过项目验证检查,并立即应用 AI 变更,包括删除文件与配置变更。`,connectionNotTested:"尚未执行可选连接检查",workspaceNotChecked:"尚未检查本地工作区",checkingWorkspace:"正在检查 Git 工作区与隔离执行环境……",workspaceReady:"本地工作区已满足隔离执行条件",workspaceDirty:(e,t,o)=>`发现本地修改 · 暂存 ${String(e)} · 未暂存 ${String(t)} · 未跟踪 ${String(o)}`,includeLocalChanges:"允许 Agent 基于我当前的本地修改继续",includeLocalChangesHelp:"Agent 可能继续修改这些文件;SpotPatch 会保留原基线,仅应用或撤销 Agent 自己的增量。",localChangesConsentRequired:"运行 AI 前,请确认允许纳入当前本地修改。",capabilityVerified:"Agent 能力验证通过",capabilityVerifiedAnnouncement:"AI 模型服务能力验证通过。",testingCapability:"正在验证鉴权、工具调用、连续调用与流式响应……",applying:"正在将变更应用到项目。",cancelling:"正在取消 Agent 任务。",reverting:"正在撤销已应用的 Agent 变更。",consentRequired:"运行 AI 前,请先确认允许向远程模型服务传输数据。",toolsReady:"工具调用与流式响应已就绪",testConnection:"检查运行环境",verifying:"验证中……",run:"运行 AI",cancel:"取消 Agent",discard:"放弃变更",apply:"应用变更",revert:"撤销变更",revise:"修改请求",diffAriaLabel:"建议的源码差异",noOutput:"没有输出。",status:e=>Ci[e]}),execution:Object.freeze({claude:"Claude",codex:"Codex",receivingTitle:"正在接收上下文",dispatchingTitle:e=>`正在交接给 ${e}`,runningTitle:e=>`正在修改 ${e}`,expandedRunningTitle:e=>`${e} 正在执行修改`,completedTitle:"修改完成",expandedCompletedTitle:"修改已完成",failedTitle:"执行失败",receivingStatus:"接收中",dispatchingStatus:"派发中",runningStatus:"执行中",checkingStatus:"检查中",completedStatus:"完成",failedStatus:"失败",resultReturned:"结果已回流 SpotPatch",resultSummary:e=>`${String(e)} 个文件`,activityAction:(e,t)=>or(vi,e,t),activityLane:rr}),announcements:Object.freeze({adapterDisabled:"React 适配器异常,本次会话已停用 React 检查。",selectionEnabled:"元素选择已启用。",chooseAnother:"请选择另一个元素。",reselectAfterChange:"文件变更后,请重新选择当前页面元素。",sourceLoaded:"源码上下文已加载。",sourceFailed:"源码上下文加载失败。",addCancelled:"已取消追加选择。",selectionLimit:e=>`已达到 ${String(e)} 个元素的选择上限。`,chooseAdditional:(e,t)=>`请选择另一个元素,当前已选 ${String(e)} / ${String(t)}。`,duplicate:"该源码目标已经在当前选择中。",sourceProbable:"找到可能的 React 组件,但没有获授权的源码标记。",sourceMissing:"选中元素没有获授权的源码标记。",noSelectable:"当前位置没有可选择的元素。",allTargetsRemoved:"已移除全部目标,请重新选择元素。",targetRemoved:"已移除选中目标。",detachedTargetPreserved:"页面元素已卸载,已采集的上下文仍保留在选择中。",contextWarning:"浏览器上下文采集完成,但存在警告。",contextCollected:"浏览器上下文采集完成。",editorOpening:"正在打开源码……",editorOpened:"源码已在编辑器中打开。",editorFailed:"无法打开编辑器。请先启动编辑器或检查 editor 配置。",completeInstructions:"请为每个目标填写修改说明,并等待上下文采集完成。",promptCopied:"Prompt 已复制到剪贴板。",clipboardUnavailable:"无法访问剪贴板,请手动选择并复制 Prompt。",copyFailed:"复制失败,请手动选择并复制 Prompt。",appliedTargetsDetached:"变更已应用;HMR 后请重新选择页面元素再发起新请求。"}),errors:Oi})});function ar(e){if(e===void 0||e.trim().length===0)return;let t=e.trim().toLowerCase();return t==="zh"||t.startsWith("zh-")?"zh-CN":t==="en"||t.startsWith("en-")?"en-US":void 0}function Ii(e,t){if(e!=="auto")return e;let o=ar(t.documentElement.lang);return o!==void 0?o:t.defaultView?.navigator.languages.map(ar).find(s=>s!==void 0)??"en-US"}function ir(e,t="auto"){let o=Ii(t,e),n=new Set;return Object.freeze({locale:()=>o,messages:()=>Pi[o],subscribe(s){return n.add(s),()=>{n.delete(s)}},toggle(){o=o==="en-US"?"zh-CN":"en-US";for(let s of n)s()}})}var Ni="spotpatch:floating-surface:";function ki(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function sr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function cr(e){return e==="start"||e==="end"}function Di(e){let t=ki(e);if(!(t?.version!==1||!cr(t.horizontal)||!cr(t.vertical)||!sr(t.xRatio)||!sr(t.yRatio)))return Object.freeze({horizontal:t.horizontal,vertical:t.vertical,xRatio:t.xRatio,yRatio:t.yRatio})}function dr(e,t){let o=`${Ni}${t}`,n;try{n=e.sessionStorage}catch{n=void 0}return Object.freeze({clear(){try{n?.removeItem(o)}catch{}},load(){let s;try{s=n?.getItem(o)??null}catch{return}if(!(s===null||s.length>1024))try{return Di(JSON.parse(s))}catch{return}},save(s){try{n?.setItem(o,JSON.stringify({version:1,...s}))}catch{}}})}var ln=Object.freeze({horizontal:"end",vertical:"end",xRatio:1,yRatio:1});function Gt(e,t,o){return Math.min(Math.max(e,t),o)}function At(e){return Number.isFinite(e)?Math.max(0,e):0}function Nn(e){return Number.isFinite(e)?Gt(e,0,1):.5}function pr(e){return Object.freeze({height:At(e.height),left:Number.isFinite(e.left)?e.left:0,top:Number.isFinite(e.top)?e.top:0,width:At(e.width)})}function Fi(e,t){return t==="end"?e.left+e.width:e.left}function Mi(e,t){return t==="end"?e.top+e.height:e.top}function lr(e,t,o){return o<=0?.5:Nn((e-t)/o)}function kn(e,t,o,n){return Object.freeze({horizontal:o,vertical:n,xRatio:lr(e.x,t.left,t.width),yRatio:lr(e.y,t.top,t.height)})}function ur(e,t,o){let n=At(t.width),s=At(t.height),d=pr(o),i=d.width,l=d.height,A=d.left,w=d.top,T=A+i,N=w+l,r=A+Nn(e.xRatio)*i,F=w+Nn(e.yRatio)*l,M=e.horizontal==="end"?r-n:r,I=e.vertical==="end"?F-s:F,b=Math.max(A,T-n),x=Math.max(w,N-s);return Object.freeze({height:s,left:Gt(M,A,b),top:Gt(I,w,x),width:n})}function Dn(e,t,o){let n=At(o),s=At(e.width),d=At(e.height),i=pr(t),l=i.left+i.width,A=i.top+i.height,w=Math.max(i.left,l-s),T=Math.max(i.top,A-d),N=Gt(e.left,i.left,w),r=Gt(e.top,i.top,T),F=Math.abs(N-i.left),M=Math.abs(l-(N+s)),I=Math.abs(r-i.top),b=Math.abs(A-(r+d)),x=Math.min(F,M)<=n?F<=M?i.left:l-s:N,K=Math.min(I,b)<=n?I<=b?i.top:A-d:r;return Object.freeze({height:d,left:x,top:K,width:s})}function gr(e,t,o){let n=Dn(e,t,0),s=n.left+n.width/2,d=n.top+n.height/2,i=t.left+At(t.width)/2,l=t.top+At(t.height)/2,A=s===i?o.horizontal:s<i?"start":"end",w=d===l?o.vertical:d<l?"start":"end";return kn({x:Fi(n,A),y:Mi(n,w)},t,A,w)}function Mt(e,t=0){return Number.isFinite(e)?e:t}function Hi(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function $i(e){return e.button===0&&e.isPrimary}function Bi(e){let t=e.getBoundingClientRect();return Object.freeze({height:Math.max(0,Mt(t.height)),width:Math.max(0,Mt(t.width))})}function zi(e,t){return typeof e.requestAnimationFrame=="function"?e.requestAnimationFrame(t):e.setTimeout(()=>{t(Date.now())},0)}function fr(e,t){if(typeof e.cancelAnimationFrame=="function"){e.cancelAnimationFrame(t);return}e.clearTimeout(t)}function mr(e,t,o){let n=t.load()??ln,s,d,i,l,A=!1,w=new Set,T=new Set;function N(){let S=e.visualViewport,C=Math.max(0,Mt(S?.width??e.innerWidth)),v=Math.max(0,Mt(S?.height??e.innerHeight)),L=C<=o.compactViewportWidth?o.compactInset:o.desktopInset;return Object.freeze({height:Math.max(0,v-L*2),left:Mt(S?.offsetLeft??0)+L,top:Mt(S?.offsetTop??0)+L,width:Math.max(0,C-L*2)})}function r(){return N().width+o.compactInset*2<=o.compactViewportWidth}function F(S){if(S.hidden||S.dataset.motionMorphing==="true"&&S.dataset.floatingPositioned==="true")return;let C=Bi(S);if(C.width===0||C.height===0)return;let v=ur(n,C,N());return S.style.left=`${String(v.left)}px`,S.style.top=`${String(v.top)}px`,S.style.right="auto",S.style.bottom="auto",S.dataset.floatingPositioned="true",v}function M(){if(!A){d!==void 0&&(fr(e,d),d=void 0);for(let S of w)F(S)}}function I(){A||d!==void 0||(d=zi(e,()=>{d=void 0,M()}))}function b(S){n=S,t.save(n)}function x(S){let C=s;if(C!==void 0){s=void 0,C.handle.dataset.dragging="false",C.surface.dataset.dragging="false";try{C.handle.hasPointerCapture(C.pointerId)&&C.handle.releasePointerCapture(C.pointerId)}catch{}if(S){let v=F(C.surface);if(v!==void 0){let L=Dn(v,N(),o.edgeSnapDistance);b(gr(L,N(),n)),F(C.surface)}}else n=t.load()??ln,M()}}function K(S){let C=s;if(C===void 0||S.pointerId!==C.pointerId)return;let v=Object.freeze({x:S.clientX,y:S.clientY}),L=Object.freeze({x:C.startX,y:C.startY});C.handle.dataset.dragging!=="true"&&Hi(v,L)<o.dragActivationDistance||(C.handle.dataset.dragging!=="true"&&C.onDragStart?.(),C.handle.dataset.dragging="true",C.surface.dataset.dragging="true",n=kn({x:v.x+C.anchorOffsetX,y:v.y+C.anchorOffsetY},N(),n.horizontal,n.vertical),I(),S.preventDefault())}function J(S,C,v,L){S.addEventListener(C,v,L),T.add(()=>{S.removeEventListener(C,v,L)})}function G(S,C,v={}){let L=$=>{if(A||s!==void 0||!$i($)||v.canStartDrag?.($)===!1)return;let k=F(C)??C.getBoundingClientRect(),He=n.horizontal==="end"?k.left+k.width:k.left,de=n.vertical==="end"?k.top+k.height:k.top;s=Object.freeze({anchorOffsetX:He-$.clientX,anchorOffsetY:de-$.clientY,handle:S,...v.onDragStart===void 0?{}:{onDragStart:v.onDragStart},pointerId:$.pointerId,startX:$.clientX,startY:$.clientY,suppressClickOnDrag:v.suppressClickOnDrag??!1,surface:C});try{S.setPointerCapture($.pointerId)}catch{}},te=$=>{s?.pointerId===$.pointerId&&x(S.dataset.dragging==="true")},Ee=$=>{i===S&&(i=void 0,l!==void 0&&(e.clearTimeout(l),l=void 0),$.preventDefault(),$.stopImmediatePropagation())};J(S,"pointerdown",$=>{L($)}),J(S,"lostpointercapture",$=>{te($)}),J(S,"click",$=>{Ee($)},!0)}function h(){x(!1),n=ln,t.clear(),M()}function R(){x(!1)}function O(S){S.key!=="Escape"||s===void 0||(x(!1),S.preventDefault(),S.stopImmediatePropagation())}function _(S){if(s?.pointerId!==S.pointerId)return;let C=s,v=C.handle.dataset.dragging==="true";x(v),v&&C.suppressClickOnDrag&&(i=C.handle,l=e.setTimeout(()=>{i=void 0,l=void 0},0))}function U(S){s?.pointerId===S.pointerId&&x(!1)}return J(e,"pointermove",S=>{K(S)}),J(e,"pointerup",S=>{_(S)}),J(e,"pointercancel",S=>{U(S)}),J(e,"resize",I),J(e,"blur",R),J(e,"keydown",S=>{O(S)},!0),e.visualViewport?.addEventListener("resize",I),e.visualViewport?.addEventListener("scroll",I),T.add(()=>e.visualViewport?.removeEventListener("resize",I)),T.add(()=>e.visualViewport?.removeEventListener("scroll",I)),Object.freeze({attachDraggable:G,dispose(){if(!A){A=!0,x(!1),d!==void 0&&(fr(e,d),d=void 0),l!==void 0&&(e.clearTimeout(l),l=void 0),i=void 0;for(let S of T)S();T.clear(),w.clear()}},isCompact:r,reconcile:M,registerSurface(S){w.add(S)},requestReconcile:I,reset:h})}var ji=1500;function Ui(e){let t=new Set([...e.querySelectorAll("script[nonce]")].map(o=>o.nonce?.trim()??"").filter(Boolean));if(t.size===1)return t.values().next().value}function Vi(e){let t=e.createElement("style");return t.textContent=`
|
|
257
257
|
:host {
|
|
258
258
|
all: initial;
|
|
259
259
|
--spotpatch-bg: #0e0e12;
|
|
@@ -272,59 +272,26 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
272
272
|
--spotpatch-success: #34d399;
|
|
273
273
|
--spotpatch-warning: #f59e0b;
|
|
274
274
|
--spotpatch-text-on-accent: #0b0b12;
|
|
275
|
-
--spotpatch-radius-panel: 16px;
|
|
276
275
|
--spotpatch-radius-card: 10px;
|
|
277
|
-
--spotpatch-shadow-panel: 0 30px 60px -20px rgb(0 0 0 / 70%);
|
|
278
|
-
color-scheme: dark;
|
|
279
276
|
color: var(--spotpatch-text);
|
|
280
277
|
font-family: Inter, "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
281
278
|
font-size: 14px;
|
|
282
279
|
line-height: 1.5;
|
|
283
|
-
text-rendering: optimizeLegibility;
|
|
284
|
-
-webkit-font-smoothing: antialiased;
|
|
285
280
|
}
|
|
286
281
|
[hidden] { display: none !important; }
|
|
287
282
|
button, textarea, select { font: inherit; }
|
|
288
|
-
|
|
289
|
-
.spotpatch-trigger {
|
|
283
|
+
.spotpatch-floating-surface {
|
|
290
284
|
position: fixed;
|
|
291
|
-
right:
|
|
292
|
-
bottom:
|
|
293
|
-
z-index: ${String(
|
|
294
|
-
|
|
295
|
-
align-items: center;
|
|
296
|
-
gap: 10px;
|
|
297
|
-
min-height: 44px;
|
|
298
|
-
border: 1px solid rgb(255 255 255 / 12%);
|
|
299
|
-
border-radius: 999px;
|
|
300
|
-
padding: 10px 17px;
|
|
301
|
-
color: #f8fafc;
|
|
302
|
-
background: #171b23;
|
|
303
|
-
box-shadow: 0 12px 34px rgb(0 0 0 / 25%), inset 0 1px rgb(255 255 255 / 5%);
|
|
304
|
-
cursor: pointer;
|
|
305
|
-
font-size: 14px;
|
|
306
|
-
font-weight: 650;
|
|
307
|
-
transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
|
|
308
|
-
}
|
|
309
|
-
.spotpatch-trigger::before {
|
|
310
|
-
width: 9px;
|
|
311
|
-
height: 9px;
|
|
312
|
-
border-radius: 999px;
|
|
313
|
-
background: var(--spotpatch-accent);
|
|
314
|
-
box-shadow: 0 0 0 4px rgb(99 102 241 / 10%);
|
|
315
|
-
content: "";
|
|
316
|
-
}
|
|
317
|
-
.spotpatch-trigger:hover { transform: translateY(-1px); border-color: rgb(129 140 248 / 52%); }
|
|
318
|
-
.spotpatch-trigger[aria-pressed="true"] {
|
|
319
|
-
border-color: rgb(124 58 237 / 55%);
|
|
320
|
-
background: #24203b;
|
|
321
|
-
box-shadow: 0 14px 42px rgb(76 29 149 / 24%), inset 0 1px rgb(255 255 255 / 10%);
|
|
285
|
+
right: ${String(Ot.desktopInset)}px;
|
|
286
|
+
bottom: ${String(Ot.desktopInset)}px;
|
|
287
|
+
z-index: ${String(sn.controls)};
|
|
288
|
+
isolation: isolate;
|
|
322
289
|
}
|
|
323
290
|
.spotpatch-highlight {
|
|
324
291
|
position: fixed;
|
|
325
292
|
top: 0;
|
|
326
293
|
left: 0;
|
|
327
|
-
z-index: ${String(
|
|
294
|
+
z-index: ${String(sn.highlight)};
|
|
328
295
|
box-sizing: border-box;
|
|
329
296
|
border: 2px solid var(--spotpatch-accent);
|
|
330
297
|
border-radius: 6px;
|
|
@@ -351,7 +318,7 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
351
318
|
.spotpatch-selection-highlights {
|
|
352
319
|
position: fixed;
|
|
353
320
|
inset: 0;
|
|
354
|
-
z-index: ${String(
|
|
321
|
+
z-index: ${String(sn.highlight)};
|
|
355
322
|
pointer-events: none;
|
|
356
323
|
}
|
|
357
324
|
.spotpatch-selection-highlight {
|
|
@@ -387,82 +354,28 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
387
354
|
background: #5546dc;
|
|
388
355
|
}
|
|
389
356
|
.spotpatch-dialog {
|
|
390
|
-
|
|
391
|
-
--spotpatch-anchor-y: 50%;
|
|
392
|
-
position: fixed;
|
|
393
|
-
top: 16px;
|
|
394
|
-
left: 16px;
|
|
395
|
-
z-index: ${String(It.controls)};
|
|
357
|
+
position: relative;
|
|
396
358
|
box-sizing: border-box;
|
|
397
|
-
width: min(${String(
|
|
398
|
-
color: #edf0f7;
|
|
359
|
+
width: min(${String(Ot.workbenchMaxWidth)}px, calc(100vw - ${String(Ot.desktopInset*2)}px));
|
|
399
360
|
outline: none;
|
|
400
|
-
filter: drop-shadow(var(--spotpatch-shadow-panel));
|
|
401
361
|
}
|
|
402
|
-
.spotpatch-anchor {
|
|
403
|
-
position: absolute;
|
|
404
|
-
z-index: 0;
|
|
405
|
-
width: 14px;
|
|
406
|
-
height: 14px;
|
|
407
|
-
border: 1px solid rgb(255 255 255 / 12%);
|
|
408
|
-
background: var(--spotpatch-bg);
|
|
409
|
-
transform: rotate(45deg);
|
|
410
|
-
}
|
|
411
|
-
.spotpatch-dialog[data-placement="above"] .spotpatch-anchor {
|
|
412
|
-
bottom: -6px;
|
|
413
|
-
left: calc(var(--spotpatch-anchor-x) - 7px);
|
|
414
|
-
border-top: 0;
|
|
415
|
-
border-left: 0;
|
|
416
|
-
}
|
|
417
|
-
.spotpatch-dialog[data-placement="below"] .spotpatch-anchor {
|
|
418
|
-
top: -6px;
|
|
419
|
-
left: calc(var(--spotpatch-anchor-x) - 7px);
|
|
420
|
-
border-right: 0;
|
|
421
|
-
border-bottom: 0;
|
|
422
|
-
}
|
|
423
|
-
.spotpatch-dialog[data-placement="left"] .spotpatch-anchor {
|
|
424
|
-
top: calc(var(--spotpatch-anchor-y) - 7px);
|
|
425
|
-
right: -6px;
|
|
426
|
-
border-bottom: 0;
|
|
427
|
-
border-left: 0;
|
|
428
|
-
}
|
|
429
|
-
.spotpatch-dialog[data-placement="right"] .spotpatch-anchor {
|
|
430
|
-
top: calc(var(--spotpatch-anchor-y) - 7px);
|
|
431
|
-
left: -6px;
|
|
432
|
-
border-top: 0;
|
|
433
|
-
border-right: 0;
|
|
434
|
-
}
|
|
435
|
-
.spotpatch-dialog[data-placement="center"] .spotpatch-anchor,
|
|
436
|
-
.spotpatch-dialog[data-placement="viewport"] .spotpatch-anchor { display: none; }
|
|
437
362
|
.spotpatch-shell {
|
|
438
363
|
position: relative;
|
|
439
364
|
z-index: 1;
|
|
440
365
|
display: flex;
|
|
441
366
|
box-sizing: border-box;
|
|
442
|
-
max-height: min(${String(
|
|
367
|
+
max-height: min(${String(Ot.workbenchMaxHeight)}px, calc(100vh - ${String(Ot.desktopInset*2)}px));
|
|
443
368
|
overflow: hidden;
|
|
444
369
|
flex-direction: column;
|
|
445
|
-
border: 1px solid var(--spotpatch-border);
|
|
446
|
-
border-radius: var(--spotpatch-radius-panel);
|
|
447
|
-
background: var(--spotpatch-bg);
|
|
448
|
-
box-shadow: inset 0 1px rgb(255 255 255 / 5%), 0 0 60px -32px rgb(139 123 255 / 20%);
|
|
449
|
-
}
|
|
450
|
-
.spotpatch-shell::before {
|
|
451
|
-
position: absolute;
|
|
452
|
-
z-index: 2;
|
|
453
|
-
top: 0;
|
|
454
|
-
right: 20%;
|
|
455
|
-
left: 20%;
|
|
456
|
-
height: 1px;
|
|
457
|
-
background: linear-gradient(90deg, transparent, var(--spotpatch-accent), var(--spotpatch-accent-cyan), transparent);
|
|
458
|
-
content: "";
|
|
459
|
-
opacity: .65;
|
|
460
|
-
pointer-events: none;
|
|
461
370
|
}
|
|
462
371
|
.spotpatch-header {
|
|
463
372
|
position: relative;
|
|
464
373
|
padding: 0 18px 14px;
|
|
465
374
|
}
|
|
375
|
+
.spotpatch-header[data-spotpatch-drag-handle] { cursor: grab; touch-action: none; user-select: none; }
|
|
376
|
+
.spotpatch-header[data-dragging="true"] { cursor: grabbing; }
|
|
377
|
+
.spotpatch-header button,
|
|
378
|
+
.spotpatch-header a { cursor: pointer; user-select: auto; }
|
|
466
379
|
.spotpatch-brand-row {
|
|
467
380
|
display: flex;
|
|
468
381
|
align-items: center;
|
|
@@ -486,18 +399,6 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
486
399
|
filter: drop-shadow(0 6px 12px rgb(76 29 149 / 22%));
|
|
487
400
|
}
|
|
488
401
|
.spotpatch-brand-copy { display: grid; min-width: 0; gap: 1px; }
|
|
489
|
-
.spotpatch-brand-name {
|
|
490
|
-
color: #fff;
|
|
491
|
-
font-size: 13.5px;
|
|
492
|
-
font-weight: 680;
|
|
493
|
-
letter-spacing: -.01em;
|
|
494
|
-
}
|
|
495
|
-
.spotpatch-brand-context {
|
|
496
|
-
color: #8e98aa;
|
|
497
|
-
font-size: 10.5px;
|
|
498
|
-
font-weight: 560;
|
|
499
|
-
letter-spacing: .02em;
|
|
500
|
-
}
|
|
501
402
|
.spotpatch-header-controls {
|
|
502
403
|
display: inline-flex;
|
|
503
404
|
align-items: center;
|
|
@@ -506,6 +407,7 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
506
407
|
}
|
|
507
408
|
.spotpatch-repository,
|
|
508
409
|
.spotpatch-locale,
|
|
410
|
+
.spotpatch-reset-position,
|
|
509
411
|
.spotpatch-close {
|
|
510
412
|
height: 27px;
|
|
511
413
|
border: 1px solid rgb(255 255 255 / 11%);
|
|
@@ -529,6 +431,16 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
529
431
|
font-size: 12px;
|
|
530
432
|
font-weight: 650;
|
|
531
433
|
}
|
|
434
|
+
.spotpatch-reset-position {
|
|
435
|
+
display: inline-grid;
|
|
436
|
+
width: 27px;
|
|
437
|
+
padding: 0;
|
|
438
|
+
place-items: center;
|
|
439
|
+
color: #c5cad5;
|
|
440
|
+
cursor: pointer;
|
|
441
|
+
font-size: 15px;
|
|
442
|
+
line-height: 1;
|
|
443
|
+
}
|
|
532
444
|
.spotpatch-close {
|
|
533
445
|
display: inline-grid;
|
|
534
446
|
width: 27px;
|
|
@@ -542,21 +454,8 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
542
454
|
}
|
|
543
455
|
.spotpatch-close:hover,
|
|
544
456
|
.spotpatch-locale:hover,
|
|
457
|
+
.spotpatch-reset-position:hover,
|
|
545
458
|
.spotpatch-repository:hover { border-color: rgb(129 112 247 / 45%); color: #fff; background: rgb(109 93 246 / 10%); }
|
|
546
|
-
.spotpatch-title {
|
|
547
|
-
margin: 0;
|
|
548
|
-
color: #fff;
|
|
549
|
-
font-size: 18px;
|
|
550
|
-
font-weight: 680;
|
|
551
|
-
letter-spacing: -.015em;
|
|
552
|
-
}
|
|
553
|
-
.spotpatch-subtitle {
|
|
554
|
-
max-width: 390px;
|
|
555
|
-
margin: 4px 0 0;
|
|
556
|
-
color: var(--spotpatch-text-secondary);
|
|
557
|
-
font-size: 12.5px;
|
|
558
|
-
line-height: 1.5;
|
|
559
|
-
}
|
|
560
459
|
.spotpatch-target-row {
|
|
561
460
|
display: flex;
|
|
562
461
|
align-items: center;
|
|
@@ -920,6 +819,7 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
920
819
|
.spotpatch-target-open:focus-visible,
|
|
921
820
|
.spotpatch-target-remove:focus-visible,
|
|
922
821
|
.spotpatch-close:focus-visible,
|
|
822
|
+
.spotpatch-reset-position:focus-visible,
|
|
923
823
|
.spotpatch-trigger:focus-visible,
|
|
924
824
|
.spotpatch-target-select:focus-visible,
|
|
925
825
|
.spotpatch-target-editor textarea:focus-visible,
|
|
@@ -944,8 +844,8 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
944
844
|
.spotpatch-diagnostics > summary::before { transition: none; }
|
|
945
845
|
}
|
|
946
846
|
@media (max-width: 520px) {
|
|
947
|
-
.spotpatch-dialog {
|
|
948
|
-
.spotpatch-shell { max-height: calc(
|
|
847
|
+
.spotpatch-dialog { width: calc(100vw - 16px); }
|
|
848
|
+
.spotpatch-shell { max-height: calc(100dvh - 16px); }
|
|
949
849
|
.spotpatch-header, .spotpatch-body { padding-left: 14px; padding-right: 14px; }
|
|
950
850
|
.spotpatch-brand-row { margin-right: -14px; margin-left: -14px; padding-right: 14px; padding-left: 14px; }
|
|
951
851
|
.spotpatch-actions { padding-right: 14px; padding-left: 14px; }
|
|
@@ -953,10 +853,10 @@ ${Gt(e.code.language,V(t.codeLines.join(`
|
|
|
953
853
|
.spotpatch-target-state { display: none; }
|
|
954
854
|
.spotpatch-repository { display: none; }
|
|
955
855
|
}
|
|
956
|
-
${
|
|
957
|
-
`,t}function
|
|
958
|
-
`).find(n=>n.startsWith(`${t}: `))?.slice(t.length+2).trim()}function Pa(e,t,o){return t.append(o),Object.freeze({root:t,refreshButton:Y(e,""),styles:e.createElement("style"),dispose:()=>{},render:()=>{},resetView:()=>{}})}function Co(e,t,o=Object.freeze({enabled:!1}),n="auto",i=!1,c=!1,r="vite",u=""){let R=Ao(e,n),s=R.messages(),A=e.createElement("spotpatch-root");A.setAttribute(xt,"");let z=A.attachShadow({mode:"open"}),m=Y(e,s.trigger.select,"spotpatch-trigger");m.title=s.trigger.title(t),m.setAttribute("aria-pressed","false");let L=d(e,"div");L.className="spotpatch-highlight",L.hidden=!0;let M=d(e,"span");M.className="spotpatch-highlight-label",L.append(M);let N=d(e,"div");N.className="spotpatch-selection-highlights",N.setAttribute("aria-hidden","true");let b=d(e,"section");b.className="spotpatch-dialog",b.hidden=!0,b.tabIndex=-1,b.dataset.placement="viewport",b.setAttribute("role","dialog"),b.setAttribute("aria-labelledby","spotpatch-selection-title");let T=d(e,"span");T.className="spotpatch-anchor",T.setAttribute("aria-hidden","true");let $=d(e,"div");$.className="spotpatch-shell";let re=d(e,"header");re.className="spotpatch-header";let H=d(e,"div");H.className="spotpatch-brand-row";let h=d(e,"div");h.className="spotpatch-brand";let S=d(e,"span");S.className="spotpatch-brand-copy";let x=d(e,"span");x.className="spotpatch-brand-name";let I=d(e,"span");I.className="spotpatch-brand-context",S.append(x,I),h.append(yo(e),S);let G=d(e,"span");G.className="spotpatch-header-controls";let W=d(e,"a");W.className="spotpatch-repository",W.href=ln,W.target="_blank",W.rel="noopener noreferrer";let Z=Y(e,"","spotpatch-locale"),Q=Y(e,"×","spotpatch-close");G.append(W,Z,Q),H.append(h,G);let F=d(e,"h2");F.id="spotpatch-selection-title",F.className="spotpatch-title";let Re=d(e,"p");Re.className="spotpatch-subtitle";let Ne=d(e,"div");Ne.className="spotpatch-target-row";let ge=d(e,"span");ge.className="spotpatch-target-label";let _=d(e,"span");_.className="spotpatch-context-state",_.dataset.state="loading",_.textContent=s.context.collecting,Ne.append(ge,_),re.append(H,F,Re,Ne);let Ue=d(e,"div");Ue.className="spotpatch-body";let Ce=d(e,"div");Ce.className="spotpatch-selection-panel";let Te=d(e,"section");Te.className="spotpatch-targets";let be=d(e,"div");be.className="spotpatch-targets-heading";let pt=d(e,"span"),ae=d(e,"span");ae.className="spotpatch-targets-meta";let ye=d(e,"span");ye.className="spotpatch-target-complete";let q=d(e,"span");q.className="spotpatch-target-budget",q.setAttribute("aria-live","polite");let Fe=d(e,"span");Fe.className="spotpatch-target-count",ae.append(ye,q),Ne.append(Fe),be.append(pt,ae);let Ie=d(e,"div");Ie.className="spotpatch-target-progress",Ie.setAttribute("aria-hidden","true");let B=d(e,"div");B.className="spotpatch-target-progress-fill",Ie.append(B);let ee=d(e,"div");ee.className="spotpatch-target-list",Te.append(be,Ie,ee);let Pe=d(e,"details");Pe.className="spotpatch-diagnostics";let We=d(e,"summary"),at=d(e,"span"),ze=d(e,"span");ze.className="spotpatch-source-peek",ze.textContent=s.diagnostics.resolving,We.append(at,ze);let De=d(e,"pre");De.className="spotpatch-summary",Pe.append(We,De);let v=ho(e,o,R),Ke=d(e,"div"),J=c?Wt()?.createPanel(e,r,R.locale,u,R.subscribe,w):void 0;Ke.append(Te,v.root,...J===void 0?[]:[J.root]);let se=Dt()?.createPanel(e,i,R.locale,Ke,Pe,w)??Pa(e,Ke,Pe);Ce.append(se.root);let fe=d(e,"div");fe.className="spotpatch-preview-panel",fe.hidden=!0;let O=d(e,"pre");O.className="spotpatch-prompt",O.tabIndex=0,O.setAttribute("aria-label",s.diagnostics.promptAriaLabel),fe.append(O),Ue.append(Ce,fe);let He=d(e,"footer");He.className="spotpatch-actions";let Ee=d(e,"div");Ee.className="spotpatch-context-state spotpatch-editor-feedback",Ee.dataset.state="idle",Ee.setAttribute("role","status"),Ee.setAttribute("aria-live","polite"),Ee.hidden=!0;let ve=Y(e,s.actions.addElement),je=Y(e,s.actions.reselect),ke=Y(e,s.actions.openEditor),ce=Y(e,s.actions.preview,"spotpatch-primary"),Ve=Y(e,s.actions.copy,"spotpatch-primary"),$e=Y(e,s.actions.back),le=d(e,"div");le.className="spotpatch-secondary-actions";let ut=d(e,"div");ut.className="spotpatch-primary-actions",ve.classList.add("spotpatch-icon-action"),ve.dataset.compactIcon="+",v.testButton.classList.add("spotpatch-icon-action"),v.testButton.dataset.compactIcon="✓",ke.classList.add("spotpatch-secondary-action"),je.classList.add("spotpatch-secondary-action"),le.append(ke,je),ut.append(v.testButton,ve,v.runButton,...J===void 0?[]:[J.sendButton],ce,v.cancelButton,v.applyButton,v.revertButton,v.resetButton,Ve,$e),He.append(Ee,le,ut),$.append(re,Ue,He),b.append(T,$);let me=d(e,"div");me.className="spotpatch-live",me.setAttribute("aria-live","polite"),me.setAttribute("aria-atomic","true");let it=[Na(e),se.styles,...J===void 0?[]:[J.styles]],st=La(e);if(st!==void 0)for(let g of it)g.nonce=st;z.append(...it,N,L,b,m,me),e.documentElement.append(A);let Be,Xe,Ye="idle",qe=!1,we=!1,Ze="",Qe=!0,Se=[],et=0,te="idle",yt=Object.freeze({component:Object.freeze({status:i?"idle":"disabled"}),page:Object.freeze({status:i?"idle":"disabled"}),observationCount:0});function a(g){te=g,Ee.dataset.state=g,Ee.hidden=g==="idle",Ee.textContent=g==="opening"?s.announcements.editorOpening:g==="success"?s.announcements.editorOpened:g==="error"?s.announcements.editorFailed:"",w()}function p(g){return g.status==="ready"?s.targets.statusReady:g.status==="warning"?s.targets.statusPartial:s.targets.statusCollecting}function y(g,E){let C=E===0?0:g/E;B.style.width=`${String(C*100)}%`}function P(g){let E=ee.querySelectorAll("textarea[data-target-instruction-id]");return Array.from(E).find(C=>g===void 0||C.dataset.targetInstructionId===g)}function k(g,E){let C=z.activeElement?.closest("textarea[data-target-instruction-id]"),U=C?.dataset.targetInstructionId,Oe=C?.selectionStart,tt=C?.selectionEnd;Se=g.map(j=>Object.freeze({...j})),et=E,ee.replaceChildren();let ct=g.filter(j=>j.instruction.trim().length>0).length,Ae=g.reduce((j,K)=>j+K.instruction.trim().length,0);y(ct,g.length),Fe.textContent=s.targets.count(g.length,E),ye.textContent=s.targets.complete(ct,g.length);let Tt=Ae>4e3;q.dataset.state=Tt?"over":"ready",q.textContent=Tt?s.targets.instructionBudgetExceeded(Ae,4e3):s.targets.instructionBudget(Ae,4e3),ve.disabled=!Qe||g.length>=E,ve.title=g.length>=E?s.targets.limitTitle(E):s.targets.addTitle,ge.textContent=g.length===1?g[0]?.label??s.context.selectedElement:s.context.selectedCount(g.length);for(let[j,K]of g.entries()){let Et=d(e,"div");Et.className="spotpatch-target-item",Et.dataset.active=String(K.active),Et.dataset.status=K.status,Et.dataset.targetId=K.id;let qt=d(e,"div");qt.className="spotpatch-target-summary";let vt=Y(e,"","spotpatch-target-select");vt.dataset.activateTargetId=K.id,vt.setAttribute("aria-label",s.targets.activate(j+1)),vt.setAttribute("aria-expanded",String(K.active));let Jt=d(e,"span");Jt.className="spotpatch-target-index",Jt.textContent=String(j+1);let Kt=d(e,"span");Kt.className="spotpatch-target-copy";let Xt=d(e,"span");Xt.className="spotpatch-target-name",Xt.textContent=K.label;let Yt=d(e,"span");Yt.className="spotpatch-target-source",Yt.textContent=`${p(K)} · ${K.source}`,Kt.append(Xt,Yt);let En=K.instruction.trim().length>0,Mt=d(e,"span");Mt.className="spotpatch-target-state",Mt.dataset.complete=String(En),Mt.textContent=En?s.targets.instructionReady:s.targets.instructionMissing,vt.append(Jt,Kt,Mt);let wt=Y(e,"↗","spotpatch-target-open");wt.dataset.openTargetId=K.id,wt.disabled=!K.canOpenEditor,wt.setAttribute("aria-label",s.actions.openTarget(j+1)),wt.title=s.actions.openTarget(j+1);let Ot=Y(e,"×","spotpatch-target-remove");if(Ot.dataset.removeTargetId=K.id,Ot.disabled=!Qe,Ot.setAttribute("aria-label",s.targets.remove(j+1)),Ot.title=s.targets.removeTitle,qt.append(vt,wt,Ot),Et.append(qt),K.active){let Zt=d(e,"label");Zt.className="spotpatch-target-editor";let Qt=d(e,"span");Qt.className="spotpatch-target-editor-head";let en=d(e,"span");en.className="spotpatch-target-editor-label",en.textContent=s.targets.instructionLabel(K.label);let tn=d(e,"span");tn.className="spotpatch-target-editor-count",tn.textContent=s.targets.instructionCount(K.instruction.length,2e3),Qt.append(en,tn);let gt=d(e,"textarea");gt.rows=4,gt.maxLength=2e3,gt.value=K.instruction,gt.placeholder=s.targets.instructionPlaceholder,gt.disabled=!Qe,gt.dataset.targetInstructionId=K.id,gt.setAttribute("aria-label",s.targets.instructionLabel(K.label)),Zt.append(Qt,gt),Et.append(Zt)}ee.append(Et)}if(U!==void 0){let j=P(U);j?.focus({preventScroll:!0}),Oe!==void 0&&tt!==void 0&&j?.setSelectionRange(Oe,tt)}}function ne(g,E){Se=Se.map(j=>j.id===g?Object.freeze({...j,instruction:E}):j);let C=Array.from(ee.querySelectorAll(".spotpatch-target-item")).find(j=>j.dataset.targetId===g);if(C===void 0)return;let U=E.trim().length>0,Oe=C.querySelector(".spotpatch-target-state"),tt=C.querySelector(".spotpatch-target-editor-count");Oe!==null&&(Oe.dataset.complete=String(U),Oe.textContent=U?s.targets.instructionReady:s.targets.instructionMissing),tt!==null&&(tt.textContent=s.targets.instructionCount(E.length,2e3));let ct=Se.filter(j=>j.instruction.trim().length>0).length;ye.textContent=s.targets.complete(ct,Se.length),y(ct,Se.length);let Ae=Se.reduce((j,K)=>j+K.instruction.trim().length,0),Tt=Ae>4e3;q.dataset.state=Tt?"over":"ready",q.textContent=Tt?s.targets.instructionBudgetExceeded(Ae,4e3):s.targets.instructionBudget(Ae,4e3)}function f(g){N.replaceChildren(),Xe=g.find(E=>E.active)?.rect,Be=Xe;for(let[E,C]of g.entries()){let U=d(e,"div");U.className="spotpatch-selection-highlight",U.dataset.targetId=C.id,U.dataset.active=String(C.active),U.style.transform=`translate(${String(C.rect.x)}px, ${String(C.rect.y)}px)`,U.style.width=`${String(C.rect.width)}px`,U.style.height=`${String(C.rect.height)}px`;let Oe=d(e,"span");Oe.textContent=`${String(E+1)} · ${C.label}`,U.append(Oe),N.append(U)}w()}function w(){if(b.hidden)return;let g=e.defaultView,E=g?.innerWidth??e.documentElement.clientWidth,C=g?.innerHeight??e.documentElement.clientHeight,U=b.getBoundingClientRect(),Oe=Ye==="previewing"?"previewing":"selected",tt=U.width>0?U.width:Math.min(xo,E-32),ct=U.height>0?U.height:Math.min(_a[Oe],C-32),Ae=Eo({dialogWidth:tt,dialogHeight:ct,viewportWidth:E,viewportHeight:C,...Be===void 0?{}:{target:Be}});b.style.left=`${String(Ae.left)}px`,b.style.top=`${String(Ae.top)}px`,b.style.setProperty("--spotpatch-anchor-x",`${String(Ae.anchorX)}px`),b.style.setProperty("--spotpatch-anchor-y",`${String(Ae.anchorY)}px`),b.dataset.placement=Ae.mode}function de(g){let E=s.summary,C=Ia(g,E.source);ze.textContent=C??s.diagnostics.noExactSource;let U=`${E.browserContext}: ${E.collectionStatuses.ready}`,Oe=`${E.browserContext}: ${E.collectionStatuses.loading}`,tt=`${E.browserContext}: ${E.collectionStatuses.failed}`,ct=`${E.api}: ${E.apiStatuses.loading}`,Ae=`${E.api}: ${E.apiStatuses.failed}`;g.includes(U)&&!g.includes(Oe)&&!g.includes(ct)&&!g.includes(tt)&&!g.includes(Ae)?(_.dataset.state="ready",_.textContent=s.context.ready):g.includes(tt)||g.includes(Ae)?(_.dataset.state="warning",_.textContent=s.context.partial):(_.dataset.state="loading",_.textContent=s.context.collecting)}function oe(g,E,C){qe=E,we=C,Ze=g,De.textContent=g,ke.disabled=!E,ce.disabled=!C,v.setContextReady(C),J?.setContextReady(C),de(g),w()}function Ge(g){Ye=g;let E=g==="selected",C=g==="previewing";m.hidden=E||C,Ce.hidden=!E,fe.hidden=!C,je.hidden=!E,ve.hidden=!E,ke.hidden=!E,ce.hidden=!E,le.hidden=!E,v.setSelectionVisible(E),J?.setSelectionVisible(E),Ve.hidden=!C,$e.hidden=!C,F.textContent=C?s.dialog.previewTitle:s.dialog.editTitle,Re.textContent=C?s.dialog.previewSubtitle:s.dialog.editSubtitle,w()}function Ct(){s=R.messages(),x.textContent=s.brand.name,I.textContent=s.brand.context,W.textContent=s.brand.repository,W.title=s.brand.repositoryTitle,W.setAttribute("aria-label",s.brand.repositoryTitle),Z.textContent=s.alternateLocaleName,Z.title=s.switchLocale,Z.setAttribute("aria-label",s.switchLocale),Q.setAttribute("aria-label",s.dialog.close),Q.title=s.dialog.close,Te.setAttribute("aria-label",s.targets.ariaLabel),pt.textContent=s.targets.title,at.textContent=s.diagnostics.title,O.setAttribute("aria-label",s.diagnostics.promptAriaLabel),ve.textContent=s.actions.addElement,je.textContent=s.actions.reselect,ke.textContent=s.actions.openEditor,ce.textContent=s.actions.preview,Ve.textContent=s.actions.copy,$e.textContent=s.actions.back,se.render(yt),m.title=s.trigger.title(t),m.textContent=Ye==="inspecting"?s.trigger.stop:s.trigger.select,Ge(Ye),a(te),Se.length>0?k(Se,et):(Fe.textContent=s.targets.count(0,et),ye.textContent=s.targets.complete(0,0),y(0,0),q.dataset.state="ready",q.textContent=s.targets.instructionBudget(0,4e3),ge.textContent=s.context.selectedElement),Ze.length>0?de(Ze):(ze.textContent=s.diagnostics.resolving,_.textContent=s.context.collecting)}Pe.addEventListener("toggle",w),Z.addEventListener("click",R.toggle);let kt=R.subscribe(Ct);return Ct(),Object.freeze({host:A,triggerButton:m,addTargetButton:ve,targetList:ee,reselectButton:je,openEditorButton:ke,repositoryLink:W,previewButton:ce,copyButton:Ve,dataFlowRefreshButton:se.refreshButton,backButton:$e,closeButton:Q,agentProviderSelect:v.providerSelect,agentModelSelect:v.modelSelect,agentModeSelect:v.modeSelect,agentConsentCheckbox:v.consentCheckbox,agentWorkspaceConsentCheckbox:v.workspaceConsentCheckbox,agentTestButton:v.testButton,agentRunButton:v.runButton,agentCancelButton:v.cancelButton,agentApplyButton:v.applyButton,agentRevertButton:v.revertButton,agentResetButton:v.resetButton,...J===void 0?{}:{externalHandoffPanel:J},renderStatus(g){let E=g==="inspecting";m.setAttribute("aria-pressed",String(E)),m.textContent=E?s.trigger.stop:s.trigger.select,Ge(g)},renderEditorStatus:a,renderDataFlow(g){yt=g,se.render(g),w()},showHighlight(g,E){Be=g,L.hidden=!1,L.style.transform=`translate(${String(g.x)}px, ${String(g.y)}px)`,L.style.width=`${String(g.width)}px`,L.style.height=`${String(g.height)}px`,M.textContent=E,ge.textContent=E,w()},hideHighlight(){Be=Xe,L.hidden=!0,M.textContent="",w()},showSelectionHighlights:f,hideSelectionHighlights(){N.replaceChildren(),Xe=void 0,Be=void 0,w()},showSelection(g,E,C){oe(g,E,C),m.hidden=!0,b.hidden=!1,w()},updateSelection:oe,renderTargets:k,updateTargetInstruction:ne,setPreviewEnabled(g){we=g,ce.disabled=!g,v.setContextReady(g),J?.setContextReady(g)},hideSelection(){b.hidden=!0,m.hidden=!1,ee.replaceChildren(),Se=[],et=0,Ze="",a("idle"),Fe.textContent=s.targets.count(0,0),ye.textContent=s.targets.complete(0,0),y(0,0),ge.textContent=s.context.selectedElement,De.textContent="",O.textContent="",ze.textContent=s.diagnostics.resolving,_.dataset.state="loading",_.textContent=s.context.collecting,ke.disabled=!0,ce.disabled=!0,qe=!1,we=!1,v.setContextReady(!1),v.setSelectionVisible(!1),J?.setContextReady(!1),J?.setSelectionVisible(!1),v.setEditingEnabled(!0),v.resetJob(),se.resetView()},hideSelectionTemporarily(){b.hidden=!0,m.hidden=!1},showPreview(g){O.textContent=g,w()},readAgentSelection(){return v.readSelection()},agentConsentGranted(){return v.consentGranted()},setAgentProviderConsent(g){v.setProviderConsent(g)},setAgentEditingEnabled(g){Qe=g,ve.disabled=!g,je.disabled=!g,ee.querySelectorAll(".spotpatch-target-remove, .spotpatch-target-select, textarea[data-target-instruction-id]").forEach(E=>{E.disabled=!g}),ke.disabled=!qe,ce.disabled=!g||!we,J?.setContextReady(g&&we),v.setEditingEnabled(g),w()},renderAgentCapability(g,E,C,U){v.renderCapability(g,E,C,U);let Oe=g==="ready"&&C?.state==="agent-ready";ce.classList.toggle("spotpatch-primary",!Oe),w()},renderAgentWorkspaceHealth(g,E,C){v.renderWorkspaceHealth(g,E,C),w()},renderAgentJob(g,E,C,U){v.renderJob(g,E,C,U),w()},resetAgentJob(){v.resetJob(),w()},focusTargetInstruction(g){P(g)?.focus({preventScroll:!0})},focusPrompt(){O.focus({preventScroll:!0})},announce(g){me.textContent="",me.textContent=g},locale:R.locale,messages:R.messages,agentWorkspaceConsentGranted:v.workspaceConsentGranted,subscribeLocale:R.subscribe,dispose(){Pe.removeEventListener("toggle",w),Z.removeEventListener("click",R.toggle),kt(),se.dispose(),J?.dispose(),v.dispose(),A.remove()}})}function Da(e,t,o){let n=t?.relativePath??e.source.relativePath,i=e.source.line,c=e.source.column;return n!==void 0&&i!==void 0?`${n}:${String(i)}${c===void 0?"":`:${String(c)}`}`:n!==void 0?n:i!==void 0?o.lineLocation(i,c):o.unavailable}function To(e,t){let o=[`SpotPatch: ${e.spotPatchVersion}`,`${e.framework==="next"?"Next.js":"Vite"}: ${e.frameworkVersion}`,`${t.source}: ${Da(e.resolution,e.code,t)}`,`${t.confidence}: ${e.resolution.source.confidence} (${t.confidenceLabels[e.resolution.source.confidence]})`,`${t.origin}: ${e.resolution.source.origin}`];return e.resolution.react.componentName!==void 0&&o.push(`${t.component}: ${e.resolution.react.componentName}`),e.resolution.react.componentStack.length>0&&o.push(`${t.stack}: ${e.resolution.react.componentStack.join(" > ")}`),!e.resolution.react.supported&&e.resolution.react.version!==void 0&&o.push(`React ${e.resolution.react.version}: ${t.unsupported}`),o.push(`${t.adapter}: ${e.resolution.react.supported?t.available:t.unavailable}`,`${t.api}: ${t.apiStatuses[e.apiStatus]}`,`${t.browserContext}: ${t.collectionStatuses[e.collectionStatus]}`),e.code!==void 0?o.push(`${t.boundary}: ${t.boundaries[e.code.boundary]}`):e.apiStatus==="loading"?o.push(`${t.sourceContext}: ${t.apiStatuses.loading}`):e.apiStatus==="failed"&&o.push(`${t.sourceContext}: ${t.unavailable}`),e.styles!==void 0&&(o.push(`${t.cssWarnings}: ${String(e.styles.warnings.length)}`),o.push(...e.styles.warnings.map(n=>`${t.warning}: ${n}`))),o.join(`
|
|
959
|
-
`)}function vo(e,t){return`${e}:${t}`}function ka(e){if(e.type==="tool")return Object.freeze({key:`tool:${String(e.data.turn)}:${e.data.toolCallId}`,label:`${e.data.toolName} · ${e.data.state}`,state:e.data.state==="started"?"active":e.data.state==="succeeded"?"success":"failure"});if(e.type==="check")return Object.freeze({key:`check:${e.data.result.checkId}:${String(e.sequence)}`,label:`${e.data.result.label} · ${e.data.result.status}`,state:e.data.result.status==="passed"?"success":e.data.result.status==="failed"||e.data.result.status==="timed-out"?"failure":"info"})}function wo(e){let t=h=>Mn(h)??l.INTERNAL_ERROR,o=h=>e.view.messages().errors[t(h)],n=new Map,i=new Set,c=new Map,r=0,u,R,s=!1,A=!1,z=()=>e.view.readAgentSelection(),m=h=>`${h.providerProfileId}:${h.applyMode}`,L=async h=>{e.view.renderAgentWorkspaceHealth("checking");try{let S=await e.api.agentWorkspaceHealth();return h!==r||e.view.renderAgentWorkspaceHealth(S.state,S,S.errorCode),S}catch(S){throw h===r&&e.view.renderAgentWorkspaceHealth("blocked",void 0,t(S)),S}},M=h=>{u!==void 0&&e.view.renderAgentJob(u,R,Object.freeze([...c.values()]),h??u.errorCode)},N=()=>{let h=z();if(h===void 0){e.view.setAgentProviderConsent(!1),e.view.renderAgentCapability("error",e.view.messages().agent.providerUnavailable);return}e.view.setAgentProviderConsent(i.has(m(h)));let S=n.get(vo(h.providerProfileId,h.modelProfileId));S===void 0?e.view.renderAgentCapability("idle",e.view.messages().agent.connectionNotTested):e.view.renderAgentCapability("ready",e.view.messages().agent.capabilityVerified,S)},b=async h=>{let S=z();if(S===void 0)throw new Error("Agent provider selection is unavailable.");let x=vo(S.providerProfileId,S.modelProfileId),I=n.get(x);if(I!==void 0)return I;e.view.renderAgentCapability("probing",e.view.messages().agent.testingCapability);let G=await e.api.agentCapability(S);if(h!==r)return G;if(G.state!=="agent-ready")throw new D(G.errorCode??l.MODEL_TOOL_CALL_UNSUPPORTED);return n.set(x,G),e.view.renderAgentCapability("ready",e.view.messages().agent.capabilityVerified,G),e.view.announce(e.view.messages().agent.capabilityVerifiedAnnouncement),G},T=async(h,S)=>{try{let x=await e.api.agentResult(h);if(S!==r||x.snapshot.jobId!==h)return;u=x.snapshot,R=x.result,M()}catch(x){S===r&&M(t(x))}},$=async(h,S)=>{try{await e.api.agentEvents(h,x=>{if(S!==r||x.jobId!==h)return;x.type==="snapshot"&&(u=x.data.snapshot,u.status==="applied"&&!s&&(s=!0,e.onApplied()));let I=ka(x);I!==void 0&&c.set(I.key,I),M()}),S===r&&await T(h,S)}catch(x){S===r&&!(x instanceof DOMException&&x.name==="AbortError")&&M(t(x))}},re=async h=>{let S=u;if(S===void 0||A)return;A=!0;let x=r;u=Object.freeze({...S,status:h==="apply"?"applying":h==="cancel"?"cancelling":"reverting",phaseMessage:h==="apply"?e.view.messages().agent.applying:h==="cancel"?e.view.messages().agent.cancelling:e.view.messages().agent.reverting,canCancel:!1,canApply:!1,canRevert:!1}),M();try{let I=h==="apply"?await e.api.applyAgentJob(S.jobId):h==="cancel"?await e.api.cancelAgentJob(S.jobId):await e.api.revertAgentJob(S.jobId);if(x!==r)return;u=I,I.status==="applied"&&!s&&(s=!0,e.onApplied()),await T(I.jobId,x)}catch(I){if(x!==r)return;u=S,await T(S.jobId,x),M(t(I)),e.view.announce(o(I))}finally{x===r&&(A=!1)}},H=()=>{r+=1,u=void 0,R=void 0,c.clear(),s=!1,A=!1,e.view.resetAgentJob(),e.view.setAgentEditingEnabled(!0),N()};return Object.freeze({apply(){u?.canApply===!0&&re("apply")},beginSelection(){H();let h=r;e.ai.enabled&&L(h).catch(()=>{})},cancel(){u?.canCancel===!0&&re("cancel")},consentChanged(){let h=z();h!==void 0&&(e.view.agentConsentGranted()?i.add(m(h)):i.delete(m(h)))},disposeSelection(){let h=u?.canCancel===!0||u?.status==="cancelling"?u.jobId:void 0;r+=1,u=void 0,R=void 0,c.clear(),s=!1,A=!1,h!==void 0&&e.api.cancelAgentJob(h).catch(()=>{})},providerOrModelChanged(){r+=1,N(),L(r).catch(()=>{})},reset(){let h=s;H(),h?e.onReselectRequired():e.ai.enabled&&L(r).catch(()=>{})},revert(){u?.canRevert===!0&&re("revert")},run(){if(!e.ai.enabled||u!==void 0)return;let h=z(),S=e.getAnnotation();if(h===void 0||S===void 0){e.view.announce(e.view.messages().announcements.completeInstructions);return}if(!e.view.agentConsentGranted()){e.view.announce(e.view.messages().agent.consentRequired);return}i.add(m(h));let x=++r;e.view.setAgentEditingEnabled(!1),L(x).then(async I=>{if(x!==r)return;if(I.state==="blocked")throw new D(I.errorCode??l.WORKTREE_LOCAL_CHANGES_UNSUPPORTED);if(I.state==="consent-required"&&!e.view.agentWorkspaceConsentGranted())throw new D(l.WORKTREE_DIRTY);let G=await e.api.createAgentJob({annotation:S,applyMode:h.applyMode,providerProfileId:h.providerProfileId,modelProfileId:h.modelProfileId,providerDataConsent:!0,...h.applyMode==="trusted-auto"?{trustedFastModeConsent:!0}:{},workingTreeMode:I.state==="consent-required"?"include-local-changes":"require-clean"});x===r&&(u=G,R=void 0,c.clear(),M(),$(G.jobId,x))}).catch(I=>{x===r&&(e.view.setAgentEditingEnabled(!0),e.view.renderAgentCapability("error",o(I),void 0,t(I)),e.view.announce(o(I)))})},testCapability(){if(!e.ai.enabled||u!==void 0)return;let h=++r;Promise.all([b(h),L(h)]).catch(S=>{h===r&&(e.view.renderAgentCapability("error",o(S),void 0,t(S)),e.view.announce(o(S)))})}})}function Oo(e){if(typeof e.crypto.randomUUID=="function")return e.crypto.randomUUID();let t=e.crypto.getRandomValues(new Uint8Array(16));return Array.from(t,o=>o.toString(16).padStart(2,"0")).join("")}function hn(e,t){return Object.freeze({url:t.location.href,pathname:t.location.pathname,title:e.title,viewportWidth:t.innerWidth,viewportHeight:t.innerHeight,devicePixelRatio:t.devicePixelRatio})}function _o(e){let t=Reflect.get(e,"clipboard");return typeof t=="object"&&t!==null&&"writeText"in t&&typeof t.writeText=="function"?t:void 0}var Fa=Object.freeze({classNames:Object.freeze([]),matchedRules:Object.freeze([]),computed:Object.freeze({}),warnings:Object.freeze(["CSS context collection failed."])});function bn(e){let t=e.id.length>0?`#${e.id}`:"",o=Array.from(e.classList).slice(0,2).map(n=>`.${n}`).join("");return`<${e.tagName.toLowerCase()}${t}${o}>`}function Ha(e,t){let o=e.code?.relativePath??e.resolution.source.relativePath,n=e.resolution.source.line,i=e.resolution.source.column;return o===void 0?t:`${o}${n===void 0?"":`:${String(n)}`}${i===void 0?"":`:${String(i)}`}`}function $a(e){return e.apiStatus==="failed"||e.collectionStatus==="failed"?"warning":e.apiStatus==="loading"||e.collectionStatus==="loading"?"loading":"ready"}function Ba(e){let t=e.document??globalThis.document,o=e.window??globalThis.window;return{document:t,window:o,mutationObserver:e.mutationObserver??globalThis.MutationObserver,resizeObserver:e.resizeObserver??globalThis.ResizeObserver}}function Lo(e,t={}){let o=Ba(t),n=t.view??Co(o.document,e.shortcut,e.ai,e.locale,e.dataFlow.enabled,e.externalAgent.enabled,e.framework,e.sessionId),i=t.api??Fn({apiBase:e.apiBase,dataFlowReportMaxBytes:e.dataFlow.limits.reportMaxBytes,fetch:o.window.fetch.bind(o.window),sessionToken:e.sessionToken}),c=t.promptComposer??ao({maxCharacters:e.budget.totalCharacters}),r=t.clipboard??_o(o.window.navigator),u=t.createId??(()=>Oo(o.window)),R=t.now??(()=>new Date().toISOString()),s=t.selectionSession??lo(o.window,e.sessionId,e.maxTargets),A=s.load(),z=fo({adapter:t.reactAdapter??Ma({...e.dataFlow.enabled?{getComponentRegistration:a=>Dt()?.getComponentRegistration(a)}:{},maxComponentDepth:e.budget.maxComponentDepth}),onAdapterError(){n.announce(n.messages().announcements.adapterDisabled),e.debug&&console.warn("[spotpatch:react] Adapter failed and was disabled for this session.")}}),m=gn,L=!1,M,N,b=A?.targets.map(a=>{let p=mn(a.source);return{id:a.id,resolution:Object.freeze({source:a.source,react:a.react}),apiStatus:p===void 0?"not-required":a.code===void 0?"failed":"connected",code:a.code,collectionStatus:"ready",dataFlowReport:void 0,dataFlowStatus:"idle",element:void 0,elementContext:a.element,instruction:a.instruction,marker:p,page:a.page,styles:a.styles}})??[],T=A?.activeTargetId,$=A?.sequence??0,re=A?.open??!1,H=!1,h=0,S=0,x=0,I,G="idle",W=!1,Z="",Q,F,Re,Ne,ge=new Map;function _(a){m=io(m,a),n.renderStatus(m.status)}function Ue(){return b.find(a=>a.id===T)??b.at(-1)}function Ce(a){let p=a.resolution.react;if(p.componentSourceId!==void 0&&p.sourceVersion!==void 0)return Object.freeze({schemaVersion:1,componentSourceId:p.componentSourceId,sourceVersion:p.sourceVersion});let y=a.marker;return y===void 0?void 0:Object.freeze({schemaVersion:1,fileId:y.fileId,line:y.line,column:y.column})}function Te(){let a=Dt(),p=a?.observations(o.window.location.pathname)??[],y=Ue();n.renderDataFlow({component:Object.freeze({status:e.dataFlow.enabled?y?.dataFlowStatus??"idle":"disabled",...y?.dataFlowReport===void 0?{}:{report:a?.mergeComponentReport(y.dataFlowReport,p)??y.dataFlowReport}}),page:Object.freeze({status:e.dataFlow.enabled?G:"disabled",...I===void 0?{}:{report:a?.mergePageReport(I,p)??I}}),observationCount:p.length})}async function be(){if(!e.dataFlow.enabled){Te();return}let a=Ue(),p=a===void 0?void 0:Ce(a),y=b.flatMap(w=>{let de=Ce(w);return de===void 0?[]:[de]}),P=++x,k=h;a!==void 0&&(a.dataFlowStatus="loading"),G=y.length===0?"idle":"loading",Te();let[ne,f]=await Promise.allSettled([p===void 0?Promise.resolve(void 0):i.componentDataFlowReport(p),y.length===0?Promise.resolve(void 0):i.pageDataFlowReport({schemaVersion:1,targets:y})]);!L||P!==x||k!==h||(a!==void 0&&b.includes(a)&&(ne.status==="fulfilled"?(a.dataFlowReport=ne.value,a.dataFlowStatus=ne.value===void 0?"idle":"ready"):(a.dataFlowReport=void 0,a.dataFlowStatus="error")),f.status==="fulfilled"?(I=f.value,G=f.value===void 0?"idle":"ready"):(I=void 0,G="error"),Te())}function pt(a){if(!(a.elementContext===void 0||a.styles===void 0))return{id:a.id,instruction:a.instruction,page:a.page,source:a.resolution.source,react:a.resolution.react,element:a.elementContext,styles:a.styles,...a.code===void 0?{}:{code:a.code}}}function ae(){let a=b.flatMap(y=>{let P=pt(y);return P===void 0?[]:[P]});if(a.length===0){s.clear();return}let p=new Set(a.map(({id:y})=>y));s.save({...T!==void 0&&p.has(T)?{activeTargetId:T}:{},open:re,sequence:$,targets:a})}function ye(a,p){return L&&p===h&&m.status!=="idle"&&b.includes(a)}function q(){let a=b.reduce((p,y)=>p+y.instruction.trim().length,0);return b.length>0&&a<=4e3&&b.every(p=>p.instruction.trim().length>0&&p.elementContext!==void 0&&p.styles!==void 0&&p.apiStatus!=="loading")}function Fe(){let a=n.messages().summary;return b.map((p,y)=>{let P=To({resolution:p.resolution,...p.code===void 0?{}:{code:p.code},...p.styles===void 0?{}:{styles:p.styles},apiStatus:p.apiStatus,collectionStatus:p.collectionStatus,framework:e.framework,frameworkVersion:e.frameworkVersion,spotPatchVersion:e.spotPatchVersion},a);return`${a.target(y+1,p.id===T)}
|
|
960
|
-
${
|
|
856
|
+
${Zo}
|
|
857
|
+
`,t}function Wi(e,t){return e.split(`
|
|
858
|
+
`).find(n=>n.startsWith(`${t}: `))?.slice(t.length+2).trim()}function Gi(e){let t=e.target;return t instanceof Element&&t.closest("a, button, input, select, textarea, summary, [contenteditable='true']")!==null}function qi(e){let t=oe(e,"","spotpatch-execution-island");t.hidden=!0,t.setAttribute("aria-hidden","true");let o=In(e,void 0,"spotpatch-fallback-execution-island");o.classList.add("spotpatch-execution-logo");let n=g(e,"span");return t.append(o,n),Object.freeze({canExpand:()=>!1,isExpanded:()=>!1,root:t,setExpanded:()=>{},render(s){let d=[s.headline,s.action,s.meta].filter(i=>i.length>0).join(" · ");n.textContent=d,t.setAttribute("aria-label",d)},dispose(){}})}function Ki(e,t,o){return t.append(o),Object.freeze({root:t,refreshButton:oe(e,""),styles:e.createElement("style"),dispose:()=>{},render:()=>{},resetView:()=>{}})}function hr(e,t,o=Object.freeze({enabled:!1}),n="auto",s=!1,d=!1,i="vite",l=""){let A=ir(e,n),w=e.defaultView;if(w===null)throw new Error("SpotPatch requires a document with an associated window.");let T=w,N=mr(T,dr(T,l),Ot),r=A.messages(),F="idle",M=!1,I=!1,b,x,K,J,G,h,R=e.createElement("spotpatch-root");R.setAttribute(kt,"");let O=R.attachShadow({mode:"open"}),_=g(e,"div");_.className="spotpatch-floating-surface",_.dataset.scene="pill",_.dataset.tone="neutral";let U=oe(e,r.trigger.select,"spotpatch-trigger");U.title=r.trigger.title(t),U.setAttribute("aria-pressed","false");let S=tr(),C=S?.createExecutionIsland(e),v=C??qi(e),L=v.root,te=g(e,"div");te.className="spotpatch-highlight",te.hidden=!0;let Ee=g(e,"span");Ee.className="spotpatch-highlight-label",te.append(Ee);let $=g(e,"div");$.className="spotpatch-selection-highlights",$.setAttribute("aria-hidden","true");let k=g(e,"section");k.className="spotpatch-dialog",k.hidden=!0,k.tabIndex=-1,k.setAttribute("role","dialog"),k.setAttribute("aria-labelledby","spotpatch-selection-title");let He=g(e,"div");He.className="spotpatch-shell";let de=g(e,"header");de.className="spotpatch-header",de.setAttribute("data-spotpatch-drag-handle","");let $e=g(e,"div");$e.className="spotpatch-brand-row";let Ae=g(e,"div");Ae.className="spotpatch-brand";let ht=g(e,"span");ht.className="spotpatch-brand-copy";let le=g(e,"span");le.className="spotpatch-brand-name";let We=g(e,"span");We.className="spotpatch-brand-context",ht.append(le,We),Ae.append(In(e),ht);let xe=g(e,"span");xe.className="spotpatch-header-controls";let be=g(e,"a");be.className="spotpatch-repository",be.href=Tn,be.target="_blank",be.rel="noopener noreferrer";let Re=oe(e,"","spotpatch-locale"),Y=oe(e,"⌖","spotpatch-reset-position"),_e=oe(e,"×","spotpatch-close");xe.append(be,Re,Y,_e),$e.append(Ae,xe);let Ke=g(e,"h2");Ke.id="spotpatch-selection-title",Ke.className="spotpatch-title";let Je=g(e,"p");Je.className="spotpatch-subtitle";let Qe=g(e,"div");Qe.className="spotpatch-target-row";let Xe=g(e,"span");Xe.className="spotpatch-target-label";let ne=g(e,"span");ne.className="spotpatch-context-state",ne.dataset.state="loading",ne.textContent=r.context.collecting,Qe.append(Xe,ne),de.append($e,Ke,Je,Qe);let xt=g(e,"div");xt.className="spotpatch-body";let et=g(e,"div");et.className="spotpatch-selection-panel";let tt=g(e,"section");tt.className="spotpatch-targets";let Be=g(e,"div");Be.className="spotpatch-targets-heading";let ze=g(e,"span"),j=g(e,"span");j.className="spotpatch-targets-meta";let Ce=g(e,"span");Ce.className="spotpatch-target-complete";let Te=g(e,"span");Te.className="spotpatch-target-budget",Te.setAttribute("aria-live","polite");let nt=g(e,"span");nt.className="spotpatch-target-count",j.append(Ce,Te),Qe.append(nt),Be.append(ze,j);let st=g(e,"div");st.className="spotpatch-target-progress",st.setAttribute("aria-hidden","true");let yt=g(e,"div");yt.className="spotpatch-target-progress-fill",st.append(yt);let fe=g(e,"div");fe.className="spotpatch-target-list",tt.append(Be,st,fe);let je=g(e,"details");je.className="spotpatch-diagnostics";let ot=g(e,"summary"),ve=g(e,"span"),rt=g(e,"span");rt.className="spotpatch-source-peek",rt.textContent=r.diagnostics.resolving,ot.append(ve,rt);let Le=g(e,"pre");Le.className="spotpatch-summary",je.append(ot,Le);let P=Qo(e,o,A),ct=g(e,"div");function re(){M&&N.requestReconcile()}let Z=d?dn()?.createPanel(e,i,A.locale,l,A.subscribe,re,Tr,vr):void 0;ct.append(tt,P.root,...Z===void 0?[]:[Z.root]);let Ge=Wt()?.createPanel(e,s,A.locale,ct,je,re)??Ki(e,ct,je);et.append(Ge.root);let qe=g(e,"div");qe.className="spotpatch-preview-panel",qe.hidden=!0;let me=g(e,"pre");me.className="spotpatch-prompt",me.tabIndex=0,me.setAttribute("aria-label",r.diagnostics.promptAriaLabel),qe.append(me),xt.append(et,qe);let bt=g(e,"footer");bt.className="spotpatch-actions";let Pe=g(e,"div");Pe.className="spotpatch-context-state spotpatch-editor-feedback",Pe.dataset.state="idle",Pe.setAttribute("role","status"),Pe.setAttribute("aria-live","polite"),Pe.hidden=!0;let Ie=oe(e,r.actions.addElement),Ye=oe(e,r.actions.reselect),Q=oe(e,r.actions.openEditor),Ue=oe(e,r.actions.preview,"spotpatch-primary"),c=oe(e,r.actions.copy,"spotpatch-primary"),u=oe(e,r.actions.back),E=g(e,"div");E.className="spotpatch-secondary-actions";let H=g(e,"div");H.className="spotpatch-primary-actions",Ie.classList.add("spotpatch-icon-action"),Ie.dataset.compactIcon="+",P.testButton.classList.add("spotpatch-icon-action"),P.testButton.dataset.compactIcon="✓",Q.classList.add("spotpatch-secondary-action"),Ye.classList.add("spotpatch-secondary-action"),E.append(Q,Ye),H.append(P.testButton,Ie,P.runButton,...Z===void 0?[]:[Z.sendButton],Ue,P.cancelButton,P.applyButton,P.revertButton,P.resetButton,c,u),bt.append(Pe,E,H),He.append(de,xt,bt),k.append(He);let V=g(e,"div");V.className="spotpatch-live",V.setAttribute("aria-live","polite"),V.setAttribute("aria-atomic","true");let ie=[Vi(e),...S===void 0?[]:[S.createStyles(e)],Ge.styles,...Z===void 0?[]:[Z.styles]],y=Ui(e);if(y!==void 0)for(let a of ie)a.nonce=y;O.append(...ie,$,te,_,V),_.append(U,k,L),e.documentElement.append(R),N.registerSurface(_);let W=S===void 0||C===void 0?void 0:S.createController(e,Object.freeze({execution:C.elements,pill:U,planner:k,surface:_}),N.reconcile),pe=()=>{W?.cancel()};N.attachDraggable(U,_,{onDragStart:pe,suppressClickOnDrag:!0}),N.attachDraggable(de,_,{canStartDrag:a=>!N.isCompact()&&!Gi(a),onDragStart:pe}),N.attachDraggable(L,_,{onDragStart:pe,suppressClickOnDrag:!0}),N.reconcile();let se=!1,Ne=!1,_t="",Lt=!0,at=[],qt=0,$n="idle",Bn=Object.freeze({component:Object.freeze({status:s?"idle":"disabled"}),page:Object.freeze({status:s?"idle":"disabled"}),observationCount:0});function Kt(){let a=at.find(f=>f.active);return Object.freeze(a===void 0?{label:r.context.selectedElement,source:""}:{label:a.label,source:a.source})}function Pt(){let a=Kt();return a.source.length===0?a.label:`${a.label} · ${a.source}`}function zn(){return h=new Date().toISOString(),h}function jn(){return h??zn()}function Jt(a){G!==void 0&&(T.clearTimeout(G),G=void 0),a&&(K=void 0,J=void 0)}function pn(a){return J===a?!1:(K===a||(Jt(!1),K=a,G=T.setTimeout(()=>{G=void 0,R.isConnected&&(J=a,b=void 0,h=void 0,I=!1,M=!1,we())},ji)),!0)}function Cr(a){return a.startsWith("claude")?r.execution.claude:a.startsWith("codex")?r.execution.codex:a}function Un(a){return Object.freeze({...a.detail===void 0?{}:{detail:a.detail},key:a.key,kind:a.kind,label:r.execution.activityLane(a.kind,a.detail),state:a.state})}function Dt(a,f,m,D="active"){return Object.freeze({...m===void 0?{}:{detail:m},key:a,kind:f,label:r.execution.activityLane(f,m),state:D})}function we(){let a=F==="inspecting",f=!M||a,m=f?{scene:a?"capturing":"pill",tone:a?"capturing":"neutral",headline:U.textContent,action:"",meta:"",recentActivities:Object.freeze([])}:!I&&b!==void 0?b:{scene:"planner",tone:"ready",headline:r.dialog.editTitle,action:r.dialog.editSubtitle,meta:r.context.ready,recentActivities:Object.freeze([])};if(W!==void 0){W.render(m,()=>{v.render(m)});return}v.render(m),_.dataset.scene=m.scene,_.dataset.tone=m.tone;let D=m.scene==="planner";U.hidden=!f,U.inert=!f,k.hidden=!D,k.inert=!D,k.setAttribute("aria-hidden",String(!D)),L.hidden=f||D,L.inert=f||D,L.setAttribute("aria-hidden",String(f||D)),N.reconcile()}function Tr(a){if(a===null?(x=void 0,h=void 0):x!==void 0&&a.phase!=="failed"&&a.phase!=="delivery-unknown"?un():(a.phase==="failed"||a.phase==="delivery-unknown")&&(x=void 0),a!==null&&!I){let f=a.phase==="failed"||a.phase==="delivery-unknown",m=a.phase==="completed",D=f||m?void 0:jn();(f||m)&&(h=void 0);let B=`dispatch:${String(a.revision)}`;if(m&&!pn(B)){b=void 0,we();return}let ae=Cr(a.adapterKind),ke=Kt(),ue=a.phase==="queued"||a.phase==="dispatching"||a.phase==="dispatched"?"dispatch":m?"sync":"unknown",De=Dt(`dispatch:${String(a.revision)}:${a.phase}`,ue,a.phase,f?"failure":m?"success":"active"),z=f?"failed":m?"success":a.phase==="working"?"running":"handoff";b={scene:z,tone:f?"danger":m?"success":"running",headline:m?r.execution.completedTitle:f?r.execution.failedTitle:z==="running"?r.execution.runningTitle(ke.label):r.execution.dispatchingTitle(ae),action:m?r.execution.resultReturned:ke.source,expandedHeadline:m?r.execution.expandedCompletedTitle:f?r.execution.failedTitle:z==="running"?r.execution.expandedRunningTitle(ae):r.execution.dispatchingTitle(ae),expandedAction:m?r.execution.resultReturned:Pt(),meta:f?r.execution.failedStatus:m?r.execution.completedStatus:z==="running"?r.execution.runningStatus:r.execution.dispatchingStatus,activity:De,recentActivities:Object.freeze([De]),...D===void 0?{}:{startedAt:D}}}else a===null&&(b=void 0);we()}function vr(a){let f=a?.task;if(a===void 0||f===void 0||I)return;let m=f.managedPhase,D=m==="failed"||m==="cleanup-warning",B=m==="completed"||m==="review-required",ae=m==="cancelled";if(D||ae?x=void 0:x!==void 0&&un(),ae){b=void 0,h=void 0,we();return}let ke=D||B?void 0:jn();if((D||B)&&(h=void 0),m==="completed"&&!pn(`managed:${String(f.revision)}`)){b=void 0,we();return}let ue=D?"failed":B?"success":m==="preparing"?"handoff":"running",De=D?"danger":B?"success":"running",z=r.execution.codex,X=Kt(),Ze=m==="preparing"?"prepare":m==="auditing"?"audit":m==="validating"?"check":m==="applying"?"apply":B?"sync":"unknown",dt=f.checks.at(-1),lt=f.files.at(-1),pt=m==="validating"?dt?.id:m==="auditing"||m==="applying"?lt?.path:void 0,Rt=Dt(`managed:${String(f.revision)}:${m}:${pt??""}`,Ze,pt,D?"failure":B?"success":"active"),Ht=Object.freeze([...f.files.slice(-2).map(ut=>Dt(`managed-file:${String(f.revision)}:${ut.path}`,"patch",ut.path,"success")),...f.checks.slice(-2).map(ut=>Dt(`managed-check:${String(f.revision)}:${ut.id}`,"check",ut.id,ut.outcome==="passed"?"success":"failure")),Rt]);b={scene:ue,tone:De,headline:B?r.execution.completedTitle:D?r.execution.failedTitle:ue==="handoff"?r.execution.dispatchingTitle(z):m==="validating"?r.execution.activityAction("check",pt):r.execution.runningTitle(X.label),action:B?f.files.length===0?r.execution.resultReturned:r.execution.resultSummary(f.files.length):X.source,expandedHeadline:B?r.execution.expandedCompletedTitle:D?r.execution.failedTitle:ue==="handoff"?r.execution.dispatchingTitle(z):r.execution.expandedRunningTitle(z),expandedAction:B?r.execution.resultReturned:Pt(),meta:D?r.execution.failedStatus:B?r.execution.completedStatus:m==="validating"?r.execution.checkingStatus:ue==="handoff"?r.execution.dispatchingStatus:r.execution.runningStatus,activity:Rt,recentActivities:Ht,...ke===void 0?{}:{startedAt:ke}},we()}function wr(a,f){if(!M)return;Jt(!0);let m=zn();I=!1;let D=Dt(`dispatch-start:${Pt()}`,"dispatch",Pt());b={scene:"agent-charging",tone:"running",headline:r.execution.receivingTitle,action:Pt(),expandedHeadline:r.execution.receivingTitle,expandedAction:Pt(),meta:r.execution.receivingStatus,activity:D,recentActivities:Object.freeze([D]),startedAt:m},we(),W?.dispatch(a,f)}function Vn(a,f){!M||a.disabled||(x=Object.freeze({source:a,target:f}))}function un(){let a=x;x=void 0,!(a===void 0||!a.source.isConnected||!a.target.isConnected)&&wr(a.source,a.target)}function gn(a){$n=a,Pe.dataset.state=a,Pe.hidden=a==="idle",Pe.textContent=a==="opening"?r.announcements.editorOpening:a==="success"?r.announcements.editorOpened:a==="error"?r.announcements.editorFailed:"",re()}function Or(a){return a.status==="ready"?r.targets.statusReady:a.status==="warning"?r.targets.statusPartial:r.targets.statusCollecting}function Xt(a,f){let m=f===0?0:a/f;yt.style.width=`${String(m*100)}%`}function Wn(a){let f=fe.querySelectorAll("textarea[data-target-instruction-id]");return Array.from(f).find(m=>a===void 0||m.dataset.targetInstructionId===a)}function Gn(a,f){let m=O.activeElement?.closest("textarea[data-target-instruction-id]"),D=m?.dataset.targetInstructionId,B=m?.selectionStart,ae=m?.selectionEnd;at=a.map(z=>Object.freeze({...z})),qt=f,fe.replaceChildren();let ke=a.filter(z=>z.instruction.trim().length>0).length,ue=a.reduce((z,X)=>z+X.instruction.trim().length,0);Xt(ke,a.length),nt.textContent=r.targets.count(a.length,f),Ce.textContent=r.targets.complete(ke,a.length);let De=ue>4e3;Te.dataset.state=De?"over":"ready",Te.textContent=De?r.targets.instructionBudgetExceeded(ue,4e3):r.targets.instructionBudget(ue,4e3),Ie.disabled=!Lt||a.length>=f,Ie.title=a.length>=f?r.targets.limitTitle(f):r.targets.addTitle,Xe.textContent=a.length===1?a[0]?.label??r.context.selectedElement:r.context.selectedCount(a.length);for(let[z,X]of a.entries()){let Ze=g(e,"div");Ze.className="spotpatch-target-item",Ze.dataset.active=String(X.active),Ze.dataset.status=X.status,Ze.dataset.targetId=X.id;let dt=g(e,"div");dt.className="spotpatch-target-summary";let lt=oe(e,"","spotpatch-target-select");lt.dataset.activateTargetId=X.id,lt.setAttribute("aria-label",r.targets.activate(z+1)),lt.setAttribute("aria-expanded",String(X.active));let pt=g(e,"span");pt.className="spotpatch-target-index",pt.textContent=String(z+1);let Rt=g(e,"span");Rt.className="spotpatch-target-copy";let Ht=g(e,"span");Ht.className="spotpatch-target-name",Ht.textContent=X.label;let ut=g(e,"span");ut.className="spotpatch-target-source",ut.textContent=`${Or(X)} · ${X.source}`,Rt.append(Ht,ut);let no=X.instruction.trim().length>0,Yt=g(e,"span");Yt.className="spotpatch-target-state",Yt.dataset.complete=String(no),Yt.textContent=no?r.targets.instructionReady:r.targets.instructionMissing,lt.append(pt,Rt,Yt);let $t=oe(e,"↗","spotpatch-target-open");$t.dataset.openTargetId=X.id,$t.disabled=!X.canOpenEditor,$t.setAttribute("aria-label",r.actions.openTarget(z+1)),$t.title=r.actions.openTarget(z+1);let Bt=oe(e,"×","spotpatch-target-remove");if(Bt.dataset.removeTargetId=X.id,Bt.disabled=!Lt,Bt.setAttribute("aria-label",r.targets.remove(z+1)),Bt.title=r.targets.removeTitle,dt.append(lt,$t,Bt),Ze.append(dt),X.active){let mn=g(e,"label");mn.className="spotpatch-target-editor";let hn=g(e,"span");hn.className="spotpatch-target-editor-head";let yn=g(e,"span");yn.className="spotpatch-target-editor-label",yn.textContent=r.targets.instructionLabel(X.label);let bn=g(e,"span");bn.className="spotpatch-target-editor-count",bn.textContent=r.targets.instructionCount(X.instruction.length,2e3),hn.append(yn,bn);let Ct=g(e,"textarea");Ct.rows=4,Ct.maxLength=2e3,Ct.value=X.instruction,Ct.placeholder=r.targets.instructionPlaceholder,Ct.disabled=!Lt,Ct.dataset.targetInstructionId=X.id,Ct.setAttribute("aria-label",r.targets.instructionLabel(X.label)),mn.append(hn,Ct),Ze.append(mn)}fe.append(Ze)}if(D!==void 0){let z=Wn(D);z?.focus({preventScroll:!0}),B!==void 0&&ae!==void 0&&z?.setSelectionRange(B,ae)}re()}function _r(a,f){at=at.map(z=>z.id===a?Object.freeze({...z,instruction:f}):z);let m=Array.from(fe.querySelectorAll(".spotpatch-target-item")).find(z=>z.dataset.targetId===a);if(m===void 0)return;let D=f.trim().length>0,B=m.querySelector(".spotpatch-target-state"),ae=m.querySelector(".spotpatch-target-editor-count");B!==null&&(B.dataset.complete=String(D),B.textContent=D?r.targets.instructionReady:r.targets.instructionMissing),ae!==null&&(ae.textContent=r.targets.instructionCount(f.length,2e3));let ke=at.filter(z=>z.instruction.trim().length>0).length;Ce.textContent=r.targets.complete(ke,at.length),Xt(ke,at.length);let ue=at.reduce((z,X)=>z+X.instruction.trim().length,0),De=ue>4e3;Te.dataset.state=De?"over":"ready",Te.textContent=De?r.targets.instructionBudgetExceeded(ue,4e3):r.targets.instructionBudget(ue,4e3)}function Lr(a){$.replaceChildren();for(let[f,m]of a.entries()){let D=g(e,"div");D.className="spotpatch-selection-highlight",D.dataset.targetId=m.id,D.dataset.active=String(m.active),D.style.transform=`translate(${String(m.rect.x)}px, ${String(m.rect.y)}px)`,D.style.width=`${String(m.rect.width)}px`,D.style.height=`${String(m.rect.height)}px`;let B=g(e,"span");B.textContent=`${String(f+1)} · ${m.label}`,D.append(B),$.append(D)}}function qn(a){let f=r.summary,m=Wi(a,f.source);rt.textContent=m??r.diagnostics.noExactSource;let D=`${f.browserContext}: ${f.collectionStatuses.ready}`,B=`${f.browserContext}: ${f.collectionStatuses.loading}`,ae=`${f.browserContext}: ${f.collectionStatuses.failed}`,ke=`${f.api}: ${f.apiStatuses.loading}`,ue=`${f.api}: ${f.apiStatuses.failed}`;a.includes(D)&&!a.includes(B)&&!a.includes(ke)&&!a.includes(ae)&&!a.includes(ue)?(ne.dataset.state="ready",ne.textContent=r.context.ready):a.includes(ae)||a.includes(ue)?(ne.dataset.state="warning",ne.textContent=r.context.partial):(ne.dataset.state="loading",ne.textContent=r.context.collecting)}function Kn(a,f,m){se=f,Ne=m,_t=a,Le.textContent=a,Q.disabled=!f,Ue.disabled=!m,P.setContextReady(m),Z?.setContextReady(m),qn(a),re()}function fn(a){F=a;let f=a==="selected",m=a==="previewing";et.hidden=!f,qe.hidden=!m,Ye.hidden=!f,Ie.hidden=!f,Q.hidden=!f,Ue.hidden=!f,E.hidden=!f,P.setSelectionVisible(f),Z?.setSelectionVisible(f),c.hidden=!m,u.hidden=!m,Ke.textContent=m?r.dialog.previewTitle:r.dialog.editTitle,Je.textContent=m?r.dialog.previewSubtitle:r.dialog.editSubtitle,we()}function Jn(){r=A.messages(),le.textContent=r.brand.name,We.textContent=r.brand.context,be.textContent=r.brand.repository,be.title=r.brand.repositoryTitle,be.setAttribute("aria-label",r.brand.repositoryTitle),Re.textContent=r.alternateLocaleName,Re.title=r.switchLocale,Re.setAttribute("aria-label",r.switchLocale),Y.title=r.floatingSurface.resetPosition,Y.setAttribute("aria-label",r.floatingSurface.resetPosition),_e.setAttribute("aria-label",r.dialog.close),_e.title=r.dialog.close,de.title=r.floatingSurface.dragHandle,tt.setAttribute("aria-label",r.targets.ariaLabel),ze.textContent=r.targets.title,ve.textContent=r.diagnostics.title,me.setAttribute("aria-label",r.diagnostics.promptAriaLabel),Ie.textContent=r.actions.addElement,Ye.textContent=r.actions.reselect,Q.textContent=r.actions.openEditor,Ue.textContent=r.actions.preview,c.textContent=r.actions.copy,u.textContent=r.actions.back,Ge.render(Bn),U.title=r.trigger.title(t),U.textContent=F==="inspecting"?r.trigger.stop:r.trigger.select,fn(F),gn($n),at.length>0?Gn(at,qt):(nt.textContent=r.targets.count(0,qt),Ce.textContent=r.targets.complete(0,0),Xt(0,0),Te.dataset.state="ready",Te.textContent=r.targets.instructionBudget(0,4e3),Xe.textContent=r.context.selectedElement),_t.length>0?qn(_t):(rt.textContent=r.diagnostics.resolving,ne.textContent=r.context.collecting)}function Xn(a){V.textContent="",V.textContent=a}function Yn(){N.reset(),Xn(r.floatingSurface.positionReset)}je.addEventListener("toggle",re),Re.addEventListener("click",A.toggle),Y.addEventListener("click",Yn);let Zn=()=>{Vn(P.runButton,P.root)},Qn=()=>{Z!==void 0&&Vn(Z.sendButton,Z.root)},eo=()=>{if(v.canExpand()&&!v.isExpanded()){W===void 0?(v.setExpanded(!0),N.reconcile()):W.updateLayout(()=>{v.setExpanded(!0)});return}Jt(!1),I=!0,we()},to=a=>{a.key!=="Escape"||!v.isExpanded()||(a.preventDefault(),a.stopPropagation(),W===void 0?(v.setExpanded(!1),N.reconcile()):W.updateLayout(()=>{v.setExpanded(!1)}))};P.runButton.addEventListener("click",Zn),Z?.sendButton.addEventListener("click",Qn),L.addEventListener("click",eo),L.addEventListener("keydown",to);let Pr=A.subscribe(Jn);return Jn(),Object.freeze({host:R,triggerButton:U,addTargetButton:Ie,targetList:fe,reselectButton:Ye,openEditorButton:Q,repositoryLink:be,previewButton:Ue,copyButton:c,dataFlowRefreshButton:Ge.refreshButton,backButton:u,closeButton:_e,agentProviderSelect:P.providerSelect,agentModelSelect:P.modelSelect,agentModeSelect:P.modeSelect,agentConsentCheckbox:P.consentCheckbox,agentWorkspaceConsentCheckbox:P.workspaceConsentCheckbox,agentTestButton:P.testButton,agentRunButton:P.runButton,agentCancelButton:P.cancelButton,agentApplyButton:P.applyButton,agentRevertButton:P.revertButton,agentResetButton:P.resetButton,...Z===void 0?{}:{externalHandoffPanel:Z},renderStatus(a){let f=a==="inspecting";a==="idle"||f?M=!1:M=!0,U.setAttribute("aria-pressed",String(f)),U.textContent=f?r.trigger.stop:r.trigger.select,fn(a)},renderEditorStatus:gn,renderDataFlow(a){Bn=a,Ge.render(a),re()},showHighlight(a,f){te.hidden=!1,te.style.transform=`translate(${String(a.x)}px, ${String(a.y)}px)`,te.style.width=`${String(a.width)}px`,te.style.height=`${String(a.height)}px`,Ee.textContent=f,Xe.textContent=f},hideHighlight(){te.hidden=!0,Ee.textContent=""},showSelectionHighlights:Lr,hideSelectionHighlights(){$.replaceChildren()},showSelection(a,f,m){Kn(a,f,m),M=!0,fn(F==="previewing"?"previewing":"selected")},updateSelection:Kn,renderTargets:Gn,updateTargetInstruction:_r,setPreviewEnabled(a){Ne=a,Ue.disabled=!a,P.setContextReady(a),Z?.setContextReady(a)},hideSelection(){M=!1,I=!1,b=void 0,fe.replaceChildren(),at=[],qt=0,_t="",gn("idle"),nt.textContent=r.targets.count(0,0),Ce.textContent=r.targets.complete(0,0),Xt(0,0),Xe.textContent=r.context.selectedElement,Le.textContent="",me.textContent="",rt.textContent=r.diagnostics.resolving,ne.dataset.state="loading",ne.textContent=r.context.collecting,Q.disabled=!0,Ue.disabled=!0,se=!1,Ne=!1,P.setContextReady(!1),P.setSelectionVisible(!1),Z?.setContextReady(!1),Z?.setSelectionVisible(!1),P.setEditingEnabled(!0),P.resetJob(),Ge.resetView(),we()},hideSelectionTemporarily(){M=!1,I=!1,b=void 0,we()},showPreview(a){me.textContent=a,re()},readAgentSelection(){return P.readSelection()},agentConsentGranted(){return P.consentGranted()},setAgentProviderConsent(a){P.setProviderConsent(a)},setAgentEditingEnabled(a){Lt=a,Ie.disabled=!a,Ye.disabled=!a,fe.querySelectorAll(".spotpatch-target-remove, .spotpatch-target-select, textarea[data-target-instruction-id]").forEach(f=>{f.disabled=!a}),Q.disabled=!se,Ue.disabled=!a||!Ne,Z?.setContextReady(a&&Ne),P.setEditingEnabled(a),re()},renderAgentCapability(a,f,m,D){P.renderCapability(a,f,m,D),a==="error"&&(x=void 0,we());let B=a==="ready"&&m?.state==="agent-ready";Ue.classList.toggle("spotpatch-primary",!B),re()},renderAgentWorkspaceHealth(a,f,m){P.renderWorkspaceHealth(a,f,m),a==="blocked"&&(x=void 0,we()),re()},renderAgentJob(a,f,m,D){P.renderJob(a,f,m,D),x!==void 0&&a.status!=="failed"&&a.status!=="cancelled"&&un(),(a.status==="failed"||a.status==="cancelled")&&(x=void 0);let B=a.status==="awaiting-review"||a.status==="applied"||a.status==="completed"||a.status==="reverted",ae=a.status==="failed",ke=a.status==="cancelled",ue=a.status==="applied"||a.status==="completed"||a.status==="reverted",De=B?"success":ae?"failed":a.status==="queued"||a.status==="preparing"?"handoff":"running";if(!I){if(ue&&!pn(`job:${a.jobId}:${a.status}`)){b=void 0,we(),re();return}let z=a.providerLabel,X=Kt(),Ze=Object.freeze(m.map(Un)),dt=m.at(-1),lt=a.status==="queued"||a.status==="preparing"?"prepare":a.status==="validating"?"check":a.status==="applying"||a.status==="reverting"?"apply":a.status==="awaiting-review"||B?"sync":"unknown",pt=Dt(`job-phase:${a.jobId}:${a.status}:${a.updatedAt}`,lt,void 0,B?"success":ae?"failure":"active"),Rt=a.status==="running"&&dt!==void 0?Un(dt):pt;b=ke?void 0:{scene:De,tone:B?"success":ae?"danger":"running",headline:B?r.execution.completedTitle:ae?r.execution.failedTitle:De==="handoff"?r.execution.dispatchingTitle(z):a.status==="validating"?r.execution.activityAction("check",dt?.detail):a.status==="applying"||a.status==="reverting"?r.execution.activityAction(lt):r.execution.runningTitle(X.label),action:B?f===void 0||f.files.length===0?r.execution.resultReturned:r.execution.resultSummary(f.files.length):dt?.detail??X.source,expandedHeadline:B?r.execution.expandedCompletedTitle:ae?r.execution.failedTitle:De==="handoff"?r.execution.dispatchingTitle(z):r.execution.expandedRunningTitle(z),expandedAction:B?f===void 0||f.files.length===0?r.execution.resultReturned:r.execution.resultSummary(f.files.length):Pt(),meta:B?r.execution.completedStatus:ae?r.execution.failedStatus:a.status==="validating"?r.execution.checkingStatus:De==="handoff"?r.execution.dispatchingStatus:r.execution.runningStatus,activity:Rt,recentActivities:Ze.length===0?Object.freeze([pt]):Ze,startedAt:a.createdAt}}we(),re()},resetAgentJob(){P.resetJob(),h=void 0,b!==void 0&&(b=void 0,I=!1,we()),re()},focusTargetInstruction(a){Wn(a)?.focus({preventScroll:!0})},focusPrompt(){me.focus({preventScroll:!0})},announce:Xn,locale:A.locale,messages:A.messages,agentWorkspaceConsentGranted:P.workspaceConsentGranted,subscribeLocale:A.subscribe,dispose(){je.removeEventListener("toggle",re),Re.removeEventListener("click",A.toggle),Y.removeEventListener("click",Yn),P.runButton.removeEventListener("click",Zn),Z?.sendButton.removeEventListener("click",Qn),L.removeEventListener("click",eo),L.removeEventListener("keydown",to),Pr(),Ge.dispose(),Z?.dispose(),P.dispose(),W?.dispose(),v.dispose(),Jt(!0),N.dispose(),R.remove()}})}function Ji(e,t,o){let n=t?.relativePath??e.source.relativePath,s=e.source.line,d=e.source.column;return n!==void 0&&s!==void 0?`${n}:${String(s)}${d===void 0?"":`:${String(d)}`}`:n!==void 0?n:s!==void 0?o.lineLocation(s,d):o.unavailable}function yr(e,t){let o=[`SpotPatch: ${e.spotPatchVersion}`,`${e.framework==="next"?"Next.js":"Vite"}: ${e.frameworkVersion}`,`${t.source}: ${Ji(e.resolution,e.code,t)}`,`${t.confidence}: ${e.resolution.source.confidence} (${t.confidenceLabels[e.resolution.source.confidence]})`,`${t.origin}: ${e.resolution.source.origin}`];return e.resolution.react.componentName!==void 0&&o.push(`${t.component}: ${e.resolution.react.componentName}`),e.resolution.react.componentStack.length>0&&o.push(`${t.stack}: ${e.resolution.react.componentStack.join(" > ")}`),!e.resolution.react.supported&&e.resolution.react.version!==void 0&&o.push(`React ${e.resolution.react.version}: ${t.unsupported}`),o.push(`${t.adapter}: ${e.resolution.react.supported?t.available:t.unavailable}`,`${t.api}: ${t.apiStatuses[e.apiStatus]}`,`${t.browserContext}: ${t.collectionStatuses[e.collectionStatus]}`),e.code!==void 0?o.push(`${t.boundary}: ${t.boundaries[e.code.boundary]}`):e.apiStatus==="loading"?o.push(`${t.sourceContext}: ${t.apiStatuses.loading}`):e.apiStatus==="failed"&&o.push(`${t.sourceContext}: ${t.unavailable}`),e.styles!==void 0&&(o.push(`${t.cssWarnings}: ${String(e.styles.warnings.length)}`),o.push(...e.styles.warnings.map(n=>`${t.warning}: ${n}`))),o.join(`
|
|
859
|
+
`)}function br(e,t){return`${e}:${t}`}var Xi=Object.freeze({list_files:"discover",search_text:"search",read_file:"read",replace_text:"patch",apply_patch:"patch",run_check:"check"});function Yi(e){return Xi[e]??"unknown"}function Zi(e){if(e.type==="tool"){let t=e.data.relativePath??e.data.checkLabel;return Object.freeze({key:`tool:${String(e.data.turn)}:${e.data.toolCallId}`,kind:Yi(e.data.toolName),...t===void 0?{}:{detail:t},label:`${e.data.toolName}${t===void 0?"":` · ${t}`} · ${e.data.state}`,state:e.data.state==="started"?"active":e.data.state==="succeeded"?"success":"failure"})}if(e.type==="check")return Object.freeze({key:`check:${e.data.result.checkId}:${String(e.sequence)}`,kind:"check",detail:e.data.result.label,label:`${e.data.result.label} · ${e.data.result.status}`,state:e.data.result.status==="passed"?"success":e.data.result.status==="failed"||e.data.result.status==="timed-out"?"failure":"info"})}function Sr(e){let t=h=>Eo(h)??p.INTERNAL_ERROR,o=h=>e.view.messages().errors[t(h)],n=new Map,s=new Set,d=new Map,i=0,l,A,w=!1,T=!1,N=()=>e.view.readAgentSelection(),r=h=>`${h.providerProfileId}:${h.applyMode}`,F=async h=>{e.view.renderAgentWorkspaceHealth("checking");try{let R=await e.api.agentWorkspaceHealth();return h!==i||e.view.renderAgentWorkspaceHealth(R.state,R,R.errorCode),R}catch(R){throw h===i&&e.view.renderAgentWorkspaceHealth("blocked",void 0,t(R)),R}},M=h=>{l!==void 0&&e.view.renderAgentJob(l,A,Object.freeze([...d.values()]),h??l.errorCode)},I=()=>{let h=N();if(h===void 0){e.view.setAgentProviderConsent(!1),e.view.renderAgentCapability("error",e.view.messages().agent.providerUnavailable);return}e.view.setAgentProviderConsent(s.has(r(h)));let R=n.get(br(h.providerProfileId,h.modelProfileId));R===void 0?e.view.renderAgentCapability("idle",e.view.messages().agent.connectionNotTested):e.view.renderAgentCapability("ready",e.view.messages().agent.capabilityVerified,R)},b=async h=>{let R=N();if(R===void 0)throw new Error("Agent provider selection is unavailable.");let O=br(R.providerProfileId,R.modelProfileId),_=n.get(O);if(_!==void 0)return _;e.view.renderAgentCapability("probing",e.view.messages().agent.testingCapability);let U=await e.api.agentCapability(R);if(h!==i)return U;if(U.state!=="agent-ready")throw new q(U.errorCode??p.MODEL_TOOL_CALL_UNSUPPORTED);return n.set(O,U),e.view.renderAgentCapability("ready",e.view.messages().agent.capabilityVerified,U),e.view.announce(e.view.messages().agent.capabilityVerifiedAnnouncement),U},x=async(h,R)=>{try{let O=await e.api.agentResult(h);if(R!==i||O.snapshot.jobId!==h)return;l=O.snapshot,A=O.result,M()}catch(O){R===i&&M(t(O))}},K=async(h,R)=>{try{await e.api.agentEvents(h,O=>{if(R!==i||O.jobId!==h)return;O.type==="snapshot"&&(l=O.data.snapshot,l.status==="applied"&&!w&&(w=!0,e.onApplied()));let _=Zi(O);_!==void 0&&d.set(_.key,_),M()}),R===i&&await x(h,R)}catch(O){R===i&&!(O instanceof DOMException&&O.name==="AbortError")&&M(t(O))}},J=async h=>{let R=l;if(R===void 0||T)return;T=!0;let O=i;l=Object.freeze({...R,status:h==="apply"?"applying":h==="cancel"?"cancelling":"reverting",phaseMessage:h==="apply"?e.view.messages().agent.applying:h==="cancel"?e.view.messages().agent.cancelling:e.view.messages().agent.reverting,canCancel:!1,canApply:!1,canRevert:!1}),M();try{let _=h==="apply"?await e.api.applyAgentJob(R.jobId):h==="cancel"?await e.api.cancelAgentJob(R.jobId):await e.api.revertAgentJob(R.jobId);if(O!==i)return;l=_,_.status==="applied"&&!w&&(w=!0,e.onApplied()),await x(_.jobId,O)}catch(_){if(O!==i)return;l=R,await x(R.jobId,O),M(t(_)),e.view.announce(o(_))}finally{O===i&&(T=!1)}},G=()=>{i+=1,l=void 0,A=void 0,d.clear(),w=!1,T=!1,e.view.resetAgentJob(),e.view.setAgentEditingEnabled(!0),I()};return Object.freeze({apply(){l?.canApply===!0&&J("apply")},beginSelection(){G();let h=i;e.ai.enabled&&F(h).catch(()=>{})},cancel(){l?.canCancel===!0&&J("cancel")},consentChanged(){let h=N();h!==void 0&&(e.view.agentConsentGranted()?s.add(r(h)):s.delete(r(h)))},disposeSelection(){let h=l?.canCancel===!0||l?.status==="cancelling"?l.jobId:void 0;i+=1,l=void 0,A=void 0,d.clear(),w=!1,T=!1,h!==void 0&&e.api.cancelAgentJob(h).catch(()=>{})},providerOrModelChanged(){i+=1,I(),F(i).catch(()=>{})},reset(){let h=w;G(),h?e.onReselectRequired():e.ai.enabled&&F(i).catch(()=>{})},revert(){l?.canRevert===!0&&J("revert")},run(){if(!e.ai.enabled||l!==void 0)return;let h=N(),R=e.getAnnotation();if(h===void 0||R===void 0){e.view.announce(e.view.messages().announcements.completeInstructions);return}if(!e.view.agentConsentGranted()){e.view.announce(e.view.messages().agent.consentRequired);return}s.add(r(h));let O=++i;e.view.setAgentEditingEnabled(!1),F(O).then(async _=>{if(O!==i)return;if(_.state==="blocked")throw new q(_.errorCode??p.WORKTREE_LOCAL_CHANGES_UNSUPPORTED);if(_.state==="consent-required"&&!e.view.agentWorkspaceConsentGranted())throw new q(p.WORKTREE_DIRTY);let U=await e.api.createAgentJob({annotation:R,applyMode:h.applyMode,providerProfileId:h.providerProfileId,modelProfileId:h.modelProfileId,providerDataConsent:!0,...h.applyMode==="trusted-auto"?{trustedFastModeConsent:!0}:{},workingTreeMode:_.state==="consent-required"?"include-local-changes":"require-clean"});O===i&&(l=U,A=void 0,d.clear(),M(),K(U.jobId,O))}).catch(_=>{O===i&&(e.view.setAgentEditingEnabled(!0),e.view.renderAgentCapability("error",o(_),void 0,t(_)),e.view.announce(o(_)))})},testCapability(){if(!e.ai.enabled||l!==void 0)return;let h=++i;Promise.all([b(h),F(h)]).catch(R=>{h===i&&(e.view.renderAgentCapability("error",o(R),void 0,t(R)),e.view.announce(o(R)))})}})}function Er(e){if(typeof e.crypto.randomUUID=="function")return e.crypto.randomUUID();let t=e.crypto.getRandomValues(new Uint8Array(16));return Array.from(t,o=>o.toString(16).padStart(2,"0")).join("")}function Fn(e,t){return Object.freeze({url:t.location.href,pathname:t.location.pathname,title:e.title,viewportWidth:t.innerWidth,viewportHeight:t.innerHeight,devicePixelRatio:t.devicePixelRatio})}function Ar(e){let t=Reflect.get(e,"clipboard");return typeof t=="object"&&t!==null&&"writeText"in t&&typeof t.writeText=="function"?t:void 0}var es=Object.freeze({classNames:Object.freeze([]),matchedRules:Object.freeze([]),computed:Object.freeze({}),warnings:Object.freeze(["CSS context collection failed."])});function Mn(e){let t=e.id.length>0?`#${e.id}`:"",o=Array.from(e.classList).slice(0,2).map(n=>`.${n}`).join("");return`<${e.tagName.toLowerCase()}${t}${o}>`}function ts(e,t){let o=e.code?.relativePath??e.resolution.source.relativePath,n=e.resolution.source.line,s=e.resolution.source.column;return o===void 0?t:`${o}${n===void 0?"":`:${String(n)}`}${s===void 0?"":`:${String(s)}`}`}function ns(e){return e.apiStatus==="failed"||e.collectionStatus==="failed"?"warning":e.apiStatus==="loading"||e.collectionStatus==="loading"?"loading":"ready"}function os(e){let t=e.document??globalThis.document,o=e.window??globalThis.window;return{document:t,window:o,mutationObserver:e.mutationObserver??globalThis.MutationObserver,resizeObserver:e.resizeObserver??globalThis.ResizeObserver}}function xr(e,t={}){let o=os(t),n=t.view??hr(o.document,e.shortcut,e.ai,e.locale,e.dataFlow.enabled,e.externalAgent.enabled,e.framework,e.sessionId),s=t.api??Ao({apiBase:e.apiBase,dataFlowReportMaxBytes:e.dataFlow.limits.reportMaxBytes,fetch:o.window.fetch.bind(o.window),sessionToken:e.sessionToken}),d=t.promptComposer??Uo({maxCharacters:e.budget.totalCharacters}),i=t.clipboard??Ar(o.window.navigator),l=t.createId??(()=>Er(o.window)),A=t.now??(()=>new Date().toISOString()),w=t.selectionSession??qo(o.window,e.sessionId,e.maxTargets),T=w.load(),N=Yo({adapter:t.reactAdapter??Qi({...e.dataFlow.enabled?{getComponentRegistration:c=>Wt()?.getComponentRegistration(c)}:{},maxComponentDepth:e.budget.maxComponentDepth}),onAdapterError(){n.announce(n.messages().announcements.adapterDisabled),e.debug&&console.warn("[spotpatch:react] Adapter failed and was disabled for this session.")}}),r=_n,F=!1,M,I,b=T?.targets.map(c=>{let u=Pn(c.source);return{id:c.id,resolution:Object.freeze({source:c.source,react:c.react}),apiStatus:u===void 0?"not-required":c.code===void 0?"failed":"connected",code:c.code,collectionStatus:"ready",dataFlowReport:void 0,dataFlowStatus:"idle",element:void 0,elementContext:c.element,instruction:c.instruction,marker:u,page:c.page,styles:c.styles}})??[],x=T?.activeTargetId,K=T?.sequence??0,J=T?.open??!1,G=!1,h=0,R=0,O=0,_,U="idle",S=!1,C="",v,L,te,Ee,$=new Map;function k(c){r=Vo(r,c),n.renderStatus(r.status)}function He(){return b.find(c=>c.id===x)??b.at(-1)}function de(c){let u=c.resolution.react;if(u.componentSourceId!==void 0&&u.sourceVersion!==void 0)return Object.freeze({schemaVersion:1,componentSourceId:u.componentSourceId,sourceVersion:u.sourceVersion});let E=c.marker;return E===void 0?void 0:Object.freeze({schemaVersion:1,fileId:E.fileId,line:E.line,column:E.column})}function $e(){let c=Wt(),u=c?.observations(o.window.location.pathname)??[],E=He();n.renderDataFlow({component:Object.freeze({status:e.dataFlow.enabled?E?.dataFlowStatus??"idle":"disabled",...E?.dataFlowReport===void 0?{}:{report:c?.mergeComponentReport(E.dataFlowReport,u)??E.dataFlowReport}}),page:Object.freeze({status:e.dataFlow.enabled?U:"disabled",..._===void 0?{}:{report:c?.mergePageReport(_,u)??_}}),observationCount:u.length})}async function Ae(){if(!e.dataFlow.enabled){$e();return}let c=He(),u=c===void 0?void 0:de(c),E=b.flatMap(W=>{let pe=de(W);return pe===void 0?[]:[pe]}),H=++O,V=h;c!==void 0&&(c.dataFlowStatus="loading"),U=E.length===0?"idle":"loading",$e();let[ie,y]=await Promise.allSettled([u===void 0?Promise.resolve(void 0):s.componentDataFlowReport(u),E.length===0?Promise.resolve(void 0):s.pageDataFlowReport({schemaVersion:1,targets:E})]);!F||H!==O||V!==h||(c!==void 0&&b.includes(c)&&(ie.status==="fulfilled"?(c.dataFlowReport=ie.value,c.dataFlowStatus=ie.value===void 0?"idle":"ready"):(c.dataFlowReport=void 0,c.dataFlowStatus="error")),y.status==="fulfilled"?(_=y.value,U=y.value===void 0?"idle":"ready"):(_=void 0,U="error"),$e())}function ht(c){if(!(c.elementContext===void 0||c.styles===void 0))return{id:c.id,instruction:c.instruction,page:c.page,source:c.resolution.source,react:c.resolution.react,element:c.elementContext,styles:c.styles,...c.code===void 0?{}:{code:c.code}}}function le(){let c=b.flatMap(E=>{let H=ht(E);return H===void 0?[]:[H]});if(c.length===0){w.clear();return}let u=new Set(c.map(({id:E})=>E));w.save({...x!==void 0&&u.has(x)?{activeTargetId:x}:{},open:J,sequence:K,targets:c})}function We(c,u){return F&&u===h&&r.status!=="idle"&&b.includes(c)}function xe(){let c=b.reduce((u,E)=>u+E.instruction.trim().length,0);return b.length>0&&c<=4e3&&b.every(u=>u.instruction.trim().length>0&&u.elementContext!==void 0&&u.styles!==void 0&&u.apiStatus!=="loading")}function be(){let c=n.messages().summary;return b.map((u,E)=>{let H=yr({resolution:u.resolution,...u.code===void 0?{}:{code:u.code},...u.styles===void 0?{}:{styles:u.styles},apiStatus:u.apiStatus,collectionStatus:u.collectionStatus,framework:e.framework,frameworkVersion:e.frameworkVersion,spotPatchVersion:e.spotPatchVersion},c);return`${c.target(E+1,u.id===x)}
|
|
860
|
+
${H}`}).join(`
|
|
961
861
|
|
|
962
|
-
`)}function Ie(){let a=b.flatMap(p=>{if(!p.element?.isConnected)return[];let y=Vt(p.element,o.window);return y===void 0?[]:[{id:p.id,label:bn(p.element),rect:y,active:p.id===T}]});a.length===0?n.hideSelectionHighlights():n.showSelectionHighlights(a)}function B(a=!1){if(b.length===0)return;n.renderTargets(b.map(k=>({id:k.id,label:k.resolution.react.componentName??(k.element===void 0?k.elementContext?.tagName??"Element":bn(k.element)),source:Ha(k,n.messages().context.sourceUnavailable),canOpenEditor:k.marker!==void 0,status:$a(k),active:k.id===T,instruction:k.instruction})),e.maxTargets),Ie();let p=Ue(),y=Fe(),P=p?.marker!==void 0;a?n.showSelection(y,P,q()):n.updateSelection(y,P,q())}function ee(){if(!q())return;let a=b.map(p=>{if(p.elementContext===void 0||p.styles===void 0)throw new Error("SpotPatch attempted to compose an incomplete target.");let y=[...p.apiStatus==="failed"?["Source context could not be loaded."]:[],...p.collectionStatus==="failed"?["Part of the browser context could not be collected."]:[]];return{instruction:p.instruction.trim(),page:p.page,source:p.resolution.source,react:p.resolution.react,element:p.elementContext,styles:p.styles,...p.code===void 0?{}:{code:p.code},warnings:y}});return An({id:u(),locale:n.locale(),createdAt:R(),page:hn(o.document,o.window),targets:a})}function Pe(a){n.showHighlight(Qn(a,o.window),bn(a))}function We(){Q?.isConnected===!0&&Q.focus({preventScroll:!0}),Q=void 0}function at(){for(let a of ge.values())o.window.clearTimeout(a);ge.clear()}function ze(){h+=1,i.cancelPending(),O.disposeSelection(),He?.cancelPending(),at(),F?.disconnect(),b=[],T=void 0,x+=1,I=void 0,G="idle",re=!1,H=!1,W=!1,Z="",n.hideSelection(),n.hideSelectionHighlights(),s.clear(),We()}function De(){m.status==="inspecting"?_({type:"CANCEL"}):m.status==="selected"?_({type:"CLOSE"}):m.status==="previewing"&&(_({type:"BACK"}),_({type:"CLOSE"})),re=!1,ae(),n.hideSelection(),n.hideSelectionHighlights(),We(),n.hideHighlight()}function v(){if(m.status!=="inspecting"||!W||b.length===0){De();return}W=!1,_({type:"SELECT"}),n.hideHighlight(),B(!0),n.focusTargetInstruction(T),n.announce(n.messages().announcements.addCancelled)}function Ke(){if(m.status==="inspecting"&&W){v();return}if(m.status!=="idle"){De();return}if(b.length>0){re=!0,_({type:"RESTORE"}),H||(O.beginSelection(),H=!0),B(!0),be(),n.focusTargetInstruction(T),ae();return}_({type:"ACTIVATE"}),n.hideSelection(),n.announce(n.messages().announcements.selectionEnabled)}function J(a=n.messages().announcements.chooseAnother){m.status==="selected"&&(_({type:"RESELECT"}),ze(),n.hideHighlight(),n.announce(a))}function se(){if(m.status==="selected"){if(b.length>=e.maxTargets){n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}W=!0,_({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideHighlight(),n.announce(n.messages().announcements.chooseAdditional(b.length,e.maxTargets))}}function fe(){h+=1,at(),F?.disconnect();for(let a of b)a.element=void 0;n.hideHighlight(),n.hideSelectionHighlights(),B(),s.clear(),n.announce(n.messages().announcements.appliedTargetsDetached)}let O=wo({ai:e.ai,api:i,getAnnotation:ee,onApplied:fe,onReselectRequired(){J(n.messages().announcements.reselectAfterChange)},view:n}),He=e.externalAgent.enabled&&n.externalHandoffPanel!==void 0?Wt()?.createWorkflow(o.window.fetch.bind(o.window),n.externalHandoffPanel,ee,e.sessionToken,o.window):void 0;async function Ee(a,p){let y=a.marker;if(y!==void 0)try{let P=await i.sourceContext({fileId:y.fileId,line:y.line,column:y.column,maxLines:e.budget.maxCodeLines});ye(a,p)&&(a.code=P,a.apiStatus="connected",ae(),B(),n.announce(n.messages().announcements.sourceLoaded))}catch(P){ye(a,p)&&(a.code=void 0,a.apiStatus="failed",ae(),B(),n.announce(n.messages().announcements.sourceFailed),e.debug&&!(P instanceof DOMException&&P.name==="AbortError")&&console.warn("[spotpatch:runtime] Source context request failed."))}}function ve(a,p){let y=a.element;if(y===void 0)return;let P=o.window.setTimeout(()=>{if(ge.delete(a.id),!ye(a,p))return;let k=!1;try{a.elementContext=Jn({element:y,maxCharacters:e.budget.domCharacters})}catch{a.elementContext=void 0,k=!0}try{a.styles=zn({document:o.document,element:y,maxCharacters:e.budget.cssCharacters})}catch{a.styles=Fa,k=!0}a.collectionStatus=k?"failed":"ready",ae(),B(),n.announce(k?n.messages().announcements.contextWarning:n.messages().announcements.contextCollected),e.debug&&a.styles.warnings.length>0&&console.warn(`[spotpatch:runtime] CSS collection completed with ${String(a.styles.warnings.length)} warning(s).`)},0);ge.set(a.id,P)}function je(a,p){return p!==void 0?b.find(y=>y.marker?.fileId===p.fileId&&y.marker.line===p.line&&y.marker.column===p.column):b.find(y=>y.element===a)}function ke(a){let p=z.resolve(a),y=mn(p.source),P=je(a,y);if(P!==void 0){T=P.id,W=!1,_({type:"SELECT"}),n.hideHighlight(),B(!0),be(),n.focusTargetInstruction(P.id),n.announce(n.messages().announcements.duplicate);return}if(b.length>=e.maxTargets){W=!1,_({type:"SELECT"}),n.hideHighlight(),B(!0),n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}b.length===0&&(Q=o.document.activeElement instanceof HTMLElement?o.document.activeElement:void 0,Z="",O.beginSelection(),H=!0),$+=1;let ne={id:`target-${String($)}`,element:a,resolution:p,marker:y,page:hn(o.document,o.window),code:void 0,elementContext:void 0,styles:void 0,instruction:"",apiStatus:y===void 0?"not-required":"loading",collectionStatus:"loading",dataFlowReport:void 0,dataFlowStatus:"idle"};b.push(ne),T=ne.id,W=!1;let f=h;_({type:"SELECT"}),n.hideHighlight(),F?.observe(a),B(!0),be(),re=!0,n.focusTargetInstruction(ne.id),ve(ne,f),y!==void 0?Ee(ne,f):n.announce(p.source.confidence==="probable"?n.messages().announcements.sourceProbable:n.messages().announcements.sourceMissing)}function ce(){if(M=void 0,m.status!=="inspecting"||N===void 0)return;let a=pn(o.document,o.window,N.x,N.y);if(_({type:"HOVER"}),a===void 0){n.hideHighlight();return}Pe(a)}function Ve(a){m.status==="inspecting"&&(N={x:a.clientX,y:a.clientY},M??=o.window.requestAnimationFrame(ce))}function $e(a){if(m.status!=="inspecting"||to(a.target))return;a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation();let p=pn(o.document,o.window,a.clientX,a.clientY);if(p===void 0){n.announce(n.messages().announcements.noSelectable);return}ke(p)}function le(a){if(a.key==="Escape"&&m.status!=="idle"){a.preventDefault(),m.status==="inspecting"&&W?v():m.status==="inspecting"||m.status==="selected"?De():(_({type:"BACK"}),n.focusTargetInstruction(T));return}Xn(a.target)||!Yn(a,e.shortcut,o.window.navigator.userAgent)||(a.preventDefault(),Ke())}function ut(a){if(m.status!=="selected"&&m.status!=="inspecting")return;let p=b.findIndex(k=>k.id===a);if(p<0)return;let[y]=b.splice(p,1);if(y===void 0)return;let P=ge.get(y.id);if(P!==void 0&&(o.window.clearTimeout(P),ge.delete(y.id)),y.element!==void 0&&F?.unobserve(y.element),T===y.id&&(T=b.at(-1)?.id),b.length===0){W=!0,m.status==="selected"&&_({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideSelectionHighlights(),I=void 0,G="idle",Te(),s.clear(),n.announce(n.messages().announcements.allTargetsRemoved);return}B(),be(),ae(),n.announce(n.messages().announcements.targetRemoved)}function me(){if(m.status==="idle"||b.length===0)return;let a=b.filter(p=>p.element!==void 0&&!p.element.isConnected);if(a.length>0){for(let p of a)p.element!==void 0&&(F?.unobserve(p.element),p.element=void 0);B(),ae(),n.announce(n.messages().announcements.detachedTargetPreserved);return}Ie()}function it(a){let p=a===void 0?Ue():b.find(ne=>ne.id===a);if(m.status!=="selected"||p?.marker===void 0)return;T!==p.id&&(T=p.id,B());let y=p.marker,P=h,k=++S;_({type:"OPEN_EDITOR"}),n.renderEditorStatus("opening"),i.openEditor({fileId:y.fileId,line:y.line,column:y.column}).then(()=>{L&&m.status==="selected"&&P===h&&k===S&&T===p.id&&b.includes(p)&&n.renderEditorStatus("success")}).catch(()=>{L&&m.status==="selected"&&P===h&&k===S&&T===p.id&&b.includes(p)&&n.renderEditorStatus("error")})}function st(a){if(m.status!=="selected"||!(a.target instanceof HTMLTextAreaElement))return;let p=a.target.dataset.targetInstructionId,y=b.find(P=>P.id===p);y!==void 0&&(y.instruction=a.target.value,n.updateTargetInstruction(y.id,y.instruction),n.setPreviewEnabled(q()),ae())}function Be(){it()}function Xe(a){e.ai.enabled&&m.status==="selected"&&a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),O.run())}function Ye(){if(m.status!=="selected")return;let a=ee();if(a===void 0){n.announce(n.messages().announcements.completeInstructions);return}Z=c.compose(a),_({type:"PREVIEW"}),n.showPreview(Z),n.focusPrompt()}function qe(){if(m.status!=="previewing"||Z.length===0)return;if(r===void 0){_({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.clipboardUnavailable);return}let a=h;r.writeText(Z).then(()=>{L&&a===h&&m.status==="previewing"&&(_({type:"COPY_SUCCESS"}),n.focusTargetInstruction(T),n.announce(n.messages().announcements.promptCopied))}).catch(()=>{L&&a===h&&m.status==="previewing"&&(_({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.copyFailed))})}function we(){m.status==="previewing"&&(_({type:"BACK"}),n.focusTargetInstruction(T))}function Ze(){if(!(!L||b.length===0)&&(B(),m.status==="previewing")){let a=ee();a!==void 0&&(Z=c.compose(a),n.showPreview(Z))}}function Qe(a){let p=a.target;if(!(p instanceof Element))return;let y=p.closest("button[data-remove-target-id]");if(y?.dataset.removeTargetId!==void 0){ut(y.dataset.removeTargetId);return}let P=p.closest("button[data-open-target-id]");if(P?.dataset.openTargetId!==void 0){it(P.dataset.openTargetId);return}let ne=p.closest("button[data-activate-target-id]")?.dataset.activateTargetId;m.status!=="selected"||ne===void 0||!b.some(f=>f.id===ne)||(T=ne,B(),be(),n.focusTargetInstruction(ne))}function Se(){J()}function et(){be()}function te(){L||(L=!0,He?.mount(),n.renderStatus(m.status),o.document.addEventListener("pointermove",Ve,!0),o.document.addEventListener("click",$e,!0),o.document.addEventListener("keydown",le,!0),o.window.addEventListener("scroll",me,!0),o.window.addEventListener("resize",me),n.triggerButton.addEventListener("click",Ke),n.addTargetButton.addEventListener("click",se),n.reselectButton.addEventListener("click",Se),n.targetList.addEventListener("click",Qe),n.targetList.addEventListener("input",st),n.targetList.addEventListener("keydown",Xe),n.openEditorButton.addEventListener("click",Be),n.dataFlowRefreshButton.addEventListener("click",et),n.previewButton.addEventListener("click",Ye),n.copyButton.addEventListener("click",qe),n.backButton.addEventListener("click",we),n.closeButton.addEventListener("click",De),n.agentProviderSelect.addEventListener("change",O.providerOrModelChanged),n.agentModelSelect.addEventListener("change",O.providerOrModelChanged),n.agentModeSelect.addEventListener("change",O.providerOrModelChanged),n.agentConsentCheckbox.addEventListener("change",O.consentChanged),n.agentTestButton.addEventListener("click",O.testCapability),n.agentRunButton.addEventListener("click",O.run),n.agentCancelButton.addEventListener("click",O.cancel),n.agentApplyButton.addEventListener("click",O.apply),n.agentRevertButton.addEventListener("click",O.revert),n.agentResetButton.addEventListener("click",O.reset),Ne=n.subscribeLocale(Ze),o.resizeObserver!==void 0&&(F=new o.resizeObserver(me)),o.mutationObserver!==void 0&&(Re=new o.mutationObserver(me),Re.observe(o.document.documentElement,{childList:!0,subtree:!0})),re&&b.length>0&&(_({type:"RESTORE"}),O.beginSelection(),H=!0,B(!0)),e.debug&&console.info(`[spotpatch:runtime] Mounted. Shortcut: ${e.shortcut}.`))}function yt(){if(!L){Ne?.(),Ne=void 0,n.dispose(),i.cancelPending(),i.dispose(),O.disposeSelection(),He?.dispose(),z.dispose();return}L=!1,Ne?.(),Ne=void 0,o.document.removeEventListener("pointermove",Ve,!0),o.document.removeEventListener("click",$e,!0),o.document.removeEventListener("keydown",le,!0),o.window.removeEventListener("scroll",me,!0),o.window.removeEventListener("resize",me),n.triggerButton.removeEventListener("click",Ke),n.addTargetButton.removeEventListener("click",se),n.reselectButton.removeEventListener("click",Se),n.targetList.removeEventListener("click",Qe),n.targetList.removeEventListener("input",st),n.targetList.removeEventListener("keydown",Xe),n.openEditorButton.removeEventListener("click",Be),n.dataFlowRefreshButton.removeEventListener("click",et),n.previewButton.removeEventListener("click",Ye),n.copyButton.removeEventListener("click",qe),n.backButton.removeEventListener("click",we),n.closeButton.removeEventListener("click",De),n.agentProviderSelect.removeEventListener("change",O.providerOrModelChanged),n.agentModelSelect.removeEventListener("change",O.providerOrModelChanged),n.agentModeSelect.removeEventListener("change",O.providerOrModelChanged),n.agentConsentCheckbox.removeEventListener("change",O.consentChanged),n.agentTestButton.removeEventListener("click",O.testCapability),n.agentRunButton.removeEventListener("click",O.run),n.agentCancelButton.removeEventListener("click",O.cancel),n.agentApplyButton.removeEventListener("click",O.apply),n.agentRevertButton.removeEventListener("click",O.revert),n.agentResetButton.removeEventListener("click",O.reset),M!==void 0&&(o.window.cancelAnimationFrame(M),M=void 0),at(),ae(),F?.disconnect(),Re?.disconnect(),F=void 0,Re=void 0,b=[],T=void 0,Z="",N=void 0,Q=void 0,i.cancelPending(),i.dispose(),O.disposeSelection(),He?.dispose(),z.dispose(),n.dispose(),m=gn}return Object.freeze({mount:te,dispose:yt,getState:()=>m})}var No="__spotpatchRuntime__";function yn(e){let t=globalThis;t[No]?.dispose();let o=Lo(e);t[No]=o,o.mount()}yn({...__SPOTPATCH_RUNTIME_CONFIG__,apiBase:X});
|
|
862
|
+
`)}function Re(){let c=b.flatMap(u=>{if(!u.element?.isConnected)return[];let E=an(u.element,o.window);return E===void 0?[]:[{id:u.id,label:Mn(u.element),rect:E,active:u.id===x}]});c.length===0?n.hideSelectionHighlights():n.showSelectionHighlights(c)}function Y(c=!1){if(b.length===0)return;n.renderTargets(b.map(V=>({id:V.id,label:V.resolution.react.componentName??(V.element===void 0?V.elementContext?.tagName??"Element":Mn(V.element)),source:ts(V,n.messages().context.sourceUnavailable),canOpenEditor:V.marker!==void 0,status:ns(V),active:V.id===x,instruction:V.instruction})),e.maxTargets),Re();let u=He(),E=be(),H=u?.marker!==void 0;c?n.showSelection(E,H,xe()):n.updateSelection(E,H,xe())}function _e(){if(!xe())return;let c=b.map(u=>{if(u.elementContext===void 0||u.styles===void 0)throw new Error("SpotPatch attempted to compose an incomplete target.");let E=[...u.apiStatus==="failed"?["Source context could not be loaded."]:[],...u.collectionStatus==="failed"?["Part of the browser context could not be collected."]:[]];return{instruction:u.instruction.trim(),page:u.page,source:u.resolution.source,react:u.resolution.react,element:u.elementContext,styles:u.styles,...u.code===void 0?{}:{code:u.code},warnings:E}});return ro({id:l(),locale:n.locale(),createdAt:A(),page:Fn(o.document,o.window),targets:c})}function Ke(c){n.showHighlight(Mo(c,o.window),Mn(c))}function Je(){v?.isConnected===!0&&v.focus({preventScroll:!0}),v=void 0}function Qe(){for(let c of $.values())o.window.clearTimeout(c);$.clear()}function Xe(){h+=1,s.cancelPending(),j.disposeSelection(),Ce?.cancelPending(),Qe(),L?.disconnect(),b=[],x=void 0,O+=1,_=void 0,U="idle",J=!1,G=!1,S=!1,C="",n.hideSelection(),n.hideSelectionHighlights(),w.clear(),Je()}function ne(){r.status==="inspecting"?k({type:"CANCEL"}):r.status==="selected"?k({type:"CLOSE"}):r.status==="previewing"&&(k({type:"BACK"}),k({type:"CLOSE"})),J=!1,le(),n.hideSelection(),n.hideSelectionHighlights(),Je(),n.hideHighlight()}function xt(){if(r.status!=="inspecting"||!S||b.length===0){ne();return}S=!1,k({type:"SELECT"}),n.hideHighlight(),Y(!0),n.focusTargetInstruction(x),n.announce(n.messages().announcements.addCancelled)}function et(){if(r.status==="inspecting"&&S){xt();return}if(r.status!=="idle"){ne();return}if(b.length>0){J=!0,k({type:"RESTORE"}),G||(j.beginSelection(),G=!0),Y(!0),Ae(),n.focusTargetInstruction(x),le();return}k({type:"ACTIVATE"}),n.hideSelection(),n.announce(n.messages().announcements.selectionEnabled)}function tt(c=n.messages().announcements.chooseAnother){r.status==="selected"&&(k({type:"RESELECT"}),Xe(),n.hideHighlight(),n.announce(c))}function Be(){if(r.status==="selected"){if(b.length>=e.maxTargets){n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}S=!0,k({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideHighlight(),n.announce(n.messages().announcements.chooseAdditional(b.length,e.maxTargets))}}function ze(){h+=1,Qe(),L?.disconnect();for(let c of b)c.element=void 0;n.hideHighlight(),n.hideSelectionHighlights(),Y(),w.clear(),n.announce(n.messages().announcements.appliedTargetsDetached)}let j=Sr({ai:e.ai,api:s,getAnnotation:_e,onApplied:ze,onReselectRequired(){tt(n.messages().announcements.reselectAfterChange)},view:n}),Ce=e.externalAgent.enabled&&n.externalHandoffPanel!==void 0?dn()?.createWorkflow(o.window.fetch.bind(o.window),n.externalHandoffPanel,_e,e.sessionToken,o.window):void 0;async function Te(c,u){let E=c.marker;if(E!==void 0)try{let H=await s.sourceContext({fileId:E.fileId,line:E.line,column:E.column,maxLines:e.budget.maxCodeLines});We(c,u)&&(c.code=H,c.apiStatus="connected",le(),Y(),n.announce(n.messages().announcements.sourceLoaded))}catch(H){We(c,u)&&(c.code=void 0,c.apiStatus="failed",le(),Y(),n.announce(n.messages().announcements.sourceFailed),e.debug&&!(H instanceof DOMException&&H.name==="AbortError")&&console.warn("[spotpatch:runtime] Source context request failed."))}}function nt(c,u){let E=c.element;if(E===void 0)return;let H=o.window.setTimeout(()=>{if($.delete(c.id),!We(c,u))return;let V=!1;try{c.elementContext=Io({element:E,maxCharacters:e.budget.domCharacters})}catch{c.elementContext=void 0,V=!0}try{c.styles=vo({document:o.document,element:E,maxCharacters:e.budget.cssCharacters})}catch{c.styles=es,V=!0}c.collectionStatus=V?"failed":"ready",le(),Y(),n.announce(V?n.messages().announcements.contextWarning:n.messages().announcements.contextCollected),e.debug&&c.styles.warnings.length>0&&console.warn(`[spotpatch:runtime] CSS collection completed with ${String(c.styles.warnings.length)} warning(s).`)},0);$.set(c.id,H)}function st(c,u){return u!==void 0?b.find(E=>E.marker?.fileId===u.fileId&&E.marker.line===u.line&&E.marker.column===u.column):b.find(E=>E.element===c)}function yt(c){let u=N.resolve(c),E=Pn(u.source),H=st(c,E);if(H!==void 0){x=H.id,S=!1,k({type:"SELECT"}),n.hideHighlight(),Y(!0),Ae(),n.focusTargetInstruction(H.id),n.announce(n.messages().announcements.duplicate);return}if(b.length>=e.maxTargets){S=!1,k({type:"SELECT"}),n.hideHighlight(),Y(!0),n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}b.length===0&&(v=o.document.activeElement instanceof HTMLElement?o.document.activeElement:void 0,C="",j.beginSelection(),G=!0),K+=1;let ie={id:`target-${String(K)}`,element:c,resolution:u,marker:E,page:Fn(o.document,o.window),code:void 0,elementContext:void 0,styles:void 0,instruction:"",apiStatus:E===void 0?"not-required":"loading",collectionStatus:"loading",dataFlowReport:void 0,dataFlowStatus:"idle"};b.push(ie),x=ie.id,S=!1;let y=h;k({type:"SELECT"}),n.hideHighlight(),L?.observe(c),Y(!0),Ae(),J=!0,n.focusTargetInstruction(ie.id),nt(ie,y),E!==void 0?Te(ie,y):n.announce(u.source.confidence==="probable"?n.messages().announcements.sourceProbable:n.messages().announcements.sourceMissing)}function fe(){if(M=void 0,r.status!=="inspecting"||I===void 0)return;let c=wn(o.document,o.window,I.x,I.y);if(k({type:"HOVER"}),c===void 0){n.hideHighlight();return}Ke(c)}function je(c){r.status==="inspecting"&&(I={x:c.clientX,y:c.clientY},M??=o.window.requestAnimationFrame(fe))}function ot(c){if(r.status!=="inspecting"||$o(c.target))return;c.preventDefault(),c.stopPropagation(),c.stopImmediatePropagation();let u=wn(o.document,o.window,c.clientX,c.clientY);if(u===void 0){n.announce(n.messages().announcements.noSelectable);return}yt(u)}function ve(c){if(c.key==="Escape"&&r.status!=="idle"){c.preventDefault(),r.status==="inspecting"&&S?xt():r.status==="inspecting"||r.status==="selected"?ne():(k({type:"BACK"}),n.focusTargetInstruction(x));return}ko(c.target)||!Do(c,e.shortcut,o.window.navigator.userAgent)||(c.preventDefault(),et())}function rt(c){if(r.status!=="selected"&&r.status!=="inspecting")return;let u=b.findIndex(V=>V.id===c);if(u<0)return;let[E]=b.splice(u,1);if(E===void 0)return;let H=$.get(E.id);if(H!==void 0&&(o.window.clearTimeout(H),$.delete(E.id)),E.element!==void 0&&L?.unobserve(E.element),x===E.id&&(x=b.at(-1)?.id),b.length===0){S=!0,r.status==="selected"&&k({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideSelectionHighlights(),_=void 0,U="idle",$e(),w.clear(),n.announce(n.messages().announcements.allTargetsRemoved);return}Y(),Ae(),le(),n.announce(n.messages().announcements.targetRemoved)}function Le(){if(r.status==="idle"||b.length===0)return;let c=b.filter(u=>u.element!==void 0&&!u.element.isConnected);if(c.length>0){for(let u of c)u.element!==void 0&&(L?.unobserve(u.element),u.element=void 0);Y(),le(),n.announce(n.messages().announcements.detachedTargetPreserved);return}Re()}function P(c){let u=c===void 0?He():b.find(ie=>ie.id===c);if(r.status!=="selected"||u?.marker===void 0)return;x!==u.id&&(x=u.id,Y());let E=u.marker,H=h,V=++R;k({type:"OPEN_EDITOR"}),n.renderEditorStatus("opening"),s.openEditor({fileId:E.fileId,line:E.line,column:E.column}).then(()=>{F&&r.status==="selected"&&H===h&&V===R&&x===u.id&&b.includes(u)&&n.renderEditorStatus("success")}).catch(()=>{F&&r.status==="selected"&&H===h&&V===R&&x===u.id&&b.includes(u)&&n.renderEditorStatus("error")})}function ct(c){if(r.status!=="selected"||!(c.target instanceof HTMLTextAreaElement))return;let u=c.target.dataset.targetInstructionId,E=b.find(H=>H.id===u);E!==void 0&&(E.instruction=c.target.value,n.updateTargetInstruction(E.id,E.instruction),n.setPreviewEnabled(xe()),le())}function re(){P()}function Z(c){e.ai.enabled&&r.status==="selected"&&c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),j.run())}function Ge(){if(r.status!=="selected")return;let c=_e();if(c===void 0){n.announce(n.messages().announcements.completeInstructions);return}C=d.compose(c),k({type:"PREVIEW"}),n.showPreview(C),n.focusPrompt()}function qe(){if(r.status!=="previewing"||C.length===0)return;if(i===void 0){k({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.clipboardUnavailable);return}let c=h;i.writeText(C).then(()=>{F&&c===h&&r.status==="previewing"&&(k({type:"COPY_SUCCESS"}),n.focusTargetInstruction(x),n.announce(n.messages().announcements.promptCopied))}).catch(()=>{F&&c===h&&r.status==="previewing"&&(k({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.copyFailed))})}function me(){r.status==="previewing"&&(k({type:"BACK"}),n.focusTargetInstruction(x))}function bt(){if(!(!F||b.length===0)&&(Y(),r.status==="previewing")){let c=_e();c!==void 0&&(C=d.compose(c),n.showPreview(C))}}function Pe(c){let u=c.target;if(!(u instanceof Element))return;let E=u.closest("button[data-remove-target-id]");if(E?.dataset.removeTargetId!==void 0){rt(E.dataset.removeTargetId);return}let H=u.closest("button[data-open-target-id]");if(H?.dataset.openTargetId!==void 0){P(H.dataset.openTargetId);return}let ie=u.closest("button[data-activate-target-id]")?.dataset.activateTargetId;r.status!=="selected"||ie===void 0||!b.some(y=>y.id===ie)||(x=ie,Y(),Ae(),n.focusTargetInstruction(ie))}function Ie(){tt()}function Ye(){Ae()}function Q(){F||(F=!0,Ce?.mount(),n.renderStatus(r.status),o.document.addEventListener("pointermove",je,!0),o.document.addEventListener("click",ot,!0),o.document.addEventListener("keydown",ve,!0),o.window.addEventListener("scroll",Le,!0),o.window.addEventListener("resize",Le),n.triggerButton.addEventListener("click",et),n.addTargetButton.addEventListener("click",Be),n.reselectButton.addEventListener("click",Ie),n.targetList.addEventListener("click",Pe),n.targetList.addEventListener("input",ct),n.targetList.addEventListener("keydown",Z),n.openEditorButton.addEventListener("click",re),n.dataFlowRefreshButton.addEventListener("click",Ye),n.previewButton.addEventListener("click",Ge),n.copyButton.addEventListener("click",qe),n.backButton.addEventListener("click",me),n.closeButton.addEventListener("click",ne),n.agentProviderSelect.addEventListener("change",j.providerOrModelChanged),n.agentModelSelect.addEventListener("change",j.providerOrModelChanged),n.agentModeSelect.addEventListener("change",j.providerOrModelChanged),n.agentConsentCheckbox.addEventListener("change",j.consentChanged),n.agentTestButton.addEventListener("click",j.testCapability),n.agentRunButton.addEventListener("click",j.run),n.agentCancelButton.addEventListener("click",j.cancel),n.agentApplyButton.addEventListener("click",j.apply),n.agentRevertButton.addEventListener("click",j.revert),n.agentResetButton.addEventListener("click",j.reset),Ee=n.subscribeLocale(bt),o.resizeObserver!==void 0&&(L=new o.resizeObserver(Le)),o.mutationObserver!==void 0&&(te=new o.mutationObserver(Le),te.observe(o.document.documentElement,{childList:!0,subtree:!0})),J&&b.length>0&&(k({type:"RESTORE"}),j.beginSelection(),G=!0,Y(!0)),e.debug&&console.info(`[spotpatch:runtime] Mounted. Shortcut: ${e.shortcut}.`))}function Ue(){if(!F){Ee?.(),Ee=void 0,n.dispose(),s.cancelPending(),s.dispose(),j.disposeSelection(),Ce?.dispose(),N.dispose();return}F=!1,Ee?.(),Ee=void 0,o.document.removeEventListener("pointermove",je,!0),o.document.removeEventListener("click",ot,!0),o.document.removeEventListener("keydown",ve,!0),o.window.removeEventListener("scroll",Le,!0),o.window.removeEventListener("resize",Le),n.triggerButton.removeEventListener("click",et),n.addTargetButton.removeEventListener("click",Be),n.reselectButton.removeEventListener("click",Ie),n.targetList.removeEventListener("click",Pe),n.targetList.removeEventListener("input",ct),n.targetList.removeEventListener("keydown",Z),n.openEditorButton.removeEventListener("click",re),n.dataFlowRefreshButton.removeEventListener("click",Ye),n.previewButton.removeEventListener("click",Ge),n.copyButton.removeEventListener("click",qe),n.backButton.removeEventListener("click",me),n.closeButton.removeEventListener("click",ne),n.agentProviderSelect.removeEventListener("change",j.providerOrModelChanged),n.agentModelSelect.removeEventListener("change",j.providerOrModelChanged),n.agentModeSelect.removeEventListener("change",j.providerOrModelChanged),n.agentConsentCheckbox.removeEventListener("change",j.consentChanged),n.agentTestButton.removeEventListener("click",j.testCapability),n.agentRunButton.removeEventListener("click",j.run),n.agentCancelButton.removeEventListener("click",j.cancel),n.agentApplyButton.removeEventListener("click",j.apply),n.agentRevertButton.removeEventListener("click",j.revert),n.agentResetButton.removeEventListener("click",j.reset),M!==void 0&&(o.window.cancelAnimationFrame(M),M=void 0),Qe(),le(),L?.disconnect(),te?.disconnect(),L=void 0,te=void 0,b=[],x=void 0,C="",I=void 0,v=void 0,s.cancelPending(),s.dispose(),j.disposeSelection(),Ce?.dispose(),N.dispose(),n.dispose(),r=_n}return Object.freeze({mount:Q,dispose:Ue,getState:()=>r})}var Rr="__spotpatchRuntime__";function Hn(e){let t=globalThis;t[Rr]?.dispose();let o=xr(e);t[Rr]=o,o.mount()}Hn({...__SPOTPATCH_RUNTIME_CONFIG__,apiBase:ce});
|