@spotpatch/vite 1.4.2 → 1.4.3
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-client.js +247 -185
- package/package.json +2 -2
package/dist/runtime-client.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import{createReact18Adapter as ea}from"@spotpatch/react-adapter";var g={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",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",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"};var ro=/data:[^\s"'<>]*;base64,[a-z0-9+/_=-]+/giu,ao=/blob:[^\s"'<>]+/giu,io=/\bbearer\s+[a-z0-9._~+/-]+=*/giu,so=/\b(https?:\/\/)[^/\s:@]+:[^/\s@]+@/giu,co=/\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,lo=new Set(["authorization","cookie","defaultvalue","password","setcookie","value"]),po=500;function uo(e){return e.toLowerCase().replaceAll(/[-_:]/gu,"")}function go(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function bt(e){let t=uo(e);return lo.has(t)||t.includes("apikey")||t.includes("authorization")||t.includes("secret")||t.includes("token")}function H(e){return e.replace(ro,"[redacted inline data]").replace(ao,"[redacted blob URL]").replace(io,"Bearer [redacted]").replace(so,"$1[redacted]@").replace(co,(t,o,n,s)=>{let r=s.at(0),i=r==='"'||r==="'"||r==="`";return`${o}${n}${i?r:""}[redacted]${i?r:""}`})}function fo(e){e.username="",e.password="";for(let[t,o]of e.searchParams)bt(t)?e.searchParams.set(t,"[redacted]"):e.searchParams.set(t,H(o));return/token|secret|authorization|api[-_]?key/iu.test(e.hash)&&(e.hash="#[redacted]"),e.toString()}function Xe(e,t){let o=e.trim();if(/^(?:blob|data|javascript):/iu.test(o))return"[redacted URL]";let n=H(o);try{let s=new URL(n,t),r=fo(s),i=new URL(t);return!/^[a-z][a-z\d+.-]*:/iu.test(n)&&s.origin===i.origin?`${s.pathname}${s.search}${s.hash}`:r}catch{return go(n,po)}}var Ve="/__spotpatch/v1",yt="X-SpotPatch-Token",Ze=Object.freeze({bootstrap:`${Ve}/bootstrap`,sourceContext:`${Ve}/source-context`,openEditor:`${Ve}/open-editor`,agentCapability:`${Ve}/agent/capability`,agentWorkspaceHealth:`${Ve}/agent/workspace-health`,agentJobs:`${Ve}/agent/jobs`});function nt(e,t){return`${Ze.agentJobs}/${encodeURIComponent(e)}/${t}`}var ho=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}),It=Object.freeze(["queued","preparing","running","validating","awaiting-review","applying","applied","completed","cancelling","cancelled","reverting","reverted","failed"]),Nt=Object.freeze(["unknown","probing","agent-ready","prompt-only","unavailable"]),mo=Object.freeze(["ready","consent-required","blocked"]),bo=Object.freeze({maxUntrackedFiles:1e3,maxUntrackedBytes:20*1024*1024}),Mt=Object.freeze(["added","modified","deleted"]),Dt=Object.freeze(["passed","failed","cancelled","timed-out"]);var $t="data-spotpatch-source",yo=/^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)$/;function zt(e){if(e===null)return;let t=yo.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 jt="https://github.com/huanglvjing/spotpatch";function Xt(e,t){return Object.freeze({...e,...e.relativePath===void 0&&t!==void 0?{relativePath:t.relativePath}:{}})}function xo(e){return Object.freeze({...e,componentStack:Object.freeze([...e.componentStack]),...e.source===void 0?{}:{source:Xt(e.source)}})}function Eo(e){return Object.freeze({...e,rect:Object.freeze({...e.rect})})}function Ao(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 Co(e){return Object.freeze({instruction:e.instruction.trim(),...e.page===void 0?{}:{page:Object.freeze({...e.page})},source:Xt(e.source,e.code),react:xo(e.react),element:Eo(e.element),styles:Ao(e.styles),...e.code===void 0?{}:{code:Object.freeze({...e.code})},warnings:Object.freeze([...e.warnings])})}function Zt(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(Co)),createdAt:e.createdAt})}var Ro=new Set(Object.values(g)),vo=new Set(Nt),To=new Set(Dt),wo=new Set(Mt),en=new Set(It),Oo=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,_o=/^[A-Za-z0-9_-]+$/,Po=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;function Be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fe(e,t){return Object.keys(e).every(o=>t.includes(o))}function ne(e,t,o=0){return typeof e=="string"&&e.length>=o&&e.length<=t}function pt(e){return ne(e,64,1)&&typeof e=="string"&&Oo.test(e)}function Bt(e){return ne(e,128,22)&&typeof e=="string"&&_o.test(e)}function ut(e){return typeof e=="string"&&Po.test(e)&&Number.isFinite(Date.parse(e))}function Qe(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function tn(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function Qt(e,t){return e===void 0||ne(e,t)}function at(e){return typeof e=="string"&&Ro.has(e)}function nn(e){return!Be(e)||!fe(e,["providerProfileId","providerLabel","modelProfileId","modelLabel","protocol","state","authenticated","modelAvailable","toolCalling","toolResultContinuation","streaming","checkedAt","errorCode"])?!1:pt(e.providerProfileId)&&ne(e.providerLabel,100)&&pt(e.modelProfileId)&&ne(e.modelLabel,100)&&(e.protocol==="responses"||e.protocol==="chat-completions")&&typeof e.state=="string"&&vo.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||ut(e.checkedAt))&&(e.errorCode===void 0||at(e.errorCode))}function on(e){if(!Be(e)||!fe(e,["state","checkedAt","changes","canIncludeLocalChanges","errorCode"])||e.state!=="ready"&&e.state!=="consent-required"&&e.state!=="blocked"||!ut(e.checkedAt)||typeof e.canIncludeLocalChanges!="boolean"||e.errorCode!==void 0&&!at(e.errorCode)||!Be(e.changes)||!fe(e.changes,["staged","unstaged","untracked","conflicted","total"]))return!1;let t=e.changes,{staged:o,unstaged:n,untracked:s,conflicted:r,total:i}=t;return!Qe(o)||!Qe(n)||!Qe(s)||!Qe(r)||!Qe(i)||i<o||i<n||i<s||i<r||i>o+n+s?!1:e.state==="ready"?i===0&&!e.canIncludeLocalChanges&&e.errorCode===void 0:e.state==="consent-required"?i>0&&r===0&&e.canIncludeLocalChanges&&e.errorCode===void 0:!e.canIncludeLocalChanges&&e.errorCode!==void 0}function xt(e){return!Be(e)||!fe(e,["jobId","status","providerProfileId","providerLabel","modelProfileId","modelLabel","phaseMessage","createdAt","updatedAt","canCancel","canApply","canRevert","errorCode"])?!1:Bt(e.jobId)&&typeof e.status=="string"&&en.has(e.status)&&pt(e.providerProfileId)&&ne(e.providerLabel,100)&&pt(e.modelProfileId)&&ne(e.modelLabel,100)&&ne(e.phaseMessage,1024)&&ut(e.createdAt)&&ut(e.updatedAt)&&typeof e.canCancel=="boolean"&&typeof e.canApply=="boolean"&&typeof e.canRevert=="boolean"&&(e.errorCode===void 0||at(e.errorCode))}function Lo(e){return Be(e)&&fe(e,["relativePath","kind","additions","deletions"])&&ne(e.relativePath,1024)&&typeof e.kind=="string"&&wo.has(e.kind)&&Qe(e.additions)&&Qe(e.deletions)}function rn(e){return Be(e)&&fe(e,["checkId","label","status","durationMs","output"])&&pt(e.checkId)&&ne(e.label,100)&&typeof e.status=="string"&&To.has(e.status)&&Qe(e.durationMs)&&ne(e.output,8e4)}function ko(e){return Be(e)&&fe(e,["jobId","summary","diff","files","checks"])&&Bt(e.jobId)&&ne(e.summary,8e4)&&ne(e.diff,1e6)&&Array.isArray(e.files)&&e.files.length<=100&&e.files.every(Lo)&&Array.isArray(e.checks)&&e.checks.length<=100&&e.checks.every(rn)}function an(e){return Be(e)&&fe(e,["snapshot","result"])&&xt(e.snapshot)&&(e.result===void 0||ko(e.result)&&e.result.jobId===e.snapshot.jobId)}function Io(e){return Be(e)&&fe(e,["schemaVersion","sequence","jobId","status","timestamp","type","data"])&&e.schemaVersion===2&&tn(e.sequence)&&Bt(e.jobId)&&typeof e.status=="string"&&en.has(e.status)&&ut(e.timestamp)&&typeof e.type=="string"&&Be(e.data)}function sn(e){if(!Io(e))return!1;let t=e.data;switch(e.type){case"snapshot":return fe(t,["snapshot"])&&xt(t.snapshot)&&t.snapshot.jobId===e.jobId&&t.snapshot.status===e.status;case"phase":return fe(t,["message"])&&ne(t.message,1024);case"tool":return fe(t,["turn","toolCallId","toolName","state","relativePath","checkLabel"])&&tn(t.turn)&&ne(t.toolCallId,256)&&ne(t.toolName,100)&&(t.state==="started"||t.state==="succeeded"||t.state==="failed")&&Qt(t.relativePath,1024)&&Qt(t.checkLabel,100);case"check":return fe(t,["result"])&&rn(t.result);case"result-ready":return fe(t,["hasResult"])&&t.hasResult===!0;case"error":return fe(t,["code","message"])&&at(t.code)&&ne(t.message,1024);default:return!1}}var No=2e6,cn=1e5,Mo=4e6,M=class extends Error{code;constructor(t){super("SpotPatch local API request failed."),this.name="RuntimeApiError",this.code=t}};function it(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Do(e){if(!(!it(e)||e.ok!==!1||!it(e.error)))return at(e.error.code)?e.error.code:void 0}function $o(e){if(!it(e)||e.ok!==!0||!("data"in e))throw new M;return e.data}function zo(e){return it(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 ln(e){if(!(!it(e)&&!Array.isArray(e))&&!Object.isFrozen(e)){for(let t of Object.values(e))ln(t);Object.freeze(e)}}function gt(e){return ln(e),e}async function jo(e,t){let o=Number(e.headers.get("content-length"));if(Number.isFinite(o)&&o>t)throw new M;if(e.body===null)throw new M;let n=e.body.getReader(),s=new TextDecoder("utf-8",{fatal:!0}),r=0,i="";try{for(;;){let l=await n.read();if(l.done)return i+=s.decode(),i;if(r+=l.value.byteLength,r>t)throw await n.cancel(),new M;i+=s.decode(l.value,{stream:!0})}}catch(l){throw l instanceof M?l:new M}finally{n.releaseLock()}}function pn(e){try{return JSON.parse(e)}catch{throw new M}}async function dn(e){let t=pn(await jo(e,No));if(!e.ok)throw new M(Do(t));return $o(t)}function Bo(e,t){if(!nn(e)||e.providerProfileId!==t.providerProfileId||e.modelProfileId!==t.modelProfileId)throw new M;return gt(e)}function Et(e,t){if(!xt(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 M;return gt(e)}function Ho(e,t){if(!an(e)||e.snapshot.jobId!==t)throw new M;return gt(e)}function Uo(e){if(!sn(e))throw new M;return gt(e)}function Go(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 un(e){return e instanceof M?e.code:void 0}function gn(e){let t=new Set;function o(){for(let i of t)i.abort();t.clear()}async function n(i,l,E){let A=new AbortController;t.add(A);try{let R=await e.fetch(i,{method:l,headers:{...E===void 0?{}:{"Content-Type":"application/json"},[yt]:e.sessionToken},...E===void 0?{}:{body:JSON.stringify(E)},signal:A.signal});return await dn(R)}finally{t.delete(A)}}async function s(i,l){let E=new AbortController;t.add(E);try{let A=await e.fetch(nt(i,"events"),{method:"POST",headers:{"Content-Type":"application/json",[yt]:e.sessionToken},body:JSON.stringify({}),signal:E.signal});if(!A.ok){await dn(A);return}if(A.body===null)throw new M;let R=A.body.getReader(),k=new TextDecoder("utf-8",{fatal:!0}),u="",P=0,Z=0,I=b=>{if(b.trim().length===0)return;if(new TextEncoder().encode(b).byteLength>cn)throw new M;let x=Uo(pn(b));if(x.jobId!==i||x.sequence<=Z)throw new M;Z=x.sequence,l(x)};try{for(;;){let b=await R.read();if(b.done){u+=k.decode(),I(u);return}if(P+=b.value.byteLength,P>Mo)throw await R.cancel(),new M;u+=k.decode(b.value,{stream:!0});let x=u.split(`
|
|
2
|
-
`);if(u=x.pop()??"",new TextEncoder().encode(u).byteLength>
|
|
3
|
-
`).length}function
|
|
4
|
-
`),e.maxCharacters),...s.length===0?{}:{textPreview:s.length<=et.maxTextCharacters?s:`${s.slice(0,et.maxTextCharacters)}…`},...
|
|
1
|
+
import{createReact18Adapter as ca}from"@spotpatch/react-adapter";var f={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",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",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"};var fo=/data:[^\s"'<>]*;base64,[a-z0-9+/_=-]+/giu,ho=/blob:[^\s"'<>]+/giu,mo=/\bbearer\s+[a-z0-9._~+/-]+=*/giu,bo=/\b(https?:\/\/)[^/\s:@]+:[^/\s@]+@/giu,yo=/\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,So=new Set(["authorization","cookie","defaultvalue","password","setcookie","value"]),xo=500;function Eo(e){return e.toLowerCase().replaceAll(/[-_:]/gu,"")}function Ao(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function St(e){let t=Eo(e);return So.has(t)||t.includes("apikey")||t.includes("authorization")||t.includes("secret")||t.includes("token")}function G(e){return e.replace(fo,"[redacted inline data]").replace(ho,"[redacted blob URL]").replace(mo,"Bearer [redacted]").replace(bo,"$1[redacted]@").replace(yo,(t,o,n,s)=>{let r=s.at(0),a=r==='"'||r==="'"||r==="`";return`${o}${n}${a?r:""}[redacted]${a?r:""}`})}function Co(e){e.username="",e.password="";for(let[t,o]of e.searchParams)St(t)?e.searchParams.set(t,"[redacted]"):e.searchParams.set(t,G(o));return/token|secret|authorization|api[-_]?key/iu.test(e.hash)&&(e.hash="#[redacted]"),e.toString()}function Xe(e,t){let o=e.trim();if(/^(?:blob|data|javascript):/iu.test(o))return"[redacted URL]";let n=G(o);try{let s=new URL(n,t),r=Co(s),a=new URL(t);return!/^[a-z][a-z\d+.-]*:/iu.test(n)&&s.origin===a.origin?`${s.pathname}${s.search}${s.hash}`:r}catch{return Ao(n,xo)}}var Je="/__spotpatch/v1",xt="X-SpotPatch-Token",Ze=Object.freeze({bootstrap:`${Je}/bootstrap`,sourceContext:`${Je}/source-context`,openEditor:`${Je}/open-editor`,agentCapability:`${Je}/agent/capability`,agentWorkspaceHealth:`${Je}/agent/workspace-health`,agentJobs:`${Je}/agent/jobs`});function at(e,t){return`${Ze.agentJobs}/${encodeURIComponent(e)}/${t}`}var Ro=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}),Mt=Object.freeze(["queued","preparing","running","validating","awaiting-review","applying","applied","completed","cancelling","cancelled","reverting","reverted","failed"]),Dt=Object.freeze(["unknown","probing","agent-ready","prompt-only","unavailable"]),vo=Object.freeze(["ready","consent-required","blocked"]),To=Object.freeze({maxUntrackedFiles:1e3,maxUntrackedBytes:20*1024*1024}),$t=Object.freeze(["added","modified","deleted"]),zt=Object.freeze(["passed","failed","cancelled","timed-out"]);var jt="data-spotpatch-source",wo=/^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)$/;function Ht(e){if(e===null)return;let t=wo.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 Bt="https://github.com/huanglvjing/spotpatch";function tn(e,t){return Object.freeze({...e,...e.relativePath===void 0&&t!==void 0?{relativePath:t.relativePath}:{}})}function _o(e){return Object.freeze({...e,componentStack:Object.freeze([...e.componentStack]),...e.source===void 0?{}:{source:tn(e.source)}})}function Po(e){return Object.freeze({...e,rect:Object.freeze({...e.rect})})}function Lo(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 Io(e){return Object.freeze({instruction:e.instruction.trim(),...e.page===void 0?{}:{page:Object.freeze({...e.page})},source:tn(e.source,e.code),react:_o(e.react),element:Po(e.element),styles:Lo(e.styles),...e.code===void 0?{}:{code:Object.freeze({...e.code})},warnings:Object.freeze([...e.warnings])})}function nn(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(Io)),createdAt:e.createdAt})}var ko=new Set(Object.values(f)),No=new Set(Dt),Mo=new Set(zt),Do=new Set($t),rn=new Set(Mt),$o=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,zo=/^[A-Za-z0-9_-]+$/,jo=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;function Ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fe(e,t){return Object.keys(e).every(o=>t.includes(o))}function re(e,t,o=0){return typeof e=="string"&&e.length>=o&&e.length<=t}function gt(e){return re(e,64,1)&&typeof e=="string"&&$o.test(e)}function Ut(e){return re(e,128,22)&&typeof e=="string"&&zo.test(e)}function ft(e){return typeof e=="string"&&jo.test(e)&&Number.isFinite(Date.parse(e))}function Qe(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function an(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function on(e,t){return e===void 0||re(e,t)}function st(e){return typeof e=="string"&&ko.has(e)}function sn(e){return!Ue(e)||!fe(e,["providerProfileId","providerLabel","modelProfileId","modelLabel","protocol","state","authenticated","modelAvailable","toolCalling","toolResultContinuation","streaming","checkedAt","errorCode"])?!1:gt(e.providerProfileId)&&re(e.providerLabel,100)&>(e.modelProfileId)&&re(e.modelLabel,100)&&(e.protocol==="responses"||e.protocol==="chat-completions")&&typeof e.state=="string"&&No.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||ft(e.checkedAt))&&(e.errorCode===void 0||st(e.errorCode))}function cn(e){if(!Ue(e)||!fe(e,["state","checkedAt","changes","canIncludeLocalChanges","errorCode"])||e.state!=="ready"&&e.state!=="consent-required"&&e.state!=="blocked"||!ft(e.checkedAt)||typeof e.canIncludeLocalChanges!="boolean"||e.errorCode!==void 0&&!st(e.errorCode)||!Ue(e.changes)||!fe(e.changes,["staged","unstaged","untracked","conflicted","total"]))return!1;let t=e.changes,{staged:o,unstaged:n,untracked:s,conflicted:r,total:a}=t;return!Qe(o)||!Qe(n)||!Qe(s)||!Qe(r)||!Qe(a)||a<o||a<n||a<s||a<r||a>o+n+s?!1:e.state==="ready"?a===0&&!e.canIncludeLocalChanges&&e.errorCode===void 0:e.state==="consent-required"?a>0&&r===0&&e.canIncludeLocalChanges&&e.errorCode===void 0:!e.canIncludeLocalChanges&&e.errorCode!==void 0}function At(e){return!Ue(e)||!fe(e,["jobId","status","providerProfileId","providerLabel","modelProfileId","modelLabel","phaseMessage","createdAt","updatedAt","canCancel","canApply","canRevert","errorCode"])?!1:Ut(e.jobId)&&typeof e.status=="string"&&rn.has(e.status)&>(e.providerProfileId)&&re(e.providerLabel,100)&>(e.modelProfileId)&&re(e.modelLabel,100)&&re(e.phaseMessage,1024)&&ft(e.createdAt)&&ft(e.updatedAt)&&typeof e.canCancel=="boolean"&&typeof e.canApply=="boolean"&&typeof e.canRevert=="boolean"&&(e.errorCode===void 0||st(e.errorCode))}function Ho(e){return Ue(e)&&fe(e,["relativePath","kind","additions","deletions"])&&re(e.relativePath,1024)&&typeof e.kind=="string"&&Do.has(e.kind)&&Qe(e.additions)&&Qe(e.deletions)}function dn(e){return Ue(e)&&fe(e,["checkId","label","status","durationMs","output"])&>(e.checkId)&&re(e.label,100)&&typeof e.status=="string"&&Mo.has(e.status)&&Qe(e.durationMs)&&re(e.output,8e4)}function Bo(e){return Ue(e)&&fe(e,["jobId","summary","diff","files","checks"])&&Ut(e.jobId)&&re(e.summary,8e4)&&re(e.diff,1e6)&&Array.isArray(e.files)&&e.files.length<=100&&e.files.every(Ho)&&Array.isArray(e.checks)&&e.checks.length<=100&&e.checks.every(dn)}function ln(e){return Ue(e)&&fe(e,["snapshot","result"])&&At(e.snapshot)&&(e.result===void 0||Bo(e.result)&&e.result.jobId===e.snapshot.jobId)}function Uo(e){return Ue(e)&&fe(e,["schemaVersion","sequence","jobId","status","timestamp","type","data"])&&e.schemaVersion===2&&an(e.sequence)&&Ut(e.jobId)&&typeof e.status=="string"&&rn.has(e.status)&&ft(e.timestamp)&&typeof e.type=="string"&&Ue(e.data)}function pn(e){if(!Uo(e))return!1;let t=e.data;switch(e.type){case"snapshot":return fe(t,["snapshot"])&&At(t.snapshot)&&t.snapshot.jobId===e.jobId&&t.snapshot.status===e.status;case"phase":return fe(t,["message"])&&re(t.message,1024);case"tool":return fe(t,["turn","toolCallId","toolName","state","relativePath","checkLabel"])&&an(t.turn)&&re(t.toolCallId,256)&&re(t.toolName,100)&&(t.state==="started"||t.state==="succeeded"||t.state==="failed")&&on(t.relativePath,1024)&&on(t.checkLabel,100);case"check":return fe(t,["result"])&&dn(t.result);case"result-ready":return fe(t,["hasResult"])&&t.hasResult===!0;case"error":return fe(t,["code","message"])&&st(t.code)&&re(t.message,1024);default:return!1}}var Go=2e6,un=1e5,Vo=4e6,M=class extends Error{code;constructor(t){super("SpotPatch local API request failed."),this.name="RuntimeApiError",this.code=t}};function ct(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wo(e){if(!(!ct(e)||e.ok!==!1||!ct(e.error)))return st(e.error.code)?e.error.code:void 0}function Jo(e){if(!ct(e)||e.ok!==!0||!("data"in e))throw new M;return e.data}function qo(e){return ct(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 fn(e){if(!(!ct(e)&&!Array.isArray(e))&&!Object.isFrozen(e)){for(let t of Object.values(e))fn(t);Object.freeze(e)}}function ht(e){return fn(e),e}async function Fo(e,t){let o=Number(e.headers.get("content-length"));if(Number.isFinite(o)&&o>t)throw new M;if(e.body===null)throw new M;let n=e.body.getReader(),s=new TextDecoder("utf-8",{fatal:!0}),r=0,a="";try{for(;;){let l=await n.read();if(l.done)return a+=s.decode(),a;if(r+=l.value.byteLength,r>t)throw await n.cancel(),new M;a+=s.decode(l.value,{stream:!0})}}catch(l){throw l instanceof M?l:new M}finally{n.releaseLock()}}function hn(e){try{return JSON.parse(e)}catch{throw new M}}async function gn(e){let t=hn(await Fo(e,Go));if(!e.ok)throw new M(Wo(t));return Jo(t)}function Ko(e,t){if(!sn(e)||e.providerProfileId!==t.providerProfileId||e.modelProfileId!==t.modelProfileId)throw new M;return ht(e)}function Ct(e,t){if(!At(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 M;return ht(e)}function Yo(e,t){if(!ln(e)||e.snapshot.jobId!==t)throw new M;return ht(e)}function Xo(e){if(!pn(e))throw new M;return ht(e)}function Zo(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 M?e.code:void 0}function bn(e){let t=new Set;function o(){for(let a of t)a.abort();t.clear()}async function n(a,l,E){let A=new AbortController;t.add(A);try{let R=await e.fetch(a,{method:l,headers:{...E===void 0?{}:{"Content-Type":"application/json"},[xt]:e.sessionToken},...E===void 0?{}:{body:JSON.stringify(E)},signal:A.signal});return await gn(R)}finally{t.delete(A)}}async function s(a,l){let E=new AbortController;t.add(E);try{let A=await e.fetch(at(a,"events"),{method:"POST",headers:{"Content-Type":"application/json",[xt]:e.sessionToken},body:JSON.stringify({}),signal:E.signal});if(!A.ok){await gn(A);return}if(A.body===null)throw new M;let R=A.body.getReader(),j=new TextDecoder("utf-8",{fatal:!0}),u="",L=0,V=0,P=b=>{if(b.trim().length===0)return;if(new TextEncoder().encode(b).byteLength>un)throw new M;let x=Xo(hn(b));if(x.jobId!==a||x.sequence<=V)throw new M;V=x.sequence,l(x)};try{for(;;){let b=await R.read();if(b.done){u+=j.decode(),P(u);return}if(L+=b.value.byteLength,L>Vo)throw await R.cancel(),new M;u+=j.decode(b.value,{stream:!0});let x=u.split(`
|
|
2
|
+
`);if(u=x.pop()??"",new TextEncoder().encode(u).byteLength>un)throw await R.cancel(),new M;for(let Q of x)P(Q)}}catch(b){throw b instanceof M||b instanceof DOMException&&b.name==="AbortError"?b:new M}finally{R.releaseLock()}}finally{t.delete(E)}}let r=Object.freeze({});return Object.freeze({cancelPending:o,async sourceContext(a){let l=await n(Ze.sourceContext,"POST",a);if(!qo(l))throw new M;return Object.freeze({...l})},async openEditor(a){let l=await n(Ze.openEditor,"POST",a);if(!ct(l)||l.editor!=="auto"&&l.editor!=="vscode"&&l.editor!=="cursor")throw new M;return Object.freeze({editor:l.editor})},async agentCapability(a){return Ko(await n(Ze.agentCapability,"POST",a),a)},async agentWorkspaceHealth(){let a=await n(Ze.agentWorkspaceHealth,"POST",r);if(!cn(a))throw new M;return ht(a)},async createAgentJob(a){let l=Zo(a);return Ct(await n(Ze.agentJobs,"POST",l),a)},agentEvents:s,async agentResult(a){return Yo(await n(at(a,"result"),"POST",r),a)},async cancelAgentJob(a){return Ct(await n(at(a,"cancel"),"POST",r),{jobId:a})},async applyAgentJob(a){return Ct(await n(at(a,"apply"),"POST",r),{jobId:a})},async revertAgentJob(a){return Ct(await n(at(a,"revert"),"POST",r),{jobId:a})},dispose(){o()}})}var Qo=500,yn=256;function er(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function tr(e){return St(e)}function Sn(e,t,o){if(!tr(e))return e==="href"||e==="src"?Xe(t,o):e==="d"&&t.length>yn?`${t.slice(0,yn)}…`:er(G(t),Qo)}function Ae(e){return G(e)}var xn=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 mt=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 nr(e){return"selectorText"in e&&"style"in e}function or(e){return"cssRules"in e}function rr(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 ar(e,t,o,n,s){return e.join(" ").length+(t?.length??0)+o.reduce((r,a)=>r+a.selector.length+a.declarations.length+(a.source?.length??0)+(a.media?.length??0),0)+Object.entries(n).reduce((r,[a,l])=>r+a.length+l.length,0)+s.join(`
|
|
3
|
+
`).length}function ir(e,t){return e.href===null?void 0:Xe(e.href,t)}function En(e,t,o,n,s,r){for(let a of t){if(nr(a)){let l=!1;try{l=e.matches(a.selectorText)}catch{r.add(mt.selector);continue}l&&s.push(Object.freeze({selector:Ae(a.selectorText),declarations:Ae(a.style.cssText),...o===void 0?{}:{source:o},...n.length===0?{}:{media:n.join(" and ")}}));continue}if(or(a)){let l=rr(a);En(e,a.cssRules,o,l===void 0?n:[...n,l],s,r)}}}function sr(e,t){if(t===void 0)return{};let o=t(e),n={};for(let s of xn){let r=Ae(o.getPropertyValue(s).trim());r.length>0&&(n[s]=r)}return n}function An(e){let t=new Set([mt.state,mt.cssInJs,mt.cascade]),o=[],n=e.readCssRules??(R=>R.cssRules);for(let R of e.document.styleSheets){let j;try{j=n(R)}catch{t.add(mt.inaccessibleStylesheet);continue}En(e.element,j,ir(R,e.document.baseURI),[],o,t)}let s=Array.from(e.element.classList),r=e.element.getAttribute("style"),a=r===null?void 0:Ae(r),l=e.getComputedStyle??e.document.defaultView?.getComputedStyle.bind(e.document.defaultView),E=Object.entries(sr(e.element,l)),A=Array.from(t);for(;ar(s,a,o,Object.fromEntries(E),A)>e.maxCharacters;){if(E.length>0){E.pop();continue}if(o.length>1){o.shift();continue}break}return Object.freeze({classNames:Object.freeze(s),...a===void 0?{}:{inlineStyle:a},matchedRules:Object.freeze(o),computed:Object.freeze(Object.fromEntries(E)),warnings:Object.freeze(A)})}var et=Object.freeze({maxDepth:3,maxNodes:30,maxParentDepth:2,maxTextCharacters:200}),cr=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"]),dr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Rn(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}function lr(e){return cr.has(e)||e.startsWith("aria-")||e==="data-testid"}function vn(e){let t=e.tagName.toLowerCase(),o=[],n=e.ownerDocument.baseURI;for(let s of e.attributes){let r=s.name.toLowerCase();if(!lr(r))continue;let a=Sn(r,s.value,n);a!==void 0&&o.push(`${r}="${Rn(a)}"`)}return`<${t}${o.length===0?"":` ${o.join(" ")}`}>`}function Tn(e){return G(e).replaceAll(/\s+/gu," ").trim()}function wn(e,t,o,n){if(o.nodeCount>=et.maxNodes){o.truncated=!0;return}o.nodeCount+=1;let s=" ".repeat(t),r=e.tagName.toLowerCase();if(n.push(`${s}${vn(e)}`),!dr.has(r)){for(let a of e.childNodes){if(o.nodeCount>=et.maxNodes){o.truncated=!0;break}if(a.nodeType===3){let l=Tn(a.textContent??"");if(l.length>0){o.nodeCount+=1;let E=l.length<=et.maxTextCharacters?l:`${l.slice(0,et.maxTextCharacters)}…`;n.push(`${" ".repeat(t+1)}${Rn(E)}`)}continue}if(a.nodeType===1){if(t>=et.maxDepth){o.truncated=!0;continue}wn(a,t+1,o,n)}}o.truncated&&t===0&&n.push(" …"),n.push(`${s}</${r}>`)}}function pr(e){let t=[],o=e.parentElement;for(;o!==null&&t.length<et.maxParentDepth;)t.push(vn(o)),o=o.parentElement;return t}function ur(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Cn(e){return Array.from(e).map(t=>/[a-z\d_-]/iu.test(t)?t:`\\${t.charCodeAt(0).toString(16)} `).join("")}function gr(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function fr(e){let t=e.tagName.toLowerCase();if(e.id.length>0)return`${t}#${Cn(e.id)}`;let o=e.getAttribute("data-testid");if(o!==null&&o.length>0)return`${t}[data-testid="${gr(o)}"]`;let n=Array.from(e.classList).slice(0,2).map(l=>`.${Cn(l)}`).join(""),s=e.parentElement===null?[]:Array.from(e.parentElement.children).filter(l=>l.tagName===e.tagName),r=s.indexOf(e),a=s.length>1&&r>=0?`:nth-of-type(${String(r+1)})`:"";return`${t}${n}${a}`}function hr(e){let t=[],o=e;for(;o!==null&&t.length<5;){let n=fr(o);if(t.unshift(n),o.id.length>0||o.hasAttribute("data-testid"))break;o=o.parentElement}return t.join(" > ")}function On(e){let t=["<!-- Selected element -->"],o={nodeCount:0,truncated:!1};wn(e.element,0,o,t);let n=pr(e.element);n.length>0&&t.push("<!-- Parent context: nearest first -->",...n);let s=Tn(e.element.textContent),r=e.element.getBoundingClientRect(),a=e.element.getAttribute("role");return Object.freeze({tagName:e.element.tagName.toLowerCase(),selector:hr(e.element),sanitizedHtml:ur(t.join(`
|
|
4
|
+
`),e.maxCharacters),...s.length===0?{}:{textPreview:s.length<=et.maxTextCharacters?s:`${s.slice(0,et.maxTextCharacters)}…`},...a===null?{}:{role:a},rect:Object.freeze({x:r.x,y:r.y,width:r.width,height:r.height})})}function _n(e){return/Mac|iPhone|iPad|iPod/i.test(e)}function mr(e){return e.toLowerCase()}function Pn(e){return e instanceof Element?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e.closest("[contenteditable]:not([contenteditable='false'])")!==null:!1}function Ln(e,t,o){let n=t.split("+").map(R=>R.trim().toLowerCase()).filter(R=>R.length>0),s=n.find(R=>R!=="mod"&&R!=="meta"&&R!=="ctrl"&&R!=="control"&&R!=="alt"&&R!=="option"&&R!=="shift");if(s===void 0||mr(e.key)!==s)return!1;let r=n.includes("mod"),a=n.includes("meta")||r&&_n(o),l=n.includes("ctrl")||n.includes("control")||r&&!_n(o),E=n.includes("alt")||n.includes("option"),A=n.includes("shift");return e.metaKey===a&&e.ctrlKey===l&&e.altKey===E&&e.shiftKey===A}function br(e){return Object.freeze({x:e.x,y:e.y,width:e.width,height:e.height})}function yr(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,r=o.right,a=o.bottom;for(let l of t.slice(1))n=Math.min(n,l.left),s=Math.min(s,l.top),r=Math.max(r,l.right),a=Math.max(a,l.bottom);return Object.freeze({x:n,y:s,width:r-n,height:a-s})}function In(e,t){if(t.startsWith("inline")){let o=yr(Array.from(e.getClientRects()));if(o!==void 0)return o}return br(e.getBoundingClientRect())}function kn(e,t){return In(e,t.getComputedStyle(e).display)}function Rt(e,t){let o=t.getComputedStyle(e);if(o.display==="none"||o.visibility==="hidden")return;let n=In(e,o.display);return n.width>0&&n.height>0?n:void 0}var it="data-spotpatch-ui",bt=Object.freeze({highlight:2147483646,controls:2147483647});function Nn(e){if(e.closest(`[${it}]`)!==null)return!0;let t=e.getRootNode();return t instanceof ShadowRoot&&t.host.hasAttribute(it)}function Sr(e,t){return Rt(e,t)!==void 0}function xr(e){return e.tagName==="HTML"||e.tagName==="BODY"}function Gt(e,t,o,n){let s=e.elementsFromPoint(o,n).filter(r=>!Nn(r)&&Sr(r,t));return s.find(r=>!xr(r))??s[0]}function Mn(e){return e instanceof Element&&Nn(e)}var Vt=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 Er(e){return Math.max(0,...Array.from(e.matchAll(/`+/gu),t=>t[0].length))}function vt(e,t){let o="`".repeat(Math.max(3,Er(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 $n(e,t){let o=e.code?.relativePath??e.source.relativePath,n=e.source.line,s=e.source.column;return o===void 0?t.unavailable:`${G(o)}${n===void 0?"":`:${String(n)}`}${s===void 0?"":`:${String(s)}`}`}function zn(e,t){return e.split(`
|
|
7
|
+
`).find(o=>/^\s*<[a-z][^>]*>/iu.test(o))?.trim()??t}function Ar(e){let t=[e.source===void 0?void 0:`/* source: ${Ae(e.source)} */`,e.media===void 0?void 0:`/* condition: ${Ae(e.media)} */`].filter(n=>n!==void 0),o=`${Ae(e.selector)} {
|
|
8
|
+
${Ae(e.declarations)}
|
|
9
9
|
}`;return[...t,o].join(`
|
|
10
|
-
`)}function
|
|
10
|
+
`)}function Cr(e,t,o){let s=[...[e.styles.classNames.length===0?void 0:`/* classes: ${e.styles.classNames.map(Ae).join(" ")} */`,e.styles.inlineStyle===void 0?void 0:`/* inline: ${Ae(e.styles.inlineStyle)} */`].filter(r=>r!==void 0),...t.map(Ar)];return s.length===0?o.unavailable:vt("css",s.join(`
|
|
11
11
|
|
|
12
|
-
`))}function
|
|
13
|
-
`))}function
|
|
12
|
+
`))}function Rr(e,t){return e.length===0?t.unavailable:vt("css",e.map(([o,n])=>`${Ae(o)}: ${Ae(n)};`).join(`
|
|
13
|
+
`))}function vr(e,t,o,n){let s=[`- ${n.adapter}: ${e.react.supported?n.supported:n.unsupported}`,...e.react.version===void 0?[]:[`- ${n.reactVersion}: ${G(e.react.version)}`],...e.react.componentName===void 0?[]:[`- ${n.component}: ${G(e.react.componentName)}`],...t.reactStack.length===0?[]:[`- ${n.stack}: ${t.reactStack.map(G).join(" > ")}`]],r=e.code===void 0||t.codeLines.length===0?n.unavailable:`- ${n.boundary}: ${e.code.boundary}
|
|
14
14
|
|
|
15
|
-
${
|
|
15
|
+
${vt(e.code.language,G(t.codeLines.join(`
|
|
16
16
|
`)))}`;return[`### ${n.target(o+1)}`,`#### ${n.requestedChange}`,t.instruction,...e.page===void 0?[]:[`#### ${n.pageEnvironment}`,`- ${n.url}: <${Xe(e.page.url,e.page.url)}>
|
|
17
|
-
- ${n.pathname}: ${
|
|
18
|
-
- ${n.title}: ${
|
|
19
|
-
`),`#### ${n.source}`,`- ${n.file}: ${
|
|
17
|
+
- ${n.pathname}: ${G(e.page.pathname)}
|
|
18
|
+
- ${n.title}: ${G(e.page.title)||n.unavailable}`],`#### ${n.reactContext}`,s.join(`
|
|
19
|
+
`),`#### ${n.source}`,`- ${n.file}: ${$n(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}`,vt("html",G(t.dom)),`#### ${n.styles}`,Cr(e,t.matchedRules,n),`#### ${n.computedStyles}`,Rr(t.computedEntries,n),`#### ${n.code}`,r,`#### ${n.warnings}`,t.warnings.length===0?`- ${n.none}`:t.warnings.map(a=>`- ${G(a)}`).join(`
|
|
22
22
|
`)].join(`
|
|
23
23
|
|
|
24
|
-
`)}function
|
|
25
|
-
- ${n.pathname}: ${
|
|
24
|
+
`)}function Dn(e,t){let o=Xe(e.page.url,e.page.url),n=Vt[e.locale];return[`## ${n.pageEnvironment}`,`- ${n.url}: <${o}>
|
|
25
|
+
- ${n.pathname}: ${G(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((s,r)=>{let
|
|
28
|
+
- ${n.devicePixelRatio}: ${String(e.page.devicePixelRatio)}`,`## ${n.selectedTargets(e.targets.length)}`,e.targets.map((s,r)=>{let a=t.targets[r];if(a===void 0)throw new RangeError("Prompt target draft is missing.");return vr(s,a,r,n)}).join(`
|
|
29
29
|
|
|
30
30
|
`),`## ${n.modificationRequirements}`,n.modificationConstraint].join(`
|
|
31
31
|
|
|
32
|
-
`)}function
|
|
32
|
+
`)}function Tr(e,t){if(t.codeLines.length===0||e.code===void 0)return!1;if(t.codeLines.length===1){let a=t.codeLines[0]??"";return a.length<=120?t.codeLines=[]:t.codeLines=[`${a.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 wr(e){return{instruction:G(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 Or(e){return{pageTitle:G(e.page.title),targets:e.targets.map(wr)}}function _r(e,t,o){let n=Vt[e.locale],s=[(r,a)=>a.computedEntries.pop()!==void 0,(r,a)=>a.reactStack.pop()!==void 0,(r,a)=>{let l=zn(a.dom,n.unavailable);return a.dom===l?!1:(a.dom=l,!0)},(r,a)=>a.matchedRules.shift()!==void 0,Tr,(r,a)=>a.warnings.pop()!==void 0];for(let r of s)for(let a=0;a<e.targets.length;a+=1){let l=(o+a)%e.targets.length,E=e.targets[l],A=t.targets[l];if(E!==void 0&&A!==void 0&&r(E,A))return(l+1)%e.targets.length}}function Pr(e,t){let o=Vt[e.locale],n=e.targets.map((s,r)=>{let a=t.targets[r],l=s.react.componentName;return[`### ${o.target(r+1)}`,`- ${o.requestedChange}: ${a?.instruction??G(s.instruction)}`,`- ${o.file}: ${$n(s,o)}`,...l===void 0?[]:[`- ${o.component}: ${G(l)}`],`- ${o.element}: ${G(zn(a?.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 Lr(e,t){let o=Or(e),n=Dn(e,o),s=0;for(;n.length>t;){let a=_r(e,o,s);if(a===void 0)if(o.pageTitle.length>0)o.pageTitle="";else break;else s=a;n=Dn(e,o)}if(n.length<=t)return n;let r=Pr(e,o);if(r.length>t)throw new RangeError("Prompt budget cannot preserve every target instruction and source location.");return r}function jn(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 Lr(t,e.maxCharacters)}})}var de=Object.freeze({idle:Object.freeze({status:"idle"}),inspecting:Object.freeze({status:"inspecting"}),selected:Object.freeze({status:"selected"}),previewing:Object.freeze({status:"previewing"})}),Wt=de.idle;function Ir(e){return e.type==="ACTIVATE"?de.inspecting:e.type==="RESTORE"?de.selected:de.idle}function kr(e){switch(e.type){case"HOVER":return de.inspecting;case"SELECT":return de.selected;case"CANCEL":return de.idle;default:return de.inspecting}}function Nr(e){switch(e.type){case"RESELECT":return de.inspecting;case"CLOSE":return de.idle;case"PREVIEW":return de.previewing;case"OPEN_EDITOR":return de.selected;default:return de.selected}}function Mr(e){switch(e.type){case"COPY_SUCCESS":case"BACK":return de.selected;case"COPY_FAILURE":return de.previewing;default:return de.previewing}}function Hn(e,t){switch(e.status){case"idle":return Ir(t);case"inspecting":return kr(t);case"selected":return Nr(t);case"previewing":return Mr(t)}}var Dr="spotpatch:selection:";function Me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Z(e){return typeof e=="string"}function Fe(e){return e===void 0||Z(e)}function Jt(e){return Array.isArray(e)&&e.length<=256&&e.every(Z)}function Ge(e){return typeof e=="number"&&Number.isFinite(e)}function Bn(e){return e===void 0||Ge(e)}function Un(e){let t=Me(e);return t!==void 0&&Z(t.origin)&&Z(t.confidence)&&Fe(t.fileId)&&Fe(t.relativePath)&&Bn(t.line)&&Bn(t.column)}function $r(e){let t=Me(e);return t!==void 0&&typeof t.supported=="boolean"&&Fe(t.version)&&Fe(t.componentName)&&Jt(t.componentStack)&&(t.source===void 0||Un(t.source))}function zr(e){let t=Me(e);return t!==void 0&&Z(t.url)&&Z(t.pathname)&&Z(t.title)&&Ge(t.viewportWidth)&&Ge(t.viewportHeight)&&Ge(t.devicePixelRatio)}function jr(e){let t=Me(e),o=Me(t?.rect);return t!==void 0&&Z(t.tagName)&&Z(t.selector)&&Z(t.sanitizedHtml)&&Fe(t.textPreview)&&Fe(t.role)&&o!==void 0&&Ge(o.x)&&Ge(o.y)&&Ge(o.width)&&Ge(o.height)}function Hr(e){let t=Me(e),o=Me(t?.computed);return t!==void 0&&Jt(t.classNames)&&Fe(t.inlineStyle)&&Array.isArray(t.matchedRules)&&t.matchedRules.length<=256&&t.matchedRules.every(n=>{let s=Me(n);return s!==void 0&&Z(s.selector)&&Z(s.declarations)&&Fe(s.source)&&Fe(s.media)})&&o!==void 0&&Object.values(o).every(Z)&&Jt(t.warnings)}function Br(e){let t=Me(e);return t!==void 0&&Z(t.relativePath)&&Z(t.language)&&Ge(t.startLine)&&Ge(t.endLine)&&Z(t.excerpt)&&Z(t.boundary)}function Ur(e){let t=Me(e);return t!==void 0&&Z(t.id)&&Z(t.instruction)&&zr(t.page)&&Un(t.source)&&$r(t.react)&&jr(t.element)&&Hr(t.styles)&&(t.code===void 0||Br(t.code))}function Gr(e,t){let o=Me(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(Ur))return;let n=o.targets,s=n.map(({id:r})=>r);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 Gn(e,t,o){let n=`${Dr}${t}`,s;try{s=e.sessionStorage}catch{s=void 0}return Object.freeze({clear(){try{s?.removeItem(n)}catch{}},load(){let r;try{r=s?.getItem(n)??null}catch{return}if(!(r===null||r.length>1e6))try{return Gr(JSON.parse(r),o)}catch{return}},save(r){try{s?.setItem(n,JSON.stringify({version:1,...r}))}catch{}}})}var Vn=Object.freeze({supported:!1,componentStack:Object.freeze([])});function Jn(e){return Ht(e.getAttribute(jt))}function Vr(e){let t=e.parentElement;for(;t!==null;){let o=Jn(t);if(o!==void 0)return o;t=t.parentElement}}function Wn(e,t,o){return Object.freeze({fileId:e.fileId,line:e.line,column:e.column,origin:t,confidence:o})}function Wr(){return Object.freeze({origin:"none",confidence:"unknown"})}function qt(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 qn(e){let t=!0;function o(n){if(!t)return Vn;try{return e.adapter.inspect(n)}catch{return t=!1,e.onAdapterError?.(),Vn}}return Object.freeze({resolve(n){let s=Jn(n),r=o(n);if(s!==void 0)return Object.freeze({react:r,source:Wn(s,"jsx-host","exact")});if(r.source!==void 0)return Object.freeze({react:r,source:r.source});let a=Vr(n);return Object.freeze(a!==void 0?{react:r,source:Wn(a,"dom-ancestor","approximate")}:{react:r,source:Wr()})},dispose(){t=!1,e.adapter.dispose()}})}function d(e,t){let o=e.createElement(t);return o.setAttribute(it,""),o}function K(e,t,o=""){let n=d(e,"button");return n.type="button",n.className=o,n.textContent=t,n}var Kn=`
|
|
38
38
|
.spotpatch-agent {
|
|
39
|
-
margin-top:
|
|
39
|
+
margin-top: 10px;
|
|
40
40
|
overflow: hidden;
|
|
41
41
|
border: 1px solid var(--spotpatch-border-subtle);
|
|
42
42
|
border-radius: var(--spotpatch-radius-card);
|
|
@@ -46,36 +46,36 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
46
46
|
display: flex;
|
|
47
47
|
align-items: center;
|
|
48
48
|
justify-content: space-between;
|
|
49
|
-
gap:
|
|
50
|
-
padding:
|
|
49
|
+
gap: 10px;
|
|
50
|
+
padding: 10px 12px;
|
|
51
51
|
border-bottom: 1px solid rgb(255 255 255 / 7%);
|
|
52
52
|
}
|
|
53
|
-
.spotpatch-agent-title { color: #eef0f5; font-size:
|
|
53
|
+
.spotpatch-agent-title { color: #eef0f5; font-size: 13px; font-weight: 650; }
|
|
54
54
|
.spotpatch-agent-badge {
|
|
55
55
|
border: 1px solid rgb(129 112 247 / 24%);
|
|
56
56
|
border-radius: 999px;
|
|
57
57
|
padding: 3px 7px;
|
|
58
58
|
color: #c5cafa;
|
|
59
59
|
background: rgb(109 93 246 / 9%);
|
|
60
|
-
font-size:
|
|
60
|
+
font-size: 10px;
|
|
61
61
|
font-weight: 650;
|
|
62
62
|
}
|
|
63
|
-
.spotpatch-agent-setup { padding:
|
|
64
|
-
.spotpatch-agent-selectors { display: grid; grid-template-columns: 1fr; gap:
|
|
65
|
-
.spotpatch-agent-selectors label { min-width: 0; color: var(--spotpatch-text-secondary); font-size:
|
|
63
|
+
.spotpatch-agent-setup { padding: 12px; }
|
|
64
|
+
.spotpatch-agent-selectors { display: grid; grid-template-columns: 1fr; gap: 10px; }
|
|
65
|
+
.spotpatch-agent-selectors label { min-width: 0; color: var(--spotpatch-text-secondary); font-size: 11.5px; font-weight: 580; }
|
|
66
66
|
.spotpatch-agent select {
|
|
67
67
|
box-sizing: border-box;
|
|
68
68
|
width: 100%;
|
|
69
69
|
min-width: 0;
|
|
70
|
-
min-height:
|
|
71
|
-
margin-top:
|
|
70
|
+
min-height: 34px;
|
|
71
|
+
margin-top: 4px;
|
|
72
72
|
border: 1px solid var(--spotpatch-border);
|
|
73
|
-
border-radius:
|
|
74
|
-
padding:
|
|
73
|
+
border-radius: 8px;
|
|
74
|
+
padding: 7px 32px 7px 9px;
|
|
75
75
|
color: #e8ebf2;
|
|
76
76
|
color-scheme: dark;
|
|
77
77
|
background: linear-gradient(180deg, rgb(255 255 255 / 4%), rgb(255 255 255 / 2%));
|
|
78
|
-
font-size:
|
|
78
|
+
font-size: 12px;
|
|
79
79
|
font-weight: 560;
|
|
80
80
|
line-height: 1.35;
|
|
81
81
|
outline: none;
|
|
@@ -87,7 +87,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
87
87
|
@supports (appearance: base-select) {
|
|
88
88
|
.spotpatch-agent select,
|
|
89
89
|
::picker(select) { appearance: base-select; }
|
|
90
|
-
.spotpatch-agent select { padding:
|
|
90
|
+
.spotpatch-agent select { padding: 7px 9px; }
|
|
91
91
|
.spotpatch-agent select::picker-icon {
|
|
92
92
|
color: #9da6b5;
|
|
93
93
|
transition: rotate 180ms cubic-bezier(.2, .8, .2, 1);
|
|
@@ -134,24 +134,24 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
134
134
|
.spotpatch-consent {
|
|
135
135
|
display: flex;
|
|
136
136
|
align-items: flex-start;
|
|
137
|
-
gap:
|
|
138
|
-
margin-top:
|
|
137
|
+
gap: 8px;
|
|
138
|
+
margin-top: 10px;
|
|
139
139
|
color: var(--spotpatch-text-secondary);
|
|
140
140
|
cursor: pointer;
|
|
141
|
-
font-size:
|
|
142
|
-
line-height: 1.
|
|
141
|
+
font-size: 11.5px;
|
|
142
|
+
line-height: 1.5;
|
|
143
143
|
}
|
|
144
|
-
.spotpatch-consent input { width:
|
|
144
|
+
.spotpatch-consent input { width: 14px; height: 14px; flex: none; margin: 2px 0 0; accent-color: var(--spotpatch-accent); }
|
|
145
145
|
.spotpatch-workspace-consent {
|
|
146
|
-
margin-top:
|
|
146
|
+
margin-top: 9px;
|
|
147
147
|
border: 1px solid rgb(251 191 36 / 18%);
|
|
148
148
|
border-radius: 10px;
|
|
149
|
-
padding:
|
|
149
|
+
padding: 9px 10px;
|
|
150
150
|
background: rgb(120 53 15 / 9%);
|
|
151
151
|
}
|
|
152
|
-
.spotpatch-workspace-consent strong { display: block; color: #fde68a; font-size:
|
|
153
|
-
.spotpatch-workspace-consent small { display: block; margin-top: 2px; color: #aeb6c4; font-size:
|
|
154
|
-
.spotpatch-agent-health-list { display: grid; gap:
|
|
152
|
+
.spotpatch-workspace-consent strong { display: block; color: #fde68a; font-size: 11.5px; font-weight: 620; }
|
|
153
|
+
.spotpatch-workspace-consent small { display: block; margin-top: 2px; color: #aeb6c4; font-size: 10.5px; line-height: 1.45; }
|
|
154
|
+
.spotpatch-agent-health-list { display: grid; gap: 6px; margin-top: 10px; }
|
|
155
155
|
.spotpatch-agent-workspace,
|
|
156
156
|
.spotpatch-agent-capability {
|
|
157
157
|
display: flex;
|
|
@@ -159,7 +159,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
159
159
|
gap: 8px;
|
|
160
160
|
margin: 0;
|
|
161
161
|
color: #929bab;
|
|
162
|
-
font-size:
|
|
162
|
+
font-size: 11px;
|
|
163
163
|
}
|
|
164
164
|
.spotpatch-agent-capability::before {
|
|
165
165
|
width: 6px;
|
|
@@ -189,7 +189,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
189
189
|
.spotpatch-agent-workspace[data-state="consent-required"]::before { background: #fbbf24; }
|
|
190
190
|
.spotpatch-agent-workspace[data-state="blocked"] { color: #fecaca; }
|
|
191
191
|
.spotpatch-agent-workspace[data-state="blocked"]::before { background: var(--spotpatch-danger); }
|
|
192
|
-
.spotpatch-agent-job { padding:
|
|
192
|
+
.spotpatch-agent-job { padding: 12px; }
|
|
193
193
|
.spotpatch-agent-job-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
|
194
194
|
.spotpatch-agent-model { min-width: 0; overflow: hidden; color: #d6dafe; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
|
|
195
195
|
.spotpatch-agent-status {
|
|
@@ -239,26 +239,28 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
239
239
|
white-space: pre;
|
|
240
240
|
user-select: text;
|
|
241
241
|
}
|
|
242
|
-
`;function Un(e,t,o,n){let s=e.createElement("option");s.value=o,s.textContent=n,t.append(s)}function Vn(e,t,o){let n=o.messages(),s=d(e,"section");s.className="spotpatch-agent",s.hidden=!t.enabled;let r=d(e,"div");r.className="spotpatch-agent-head";let i=d(e,"span");i.className="spotpatch-agent-title";let l=d(e,"span");l.className="spotpatch-agent-badge",r.append(i,l);let E=d(e,"div");E.className="spotpatch-agent-setup";let A=d(e,"div");A.className="spotpatch-agent-selectors";let R=d(e,"label"),k=d(e,"span"),u=d(e,"select");R.append(k,u);let P=d(e,"label"),Z=d(e,"span"),I=d(e,"select");P.append(Z,I),A.append(R,P);let b=d(e,"label");b.className="spotpatch-consent";let x=d(e,"input");x.type="checkbox";let Q=d(e,"span");b.append(x,Q);let q=d(e,"label");q.className="spotpatch-consent spotpatch-workspace-consent",q.hidden=!0;let f=d(e,"input");f.type="checkbox";let y=d(e,"span"),C=d(e,"strong"),v=d(e,"small");y.append(C,v),q.append(f,y);let D=d(e,"div");D.className="spotpatch-agent-health-list";let G=d(e,"p");G.className="spotpatch-agent-workspace",G.dataset.state="idle";let $=d(e,"p");$.className="spotpatch-agent-capability",$.dataset.state="idle",D.append(G,$),E.append(A,b,q,D);let de=d(e,"div");de.className="spotpatch-agent-job",de.hidden=!0;let oe=d(e,"div");oe.className="spotpatch-agent-job-meta";let B=d(e,"span");B.className="spotpatch-agent-model";let L=d(e,"span");L.className="spotpatch-agent-status",oe.append(B,L);let Pe=d(e,"p");Pe.className="spotpatch-agent-phase";let he=d(e,"p");he.className="spotpatch-agent-error",he.hidden=!0;let F=d(e,"ul");F.className="spotpatch-agent-activity";let Ce=d(e,"div");Ce.className="spotpatch-agent-result",Ce.hidden=!0;let Re=d(e,"p");Re.className="spotpatch-agent-summary";let me=d(e,"ul");me.className="spotpatch-agent-files";let ee=d(e,"div");ee.className="spotpatch-agent-checks";let N=d(e,"pre");N.className="spotpatch-agent-diff",N.tabIndex=0,N.setAttribute("aria-label",n.agent.diffAriaLabel),Ce.append(Re,me,ee,N),de.append(oe,Pe,he,F,Ce),s.append(r,E,de);let K=J(e,n.agent.testConnection),be=J(e,n.agent.verifyAndRun,"spotpatch-run"),Le=J(e,n.agent.cancel),ve=J(e,n.agent.apply,"spotpatch-primary"),ye=J(e,n.agent.revert),re=J(e,n.agent.revise),_=t.enabled?t.providers:[],ke=new Map(_.map(m=>[m.id,m])),Se=!1,Me=!0,Y=!1,T=!1,Te=!1,le=!1,ae,De,$e=[],Ae,ie="idle",we=n.agent.connectionNotTested,Oe,V="idle",ze,Ie;for(let m of _)Un(e,u,m.id,m.label);t.enabled&&(u.value=t.defaultProvider);let xe=()=>ke.get(u.value),pe=()=>{let m=xe();if(I.replaceChildren(),m===void 0){Q.textContent=n.agent.providerUnavailable;return}for(let a of m.models)Un(e,I,a.id,a.label);I.value=m.defaultModel,Q.textContent=n.agent.consent(m.label)},U=()=>{let m=t.enabled&&Y&&!T;be.textContent=Te?n.agent.verifying:le?n.agent.run:n.agent.verifyAndRun,be.classList.toggle("spotpatch-primary",le),K.hidden=!m,be.hidden=!m,K.disabled=!Me||Te||xe()===void 0,be.disabled=!Me||Te||!Se||!x.checked||V==="idle"||V==="checking"||V==="blocked"||V==="consent-required"&&!f.checked||xe()===void 0||I.value.length===0,(!T||!Y)&&(Le.hidden=!0,ve.hidden=!0,ye.hidden=!0,re.hidden=!0)},qe=()=>{if(V==="idle")G.textContent=n.agent.workspaceNotChecked;else if(V==="checking")G.textContent=n.agent.checkingWorkspace;else if(V==="ready")G.textContent=n.agent.workspaceReady;else if(V==="consent-required"){let m=ze?.changes;G.textContent=n.agent.workspaceDirty(m?.staged??0,m?.unstaged??0,m?.untracked??0)}else G.textContent=Ie===void 0?n.errors.INTERNAL_ERROR:n.errors[Ie]};function Ue(){pe(),x.checked=!1,$.dataset.state="idle",$.textContent=n.agent.connectionNotTested,ie="idle",we=n.agent.connectionNotTested,Oe=void 0,le=!1,U()}function rt(){$.dataset.state="idle",$.textContent=n.agent.connectionNotTested,ie="idle",we=n.agent.connectionNotTested,Oe=void 0,le=!1,U()}pe(),u.addEventListener("change",Ue),I.addEventListener("change",rt),x.addEventListener("change",U),f.addEventListener("change",U);function Fe(){if(ae===void 0)return;let m=ae,a=De;B.textContent=`${m.providerLabel} · ${m.modelLabel}`,L.textContent=n.agent.status(m.status),Pe.textContent=m.phaseMessage;let c=Ae??m.errorCode;he.hidden=c===void 0,he.textContent=c===void 0?"":n.errors[c],F.replaceChildren();for(let h of $e.slice(-8)){let w=d(e,"li");w.dataset.state=h.state,w.textContent=h.label,F.append(w)}Ce.hidden=a===void 0,Re.textContent=a?.summary??"",me.replaceChildren(),ee.replaceChildren(),N.textContent=a?.diff??"";for(let h of a?.files??[]){let w=d(e,"li");w.textContent=`${h.kind} ${h.relativePath} (+${String(h.additions)} / -${String(h.deletions)})`,me.append(w)}for(let h of a?.checks??[]){let w=d(e,"details"),z=d(e,"summary");z.textContent=`${h.label}: ${h.status} · ${String(h.durationMs)} ms`;let te=d(e,"pre");te.textContent=h.output.length===0?n.agent.noOutput:h.output,w.append(z,te),ee.append(w)}K.hidden=!0,be.hidden=!0,Le.hidden=!Y||!m.canCancel,Le.textContent=m.status==="awaiting-review"?n.agent.discard:n.agent.cancel,ve.hidden=!Y||!m.canApply,ye.hidden=!Y||!m.canRevert,re.hidden=!Y||!["completed","cancelled","reverted","failed"].includes(m.status)}function Ke(){n=o.messages(),i.textContent=n.agent.title,l.textContent=t.enabled&&t.applyMode==="auto"?n.agent.autoGated:n.agent.review,k.textContent=n.agent.provider,Z.textContent=n.agent.model,u.setAttribute("aria-label",n.agent.providerAriaLabel),I.setAttribute("aria-label",n.agent.modelAriaLabel),C.textContent=n.agent.includeLocalChanges,v.textContent=n.agent.includeLocalChangesHelp,N.setAttribute("aria-label",n.agent.diffAriaLabel),K.textContent=n.agent.testConnection,ve.textContent=n.agent.apply,ye.textContent=n.agent.revert,re.textContent=n.agent.revise;let m=xe();Q.textContent=m===void 0?n.agent.providerUnavailable:n.agent.consent(m.label),ie==="idle"?$.textContent=n.agent.connectionNotTested:ie==="probing"?$.textContent=n.agent.testingCapability:ie==="ready"?$.textContent=`${n.agent.capabilityVerified} · ${n.agent.toolsReady}`:Oe!==void 0?$.textContent=n.errors[Oe]:xe()===void 0?$.textContent=n.agent.providerUnavailable:$.textContent=we,qe(),U(),Fe()}let st=o.subscribe(Ke);return Ke(),Object.freeze({root:s,providerSelect:u,modelSelect:I,consentCheckbox:x,workspaceConsentCheckbox:f,testButton:K,runButton:be,cancelButton:Le,applyButton:ve,revertButton:ye,resetButton:re,consentGranted(){return x.checked},workspaceConsentGranted(){return f.checked},readSelection(){let m=xe(),a=m?.models.find(c=>c.id===I.value);return m===void 0||a===void 0?void 0:Object.freeze({providerProfileId:m.id,modelProfileId:a.id})},renderCapability(m,a,c,h){ie=m,we=a,Oe=h,Te=m==="probing",le=m==="ready"&&c?.state==="agent-ready",$.dataset.state=m,$.textContent=c?.state==="agent-ready"?`${a} · ${n.agent.toolsReady}`:a,U()},renderWorkspaceHealth(m,a,c){V=m,ze=a,Ie=c??a?.errorCode,G.dataset.state=m,m!=="checking"&&(q.hidden=m!=="consent-required"),(m==="idle"||m==="ready"||m==="blocked")&&(f.checked=!1),qe(),U()},renderJob(m,a,c,h){T=!0,E.hidden=!0,de.hidden=!1,u.disabled=!0,I.disabled=!0,x.disabled=!0,f.disabled=!0,ae=m,De=a,$e=c,Ae=h,Fe()},resetJob(){T=!1,ae=void 0,De=void 0,$e=[],Ae=void 0,E.hidden=!1,de.hidden=!0,u.disabled=!1,I.disabled=!1,x.disabled=!1,f.disabled=!1,F.replaceChildren(),me.replaceChildren(),ee.replaceChildren(),N.textContent="",he.textContent="",he.hidden=!0,U()},setContextReady(m){Se=m,U()},setEditingEnabled(m){Me=m,u.disabled=!m||T,I.disabled=!m||T,x.disabled=!m||T,f.disabled=!m||T,U()},setProviderConsent(m){x.checked=m,U()},setSelectionVisible(m){Y=m,U(),m||(Le.hidden=!0,ve.hidden=!0,ye.hidden=!0,re.hidden=!0)},dispose(){st(),u.removeEventListener("change",Ue),I.removeEventListener("change",rt),x.removeEventListener("change",U),f.removeEventListener("change",U)}})}var Wn="http://www.w3.org/2000/svg",$r="";function zr(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:$r,viewBox:"0 0 1 1"}}function jr(e,t,o){let n=e.createElementNS(Wn,t);for(let[s,r]of Object.entries(o))n.setAttribute(s,r);return n}function Jn(e,t){let o=zr(t),n=jr(e,"svg",{xmlns:Wn,class:"spotpatch-brand-mark",viewBox:o.viewBox,"aria-hidden":"true",focusable:"false"});return n.innerHTML=o.content,n}function Ct(e,t,o){return Math.min(Math.max(e,t),Math.max(t,o))}function qn({dialogHeight:e,dialogWidth:t,target:o,viewportHeight:n,viewportWidth:s}){let r=s-t-16,i=n-e-16,l=o.x+o.width/2,E=o.y+o.height/2,A=Ct(l-t/2,16,r),R=Ct(E-e/2,16,i),k=A,u=R,P="viewport";return o.width>=t+48&&o.height>=e+48?P="center":o.y-e-14>=16?(u=o.y-e-14,P="above"):o.y+o.height+14+e<=n-16?(u=o.y+o.height+14,P="below"):o.x+o.width+14+t<=s-16?(k=o.x+o.width+14,P="right"):o.x-t-14>=16&&(k=o.x-t-14,P="left"),Object.freeze({anchorX:Ct(l-k,22,t-22),anchorY:Ct(E-u,22,e-22),left:k,mode:P,top:u})}var Br=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"}),Hr=Object.freeze({queued:"已排队",preparing:"准备中",running:"执行中",validating:"验证中","awaiting-review":"等待审阅",applying:"应用中",applied:"已应用",completed:"已完成",cancelling:"取消中",cancelled:"已取消",reverting:"撤销中",reverted:"已撤销",failed:"失败"}),Ur=Object.freeze({[g.INVALID_REQUEST]:"The Agent request was rejected as invalid.",[g.INVALID_TOKEN]:"The local SpotPatch session expired.",[g.ORIGIN_NOT_ALLOWED]:"The current page origin is not authorized.",[g.SOURCE_NOT_FOUND]:"The selected source is no longer available.",[g.SOURCE_OUTSIDE_ROOT]:"The selected source is outside the project.",[g.SOURCE_TOO_LARGE]:"The selected source exceeds the safety limit.",[g.EDITOR_OPEN_FAILED]:"The editor request failed.",[g.AI_DISABLED]:"AI execution is disabled in Vite configuration.",[g.PROVIDER_NOT_CONFIGURED]:"The provider Key environment variable is missing on the Vite process.",[g.PROVIDER_AUTH_FAILED]:"The provider rejected authentication. Check the server-side Key.",[g.PROVIDER_PROTOCOL_UNSUPPORTED]:"The relay does not match the configured OpenAI-compatible protocol.",[g.MODEL_NOT_ALLOWED]:"The selected model profile is not allowed.",[g.MODEL_TOOL_CALL_UNSUPPORTED]:"The selected model did not complete the required tool-call probe.",[g.PROVIDER_RATE_LIMITED]:"The provider is rate limited. Wait and try again.",[g.AGENT_BUSY]:"Another write Agent job is still active.",[g.AGENT_LIMIT_EXCEEDED]:"The Agent stopped at a configured time, turn, output, or size limit.",[g.AGENT_CANCELLED]:"The Agent job was cancelled.",[g.WORKTREE_DIRTY]:"Confirm inclusion of local changes before running AI.",[g.WORKTREE_NOT_REPOSITORY]:"Vite root must be an initialized Git repository root.",[g.WORKTREE_OPERATION_IN_PROGRESS]:"Finish the active merge, rebase, cherry-pick, or revert.",[g.WORKTREE_CONFLICTED]:"Resolve all Git conflicts before running AI.",[g.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"Reduce untracked files below the safe count and size limits.",[g.WORKTREE_UNTRACKED_UNSUPPORTED]:"An untracked path is missing, linked, or not a regular file.",[g.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"Local changes cannot be isolated safely.",[g.TOOL_DENIED]:"A tool request violated local safety policy.",[g.TOOL_INPUT_INVALID]:"Invalid tool request.",[g.TOOL_ARGUMENTS_INVALID]:"Tool arguments are invalid.",[g.TOOL_CALL_ID_CONFLICT]:"Tool ID conflicts in this turn.",[g.TOOL_PATH_DENIED]:"The model requested a protected or external path.",[g.PATCH_REJECTED]:"The patch violated local policy.",[g.VALIDATION_FAILED]:"Required checks failed; changes cannot be applied.",[g.APPLY_CONFLICT]:"Agent-touched files changed; nothing was overwritten.",[g.INTERNAL_ERROR]:"The Agent failed without exposing private details."}),Gr=Object.freeze({[g.INVALID_REQUEST]:"Agent 请求无效,已被拒绝。",[g.INVALID_TOKEN]:"本地 SpotPatch 会话已失效。",[g.ORIGIN_NOT_ALLOWED]:"当前页面来源未获授权。",[g.SOURCE_NOT_FOUND]:"选中目标对应的源码已不可用。",[g.SOURCE_OUTSIDE_ROOT]:"选中源码位于项目根目录之外。",[g.SOURCE_TOO_LARGE]:"选中源码超过安全大小限制。",[g.EDITOR_OPEN_FAILED]:"编辑器打开请求失败。",[g.AI_DISABLED]:"Vite 配置未启用 AI 执行。",[g.PROVIDER_NOT_CONFIGURED]:"启动 Vite 的进程中缺少模型服务 Key 环境变量。",[g.PROVIDER_AUTH_FAILED]:"模型服务鉴权失败,请检查服务端 Key。",[g.PROVIDER_PROTOCOL_UNSUPPORTED]:"中转服务与配置的 OpenAI 兼容协议不一致。",[g.MODEL_NOT_ALLOWED]:"当前模型配置未获授权。",[g.MODEL_TOOL_CALL_UNSUPPORTED]:"当前模型未通过必要的工具调用能力探测。",[g.PROVIDER_RATE_LIMITED]:"模型服务正在限流,请稍后重试。",[g.AGENT_BUSY]:"当前项目已有一个写入任务正在运行。",[g.AGENT_LIMIT_EXCEEDED]:"Agent 达到时间、轮次、输出或变更规模限制。",[g.AGENT_CANCELLED]:"Agent 任务已取消。",[g.WORKTREE_DIRTY]:"运行 AI 前,请明确同意将当前本地修改纳入隔离基线。",[g.WORKTREE_NOT_REPOSITORY]:"Vite 根目录不是已初始化 Git 仓库的顶层目录。",[g.WORKTREE_OPERATION_IN_PROGRESS]:"请先完成当前 merge、rebase、cherry-pick 或 revert,再运行 AI。",[g.WORKTREE_CONFLICTED]:"请先解决全部 Git 冲突,再运行 AI。",[g.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"未跟踪文件超过安全数量或体积上限,请先精简。",[g.WORKTREE_UNTRACKED_UNSUPPORTED]:"未跟踪项已丢失、是符号链接或不是普通文件。",[g.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"当前本地修改无法安全隔离。",[g.TOOL_DENIED]:"工具请求违反本地安全策略。",[g.TOOL_INPUT_INVALID]:"工具请求无效。",[g.TOOL_ARGUMENTS_INVALID]:"工具参数无效。",[g.TOOL_CALL_ID_CONFLICT]:"本轮工具 ID 冲突。",[g.TOOL_PATH_DENIED]:"模型请求了受保护或项目外路径。",[g.PATCH_REJECTED]:"补丁违反本地策略。",[g.VALIDATION_FAILED]:"必需检查失败,无法应用变更。",[g.APPLY_CONFLICT]:"Agent 触及文件已变化,未覆盖。",[g.INTERNAL_ERROR]:"Agent 失败,未暴露私有细节。"}),Vr=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"}),Wr=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:"警告"}),Jr=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:Vr,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",review:"Review",autoGated:"Auto gated",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.`,connectionNotTested:"Connection not tested",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 validated 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",verifyAndRun:"Verify & run",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=>Br[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:Ur}),"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:Wr,actions:Object.freeze({addElement:"添加元素",reselect:"重新开始",openEditor:"打开源码",openTarget:e=>`打开目标 ${String(e)} 的源码`,preview:"预览 Prompt",copy:"复制 Prompt",back:"返回编辑"}),agent:Object.freeze({title:"AI 代码 Agent",review:"审阅模式",autoGated:"受控自动模式",provider:"模型服务",model:"模型",providerAriaLabel:"AI 模型服务",modelAriaLabel:"AI 模型",providerUnavailable:"模型服务配置不可用。",consent:e=>`我了解选中上下文与获准源码可能发送到 ${e},并自行负责其数据策略。`,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:"检查运行环境",verifyAndRun:"验证并运行",verifying:"验证中……",run:"运行 AI",cancel:"取消 Agent",discard:"放弃变更",apply:"应用变更",revert:"撤销变更",revise:"修改请求",diffAriaLabel:"建议的源码差异",noOutput:"没有输出。",status:e=>Hr[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:Gr})});function Fn(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 qr(e,t){if(e!=="auto")return e;let o=Fn(t.documentElement.lang);return o!==void 0?o:t.defaultView?.navigator.languages.map(Fn).find(s=>s!==void 0)??"en-US"}function Kn(e,t="auto"){let o=qr(t,e),n=new Set;return Object.freeze({locale:()=>o,messages:()=>Jr[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 Fr=560,Kr=Object.freeze({previewing:640,selected:720});function Yr(e){let t=e.createElement("style");return t.textContent=`
|
|
242
|
+
`;function Fn(e,t,o,n){let s=e.createElement("option");s.value=o,s.textContent=n,t.append(s)}function Yn(e,t,o){let n=o.messages(),s=d(e,"section");s.className="spotpatch-agent",s.hidden=!t.enabled;let r=d(e,"div");r.className="spotpatch-agent-head";let a=d(e,"span");a.className="spotpatch-agent-title";let l=d(e,"span");l.className="spotpatch-agent-badge",r.append(a,l);let E=d(e,"div");E.className="spotpatch-agent-setup";let A=d(e,"div");A.className="spotpatch-agent-selectors";let R=d(e,"label"),j=d(e,"span"),u=d(e,"select");R.append(j,u);let L=d(e,"label"),V=d(e,"span"),P=d(e,"select");L.append(V,P),A.append(R,L);let b=d(e,"label");b.className="spotpatch-consent";let x=d(e,"input");x.type="checkbox";let Q=d(e,"span");b.append(x,Q);let Y=d(e,"label");Y.className="spotpatch-consent spotpatch-workspace-consent",Y.hidden=!0;let h=d(e,"input");h.type="checkbox";let S=d(e,"span"),C=d(e,"strong"),T=d(e,"small");S.append(C,T),Y.append(h,S);let D=d(e,"div");D.className="spotpatch-agent-health-list";let F=d(e,"p");F.className="spotpatch-agent-workspace",F.dataset.state="idle";let $=d(e,"p");$.className="spotpatch-agent-capability",$.dataset.state="idle",D.append(F,$),E.append(A,b,Y,D);let ae=d(e,"div");ae.className="spotpatch-agent-job",ae.hidden=!0;let ie=d(e,"div");ie.className="spotpatch-agent-job-meta";let B=d(e,"span");B.className="spotpatch-agent-model";let k=d(e,"span");k.className="spotpatch-agent-status",ie.append(B,k);let Le=d(e,"p");Le.className="spotpatch-agent-phase";let he=d(e,"p");he.className="spotpatch-agent-error",he.hidden=!0;let X=d(e,"ul");X.className="spotpatch-agent-activity";let Re=d(e,"div");Re.className="spotpatch-agent-result",Re.hidden=!0;let ve=d(e,"p");ve.className="spotpatch-agent-summary";let me=d(e,"ul");me.className="spotpatch-agent-files";let ee=d(e,"div");ee.className="spotpatch-agent-checks";let N=d(e,"pre");N.className="spotpatch-agent-diff",N.tabIndex=0,N.setAttribute("aria-label",n.agent.diffAriaLabel),Re.append(ve,me,ee,N),ae.append(ie,Le,he,X,Re),s.append(r,E,ae);let be=K(e,n.agent.testConnection),Te=K(e,n.agent.verifyAndRun,"spotpatch-run"),te=K(e,n.agent.cancel),le=K(e,n.agent.apply,"spotpatch-primary"),De=K(e,n.agent.revert),ye=K(e,n.agent.revise),we=t.enabled?t.providers:[],$e=new Map(we.map(m=>[m.id,m])),w=!1,Oe=!0,ne=!1,_=!1,se=!1,oe=!1,Ce,Se,pe=[],Ie,xe="idle",_e=n.agent.connectionNotTested,ke,W="idle",Pe,Ne;for(let m of we)Fn(e,u,m.id,m.label);t.enabled&&(u.value=t.defaultProvider);let Ee=()=>$e.get(u.value),Ve=()=>{let m=Ee();if(P.replaceChildren(),m===void 0){Q.textContent=n.agent.providerUnavailable;return}for(let i of m.models)Fn(e,P,i.id,i.label);P.value=m.defaultModel,Q.textContent=n.agent.consent(m.label)},J=()=>{let m=t.enabled&&ne&&!_;Te.textContent=se?n.agent.verifying:oe?n.agent.run:n.agent.verifyAndRun,Te.classList.toggle("spotpatch-primary",oe),be.hidden=!m,Te.hidden=!m,be.disabled=!Oe||se||Ee()===void 0,Te.disabled=!Oe||se||!w||!x.checked||W==="idle"||W==="checking"||W==="blocked"||W==="consent-required"&&!h.checked||Ee()===void 0||P.value.length===0,(!_||!ne)&&(te.hidden=!0,le.hidden=!0,De.hidden=!0,ye.hidden=!0)},ze=()=>{if(W==="idle")F.textContent=n.agent.workspaceNotChecked;else if(W==="checking")F.textContent=n.agent.checkingWorkspace;else if(W==="ready")F.textContent=n.agent.workspaceReady;else if(W==="consent-required"){let m=Pe?.changes;F.textContent=n.agent.workspaceDirty(m?.staged??0,m?.unstaged??0,m?.untracked??0)}else F.textContent=Ne===void 0?n.errors.INTERNAL_ERROR:n.errors[Ne]};function je(){Ve(),x.checked=!1,$.dataset.state="idle",$.textContent=n.agent.connectionNotTested,xe="idle",_e=n.agent.connectionNotTested,ke=void 0,oe=!1,J()}function ue(){$.dataset.state="idle",$.textContent=n.agent.connectionNotTested,xe="idle",_e=n.agent.connectionNotTested,ke=void 0,oe=!1,J()}Ve(),u.addEventListener("change",je),P.addEventListener("change",ue),x.addEventListener("change",J),h.addEventListener("change",J);function He(){if(Ce===void 0)return;let m=Ce,i=Se;B.textContent=`${m.providerLabel} · ${m.modelLabel}`,k.textContent=n.agent.status(m.status),Le.textContent=m.phaseMessage;let c=Ie??m.errorCode;he.hidden=c===void 0,he.textContent=c===void 0?"":n.errors[c],X.replaceChildren();for(let g of pe.slice(-8)){let O=d(e,"li");O.dataset.state=g.state,O.textContent=g.label,X.append(O)}Re.hidden=i===void 0,ve.textContent=i?.summary??"",me.replaceChildren(),ee.replaceChildren(),N.textContent=i?.diff??"";for(let g of i?.files??[]){let O=d(e,"li");O.textContent=`${g.kind} ${g.relativePath} (+${String(g.additions)} / -${String(g.deletions)})`,me.append(O)}for(let g of i?.checks??[]){let O=d(e,"details"),z=d(e,"summary");z.textContent=`${g.label}: ${g.status} · ${String(g.durationMs)} ms`;let I=d(e,"pre");I.textContent=g.output.length===0?n.agent.noOutput:g.output,O.append(z,I),ee.append(O)}be.hidden=!0,Te.hidden=!0,te.hidden=!ne||!m.canCancel,te.textContent=m.status==="awaiting-review"?n.agent.discard:n.agent.cancel,le.hidden=!ne||!m.canApply,De.hidden=!ne||!m.canRevert,ye.hidden=!ne||!["completed","cancelled","reverted","failed"].includes(m.status)}function Ke(){n=o.messages(),a.textContent=n.agent.title,l.textContent=t.enabled&&t.applyMode==="auto"?n.agent.autoGated:n.agent.review,j.textContent=n.agent.provider,V.textContent=n.agent.model,u.setAttribute("aria-label",n.agent.providerAriaLabel),P.setAttribute("aria-label",n.agent.modelAriaLabel),C.textContent=n.agent.includeLocalChanges,T.textContent=n.agent.includeLocalChangesHelp,N.setAttribute("aria-label",n.agent.diffAriaLabel),be.textContent=n.agent.testConnection,le.textContent=n.agent.apply,De.textContent=n.agent.revert,ye.textContent=n.agent.revise;let m=Ee();Q.textContent=m===void 0?n.agent.providerUnavailable:n.agent.consent(m.label),xe==="idle"?$.textContent=n.agent.connectionNotTested:xe==="probing"?$.textContent=n.agent.testingCapability:xe==="ready"?$.textContent=`${n.agent.capabilityVerified} · ${n.agent.toolsReady}`:ke!==void 0?$.textContent=n.errors[ke]:Ee()===void 0?$.textContent=n.agent.providerUnavailable:$.textContent=_e,ze(),J(),He()}let nt=o.subscribe(Ke);return Ke(),Object.freeze({root:s,providerSelect:u,modelSelect:P,consentCheckbox:x,workspaceConsentCheckbox:h,testButton:be,runButton:Te,cancelButton:te,applyButton:le,revertButton:De,resetButton:ye,consentGranted(){return x.checked},workspaceConsentGranted(){return h.checked},readSelection(){let m=Ee(),i=m?.models.find(c=>c.id===P.value);return m===void 0||i===void 0?void 0:Object.freeze({providerProfileId:m.id,modelProfileId:i.id})},renderCapability(m,i,c,g){xe=m,_e=i,ke=g,se=m==="probing",oe=m==="ready"&&c?.state==="agent-ready",$.dataset.state=m,$.textContent=c?.state==="agent-ready"?`${i} · ${n.agent.toolsReady}`:i,J()},renderWorkspaceHealth(m,i,c){W=m,Pe=i,Ne=c??i?.errorCode,F.dataset.state=m,m!=="checking"&&(Y.hidden=m!=="consent-required"),(m==="idle"||m==="ready"||m==="blocked")&&(h.checked=!1),ze(),J()},renderJob(m,i,c,g){_=!0,E.hidden=!0,ae.hidden=!1,u.disabled=!0,P.disabled=!0,x.disabled=!0,h.disabled=!0,Ce=m,Se=i,pe=c,Ie=g,He()},resetJob(){_=!1,Ce=void 0,Se=void 0,pe=[],Ie=void 0,E.hidden=!1,ae.hidden=!0,u.disabled=!1,P.disabled=!1,x.disabled=!1,h.disabled=!1,X.replaceChildren(),me.replaceChildren(),ee.replaceChildren(),N.textContent="",he.textContent="",he.hidden=!0,J()},setContextReady(m){w=m,J()},setEditingEnabled(m){Oe=m,u.disabled=!m||_,P.disabled=!m||_,x.disabled=!m||_,h.disabled=!m||_,J()},setProviderConsent(m){x.checked=m,J()},setSelectionVisible(m){ne=m,J(),m||(te.hidden=!0,le.hidden=!0,De.hidden=!0,ye.hidden=!0)},dispose(){nt(),u.removeEventListener("change",je),P.removeEventListener("change",ue),x.removeEventListener("change",J),h.removeEventListener("change",J)}})}var Xn="http://www.w3.org/2000/svg",Jr="";function qr(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:Jr,viewBox:"0 0 1 1"}}function Fr(e,t,o){let n=e.createElementNS(Xn,t);for(let[s,r]of Object.entries(o))n.setAttribute(s,r);return n}function Zn(e,t){let o=qr(t),n=Fr(e,"svg",{xmlns:Xn,class:"spotpatch-brand-mark",viewBox:o.viewBox,"aria-hidden":"true",focusable:"false"});return n.innerHTML=o.content,n}function tt(e,t,o){return Math.min(Math.max(e,t),Math.max(t,o))}function Qn({dialogHeight:e,dialogWidth:t,target:o,viewportHeight:n,viewportWidth:s}){let r=s-t-16,a=n-e-16,l=tt((s-t)/2,16,r),E=tt((n-e)/2,16,a);if(o===void 0)return Object.freeze({anchorX:tt(t/2,22,t-22),anchorY:tt(e/2,22,e-22),left:l,mode:"viewport",top:E});let A=o.x+o.width/2,R=o.y+o.height/2,j=tt(A-t/2,16,r),u=tt(R-e/2,16,a),L=j,V=u,P="viewport";return o.width>=t+48&&o.height>=e+48?P="center":o.y-e-14>=16?(V=o.y-e-14,P="above"):o.y+o.height+14+e<=n-16?(V=o.y+o.height+14,P="below"):o.x+o.width+14+t<=s-16?(L=o.x+o.width+14,P="right"):o.x-t-14>=16&&(L=o.x-t-14,P="left"),Object.freeze({anchorX:tt(A-L,22,t-22),anchorY:tt(R-V,22,e-22),left:L,mode:P,top:V})}var Kr=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"}),Yr=Object.freeze({queued:"已排队",preparing:"准备中",running:"执行中",validating:"验证中","awaiting-review":"等待审阅",applying:"应用中",applied:"已应用",completed:"已完成",cancelling:"取消中",cancelled:"已取消",reverting:"撤销中",reverted:"已撤销",failed:"失败"}),Xr=Object.freeze({[f.INVALID_REQUEST]:"The Agent request was rejected as invalid.",[f.INVALID_TOKEN]:"The local SpotPatch session expired.",[f.ORIGIN_NOT_ALLOWED]:"The current page origin is not authorized.",[f.SOURCE_NOT_FOUND]:"The selected source is no longer available.",[f.SOURCE_OUTSIDE_ROOT]:"The selected source is outside the project.",[f.SOURCE_TOO_LARGE]:"The selected source exceeds the safety limit.",[f.EDITOR_OPEN_FAILED]:"The editor request failed.",[f.AI_DISABLED]:"AI execution is disabled in Vite configuration.",[f.PROVIDER_NOT_CONFIGURED]:"The provider Key environment variable is missing on the Vite process.",[f.PROVIDER_AUTH_FAILED]:"The provider rejected authentication. Check the server-side Key.",[f.PROVIDER_PROTOCOL_UNSUPPORTED]:"The relay does not match the configured OpenAI-compatible protocol.",[f.MODEL_NOT_ALLOWED]:"The selected model profile is not allowed.",[f.MODEL_TOOL_CALL_UNSUPPORTED]:"The selected model did not complete the required tool-call probe.",[f.PROVIDER_RATE_LIMITED]:"The provider is rate limited. Wait and try again.",[f.AGENT_BUSY]:"Another write Agent job is still active.",[f.AGENT_LIMIT_EXCEEDED]:"The Agent stopped at a configured time, turn, output, or size limit.",[f.AGENT_CANCELLED]:"The Agent job was cancelled.",[f.WORKTREE_DIRTY]:"Confirm inclusion of local changes before running AI.",[f.WORKTREE_NOT_REPOSITORY]:"Vite root must be an initialized Git repository root.",[f.WORKTREE_OPERATION_IN_PROGRESS]:"Finish the active merge, rebase, cherry-pick, or revert.",[f.WORKTREE_CONFLICTED]:"Resolve all Git conflicts before running AI.",[f.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"Reduce untracked files below the safe count and size limits.",[f.WORKTREE_UNTRACKED_UNSUPPORTED]:"An untracked path is missing, linked, or not a regular file.",[f.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"Local changes cannot be isolated safely.",[f.TOOL_DENIED]:"A tool request violated local safety policy.",[f.TOOL_INPUT_INVALID]:"Invalid tool request.",[f.TOOL_ARGUMENTS_INVALID]:"Tool arguments are invalid.",[f.TOOL_CALL_ID_CONFLICT]:"Tool ID conflicts in this turn.",[f.TOOL_PATH_DENIED]:"The model requested a protected or external path.",[f.PATCH_REJECTED]:"The patch violated local policy.",[f.VALIDATION_FAILED]:"Required checks failed; changes cannot be applied.",[f.APPLY_CONFLICT]:"Agent-touched files changed; nothing was overwritten.",[f.INTERNAL_ERROR]:"The Agent failed without exposing private details."}),Zr=Object.freeze({[f.INVALID_REQUEST]:"Agent 请求无效,已被拒绝。",[f.INVALID_TOKEN]:"本地 SpotPatch 会话已失效。",[f.ORIGIN_NOT_ALLOWED]:"当前页面来源未获授权。",[f.SOURCE_NOT_FOUND]:"选中目标对应的源码已不可用。",[f.SOURCE_OUTSIDE_ROOT]:"选中源码位于项目根目录之外。",[f.SOURCE_TOO_LARGE]:"选中源码超过安全大小限制。",[f.EDITOR_OPEN_FAILED]:"编辑器打开请求失败。",[f.AI_DISABLED]:"Vite 配置未启用 AI 执行。",[f.PROVIDER_NOT_CONFIGURED]:"启动 Vite 的进程中缺少模型服务 Key 环境变量。",[f.PROVIDER_AUTH_FAILED]:"模型服务鉴权失败,请检查服务端 Key。",[f.PROVIDER_PROTOCOL_UNSUPPORTED]:"中转服务与配置的 OpenAI 兼容协议不一致。",[f.MODEL_NOT_ALLOWED]:"当前模型配置未获授权。",[f.MODEL_TOOL_CALL_UNSUPPORTED]:"当前模型未通过必要的工具调用能力探测。",[f.PROVIDER_RATE_LIMITED]:"模型服务正在限流,请稍后重试。",[f.AGENT_BUSY]:"当前项目已有一个写入任务正在运行。",[f.AGENT_LIMIT_EXCEEDED]:"Agent 达到时间、轮次、输出或变更规模限制。",[f.AGENT_CANCELLED]:"Agent 任务已取消。",[f.WORKTREE_DIRTY]:"运行 AI 前,请明确同意将当前本地修改纳入隔离基线。",[f.WORKTREE_NOT_REPOSITORY]:"Vite 根目录不是已初始化 Git 仓库的顶层目录。",[f.WORKTREE_OPERATION_IN_PROGRESS]:"请先完成当前 merge、rebase、cherry-pick 或 revert,再运行 AI。",[f.WORKTREE_CONFLICTED]:"请先解决全部 Git 冲突,再运行 AI。",[f.WORKTREE_LOCAL_CHANGES_TOO_LARGE]:"未跟踪文件超过安全数量或体积上限,请先精简。",[f.WORKTREE_UNTRACKED_UNSUPPORTED]:"未跟踪项已丢失、是符号链接或不是普通文件。",[f.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]:"当前本地修改无法安全隔离。",[f.TOOL_DENIED]:"工具请求违反本地安全策略。",[f.TOOL_INPUT_INVALID]:"工具请求无效。",[f.TOOL_ARGUMENTS_INVALID]:"工具参数无效。",[f.TOOL_CALL_ID_CONFLICT]:"本轮工具 ID 冲突。",[f.TOOL_PATH_DENIED]:"模型请求了受保护或项目外路径。",[f.PATCH_REJECTED]:"补丁违反本地策略。",[f.VALIDATION_FAILED]:"必需检查失败,无法应用变更。",[f.APPLY_CONFLICT]:"Agent 触及文件已变化,未覆盖。",[f.INTERNAL_ERROR]:"Agent 失败,未暴露私有细节。"}),Qr=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"}),ea=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:"警告"}),ta=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:Qr,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",review:"Review",autoGated:"Auto gated",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.`,connectionNotTested:"Connection not tested",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 validated 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",verifyAndRun:"Verify & run",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=>Kr[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:Xr}),"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:ea,actions:Object.freeze({addElement:"添加元素",reselect:"重新开始",openEditor:"打开源码",openTarget:e=>`打开目标 ${String(e)} 的源码`,preview:"预览 Prompt",copy:"复制 Prompt",back:"返回编辑"}),agent:Object.freeze({title:"AI 代码 Agent",review:"审阅模式",autoGated:"受控自动模式",provider:"模型服务",model:"模型",providerAriaLabel:"AI 模型服务",modelAriaLabel:"AI 模型",providerUnavailable:"模型服务配置不可用。",consent:e=>`我了解选中上下文与获准源码可能发送到 ${e},并自行负责其数据策略。`,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:"检查运行环境",verifyAndRun:"验证并运行",verifying:"验证中……",run:"运行 AI",cancel:"取消 Agent",discard:"放弃变更",apply:"应用变更",revert:"撤销变更",revise:"修改请求",diffAriaLabel:"建议的源码差异",noOutput:"没有输出。",status:e=>Yr[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:Zr})});function eo(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 na(e,t){if(e!=="auto")return e;let o=eo(t.documentElement.lang);return o!==void 0?o:t.defaultView?.navigator.languages.map(eo).find(s=>s!==void 0)??"en-US"}function to(e,t="auto"){let o=na(t,e),n=new Set;return Object.freeze({locale:()=>o,messages:()=>ta[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 no=460,oo=620,oa=Object.freeze({previewing:560,selected:oo});function ra(e){let t=e.createElement("style");return t.textContent=`
|
|
243
243
|
:host {
|
|
244
244
|
all: initial;
|
|
245
|
-
--spotpatch-bg: #
|
|
246
|
-
--spotpatch-bg-raised: #
|
|
247
|
-
--spotpatch-bg-
|
|
248
|
-
--spotpatch-
|
|
249
|
-
--spotpatch-border
|
|
250
|
-
--spotpatch-
|
|
251
|
-
--spotpatch-text
|
|
252
|
-
--spotpatch-text-
|
|
253
|
-
--spotpatch-
|
|
254
|
-
--spotpatch-accent
|
|
255
|
-
--spotpatch-accent-
|
|
245
|
+
--spotpatch-bg: #0e0e12;
|
|
246
|
+
--spotpatch-bg-raised: #17171c;
|
|
247
|
+
--spotpatch-bg-active: #1c1c22;
|
|
248
|
+
--spotpatch-bg-input: #0b0b0f;
|
|
249
|
+
--spotpatch-border: #2a2a32;
|
|
250
|
+
--spotpatch-border-subtle: #232329;
|
|
251
|
+
--spotpatch-text: #f2f2f5;
|
|
252
|
+
--spotpatch-text-secondary: #96969f;
|
|
253
|
+
--spotpatch-text-muted: #686872;
|
|
254
|
+
--spotpatch-accent: #8b7bff;
|
|
255
|
+
--spotpatch-accent-strong: #6a5ce8;
|
|
256
|
+
--spotpatch-accent-cyan: #52a8ff;
|
|
256
257
|
--spotpatch-danger: #fb7185;
|
|
257
258
|
--spotpatch-success: #34d399;
|
|
258
259
|
--spotpatch-warning: #f59e0b;
|
|
259
|
-
--spotpatch-
|
|
260
|
-
--spotpatch-radius-
|
|
261
|
-
--spotpatch-
|
|
260
|
+
--spotpatch-text-on-accent: #0b0b12;
|
|
261
|
+
--spotpatch-radius-panel: 16px;
|
|
262
|
+
--spotpatch-radius-card: 10px;
|
|
263
|
+
--spotpatch-shadow-panel: 0 30px 60px -20px rgb(0 0 0 / 70%);
|
|
262
264
|
color-scheme: dark;
|
|
263
265
|
color: var(--spotpatch-text);
|
|
264
266
|
font-family: Inter, "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
@@ -274,7 +276,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
274
276
|
position: fixed;
|
|
275
277
|
right: 24px;
|
|
276
278
|
bottom: 24px;
|
|
277
|
-
z-index: ${String(
|
|
279
|
+
z-index: ${String(bt.controls)};
|
|
278
280
|
display: inline-flex;
|
|
279
281
|
align-items: center;
|
|
280
282
|
gap: 10px;
|
|
@@ -308,7 +310,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
308
310
|
position: fixed;
|
|
309
311
|
top: 0;
|
|
310
312
|
left: 0;
|
|
311
|
-
z-index: ${String(
|
|
313
|
+
z-index: ${String(bt.highlight)};
|
|
312
314
|
box-sizing: border-box;
|
|
313
315
|
border: 2px solid var(--spotpatch-accent);
|
|
314
316
|
border-radius: 6px;
|
|
@@ -335,7 +337,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
335
337
|
.spotpatch-selection-highlights {
|
|
336
338
|
position: fixed;
|
|
337
339
|
inset: 0;
|
|
338
|
-
z-index: ${String(
|
|
340
|
+
z-index: ${String(bt.highlight)};
|
|
339
341
|
pointer-events: none;
|
|
340
342
|
}
|
|
341
343
|
.spotpatch-selection-highlight {
|
|
@@ -376,9 +378,9 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
376
378
|
position: fixed;
|
|
377
379
|
top: 16px;
|
|
378
380
|
left: 16px;
|
|
379
|
-
z-index: ${String(
|
|
381
|
+
z-index: ${String(bt.controls)};
|
|
380
382
|
box-sizing: border-box;
|
|
381
|
-
width: min(
|
|
383
|
+
width: min(${String(no)}px, calc(100vw - 32px));
|
|
382
384
|
color: #edf0f7;
|
|
383
385
|
outline: none;
|
|
384
386
|
filter: drop-shadow(var(--spotpatch-shadow-panel));
|
|
@@ -422,78 +424,92 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
422
424
|
position: relative;
|
|
423
425
|
z-index: 1;
|
|
424
426
|
display: flex;
|
|
425
|
-
|
|
427
|
+
box-sizing: border-box;
|
|
428
|
+
max-height: min(${String(oo)}px, calc(100vh - 32px));
|
|
426
429
|
overflow: hidden;
|
|
427
430
|
flex-direction: column;
|
|
428
431
|
border: 1px solid var(--spotpatch-border);
|
|
429
432
|
border-radius: var(--spotpatch-radius-panel);
|
|
430
433
|
background: var(--spotpatch-bg);
|
|
431
|
-
box-shadow: inset 0 1px rgb(255 255 255 /
|
|
434
|
+
box-shadow: inset 0 1px rgb(255 255 255 / 5%), 0 0 60px -32px rgb(139 123 255 / 20%);
|
|
435
|
+
}
|
|
436
|
+
.spotpatch-shell::before {
|
|
437
|
+
position: absolute;
|
|
438
|
+
z-index: 2;
|
|
439
|
+
top: 0;
|
|
440
|
+
right: 20%;
|
|
441
|
+
left: 20%;
|
|
442
|
+
height: 1px;
|
|
443
|
+
background: linear-gradient(90deg, transparent, var(--spotpatch-accent), var(--spotpatch-accent-cyan), transparent);
|
|
444
|
+
content: "";
|
|
445
|
+
opacity: .65;
|
|
446
|
+
pointer-events: none;
|
|
432
447
|
}
|
|
433
448
|
.spotpatch-header {
|
|
434
449
|
position: relative;
|
|
435
|
-
padding:
|
|
436
|
-
border-bottom: 1px solid rgb(255 255 255 / 8%);
|
|
450
|
+
padding: 0 18px 14px;
|
|
437
451
|
}
|
|
438
452
|
.spotpatch-brand-row {
|
|
439
453
|
display: flex;
|
|
440
454
|
align-items: center;
|
|
441
455
|
justify-content: space-between;
|
|
442
|
-
gap:
|
|
443
|
-
margin
|
|
456
|
+
gap: 12px;
|
|
457
|
+
margin: 0 -18px 18px;
|
|
458
|
+
padding: 14px 18px 13px;
|
|
459
|
+
border-bottom: 1px solid var(--spotpatch-border-subtle);
|
|
444
460
|
}
|
|
445
461
|
.spotpatch-brand {
|
|
446
462
|
display: inline-flex;
|
|
447
463
|
align-items: center;
|
|
448
|
-
gap:
|
|
464
|
+
gap: 10px;
|
|
449
465
|
min-width: 0;
|
|
450
466
|
color: #f8fafc;
|
|
451
467
|
}
|
|
452
468
|
.spotpatch-brand-mark {
|
|
453
|
-
width:
|
|
454
|
-
height:
|
|
469
|
+
width: 30px;
|
|
470
|
+
height: 30px;
|
|
455
471
|
flex: none;
|
|
456
472
|
filter: drop-shadow(0 6px 12px rgb(76 29 149 / 22%));
|
|
457
473
|
}
|
|
458
474
|
.spotpatch-brand-copy { display: grid; min-width: 0; gap: 1px; }
|
|
459
475
|
.spotpatch-brand-name {
|
|
460
476
|
color: #fff;
|
|
461
|
-
font-size:
|
|
462
|
-
font-weight:
|
|
477
|
+
font-size: 13.5px;
|
|
478
|
+
font-weight: 680;
|
|
463
479
|
letter-spacing: -.01em;
|
|
464
480
|
}
|
|
465
481
|
.spotpatch-brand-context {
|
|
466
482
|
color: #8e98aa;
|
|
467
|
-
font-size:
|
|
483
|
+
font-size: 10.5px;
|
|
468
484
|
font-weight: 560;
|
|
469
485
|
letter-spacing: .02em;
|
|
470
486
|
}
|
|
471
487
|
.spotpatch-header-controls {
|
|
472
488
|
display: inline-flex;
|
|
473
489
|
align-items: center;
|
|
474
|
-
gap:
|
|
490
|
+
gap: 6px;
|
|
475
491
|
flex: none;
|
|
476
492
|
}
|
|
477
493
|
.spotpatch-repository,
|
|
478
494
|
.spotpatch-locale,
|
|
479
495
|
.spotpatch-close {
|
|
480
|
-
height:
|
|
496
|
+
height: 27px;
|
|
481
497
|
border: 1px solid rgb(255 255 255 / 11%);
|
|
482
|
-
border-radius:
|
|
483
|
-
background:
|
|
498
|
+
border-radius: 7px;
|
|
499
|
+
background: transparent;
|
|
484
500
|
}
|
|
485
501
|
.spotpatch-repository {
|
|
486
502
|
display: inline-flex;
|
|
487
503
|
align-items: center;
|
|
488
|
-
padding: 0
|
|
489
|
-
color:
|
|
504
|
+
padding: 0 9px;
|
|
505
|
+
color: var(--spotpatch-text-secondary);
|
|
490
506
|
font-size: 11px;
|
|
491
507
|
font-weight: 680;
|
|
492
508
|
text-decoration: none;
|
|
493
509
|
}
|
|
494
510
|
.spotpatch-locale {
|
|
495
|
-
min-width:
|
|
496
|
-
padding: 0
|
|
511
|
+
min-width: 34px;
|
|
512
|
+
padding: 0 8px;
|
|
497
513
|
color: #c5cad5;
|
|
498
514
|
cursor: pointer;
|
|
499
515
|
font-size: 12px;
|
|
@@ -501,12 +517,12 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
501
517
|
}
|
|
502
518
|
.spotpatch-close {
|
|
503
519
|
display: inline-grid;
|
|
504
|
-
width:
|
|
520
|
+
width: 27px;
|
|
505
521
|
padding: 0;
|
|
506
522
|
place-items: center;
|
|
507
523
|
color: #9da5b4;
|
|
508
524
|
cursor: pointer;
|
|
509
|
-
font-size:
|
|
525
|
+
font-size: 15px;
|
|
510
526
|
line-height: 1;
|
|
511
527
|
transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
|
|
512
528
|
}
|
|
@@ -516,30 +532,30 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
516
532
|
.spotpatch-title {
|
|
517
533
|
margin: 0;
|
|
518
534
|
color: #fff;
|
|
519
|
-
font-size:
|
|
520
|
-
font-weight:
|
|
521
|
-
letter-spacing: -.
|
|
535
|
+
font-size: 18px;
|
|
536
|
+
font-weight: 680;
|
|
537
|
+
letter-spacing: -.015em;
|
|
522
538
|
}
|
|
523
539
|
.spotpatch-subtitle {
|
|
524
|
-
max-width:
|
|
525
|
-
margin:
|
|
526
|
-
color:
|
|
527
|
-
font-size:
|
|
528
|
-
line-height: 1.
|
|
540
|
+
max-width: 390px;
|
|
541
|
+
margin: 4px 0 0;
|
|
542
|
+
color: var(--spotpatch-text-secondary);
|
|
543
|
+
font-size: 12.5px;
|
|
544
|
+
line-height: 1.5;
|
|
529
545
|
}
|
|
530
546
|
.spotpatch-target-row {
|
|
531
547
|
display: flex;
|
|
532
548
|
align-items: center;
|
|
533
549
|
gap: 8px;
|
|
534
550
|
min-width: 0;
|
|
535
|
-
margin-top:
|
|
551
|
+
margin-top: 14px;
|
|
536
552
|
}
|
|
537
553
|
.spotpatch-target-label {
|
|
538
554
|
min-width: 0;
|
|
539
555
|
overflow: hidden;
|
|
540
556
|
border: 1px solid rgb(129 112 247 / 24%);
|
|
541
557
|
border-radius: 999px;
|
|
542
|
-
padding:
|
|
558
|
+
padding: 4px 10px;
|
|
543
559
|
color: #cdd2ff;
|
|
544
560
|
background: rgb(109 93 246 / 10%);
|
|
545
561
|
font: 600 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
@@ -552,7 +568,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
552
568
|
gap: 6px;
|
|
553
569
|
flex: none;
|
|
554
570
|
color: #a5adba;
|
|
555
|
-
font-size:
|
|
571
|
+
font-size: 11px;
|
|
556
572
|
white-space: nowrap;
|
|
557
573
|
}
|
|
558
574
|
.spotpatch-context-state::before {
|
|
@@ -573,7 +589,7 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
573
589
|
.spotpatch-body {
|
|
574
590
|
min-height: 0;
|
|
575
591
|
overflow: auto;
|
|
576
|
-
padding:
|
|
592
|
+
padding: 0 18px 14px;
|
|
577
593
|
scrollbar-color: rgb(100 116 139 / 50%) transparent;
|
|
578
594
|
scrollbar-width: thin;
|
|
579
595
|
}
|
|
@@ -584,36 +600,54 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
584
600
|
display: flex;
|
|
585
601
|
align-items: center;
|
|
586
602
|
justify-content: space-between;
|
|
587
|
-
gap:
|
|
588
|
-
margin-bottom:
|
|
589
|
-
color:
|
|
590
|
-
font-size:
|
|
591
|
-
font-weight:
|
|
603
|
+
gap: 10px;
|
|
604
|
+
margin-bottom: 8px;
|
|
605
|
+
color: var(--spotpatch-text-secondary);
|
|
606
|
+
font-size: 11px;
|
|
607
|
+
font-weight: 650;
|
|
608
|
+
letter-spacing: .04em;
|
|
609
|
+
text-transform: uppercase;
|
|
592
610
|
}
|
|
593
611
|
.spotpatch-targets-meta {
|
|
594
612
|
display: flex;
|
|
595
613
|
align-items: center;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
614
|
+
gap: 8px;
|
|
615
|
+
min-width: 0;
|
|
616
|
+
letter-spacing: 0;
|
|
617
|
+
text-transform: none;
|
|
599
618
|
}
|
|
600
|
-
.spotpatch-target-complete { color: var(--spotpatch-text-
|
|
619
|
+
.spotpatch-target-complete { color: var(--spotpatch-text-muted); font-size: 11px; font-weight: 560; }
|
|
601
620
|
.spotpatch-target-budget {
|
|
602
621
|
color: var(--spotpatch-text-muted);
|
|
603
|
-
font: 550
|
|
622
|
+
font: 550 10.5px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
604
623
|
}
|
|
624
|
+
.spotpatch-target-budget[data-state="ready"] { display: none; }
|
|
605
625
|
.spotpatch-target-budget[data-state="over"] { color: #fda4af; }
|
|
606
626
|
.spotpatch-target-count {
|
|
627
|
+
margin-left: auto;
|
|
607
628
|
border-radius: 999px;
|
|
608
629
|
padding: 3px 8px;
|
|
609
|
-
color:
|
|
610
|
-
|
|
611
|
-
|
|
630
|
+
color: var(--spotpatch-text-muted);
|
|
631
|
+
font: 600 10.5px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
632
|
+
}
|
|
633
|
+
.spotpatch-target-progress {
|
|
634
|
+
height: 3px;
|
|
635
|
+
margin-bottom: 13px;
|
|
636
|
+
overflow: hidden;
|
|
637
|
+
border-radius: 999px;
|
|
638
|
+
background: var(--spotpatch-border-subtle);
|
|
639
|
+
}
|
|
640
|
+
.spotpatch-target-progress-fill {
|
|
641
|
+
width: 0;
|
|
642
|
+
height: 100%;
|
|
643
|
+
border-radius: inherit;
|
|
644
|
+
background: linear-gradient(90deg, var(--spotpatch-accent), var(--spotpatch-accent-cyan));
|
|
645
|
+
transition: width 180ms ease;
|
|
612
646
|
}
|
|
613
647
|
.spotpatch-target-list {
|
|
614
648
|
display: grid;
|
|
615
|
-
gap:
|
|
616
|
-
max-height: min(
|
|
649
|
+
gap: 8px;
|
|
650
|
+
max-height: min(340px, 48vh);
|
|
617
651
|
overflow: auto;
|
|
618
652
|
padding-right: 2px;
|
|
619
653
|
}
|
|
@@ -621,30 +655,30 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
621
655
|
overflow: hidden;
|
|
622
656
|
border: 1px solid var(--spotpatch-border-subtle);
|
|
623
657
|
border-radius: var(--spotpatch-radius-card);
|
|
624
|
-
background:
|
|
658
|
+
background: var(--spotpatch-bg-raised);
|
|
625
659
|
transition: border-color 150ms ease, background 150ms ease;
|
|
626
660
|
}
|
|
627
661
|
.spotpatch-target-item[data-active="true"] {
|
|
628
|
-
border-color: rgb(
|
|
629
|
-
background:
|
|
630
|
-
box-shadow:
|
|
662
|
+
border-color: rgb(139 123 255 / 34%);
|
|
663
|
+
background: var(--spotpatch-bg-active);
|
|
664
|
+
box-shadow: 0 0 0 3px rgb(139 123 255 / 10%);
|
|
631
665
|
}
|
|
632
666
|
.spotpatch-target-summary {
|
|
633
667
|
display: grid;
|
|
634
|
-
grid-template-columns: minmax(0, 1fr)
|
|
668
|
+
grid-template-columns: minmax(0, 1fr) 28px 28px;
|
|
635
669
|
align-items: stretch;
|
|
636
|
-
gap:
|
|
637
|
-
padding:
|
|
670
|
+
gap: 2px;
|
|
671
|
+
padding: 4px;
|
|
638
672
|
}
|
|
639
673
|
.spotpatch-target-select {
|
|
640
674
|
display: grid;
|
|
641
|
-
grid-template-columns:
|
|
675
|
+
grid-template-columns: 24px minmax(0, 1fr) auto;
|
|
642
676
|
align-items: center;
|
|
643
|
-
gap:
|
|
677
|
+
gap: 9px;
|
|
644
678
|
min-width: 0;
|
|
645
679
|
border: 0;
|
|
646
|
-
border-radius:
|
|
647
|
-
padding:
|
|
680
|
+
border-radius: 8px;
|
|
681
|
+
padding: 8px;
|
|
648
682
|
color: inherit;
|
|
649
683
|
background: transparent;
|
|
650
684
|
cursor: pointer;
|
|
@@ -653,14 +687,14 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
653
687
|
.spotpatch-target-select:hover { background: rgb(255 255 255 / 3.5%); }
|
|
654
688
|
.spotpatch-target-index {
|
|
655
689
|
display: inline-grid;
|
|
656
|
-
width:
|
|
657
|
-
height:
|
|
690
|
+
width: 22px;
|
|
691
|
+
height: 22px;
|
|
658
692
|
place-items: center;
|
|
659
693
|
border: 1px solid rgb(68 202 224 / 25%);
|
|
660
|
-
border-radius:
|
|
661
|
-
color:
|
|
662
|
-
background:
|
|
663
|
-
font:
|
|
694
|
+
border-radius: 6px;
|
|
695
|
+
color: var(--spotpatch-text-secondary);
|
|
696
|
+
background: var(--spotpatch-bg);
|
|
697
|
+
font: 650 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
664
698
|
}
|
|
665
699
|
.spotpatch-target-copy { min-width: 0; }
|
|
666
700
|
.spotpatch-target-name,
|
|
@@ -670,14 +704,14 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
670
704
|
text-overflow: ellipsis;
|
|
671
705
|
white-space: nowrap;
|
|
672
706
|
}
|
|
673
|
-
.spotpatch-target-name { color: #
|
|
674
|
-
.spotpatch-target-source { margin-top:
|
|
707
|
+
.spotpatch-target-name { color: #f2f2f5; font-size: 13px; font-weight: 650; }
|
|
708
|
+
.spotpatch-target-source { margin-top: 1px; color: var(--spotpatch-text-muted); font: 500 10.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
675
709
|
.spotpatch-target-state {
|
|
676
710
|
border-radius: 999px;
|
|
677
|
-
padding:
|
|
711
|
+
padding: 3px 8px;
|
|
678
712
|
color: #a7f3d0;
|
|
679
713
|
background: rgb(16 185 129 / 9%);
|
|
680
|
-
font-size:
|
|
714
|
+
font-size: 10.5px;
|
|
681
715
|
font-weight: 650;
|
|
682
716
|
white-space: nowrap;
|
|
683
717
|
}
|
|
@@ -685,13 +719,13 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
685
719
|
.spotpatch-target-open,
|
|
686
720
|
.spotpatch-target-remove {
|
|
687
721
|
display: inline-grid;
|
|
688
|
-
width:
|
|
722
|
+
width: 28px;
|
|
689
723
|
height: 100%;
|
|
690
|
-
min-height:
|
|
724
|
+
min-height: 34px;
|
|
691
725
|
padding: 0;
|
|
692
726
|
place-items: center;
|
|
693
727
|
border: 1px solid transparent;
|
|
694
|
-
border-radius:
|
|
728
|
+
border-radius: 7px;
|
|
695
729
|
color: #7f899a;
|
|
696
730
|
background: transparent;
|
|
697
731
|
cursor: pointer;
|
|
@@ -700,31 +734,30 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
700
734
|
.spotpatch-target-open:hover:not(:disabled) { border-color: rgb(68 202 224 / 30%); color: #c8f7ff; background: rgb(8 145 178 / 11%); }
|
|
701
735
|
.spotpatch-target-remove:hover:not(:disabled) { border-color: rgb(251 113 133 / 24%); color: #fda4af; background: rgb(127 29 29 / 12%); }
|
|
702
736
|
.spotpatch-target-editor {
|
|
703
|
-
|
|
704
|
-
padding: 18px;
|
|
737
|
+
padding: 0 12px 12px;
|
|
705
738
|
}
|
|
706
739
|
.spotpatch-target-editor-head {
|
|
707
740
|
display: flex;
|
|
708
741
|
align-items: baseline;
|
|
709
742
|
justify-content: space-between;
|
|
710
743
|
gap: 12px;
|
|
711
|
-
margin-bottom:
|
|
744
|
+
margin-bottom: 6px;
|
|
712
745
|
}
|
|
713
|
-
.spotpatch-target-editor-label { color:
|
|
714
|
-
.spotpatch-target-editor-count { color: var(--spotpatch-text-muted); font: 500
|
|
746
|
+
.spotpatch-target-editor-label { color: var(--spotpatch-text-secondary); font-size: 11px; font-weight: 650; }
|
|
747
|
+
.spotpatch-target-editor-count { color: var(--spotpatch-text-muted); font: 500 10.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
715
748
|
.spotpatch-target-editor textarea {
|
|
716
749
|
box-sizing: border-box;
|
|
717
750
|
width: 100%;
|
|
718
|
-
min-height:
|
|
751
|
+
min-height: 74px;
|
|
719
752
|
resize: vertical;
|
|
720
753
|
border: 1px solid var(--spotpatch-border);
|
|
721
|
-
border-radius:
|
|
722
|
-
padding:
|
|
754
|
+
border-radius: 7px;
|
|
755
|
+
padding: 9px 10px;
|
|
723
756
|
color: #f8fafc;
|
|
724
757
|
caret-color: #8b7cf7;
|
|
725
758
|
background: var(--spotpatch-bg-input);
|
|
726
|
-
font-size:
|
|
727
|
-
line-height: 1.
|
|
759
|
+
font-size: 12.5px;
|
|
760
|
+
line-height: 1.55;
|
|
728
761
|
outline: none;
|
|
729
762
|
transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
|
|
730
763
|
}
|
|
@@ -733,23 +766,23 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
733
766
|
.spotpatch-target-editor textarea:focus {
|
|
734
767
|
border-color: rgb(139 124 247 / 68%);
|
|
735
768
|
background: rgb(3 7 18 / 65%);
|
|
736
|
-
box-shadow: 0 0 0
|
|
769
|
+
box-shadow: 0 0 0 2px rgb(109 93 246 / 10%);
|
|
737
770
|
}
|
|
738
771
|
.spotpatch-diagnostics {
|
|
739
|
-
margin-top:
|
|
772
|
+
margin-top: 10px;
|
|
740
773
|
overflow: hidden;
|
|
741
774
|
border: 1px solid rgb(255 255 255 / 8%);
|
|
742
|
-
border-radius:
|
|
775
|
+
border-radius: 9px;
|
|
743
776
|
background: rgb(255 255 255 / 2.5%);
|
|
744
777
|
}
|
|
745
778
|
.spotpatch-diagnostics > summary {
|
|
746
779
|
display: flex;
|
|
747
780
|
align-items: center;
|
|
748
781
|
gap: 8px;
|
|
749
|
-
padding: 11px
|
|
782
|
+
padding: 9px 11px;
|
|
750
783
|
color: #bfc5d0;
|
|
751
784
|
cursor: pointer;
|
|
752
|
-
font-size:
|
|
785
|
+
font-size: 11px;
|
|
753
786
|
font-weight: 650;
|
|
754
787
|
list-style: none;
|
|
755
788
|
user-select: none;
|
|
@@ -778,9 +811,9 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
778
811
|
margin: 0;
|
|
779
812
|
overflow: auto;
|
|
780
813
|
border-top: 1px solid rgb(255 255 255 / 7%);
|
|
781
|
-
padding:
|
|
814
|
+
padding: 10px 11px 11px;
|
|
782
815
|
color: #9ca5b5;
|
|
783
|
-
font:
|
|
816
|
+
font: 10.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
784
817
|
overflow-wrap: anywhere;
|
|
785
818
|
white-space: pre-wrap;
|
|
786
819
|
user-select: text;
|
|
@@ -790,39 +823,44 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
790
823
|
margin: 0;
|
|
791
824
|
overflow: auto;
|
|
792
825
|
border: 1px solid rgb(255 255 255 / 9%);
|
|
793
|
-
border-radius:
|
|
794
|
-
padding:
|
|
826
|
+
border-radius: 9px;
|
|
827
|
+
padding: 11px;
|
|
795
828
|
color: #d8ddeb;
|
|
796
829
|
background: rgb(3 7 18 / 55%);
|
|
797
|
-
font:
|
|
830
|
+
font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
798
831
|
overflow-wrap: anywhere;
|
|
799
832
|
white-space: pre-wrap;
|
|
800
833
|
user-select: text;
|
|
801
834
|
}
|
|
802
835
|
.spotpatch-actions {
|
|
803
|
-
display:
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
padding: 14px 22px 18px;
|
|
836
|
+
display: grid;
|
|
837
|
+
gap: 8px;
|
|
838
|
+
padding: 10px 18px 14px;
|
|
807
839
|
border-top: 1px solid rgb(255 255 255 / 8%);
|
|
808
|
-
background: rgb(8 12
|
|
840
|
+
background: rgb(8 8 12 / 86%);
|
|
809
841
|
}
|
|
810
842
|
.spotpatch-editor-feedback {
|
|
811
|
-
flex-basis: 100%;
|
|
812
843
|
white-space: normal;
|
|
813
844
|
}
|
|
845
|
+
.spotpatch-secondary-actions,
|
|
846
|
+
.spotpatch-primary-actions {
|
|
847
|
+
display: flex;
|
|
848
|
+
align-items: center;
|
|
849
|
+
gap: 7px;
|
|
850
|
+
}
|
|
851
|
+
.spotpatch-secondary-actions { min-height: 30px; }
|
|
814
852
|
.spotpatch-actions button {
|
|
815
853
|
display: inline-flex;
|
|
816
|
-
min-height:
|
|
854
|
+
min-height: 34px;
|
|
817
855
|
align-items: center;
|
|
818
856
|
justify-content: center;
|
|
819
857
|
border: 1px solid rgb(255 255 255 / 10%);
|
|
820
|
-
border-radius:
|
|
821
|
-
padding:
|
|
822
|
-
color:
|
|
858
|
+
border-radius: 9px;
|
|
859
|
+
padding: 7px 11px;
|
|
860
|
+
color: var(--spotpatch-text-secondary);
|
|
823
861
|
background: rgb(255 255 255 / 4%);
|
|
824
862
|
cursor: pointer;
|
|
825
|
-
font-size:
|
|
863
|
+
font-size: 12px;
|
|
826
864
|
font-weight: 650;
|
|
827
865
|
transition: border-color 150ms ease, box-shadow 150ms ease, color 150ms ease, transform 150ms ease;
|
|
828
866
|
}
|
|
@@ -832,14 +870,36 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
832
870
|
transform: translateY(-1px);
|
|
833
871
|
}
|
|
834
872
|
.spotpatch-actions .spotpatch-primary {
|
|
835
|
-
min-width:
|
|
873
|
+
min-width: 138px;
|
|
836
874
|
flex: 1;
|
|
837
|
-
border-color:
|
|
838
|
-
color:
|
|
839
|
-
background: var(--spotpatch-accent-strong);
|
|
840
|
-
box-shadow: 0
|
|
875
|
+
border-color: transparent;
|
|
876
|
+
color: var(--spotpatch-text-on-accent);
|
|
877
|
+
background: linear-gradient(135deg, var(--spotpatch-accent), var(--spotpatch-accent-strong));
|
|
878
|
+
box-shadow: 0 8px 20px -8px rgb(139 123 255 / 55%);
|
|
841
879
|
}
|
|
880
|
+
.spotpatch-actions .spotpatch-primary:hover:not(:disabled) { color: var(--spotpatch-text-on-accent); filter: brightness(1.08); }
|
|
842
881
|
.spotpatch-actions .spotpatch-primary::after { margin-left: 8px; content: "↗"; font-size: 12px; }
|
|
882
|
+
.spotpatch-actions .spotpatch-secondary-action {
|
|
883
|
+
min-height: 30px;
|
|
884
|
+
border-style: dashed;
|
|
885
|
+
padding: 5px 10px;
|
|
886
|
+
color: var(--spotpatch-text-muted);
|
|
887
|
+
background: transparent;
|
|
888
|
+
font-size: 11px;
|
|
889
|
+
}
|
|
890
|
+
.spotpatch-actions .spotpatch-icon-action {
|
|
891
|
+
width: 34px;
|
|
892
|
+
min-width: 34px;
|
|
893
|
+
padding: 0;
|
|
894
|
+
font-size: 0;
|
|
895
|
+
}
|
|
896
|
+
.spotpatch-actions .spotpatch-icon-action::before {
|
|
897
|
+
color: var(--spotpatch-text-secondary);
|
|
898
|
+
content: attr(data-compact-icon);
|
|
899
|
+
font-size: 18px;
|
|
900
|
+
font-weight: 400;
|
|
901
|
+
line-height: 1;
|
|
902
|
+
}
|
|
843
903
|
.spotpatch-actions button:disabled { cursor: not-allowed; opacity: .4; transform: none; }
|
|
844
904
|
.spotpatch-actions button:focus-visible,
|
|
845
905
|
.spotpatch-repository:focus-visible,
|
|
@@ -871,16 +931,18 @@ ${At(e.code.language,H(t.codeLines.join(`
|
|
|
871
931
|
}
|
|
872
932
|
@media (max-width: 520px) {
|
|
873
933
|
.spotpatch-dialog { top: 8px; left: 8px; width: calc(100vw - 16px); }
|
|
874
|
-
.spotpatch-shell { max-height: calc(100vh - 16px); border-radius:
|
|
875
|
-
.spotpatch-header, .spotpatch-body { padding-left:
|
|
876
|
-
.spotpatch-
|
|
877
|
-
.spotpatch-
|
|
934
|
+
.spotpatch-shell { max-height: calc(100vh - 16px); border-radius: 14px; }
|
|
935
|
+
.spotpatch-header, .spotpatch-body { padding-left: 14px; padding-right: 14px; }
|
|
936
|
+
.spotpatch-brand-row { margin-right: -14px; margin-left: -14px; padding-right: 14px; padding-left: 14px; }
|
|
937
|
+
.spotpatch-actions { padding-right: 14px; padding-left: 14px; }
|
|
938
|
+
.spotpatch-target-select { grid-template-columns: 24px minmax(0, 1fr); }
|
|
878
939
|
.spotpatch-target-state { display: none; }
|
|
940
|
+
.spotpatch-repository { display: none; }
|
|
879
941
|
}
|
|
880
|
-
${
|
|
881
|
-
`,t}function
|
|
882
|
-
`).find(n=>n.startsWith(`${t}: `))?.slice(t.length+2).trim()}function Yn(e,t,o=Object.freeze({enabled:!1}),n="auto"){let s=Kn(e,n),r=s.messages(),i=e.createElement("spotpatch-root");i.setAttribute(ot,"");let l=i.attachShadow({mode:"open"}),E=J(e,r.trigger.select,"spotpatch-trigger");E.title=r.trigger.title(t),E.setAttribute("aria-pressed","false");let A=d(e,"div");A.className="spotpatch-highlight",A.hidden=!0;let R=d(e,"span");R.className="spotpatch-highlight-label",A.append(R);let k=d(e,"div");k.className="spotpatch-selection-highlights",k.setAttribute("aria-hidden","true");let u=d(e,"section");u.className="spotpatch-dialog",u.hidden=!0,u.tabIndex=-1,u.dataset.placement="viewport",u.setAttribute("role","dialog"),u.setAttribute("aria-labelledby","spotpatch-selection-title");let P=d(e,"span");P.className="spotpatch-anchor",P.setAttribute("aria-hidden","true");let Z=d(e,"div");Z.className="spotpatch-shell";let I=d(e,"header");I.className="spotpatch-header";let b=d(e,"div");b.className="spotpatch-brand-row";let x=d(e,"div");x.className="spotpatch-brand";let Q=d(e,"span");Q.className="spotpatch-brand-copy";let q=d(e,"span");q.className="spotpatch-brand-name";let f=d(e,"span");f.className="spotpatch-brand-context",Q.append(q,f),x.append(Jn(e),Q);let y=d(e,"span");y.className="spotpatch-header-controls";let C=d(e,"a");C.className="spotpatch-repository",C.href=jt,C.target="_blank",C.rel="noopener noreferrer";let v=J(e,"","spotpatch-locale"),D=J(e,"×","spotpatch-close");y.append(C,v,D),b.append(x,y);let G=d(e,"h2");G.id="spotpatch-selection-title",G.className="spotpatch-title";let $=d(e,"p");$.className="spotpatch-subtitle";let de=d(e,"div");de.className="spotpatch-target-row";let oe=d(e,"span");oe.className="spotpatch-target-label";let B=d(e,"span");B.className="spotpatch-context-state",B.dataset.state="loading",B.textContent=r.context.collecting,de.append(oe,B),I.append(b,G,$,de);let L=d(e,"div");L.className="spotpatch-body";let Pe=d(e,"div");Pe.className="spotpatch-selection-panel";let he=d(e,"section");he.className="spotpatch-targets";let F=d(e,"div");F.className="spotpatch-targets-heading";let Ce=d(e,"span"),Re=d(e,"span");Re.className="spotpatch-targets-meta";let me=d(e,"span");me.className="spotpatch-target-complete";let ee=d(e,"span");ee.className="spotpatch-target-budget",ee.setAttribute("aria-live","polite");let N=d(e,"span");N.className="spotpatch-target-count",Re.append(me,ee),F.append(Ce,N);let K=d(e,"div");K.className="spotpatch-target-list",he.append(F,Re,K);let be=d(e,"details");be.className="spotpatch-diagnostics";let Le=d(e,"summary"),ve=d(e,"span"),ye=d(e,"span");ye.className="spotpatch-source-peek",ye.textContent=r.diagnostics.resolving,Le.append(ve,ye);let re=d(e,"pre");re.className="spotpatch-summary",be.append(Le,re);let _=Vn(e,o,s);Pe.append(he,be,_.root);let ke=d(e,"div");ke.className="spotpatch-preview-panel",ke.hidden=!0;let Se=d(e,"pre");Se.className="spotpatch-prompt",Se.tabIndex=0,Se.setAttribute("aria-label",r.diagnostics.promptAriaLabel),ke.append(Se),L.append(Pe,ke);let Me=d(e,"footer");Me.className="spotpatch-actions";let Y=d(e,"div");Y.className="spotpatch-context-state spotpatch-editor-feedback",Y.dataset.state="idle",Y.setAttribute("role","status"),Y.setAttribute("aria-live","polite"),Y.hidden=!0;let T=J(e,r.actions.addElement),Te=J(e,r.actions.reselect),le=J(e,r.actions.openEditor),ae=J(e,r.actions.preview,"spotpatch-primary"),De=J(e,r.actions.copy,"spotpatch-primary"),$e=J(e,r.actions.back);Me.append(Y,_.runButton,ae,_.testButton,_.cancelButton,_.applyButton,_.revertButton,_.resetButton,T,le,Te,De,$e),Z.append(I,L,Me),u.append(P,Z);let Ae=d(e,"div");Ae.className="spotpatch-live",Ae.setAttribute("aria-live","polite"),Ae.setAttribute("aria-atomic","true"),l.append(Yr(e),k,A,u,E,Ae),e.documentElement.append(i);let ie,we,Oe="idle",V=!1,ze=!1,Ie="",xe=!0,pe=[],U=0,qe="idle";function Ue(p){qe=p,Y.dataset.state=p,Y.hidden=p==="idle",Y.textContent=p==="opening"?r.announcements.editorOpening:p==="success"?r.announcements.editorOpened:p==="error"?r.announcements.editorFailed:"",a()}function rt(p){return p.status==="ready"?r.targets.statusReady:p.status==="warning"?r.targets.statusPartial:r.targets.statusCollecting}function Fe(p){let S=K.querySelectorAll("textarea[data-target-instruction-id]");return Array.from(S).find(O=>p===void 0||O.dataset.targetInstructionId===p)}function Ke(p,S){let O=l.activeElement?.closest("textarea[data-target-instruction-id]"),j=O?.dataset.targetInstructionId,ue=O?.selectionStart,je=O?.selectionEnd;pe=p.map(se=>Object.freeze({...se})),U=S,K.replaceChildren();let Ge=p.filter(se=>se.instruction.trim().length>0).length,ge=p.reduce((se,W)=>se+W.instruction.trim().length,0);N.textContent=r.targets.count(p.length,S),me.textContent=r.targets.complete(Ge,p.length);let _e=ge>4e3;ee.dataset.state=_e?"over":"ready",ee.textContent=_e?r.targets.instructionBudgetExceeded(ge,4e3):r.targets.instructionBudget(ge,4e3),T.disabled=!xe||p.length>=S,T.title=p.length>=S?r.targets.limitTitle(S):r.targets.addTitle,oe.textContent=p.length===1?p[0]?.label??r.context.selectedElement:r.context.selectedCount(p.length);for(let[se,W]of p.entries()){let tt=d(e,"div");tt.className="spotpatch-target-item",tt.dataset.active=String(W.active),tt.dataset.status=W.status,tt.dataset.targetId=W.id;let Rt=d(e,"div");Rt.className="spotpatch-target-summary";let ct=J(e,"","spotpatch-target-select");ct.dataset.activateTargetId=W.id,ct.setAttribute("aria-label",r.targets.activate(se+1)),ct.setAttribute("aria-expanded",String(W.active));let vt=d(e,"span");vt.className="spotpatch-target-index",vt.textContent=String(se+1);let Tt=d(e,"span");Tt.className="spotpatch-target-copy";let wt=d(e,"span");wt.className="spotpatch-target-name",wt.textContent=W.label;let Ot=d(e,"span");Ot.className="spotpatch-target-source",Ot.textContent=`${rt(W)} · ${W.source}`,Tt.append(wt,Ot);let Yt=W.instruction.trim().length>0,mt=d(e,"span");mt.className="spotpatch-target-state",mt.dataset.complete=String(Yt),mt.textContent=Yt?r.targets.instructionReady:r.targets.instructionMissing,ct.append(vt,Tt,mt);let dt=J(e,"↗","spotpatch-target-open");dt.dataset.openTargetId=W.id,dt.disabled=!W.canOpenEditor,dt.setAttribute("aria-label",r.actions.openTarget(se+1)),dt.title=r.actions.openTarget(se+1);let lt=J(e,"×","spotpatch-target-remove");if(lt.dataset.removeTargetId=W.id,lt.disabled=!xe,lt.setAttribute("aria-label",r.targets.remove(se+1)),lt.title=r.targets.removeTitle,Rt.append(ct,dt,lt),tt.append(Rt),W.active){let _t=d(e,"label");_t.className="spotpatch-target-editor";let Pt=d(e,"span");Pt.className="spotpatch-target-editor-head";let Lt=d(e,"span");Lt.className="spotpatch-target-editor-label",Lt.textContent=r.targets.instructionLabel(W.label);let kt=d(e,"span");kt.className="spotpatch-target-editor-count",kt.textContent=r.targets.instructionCount(W.instruction.length,2e3),Pt.append(Lt,kt);let Ye=d(e,"textarea");Ye.rows=4,Ye.maxLength=2e3,Ye.value=W.instruction,Ye.placeholder=r.targets.instructionPlaceholder,Ye.disabled=!xe,Ye.dataset.targetInstructionId=W.id,Ye.setAttribute("aria-label",r.targets.instructionLabel(W.label)),_t.append(Pt,Ye),tt.append(_t)}K.append(tt)}if(j!==void 0){let se=Fe(j);se?.focus({preventScroll:!0}),ue!==void 0&&je!==void 0&&se?.setSelectionRange(ue,je)}}function st(p,S){pe=pe.map(_e=>_e.id===p?Object.freeze({..._e,instruction:S}):_e);let O=Array.from(K.querySelectorAll(".spotpatch-target-item")).find(_e=>_e.dataset.targetId===p);if(O===void 0)return;let j=S.trim().length>0,ue=O.querySelector(".spotpatch-target-state"),je=O.querySelector(".spotpatch-target-editor-count");ue!==null&&(ue.dataset.complete=String(j),ue.textContent=j?r.targets.instructionReady:r.targets.instructionMissing),je!==null&&(je.textContent=r.targets.instructionCount(S.length,2e3)),me.textContent=r.targets.complete(pe.filter(_e=>_e.instruction.trim().length>0).length,pe.length);let Ge=pe.reduce((_e,se)=>_e+se.instruction.trim().length,0),ge=Ge>4e3;ee.dataset.state=ge?"over":"ready",ee.textContent=ge?r.targets.instructionBudgetExceeded(Ge,4e3):r.targets.instructionBudget(Ge,4e3)}function m(p){k.replaceChildren(),we=p.find(S=>S.active)?.rect,ie=we;for(let[S,O]of p.entries()){let j=d(e,"div");j.className="spotpatch-selection-highlight",j.dataset.targetId=O.id,j.dataset.active=String(O.active),j.style.transform=`translate(${String(O.rect.x)}px, ${String(O.rect.y)}px)`,j.style.width=`${String(O.rect.width)}px`,j.style.height=`${String(O.rect.height)}px`;let ue=d(e,"span");ue.textContent=`${String(S+1)} · ${O.label}`,j.append(ue),k.append(j)}a()}function a(){if(u.hidden||ie===void 0)return;let p=e.defaultView,S=p?.innerWidth??e.documentElement.clientWidth,O=p?.innerHeight??e.documentElement.clientHeight,j=u.getBoundingClientRect(),ue=Oe==="previewing"?"previewing":"selected",je=j.width>0?j.width:Math.min(Fr,S-32),Ge=j.height>0?j.height:Math.min(Kr[ue],O-32),ge=qn({target:ie,dialogWidth:je,dialogHeight:Ge,viewportWidth:S,viewportHeight:O});u.style.left=`${String(ge.left)}px`,u.style.top=`${String(ge.top)}px`,u.style.setProperty("--spotpatch-anchor-x",`${String(ge.anchorX)}px`),u.style.setProperty("--spotpatch-anchor-y",`${String(ge.anchorY)}px`),u.dataset.placement=ge.mode}function c(p){let S=r.summary,O=Xr(p,S.source);ye.textContent=O??r.diagnostics.noExactSource;let j=`${S.browserContext}: ${S.collectionStatuses.ready}`,ue=`${S.browserContext}: ${S.collectionStatuses.loading}`,je=`${S.browserContext}: ${S.collectionStatuses.failed}`,Ge=`${S.api}: ${S.apiStatuses.loading}`,ge=`${S.api}: ${S.apiStatuses.failed}`;p.includes(j)&&!p.includes(ue)&&!p.includes(Ge)&&!p.includes(je)&&!p.includes(ge)?(B.dataset.state="ready",B.textContent=r.context.ready):p.includes(je)||p.includes(ge)?(B.dataset.state="warning",B.textContent=r.context.partial):(B.dataset.state="loading",B.textContent=r.context.collecting)}function h(p,S,O){V=S,ze=O,Ie=p,re.textContent=p,le.disabled=!S,ae.disabled=!O,_.setContextReady(O),c(p),a()}function w(p){Oe=p;let S=p==="selected",O=p==="previewing";E.hidden=S||O,Pe.hidden=!S,ke.hidden=!O,Te.hidden=!S,T.hidden=!S,le.hidden=!S,ae.hidden=!S,_.setSelectionVisible(S),De.hidden=!O,$e.hidden=!O,G.textContent=O?r.dialog.previewTitle:r.dialog.editTitle,$.textContent=O?r.dialog.previewSubtitle:r.dialog.editSubtitle,a()}function z(){r=s.messages(),q.textContent=r.brand.name,f.textContent=r.brand.context,C.textContent=r.brand.repository,C.title=r.brand.repositoryTitle,C.setAttribute("aria-label",r.brand.repositoryTitle),v.textContent=r.alternateLocaleName,v.title=r.switchLocale,v.setAttribute("aria-label",r.switchLocale),D.setAttribute("aria-label",r.dialog.close),D.title=r.dialog.close,he.setAttribute("aria-label",r.targets.ariaLabel),Ce.textContent=r.targets.title,ve.textContent=r.diagnostics.title,Se.setAttribute("aria-label",r.diagnostics.promptAriaLabel),T.textContent=r.actions.addElement,Te.textContent=r.actions.reselect,le.textContent=r.actions.openEditor,ae.textContent=r.actions.preview,De.textContent=r.actions.copy,$e.textContent=r.actions.back,E.title=r.trigger.title(t),E.textContent=Oe==="inspecting"?r.trigger.stop:r.trigger.select,w(Oe),Ue(qe),pe.length>0?Ke(pe,U):(N.textContent=r.targets.count(0,U),me.textContent=r.targets.complete(0,0),ee.dataset.state="ready",ee.textContent=r.targets.instructionBudget(0,4e3),oe.textContent=r.context.selectedElement),Ie.length>0?c(Ie):(ye.textContent=r.diagnostics.resolving,B.textContent=r.context.collecting)}be.addEventListener("toggle",a),v.addEventListener("click",s.toggle);let te=s.subscribe(z);return z(),Object.freeze({host:i,triggerButton:E,addTargetButton:T,targetList:K,reselectButton:Te,openEditorButton:le,repositoryLink:C,previewButton:ae,copyButton:De,backButton:$e,closeButton:D,agentProviderSelect:_.providerSelect,agentModelSelect:_.modelSelect,agentConsentCheckbox:_.consentCheckbox,agentWorkspaceConsentCheckbox:_.workspaceConsentCheckbox,agentTestButton:_.testButton,agentRunButton:_.runButton,agentCancelButton:_.cancelButton,agentApplyButton:_.applyButton,agentRevertButton:_.revertButton,agentResetButton:_.resetButton,renderStatus(p){let S=p==="inspecting";E.setAttribute("aria-pressed",String(S)),E.textContent=S?r.trigger.stop:r.trigger.select,w(p)},renderEditorStatus:Ue,showHighlight(p,S){ie=p,A.hidden=!1,A.style.transform=`translate(${String(p.x)}px, ${String(p.y)}px)`,A.style.width=`${String(p.width)}px`,A.style.height=`${String(p.height)}px`,R.textContent=S,oe.textContent=S,a()},hideHighlight(){ie=we,A.hidden=!0,R.textContent="",a()},showSelectionHighlights:m,hideSelectionHighlights(){k.replaceChildren(),we=void 0,ie=void 0},showSelection(p,S,O){h(p,S,O),E.hidden=!0,u.hidden=!1,a()},updateSelection:h,renderTargets:Ke,updateTargetInstruction:st,setPreviewEnabled(p){ze=p,ae.disabled=!p,_.setContextReady(p)},hideSelection(){u.hidden=!0,E.hidden=!1,K.replaceChildren(),pe=[],U=0,Ie="",Ue("idle"),N.textContent=r.targets.count(0,0),me.textContent=r.targets.complete(0,0),oe.textContent=r.context.selectedElement,re.textContent="",Se.textContent="",ye.textContent=r.diagnostics.resolving,B.dataset.state="loading",B.textContent=r.context.collecting,le.disabled=!0,ae.disabled=!0,V=!1,ze=!1,_.setContextReady(!1),_.setSelectionVisible(!1),_.setEditingEnabled(!0),_.resetJob()},hideSelectionTemporarily(){u.hidden=!0,E.hidden=!1},showPreview(p){Se.textContent=p,a()},readAgentSelection(){return _.readSelection()},agentConsentGranted(){return _.consentGranted()},setAgentProviderConsent(p){_.setProviderConsent(p)},setAgentEditingEnabled(p){xe=p,T.disabled=!p,Te.disabled=!p,K.querySelectorAll(".spotpatch-target-remove, .spotpatch-target-select, textarea[data-target-instruction-id]").forEach(S=>{S.disabled=!p}),le.disabled=!V,ae.disabled=!p||!ze,_.setEditingEnabled(p),a()},renderAgentCapability(p,S,O,j){_.renderCapability(p,S,O,j);let ue=p==="ready"&&O?.state==="agent-ready";ae.classList.toggle("spotpatch-primary",!ue),a()},renderAgentWorkspaceHealth(p,S,O){_.renderWorkspaceHealth(p,S,O),a()},renderAgentJob(p,S,O,j){_.renderJob(p,S,O,j),a()},resetAgentJob(){_.resetJob(),a()},focusTargetInstruction(p){Fe(p)?.focus({preventScroll:!0})},focusPrompt(){Se.focus({preventScroll:!0})},announce(p){Ae.textContent="",Ae.textContent=p},locale:s.locale,messages:s.messages,agentWorkspaceConsentGranted:_.workspaceConsentGranted,subscribeLocale:s.subscribe,dispose(){be.removeEventListener("toggle",a),v.removeEventListener("click",s.toggle),te(),_.dispose(),i.remove()}})}function Zr(e,t,o){let n=t?.relativePath??e.source.relativePath,s=e.source.line,r=e.source.column;return n!==void 0&&s!==void 0?`${n}:${String(s)}${r===void 0?"":`:${String(r)}`}`:n!==void 0?n:s!==void 0?o.lineLocation(s,r):o.unavailable}function Xn(e,t){let o=[`SpotPatch: ${e.spotPatchVersion}`,`${e.framework==="next"?"Next.js":"Vite"}: ${e.frameworkVersion}`,`${t.source}: ${Zr(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(`
|
|
883
|
-
`)}function
|
|
884
|
-
${
|
|
942
|
+
${Kn}
|
|
943
|
+
`,t}function aa(e,t){return e.split(`
|
|
944
|
+
`).find(n=>n.startsWith(`${t}: `))?.slice(t.length+2).trim()}function ro(e,t,o=Object.freeze({enabled:!1}),n="auto"){let s=to(e,n),r=s.messages(),a=e.createElement("spotpatch-root");a.setAttribute(it,"");let l=a.attachShadow({mode:"open"}),E=K(e,r.trigger.select,"spotpatch-trigger");E.title=r.trigger.title(t),E.setAttribute("aria-pressed","false");let A=d(e,"div");A.className="spotpatch-highlight",A.hidden=!0;let R=d(e,"span");R.className="spotpatch-highlight-label",A.append(R);let j=d(e,"div");j.className="spotpatch-selection-highlights",j.setAttribute("aria-hidden","true");let u=d(e,"section");u.className="spotpatch-dialog",u.hidden=!0,u.tabIndex=-1,u.dataset.placement="viewport",u.setAttribute("role","dialog"),u.setAttribute("aria-labelledby","spotpatch-selection-title");let L=d(e,"span");L.className="spotpatch-anchor",L.setAttribute("aria-hidden","true");let V=d(e,"div");V.className="spotpatch-shell";let P=d(e,"header");P.className="spotpatch-header";let b=d(e,"div");b.className="spotpatch-brand-row";let x=d(e,"div");x.className="spotpatch-brand";let Q=d(e,"span");Q.className="spotpatch-brand-copy";let Y=d(e,"span");Y.className="spotpatch-brand-name";let h=d(e,"span");h.className="spotpatch-brand-context",Q.append(Y,h),x.append(Zn(e),Q);let S=d(e,"span");S.className="spotpatch-header-controls";let C=d(e,"a");C.className="spotpatch-repository",C.href=Bt,C.target="_blank",C.rel="noopener noreferrer";let T=K(e,"","spotpatch-locale"),D=K(e,"×","spotpatch-close");S.append(C,T,D),b.append(x,S);let F=d(e,"h2");F.id="spotpatch-selection-title",F.className="spotpatch-title";let $=d(e,"p");$.className="spotpatch-subtitle";let ae=d(e,"div");ae.className="spotpatch-target-row";let ie=d(e,"span");ie.className="spotpatch-target-label";let B=d(e,"span");B.className="spotpatch-context-state",B.dataset.state="loading",B.textContent=r.context.collecting,ae.append(ie,B),P.append(b,F,$,ae);let k=d(e,"div");k.className="spotpatch-body";let Le=d(e,"div");Le.className="spotpatch-selection-panel";let he=d(e,"section");he.className="spotpatch-targets";let X=d(e,"div");X.className="spotpatch-targets-heading";let Re=d(e,"span"),ve=d(e,"span");ve.className="spotpatch-targets-meta";let me=d(e,"span");me.className="spotpatch-target-complete";let ee=d(e,"span");ee.className="spotpatch-target-budget",ee.setAttribute("aria-live","polite");let N=d(e,"span");N.className="spotpatch-target-count",ve.append(me,ee),ae.append(N),X.append(Re,ve);let be=d(e,"div");be.className="spotpatch-target-progress",be.setAttribute("aria-hidden","true");let Te=d(e,"div");Te.className="spotpatch-target-progress-fill",be.append(Te);let te=d(e,"div");te.className="spotpatch-target-list",he.append(X,be,te);let le=d(e,"details");le.className="spotpatch-diagnostics";let De=d(e,"summary"),ye=d(e,"span"),we=d(e,"span");we.className="spotpatch-source-peek",we.textContent=r.diagnostics.resolving,De.append(ye,we);let $e=d(e,"pre");$e.className="spotpatch-summary",le.append(De,$e);let w=Yn(e,o,s);Le.append(he,le,w.root);let Oe=d(e,"div");Oe.className="spotpatch-preview-panel",Oe.hidden=!0;let ne=d(e,"pre");ne.className="spotpatch-prompt",ne.tabIndex=0,ne.setAttribute("aria-label",r.diagnostics.promptAriaLabel),Oe.append(ne),k.append(Le,Oe);let _=d(e,"footer");_.className="spotpatch-actions";let se=d(e,"div");se.className="spotpatch-context-state spotpatch-editor-feedback",se.dataset.state="idle",se.setAttribute("role","status"),se.setAttribute("aria-live","polite"),se.hidden=!0;let oe=K(e,r.actions.addElement),Ce=K(e,r.actions.reselect),Se=K(e,r.actions.openEditor),pe=K(e,r.actions.preview,"spotpatch-primary"),Ie=K(e,r.actions.copy,"spotpatch-primary"),xe=K(e,r.actions.back),_e=d(e,"div");_e.className="spotpatch-secondary-actions";let ke=d(e,"div");ke.className="spotpatch-primary-actions",oe.classList.add("spotpatch-icon-action"),oe.dataset.compactIcon="+",w.testButton.classList.add("spotpatch-icon-action"),w.testButton.dataset.compactIcon="✓",Se.classList.add("spotpatch-secondary-action"),Ce.classList.add("spotpatch-secondary-action"),_e.append(Se,Ce),ke.append(w.testButton,oe,w.runButton,pe,w.cancelButton,w.applyButton,w.revertButton,w.resetButton,Ie,xe),_.append(se,_e,ke),V.append(P,k,_),u.append(L,V);let W=d(e,"div");W.className="spotpatch-live",W.setAttribute("aria-live","polite"),W.setAttribute("aria-atomic","true"),l.append(ra(e),j,A,u,E,W),e.documentElement.append(a);let Pe,Ne,Ee="idle",Ve=!1,J=!1,ze="",je=!0,ue=[],He=0,Ke="idle";function nt(p){Ke=p,se.dataset.state=p,se.hidden=p==="idle",se.textContent=p==="opening"?r.announcements.editorOpening:p==="success"?r.announcements.editorOpened:p==="error"?r.announcements.editorFailed:"",I()}function m(p){return p.status==="ready"?r.targets.statusReady:p.status==="warning"?r.targets.statusPartial:r.targets.statusCollecting}function i(p,y){let v=y===0?0:p/y;Te.style.width=`${String(v*100)}%`}function c(p){let y=te.querySelectorAll("textarea[data-target-instruction-id]");return Array.from(y).find(v=>p===void 0||v.dataset.targetInstructionId===p)}function g(p,y){let v=l.activeElement?.closest("textarea[data-target-instruction-id]"),H=v?.dataset.targetInstructionId,ge=v?.selectionStart,Be=v?.selectionEnd;ue=p.map(U=>Object.freeze({...U})),He=y,te.replaceChildren();let We=p.filter(U=>U.instruction.trim().length>0).length,ce=p.reduce((U,q)=>U+q.instruction.trim().length,0);i(We,p.length),N.textContent=r.targets.count(p.length,y),me.textContent=r.targets.complete(We,p.length);let dt=ce>4e3;ee.dataset.state=dt?"over":"ready",ee.textContent=dt?r.targets.instructionBudgetExceeded(ce,4e3):r.targets.instructionBudget(ce,4e3),oe.disabled=!je||p.length>=y,oe.title=p.length>=y?r.targets.limitTitle(y):r.targets.addTitle,ie.textContent=p.length===1?p[0]?.label??r.context.selectedElement:r.context.selectedCount(p.length);for(let[U,q]of p.entries()){let rt=d(e,"div");rt.className="spotpatch-target-item",rt.dataset.active=String(q.active),rt.dataset.status=q.status,rt.dataset.targetId=q.id;let Tt=d(e,"div");Tt.className="spotpatch-target-summary";let lt=K(e,"","spotpatch-target-select");lt.dataset.activateTargetId=q.id,lt.setAttribute("aria-label",r.targets.activate(U+1)),lt.setAttribute("aria-expanded",String(q.active));let wt=d(e,"span");wt.className="spotpatch-target-index",wt.textContent=String(U+1);let Ot=d(e,"span");Ot.className="spotpatch-target-copy";let _t=d(e,"span");_t.className="spotpatch-target-name",_t.textContent=q.label;let Pt=d(e,"span");Pt.className="spotpatch-target-source",Pt.textContent=`${m(q)} · ${q.source}`,Ot.append(_t,Pt);let en=q.instruction.trim().length>0,yt=d(e,"span");yt.className="spotpatch-target-state",yt.dataset.complete=String(en),yt.textContent=en?r.targets.instructionReady:r.targets.instructionMissing,lt.append(wt,Ot,yt);let pt=K(e,"↗","spotpatch-target-open");pt.dataset.openTargetId=q.id,pt.disabled=!q.canOpenEditor,pt.setAttribute("aria-label",r.actions.openTarget(U+1)),pt.title=r.actions.openTarget(U+1);let ut=K(e,"×","spotpatch-target-remove");if(ut.dataset.removeTargetId=q.id,ut.disabled=!je,ut.setAttribute("aria-label",r.targets.remove(U+1)),ut.title=r.targets.removeTitle,Tt.append(lt,pt,ut),rt.append(Tt),q.active){let Lt=d(e,"label");Lt.className="spotpatch-target-editor";let It=d(e,"span");It.className="spotpatch-target-editor-head";let kt=d(e,"span");kt.className="spotpatch-target-editor-label",kt.textContent=r.targets.instructionLabel(q.label);let Nt=d(e,"span");Nt.className="spotpatch-target-editor-count",Nt.textContent=r.targets.instructionCount(q.instruction.length,2e3),It.append(kt,Nt);let Ye=d(e,"textarea");Ye.rows=4,Ye.maxLength=2e3,Ye.value=q.instruction,Ye.placeholder=r.targets.instructionPlaceholder,Ye.disabled=!je,Ye.dataset.targetInstructionId=q.id,Ye.setAttribute("aria-label",r.targets.instructionLabel(q.label)),Lt.append(It,Ye),rt.append(Lt)}te.append(rt)}if(H!==void 0){let U=c(H);U?.focus({preventScroll:!0}),ge!==void 0&&Be!==void 0&&U?.setSelectionRange(ge,Be)}}function O(p,y){ue=ue.map(U=>U.id===p?Object.freeze({...U,instruction:y}):U);let v=Array.from(te.querySelectorAll(".spotpatch-target-item")).find(U=>U.dataset.targetId===p);if(v===void 0)return;let H=y.trim().length>0,ge=v.querySelector(".spotpatch-target-state"),Be=v.querySelector(".spotpatch-target-editor-count");ge!==null&&(ge.dataset.complete=String(H),ge.textContent=H?r.targets.instructionReady:r.targets.instructionMissing),Be!==null&&(Be.textContent=r.targets.instructionCount(y.length,2e3));let We=ue.filter(U=>U.instruction.trim().length>0).length;me.textContent=r.targets.complete(We,ue.length),i(We,ue.length);let ce=ue.reduce((U,q)=>U+q.instruction.trim().length,0),dt=ce>4e3;ee.dataset.state=dt?"over":"ready",ee.textContent=dt?r.targets.instructionBudgetExceeded(ce,4e3):r.targets.instructionBudget(ce,4e3)}function z(p){j.replaceChildren(),Ne=p.find(y=>y.active)?.rect,Pe=Ne;for(let[y,v]of p.entries()){let H=d(e,"div");H.className="spotpatch-selection-highlight",H.dataset.targetId=v.id,H.dataset.active=String(v.active),H.style.transform=`translate(${String(v.rect.x)}px, ${String(v.rect.y)}px)`,H.style.width=`${String(v.rect.width)}px`,H.style.height=`${String(v.rect.height)}px`;let ge=d(e,"span");ge.textContent=`${String(y+1)} · ${v.label}`,H.append(ge),j.append(H)}I()}function I(){if(u.hidden)return;let p=e.defaultView,y=p?.innerWidth??e.documentElement.clientWidth,v=p?.innerHeight??e.documentElement.clientHeight,H=u.getBoundingClientRect(),ge=Ee==="previewing"?"previewing":"selected",Be=H.width>0?H.width:Math.min(no,y-32),We=H.height>0?H.height:Math.min(oa[ge],v-32),ce=Qn({dialogWidth:Be,dialogHeight:We,viewportWidth:y,viewportHeight:v,...Pe===void 0?{}:{target:Pe}});u.style.left=`${String(ce.left)}px`,u.style.top=`${String(ce.top)}px`,u.style.setProperty("--spotpatch-anchor-x",`${String(ce.anchorX)}px`),u.style.setProperty("--spotpatch-anchor-y",`${String(ce.anchorY)}px`),u.dataset.placement=ce.mode}function ot(p){let y=r.summary,v=aa(p,y.source);we.textContent=v??r.diagnostics.noExactSource;let H=`${y.browserContext}: ${y.collectionStatuses.ready}`,ge=`${y.browserContext}: ${y.collectionStatuses.loading}`,Be=`${y.browserContext}: ${y.collectionStatuses.failed}`,We=`${y.api}: ${y.apiStatuses.loading}`,ce=`${y.api}: ${y.apiStatuses.failed}`;p.includes(H)&&!p.includes(ge)&&!p.includes(We)&&!p.includes(Be)&&!p.includes(ce)?(B.dataset.state="ready",B.textContent=r.context.ready):p.includes(Be)||p.includes(ce)?(B.dataset.state="warning",B.textContent=r.context.partial):(B.dataset.state="loading",B.textContent=r.context.collecting)}function Xt(p,y,v){Ve=y,J=v,ze=p,$e.textContent=p,Se.disabled=!y,pe.disabled=!v,w.setContextReady(v),ot(p),I()}function Zt(p){Ee=p;let y=p==="selected",v=p==="previewing";E.hidden=y||v,Le.hidden=!y,Oe.hidden=!v,Ce.hidden=!y,oe.hidden=!y,Se.hidden=!y,pe.hidden=!y,_e.hidden=!y,w.setSelectionVisible(y),Ie.hidden=!v,xe.hidden=!v,F.textContent=v?r.dialog.previewTitle:r.dialog.editTitle,$.textContent=v?r.dialog.previewSubtitle:r.dialog.editSubtitle,I()}function Qt(){r=s.messages(),Y.textContent=r.brand.name,h.textContent=r.brand.context,C.textContent=r.brand.repository,C.title=r.brand.repositoryTitle,C.setAttribute("aria-label",r.brand.repositoryTitle),T.textContent=r.alternateLocaleName,T.title=r.switchLocale,T.setAttribute("aria-label",r.switchLocale),D.setAttribute("aria-label",r.dialog.close),D.title=r.dialog.close,he.setAttribute("aria-label",r.targets.ariaLabel),Re.textContent=r.targets.title,ye.textContent=r.diagnostics.title,ne.setAttribute("aria-label",r.diagnostics.promptAriaLabel),oe.textContent=r.actions.addElement,Ce.textContent=r.actions.reselect,Se.textContent=r.actions.openEditor,pe.textContent=r.actions.preview,Ie.textContent=r.actions.copy,xe.textContent=r.actions.back,E.title=r.trigger.title(t),E.textContent=Ee==="inspecting"?r.trigger.stop:r.trigger.select,Zt(Ee),nt(Ke),ue.length>0?g(ue,He):(N.textContent=r.targets.count(0,He),me.textContent=r.targets.complete(0,0),i(0,0),ee.dataset.state="ready",ee.textContent=r.targets.instructionBudget(0,4e3),ie.textContent=r.context.selectedElement),ze.length>0?ot(ze):(we.textContent=r.diagnostics.resolving,B.textContent=r.context.collecting)}le.addEventListener("toggle",I),T.addEventListener("click",s.toggle);let go=s.subscribe(Qt);return Qt(),Object.freeze({host:a,triggerButton:E,addTargetButton:oe,targetList:te,reselectButton:Ce,openEditorButton:Se,repositoryLink:C,previewButton:pe,copyButton:Ie,backButton:xe,closeButton:D,agentProviderSelect:w.providerSelect,agentModelSelect:w.modelSelect,agentConsentCheckbox:w.consentCheckbox,agentWorkspaceConsentCheckbox:w.workspaceConsentCheckbox,agentTestButton:w.testButton,agentRunButton:w.runButton,agentCancelButton:w.cancelButton,agentApplyButton:w.applyButton,agentRevertButton:w.revertButton,agentResetButton:w.resetButton,renderStatus(p){let y=p==="inspecting";E.setAttribute("aria-pressed",String(y)),E.textContent=y?r.trigger.stop:r.trigger.select,Zt(p)},renderEditorStatus:nt,showHighlight(p,y){Pe=p,A.hidden=!1,A.style.transform=`translate(${String(p.x)}px, ${String(p.y)}px)`,A.style.width=`${String(p.width)}px`,A.style.height=`${String(p.height)}px`,R.textContent=y,ie.textContent=y,I()},hideHighlight(){Pe=Ne,A.hidden=!0,R.textContent="",I()},showSelectionHighlights:z,hideSelectionHighlights(){j.replaceChildren(),Ne=void 0,Pe=void 0,I()},showSelection(p,y,v){Xt(p,y,v),E.hidden=!0,u.hidden=!1,I()},updateSelection:Xt,renderTargets:g,updateTargetInstruction:O,setPreviewEnabled(p){J=p,pe.disabled=!p,w.setContextReady(p)},hideSelection(){u.hidden=!0,E.hidden=!1,te.replaceChildren(),ue=[],He=0,ze="",nt("idle"),N.textContent=r.targets.count(0,0),me.textContent=r.targets.complete(0,0),i(0,0),ie.textContent=r.context.selectedElement,$e.textContent="",ne.textContent="",we.textContent=r.diagnostics.resolving,B.dataset.state="loading",B.textContent=r.context.collecting,Se.disabled=!0,pe.disabled=!0,Ve=!1,J=!1,w.setContextReady(!1),w.setSelectionVisible(!1),w.setEditingEnabled(!0),w.resetJob()},hideSelectionTemporarily(){u.hidden=!0,E.hidden=!1},showPreview(p){ne.textContent=p,I()},readAgentSelection(){return w.readSelection()},agentConsentGranted(){return w.consentGranted()},setAgentProviderConsent(p){w.setProviderConsent(p)},setAgentEditingEnabled(p){je=p,oe.disabled=!p,Ce.disabled=!p,te.querySelectorAll(".spotpatch-target-remove, .spotpatch-target-select, textarea[data-target-instruction-id]").forEach(y=>{y.disabled=!p}),Se.disabled=!Ve,pe.disabled=!p||!J,w.setEditingEnabled(p),I()},renderAgentCapability(p,y,v,H){w.renderCapability(p,y,v,H);let ge=p==="ready"&&v?.state==="agent-ready";pe.classList.toggle("spotpatch-primary",!ge),I()},renderAgentWorkspaceHealth(p,y,v){w.renderWorkspaceHealth(p,y,v),I()},renderAgentJob(p,y,v,H){w.renderJob(p,y,v,H),I()},resetAgentJob(){w.resetJob(),I()},focusTargetInstruction(p){c(p)?.focus({preventScroll:!0})},focusPrompt(){ne.focus({preventScroll:!0})},announce(p){W.textContent="",W.textContent=p},locale:s.locale,messages:s.messages,agentWorkspaceConsentGranted:w.workspaceConsentGranted,subscribeLocale:s.subscribe,dispose(){le.removeEventListener("toggle",I),T.removeEventListener("click",s.toggle),go(),w.dispose(),a.remove()}})}function ia(e,t,o){let n=t?.relativePath??e.source.relativePath,s=e.source.line,r=e.source.column;return n!==void 0&&s!==void 0?`${n}:${String(s)}${r===void 0?"":`:${String(r)}`}`:n!==void 0?n:s!==void 0?o.lineLocation(s,r):o.unavailable}function ao(e,t){let o=[`SpotPatch: ${e.spotPatchVersion}`,`${e.framework==="next"?"Next.js":"Vite"}: ${e.frameworkVersion}`,`${t.source}: ${ia(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(`
|
|
945
|
+
`)}function io(e,t){return`${e}:${t}`}function sa(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 so(e){let t=h=>mn(h)??f.INTERNAL_ERROR,o=h=>e.view.messages().errors[t(h)],n=new Map,s=new Set,r=new Map,a=0,l,E,A=!1,R=!1,j=()=>e.view.readAgentSelection(),u=async h=>{e.view.renderAgentWorkspaceHealth("checking");try{let S=await e.api.agentWorkspaceHealth();return h!==a||e.view.renderAgentWorkspaceHealth(S.state,S,S.errorCode),S}catch(S){throw h===a&&e.view.renderAgentWorkspaceHealth("blocked",void 0,t(S)),S}},L=h=>{l!==void 0&&e.view.renderAgentJob(l,E,Object.freeze([...r.values()]),h??l.errorCode)},V=()=>{let h=j();if(h===void 0){e.view.setAgentProviderConsent(!1),e.view.renderAgentCapability("error",e.view.messages().agent.providerUnavailable);return}e.view.setAgentProviderConsent(s.has(h.providerProfileId));let S=n.get(io(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)},P=async h=>{let S=j();if(S===void 0)throw new Error("Agent provider selection is unavailable.");let C=io(S.providerProfileId,S.modelProfileId),T=n.get(C);if(T!==void 0)return T;e.view.renderAgentCapability("probing",e.view.messages().agent.testingCapability);let D=await e.api.agentCapability(S);if(h!==a)return D;if(D.state!=="agent-ready")throw new M(D.errorCode??f.MODEL_TOOL_CALL_UNSUPPORTED);return n.set(C,D),e.view.renderAgentCapability("ready",e.view.messages().agent.capabilityVerified,D),e.view.announce(e.view.messages().agent.capabilityVerifiedAnnouncement),D},b=async(h,S)=>{try{let C=await e.api.agentResult(h);if(S!==a||C.snapshot.jobId!==h)return;l=C.snapshot,E=C.result,L()}catch(C){S===a&&L(t(C))}},x=async(h,S)=>{try{await e.api.agentEvents(h,C=>{if(S!==a||C.jobId!==h)return;C.type==="snapshot"&&(l=C.data.snapshot,l.status==="applied"&&!A&&(A=!0,e.onApplied()));let T=sa(C);T!==void 0&&r.set(T.key,T),L()}),S===a&&await b(h,S)}catch(C){S===a&&!(C instanceof DOMException&&C.name==="AbortError")&&L(t(C))}},Q=async h=>{let S=l;if(S===void 0||R)return;R=!0;let C=a;l=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}),L();try{let T=h==="apply"?await e.api.applyAgentJob(S.jobId):h==="cancel"?await e.api.cancelAgentJob(S.jobId):await e.api.revertAgentJob(S.jobId);if(C!==a)return;l=T,T.status==="applied"&&!A&&(A=!0,e.onApplied()),await b(T.jobId,C)}catch(T){if(C!==a)return;l=S,await b(S.jobId,C),L(t(T)),e.view.announce(o(T))}finally{C===a&&(R=!1)}},Y=()=>{a+=1,l=void 0,E=void 0,r.clear(),A=!1,R=!1,e.view.resetAgentJob(),e.view.setAgentEditingEnabled(!0),V()};return Object.freeze({apply(){l?.canApply===!0&&Q("apply")},beginSelection(){Y();let h=a;e.ai.enabled&&u(h).catch(()=>{})},cancel(){l?.canCancel===!0&&Q("cancel")},consentChanged(){let h=j();h!==void 0&&(e.view.agentConsentGranted()?s.add(h.providerProfileId):s.delete(h.providerProfileId))},disposeSelection(){let h=l?.canCancel===!0||l?.status==="cancelling"?l.jobId:void 0;a+=1,l=void 0,E=void 0,r.clear(),A=!1,R=!1,h!==void 0&&e.api.cancelAgentJob(h).catch(()=>{})},providerOrModelChanged(){a+=1,V(),u(a).catch(()=>{})},reset(){let h=A;Y(),h?e.onReselectRequired():e.ai.enabled&&u(a).catch(()=>{})},revert(){l?.canRevert===!0&&Q("revert")},run(){if(!e.ai.enabled||l!==void 0)return;let h=j(),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}s.add(h.providerProfileId);let C=++a;e.view.setAgentEditingEnabled(!1),Promise.all([P(C),u(C)]).then(async([,T])=>{if(C!==a)return;if(T.state==="blocked")throw new M(T.errorCode??f.WORKTREE_LOCAL_CHANGES_UNSUPPORTED);if(T.state==="consent-required"&&!e.view.agentWorkspaceConsentGranted())throw new M(f.WORKTREE_DIRTY);let D=await e.api.createAgentJob({annotation:S,providerProfileId:h.providerProfileId,modelProfileId:h.modelProfileId,providerDataConsent:!0,workingTreeMode:T.state==="consent-required"?"include-local-changes":"require-clean"});C===a&&(l=D,E=void 0,r.clear(),L(),x(D.jobId,C))}).catch(T=>{C===a&&(e.view.setAgentEditingEnabled(!0),e.view.renderAgentCapability("error",o(T),void 0,t(T)),e.view.announce(o(T)))})},testCapability(){if(!e.ai.enabled||l!==void 0)return;let h=++a;Promise.all([P(h),u(h)]).catch(S=>{h===a&&(e.view.renderAgentCapability("error",o(S),void 0,t(S)),e.view.announce(o(S)))})}})}function co(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 Ft(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 lo(e){let t=Reflect.get(e,"clipboard");return typeof t=="object"&&t!==null&&"writeText"in t&&typeof t.writeText=="function"?t:void 0}var da=Object.freeze({classNames:Object.freeze([]),matchedRules:Object.freeze([]),computed:Object.freeze({}),warnings:Object.freeze(["CSS context collection failed."])});function Kt(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 la(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 pa(e){return e.apiStatus==="failed"||e.collectionStatus==="failed"?"warning":e.apiStatus==="loading"||e.collectionStatus==="loading"?"loading":"ready"}function ua(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 po(e,t={}){let o=ua(t),n=t.view??ro(o.document,e.shortcut,e.ai,e.locale),s=t.api??bn({apiBase:e.apiBase,fetch:o.window.fetch.bind(o.window),sessionToken:e.sessionToken}),r=t.promptComposer??jn({maxCharacters:e.budget.totalCharacters}),a=t.clipboard??lo(o.window.navigator),l=t.createId??(()=>co(o.window)),E=t.now??(()=>new Date().toISOString()),A=t.selectionSession??Gn(o.window,e.sessionId,e.maxTargets),R=A.load(),j=qn({adapter:t.reactAdapter??ca({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.")}}),u=Wt,L=!1,V,P,b=R?.targets.map(i=>{let c=qt(i.source);return{id:i.id,resolution:Object.freeze({source:i.source,react:i.react}),apiStatus:c===void 0?"not-required":i.code===void 0?"failed":"connected",code:i.code,collectionStatus:"ready",element:void 0,elementContext:i.element,instruction:i.instruction,marker:c,page:i.page,styles:i.styles}})??[],x=R?.activeTargetId,Q=R?.sequence??0,Y=R?.open??!1,h=!1,S=0,C=0,T=!1,D="",F,$,ae,ie,B=new Map;function k(i){u=Hn(u,i),n.renderStatus(u.status)}function Le(){return b.find(i=>i.id===x)??b.at(-1)}function he(i){if(!(i.elementContext===void 0||i.styles===void 0))return{id:i.id,instruction:i.instruction,page:i.page,source:i.resolution.source,react:i.resolution.react,element:i.elementContext,styles:i.styles,...i.code===void 0?{}:{code:i.code}}}function X(){let i=b.flatMap(g=>{let O=he(g);return O===void 0?[]:[O]});if(i.length===0){A.clear();return}let c=new Set(i.map(({id:g})=>g));A.save({...x!==void 0&&c.has(x)?{activeTargetId:x}:{},open:Y,sequence:Q,targets:i})}function Re(i,c){return L&&c===S&&u.status!=="idle"&&b.includes(i)}function ve(){let i=b.reduce((c,g)=>c+g.instruction.trim().length,0);return b.length>0&&i<=4e3&&b.every(c=>c.instruction.trim().length>0&&c.elementContext!==void 0&&c.styles!==void 0&&c.apiStatus!=="loading")}function me(){let i=n.messages().summary;return b.map((c,g)=>{let O=ao({resolution:c.resolution,...c.code===void 0?{}:{code:c.code},...c.styles===void 0?{}:{styles:c.styles},apiStatus:c.apiStatus,collectionStatus:c.collectionStatus,framework:e.framework,frameworkVersion:e.frameworkVersion,spotPatchVersion:e.spotPatchVersion},i);return`${i.target(g+1,c.id===x)}
|
|
946
|
+
${O}`}).join(`
|
|
885
947
|
|
|
886
|
-
`)}function ee(){let a=b.flatMap(c=>c.element?.isConnected?[{id:c.id,label:Ft(c.element),rect:Ht(c.element,o.window),active:c.id===x}]:[]);a.length===0?n.hideSelectionHighlights():n.showSelectionHighlights(a)}function N(a=!1){if(b.length===0)return;n.renderTargets(b.map(z=>({id:z.id,label:z.resolution.react.componentName??(z.element===void 0?z.elementContext?.tagName??"Element":Ft(z.element)),source:na(z,n.messages().context.sourceUnavailable),canOpenEditor:z.marker!==void 0,status:oa(z),active:z.id===x,instruction:z.instruction})),e.maxTargets),ee();let c=Pe(),h=me(),w=c?.marker!==void 0;a?n.showSelection(h,w,Re()):n.updateSelection(h,w,Re())}function K(){if(!Re())return;let a=b.map(c=>{if(c.elementContext===void 0||c.styles===void 0)throw new Error("SpotPatch attempted to compose an incomplete target.");let h=[...c.apiStatus==="failed"?["Source context could not be loaded."]:[],...c.collectionStatus==="failed"?["Part of the browser context could not be collected."]:[]];return{instruction:c.instruction.trim(),page:c.page,source:c.resolution.source,react:c.resolution.react,element:c.elementContext,styles:c.styles,...c.code===void 0?{}:{code:c.code},warnings:h}});return Zt({id:l(),locale:n.locale(),createdAt:E(),page:qt(o.document,o.window),targets:a})}function be(a){n.showHighlight(Ht(a,o.window),Ft(a))}function Le(){G?.isConnected===!0&&G.focus({preventScroll:!0}),G=void 0}function ve(){for(let a of B.values())o.window.clearTimeout(a);B.clear()}function ye(){y+=1,s.cancelPending(),T.disposeSelection(),ve(),$?.disconnect(),b=[],x=void 0,q=!1,f=!1,v=!1,D="",n.hideSelection(),n.hideSelectionHighlights(),A.clear(),Le()}function re(){u.status==="inspecting"?L({type:"CANCEL"}):u.status==="selected"?L({type:"CLOSE"}):u.status==="previewing"&&(L({type:"BACK"}),L({type:"CLOSE"})),q=!1,F(),n.hideSelection(),n.hideSelectionHighlights(),Le(),n.hideHighlight()}function _(){if(u.status!=="inspecting"||!v||b.length===0){re();return}v=!1,L({type:"SELECT"}),n.hideHighlight(),N(!0),n.focusTargetInstruction(x),n.announce(n.messages().announcements.addCancelled)}function ke(){if(u.status==="inspecting"&&v){_();return}if(u.status!=="idle"){re();return}if(b.length>0){q=!0,L({type:"RESTORE"}),f||(T.beginSelection(),f=!0),N(!0),n.focusTargetInstruction(x),F();return}L({type:"ACTIVATE"}),n.hideSelection(),n.announce(n.messages().announcements.selectionEnabled)}function Se(a=n.messages().announcements.chooseAnother){u.status==="selected"&&(L({type:"RESELECT"}),ye(),n.hideHighlight(),n.announce(a))}function Me(){if(u.status==="selected"){if(b.length>=e.maxTargets){n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}v=!0,L({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideHighlight(),n.announce(n.messages().announcements.chooseAdditional(b.length,e.maxTargets))}}function Y(){y+=1,ve(),$?.disconnect();for(let a of b)a.element=void 0;n.hideHighlight(),n.hideSelectionHighlights(),N(),A.clear(),n.announce(n.messages().announcements.appliedTargetsDetached)}let T=Qn({ai:e.ai,api:s,getAnnotation:K,onApplied:Y,onReselectRequired(){Se(n.messages().announcements.reselectAfterChange)},view:n});async function Te(a,c){let h=a.marker;if(h!==void 0)try{let w=await s.sourceContext({fileId:h.fileId,line:h.line,column:h.column,maxLines:e.budget.maxCodeLines});Ce(a,c)&&(a.code=w,a.apiStatus="connected",F(),N(),n.announce(n.messages().announcements.sourceLoaded))}catch(w){Ce(a,c)&&(a.code=void 0,a.apiStatus="failed",F(),N(),n.announce(n.messages().announcements.sourceFailed),e.debug&&!(w instanceof DOMException&&w.name==="AbortError")&&console.warn("[spotpatch:runtime] Source context request failed."))}}function le(a,c){let h=a.element;if(h===void 0)return;let w=o.window.setTimeout(()=>{if(B.delete(a.id),!Ce(a,c))return;let z=!1;try{a.elementContext=Rn({element:h,maxCharacters:e.budget.domCharacters})}catch{a.elementContext=void 0,z=!0}try{a.styles=yn({document:o.document,element:h,maxCharacters:e.budget.cssCharacters})}catch{a.styles=ta,z=!0}a.collectionStatus=z?"failed":"ready",F(),N(),n.announce(z?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);B.set(a.id,w)}function ae(a,c){return c!==void 0?b.find(h=>h.marker?.fileId===c.fileId&&h.marker.line===c.line&&h.marker.column===c.column):b.find(h=>h.element===a)}function De(a){let c=k.resolve(a),h=Jt(c.source),w=ae(a,h);if(w!==void 0){x=w.id,v=!1,L({type:"SELECT"}),n.hideHighlight(),N(!0),n.focusTargetInstruction(w.id),n.announce(n.messages().announcements.duplicate);return}if(b.length>=e.maxTargets){v=!1,L({type:"SELECT"}),n.hideHighlight(),N(!0),n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}b.length===0&&(G=o.document.activeElement instanceof HTMLElement?o.document.activeElement:void 0,D="",T.beginSelection(),f=!0),Q+=1;let te={id:`target-${String(Q)}`,element:a,resolution:c,marker:h,page:qt(o.document,o.window),code:void 0,elementContext:void 0,styles:void 0,instruction:"",apiStatus:h===void 0?"not-required":"loading",collectionStatus:"loading"};b.push(te),x=te.id,v=!1;let p=y;L({type:"SELECT"}),n.hideHighlight(),$?.observe(a),N(!0),q=!0,n.focusTargetInstruction(te.id),le(te,p),h!==void 0?Te(te,p):n.announce(c.source.confidence==="probable"?n.messages().announcements.sourceProbable:n.messages().announcements.sourceMissing)}function $e(){if(Z=void 0,u.status!=="inspecting"||I===void 0)return;let a=Ut(o.document,o.window,I.x,I.y);if(L({type:"HOVER"}),a===void 0){n.hideHighlight();return}be(a)}function Ae(a){u.status==="inspecting"&&(I={x:a.clientX,y:a.clientY},Z??=o.window.requestAnimationFrame($e))}function ie(a){if(u.status!=="inspecting"||_n(a.target))return;a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation();let c=Ut(o.document,o.window,a.clientX,a.clientY);if(c===void 0){n.announce(n.messages().announcements.noSelectable);return}De(c)}function we(a){if(a.key==="Escape"&&u.status!=="idle"){a.preventDefault(),u.status==="inspecting"&&v?_():u.status==="inspecting"||u.status==="selected"?re():(L({type:"BACK"}),n.focusTargetInstruction(x));return}Tn(a.target)||!wn(a,e.shortcut,o.window.navigator.userAgent)||(a.preventDefault(),ke())}function Oe(a){if(u.status!=="selected"&&u.status!=="inspecting")return;let c=b.findIndex(z=>z.id===a);if(c<0)return;let[h]=b.splice(c,1);if(h===void 0)return;let w=B.get(h.id);if(w!==void 0&&(o.window.clearTimeout(w),B.delete(h.id)),h.element!==void 0&&$?.unobserve(h.element),x===h.id&&(x=b.at(-1)?.id),b.length===0){v=!0,u.status==="selected"&&L({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideSelectionHighlights(),A.clear(),n.announce(n.messages().announcements.allTargetsRemoved);return}N(),F(),n.announce(n.messages().announcements.targetRemoved)}function V(){if(u.status==="idle"||b.length===0)return;let a=b.filter(c=>c.element!==void 0&&!c.element.isConnected);if(a.length>0){for(let c of a)c.element!==void 0&&($?.unobserve(c.element),c.element=void 0);N(),F(),n.announce(n.messages().announcements.detachedTargetPreserved);return}ee()}function ze(a){let c=a===void 0?Pe():b.find(te=>te.id===a);if(u.status!=="selected"||c?.marker===void 0)return;x!==c.id&&(x=c.id,N());let h=c.marker,w=y,z=++C;L({type:"OPEN_EDITOR"}),n.renderEditorStatus("opening"),s.openEditor({fileId:h.fileId,line:h.line,column:h.column}).then(()=>{P&&u.status==="selected"&&w===y&&z===C&&x===c.id&&b.includes(c)&&n.renderEditorStatus("success")}).catch(()=>{P&&u.status==="selected"&&w===y&&z===C&&x===c.id&&b.includes(c)&&n.renderEditorStatus("error")})}function Ie(a){if(u.status!=="selected"||!(a.target instanceof HTMLTextAreaElement))return;let c=a.target.dataset.targetInstructionId,h=b.find(w=>w.id===c);h!==void 0&&(h.instruction=a.target.value,n.updateTargetInstruction(h.id,h.instruction),n.setPreviewEnabled(Re()),F())}function xe(){ze()}function pe(a){e.ai.enabled&&u.status==="selected"&&a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),T.run())}function U(){if(u.status!=="selected")return;let a=K();if(a===void 0){n.announce(n.messages().announcements.completeInstructions);return}D=r.compose(a),L({type:"PREVIEW"}),n.showPreview(D),n.focusPrompt()}function qe(){if(u.status!=="previewing"||D.length===0)return;if(i===void 0){L({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.clipboardUnavailable);return}let a=y;i.writeText(D).then(()=>{P&&a===y&&u.status==="previewing"&&(L({type:"COPY_SUCCESS"}),n.focusTargetInstruction(x),n.announce(n.messages().announcements.promptCopied))}).catch(()=>{P&&a===y&&u.status==="previewing"&&(L({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.copyFailed))})}function Ue(){u.status==="previewing"&&(L({type:"BACK"}),n.focusTargetInstruction(x))}function rt(){if(!(!P||b.length===0)&&(N(),u.status==="previewing")){let a=K();a!==void 0&&(D=r.compose(a),n.showPreview(D))}}function Fe(a){let c=a.target;if(!(c instanceof Element))return;let h=c.closest("button[data-remove-target-id]");if(h?.dataset.removeTargetId!==void 0){Oe(h.dataset.removeTargetId);return}let w=c.closest("button[data-open-target-id]");if(w?.dataset.openTargetId!==void 0){ze(w.dataset.openTargetId);return}let te=c.closest("button[data-activate-target-id]")?.dataset.activateTargetId;u.status!=="selected"||te===void 0||!b.some(p=>p.id===te)||(x=te,N(),n.focusTargetInstruction(te))}function Ke(){Se()}function st(){P||(P=!0,n.renderStatus(u.status),o.document.addEventListener("pointermove",Ae,!0),o.document.addEventListener("click",ie,!0),o.document.addEventListener("keydown",we,!0),o.window.addEventListener("scroll",V,!0),o.window.addEventListener("resize",V),n.triggerButton.addEventListener("click",ke),n.addTargetButton.addEventListener("click",Me),n.reselectButton.addEventListener("click",Ke),n.targetList.addEventListener("click",Fe),n.targetList.addEventListener("input",Ie),n.targetList.addEventListener("keydown",pe),n.openEditorButton.addEventListener("click",xe),n.previewButton.addEventListener("click",U),n.copyButton.addEventListener("click",qe),n.backButton.addEventListener("click",Ue),n.closeButton.addEventListener("click",re),n.agentProviderSelect.addEventListener("change",T.providerOrModelChanged),n.agentModelSelect.addEventListener("change",T.providerOrModelChanged),n.agentConsentCheckbox.addEventListener("change",T.consentChanged),n.agentTestButton.addEventListener("click",T.testCapability),n.agentRunButton.addEventListener("click",T.run),n.agentCancelButton.addEventListener("click",T.cancel),n.agentApplyButton.addEventListener("click",T.apply),n.agentRevertButton.addEventListener("click",T.revert),n.agentResetButton.addEventListener("click",T.reset),oe=n.subscribeLocale(rt),o.resizeObserver!==void 0&&($=new o.resizeObserver(V)),o.mutationObserver!==void 0&&(de=new o.mutationObserver(V),de.observe(o.document.documentElement,{childList:!0,subtree:!0})),q&&b.length>0&&(L({type:"RESTORE"}),T.beginSelection(),f=!0,N(!0)),e.debug&&console.info(`[spotpatch:runtime] Mounted. Shortcut: ${e.shortcut}.`))}function m(){if(!P){oe?.(),oe=void 0,n.dispose(),s.cancelPending(),s.dispose(),T.disposeSelection(),k.dispose();return}P=!1,oe?.(),oe=void 0,o.document.removeEventListener("pointermove",Ae,!0),o.document.removeEventListener("click",ie,!0),o.document.removeEventListener("keydown",we,!0),o.window.removeEventListener("scroll",V,!0),o.window.removeEventListener("resize",V),n.triggerButton.removeEventListener("click",ke),n.addTargetButton.removeEventListener("click",Me),n.reselectButton.removeEventListener("click",Ke),n.targetList.removeEventListener("click",Fe),n.targetList.removeEventListener("input",Ie),n.targetList.removeEventListener("keydown",pe),n.openEditorButton.removeEventListener("click",xe),n.previewButton.removeEventListener("click",U),n.copyButton.removeEventListener("click",qe),n.backButton.removeEventListener("click",Ue),n.closeButton.removeEventListener("click",re),n.agentProviderSelect.removeEventListener("change",T.providerOrModelChanged),n.agentModelSelect.removeEventListener("change",T.providerOrModelChanged),n.agentConsentCheckbox.removeEventListener("change",T.consentChanged),n.agentTestButton.removeEventListener("click",T.testCapability),n.agentRunButton.removeEventListener("click",T.run),n.agentCancelButton.removeEventListener("click",T.cancel),n.agentApplyButton.removeEventListener("click",T.apply),n.agentRevertButton.removeEventListener("click",T.revert),n.agentResetButton.removeEventListener("click",T.reset),Z!==void 0&&(o.window.cancelAnimationFrame(Z),Z=void 0),ve(),F(),$?.disconnect(),de?.disconnect(),$=void 0,de=void 0,b=[],x=void 0,D="",I=void 0,G=void 0,s.cancelPending(),s.dispose(),T.disposeSelection(),k.dispose(),n.dispose(),u=Vt}return Object.freeze({mount:st,dispose:m,getState:()=>u})}var oo="__spotpatchRuntime__";function Kt(e){let t=globalThis;t[oo]?.dispose();let o=no(e);t[oo]=o,o.mount()}Kt({...__SPOTPATCH_RUNTIME_CONFIG__,apiBase:Ve});
|
|
948
|
+
`)}function ee(){let i=b.flatMap(c=>{if(!c.element?.isConnected)return[];let g=Rt(c.element,o.window);return g===void 0?[]:[{id:c.id,label:Kt(c.element),rect:g,active:c.id===x}]});i.length===0?n.hideSelectionHighlights():n.showSelectionHighlights(i)}function N(i=!1){if(b.length===0)return;n.renderTargets(b.map(z=>({id:z.id,label:z.resolution.react.componentName??(z.element===void 0?z.elementContext?.tagName??"Element":Kt(z.element)),source:la(z,n.messages().context.sourceUnavailable),canOpenEditor:z.marker!==void 0,status:pa(z),active:z.id===x,instruction:z.instruction})),e.maxTargets),ee();let c=Le(),g=me(),O=c?.marker!==void 0;i?n.showSelection(g,O,ve()):n.updateSelection(g,O,ve())}function be(){if(!ve())return;let i=b.map(c=>{if(c.elementContext===void 0||c.styles===void 0)throw new Error("SpotPatch attempted to compose an incomplete target.");let g=[...c.apiStatus==="failed"?["Source context could not be loaded."]:[],...c.collectionStatus==="failed"?["Part of the browser context could not be collected."]:[]];return{instruction:c.instruction.trim(),page:c.page,source:c.resolution.source,react:c.resolution.react,element:c.elementContext,styles:c.styles,...c.code===void 0?{}:{code:c.code},warnings:g}});return nn({id:l(),locale:n.locale(),createdAt:E(),page:Ft(o.document,o.window),targets:i})}function Te(i){n.showHighlight(kn(i,o.window),Kt(i))}function te(){F?.isConnected===!0&&F.focus({preventScroll:!0}),F=void 0}function le(){for(let i of B.values())o.window.clearTimeout(i);B.clear()}function De(){S+=1,s.cancelPending(),_.disposeSelection(),le(),$?.disconnect(),b=[],x=void 0,Y=!1,h=!1,T=!1,D="",n.hideSelection(),n.hideSelectionHighlights(),A.clear(),te()}function ye(){u.status==="inspecting"?k({type:"CANCEL"}):u.status==="selected"?k({type:"CLOSE"}):u.status==="previewing"&&(k({type:"BACK"}),k({type:"CLOSE"})),Y=!1,X(),n.hideSelection(),n.hideSelectionHighlights(),te(),n.hideHighlight()}function we(){if(u.status!=="inspecting"||!T||b.length===0){ye();return}T=!1,k({type:"SELECT"}),n.hideHighlight(),N(!0),n.focusTargetInstruction(x),n.announce(n.messages().announcements.addCancelled)}function $e(){if(u.status==="inspecting"&&T){we();return}if(u.status!=="idle"){ye();return}if(b.length>0){Y=!0,k({type:"RESTORE"}),h||(_.beginSelection(),h=!0),N(!0),n.focusTargetInstruction(x),X();return}k({type:"ACTIVATE"}),n.hideSelection(),n.announce(n.messages().announcements.selectionEnabled)}function w(i=n.messages().announcements.chooseAnother){u.status==="selected"&&(k({type:"RESELECT"}),De(),n.hideHighlight(),n.announce(i))}function Oe(){if(u.status==="selected"){if(b.length>=e.maxTargets){n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}T=!0,k({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideHighlight(),n.announce(n.messages().announcements.chooseAdditional(b.length,e.maxTargets))}}function ne(){S+=1,le(),$?.disconnect();for(let i of b)i.element=void 0;n.hideHighlight(),n.hideSelectionHighlights(),N(),A.clear(),n.announce(n.messages().announcements.appliedTargetsDetached)}let _=so({ai:e.ai,api:s,getAnnotation:be,onApplied:ne,onReselectRequired(){w(n.messages().announcements.reselectAfterChange)},view:n});async function se(i,c){let g=i.marker;if(g!==void 0)try{let O=await s.sourceContext({fileId:g.fileId,line:g.line,column:g.column,maxLines:e.budget.maxCodeLines});Re(i,c)&&(i.code=O,i.apiStatus="connected",X(),N(),n.announce(n.messages().announcements.sourceLoaded))}catch(O){Re(i,c)&&(i.code=void 0,i.apiStatus="failed",X(),N(),n.announce(n.messages().announcements.sourceFailed),e.debug&&!(O instanceof DOMException&&O.name==="AbortError")&&console.warn("[spotpatch:runtime] Source context request failed."))}}function oe(i,c){let g=i.element;if(g===void 0)return;let O=o.window.setTimeout(()=>{if(B.delete(i.id),!Re(i,c))return;let z=!1;try{i.elementContext=On({element:g,maxCharacters:e.budget.domCharacters})}catch{i.elementContext=void 0,z=!0}try{i.styles=An({document:o.document,element:g,maxCharacters:e.budget.cssCharacters})}catch{i.styles=da,z=!0}i.collectionStatus=z?"failed":"ready",X(),N(),n.announce(z?n.messages().announcements.contextWarning:n.messages().announcements.contextCollected),e.debug&&i.styles.warnings.length>0&&console.warn(`[spotpatch:runtime] CSS collection completed with ${String(i.styles.warnings.length)} warning(s).`)},0);B.set(i.id,O)}function Ce(i,c){return c!==void 0?b.find(g=>g.marker?.fileId===c.fileId&&g.marker.line===c.line&&g.marker.column===c.column):b.find(g=>g.element===i)}function Se(i){let c=j.resolve(i),g=qt(c.source),O=Ce(i,g);if(O!==void 0){x=O.id,T=!1,k({type:"SELECT"}),n.hideHighlight(),N(!0),n.focusTargetInstruction(O.id),n.announce(n.messages().announcements.duplicate);return}if(b.length>=e.maxTargets){T=!1,k({type:"SELECT"}),n.hideHighlight(),N(!0),n.announce(n.messages().announcements.selectionLimit(e.maxTargets));return}b.length===0&&(F=o.document.activeElement instanceof HTMLElement?o.document.activeElement:void 0,D="",_.beginSelection(),h=!0),Q+=1;let I={id:`target-${String(Q)}`,element:i,resolution:c,marker:g,page:Ft(o.document,o.window),code:void 0,elementContext:void 0,styles:void 0,instruction:"",apiStatus:g===void 0?"not-required":"loading",collectionStatus:"loading"};b.push(I),x=I.id,T=!1;let ot=S;k({type:"SELECT"}),n.hideHighlight(),$?.observe(i),N(!0),Y=!0,n.focusTargetInstruction(I.id),oe(I,ot),g!==void 0?se(I,ot):n.announce(c.source.confidence==="probable"?n.messages().announcements.sourceProbable:n.messages().announcements.sourceMissing)}function pe(){if(V=void 0,u.status!=="inspecting"||P===void 0)return;let i=Gt(o.document,o.window,P.x,P.y);if(k({type:"HOVER"}),i===void 0){n.hideHighlight();return}Te(i)}function Ie(i){u.status==="inspecting"&&(P={x:i.clientX,y:i.clientY},V??=o.window.requestAnimationFrame(pe))}function xe(i){if(u.status!=="inspecting"||Mn(i.target))return;i.preventDefault(),i.stopPropagation(),i.stopImmediatePropagation();let c=Gt(o.document,o.window,i.clientX,i.clientY);if(c===void 0){n.announce(n.messages().announcements.noSelectable);return}Se(c)}function _e(i){if(i.key==="Escape"&&u.status!=="idle"){i.preventDefault(),u.status==="inspecting"&&T?we():u.status==="inspecting"||u.status==="selected"?ye():(k({type:"BACK"}),n.focusTargetInstruction(x));return}Pn(i.target)||!Ln(i,e.shortcut,o.window.navigator.userAgent)||(i.preventDefault(),$e())}function ke(i){if(u.status!=="selected"&&u.status!=="inspecting")return;let c=b.findIndex(z=>z.id===i);if(c<0)return;let[g]=b.splice(c,1);if(g===void 0)return;let O=B.get(g.id);if(O!==void 0&&(o.window.clearTimeout(O),B.delete(g.id)),g.element!==void 0&&$?.unobserve(g.element),x===g.id&&(x=b.at(-1)?.id),b.length===0){T=!0,u.status==="selected"&&k({type:"RESELECT"}),n.hideSelectionTemporarily(),n.hideSelectionHighlights(),A.clear(),n.announce(n.messages().announcements.allTargetsRemoved);return}N(),X(),n.announce(n.messages().announcements.targetRemoved)}function W(){if(u.status==="idle"||b.length===0)return;let i=b.filter(c=>c.element!==void 0&&!c.element.isConnected);if(i.length>0){for(let c of i)c.element!==void 0&&($?.unobserve(c.element),c.element=void 0);N(),X(),n.announce(n.messages().announcements.detachedTargetPreserved);return}ee()}function Pe(i){let c=i===void 0?Le():b.find(I=>I.id===i);if(u.status!=="selected"||c?.marker===void 0)return;x!==c.id&&(x=c.id,N());let g=c.marker,O=S,z=++C;k({type:"OPEN_EDITOR"}),n.renderEditorStatus("opening"),s.openEditor({fileId:g.fileId,line:g.line,column:g.column}).then(()=>{L&&u.status==="selected"&&O===S&&z===C&&x===c.id&&b.includes(c)&&n.renderEditorStatus("success")}).catch(()=>{L&&u.status==="selected"&&O===S&&z===C&&x===c.id&&b.includes(c)&&n.renderEditorStatus("error")})}function Ne(i){if(u.status!=="selected"||!(i.target instanceof HTMLTextAreaElement))return;let c=i.target.dataset.targetInstructionId,g=b.find(O=>O.id===c);g!==void 0&&(g.instruction=i.target.value,n.updateTargetInstruction(g.id,g.instruction),n.setPreviewEnabled(ve()),X())}function Ee(){Pe()}function Ve(i){e.ai.enabled&&u.status==="selected"&&i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),_.run())}function J(){if(u.status!=="selected")return;let i=be();if(i===void 0){n.announce(n.messages().announcements.completeInstructions);return}D=r.compose(i),k({type:"PREVIEW"}),n.showPreview(D),n.focusPrompt()}function ze(){if(u.status!=="previewing"||D.length===0)return;if(a===void 0){k({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.clipboardUnavailable);return}let i=S;a.writeText(D).then(()=>{L&&i===S&&u.status==="previewing"&&(k({type:"COPY_SUCCESS"}),n.focusTargetInstruction(x),n.announce(n.messages().announcements.promptCopied))}).catch(()=>{L&&i===S&&u.status==="previewing"&&(k({type:"COPY_FAILURE"}),n.focusPrompt(),n.announce(n.messages().announcements.copyFailed))})}function je(){u.status==="previewing"&&(k({type:"BACK"}),n.focusTargetInstruction(x))}function ue(){if(!(!L||b.length===0)&&(N(),u.status==="previewing")){let i=be();i!==void 0&&(D=r.compose(i),n.showPreview(D))}}function He(i){let c=i.target;if(!(c instanceof Element))return;let g=c.closest("button[data-remove-target-id]");if(g?.dataset.removeTargetId!==void 0){ke(g.dataset.removeTargetId);return}let O=c.closest("button[data-open-target-id]");if(O?.dataset.openTargetId!==void 0){Pe(O.dataset.openTargetId);return}let I=c.closest("button[data-activate-target-id]")?.dataset.activateTargetId;u.status!=="selected"||I===void 0||!b.some(ot=>ot.id===I)||(x=I,N(),n.focusTargetInstruction(I))}function Ke(){w()}function nt(){L||(L=!0,n.renderStatus(u.status),o.document.addEventListener("pointermove",Ie,!0),o.document.addEventListener("click",xe,!0),o.document.addEventListener("keydown",_e,!0),o.window.addEventListener("scroll",W,!0),o.window.addEventListener("resize",W),n.triggerButton.addEventListener("click",$e),n.addTargetButton.addEventListener("click",Oe),n.reselectButton.addEventListener("click",Ke),n.targetList.addEventListener("click",He),n.targetList.addEventListener("input",Ne),n.targetList.addEventListener("keydown",Ve),n.openEditorButton.addEventListener("click",Ee),n.previewButton.addEventListener("click",J),n.copyButton.addEventListener("click",ze),n.backButton.addEventListener("click",je),n.closeButton.addEventListener("click",ye),n.agentProviderSelect.addEventListener("change",_.providerOrModelChanged),n.agentModelSelect.addEventListener("change",_.providerOrModelChanged),n.agentConsentCheckbox.addEventListener("change",_.consentChanged),n.agentTestButton.addEventListener("click",_.testCapability),n.agentRunButton.addEventListener("click",_.run),n.agentCancelButton.addEventListener("click",_.cancel),n.agentApplyButton.addEventListener("click",_.apply),n.agentRevertButton.addEventListener("click",_.revert),n.agentResetButton.addEventListener("click",_.reset),ie=n.subscribeLocale(ue),o.resizeObserver!==void 0&&($=new o.resizeObserver(W)),o.mutationObserver!==void 0&&(ae=new o.mutationObserver(W),ae.observe(o.document.documentElement,{childList:!0,subtree:!0})),Y&&b.length>0&&(k({type:"RESTORE"}),_.beginSelection(),h=!0,N(!0)),e.debug&&console.info(`[spotpatch:runtime] Mounted. Shortcut: ${e.shortcut}.`))}function m(){if(!L){ie?.(),ie=void 0,n.dispose(),s.cancelPending(),s.dispose(),_.disposeSelection(),j.dispose();return}L=!1,ie?.(),ie=void 0,o.document.removeEventListener("pointermove",Ie,!0),o.document.removeEventListener("click",xe,!0),o.document.removeEventListener("keydown",_e,!0),o.window.removeEventListener("scroll",W,!0),o.window.removeEventListener("resize",W),n.triggerButton.removeEventListener("click",$e),n.addTargetButton.removeEventListener("click",Oe),n.reselectButton.removeEventListener("click",Ke),n.targetList.removeEventListener("click",He),n.targetList.removeEventListener("input",Ne),n.targetList.removeEventListener("keydown",Ve),n.openEditorButton.removeEventListener("click",Ee),n.previewButton.removeEventListener("click",J),n.copyButton.removeEventListener("click",ze),n.backButton.removeEventListener("click",je),n.closeButton.removeEventListener("click",ye),n.agentProviderSelect.removeEventListener("change",_.providerOrModelChanged),n.agentModelSelect.removeEventListener("change",_.providerOrModelChanged),n.agentConsentCheckbox.removeEventListener("change",_.consentChanged),n.agentTestButton.removeEventListener("click",_.testCapability),n.agentRunButton.removeEventListener("click",_.run),n.agentCancelButton.removeEventListener("click",_.cancel),n.agentApplyButton.removeEventListener("click",_.apply),n.agentRevertButton.removeEventListener("click",_.revert),n.agentResetButton.removeEventListener("click",_.reset),V!==void 0&&(o.window.cancelAnimationFrame(V),V=void 0),le(),X(),$?.disconnect(),ae?.disconnect(),$=void 0,ae=void 0,b=[],x=void 0,D="",P=void 0,F=void 0,s.cancelPending(),s.dispose(),_.disposeSelection(),j.dispose(),n.dispose(),u=Wt}return Object.freeze({mount:nt,dispose:m,getState:()=>u})}var uo="__spotpatchRuntime__";function Yt(e){let t=globalThis;t[uo]?.dispose();let o=po(e);t[uo]=o,o.mount()}Yt({...__SPOTPATCH_RUNTIME_CONFIG__,apiBase:Je});
|