@plannotator/opencode 0.17.8 → 0.17.9
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/package.json +2 -2
- package/plannotator.html +2 -2
- package/review-editor.html +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plannotator/opencode",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.9",
|
|
4
4
|
"description": "Plannotator plugin for OpenCode - interactive plan review with visual annotation",
|
|
5
5
|
"author": "backnotprop",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@opencode-ai/plugin": "^1.1.10"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@plannotator/server": "0.17.
|
|
41
|
+
"@plannotator/server": "0.17.9",
|
|
42
42
|
"@plannotator/shared": "0.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
package/plannotator.html
CHANGED
|
@@ -508,7 +508,7 @@ created: ${new Date().toISOString().slice(0,19)}Z
|
|
|
508
508
|
source: plannotator
|
|
509
509
|
tags: [plan, ...]
|
|
510
510
|
---`})]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":Q.autoSave,onClick:()=>qA({autoSave:!Q.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${Q.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${Q.autoSave?"translate-x-6":"translate-x-1"}`})})]}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),w.jsx("button",{role:"switch","aria-checked":Q.vaultBrowserEnabled,onClick:()=>qA({vaultBrowserEnabled:!Q.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${Q.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${Q.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),C==="bear"&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),w.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),w.jsx("button",{role:"switch","aria-checked":k.enabled,onClick:()=>ce({enabled:!k.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${k.enabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${k.enabled?"translate-x-6":"translate-x-1"}`})})]}),k.enabled&&w.jsxs("div",{className:"mt-3 space-y-3",children:[w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),w.jsx("input",{type:"text",value:k.customTags,onChange:hA=>ce({customTags:hA.target.value}),onBlur:hA=>ce({customTags:TYA(hA.target.value)}),placeholder:"plan, work",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),w.jsxs("select",{value:k.tagPosition,onChange:hA=>ce({tagPosition:hA.target.value}),className:"w-full px-3 py-2 bg-muted rounded-lg text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",children:[w.jsx("option",{value:"append",children:"Append (end of note)"}),w.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":k.autoSave,onClick:()=>ce({autoSave:!k.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${k.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${k.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),C==="octarine"&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),w.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),w.jsx("button",{role:"switch","aria-checked":b.enabled,onClick:()=>RA({enabled:!b.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${b.enabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${b.enabled?"translate-x-6":"translate-x-1"}`})})]}),b.enabled&&w.jsxs("div",{className:"mt-3 space-y-3",children:[w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),w.jsx("input",{type:"text",value:b.workspace,onChange:hA=>RA({workspace:hA.target.value}),placeholder:"My Workspace",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),w.jsx("input",{type:"text",value:b.folder,onChange:hA=>RA({folder:hA.target.value}),placeholder:"plannotator",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),w.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",b.workspace||"..."," / ",b.folder||"plannotator","/"]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":b.autoSave,onClick:()=>RA({autoSave:!b.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${b.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${b.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body)]})},NT=({onClick:e,disabled:A=!1,isLoading:t=!1,label:i="Send Feedback",shortLabel:r,loadingLabel:n="Sending...",shortLoadingLabel:a,title:s="Send Feedback",muted:o=!1})=>w.jsxs("button",{onClick:e,disabled:A,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${o?"opacity-50 cursor-not-allowed bg-accent/10 text-accent/50":A?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:s,children:[w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r?w.jsxs(w.Fragment,{children:[w.jsx("span",{className:"hidden md:inline lg:hidden",children:t?a??n:r}),w.jsx("span",{className:"hidden lg:inline",children:t?n:i})]}):w.jsx("span",{className:"hidden md:inline",children:t?n:i})]}),UZ=({onClick:e,disabled:A=!1,isLoading:t=!1,label:i="Approve",loadingLabel:r="Approving...",mobileLabel:n="OK",mobileLoadingLabel:a="...",title:s,dimmed:o=!1,muted:g=!1})=>w.jsxs("button",{onClick:e,disabled:A,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${g?"opacity-40 cursor-not-allowed bg-muted text-muted-foreground":A?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":o?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,title:s,children:[w.jsx("span",{className:"md:hidden",children:t?a:n}),w.jsx("span",{className:"hidden md:inline",children:t?r:i})]}),K8A=({onClick:e,disabled:A=!1,isLoading:t=!1,title:i="Close session without sending feedback"})=>w.jsxs("button",{onClick:e,disabled:A||t,className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${A||t?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"}`,title:i,children:[w.jsx("span",{className:"md:hidden",children:t?"...":"✕"}),w.jsx("span",{className:"hidden md:inline",children:t?"Closing...":"Close"})]});async function bIA(e){const A=JSON.stringify(e),t=new TextEncoder().encode(A),i=new CompressionStream("deflate-raw"),r=i.writable.getWriter();r.write(t),r.close();const n=await new Response(i.readable).arrayBuffer(),a=new Uint8Array(n);let s="";for(let g=0;g<a.length;g++)s+=String.fromCharCode(a[g]);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function SS(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A),i=Uint8Array.from(t,o=>o.charCodeAt(0)),r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(i),n.close();const a=await new Response(r.readable).arrayBuffer(),s=new TextDecoder().decode(a);return JSON.parse(s)}async function Y8A(e){const A=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt"]),t=crypto.getRandomValues(new Uint8Array(12)),i=new TextEncoder().encode(e),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},A,i),n=new Uint8Array(t.length+r.byteLength);n.set(t,0),n.set(new Uint8Array(r),t.length);const a=await crypto.subtle.exportKey("raw",A);return{ciphertext:KZ(n),key:KZ(new Uint8Array(a))}}async function H8A(e,A){const t=YZ(e),i=YZ(A),r=t.slice(0,12),n=t.slice(12),a=await crypto.subtle.importKey("raw",i.buffer,{name:"AES-GCM",length:256},!1,["decrypt"]),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},a,n);return new TextDecoder().decode(s)}function KZ(e){let A="";for(let t=0;t<e.length;t++)A+=String.fromCharCode(e[t]);return btoa(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function YZ(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A);return Uint8Array.from(t,i=>i.charCodeAt(0))}function dd(e){if(e?.length)return e.map(A=>{if(typeof A=="string"){const t=A.split("/").pop()?.replace(/\.[^.]+$/,"")||"image";return{path:A,name:t}}return{path:A[0],name:A[1]}})}function N5(e){if(e?.length)return e.map(A=>[A.path,A.name])}function RIA(e){return e.map(A=>{const t=A.author||null,i=N5(A.images);return A.type===oi.GLOBAL_COMMENT?["G",A.text||"",t,i]:A.type===oi.DELETION?["D",A.originalText,t,i]:A.isQuickLabel?["C",A.originalText,A.text||"",t,i??void 0,1]:["C",A.originalText,A.text||"",t,i]})}function Nw(e,A,t){const i={D:oi.DELETION,C:oi.COMMENT,G:oi.GLOBAL_COMMENT};return e.map((r,n)=>{const a=r[0];if(a==="G"){const C=r[1],E=r[2],u=r[3];return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:oi.GLOBAL_COMMENT,text:C||void 0,originalText:"",createdA:Date.now()+n,author:E||void 0,images:dd(u),...t?.[n]?{source:t[n]}:{}}}const s=r[1],o=a==="D"?void 0:r[2],g=a==="D"?r[2]:r[3],l=a==="D"?r[3]:r[4],I=a==="C"&&r.length>5&&r[5]===1?!0:void 0;return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:i[a],text:o||void 0,originalText:s,createdA:Date.now()+n,author:g||void 0,images:dd(l),...I?{isQuickLabel:I}:{},...A?.[n]?{diffContext:A[n]}:{},...t?.[n]?{source:t[n]}:{}}})}function NIA(e){const A=e.map(t=>t.diffContext||null);return A.some(t=>t!==null)?A:null}function MIA(e){const A=e.map(t=>t.source||void 0);return A.some(t=>t!==void 0)?A:null}async function P8A(e,A,t,i=xIA){const r=NIA(A),n=MIA(A),a={p:e,a:RIA(A),g:t?.length?N5(t):void 0,...r?{d:r}:{},...n?{s:n}:{}},s=await bIA(a);return`${i}/#${s}`}async function J8A(){const A=window.location.hash.slice(1).split("?")[0];if(!A)return null;try{return await SS(A)}catch(t){return console.warn("Failed to parse share hash:",t),null}}function z8A(e){const A=new Blob([e]).size;return A<1024?`${A} B`:`${(A/1024).toFixed(1)} KB`}const kIA="https://plannotator-paste.plannotator.workers.dev",xIA="https://share.plannotator.ai";async function q8A(e,A,t,i){const r=i?.pasteApiUrl??kIA,n=i?.shareBaseUrl??xIA;try{const a=NIA(A),s=MIA(A),o={p:e,a:RIA(A),g:t?.length?N5(t):void 0,...a?{d:a}:{},...s?{s}:{}},g=await bIA(o),{ciphertext:l,key:I}=await Y8A(g),C=await fetch(`${r}/api/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l}),signal:AbortSignal.timeout(5e3)});if(!C.ok)return console.warn(`[sharing] Paste service returned ${C.status}`),null;const E=await C.json();return{shortUrl:`${n}/p/${E.id}#key=${I}`,id:E.id}}catch(a){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",a),null}}async function HZ(e,A=kIA,t){try{const i=await fetch(`${A}/api/paste/${e}`,{signal:AbortSignal.timeout(1e4)});if(!i.ok)return console.warn(`[sharing] Paste fetch returned ${i.status} for id ${e}`),null;const r=await i.json();if(t){const n=await H8A(r.data,t);return await SS(n)}return await SS(r.data)}catch(i){return console.warn("[sharing] Failed to load from paste ID:",i),null}}function W8A(e,A,t,i,r,n,a,s,o){const[g,l]=nA.useState(!1),[I,C]=nA.useState(!0),[E,u]=nA.useState(""),[d,Q]=nA.useState(""),[f,p]=nA.useState(""),[y,D]=nA.useState(!1),[S,k]=nA.useState(""),[R,b]=nA.useState(null),[N,T]=nA.useState(null),[L,K]=nA.useState(""),H=nA.useCallback(()=>{b(null),T(null)},[]),x=nA.useCallback(()=>K(""),[]),U=nA.useCallback(async()=>{try{const P=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(P){const q=P[1],j=window.location.hash.slice(1),X=j.startsWith("key=")?j.slice(4):void 0,_=await HZ(q,o,X);if(_){i(_.p);const oA=Nw(_.a,_.d,_.s);if(r(oA),_.g?.length){const dA=dd(_.g)??[];n(dA),T(dA)}b(oA),l(!0),a?.();const eA=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",eA),!0}return K("Failed to load shared plan — the link may be expired or incomplete."),!1}const z=window.location.hash.slice(1),Y=await J8A();if(Y){i(Y.p);const q=Nw(Y.a,Y.d,Y.s);if(r(q),Y.g?.length){const j=dd(Y.g)??[];n(j),T(j)}return b(q),l(!0),a?.(),window.history.replaceState({},"",window.location.pathname),!0}return z&&K("Failed to load shared plan — the URL may have been truncated by your browser."),!1}catch(P){return console.error("Failed to load from share hash:",P),K("Failed to load shared plan — an unexpected error occurred."),!1}},[i,r,n,a,o]);nA.useEffect(()=>{U().finally(()=>C(!1))},[]),nA.useEffect(()=>{const P=()=>{window.location.hash.length>1&&U()};return window.addEventListener("hashchange",P),()=>window.removeEventListener("hashchange",P)},[U]);const G=nA.useCallback(async()=>{try{const P=await P8A(e,A,t,s);u(P),Q(z8A(P))}catch(P){console.error("Failed to generate share URL:",P),u(""),Q("")}},[e,A,t,s]);nA.useEffect(()=>{G()},[G]),nA.useEffect(()=>{p(""),k("")},[e,A]);const F=nA.useCallback(async()=>{if(e){D(!0),k("");try{const P=await q8A(e,A,t,{pasteApiUrl:o,shareBaseUrl:s});P?p(P.shortUrl):(p(""),k("Short URL service unavailable"))}catch{p(""),k("Failed to generate short URL")}finally{D(!1)}}},[e,A,t,s,o]),O=nA.useCallback(async P=>{try{let z;const Y=P.match(/\/p\/([A-Za-z0-9]{6,16})(?:#key=([A-Za-z0-9_-]+))?(?:\?|#|$)/);if(Y){const eA=Y[1],dA=Y[2],iA=await HZ(eA,o,dA);if(!iA)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};z=iA}else{const eA=P.indexOf("#");if(eA===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const dA=P.slice(eA+1);if(!dA)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};z=await SS(dA)}const j=(z.p||"").trim().split(`
|
|
511
|
-
`).find(eA=>eA.startsWith("#")),X=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",_=Nw(z.a,z.d,z.s);if(_.length===0)return{success:!0,count:0,planTitle:X,error:"No annotations found in share link"};const oA=_.filter(eA=>!A.some(dA=>dA.originalText===eA.originalText&&dA.type===eA.type&&dA.text===eA.text));if(oA.length>0&&(r(eA=>{const dA=_.filter(sA=>!eA.some(gA=>gA.originalText===sA.originalText&&gA.type===sA.type&&gA.text===sA.text));if(dA.length===0)return eA;const iA=[...eA,...dA];return b(iA),iA}),z.g?.length)){const eA=dd(z.g)??[];n(dA=>{const iA=new Set(dA.map(gA=>gA.path)),sA=eA.filter(gA=>!iA.has(gA.path));return sA.length>0?[...dA,...sA]:dA}),T(eA)}return{success:!0,count:oA.length,planTitle:X}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:d,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:R,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:G,generateShortUrl:F,importFromShareUrl:O,shareLoadError:L,clearShareLoadError:x}}var Mw=(e=>(e.Approve="approve",e.Feedback="feedback",e))(Mw||{});function V8A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),i=A.get("ct");if(!t||!i){const r=e.hash.indexOf("?");if(r!==-1){const n=new URLSearchParams(e.hash.slice(r+1));t=t??n.get("cb"),i=i??n.get("ct")}}if(!t||!i)return null;try{const{protocol:r}=new URL(t);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:t,token:i}}async function Z8A(e,A,t){const i=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return r.ok?{type:"success",message:i}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function j8A(e,A,t){const[i,r]=nA.useState(null),n=nA.useRef(null);return nA.useEffect(()=>{const a=t??e.current;if(!a)return;const s=a.querySelectorAll('[data-block-type="heading"]');if(s.length===0)return;const o=new Map;return n.current=new IntersectionObserver(g=>{g.forEach(C=>{o.set(C.target,C.isIntersecting)});let l=null,I=1/0;for(const[C,E]of o)if(E){const u=C.getBoundingClientRect();u.top<I&&(I=u.top,l=C)}if(l){const C=l.getAttribute("data-block-id");C&&r(C)}},{root:a,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),s.forEach(g=>{n.current?.observe(g)}),()=>{n.current?.disconnect()}},[e,A,t]),i}function PZ(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function _8A(e){const[A,t]=nA.useState({phase:"idle"});nA.useEffect(()=>{if(!e)return;const r=RiA();r==="0"?(PZ(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),nA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){PZ(()=>t({phase:"closeFailed"}));return}const r=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(r)},[A]);const i=nA.useCallback(()=>{NiA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const X8A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),$8A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function A9A({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=_8A(!!e);if(!e)return null;const a=e==="approved";return w.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:w.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[w.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${a?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:a?w.jsx(X8A,{}):w.jsx($8A,{})}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),w.jsx("p",{className:"text-muted-foreground",children:t})]}),w.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",w.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),w.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",w.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[w.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),w.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const e9A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",JZ={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function t9A(e,A){const t=n=>n.replace(/^v/,""),i=t(e).split(".").map(Number),r=t(A).split(".").map(Number);for(let n=0;n<Math.max(i.length,r.length);n++){const a=i[n]||0,s=r[n]||0;if(s>a)return!0;if(s<a)return!1}return!1}function i9A(){const[e,A]=nA.useState(null);return nA.useEffect(()=>{(async()=>{try{const i="0.17.8",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:i,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:JZ[C]});return}const a=await fetch(e9A);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=t9A(i,o),l=o.replace(/^v/,""),I=JZ[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const r9A="pi install npm:@plannotator/pi-extension";function n9A(e){return lSA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const a9A=({origin:e,isWSL:A=!1})=>{const t=i9A(),[i,r]=nA.useState(!1),[n,a]=nA.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?r9A:n9A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),r(!0),setTimeout(()=>r(!1),2e3)}catch(d){console.error("Failed to copy:",d)}};return t.featureHighlight?w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[w.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:w.jsxs("div",{className:"flex items-start justify-between gap-3",children:[w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),w.jsxs("div",{children:[w.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),w.jsxs("div",{className:"px-5 py-4",children:[w.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),w.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:w.jsxs("div",{className:"flex items-start gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),w.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})},LIA="plannotator-editor-mode",s9A="selection";function o9A(){const e=Ye.getItem(LIA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:s9A}function g9A(e){Ye.setItem(LIA,e)}const TIA="plannotator-input-method",l9A="drag";function c9A(){const e=Ye.getItem(TIA);return e==="drag"||e==="pinpoint"?e:l9A}function I9A(e){Ye.setItem(TIA,e)}const C9A=300,E9A=300;function u9A(e,A){const t=nA.useRef("idle"),i=nA.useRef(0),r=nA.useRef(void 0),n=nA.useRef(e);nA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=nA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);nA.useEffect(()=>{const s=g=>{if(g.key!=="Alt"||g.repeat)return;const l=g.target?.tagName;l==="INPUT"||l==="TEXTAREA"||g.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(t.current==="idle"?(n.current=e,i.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(r.current),t.current="idle",n.current=a(n.current)))},o=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-i.current>=E9A?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},C9A)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function B9A(){nA.useEffect(()=>{const e=()=>document.documentElement.classList.add("plannotator-print"),A=()=>document.documentElement.classList.remove("plannotator-print"),t=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",e),window.addEventListener("afterprint",A),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",A),document.removeEventListener("visibilitychange",t),document.documentElement.classList.remove("plannotator-print")}},[])}function zZ({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=nA.useState(()=>{const Q=Ye.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=nA.useState(!1),g=nA.useRef(0),l=nA.useRef(0),I=nA.useRef(n),C=nA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=nA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),u=nA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);nA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const D=Q(y),S=r==="right"?g.current-D:D-g.current;C(Math.min(i,Math.max(t,l.current+S)))},p=()=>{o(!1),Ye.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",p),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",p),document.addEventListener("touchcancel",p),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",p),document.removeEventListener("touchcancel",p)}},[s,t,i,e,r,C]);const d=nA.useCallback(()=>{C(A),Ye.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:u,onDoubleClick:d}}}const qZ=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r,side:n})=>w.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[w.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),w.jsx("div",{className:`absolute inset-y-0 ${n==="left"?"-right-2 -left-1":n==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:A,onTouchStart:t,onDoubleClick:i})]});function d9A(){const e=nA.useRef(null),[A,t]=nA.useState(null),i=nA.useCallback(r=>{const n=r;e.current=n,t(n)},[]);return{ref:e,viewport:A,onViewportReady:i}}const h9A=({className:e,panelClassName:A,renderTrigger:t,children:i})=>{const[r,n]=nA.useState(!1),a=nA.useRef(null);return nA.useEffect(()=>{if(!r)return;const s=g=>{a.current&&!a.current.contains(g.target)&&n(!1)},o=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[r]),w.jsxs("div",{ref:a,className:e?`relative ${e}`:"relative",children:[t({isOpen:r,toggleMenu:()=>n(s=>!s)}),r&&w.jsx("div",{className:A??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:i({closeMenu:()=>n(!1)})})]})},Hg=({onClick:e,icon:A,label:t,subtitle:i,badge:r})=>w.jsxs("button",{onClick:e,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[w.jsx("span",{className:"text-muted-foreground",children:A}),i?w.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[w.jsx("span",{children:t}),w.jsx("span",{className:"text-[10px] text-muted-foreground",children:i})]}):w.jsx("span",{className:"flex-1",children:t}),r]}),iD=()=>w.jsx("div",{className:"my-1 border-t border-border"}),WZ=({children:e})=>w.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),Q9A=({className:e="w-3.5 h-3.5"})=>w.jsxs("svg",{className:`${e} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[w.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),w.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),w.jsx("path",{d:"M27 14L29.2 14.3L30.2 17.2L32.6 18.6L35.5 17.5L37.2 19.2L36.1 22.1L37.5 24.5L40.4 25.5L40.7 27.7L40.4 29.9L37.5 30.9L36.1 33.3L37.2 36.2L35.5 37.9L32.6 36.8L30.2 38.2L29.2 41.1L27 41.4L24.8 41.1L23.8 38.2L21.4 36.8L18.5 37.9L16.8 36.2L17.9 33.3L16.5 30.9L13.6 29.9L13.3 27.7L13.6 25.5L16.5 24.5L17.9 22.1L16.8 19.2L18.5 17.5L21.4 18.6L23.8 17.2L24.8 14.3Z",strokeWidth:1.5,strokeLinejoin:"round"}),w.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),f9A=({appVersion:e,onOpenSettings:A,onOpenExport:t,onCopyAgentInstructions:i,onDownloadAnnotations:r,onPrint:n,onCopyShareLink:a,onOpenImport:s,onSaveToObsidian:o,onSaveToBear:g,onSaveToOctarine:l,sharingEnabled:I,isApiMode:C,agentInstructionsEnabled:E,hasNewSettingsHints:u,obsidianConfigured:d,bearConfigured:Q,octarineConfigured:f})=>{const{theme:p,setTheme:y}=$cA(),D=C&&(d||Q||f);return w.jsx(h9A,{renderTrigger:({isOpen:S,toggleMenu:k})=>w.jsxs("button",{onClick:k,className:`relative flex items-center gap-1.5 p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-colors ${S?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Options","aria-label":"Options","aria-expanded":S,children:[S?w.jsx(m9A,{}):w.jsx(p9A,{}),w.jsx("span",{className:"hidden md:inline",children:"Options"}),u&&!S&&w.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2 w-2",children:[w.jsx("span",{className:"absolute inset-0 rounded-full bg-primary opacity-75 animate-ping"}),w.jsx("span",{className:"relative rounded-full h-2 w-2 bg-primary"})]})]}),children:({closeMenu:S})=>w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[w.jsx(WZ,{children:"Theme"}),w.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(k=>w.jsxs("button",{onClick:()=>{S(),y(k)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${p===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[k==="light"?w.jsx(pIA,{}):k==="dark"?w.jsx(mIA,{}):w.jsx(yIA,{}),w.jsx("span",{className:"capitalize",children:k})]},k))})]}),w.jsx(iD,{}),w.jsx(Hg,{onClick:()=>{S(),A()},icon:w.jsx(y9A,{}),label:"Settings"}),w.jsx(Hg,{onClick:()=>{S(),t()},icon:w.jsx(D9A,{}),label:"Export"}),E&&w.jsx(Hg,{onClick:()=>{S(),i()},icon:w.jsx(Q9A,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),w.jsx(iD,{}),w.jsx(Hg,{onClick:()=>{S(),r()},icon:w.jsx(w9A,{}),label:"Download Annotations"}),w.jsx(Hg,{onClick:()=>{S(),n()},icon:w.jsx(v9A,{}),label:"Print Plan"}),I&&w.jsx(Hg,{onClick:()=>{S(),a()},icon:w.jsx(S9A,{}),label:"Copy Share Link"}),I&&w.jsx(Hg,{onClick:()=>{S(),s()},icon:w.jsx(b9A,{}),label:"Import Review"}),D&&w.jsxs(w.Fragment,{children:[w.jsx(iD,{}),d&&w.jsx(Hg,{onClick:()=>{S(),o()},icon:w.jsx(MT,{}),label:"Save to Obsidian"}),Q&&w.jsx(Hg,{onClick:()=>{S(),g()},icon:w.jsx(MT,{}),label:"Save to Bear"}),f&&w.jsx(Hg,{onClick:()=>{S(),l()},icon:w.jsx(MT,{}),label:"Save to Octarine"})]}),w.jsx(iD,{}),w.jsxs("div",{className:"px-3 py-2 space-y-2",children:[w.jsxs("div",{className:"flex items-center justify-between gap-3",children:[w.jsx(WZ,{children:"Plannotator"}),w.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",e]})]}),w.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[w.jsx("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",onClick:S,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Release notes"}),w.jsx("a",{href:"https://github.com/backnotprop/plannotator",target:"_blank",rel:"noopener noreferrer",onClick:S,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Project repo"})]})]})]})})},p9A=()=>w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),m9A=()=>w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),y9A=()=>w.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),D9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),w9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),v9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),S9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),b9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),MT=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),R9A=({isOpen:e,onComplete:A})=>{const[t,i]=nA.useState("acceptEdits");if(!e)return null;const r=()=>{CIA(t),A(t)};return wg.createPortal(w.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:w.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[w.jsxs("div",{className:"p-5 border-b border-border",children:[w.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[w.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})})}),w.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),w.jsx("p",{className:"text-sm text-muted-foreground",children:"Claude Code 2.1.7+ supports preserving your permission mode after plan approval. Choose your preferred automation level."}),w.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",w.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),w.jsx("div",{className:"p-4 space-y-2",children:JO.map(n=>w.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${t===n.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[w.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),w.jsxs("div",{className:"flex-1",children:[w.jsx("div",{className:"text-sm font-medium",children:n.label}),w.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),w.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[w.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),w.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function N9A(e){const[A,t]=nA.useState(e),[i,r]=nA.useState("toc"),n=nA.useCallback(o=>{t(!0),o&&r(o)},[]),a=nA.useCallback(()=>{t(!1)},[]),s=nA.useCallback(o=>{A?i===o?t(!1):r(o):(t(!0),r(o))},[A,i]);return{isOpen:A,activeTab:i,open:n,close:a,toggleTab:s}}class M9A{diff(A,t,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const n=this.castInput(A,i),a=this.castInput(t,i),s=this.removeEmpty(this.tokenize(n,i)),o=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(s,o,i,r)}diffWithOptionsObj(A,t,i,r){var n;const a=p=>{if(p=this.postProcess(p,i),r){setTimeout(function(){r(p)},0);return}else return p},s=t.length,o=A.length;let g=1,l=s+o;i.maxEditLength!=null&&(l=Math.min(l,i.maxEditLength));const I=(n=i.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let u=this.extractCommon(E[0],t,A,0,i);if(E[0].oldPos+1>=o&&u+1>=s)return a(this.buildValues(E[0].lastComponent,t,A));let d=-1/0,Q=1/0;const f=()=>{for(let p=Math.max(d,-g);p<=Math.min(Q,g);p+=2){let y;const D=E[p-1],S=E[p+1];D&&(E[p-1]=void 0);let k=!1;if(S){const b=S.oldPos-p;k=S&&0<=b&&b<s}const R=D&&D.oldPos+1<o;if(!k&&!R){E[p]=void 0;continue}if(!R||k&&D.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(D,!1,!0,1,i),u=this.extractCommon(y,t,A,p,i),y.oldPos+1>=o&&u+1>=s)return a(this.buildValues(y.lastComponent,t,A))||!0;E[p]=y,y.oldPos+1>=o&&(Q=Math.min(Q,p-1)),u+1>=s&&(d=Math.max(d,p+1))}g++};if(r)(function p(){setTimeout(function(){if(g>l||Date.now()>C)return r(void 0);f()||p()},0)})();else for(;g<=l&&Date.now()<=C;){const p=f();if(p)return p}}addToPath(A,t,i,r,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===i?{oldPos:A.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:i,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+r,lastComponent:{count:1,added:t,removed:i,previousComponent:a}}}extractCommon(A,t,i,r,n){const a=t.length,s=i.length;let o=A.oldPos,g=o-r,l=0;for(;g+1<a&&o+1<s&&this.equals(i[o+1],t[g+1],n);)g++,o++,l++,n.oneChangePerToken&&(A.lastComponent={count:1,previousComponent:A.lastComponent,added:!1,removed:!1});return l&&!n.oneChangePerToken&&(A.lastComponent={count:l,previousComponent:A.lastComponent,added:!1,removed:!1}),A.oldPos=o,g}equals(A,t,i){return i.comparator?i.comparator(A,t):A===t||!!i.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let i=0;i<A.length;i++)A[i]&&t.push(A[i]);return t}castInput(A,t){return A}tokenize(A,t){return Array.from(A)}join(A){return A.join("")}postProcess(A,t){return A}get useLongestToken(){return!1}buildValues(A,t,i){const r=[];let n;for(;A;)r.push(A),n=A.previousComponent,delete A.previousComponent,A=n;r.reverse();const a=r.length;let s=0,o=0,g=0;for(;s<a;s++){const l=r[s];if(l.removed)l.value=this.join(i.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(o,o+l.count);I=I.map(function(C,E){const u=i[g+E];return u.length>C.length?u:C}),l.value=this.join(I)}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(g+=l.count)}}return r}}class k9A extends M9A{constructor(){super(...arguments),this.tokenize=T9A}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
|
|
511
|
+
`).find(eA=>eA.startsWith("#")),X=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",_=Nw(z.a,z.d,z.s);if(_.length===0)return{success:!0,count:0,planTitle:X,error:"No annotations found in share link"};const oA=_.filter(eA=>!A.some(dA=>dA.originalText===eA.originalText&&dA.type===eA.type&&dA.text===eA.text));if(oA.length>0&&(r(eA=>{const dA=_.filter(sA=>!eA.some(gA=>gA.originalText===sA.originalText&&gA.type===sA.type&&gA.text===sA.text));if(dA.length===0)return eA;const iA=[...eA,...dA];return b(iA),iA}),z.g?.length)){const eA=dd(z.g)??[];n(dA=>{const iA=new Set(dA.map(gA=>gA.path)),sA=eA.filter(gA=>!iA.has(gA.path));return sA.length>0?[...dA,...sA]:dA}),T(eA)}return{success:!0,count:oA.length,planTitle:X}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:d,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:R,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:G,generateShortUrl:F,importFromShareUrl:O,shareLoadError:L,clearShareLoadError:x}}var Mw=(e=>(e.Approve="approve",e.Feedback="feedback",e))(Mw||{});function V8A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),i=A.get("ct");if(!t||!i){const r=e.hash.indexOf("?");if(r!==-1){const n=new URLSearchParams(e.hash.slice(r+1));t=t??n.get("cb"),i=i??n.get("ct")}}if(!t||!i)return null;try{const{protocol:r}=new URL(t);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:t,token:i}}async function Z8A(e,A,t){const i=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return r.ok?{type:"success",message:i}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function j8A(e,A,t){const[i,r]=nA.useState(null),n=nA.useRef(null);return nA.useEffect(()=>{const a=t??e.current;if(!a)return;const s=a.querySelectorAll('[data-block-type="heading"]');if(s.length===0)return;const o=new Map;return n.current=new IntersectionObserver(g=>{g.forEach(C=>{o.set(C.target,C.isIntersecting)});let l=null,I=1/0;for(const[C,E]of o)if(E){const u=C.getBoundingClientRect();u.top<I&&(I=u.top,l=C)}if(l){const C=l.getAttribute("data-block-id");C&&r(C)}},{root:a,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),s.forEach(g=>{n.current?.observe(g)}),()=>{n.current?.disconnect()}},[e,A,t]),i}function PZ(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function _8A(e){const[A,t]=nA.useState({phase:"idle"});nA.useEffect(()=>{if(!e)return;const r=RiA();r==="0"?(PZ(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),nA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){PZ(()=>t({phase:"closeFailed"}));return}const r=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(r)},[A]);const i=nA.useCallback(()=>{NiA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const X8A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),$8A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function A9A({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=_8A(!!e);if(!e)return null;const a=e==="approved";return w.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:w.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[w.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${a?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:a?w.jsx(X8A,{}):w.jsx($8A,{})}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),w.jsx("p",{className:"text-muted-foreground",children:t})]}),w.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",w.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),w.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",w.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[w.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),w.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const e9A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",JZ={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function t9A(e,A){const t=n=>n.replace(/^v/,""),i=t(e).split(".").map(Number),r=t(A).split(".").map(Number);for(let n=0;n<Math.max(i.length,r.length);n++){const a=i[n]||0,s=r[n]||0;if(s>a)return!0;if(s<a)return!1}return!1}function i9A(){const[e,A]=nA.useState(null);return nA.useEffect(()=>{(async()=>{try{const i="0.17.9",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:i,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:JZ[C]});return}const a=await fetch(e9A);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=t9A(i,o),l=o.replace(/^v/,""),I=JZ[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const r9A="pi install npm:@plannotator/pi-extension";function n9A(e){return lSA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const a9A=({origin:e,isWSL:A=!1})=>{const t=i9A(),[i,r]=nA.useState(!1),[n,a]=nA.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?r9A:n9A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),r(!0),setTimeout(()=>r(!1),2e3)}catch(d){console.error("Failed to copy:",d)}};return t.featureHighlight?w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[w.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:w.jsxs("div",{className:"flex items-start justify-between gap-3",children:[w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),w.jsxs("div",{children:[w.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),w.jsxs("div",{className:"px-5 py-4",children:[w.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),w.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:w.jsxs("div",{className:"flex items-start gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),w.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})},LIA="plannotator-editor-mode",s9A="selection";function o9A(){const e=Ye.getItem(LIA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:s9A}function g9A(e){Ye.setItem(LIA,e)}const TIA="plannotator-input-method",l9A="drag";function c9A(){const e=Ye.getItem(TIA);return e==="drag"||e==="pinpoint"?e:l9A}function I9A(e){Ye.setItem(TIA,e)}const C9A=300,E9A=300;function u9A(e,A){const t=nA.useRef("idle"),i=nA.useRef(0),r=nA.useRef(void 0),n=nA.useRef(e);nA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=nA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);nA.useEffect(()=>{const s=g=>{if(g.key!=="Alt"||g.repeat)return;const l=g.target?.tagName;l==="INPUT"||l==="TEXTAREA"||g.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(t.current==="idle"?(n.current=e,i.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(r.current),t.current="idle",n.current=a(n.current)))},o=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-i.current>=E9A?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},C9A)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function B9A(){nA.useEffect(()=>{const e=()=>document.documentElement.classList.add("plannotator-print"),A=()=>document.documentElement.classList.remove("plannotator-print"),t=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",e),window.addEventListener("afterprint",A),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",A),document.removeEventListener("visibilitychange",t),document.documentElement.classList.remove("plannotator-print")}},[])}function zZ({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=nA.useState(()=>{const Q=Ye.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=nA.useState(!1),g=nA.useRef(0),l=nA.useRef(0),I=nA.useRef(n),C=nA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=nA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),u=nA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);nA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const D=Q(y),S=r==="right"?g.current-D:D-g.current;C(Math.min(i,Math.max(t,l.current+S)))},p=()=>{o(!1),Ye.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",p),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",p),document.addEventListener("touchcancel",p),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",p),document.removeEventListener("touchcancel",p)}},[s,t,i,e,r,C]);const d=nA.useCallback(()=>{C(A),Ye.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:u,onDoubleClick:d}}}const qZ=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r,side:n})=>w.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[w.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),w.jsx("div",{className:`absolute inset-y-0 ${n==="left"?"-right-2 -left-1":n==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:A,onTouchStart:t,onDoubleClick:i})]});function d9A(){const e=nA.useRef(null),[A,t]=nA.useState(null),i=nA.useCallback(r=>{const n=r;e.current=n,t(n)},[]);return{ref:e,viewport:A,onViewportReady:i}}const h9A=({className:e,panelClassName:A,renderTrigger:t,children:i})=>{const[r,n]=nA.useState(!1),a=nA.useRef(null);return nA.useEffect(()=>{if(!r)return;const s=g=>{a.current&&!a.current.contains(g.target)&&n(!1)},o=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[r]),w.jsxs("div",{ref:a,className:e?`relative ${e}`:"relative",children:[t({isOpen:r,toggleMenu:()=>n(s=>!s)}),r&&w.jsx("div",{className:A??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:i({closeMenu:()=>n(!1)})})]})},Hg=({onClick:e,icon:A,label:t,subtitle:i,badge:r})=>w.jsxs("button",{onClick:e,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[w.jsx("span",{className:"text-muted-foreground",children:A}),i?w.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[w.jsx("span",{children:t}),w.jsx("span",{className:"text-[10px] text-muted-foreground",children:i})]}):w.jsx("span",{className:"flex-1",children:t}),r]}),iD=()=>w.jsx("div",{className:"my-1 border-t border-border"}),WZ=({children:e})=>w.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),Q9A=({className:e="w-3.5 h-3.5"})=>w.jsxs("svg",{className:`${e} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[w.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),w.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),w.jsx("path",{d:"M27 14L29.2 14.3L30.2 17.2L32.6 18.6L35.5 17.5L37.2 19.2L36.1 22.1L37.5 24.5L40.4 25.5L40.7 27.7L40.4 29.9L37.5 30.9L36.1 33.3L37.2 36.2L35.5 37.9L32.6 36.8L30.2 38.2L29.2 41.1L27 41.4L24.8 41.1L23.8 38.2L21.4 36.8L18.5 37.9L16.8 36.2L17.9 33.3L16.5 30.9L13.6 29.9L13.3 27.7L13.6 25.5L16.5 24.5L17.9 22.1L16.8 19.2L18.5 17.5L21.4 18.6L23.8 17.2L24.8 14.3Z",strokeWidth:1.5,strokeLinejoin:"round"}),w.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),f9A=({appVersion:e,onOpenSettings:A,onOpenExport:t,onCopyAgentInstructions:i,onDownloadAnnotations:r,onPrint:n,onCopyShareLink:a,onOpenImport:s,onSaveToObsidian:o,onSaveToBear:g,onSaveToOctarine:l,sharingEnabled:I,isApiMode:C,agentInstructionsEnabled:E,hasNewSettingsHints:u,obsidianConfigured:d,bearConfigured:Q,octarineConfigured:f})=>{const{theme:p,setTheme:y}=$cA(),D=C&&(d||Q||f);return w.jsx(h9A,{renderTrigger:({isOpen:S,toggleMenu:k})=>w.jsxs("button",{onClick:k,className:`relative flex items-center gap-1.5 p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-colors ${S?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Options","aria-label":"Options","aria-expanded":S,children:[S?w.jsx(m9A,{}):w.jsx(p9A,{}),w.jsx("span",{className:"hidden md:inline",children:"Options"}),u&&!S&&w.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2 w-2",children:[w.jsx("span",{className:"absolute inset-0 rounded-full bg-primary opacity-75 animate-ping"}),w.jsx("span",{className:"relative rounded-full h-2 w-2 bg-primary"})]})]}),children:({closeMenu:S})=>w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[w.jsx(WZ,{children:"Theme"}),w.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(k=>w.jsxs("button",{onClick:()=>{S(),y(k)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${p===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[k==="light"?w.jsx(pIA,{}):k==="dark"?w.jsx(mIA,{}):w.jsx(yIA,{}),w.jsx("span",{className:"capitalize",children:k})]},k))})]}),w.jsx(iD,{}),w.jsx(Hg,{onClick:()=>{S(),A()},icon:w.jsx(y9A,{}),label:"Settings"}),w.jsx(Hg,{onClick:()=>{S(),t()},icon:w.jsx(D9A,{}),label:"Export"}),E&&w.jsx(Hg,{onClick:()=>{S(),i()},icon:w.jsx(Q9A,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),w.jsx(iD,{}),w.jsx(Hg,{onClick:()=>{S(),r()},icon:w.jsx(w9A,{}),label:"Download Annotations"}),w.jsx(Hg,{onClick:()=>{S(),n()},icon:w.jsx(v9A,{}),label:"Print Plan"}),I&&w.jsx(Hg,{onClick:()=>{S(),a()},icon:w.jsx(S9A,{}),label:"Copy Share Link"}),I&&w.jsx(Hg,{onClick:()=>{S(),s()},icon:w.jsx(b9A,{}),label:"Import Review"}),D&&w.jsxs(w.Fragment,{children:[w.jsx(iD,{}),d&&w.jsx(Hg,{onClick:()=>{S(),o()},icon:w.jsx(MT,{}),label:"Save to Obsidian"}),Q&&w.jsx(Hg,{onClick:()=>{S(),g()},icon:w.jsx(MT,{}),label:"Save to Bear"}),f&&w.jsx(Hg,{onClick:()=>{S(),l()},icon:w.jsx(MT,{}),label:"Save to Octarine"})]}),w.jsx(iD,{}),w.jsxs("div",{className:"px-3 py-2 space-y-2",children:[w.jsxs("div",{className:"flex items-center justify-between gap-3",children:[w.jsx(WZ,{children:"Plannotator"}),w.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",e]})]}),w.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[w.jsx("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",onClick:S,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Release notes"}),w.jsx("a",{href:"https://github.com/backnotprop/plannotator",target:"_blank",rel:"noopener noreferrer",onClick:S,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Project repo"})]})]})]})})},p9A=()=>w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),m9A=()=>w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),y9A=()=>w.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),D9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),w9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),v9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),S9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),b9A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),MT=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),R9A=({isOpen:e,onComplete:A})=>{const[t,i]=nA.useState("acceptEdits");if(!e)return null;const r=()=>{CIA(t),A(t)};return wg.createPortal(w.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:w.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[w.jsxs("div",{className:"p-5 border-b border-border",children:[w.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[w.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})})}),w.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),w.jsx("p",{className:"text-sm text-muted-foreground",children:"Claude Code 2.1.7+ supports preserving your permission mode after plan approval. Choose your preferred automation level."}),w.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",w.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),w.jsx("div",{className:"p-4 space-y-2",children:JO.map(n=>w.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${t===n.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[w.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),w.jsxs("div",{className:"flex-1",children:[w.jsx("div",{className:"text-sm font-medium",children:n.label}),w.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),w.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[w.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),w.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function N9A(e){const[A,t]=nA.useState(e),[i,r]=nA.useState("toc"),n=nA.useCallback(o=>{t(!0),o&&r(o)},[]),a=nA.useCallback(()=>{t(!1)},[]),s=nA.useCallback(o=>{A?i===o?t(!1):r(o):(t(!0),r(o))},[A,i]);return{isOpen:A,activeTab:i,open:n,close:a,toggleTab:s}}class M9A{diff(A,t,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const n=this.castInput(A,i),a=this.castInput(t,i),s=this.removeEmpty(this.tokenize(n,i)),o=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(s,o,i,r)}diffWithOptionsObj(A,t,i,r){var n;const a=p=>{if(p=this.postProcess(p,i),r){setTimeout(function(){r(p)},0);return}else return p},s=t.length,o=A.length;let g=1,l=s+o;i.maxEditLength!=null&&(l=Math.min(l,i.maxEditLength));const I=(n=i.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let u=this.extractCommon(E[0],t,A,0,i);if(E[0].oldPos+1>=o&&u+1>=s)return a(this.buildValues(E[0].lastComponent,t,A));let d=-1/0,Q=1/0;const f=()=>{for(let p=Math.max(d,-g);p<=Math.min(Q,g);p+=2){let y;const D=E[p-1],S=E[p+1];D&&(E[p-1]=void 0);let k=!1;if(S){const b=S.oldPos-p;k=S&&0<=b&&b<s}const R=D&&D.oldPos+1<o;if(!k&&!R){E[p]=void 0;continue}if(!R||k&&D.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(D,!1,!0,1,i),u=this.extractCommon(y,t,A,p,i),y.oldPos+1>=o&&u+1>=s)return a(this.buildValues(y.lastComponent,t,A))||!0;E[p]=y,y.oldPos+1>=o&&(Q=Math.min(Q,p-1)),u+1>=s&&(d=Math.max(d,p+1))}g++};if(r)(function p(){setTimeout(function(){if(g>l||Date.now()>C)return r(void 0);f()||p()},0)})();else for(;g<=l&&Date.now()<=C;){const p=f();if(p)return p}}addToPath(A,t,i,r,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===i?{oldPos:A.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:i,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+r,lastComponent:{count:1,added:t,removed:i,previousComponent:a}}}extractCommon(A,t,i,r,n){const a=t.length,s=i.length;let o=A.oldPos,g=o-r,l=0;for(;g+1<a&&o+1<s&&this.equals(i[o+1],t[g+1],n);)g++,o++,l++,n.oneChangePerToken&&(A.lastComponent={count:1,previousComponent:A.lastComponent,added:!1,removed:!1});return l&&!n.oneChangePerToken&&(A.lastComponent={count:l,previousComponent:A.lastComponent,added:!1,removed:!1}),A.oldPos=o,g}equals(A,t,i){return i.comparator?i.comparator(A,t):A===t||!!i.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let i=0;i<A.length;i++)A[i]&&t.push(A[i]);return t}castInput(A,t){return A}tokenize(A,t){return Array.from(A)}join(A){return A.join("")}postProcess(A,t){return A}get useLongestToken(){return!1}buildValues(A,t,i){const r=[];let n;for(;A;)r.push(A),n=A.previousComponent,delete A.previousComponent,A=n;r.reverse();const a=r.length;let s=0,o=0,g=0;for(;s<a;s++){const l=r[s];if(l.removed)l.value=this.join(i.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(o,o+l.count);I=I.map(function(C,E){const u=i[g+E];return u.length>C.length?u:C}),l.value=this.join(I)}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(g+=l.count)}}return r}}class k9A extends M9A{constructor(){super(...arguments),this.tokenize=T9A}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
|
|
512
512
|
`))&&(A=A.trim()),(!i.newlineIsToken||!t.includes(`
|
|
513
513
|
`))&&(t=t.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(A.endsWith(`
|
|
514
514
|
`)&&(A=A.slice(0,-1)),t.endsWith(`
|
|
@@ -977,7 +977,7 @@ export const CursorOverlay: React.FC<CursorOverlayProps> = ({
|
|
|
977
977
|
---
|
|
978
978
|
|
|
979
979
|
**Target:** Ship MVP in next sprint
|
|
980
|
-
`;function fHA({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:i}){const[r,n]=nA.useState(new Map),a=nA.useRef(e);a.current=e;const s=nA.useRef(A);s.current=A,nA.useEffect(()=>{if(r.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...r.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(u=>E.delete(u)),E})},[e]);const o=nA.useCallback((l,I)=>{const C=a.current,E=s.current,u=C.find(Q=>Q.id===l);if(u&&I===u.checked)n(f=>{const p=new Map(f);return p.delete(l),p}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id)),n(f=>{const p=new Map(f);return p.set(l,I),p}),u){const f=C.indexOf(u);let p="";for(let k=f-1;k>=0;k--)if(C[k].type==="heading"){p=C[k].content;break}const y=I?"Mark as completed":"Mark as not completed",D=p?` (under "${p}")`:` (line ${u.startLine})`,S={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:u.content.length,type:oi.COMMENT,text:`${y}${D}: ${u.content}`,originalText:u.content,createdA:Date.now()};t(S)}},[t,i]),g=nA.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:r,toggle:o,revertOverride:g}}const pHA=()=>{const[e,A]=nA.useState(QHA),[t,i]=nA.useState([]),[r,n]=nA.useState(null),[a,s]=nA.useState([]),[o,g]=nA.useState(null),[l,I]=nA.useState(!1),[C,E]=nA.useState(!1),[u,d]=nA.useState(!1),[Q,f]=nA.useState(!1),[p,y]=nA.useState(!1),[D,S]=nA.useState(!1),[k,R]=nA.useState(""),[b,N]=nA.useState(()=>window.innerWidth>=768),[T,L]=nA.useState(!1),[K,H]=nA.useState(()=>QIA()),[x,U]=nA.useState(o9A),[G,F]=nA.useState(c9A),[O,P]=nA.useState(()=>Ye.getItem("plannotator-tater-mode")==="true"),[z,Y]=nA.useState(()=>PO()),q=nA.useRef(null),[j,X]=nA.useState("full");nA.useLayoutEffect(()=>{const ee=q.current;if(!ee)return;const Pe=Ct=>Ct>=800?"full":Ct>=680?"short":"icon";X(Pe(ee.getBoundingClientRect().width));const Xe=new ResizeObserver(([Ct])=>{const ei=Pe(Ct.contentRect.width);X(nr=>nr===ei?nr:ei)});return Xe.observe(ee),()=>Xe.disconnect()},[]);const[_,oA]=nA.useState(!1),[eA,dA]=nA.useState(null),[iA,sA]=nA.useState(),[gA,rA]=nA.useState(!1),[EA,cA]=nA.useState([]),[wA,uA]=nA.useState(!1),[UA,aA]=nA.useState(null),[Ae,bA]=nA.useState(),[ie,ae]=nA.useState(void 0),[Ce,GA]=nA.useState(!0),[$A,KA]=nA.useState(!1),[qA,ce]=nA.useState(!1),[RA,_A]=nA.useState(null),[BA,vA]=nA.useState(null),[Z,mA]=nA.useState(!1),[fA,kA]=nA.useState("bypassPermissions"),[xA,hA]=nA.useState(!0),[TA,MA]=nA.useState(void 0),[HA,jA]=nA.useState(void 0),[re,yA]=nA.useState(null),[PA,YA]=nA.useState(null);nA.useEffect(()=>{document.title=re?`${re.display} · Plannotator`:"Plannotator"},[re]);const[se,Ne]=nA.useState(),[ve,tA]=nA.useState(null),[ge,oe]=nA.useState(!1),[Se,be]=nA.useState("clean"),[Ke,Ue]=nA.useState(null),[qe,St]=nA.useState(null),_e=nA.useRef(null),{ref:Dt,viewport:jt,onViewportReady:Pt}=d9A();B9A();const pt=zZ({storageKey:"plannotator-panel-width"}),Jt=zZ({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),Li=pt.isDragging||Jt.isDragging,Fe=N9A(PO().tocEnabled);nA.useEffect(()=>{z.tocEnabled?Fe.open("toc"):Fe.close()},[z.tocEnabled]),nA.useEffect(()=>{Fe.activeTab==="toc"&&ge&&oe(!1)},[Fe.activeTab]),nA.useEffect(()=>{if(!ge)return;const ee=Pe=>{Pe.key==="Escape"&&oe(!1)};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[ge]);const JA=G9A(e,Ke,qe),Ee=O9A({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:EA,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:cA,viewerRef:_e,sidebar:Fe,sourceFilePath:Ae}),Ge=P9A({markdown:e,viewerRef:_e,linkedDocHook:Ee,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setSubmitted:_A}),rt=_9A(),ti=nA.useMemo(()=>SZ()?TI(LI()):"",[z]),st=nA.useMemo(()=>!!PA||OZ()||SZ(),[PA,z]),gi=nA.useMemo(()=>{const ee=PA?[PA]:[],Pe=OZ()?R5().directories:[];return[...new Set([...ee,...Pe])]},[PA,z]);nA.useEffect(()=>{st||rt.setActiveFile(null)},[st]),nA.useEffect(()=>{ti||rt.clearVaultDirs()},[ti]),nA.useEffect(()=>{if(Fe.activeTab==="files"&&st){if(gi.length>0){const ee=rt.dirs.filter(Xe=>!Xe.isVault).map(Xe=>Xe.path);(gi.some(Xe=>!ee.includes(Xe))||ee.some(Xe=>!gi.includes(Xe)))&&rt.fetchAll(gi)}ti&&!rt.dirs.find(ee=>ee.isVault&&ee.path===ti&&!ee.error)&&rt.addVaultDir(ti)}},[Fe.activeTab,st,gi,ti]);const _i=Qn.useCallback((ee,Pe)=>{const Ct=rt.dirs.find(ei=>ei.path===Pe)?.isVault?ei=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Pe)}&path=${encodeURIComponent(ei)}`:ei=>`/api/doc?path=${encodeURIComponent(ei)}&base=${encodeURIComponent(Pe)}`;Ee.open(ee,Ct,"files"),rt.setActiveFile(ee)},[Ee,rt]),pi=Qn.useCallback(ee=>{if(rt.dirs.find(Xe=>Xe.path===rt.activeDirPath)?.isVault&&rt.activeDirPath)Ee.open(ee,Xe=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(rt.activeDirPath)}&path=${encodeURIComponent(Xe)}`);else if(rt.activeFile&&rt.activeDirPath){const Xe=Ee.filepath?.replace(/\/[^/]+$/,"")||rt.activeDirPath;Ee.open(ee,Ct=>`/api/doc?path=${encodeURIComponent(Ct)}&base=${encodeURIComponent(Xe)}`)}else{const Xe=Ee.filepath?Ee.filepath.replace(/\/[^/]+$/,""):ie;Xe?Ee.open(ee,Ct=>`/api/doc?path=${encodeURIComponent(Ct)}&base=${encodeURIComponent(Xe)}`):Ee.open(ee)}},[rt.dirs,rt.activeDirPath,rt.activeFile,Ee,ie]),xe=Qn.useCallback(()=>{Ee.back(),rt.setActiveFile(null),Ge.clearSelection()},[Ee,rt,Ge]),ye=nA.useMemo(()=>{const ee=new Map;for(const[Pe,Xe]of Ee.getDocAnnotations()){const Ct=Xe.annotations.length+Xe.globalAttachments.length;Ct>0&&ee.set(Pe,Ct)}return ee},[Ee.getDocAnnotations,t,EA]),ke=nA.useMemo(()=>{const ee=rt.dirs.map(Xe=>Xe.path);if(ee.length===0)return ye;const Pe=new Map;for(const[Xe,Ct]of ye)ee.some(ei=>Xe.startsWith(ei+"/"))&&Pe.set(Xe,Ct);return Pe},[ye,rt.dirs]),Re=ke.size>0,De=nA.useMemo(()=>{const ee=Ee.filepath;let Pe=0,Xe=0;for(const[Ct,ei]of ye)Ct!==ee&&(Pe+=ei,Xe++);return Pe>0?{count:Pe,files:Xe}:void 0},[ye,Ee.filepath]),[ct,LA]=nA.useState(),Ji=Qn.useRef(),FA=Qn.useCallback(()=>{const ee=new Set(ye.keys());ee.size!==0&&((!Fe.isOpen||Fe.activeTab!=="files")&&Fe.open("files"),Ji.current&&clearTimeout(Ji.current),LA(void 0),requestAnimationFrame(()=>{LA(ee),Ji.current=setTimeout(()=>LA(void 0),1200)}))},[ye,Fe,Re]),Tt=UA==="folder"?"file list":UA==="file"?"file":UA==="message"?"message":"plan",ns=nA.useMemo(()=>a.filter(ee=>ee.type==="heading").length,[a]),as=j8A(Dt,ns,jt),{editorAnnotations:Dr,deleteEditorAnnotation:Ls}=z9A(),{externalAnnotations:vi,updateExternalAnnotation:cr,deleteExternalAnnotation:ss}=V9A({enabled:_}),{reset:ta}=Z9A({viewerRef:_e,externalAnnotations:vi,enabled:_&&!Ee.isActive&&!ge,planKey:e}),li=nA.useMemo(()=>vi.length===0?t:[...t.filter(Pe=>Pe.source?!vi.some(Xe=>Xe.source===Pe.source&&Xe.type===Pe.type&&Xe.originalText===Pe.originalText):!0),...vi],[t,vi]),Br=nA.useMemo(()=>li.filter(ee=>!!ee.diffContext),[li]),Ts=nA.useMemo(()=>li.filter(ee=>!ee.diffContext),[li]),{isSharedSession:Ri,isLoadingShared:Et,shareUrl:ht,shareUrlSize:Hi,shortShareUrl:ii,isGeneratingShortUrl:An,shortUrlError:Ir,pendingSharedAnnotations:Cn,clearPendingSharedAnnotations:en,generateShortUrl:Ve,importFromShareUrl:W,shareLoadError:$,clearShareLoadError:CA}=W8A(e,li,EA,A,i,cA,()=>{GA(!1)},TA,HA),{draftBanner:DA,restoreDraft:OA,dismissDraft:XA}=H9A({annotations:li,globalAttachments:EA,isApiMode:_,isSharedSession:Ri,submitted:!!RA}),ue=Qn.useCallback(()=>{const{annotations:ee,globalAttachments:Pe}=OA();ee.length>0&&(i(ee),Pe.length>0&&cA(Pe),setTimeout(()=>{_e.current?.applySharedAnnotations(ee.filter(Xe=>!Xe.diffContext))},100))},[OA]),{getAgentWarning:pe}=BIA(eA);nA.useEffect(()=>{if(Cn&&Cn.length>0){const ee=setTimeout(()=>{_e.current?.clearAllHighlights(),_e.current?.applySharedAnnotations(Cn.filter(Pe=>!Pe.diffContext)),en(),ta()},100);return()=>clearTimeout(ee)}},[Cn,en,ta]);const $e=ee=>{P(ee),Ye.setItem("plannotator-tater-mode",String(ee))},Ht=ee=>{U(ee),g9A(ee)},kt=ee=>{F(ee),I9A(ee)};u9A(G,kt),nA.useEffect(()=>{Et||Ri||fetch("/api/plan").then(ee=>{if(!ee.ok)throw new Error("Not in API mode");return ee.json()}).then(ee=>{fn.init(ee.serverConfig),sA(ee.serverConfig?.gitUser),ee.mode==="archive"?(A(ee.plan||""),ee.archivePlans&&Ge.init(ee.archivePlans),Ge.fetchPlans(),hA(!1),Fe.open("archive")):ee.mode==="annotate-folder"?A(""):ee.plan&&A(ee.plan),oA(!0),(ee.mode==="annotate"||ee.mode==="annotate-last"||ee.mode==="annotate-folder")&&uA(!0),ee.mode==="annotate-folder"&&Fe.open("files"),ee.mode&&ee.mode!=="archive"&&aA(ee.mode==="annotate-last"?"message":ee.mode==="annotate-folder"?"folder":"file"),ee.filePath&&(ae(ee.mode==="annotate-folder"?ee.filePath:ee.filePath.replace(/\/[^/]+$/,"")),ee.mode==="annotate"&&bA(ee.filePath)),ee.sharingEnabled!==void 0&&hA(ee.sharingEnabled),ee.shareBaseUrl&&MA(ee.shareBaseUrl),ee.pasteApiUrl&&jA(ee.pasteApiUrl),ee.repoInfo&&yA(ee.repoInfo),ee.projectRoot&&YA(ee.projectRoot),ee.previousPlan!==void 0&&Ue(ee.previousPlan),ee.versionInfo&&St(ee.versionInfo),ee.origin&&(dA(ee.origin),ee.origin==="claude-code"&&l8A()&&mA(!0),kA(IIA().mode)),ee.isWSL&&rA(!0)}).catch(()=>{oA(!1)}).finally(()=>GA(!1))},[Et,Ri]),nA.useEffect(()=>{const{frontmatter:ee}=piA(e);g(ee),s(miA(e))},[e]);const Ai=nA.useRef(!1),_t=nA.useRef({}),mt=nA.useRef(null);nA.useEffect(()=>{Ai.current=!1,_t.current={},mt.current=null},[e]),nA.useEffect(()=>{if(!_||!e||Ri||wA||Ge.archiveMode||Ai.current)return;const ee={},Pe=[],Xe=LI();if(Xe.autoSave&&Xe.enabled){const dr=TI(Xe);dr&&(ee.obsidian={vaultPath:dr,folder:Xe.folder||"plannotator",plan:e,...Xe.filenameFormat&&{filenameFormat:Xe.filenameFormat},...Xe.filenameSeparator&&Xe.filenameSeparator!=="space"&&{filenameSeparator:Xe.filenameSeparator}},Pe.push("Obsidian"))}const Ct=DE();Ct.autoSave&&Ct.enabled&&(ee.bear={plan:e,customTags:Ct.customTags,tagPosition:Ct.tagPosition},Pe.push("Bear"));const ei=Bd();if(ei.autoSave&&tD()&&(ee.octarine={plan:e,workspace:ei.workspace,folder:ei.folder||"plannotator"},Pe.push("Octarine")),Pe.length===0)return;Ai.current=!0;const nr=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}).then(dr=>dr.json()).then(dr=>{const Xo={...ee.obsidian?{obsidian:!!dr.results?.obsidian?.success}:{},...ee.bear?{bear:!!dr.results?.bear?.success}:{},...ee.octarine?{octarine:!!dr.results?.octarine?.success}:{}};_t.current=Xo;const KC=Pe.filter(Kh=>!dr.results?.[Kh.toLowerCase()]?.success);return KC.length===0?tA({type:"success",message:`Auto-saved to ${Pe.join(" & ")}`}):tA({type:"error",message:`Auto-save failed for ${KC.join(" & ")}`}),Xo}).catch(()=>(_t.current={},tA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>tA(null),3e3));mt.current=nr},[_,e,Ri,wA]),nA.useEffect(()=>{const ee=Pe=>{const Xe=Pe.clipboardData?.items;if(Xe){for(const Ct of Xe)if(Ct.type.startsWith("image/")){Pe.preventDefault();const ei=Ct.getAsFile();if(ei){const nr=Q3(ei.name,EA.map(Xo=>Xo.name)),dr=URL.createObjectURL(ei);vA({file:ei,blobUrl:dr,initialName:nr})}break}}};return document.addEventListener("paste",ee),()=>document.removeEventListener("paste",ee)},[EA]);const xt=async(ee,Pe,Xe)=>{if(BA)try{const Ct=new FormData,ei=Pe?new File([ee],"annotated.png",{type:"image/png"}):BA.file;Ct.append("file",ei);const nr=await fetch("/api/upload",{method:"POST",body:Ct});if(nr.ok){const dr=await nr.json();cA(Xo=>[...Xo,{path:dr.path,name:Xe}])}}catch{}finally{URL.revokeObjectURL(BA.blobUrl),vA(null)}},rr=()=>{BA&&(URL.revokeObjectURL(BA.blobUrl),vA(null))},tn=async()=>{KA(!0);try{const ee=LI(),Pe=DE(),Xe=Bd(),Ct=S5(),ei=wS(),nr=Pe.autoSave&&mt.current?await mt.current:_t.current,dr={};eA==="claude-code"&&(dr.permissionMode=fA);const Xo=a8A(Ct);Xo&&(dr.agentSwitch=Xo),dr.planSave={enabled:ei.enabled,...ei.customPath&&{customPath:ei.customPath}};const KC=TI(ee);ee.enabled&&KC&&(dr.obsidian={vaultPath:KC,folder:ee.folder||"plannotator",plan:e,...ee.filenameFormat&&{filenameFormat:ee.filenameFormat},...ee.filenameSeparator&&ee.filenameSeparator!=="space"&&{filenameSeparator:ee.filenameSeparator}}),Pe.enabled&&!(Pe.autoSave&&nr.bear)&&(dr.bear={plan:e,customTags:Pe.customTags,tagPosition:Pe.tagPosition}),tD()&&(dr.octarine={plan:e,workspace:Xe.workspace,folder:Xe.folder||"plannotator"});const Kh=Array.from(Ee.getDocAnnotations().values()).some(bm=>bm.annotations.length>0||bm.globalAttachments.length>0);(li.length>0||EA.length>0||Kh||Dr.length>0)&&(dr.feedback=xl),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(dr)}),_A("approved")}catch{KA(!1)}},Rn=async()=>{KA(!0);try{const ee=wS();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:xl,planSave:{enabled:ee.enabled,...ee.customPath&&{customPath:ee.customPath}}})}),_A("denied")}catch{KA(!1)}},Xi=async()=>{KA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:xl,annotations:li})}),_A("denied")}catch{KA(!1)}},zr=nA.useCallback(async()=>{ce(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)_A("exited");else throw new Error("Failed to exit")}catch{ce(!1)}},[]);nA.useEffect(()=>{const ee=Pe=>{if(Pe.key!=="Enter"||!(Pe.metaKey||Pe.ctrlKey))return;const Xe=Pe.target?.tagName;if(Xe==="INPUT"||Xe==="TEXTAREA"||l||C||u||Q||p||D||Z||BA||RA||$A||qA||!_||Ee.isActive)return;if(Pe.preventDefault(),wA){Xi();return}const Ct=Ee.getDocAnnotations(),ei=Array.from(Ct.values()).some(nr=>nr.annotations.length>0||nr.globalAttachments.length>0);if(li.length===0&&Dr.length===0&&!ei){if(eA==="opencode"){const nr=pe();if(nr){R(nr),S(!0);return}}tn()}else Rn()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,C,u,Q,p,D,Z,BA,RA,$A,qA,_,Ee.isActive,t.length,vi.length,wA,eA,pe]);const os=ee=>{i(Pe=>[...Pe,ee]),n(ee.id),N(!0)},Nn=Qn.useCallback(ee=>{n(ee),ee&&window.innerWidth<768&&N(!0)},[]),_o=ee=>{_e.current?.removeHighlight(ee),i(Pe=>Pe.filter(Xe=>Xe.id!==ee)),r===ee&&n(null)},wr=fHA({blocks:a,annotations:t,addAnnotation:os,removeAnnotation:_o}),Uh=ee=>{const Pe=li.find(Xe=>Xe.id===ee);if(Pe?.source&&vi.some(Xe=>Xe.id===ee)){ss(ee),r===ee&&n(null);return}ee.startsWith("ann-checkbox-")&&Pe&&wr.revertOverride(Pe.blockId),_o(ee)},UC=(ee,Pe)=>{if(li.find(Ct=>Ct.id===ee)?.source&&vi.some(Ct=>Ct.id===ee)){cr(ee,Pe);return}i(Ct=>Ct.map(ei=>ei.id===ee?{...ei,...Pe}:ei))},zu=(ee,Pe)=>{i(Xe=>Xe.map(Ct=>Ct.author===ee?{...Ct,author:Pe}:Ct))},wm=ee=>{cA(Pe=>[...Pe,ee])},jR=ee=>{cA(Pe=>Pe.filter(Xe=>Xe.path!==ee))},_R=ee=>{},xl=nA.useMemo(()=>{const ee=Ee.getDocAnnotations(),Pe=Array.from(ee.values()).some(nr=>nr.annotations.length>0||nr.globalAttachments.length>0),Xe=li.length>0||EA.length>0,Ct=Dr.length>0;if(!Xe&&!Pe&&!Ct)return"User reviewed the document and has no feedback.";let ei=Xe?YmA(a,li,EA,UA==="message"?"Message Feedback":UA==="folder"?"Folder Feedback":UA==="file"?"File Feedback":"Plan Feedback",UA??"plan"):"";return Pe&&(ei+=HmA(ee)),Ct&&(ei+=PmA(Dr)),ei},[a,li,EA,Ee.getDocAnnotations,Dr]),jc=Qn.useMemo(()=>V8A(),[]),qu=Qn.useCallback(async ee=>{if(!(!jc||$A||!ht)){KA(!0);try{const Pe=await Z8A(ee,jc,ht);Pe&&(tA(Pe),setTimeout(()=>tA(null),4e3),Pe.type==="success"&&_A(ee===Mw.Approve?"approved":"denied"))}finally{KA(!1)}}},[jc,$A,ht]),XR=Qn.useCallback(()=>qu(Mw.Approve),[qu]),$R=Qn.useCallback(()=>qu(Mw.Feedback),[qu]),vm=()=>{const ee=new Blob([xl],{type:"text/plain"}),Pe=URL.createObjectURL(ee),Xe=document.createElement("a");Xe.href=Pe,Xe.download="annotations.md",Xe.click(),URL.revokeObjectURL(Pe),tA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>tA(null),3e3)},_c=async ee=>{const Pe={};if(ee==="obsidian"){const Ct=LI(),ei=TI(Ct);ei&&(Pe.obsidian={vaultPath:ei,folder:Ct.folder||"plannotator",plan:e,...Ct.filenameFormat&&{filenameFormat:Ct.filenameFormat},...Ct.filenameSeparator&&Ct.filenameSeparator!=="space"&&{filenameSeparator:Ct.filenameSeparator}})}if(ee==="bear"){const Ct=DE();Pe.bear={plan:e,customTags:Ct.customTags,tagPosition:Ct.tagPosition}}if(ee==="octarine"){const Ct=Bd();Pe.octarine={plan:e,workspace:Ct.workspace,folder:Ct.folder||"plannotator"}}const Xe=ee==="obsidian"?"Obsidian":ee==="bear"?"Bear":"Octarine";try{const nr=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe)})).json()).results?.[ee];nr?.success?tA({type:"success",message:`Saved to ${Xe}`}):tA({type:"error",message:nr?.error||"Save failed"})}catch{tA({type:"error",message:"Save failed"})}setTimeout(()=>tA(null),3e3)},Sm=async()=>{const ee=j9A(window.location.origin);try{await navigator.clipboard.writeText(ee),tA({type:"success",message:"Agent instructions copied"})}catch{tA({type:"error",message:"Failed to copy"})}setTimeout(()=>tA(null),3e3)},AN=async()=>{try{await navigator.clipboard.writeText(ht),tA({type:"success",message:"Share link copied"})}catch{tA({type:"error",message:"Failed to copy"})}setTimeout(()=>tA(null),3e3)};nA.useEffect(()=>{const ee=Pe=>{if(Pe.key!=="s"||!(Pe.metaKey||Pe.ctrlKey))return;const Xe=Pe.target?.tagName;if(Xe==="INPUT"||Xe==="TEXTAREA"||l||u||Q||p||D||Z||BA||RA||!_)return;Pe.preventDefault();const Ct=uIA(),ei=vZ(),nr=DE().enabled,dr=tD();Ct==="download"?vm():Ct==="obsidian"&&ei?_c("obsidian"):Ct==="bear"&&nr?_c("bear"):Ct==="octarine"&&dr?_c("octarine"):(Ne("notes"),I(!0))};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,u,Q,p,D,Z,BA,RA,_,e,xl]),nA.useEffect(()=>{const ee=Pe=>{if(Pe.key!=="p"||!(Pe.metaKey||Pe.ctrlKey))return;const Xe=Pe.target?.tagName;Xe==="INPUT"||Xe==="TEXTAREA"||l||u||Q||p||D||Z||BA||RA||(Pe.preventDefault(),window.print())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,u,Q,p,D,Z,BA,RA]);const Ll=nA.useMemo(()=>UmA(eA),[eA]),Wu=nA.useMemo(()=>({compact:832,default:1040,wide:1280})[z.planWidth]??832,[z.planWidth]);return w.jsx(UYA,{defaultTheme:"dark",children:w.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[w.jsxs("header",{className:"h-12 flex items-center justify-between px-2 md:px-4 border-b border-border/50 bg-card/50 backdrop-blur-xl sticky top-0 z-[50]",children:[w.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:w.jsx("a",{href:"https://plannotator.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 md:gap-2 hover:opacity-80 transition-opacity",children:w.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),w.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[jc&&!_&&Ri&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),w.jsx(NT,{onClick:$R,disabled:$A||!ht,isLoading:$A,title:"Send feedback to bot"}),w.jsx(UZ,{onClick:XR,disabled:$A||!ht,isLoading:$A,title:"Approve design and notify bot"})]}),_&&!Ee.isActive&&Ge.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsxs("button",{onClick:Ge.copy,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-muted text-foreground hover:bg-muted/80 border border-border",title:"Copy plan content",children:[w.jsx("span",{className:"hidden md:inline",children:"Copy"}),w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]}),w.jsx("button",{onClick:Ge.done,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-success text-success-foreground hover:opacity-90",title:"Close archive",children:"Done"})]}),_&&(!Ee.isActive||wA)&&!Ge.archiveMode&&w.jsxs(w.Fragment,{children:[wA?w.jsxs(w.Fragment,{children:[w.jsx(K8A,{onClick:()=>li.length>0||Dr.length>0||Ee.docAnnotationCount>0||EA.length>0?y(!0):zr(),disabled:$A||qA,isLoading:qA}),(li.length>0||Dr.length>0||Ee.docAnnotationCount>0||EA.length>0)&&w.jsx(NT,{onClick:Xi,disabled:$A||qA,isLoading:$A,label:"Send Annotations",title:"Send Annotations"})]}):w.jsx(NT,{onClick:()=>{const ee=Ee.getDocAnnotations(),Pe=Array.from(ee.values()).some(Xe=>Xe.annotations.length>0||Xe.globalAttachments.length>0);li.length===0&&Dr.length===0&&!Pe?d(!0):Rn()},disabled:$A,isLoading:$A,label:"Send Feedback",title:"Send Feedback"}),!wA&&w.jsxs("div",{className:"relative group/approve",children:[w.jsx(UZ,{onClick:()=>{if(eA==="claude-code"&&li.length>0){f(!0);return}if(eA==="opencode"){const ee=pe();if(ee){R(ee),S(!0);return}}tn()},disabled:$A,isLoading:$A,dimmed:(eA==="claude-code"||eA==="gemini-cli")&&li.length>0}),(eA==="claude-code"||eA==="gemini-cli")&&li.length>0&&w.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[w.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),w.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),Ll," doesn't support feedback on approval. Your annotations won't be seen."]})]}),w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),w.jsx("button",{onClick:()=>N(!b),className:`p-1.5 rounded-md text-xs font-medium transition-all ${b?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:b?"Hide annotations":"Show annotations",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),w.jsx("div",{className:"hidden",children:w.jsx(U8A,{taterMode:O,onTaterModeChange:$e,onIdentityChange:zu,origin:eA,onUIPreferencesChange:Y,externalOpen:T,onExternalClose:()=>L(!1),gitUser:iA})}),w.jsx(f9A,{appVersion:"0.17.8",hasNewSettingsHints:K,onOpenSettings:()=>{K&&(fIA(),H(!1)),L(!0)},onOpenExport:()=>{Ne(void 0),I(!0)},onCopyAgentInstructions:Sm,onDownloadAnnotations:vm,onPrint:()=>window.print(),onCopyShareLink:AN,onOpenImport:()=>E(!0),onSaveToObsidian:()=>_c("obsidian"),onSaveToBear:()=>_c("bear"),onSaveToOctarine:()=>_c("octarine"),sharingEnabled:xA,isApiMode:_,agentInstructionsEnabled:_&&!Ge.archiveMode&&!wA,obsidianConfigured:vZ(),bearConfigured:DE().enabled,octarineConfigured:tD()})]})]}),Ee.error&&w.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[w.jsx("span",{className:"text-xs text-destructive",children:Ee.error}),w.jsx("button",{onClick:Ee.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),w.jsx(zlA.Provider,{value:jt,children:w.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${Li?"select-none":""}`,children:[O&&w.jsx($YA,{}),!Fe.isOpen&&w.jsx(X9A,{activeTab:Fe.activeTab,onToggleTab:Fe.toggleTab,hasDiff:JA.hasPreviousVersion,showVersionsTab:qe!==null&&qe.totalVersions>1,showFilesTab:st&&!Ge.archiveMode,hasFileAnnotations:Re,className:"hidden lg:flex absolute left-0 top-0 z-10"}),Fe.isOpen&&w.jsxs(w.Fragment,{children:[w.jsx(lHA,{activeTab:Fe.activeTab,onTabChange:ee=>{Fe.toggleTab(ee),ee==="archive"&&!Ge.archiveMode&&Ge.fetchPlans()},onClose:Fe.close,width:Jt.width,blocks:a,annotations:t,activeSection:as,onTocNavigate:_R,linkedDocFilepath:Ee.filepath,onLinkedDocBack:Ee.isActive?xe:void 0,backLabel:Tt,showFilesTab:st&&!Ge.archiveMode,fileAnnotationCounts:ke,highlightedFiles:ct,fileBrowser:rt,onFilesSelectFile:_i,onFilesFetchAll:()=>rt.fetchAll(gi),onFilesRetryVaultDir:ee=>rt.addVaultDir(ee),hasFileAnnotations:Re,showVersionsTab:qe!==null&&qe.totalVersions>1,versionInfo:qe,versions:JA.versions,selectedBaseVersion:JA.diffBaseVersion,onSelectBaseVersion:JA.selectBaseVersion,isPlanDiffActive:ge,hasPreviousVersion:JA.hasPreviousVersion,onActivatePlanDiff:()=>oe(!0),isLoadingVersions:JA.isLoadingVersions,isSelectingVersion:JA.isSelectingVersion,fetchingVersion:JA.fetchingVersion,onFetchVersions:JA.fetchVersions,showArchiveTab:_&&!wA,archivePlans:Ge.plans,selectedArchiveFile:Ge.selectedFile,onArchiveSelect:Ge.select,isLoadingArchive:Ge.isLoading}),w.jsx(qZ,{...Jt.handleProps,className:"hidden lg:block",side:"left"})]}),w.jsxs(Jp,{element:"main",className:`flex-1 min-w-0 bg-grid ${Fe.isOpen?"":"lg:pl-[30px]"}`,"data-print-region":"document",onViewportReady:Pt,children:[w.jsx(SB,{isOpen:!!DA,onClose:XA,onConfirm:ue,title:"Draft Recovered",message:DA?`Found ${DA.count} annotation${DA.count!==1?"s":""} from ${DA.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),w.jsxs("div",{ref:q,className:"min-h-full flex flex-col items-center px-2 py-3 md:px-10 md:py-8 xl:px-16 relative z-10",children:[!ge&&!Ge.archiveMode&&z.stickyActionsEnabled&&w.jsx(VYA,{inputMethod:G,onInputMethodChange:kt,mode:x,onModeChange:Ht,taterMode:O,repoInfo:re,planDiffStats:JA.diffStats,isPlanDiffActive:ge,hasPreviousVersion:JA.hasPreviousVersion,onPlanDiffToggle:()=>oe(!ge),archiveInfo:Ge.currentInfo,maxWidth:Wu,remountToken:Ee.isActive?`doc:${Ee.filepath}`:"plan"}),!ge&&!Ge.archiveMode&&w.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:Wu},children:w.jsx(eIA,{inputMethod:G,onInputMethodChange:kt,mode:x,onModeChange:Ht,taterMode:O})}),JA.diffBlocks&&JA.diffStats&&w.jsx("div",{className:"w-full flex justify-center",style:{display:ge?void 0:"none"},children:w.jsx(hHA,{diffBlocks:JA.diffBlocks,diffStats:JA.diffStats,diffMode:Se,onDiffModeChange:be,onPlanDiffToggle:()=>oe(!1),repoInfo:re,baseVersionLabel:JA.diffBaseVersion!=null?`v${JA.diffBaseVersion}`:void 0,baseVersion:JA.diffBaseVersion??void 0,maxWidth:Wu,annotations:Br,onAddAnnotation:os,onSelectAnnotation:Nn,selectedAnnotationId:r,mode:x})}),UA==="folder"&&!e&&!Ee.isActive&&w.jsx("div",{className:"w-full flex justify-center",children:w.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[w.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),w.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),w.jsx("div",{className:"w-full flex justify-center",style:{display:ge&&JA.diffBlocks||UA==="folder"&&!e&&!Ee.isActive?"none":void 0},children:w.jsx(E5A,{ref:_e,blocks:a,markdown:e,frontmatter:o,annotations:Ts,onAddAnnotation:os,onSelectAnnotation:Nn,selectedAnnotationId:r,mode:x,inputMethod:G,taterMode:O,globalAttachments:EA,onAddGlobalAttachment:wm,onRemoveGlobalAttachment:jR,repoInfo:re,stickyActions:z.stickyActionsEnabled,planDiffStats:Ee.isActive?null:JA.diffStats,isPlanDiffActive:ge,onPlanDiffToggle:()=>oe(!ge),hasPreviousVersion:!Ee.isActive&&JA.hasPreviousVersion,showDemoBadge:!_&&!Et&&!Ri,maxWidth:Wu,onOpenLinkedDoc:pi,linkedDocInfo:Ee.isActive?{filepath:Ee.filepath,onBack:xe,label:rt.dirs.find(ee=>ee.path===rt.activeDirPath)?.isVault?"Vault File":rt.activeFile?"File":void 0,backLabel:Tt}:null,imageBaseDir:ie,copyLabel:UA==="message"?"Copy message":UA==="file"||UA==="folder"?"Copy file":void 0,archiveInfo:Ge.currentInfo,onToggleCheckbox:wr.toggle,checkboxOverrides:wr.overrides,actionsLabelMode:j},Ee.isActive?`doc:${Ee.filepath}`:"plan")})]})]}),b&&w.jsx(qZ,{...pt.handleProps,className:"hidden md:block",side:"right"}),w.jsx(RYA,{isOpen:b,blocks:a,annotations:li,selectedId:r,onSelect:n,onDelete:Uh,onEdit:UC,sharingEnabled:xA,width:pt.width,editorAnnotations:Dr,onDeleteEditorAnnotation:Ls,onClose:()=>N(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(DiA(xl))},onShare:ht?()=>{N(!1),Ne("share"),I(!0)}:void 0,otherFileAnnotations:De,onOtherFileAnnotationsClick:FA})]})}),w.jsx(GYA,{isOpen:l,onClose:()=>{I(!1),Ne(void 0)},shareUrl:ht,shareUrlSize:Hi,shortShareUrl:ii,isGeneratingShortUrl:An,shortUrlError:Ir,onGenerateShortUrl:Ve,annotationsOutput:xl,annotationCount:li.length,taterSprite:O?w.jsx(v5,{}):void 0,sharingEnabled:xA,markdown:e,isApiMode:_,initialTab:se}),w.jsx(OYA,{isOpen:C,onClose:()=>E(!1),onImport:W,shareBaseUrl:TA}),w.jsx(SB,{isOpen:u,onClose:()=>d(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Ll} will use your annotations to revise the plan.`,variant:"info"}),w.jsx(SB,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),tn()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:[Ll," doesn't yet support feedback on approval. Your ",li.length," annotation",li.length!==1?"s":""," will be lost."]}),subMessage:w.jsxs(w.Fragment,{children:["To send feedback, use ",w.jsx("strong",{children:"Send Feedback"})," instead.",w.jsx("br",{}),w.jsx("br",{}),"Want this feature? Upvote these issues:",w.jsx("br",{}),w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/15755",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#15755"})]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(SB,{isOpen:p,onClose:()=>y(!1),onConfirm:()=>{y(!1),zr()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:["You have ",li.length+Dr.length+Ee.docAnnotationCount+EA.length," annotation",li.length+Dr.length+Ee.docAnnotationCount+EA.length!==1?"s":""," that will be lost if you close."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(SB,{isOpen:D,onClose:()=>S(!1),onConfirm:()=>{S(!1),tn()},title:"Agent Not Found",message:k,subMessage:w.jsxs(w.Fragment,{children:["You can change the agent in ",w.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(SB,{isOpen:!!$&&!_,onClose:CA,title:"Shared Plan Could Not Be Loaded",message:$,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),ve&&w.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${ve.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:ve.message}),w.jsx(A9A,{submitted:RA,title:Ge.archiveMode?"Archive Closed":RA==="exited"?"Session Closed":RA==="approved"?"Plan Approved":wA?"Annotations Sent":"Feedback Sent",subtitle:RA==="exited"?"Annotation session closed without feedback.":Ge.archiveMode?"You can reopen with plannotator archive.":RA==="approved"?`${Ll} will proceed with the implementation.`:wA?`${Ll} will address your annotations on the ${UA==="message"?"message":UA==="folder"?"files":"file"}.`:`${Ll} will revise the plan based on your annotations.`,agentLabel:Ll}),w.jsx(a9A,{origin:eA,isWSL:gA}),w.jsx(FiA,{isOpen:!!BA,imageSrc:BA?.blobUrl??"",initialName:BA?.initialName,onAccept:xt,onClose:rr}),w.jsx(R9A,{isOpen:Z,onComplete:ee=>{kA(ee),mA(!1)}})]})})},UIA=document.getElementById("root");if(!UIA)throw new Error("Could not find root element to mount to");const mHA=OmA.createRoot(UIA);mHA.render(w.jsx(Qn.StrictMode,{children:w.jsx(pHA,{})}));class Bs{constructor(A,t,i){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=i}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new Bs(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class $s{constructor(A,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=A,this.loc=t}range(A,t){return new $s(t,Bs.range(this,A))}}class je{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var i="KaTeX parse error: "+A,r,n,a=t&&t.loc;if(a&&a.start<=a.end){var s=a.lexer.input;r=a.start,n=a.end,r===s.length?i+=" at end of input: ":i+=" at position "+(r+1)+": ";var o=s.slice(r,n).replace(/[^]/g,"$&̲"),g;r>15?g="…"+s.slice(r-15,r):g=s.slice(0,r);var l;n+15<s.length?l=s.slice(n,n+15)+"…":l=s.slice(n),i+=g+o+l}var I=new Error(i);return I.name="ParseError",I.__proto__=je.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}je.prototype.__proto__=Error.prototype;var yHA=function(A,t){return A===void 0?t:A},DHA=/([A-Z])/g,wHA=function(A){return A.replace(DHA,"-$1").toLowerCase()},vHA={"&":"&",">":">","<":"<",'"':""","'":"'"},SHA=/[&><"']/g;function bHA(e){return String(e).replace(SHA,A=>vHA[A])}var KIA=function e(A){return A.type==="ordgroup"||A.type==="color"?A.body.length===1?e(A.body[0]):A:A.type==="font"?e(A.body):A},RHA=function(A){var t=KIA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},NHA=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},MHA=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Ui={deflt:yHA,escape:bHA,hyphenate:wHA,getBaseElem:KIA,isCharacterBox:RHA,protocolFromUrl:MHA},p0={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,A)=>(A.push(e),A)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function kHA(e){if(e.default)return e.default;var A=e.type,t=Array.isArray(A)?A[0]:A;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class M5{constructor(A){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,A=A||{};for(var t in p0)if(p0.hasOwnProperty(t)){var i=p0[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:kHA(i)}}reportNonstrict(A,t,i){var r=this.strict;if(typeof r=="function"&&(r=r(A,t,i)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new je("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),i);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,i){var r=this.strict;if(typeof r=="function")try{r=r(A,t,i)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=Ui.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class pI{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return Al[xHA[this.id]]}sub(){return Al[LHA[this.id]]}fracNum(){return Al[THA[this.id]]}fracDen(){return Al[FHA[this.id]]}cramp(){return Al[GHA[this.id]]}text(){return Al[OHA[this.id]]}isTight(){return this.size>=2}}var k5=0,bS=1,hd=2,yc=3,ep=4,To=5,jd=6,qa=7,Al=[new pI(k5,0,!1),new pI(bS,0,!0),new pI(hd,1,!1),new pI(yc,1,!0),new pI(ep,2,!1),new pI(To,2,!0),new pI(jd,3,!1),new pI(qa,3,!0)],xHA=[ep,To,ep,To,jd,qa,jd,qa],LHA=[To,To,To,To,qa,qa,qa,qa],THA=[hd,yc,ep,To,jd,qa,jd,qa],FHA=[yc,yc,To,To,qa,qa,qa,qa],GHA=[bS,bS,yc,yc,To,To,qa,qa],OHA=[k5,bS,hd,yc,hd,yc,hd,yc],Gt={DISPLAY:Al[k5],TEXT:Al[hd],SCRIPT:Al[ep],SCRIPTSCRIPT:Al[jd]},VO=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function UHA(e){for(var A=0;A<VO.length;A++)for(var t=VO[A],i=0;i<t.blocks.length;i++){var r=t.blocks[i];if(e>=r[0]&&e<=r[1])return t.name}return null}var kw=[];VO.forEach(e=>e.blocks.forEach(A=>kw.push(...A)));function YIA(e){for(var A=0;A<kw.length;A+=2)if(e>=kw[A]&&e<=kw[A+1])return!0;return!1}var RB=80,KHA=function(A,t){return"M95,"+(622+A+t)+`
|
|
980
|
+
`;function fHA({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:i}){const[r,n]=nA.useState(new Map),a=nA.useRef(e);a.current=e;const s=nA.useRef(A);s.current=A,nA.useEffect(()=>{if(r.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...r.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(u=>E.delete(u)),E})},[e]);const o=nA.useCallback((l,I)=>{const C=a.current,E=s.current,u=C.find(Q=>Q.id===l);if(u&&I===u.checked)n(f=>{const p=new Map(f);return p.delete(l),p}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id)),n(f=>{const p=new Map(f);return p.set(l,I),p}),u){const f=C.indexOf(u);let p="";for(let k=f-1;k>=0;k--)if(C[k].type==="heading"){p=C[k].content;break}const y=I?"Mark as completed":"Mark as not completed",D=p?` (under "${p}")`:` (line ${u.startLine})`,S={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:u.content.length,type:oi.COMMENT,text:`${y}${D}: ${u.content}`,originalText:u.content,createdA:Date.now()};t(S)}},[t,i]),g=nA.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:r,toggle:o,revertOverride:g}}const pHA=()=>{const[e,A]=nA.useState(QHA),[t,i]=nA.useState([]),[r,n]=nA.useState(null),[a,s]=nA.useState([]),[o,g]=nA.useState(null),[l,I]=nA.useState(!1),[C,E]=nA.useState(!1),[u,d]=nA.useState(!1),[Q,f]=nA.useState(!1),[p,y]=nA.useState(!1),[D,S]=nA.useState(!1),[k,R]=nA.useState(""),[b,N]=nA.useState(()=>window.innerWidth>=768),[T,L]=nA.useState(!1),[K,H]=nA.useState(()=>QIA()),[x,U]=nA.useState(o9A),[G,F]=nA.useState(c9A),[O,P]=nA.useState(()=>Ye.getItem("plannotator-tater-mode")==="true"),[z,Y]=nA.useState(()=>PO()),q=nA.useRef(null),[j,X]=nA.useState("full");nA.useLayoutEffect(()=>{const ee=q.current;if(!ee)return;const Pe=Ct=>Ct>=800?"full":Ct>=680?"short":"icon";X(Pe(ee.getBoundingClientRect().width));const Xe=new ResizeObserver(([Ct])=>{const ei=Pe(Ct.contentRect.width);X(nr=>nr===ei?nr:ei)});return Xe.observe(ee),()=>Xe.disconnect()},[]);const[_,oA]=nA.useState(!1),[eA,dA]=nA.useState(null),[iA,sA]=nA.useState(),[gA,rA]=nA.useState(!1),[EA,cA]=nA.useState([]),[wA,uA]=nA.useState(!1),[UA,aA]=nA.useState(null),[Ae,bA]=nA.useState(),[ie,ae]=nA.useState(void 0),[Ce,GA]=nA.useState(!0),[$A,KA]=nA.useState(!1),[qA,ce]=nA.useState(!1),[RA,_A]=nA.useState(null),[BA,vA]=nA.useState(null),[Z,mA]=nA.useState(!1),[fA,kA]=nA.useState("bypassPermissions"),[xA,hA]=nA.useState(!0),[TA,MA]=nA.useState(void 0),[HA,jA]=nA.useState(void 0),[re,yA]=nA.useState(null),[PA,YA]=nA.useState(null);nA.useEffect(()=>{document.title=re?`${re.display} · Plannotator`:"Plannotator"},[re]);const[se,Ne]=nA.useState(),[ve,tA]=nA.useState(null),[ge,oe]=nA.useState(!1),[Se,be]=nA.useState("clean"),[Ke,Ue]=nA.useState(null),[qe,St]=nA.useState(null),_e=nA.useRef(null),{ref:Dt,viewport:jt,onViewportReady:Pt}=d9A();B9A();const pt=zZ({storageKey:"plannotator-panel-width"}),Jt=zZ({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),Li=pt.isDragging||Jt.isDragging,Fe=N9A(PO().tocEnabled);nA.useEffect(()=>{z.tocEnabled?Fe.open("toc"):Fe.close()},[z.tocEnabled]),nA.useEffect(()=>{Fe.activeTab==="toc"&&ge&&oe(!1)},[Fe.activeTab]),nA.useEffect(()=>{if(!ge)return;const ee=Pe=>{Pe.key==="Escape"&&oe(!1)};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[ge]);const JA=G9A(e,Ke,qe),Ee=O9A({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:EA,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:cA,viewerRef:_e,sidebar:Fe,sourceFilePath:Ae}),Ge=P9A({markdown:e,viewerRef:_e,linkedDocHook:Ee,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setSubmitted:_A}),rt=_9A(),ti=nA.useMemo(()=>SZ()?TI(LI()):"",[z]),st=nA.useMemo(()=>!!PA||OZ()||SZ(),[PA,z]),gi=nA.useMemo(()=>{const ee=PA?[PA]:[],Pe=OZ()?R5().directories:[];return[...new Set([...ee,...Pe])]},[PA,z]);nA.useEffect(()=>{st||rt.setActiveFile(null)},[st]),nA.useEffect(()=>{ti||rt.clearVaultDirs()},[ti]),nA.useEffect(()=>{if(Fe.activeTab==="files"&&st){if(gi.length>0){const ee=rt.dirs.filter(Xe=>!Xe.isVault).map(Xe=>Xe.path);(gi.some(Xe=>!ee.includes(Xe))||ee.some(Xe=>!gi.includes(Xe)))&&rt.fetchAll(gi)}ti&&!rt.dirs.find(ee=>ee.isVault&&ee.path===ti&&!ee.error)&&rt.addVaultDir(ti)}},[Fe.activeTab,st,gi,ti]);const _i=Qn.useCallback((ee,Pe)=>{const Ct=rt.dirs.find(ei=>ei.path===Pe)?.isVault?ei=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Pe)}&path=${encodeURIComponent(ei)}`:ei=>`/api/doc?path=${encodeURIComponent(ei)}&base=${encodeURIComponent(Pe)}`;Ee.open(ee,Ct,"files"),rt.setActiveFile(ee)},[Ee,rt]),pi=Qn.useCallback(ee=>{if(rt.dirs.find(Xe=>Xe.path===rt.activeDirPath)?.isVault&&rt.activeDirPath)Ee.open(ee,Xe=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(rt.activeDirPath)}&path=${encodeURIComponent(Xe)}`);else if(rt.activeFile&&rt.activeDirPath){const Xe=Ee.filepath?.replace(/\/[^/]+$/,"")||rt.activeDirPath;Ee.open(ee,Ct=>`/api/doc?path=${encodeURIComponent(Ct)}&base=${encodeURIComponent(Xe)}`)}else{const Xe=Ee.filepath?Ee.filepath.replace(/\/[^/]+$/,""):ie;Xe?Ee.open(ee,Ct=>`/api/doc?path=${encodeURIComponent(Ct)}&base=${encodeURIComponent(Xe)}`):Ee.open(ee)}},[rt.dirs,rt.activeDirPath,rt.activeFile,Ee,ie]),xe=Qn.useCallback(()=>{Ee.back(),rt.setActiveFile(null),Ge.clearSelection()},[Ee,rt,Ge]),ye=nA.useMemo(()=>{const ee=new Map;for(const[Pe,Xe]of Ee.getDocAnnotations()){const Ct=Xe.annotations.length+Xe.globalAttachments.length;Ct>0&&ee.set(Pe,Ct)}return ee},[Ee.getDocAnnotations,t,EA]),ke=nA.useMemo(()=>{const ee=rt.dirs.map(Xe=>Xe.path);if(ee.length===0)return ye;const Pe=new Map;for(const[Xe,Ct]of ye)ee.some(ei=>Xe.startsWith(ei+"/"))&&Pe.set(Xe,Ct);return Pe},[ye,rt.dirs]),Re=ke.size>0,De=nA.useMemo(()=>{const ee=Ee.filepath;let Pe=0,Xe=0;for(const[Ct,ei]of ye)Ct!==ee&&(Pe+=ei,Xe++);return Pe>0?{count:Pe,files:Xe}:void 0},[ye,Ee.filepath]),[ct,LA]=nA.useState(),Ji=Qn.useRef(),FA=Qn.useCallback(()=>{const ee=new Set(ye.keys());ee.size!==0&&((!Fe.isOpen||Fe.activeTab!=="files")&&Fe.open("files"),Ji.current&&clearTimeout(Ji.current),LA(void 0),requestAnimationFrame(()=>{LA(ee),Ji.current=setTimeout(()=>LA(void 0),1200)}))},[ye,Fe,Re]),Tt=UA==="folder"?"file list":UA==="file"?"file":UA==="message"?"message":"plan",ns=nA.useMemo(()=>a.filter(ee=>ee.type==="heading").length,[a]),as=j8A(Dt,ns,jt),{editorAnnotations:Dr,deleteEditorAnnotation:Ls}=z9A(),{externalAnnotations:vi,updateExternalAnnotation:cr,deleteExternalAnnotation:ss}=V9A({enabled:_}),{reset:ta}=Z9A({viewerRef:_e,externalAnnotations:vi,enabled:_&&!Ee.isActive&&!ge,planKey:e}),li=nA.useMemo(()=>vi.length===0?t:[...t.filter(Pe=>Pe.source?!vi.some(Xe=>Xe.source===Pe.source&&Xe.type===Pe.type&&Xe.originalText===Pe.originalText):!0),...vi],[t,vi]),Br=nA.useMemo(()=>li.filter(ee=>!!ee.diffContext),[li]),Ts=nA.useMemo(()=>li.filter(ee=>!ee.diffContext),[li]),{isSharedSession:Ri,isLoadingShared:Et,shareUrl:ht,shareUrlSize:Hi,shortShareUrl:ii,isGeneratingShortUrl:An,shortUrlError:Ir,pendingSharedAnnotations:Cn,clearPendingSharedAnnotations:en,generateShortUrl:Ve,importFromShareUrl:W,shareLoadError:$,clearShareLoadError:CA}=W8A(e,li,EA,A,i,cA,()=>{GA(!1)},TA,HA),{draftBanner:DA,restoreDraft:OA,dismissDraft:XA}=H9A({annotations:li,globalAttachments:EA,isApiMode:_,isSharedSession:Ri,submitted:!!RA}),ue=Qn.useCallback(()=>{const{annotations:ee,globalAttachments:Pe}=OA();ee.length>0&&(i(ee),Pe.length>0&&cA(Pe),setTimeout(()=>{_e.current?.applySharedAnnotations(ee.filter(Xe=>!Xe.diffContext))},100))},[OA]),{getAgentWarning:pe}=BIA(eA);nA.useEffect(()=>{if(Cn&&Cn.length>0){const ee=setTimeout(()=>{_e.current?.clearAllHighlights(),_e.current?.applySharedAnnotations(Cn.filter(Pe=>!Pe.diffContext)),en(),ta()},100);return()=>clearTimeout(ee)}},[Cn,en,ta]);const $e=ee=>{P(ee),Ye.setItem("plannotator-tater-mode",String(ee))},Ht=ee=>{U(ee),g9A(ee)},kt=ee=>{F(ee),I9A(ee)};u9A(G,kt),nA.useEffect(()=>{Et||Ri||fetch("/api/plan").then(ee=>{if(!ee.ok)throw new Error("Not in API mode");return ee.json()}).then(ee=>{fn.init(ee.serverConfig),sA(ee.serverConfig?.gitUser),ee.mode==="archive"?(A(ee.plan||""),ee.archivePlans&&Ge.init(ee.archivePlans),Ge.fetchPlans(),hA(!1),Fe.open("archive")):ee.mode==="annotate-folder"?A(""):ee.plan&&A(ee.plan),oA(!0),(ee.mode==="annotate"||ee.mode==="annotate-last"||ee.mode==="annotate-folder")&&uA(!0),ee.mode==="annotate-folder"&&Fe.open("files"),ee.mode&&ee.mode!=="archive"&&aA(ee.mode==="annotate-last"?"message":ee.mode==="annotate-folder"?"folder":"file"),ee.filePath&&(ae(ee.mode==="annotate-folder"?ee.filePath:ee.filePath.replace(/\/[^/]+$/,"")),ee.mode==="annotate"&&bA(ee.filePath)),ee.sharingEnabled!==void 0&&hA(ee.sharingEnabled),ee.shareBaseUrl&&MA(ee.shareBaseUrl),ee.pasteApiUrl&&jA(ee.pasteApiUrl),ee.repoInfo&&yA(ee.repoInfo),ee.projectRoot&&YA(ee.projectRoot),ee.previousPlan!==void 0&&Ue(ee.previousPlan),ee.versionInfo&&St(ee.versionInfo),ee.origin&&(dA(ee.origin),ee.origin==="claude-code"&&l8A()&&mA(!0),kA(IIA().mode)),ee.isWSL&&rA(!0)}).catch(()=>{oA(!1)}).finally(()=>GA(!1))},[Et,Ri]),nA.useEffect(()=>{const{frontmatter:ee}=piA(e);g(ee),s(miA(e))},[e]);const Ai=nA.useRef(!1),_t=nA.useRef({}),mt=nA.useRef(null);nA.useEffect(()=>{Ai.current=!1,_t.current={},mt.current=null},[e]),nA.useEffect(()=>{if(!_||!e||Ri||wA||Ge.archiveMode||Ai.current)return;const ee={},Pe=[],Xe=LI();if(Xe.autoSave&&Xe.enabled){const dr=TI(Xe);dr&&(ee.obsidian={vaultPath:dr,folder:Xe.folder||"plannotator",plan:e,...Xe.filenameFormat&&{filenameFormat:Xe.filenameFormat},...Xe.filenameSeparator&&Xe.filenameSeparator!=="space"&&{filenameSeparator:Xe.filenameSeparator}},Pe.push("Obsidian"))}const Ct=DE();Ct.autoSave&&Ct.enabled&&(ee.bear={plan:e,customTags:Ct.customTags,tagPosition:Ct.tagPosition},Pe.push("Bear"));const ei=Bd();if(ei.autoSave&&tD()&&(ee.octarine={plan:e,workspace:ei.workspace,folder:ei.folder||"plannotator"},Pe.push("Octarine")),Pe.length===0)return;Ai.current=!0;const nr=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}).then(dr=>dr.json()).then(dr=>{const Xo={...ee.obsidian?{obsidian:!!dr.results?.obsidian?.success}:{},...ee.bear?{bear:!!dr.results?.bear?.success}:{},...ee.octarine?{octarine:!!dr.results?.octarine?.success}:{}};_t.current=Xo;const KC=Pe.filter(Kh=>!dr.results?.[Kh.toLowerCase()]?.success);return KC.length===0?tA({type:"success",message:`Auto-saved to ${Pe.join(" & ")}`}):tA({type:"error",message:`Auto-save failed for ${KC.join(" & ")}`}),Xo}).catch(()=>(_t.current={},tA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>tA(null),3e3));mt.current=nr},[_,e,Ri,wA]),nA.useEffect(()=>{const ee=Pe=>{const Xe=Pe.clipboardData?.items;if(Xe){for(const Ct of Xe)if(Ct.type.startsWith("image/")){Pe.preventDefault();const ei=Ct.getAsFile();if(ei){const nr=Q3(ei.name,EA.map(Xo=>Xo.name)),dr=URL.createObjectURL(ei);vA({file:ei,blobUrl:dr,initialName:nr})}break}}};return document.addEventListener("paste",ee),()=>document.removeEventListener("paste",ee)},[EA]);const xt=async(ee,Pe,Xe)=>{if(BA)try{const Ct=new FormData,ei=Pe?new File([ee],"annotated.png",{type:"image/png"}):BA.file;Ct.append("file",ei);const nr=await fetch("/api/upload",{method:"POST",body:Ct});if(nr.ok){const dr=await nr.json();cA(Xo=>[...Xo,{path:dr.path,name:Xe}])}}catch{}finally{URL.revokeObjectURL(BA.blobUrl),vA(null)}},rr=()=>{BA&&(URL.revokeObjectURL(BA.blobUrl),vA(null))},tn=async()=>{KA(!0);try{const ee=LI(),Pe=DE(),Xe=Bd(),Ct=S5(),ei=wS(),nr=Pe.autoSave&&mt.current?await mt.current:_t.current,dr={};eA==="claude-code"&&(dr.permissionMode=fA);const Xo=a8A(Ct);Xo&&(dr.agentSwitch=Xo),dr.planSave={enabled:ei.enabled,...ei.customPath&&{customPath:ei.customPath}};const KC=TI(ee);ee.enabled&&KC&&(dr.obsidian={vaultPath:KC,folder:ee.folder||"plannotator",plan:e,...ee.filenameFormat&&{filenameFormat:ee.filenameFormat},...ee.filenameSeparator&&ee.filenameSeparator!=="space"&&{filenameSeparator:ee.filenameSeparator}}),Pe.enabled&&!(Pe.autoSave&&nr.bear)&&(dr.bear={plan:e,customTags:Pe.customTags,tagPosition:Pe.tagPosition}),tD()&&(dr.octarine={plan:e,workspace:Xe.workspace,folder:Xe.folder||"plannotator"});const Kh=Array.from(Ee.getDocAnnotations().values()).some(bm=>bm.annotations.length>0||bm.globalAttachments.length>0);(li.length>0||EA.length>0||Kh||Dr.length>0)&&(dr.feedback=xl),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(dr)}),_A("approved")}catch{KA(!1)}},Rn=async()=>{KA(!0);try{const ee=wS();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:xl,planSave:{enabled:ee.enabled,...ee.customPath&&{customPath:ee.customPath}}})}),_A("denied")}catch{KA(!1)}},Xi=async()=>{KA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:xl,annotations:li})}),_A("denied")}catch{KA(!1)}},zr=nA.useCallback(async()=>{ce(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)_A("exited");else throw new Error("Failed to exit")}catch{ce(!1)}},[]);nA.useEffect(()=>{const ee=Pe=>{if(Pe.key!=="Enter"||!(Pe.metaKey||Pe.ctrlKey))return;const Xe=Pe.target?.tagName;if(Xe==="INPUT"||Xe==="TEXTAREA"||l||C||u||Q||p||D||Z||BA||RA||$A||qA||!_||Ee.isActive)return;if(Pe.preventDefault(),wA){Xi();return}const Ct=Ee.getDocAnnotations(),ei=Array.from(Ct.values()).some(nr=>nr.annotations.length>0||nr.globalAttachments.length>0);if(li.length===0&&Dr.length===0&&!ei){if(eA==="opencode"){const nr=pe();if(nr){R(nr),S(!0);return}}tn()}else Rn()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,C,u,Q,p,D,Z,BA,RA,$A,qA,_,Ee.isActive,t.length,vi.length,wA,eA,pe]);const os=ee=>{i(Pe=>[...Pe,ee]),n(ee.id),N(!0)},Nn=Qn.useCallback(ee=>{n(ee),ee&&window.innerWidth<768&&N(!0)},[]),_o=ee=>{_e.current?.removeHighlight(ee),i(Pe=>Pe.filter(Xe=>Xe.id!==ee)),r===ee&&n(null)},wr=fHA({blocks:a,annotations:t,addAnnotation:os,removeAnnotation:_o}),Uh=ee=>{const Pe=li.find(Xe=>Xe.id===ee);if(Pe?.source&&vi.some(Xe=>Xe.id===ee)){ss(ee),r===ee&&n(null);return}ee.startsWith("ann-checkbox-")&&Pe&&wr.revertOverride(Pe.blockId),_o(ee)},UC=(ee,Pe)=>{if(li.find(Ct=>Ct.id===ee)?.source&&vi.some(Ct=>Ct.id===ee)){cr(ee,Pe);return}i(Ct=>Ct.map(ei=>ei.id===ee?{...ei,...Pe}:ei))},zu=(ee,Pe)=>{i(Xe=>Xe.map(Ct=>Ct.author===ee?{...Ct,author:Pe}:Ct))},wm=ee=>{cA(Pe=>[...Pe,ee])},jR=ee=>{cA(Pe=>Pe.filter(Xe=>Xe.path!==ee))},_R=ee=>{},xl=nA.useMemo(()=>{const ee=Ee.getDocAnnotations(),Pe=Array.from(ee.values()).some(nr=>nr.annotations.length>0||nr.globalAttachments.length>0),Xe=li.length>0||EA.length>0,Ct=Dr.length>0;if(!Xe&&!Pe&&!Ct)return"User reviewed the document and has no feedback.";let ei=Xe?YmA(a,li,EA,UA==="message"?"Message Feedback":UA==="folder"?"Folder Feedback":UA==="file"?"File Feedback":"Plan Feedback",UA??"plan"):"";return Pe&&(ei+=HmA(ee)),Ct&&(ei+=PmA(Dr)),ei},[a,li,EA,Ee.getDocAnnotations,Dr]),jc=Qn.useMemo(()=>V8A(),[]),qu=Qn.useCallback(async ee=>{if(!(!jc||$A||!ht)){KA(!0);try{const Pe=await Z8A(ee,jc,ht);Pe&&(tA(Pe),setTimeout(()=>tA(null),4e3),Pe.type==="success"&&_A(ee===Mw.Approve?"approved":"denied"))}finally{KA(!1)}}},[jc,$A,ht]),XR=Qn.useCallback(()=>qu(Mw.Approve),[qu]),$R=Qn.useCallback(()=>qu(Mw.Feedback),[qu]),vm=()=>{const ee=new Blob([xl],{type:"text/plain"}),Pe=URL.createObjectURL(ee),Xe=document.createElement("a");Xe.href=Pe,Xe.download="annotations.md",Xe.click(),URL.revokeObjectURL(Pe),tA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>tA(null),3e3)},_c=async ee=>{const Pe={};if(ee==="obsidian"){const Ct=LI(),ei=TI(Ct);ei&&(Pe.obsidian={vaultPath:ei,folder:Ct.folder||"plannotator",plan:e,...Ct.filenameFormat&&{filenameFormat:Ct.filenameFormat},...Ct.filenameSeparator&&Ct.filenameSeparator!=="space"&&{filenameSeparator:Ct.filenameSeparator}})}if(ee==="bear"){const Ct=DE();Pe.bear={plan:e,customTags:Ct.customTags,tagPosition:Ct.tagPosition}}if(ee==="octarine"){const Ct=Bd();Pe.octarine={plan:e,workspace:Ct.workspace,folder:Ct.folder||"plannotator"}}const Xe=ee==="obsidian"?"Obsidian":ee==="bear"?"Bear":"Octarine";try{const nr=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe)})).json()).results?.[ee];nr?.success?tA({type:"success",message:`Saved to ${Xe}`}):tA({type:"error",message:nr?.error||"Save failed"})}catch{tA({type:"error",message:"Save failed"})}setTimeout(()=>tA(null),3e3)},Sm=async()=>{const ee=j9A(window.location.origin);try{await navigator.clipboard.writeText(ee),tA({type:"success",message:"Agent instructions copied"})}catch{tA({type:"error",message:"Failed to copy"})}setTimeout(()=>tA(null),3e3)},AN=async()=>{try{await navigator.clipboard.writeText(ht),tA({type:"success",message:"Share link copied"})}catch{tA({type:"error",message:"Failed to copy"})}setTimeout(()=>tA(null),3e3)};nA.useEffect(()=>{const ee=Pe=>{if(Pe.key!=="s"||!(Pe.metaKey||Pe.ctrlKey))return;const Xe=Pe.target?.tagName;if(Xe==="INPUT"||Xe==="TEXTAREA"||l||u||Q||p||D||Z||BA||RA||!_)return;Pe.preventDefault();const Ct=uIA(),ei=vZ(),nr=DE().enabled,dr=tD();Ct==="download"?vm():Ct==="obsidian"&&ei?_c("obsidian"):Ct==="bear"&&nr?_c("bear"):Ct==="octarine"&&dr?_c("octarine"):(Ne("notes"),I(!0))};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,u,Q,p,D,Z,BA,RA,_,e,xl]),nA.useEffect(()=>{const ee=Pe=>{if(Pe.key!=="p"||!(Pe.metaKey||Pe.ctrlKey))return;const Xe=Pe.target?.tagName;Xe==="INPUT"||Xe==="TEXTAREA"||l||u||Q||p||D||Z||BA||RA||(Pe.preventDefault(),window.print())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,u,Q,p,D,Z,BA,RA]);const Ll=nA.useMemo(()=>UmA(eA),[eA]),Wu=nA.useMemo(()=>({compact:832,default:1040,wide:1280})[z.planWidth]??832,[z.planWidth]);return w.jsx(UYA,{defaultTheme:"dark",children:w.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[w.jsxs("header",{className:"h-12 flex items-center justify-between px-2 md:px-4 border-b border-border/50 bg-card/50 backdrop-blur-xl sticky top-0 z-[50]",children:[w.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:w.jsx("a",{href:"https://plannotator.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 md:gap-2 hover:opacity-80 transition-opacity",children:w.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),w.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[jc&&!_&&Ri&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),w.jsx(NT,{onClick:$R,disabled:$A||!ht,isLoading:$A,title:"Send feedback to bot"}),w.jsx(UZ,{onClick:XR,disabled:$A||!ht,isLoading:$A,title:"Approve design and notify bot"})]}),_&&!Ee.isActive&&Ge.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsxs("button",{onClick:Ge.copy,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-muted text-foreground hover:bg-muted/80 border border-border",title:"Copy plan content",children:[w.jsx("span",{className:"hidden md:inline",children:"Copy"}),w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]}),w.jsx("button",{onClick:Ge.done,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-success text-success-foreground hover:opacity-90",title:"Close archive",children:"Done"})]}),_&&(!Ee.isActive||wA)&&!Ge.archiveMode&&w.jsxs(w.Fragment,{children:[wA?w.jsxs(w.Fragment,{children:[w.jsx(K8A,{onClick:()=>li.length>0||Dr.length>0||Ee.docAnnotationCount>0||EA.length>0?y(!0):zr(),disabled:$A||qA,isLoading:qA}),(li.length>0||Dr.length>0||Ee.docAnnotationCount>0||EA.length>0)&&w.jsx(NT,{onClick:Xi,disabled:$A||qA,isLoading:$A,label:"Send Annotations",title:"Send Annotations"})]}):w.jsx(NT,{onClick:()=>{const ee=Ee.getDocAnnotations(),Pe=Array.from(ee.values()).some(Xe=>Xe.annotations.length>0||Xe.globalAttachments.length>0);li.length===0&&Dr.length===0&&!Pe?d(!0):Rn()},disabled:$A,isLoading:$A,label:"Send Feedback",title:"Send Feedback"}),!wA&&w.jsxs("div",{className:"relative group/approve",children:[w.jsx(UZ,{onClick:()=>{if(eA==="claude-code"&&li.length>0){f(!0);return}if(eA==="opencode"){const ee=pe();if(ee){R(ee),S(!0);return}}tn()},disabled:$A,isLoading:$A,dimmed:(eA==="claude-code"||eA==="gemini-cli")&&li.length>0}),(eA==="claude-code"||eA==="gemini-cli")&&li.length>0&&w.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[w.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),w.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),Ll," doesn't support feedback on approval. Your annotations won't be seen."]})]}),w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),w.jsx("button",{onClick:()=>N(!b),className:`p-1.5 rounded-md text-xs font-medium transition-all ${b?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:b?"Hide annotations":"Show annotations",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),w.jsx("div",{className:"hidden",children:w.jsx(U8A,{taterMode:O,onTaterModeChange:$e,onIdentityChange:zu,origin:eA,onUIPreferencesChange:Y,externalOpen:T,onExternalClose:()=>L(!1),gitUser:iA})}),w.jsx(f9A,{appVersion:"0.17.9",hasNewSettingsHints:K,onOpenSettings:()=>{K&&(fIA(),H(!1)),L(!0)},onOpenExport:()=>{Ne(void 0),I(!0)},onCopyAgentInstructions:Sm,onDownloadAnnotations:vm,onPrint:()=>window.print(),onCopyShareLink:AN,onOpenImport:()=>E(!0),onSaveToObsidian:()=>_c("obsidian"),onSaveToBear:()=>_c("bear"),onSaveToOctarine:()=>_c("octarine"),sharingEnabled:xA,isApiMode:_,agentInstructionsEnabled:_&&!Ge.archiveMode&&!wA,obsidianConfigured:vZ(),bearConfigured:DE().enabled,octarineConfigured:tD()})]})]}),Ee.error&&w.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[w.jsx("span",{className:"text-xs text-destructive",children:Ee.error}),w.jsx("button",{onClick:Ee.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),w.jsx(zlA.Provider,{value:jt,children:w.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${Li?"select-none":""}`,children:[O&&w.jsx($YA,{}),!Fe.isOpen&&w.jsx(X9A,{activeTab:Fe.activeTab,onToggleTab:Fe.toggleTab,hasDiff:JA.hasPreviousVersion,showVersionsTab:qe!==null&&qe.totalVersions>1,showFilesTab:st&&!Ge.archiveMode,hasFileAnnotations:Re,className:"hidden lg:flex absolute left-0 top-0 z-10"}),Fe.isOpen&&w.jsxs(w.Fragment,{children:[w.jsx(lHA,{activeTab:Fe.activeTab,onTabChange:ee=>{Fe.toggleTab(ee),ee==="archive"&&!Ge.archiveMode&&Ge.fetchPlans()},onClose:Fe.close,width:Jt.width,blocks:a,annotations:t,activeSection:as,onTocNavigate:_R,linkedDocFilepath:Ee.filepath,onLinkedDocBack:Ee.isActive?xe:void 0,backLabel:Tt,showFilesTab:st&&!Ge.archiveMode,fileAnnotationCounts:ke,highlightedFiles:ct,fileBrowser:rt,onFilesSelectFile:_i,onFilesFetchAll:()=>rt.fetchAll(gi),onFilesRetryVaultDir:ee=>rt.addVaultDir(ee),hasFileAnnotations:Re,showVersionsTab:qe!==null&&qe.totalVersions>1,versionInfo:qe,versions:JA.versions,selectedBaseVersion:JA.diffBaseVersion,onSelectBaseVersion:JA.selectBaseVersion,isPlanDiffActive:ge,hasPreviousVersion:JA.hasPreviousVersion,onActivatePlanDiff:()=>oe(!0),isLoadingVersions:JA.isLoadingVersions,isSelectingVersion:JA.isSelectingVersion,fetchingVersion:JA.fetchingVersion,onFetchVersions:JA.fetchVersions,showArchiveTab:_&&!wA,archivePlans:Ge.plans,selectedArchiveFile:Ge.selectedFile,onArchiveSelect:Ge.select,isLoadingArchive:Ge.isLoading}),w.jsx(qZ,{...Jt.handleProps,className:"hidden lg:block",side:"left"})]}),w.jsxs(Jp,{element:"main",className:`flex-1 min-w-0 bg-grid ${Fe.isOpen?"":"lg:pl-[30px]"}`,"data-print-region":"document",onViewportReady:Pt,children:[w.jsx(SB,{isOpen:!!DA,onClose:XA,onConfirm:ue,title:"Draft Recovered",message:DA?`Found ${DA.count} annotation${DA.count!==1?"s":""} from ${DA.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),w.jsxs("div",{ref:q,className:"min-h-full flex flex-col items-center px-2 py-3 md:px-10 md:py-8 xl:px-16 relative z-10",children:[!ge&&!Ge.archiveMode&&z.stickyActionsEnabled&&w.jsx(VYA,{inputMethod:G,onInputMethodChange:kt,mode:x,onModeChange:Ht,taterMode:O,repoInfo:re,planDiffStats:JA.diffStats,isPlanDiffActive:ge,hasPreviousVersion:JA.hasPreviousVersion,onPlanDiffToggle:()=>oe(!ge),archiveInfo:Ge.currentInfo,maxWidth:Wu,remountToken:Ee.isActive?`doc:${Ee.filepath}`:"plan"}),!ge&&!Ge.archiveMode&&w.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:Wu},children:w.jsx(eIA,{inputMethod:G,onInputMethodChange:kt,mode:x,onModeChange:Ht,taterMode:O})}),JA.diffBlocks&&JA.diffStats&&w.jsx("div",{className:"w-full flex justify-center",style:{display:ge?void 0:"none"},children:w.jsx(hHA,{diffBlocks:JA.diffBlocks,diffStats:JA.diffStats,diffMode:Se,onDiffModeChange:be,onPlanDiffToggle:()=>oe(!1),repoInfo:re,baseVersionLabel:JA.diffBaseVersion!=null?`v${JA.diffBaseVersion}`:void 0,baseVersion:JA.diffBaseVersion??void 0,maxWidth:Wu,annotations:Br,onAddAnnotation:os,onSelectAnnotation:Nn,selectedAnnotationId:r,mode:x})}),UA==="folder"&&!e&&!Ee.isActive&&w.jsx("div",{className:"w-full flex justify-center",children:w.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[w.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),w.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),w.jsx("div",{className:"w-full flex justify-center",style:{display:ge&&JA.diffBlocks||UA==="folder"&&!e&&!Ee.isActive?"none":void 0},children:w.jsx(E5A,{ref:_e,blocks:a,markdown:e,frontmatter:o,annotations:Ts,onAddAnnotation:os,onSelectAnnotation:Nn,selectedAnnotationId:r,mode:x,inputMethod:G,taterMode:O,globalAttachments:EA,onAddGlobalAttachment:wm,onRemoveGlobalAttachment:jR,repoInfo:re,stickyActions:z.stickyActionsEnabled,planDiffStats:Ee.isActive?null:JA.diffStats,isPlanDiffActive:ge,onPlanDiffToggle:()=>oe(!ge),hasPreviousVersion:!Ee.isActive&&JA.hasPreviousVersion,showDemoBadge:!_&&!Et&&!Ri,maxWidth:Wu,onOpenLinkedDoc:pi,linkedDocInfo:Ee.isActive?{filepath:Ee.filepath,onBack:xe,label:rt.dirs.find(ee=>ee.path===rt.activeDirPath)?.isVault?"Vault File":rt.activeFile?"File":void 0,backLabel:Tt}:null,imageBaseDir:ie,copyLabel:UA==="message"?"Copy message":UA==="file"||UA==="folder"?"Copy file":void 0,archiveInfo:Ge.currentInfo,onToggleCheckbox:wr.toggle,checkboxOverrides:wr.overrides,actionsLabelMode:j},Ee.isActive?`doc:${Ee.filepath}`:"plan")})]})]}),b&&w.jsx(qZ,{...pt.handleProps,className:"hidden md:block",side:"right"}),w.jsx(RYA,{isOpen:b,blocks:a,annotations:li,selectedId:r,onSelect:n,onDelete:Uh,onEdit:UC,sharingEnabled:xA,width:pt.width,editorAnnotations:Dr,onDeleteEditorAnnotation:Ls,onClose:()=>N(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(DiA(xl))},onShare:ht?()=>{N(!1),Ne("share"),I(!0)}:void 0,otherFileAnnotations:De,onOtherFileAnnotationsClick:FA})]})}),w.jsx(GYA,{isOpen:l,onClose:()=>{I(!1),Ne(void 0)},shareUrl:ht,shareUrlSize:Hi,shortShareUrl:ii,isGeneratingShortUrl:An,shortUrlError:Ir,onGenerateShortUrl:Ve,annotationsOutput:xl,annotationCount:li.length,taterSprite:O?w.jsx(v5,{}):void 0,sharingEnabled:xA,markdown:e,isApiMode:_,initialTab:se}),w.jsx(OYA,{isOpen:C,onClose:()=>E(!1),onImport:W,shareBaseUrl:TA}),w.jsx(SB,{isOpen:u,onClose:()=>d(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Ll} will use your annotations to revise the plan.`,variant:"info"}),w.jsx(SB,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),tn()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:[Ll," doesn't yet support feedback on approval. Your ",li.length," annotation",li.length!==1?"s":""," will be lost."]}),subMessage:w.jsxs(w.Fragment,{children:["To send feedback, use ",w.jsx("strong",{children:"Send Feedback"})," instead.",w.jsx("br",{}),w.jsx("br",{}),"Want this feature? Upvote these issues:",w.jsx("br",{}),w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/15755",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#15755"})]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(SB,{isOpen:p,onClose:()=>y(!1),onConfirm:()=>{y(!1),zr()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:["You have ",li.length+Dr.length+Ee.docAnnotationCount+EA.length," annotation",li.length+Dr.length+Ee.docAnnotationCount+EA.length!==1?"s":""," that will be lost if you close."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(SB,{isOpen:D,onClose:()=>S(!1),onConfirm:()=>{S(!1),tn()},title:"Agent Not Found",message:k,subMessage:w.jsxs(w.Fragment,{children:["You can change the agent in ",w.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(SB,{isOpen:!!$&&!_,onClose:CA,title:"Shared Plan Could Not Be Loaded",message:$,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),ve&&w.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${ve.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:ve.message}),w.jsx(A9A,{submitted:RA,title:Ge.archiveMode?"Archive Closed":RA==="exited"?"Session Closed":RA==="approved"?"Plan Approved":wA?"Annotations Sent":"Feedback Sent",subtitle:RA==="exited"?"Annotation session closed without feedback.":Ge.archiveMode?"You can reopen with plannotator archive.":RA==="approved"?`${Ll} will proceed with the implementation.`:wA?`${Ll} will address your annotations on the ${UA==="message"?"message":UA==="folder"?"files":"file"}.`:`${Ll} will revise the plan based on your annotations.`,agentLabel:Ll}),w.jsx(a9A,{origin:eA,isWSL:gA}),w.jsx(FiA,{isOpen:!!BA,imageSrc:BA?.blobUrl??"",initialName:BA?.initialName,onAccept:xt,onClose:rr}),w.jsx(R9A,{isOpen:Z,onComplete:ee=>{kA(ee),mA(!1)}})]})})},UIA=document.getElementById("root");if(!UIA)throw new Error("Could not find root element to mount to");const mHA=OmA.createRoot(UIA);mHA.render(w.jsx(Qn.StrictMode,{children:w.jsx(pHA,{})}));class Bs{constructor(A,t,i){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=i}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new Bs(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class $s{constructor(A,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=A,this.loc=t}range(A,t){return new $s(t,Bs.range(this,A))}}class je{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var i="KaTeX parse error: "+A,r,n,a=t&&t.loc;if(a&&a.start<=a.end){var s=a.lexer.input;r=a.start,n=a.end,r===s.length?i+=" at end of input: ":i+=" at position "+(r+1)+": ";var o=s.slice(r,n).replace(/[^]/g,"$&̲"),g;r>15?g="…"+s.slice(r-15,r):g=s.slice(0,r);var l;n+15<s.length?l=s.slice(n,n+15)+"…":l=s.slice(n),i+=g+o+l}var I=new Error(i);return I.name="ParseError",I.__proto__=je.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}je.prototype.__proto__=Error.prototype;var yHA=function(A,t){return A===void 0?t:A},DHA=/([A-Z])/g,wHA=function(A){return A.replace(DHA,"-$1").toLowerCase()},vHA={"&":"&",">":">","<":"<",'"':""","'":"'"},SHA=/[&><"']/g;function bHA(e){return String(e).replace(SHA,A=>vHA[A])}var KIA=function e(A){return A.type==="ordgroup"||A.type==="color"?A.body.length===1?e(A.body[0]):A:A.type==="font"?e(A.body):A},RHA=function(A){var t=KIA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},NHA=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},MHA=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Ui={deflt:yHA,escape:bHA,hyphenate:wHA,getBaseElem:KIA,isCharacterBox:RHA,protocolFromUrl:MHA},p0={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,A)=>(A.push(e),A)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function kHA(e){if(e.default)return e.default;var A=e.type,t=Array.isArray(A)?A[0]:A;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class M5{constructor(A){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,A=A||{};for(var t in p0)if(p0.hasOwnProperty(t)){var i=p0[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:kHA(i)}}reportNonstrict(A,t,i){var r=this.strict;if(typeof r=="function"&&(r=r(A,t,i)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new je("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),i);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,i){var r=this.strict;if(typeof r=="function")try{r=r(A,t,i)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=Ui.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class pI{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return Al[xHA[this.id]]}sub(){return Al[LHA[this.id]]}fracNum(){return Al[THA[this.id]]}fracDen(){return Al[FHA[this.id]]}cramp(){return Al[GHA[this.id]]}text(){return Al[OHA[this.id]]}isTight(){return this.size>=2}}var k5=0,bS=1,hd=2,yc=3,ep=4,To=5,jd=6,qa=7,Al=[new pI(k5,0,!1),new pI(bS,0,!0),new pI(hd,1,!1),new pI(yc,1,!0),new pI(ep,2,!1),new pI(To,2,!0),new pI(jd,3,!1),new pI(qa,3,!0)],xHA=[ep,To,ep,To,jd,qa,jd,qa],LHA=[To,To,To,To,qa,qa,qa,qa],THA=[hd,yc,ep,To,jd,qa,jd,qa],FHA=[yc,yc,To,To,qa,qa,qa,qa],GHA=[bS,bS,yc,yc,To,To,qa,qa],OHA=[k5,bS,hd,yc,hd,yc,hd,yc],Gt={DISPLAY:Al[k5],TEXT:Al[hd],SCRIPT:Al[ep],SCRIPTSCRIPT:Al[jd]},VO=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function UHA(e){for(var A=0;A<VO.length;A++)for(var t=VO[A],i=0;i<t.blocks.length;i++){var r=t.blocks[i];if(e>=r[0]&&e<=r[1])return t.name}return null}var kw=[];VO.forEach(e=>e.blocks.forEach(A=>kw.push(...A)));function YIA(e){for(var A=0;A<kw.length;A+=2)if(e>=kw[A]&&e<=kw[A+1])return!0;return!1}var RB=80,KHA=function(A,t){return"M95,"+(622+A+t)+`
|
|
981
981
|
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
982
982
|
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
983
983
|
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
package/review-editor.html
CHANGED
|
@@ -80,7 +80,7 @@ Error generating stack: `+m.message+`
|
|
|
80
80
|
created: ${new Date().toISOString().slice(0,19)}Z
|
|
81
81
|
source: plannotator
|
|
82
82
|
tags: [plan, ...]
|
|
83
|
-
---`})]}),p.jsx("div",{className:"border-t border-border/30"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),p.jsx("button",{role:"switch","aria-checked":v.autoSave,onClick:()=>rt({autoSave:!v.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${v.autoSave?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${v.autoSave?"translate-x-6":"translate-x-1"}`})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),p.jsx("button",{role:"switch","aria-checked":v.vaultBrowserEnabled,onClick:()=>rt({vaultBrowserEnabled:!v.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${v.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${v.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),h==="bear"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),p.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),p.jsx("button",{role:"switch","aria-checked":D.enabled,onClick:()=>Ht({enabled:!D.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${D.enabled?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${D.enabled?"translate-x-6":"translate-x-1"}`})})]}),D.enabled&&p.jsxs("div",{className:"mt-3 space-y-3",children:[p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),p.jsx("input",{type:"text",value:D.customTags,onChange:ae=>Ht({customTags:ae.target.value}),onBlur:ae=>Ht({customTags:QM(ae.target.value)}),placeholder:"plan, work",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),p.jsxs("select",{value:D.tagPosition,onChange:ae=>Ht({tagPosition:ae.target.value}),className:"w-full px-3 py-2 bg-muted rounded-lg text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",children:[p.jsx("option",{value:"append",children:"Append (end of note)"}),p.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),p.jsx("div",{className:"border-t border-border/30"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),p.jsx("button",{role:"switch","aria-checked":D.autoSave,onClick:()=>Ht({autoSave:!D.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${D.autoSave?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${D.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),h==="octarine"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),p.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),p.jsx("button",{role:"switch","aria-checked":N.enabled,onClick:()=>hn({enabled:!N.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${N.enabled?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${N.enabled?"translate-x-6":"translate-x-1"}`})})]}),N.enabled&&p.jsxs("div",{className:"mt-3 space-y-3",children:[p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),p.jsx("input",{type:"text",value:N.workspace,onChange:ae=>hn({workspace:ae.target.value}),placeholder:"My Workspace",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),p.jsx("input",{type:"text",value:N.folder,onChange:ae=>hn({folder:ae.target.value}),placeholder:"plannotator",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),p.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",N.workspace||"..."," / ",N.folder||"plannotator","/"]}),p.jsx("div",{className:"border-t border-border/30"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),p.jsx("button",{role:"switch","aria-checked":N.autoSave,onClick:()=>hn({autoSave:!N.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${N.autoSave?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${N.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body)]})},hR=({onClick:t,disabled:e=!1,isLoading:n=!1,label:a="Send Feedback",shortLabel:r,loadingLabel:s="Sending...",shortLoadingLabel:c,title:d="Send Feedback",muted:u=!1})=>p.jsxs("button",{onClick:t,disabled:e,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${u?"opacity-50 cursor-not-allowed bg-accent/10 text-accent/50":e?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:d,children:[p.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"hidden md:inline lg:hidden",children:n?c??s:r}),p.jsx("span",{className:"hidden lg:inline",children:n?s:a})]}):p.jsx("span",{className:"hidden md:inline",children:n?s:a})]}),yR=({onClick:t,disabled:e=!1,isLoading:n=!1,label:a="Approve",loadingLabel:r="Approving...",mobileLabel:s="OK",mobileLoadingLabel:c="...",title:d,dimmed:u=!1,muted:A=!1})=>p.jsxs("button",{onClick:t,disabled:e,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${A?"opacity-40 cursor-not-allowed bg-muted text-muted-foreground":e?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":u?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,title:d,children:[p.jsx("span",{className:"md:hidden",children:n?c:s}),p.jsx("span",{className:"hidden md:inline",children:n?r:a})]}),wR=({onClick:t,disabled:e=!1,isLoading:n=!1,title:a="Close session without sending feedback"})=>p.jsxs("button",{onClick:t,disabled:e||n,className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${e||n?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"}`,title:a,children:[p.jsx("span",{className:"md:hidden",children:n?"...":"✕"}),p.jsx("span",{className:"hidden md:inline",children:n?"Closing...":"Close"})]}),P8=({totalAnnotationCount:t,isSendingFeedback:e,isApproving:n,isExiting:a,onSendFeedback:r,onApprove:s,onExit:c})=>{const d=e||n||a,u=t>0;return p.jsxs(p.Fragment,{children:[p.jsx(wR,{onClick:c,disabled:d,isLoading:a}),u&&p.jsx(hR,{onClick:r,disabled:d,isLoading:e,label:"Send Feedback",shortLabel:"Send",loadingLabel:"Sending...",title:"Send feedback"}),p.jsxs("div",{className:"relative group/approve inline-flex items-center",children:[p.jsx(yR,{onClick:s,disabled:d,isLoading:n,dimmed:t>0,title:"Approve - no changes needed"}),t>0&&p.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[p.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),p.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),"Your ",t," annotation",t!==1?"s":""," won't be sent if you approve."]})]})]})},j8="https://api.github.com/repos/backnotprop/plannotator/releases/latest",QB={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function G8(t,e){const n=s=>s.replace(/^v/,""),a=n(t).split(".").map(Number),r=n(e).split(".").map(Number);for(let s=0;s<Math.max(a.length,r.length);s++){const c=a[s]||0,d=r[s]||0;if(d>c)return!0;if(d<c)return!1}return!1}function z8(){const[t,e]=E.useState(null);return E.useEffect(()=>{(async()=>{try{const a="0.17.8",s=new URLSearchParams(window.location.search).get("preview-update");if(s){const h=s.replace(/^v/,"");e({currentVersion:a,latestVersion:s,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${h}`,featureHighlight:QB[h]});return}const c=await fetch(j8);if(!c.ok)return;const d=await c.json(),u=d.tag_name,A=G8(a,u),g=u.replace(/^v/,""),b=QB[g];e({currentVersion:a,latestVersion:u,updateAvailable:A,releaseUrl:d.html_url,featureHighlight:b})}catch(a){console.debug("Update check failed:",a)}})()},[]),t}const q8="pi install npm:@plannotator/pi-extension";function U8(t){return YM&&!t?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const H8=({origin:t,isWSL:e=!1})=>{const n=z8(),[a,r]=E.useState(!1),[s,c]=E.useState(!1),A=new URLSearchParams(window.location.search).get("preview-origin")||t,g=A==="pi",b=A==="opencode",h=g?q8:U8(e);if(!n?.updateAvailable||s)return null;const y=async()=>{try{await navigator.clipboard.writeText(h),r(!0),setTimeout(()=>r(!1),2e3)}catch(k){console.error("Failed to copy:",k)}};return n.featureHighlight?p.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:p.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[p.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:p.jsxs("div",{className:"flex items-start justify-between gap-3",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:p.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),p.jsxs("div",{children:[p.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.featureHighlight.title}),p.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",n.latestVersion]})]})]}),p.jsx("button",{onClick:()=>c(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:p.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),p.jsxs("div",{className:"px-5 py-4",children:[p.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:n.featureHighlight.description}),p.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",n.currentVersion]}),b&&p.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),g&&p.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),p.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[p.jsx("button",{onClick:y,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:a?"Copied!":"Copy install command"}),p.jsx("a",{href:n.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):p.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:p.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:p.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),p.jsx("button",{onClick:()=>c(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:p.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),p.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[n.latestVersion," is available (you have ",n.currentVersion,")"]}),p.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[p.jsx("button",{onClick:y,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:a?"Copied!":"Copy install command"}),p.jsx("a",{href:n.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})};function NB(t){window.close(),setTimeout(()=>{window.closed||t()},300)}function Y8(t){const[e,n]=E.useState({phase:"idle"});E.useEffect(()=>{if(!t)return;const r=q1();r==="0"?(NB(()=>n({phase:"closeFailed"})),n({phase:"closed"})):n(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[t]),E.useEffect(()=>{if(e.phase!=="counting")return;if(e.remaining<=0){NB(()=>n({phase:"closeFailed"}));return}const r=setTimeout(()=>n(s=>s.phase==="counting"?{phase:"counting",remaining:s.remaining-1}:s),1e3);return()=>clearTimeout(r)},[e]);const a=E.useCallback(()=>{U1("3"),n({phase:"counting",remaining:3})},[]);return{state:e,enableAndStart:a}}const $8=()=>p.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),K8=()=>p.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function W8({submitted:t,title:e,subtitle:n,agentLabel:a}){const{state:r,enableAndStart:s}=Y8(!!t);if(!t)return null;const c=t==="approved";return p.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:p.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[p.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${c?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:c?p.jsx($8,{}):p.jsx(K8,{})}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),p.jsx("p",{className:"text-muted-foreground",children:n})]}),p.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",p.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),p.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),p.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",a,"."]})]}):p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",p.jsx("span",{className:"text-foreground font-medium",children:a}),"."]}),r.phase==="prompt"?p.jsxs(p.Fragment,{children:[p.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[p.jsx("input",{type:"checkbox",checked:!1,onChange:s,className:"accent-primary"}),p.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),p.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):p.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const Z8=({className:t})=>p.jsx("svg",{className:t,viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z"})}),V8=({className:t})=>p.jsxs("svg",{className:t,viewBox:"90 90 200 195",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M282.83 170.73l-.27-.69-26.14-68.22a6.81 6.81 0 00-2.69-3.24 7 7 0 00-8 .43 7 7 0 00-2.32 3.52l-17.65 54h-71.47l-17.65-54a6.86 6.86 0 00-2.32-3.53 7 7 0 00-8-.43 6.87 6.87 0 00-2.69 3.24L97.44 170l-.26.69a48.54 48.54 0 0016.1 56.1l.09.07.24.17 39.82 29.82 19.7 14.91 12 9.06a8.07 8.07 0 009.76 0l12-9.06 19.7-14.91 40.06-30 .1-.08a48.56 48.56 0 0016.08-56.04z"}),p.jsx("path",{d:"M282.83 170.73l-.27-.69a88.3 88.3 0 00-35.15 15.8L190 229.25c19.55 14.79 36.57 27.64 36.57 27.64l40.06-30 .1-.08a48.56 48.56 0 0016.1-56.08z",opacity:"0.7"}),p.jsx("path",{d:"M153.43 256.89l19.7 14.91 12 9.06a8.07 8.07 0 009.76 0l12-9.06 19.7-14.91s-17.04-12.89-36.59-27.64c-19.55 14.75-36.57 27.64-36.57 27.64z",opacity:"0.85"}),p.jsx("path",{d:"M132.58 185.84A88.19 88.19 0 0097.44 170l-.26.69a48.54 48.54 0 0016.1 56.1l.09.07.24.17 39.82 29.82s17-12.85 36.57-27.64z",opacity:"0.7"})]}),RB=({className:t})=>p.jsx("svg",{className:t,viewBox:"0 0 768 1024",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{d:"M320 256h-64v64h64v-64z m0-128h-64v64h64v-64z m384-128c-32 0-608 0-640 0s-64 32-64 64 0 736 0 768 32 64 64 64 128 0 128 0v128l96-96 96 96v-128s288 0 320 0 64-32 64-64 0-736 0-768-32-64-64-64z m0 800c0 16-15 32-32 32s-288 0-288 0v-64h-192v64s-79 0-96 0-32-17-32-32 0-96 0-96h640s0 80 0 96z m0-160h-512v-576h513l-1 576z m-384-128h-64v64h64v-64z m0-128h-64v64h64v-64z"})}),J8=({className:t})=>p.jsx("svg",{className:t,viewBox:"0 0 768 1024",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{d:"M704 722s0-306 0-402-96-192-192-192c-64 0-64 0-64 0v-128l-192 192 192 192v-128s32 0 64 0 64 32 64 64 0 402 0 402c-38 22-64 63-64 110 0 71 57 128 128 128s128-57 128-128c0-47-26-88-64-110z m-64 174c-35 0-64-29-64-64s29-64 64-64 64 29 64 64-29 64-64 64z m-512-832c-71 0-128 57-128 128 0 47 26 88 64 110v419c-38 22-64 63-64 110 0 71 57 128 128 128s128-57 128-128c0-47-26-88-64-110v-419c38-22 64-63 64-110 0-71-57-128-128-128z m0 832c-35 0-64-29-64-64s29-64 64-64 64 29 64 64-29 64-64 64z m0-640c-35 0-64-29-64-64s29-64 64-64 64 29 64 64-29 64-64 64z"})});function X8(t){return t.platform==="github"?"GitHub":"GitLab"}function _R(t){return t.platform==="github"?"PR":"MR"}function kR(t){return t.platform==="github"?`#${t.number}`:`!${t.iid}`}function vR(t){return t.platform==="github"?`${t.owner}/${t.repo}`:t.projectPath}const CR="plannotator-ai-setup-done";function eP(){return Ee.getItem(CR)!=="true"}function tP(){Ee.setItem(CR,"true")}const nP=({isOpen:t,providers:e,onComplete:n})=>{const[a,r]=E.useState(null),[s,c]=E.useState(()=>ao().preferredModels);if(!t||e.length===0)return null;const d=a??e[0]?.id??null,u=b=>{r(b)},A=(b,h)=>{xN(b,h),c(y=>({...y,[b]:h}))},g=()=>{if(!d)return;const b=ao();RA({...b,providerId:d}),tP(),n(d)};return no.createPortal(p.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:p.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[p.jsxs("div",{className:"p-5 border-b border-border",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[p.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:p.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"})})}),p.jsx("h3",{className:"font-semibold text-base",children:"AI-Assisted Code Review"})]}),p.jsx("p",{className:"text-sm text-muted-foreground",children:"Ask questions about code changes inline or in a side chat. Select lines in a diff, click the sparkle, and get streaming answers with full diff context."})]}),p.jsxs("div",{className:"p-4",children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:"Choose your default provider"}),p.jsx("div",{className:"grid grid-cols-2 gap-2",children:e.map(b=>{const h=tA(b.name),y=h.icon,_=d===b.id;return p.jsxs("button",{type:"button",onClick:()=>u(b.id),className:`flex items-center gap-2.5 p-3 rounded-lg border transition-colors text-left ${_?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/30 hover:bg-muted/50"}`,children:[p.jsx("div",{className:"w-7 h-7 rounded-md bg-muted flex items-center justify-center text-muted-foreground flex-shrink-0",children:p.jsx(y,{className:"w-4.5 h-4.5"})}),p.jsx("span",{className:"text-sm font-medium",children:h.label}),_&&p.jsx("svg",{className:"w-3.5 h-3.5 text-primary ml-auto flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},b.id)})}),d&&(()=>{const h=e.find(k=>k.id===d)?.models??[];if(h.length<=1)return null;const y=h.find(k=>k.default)??h[0],_=s[d]??y?.id??"";return p.jsx("div",{className:"mt-3",children:p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-xs text-muted-foreground",children:"Model"}),p.jsx("select",{value:_,onChange:k=>A(d,k.target.value),className:"flex-1 text-xs bg-muted rounded px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-primary/50 cursor-pointer",children:h.map(k=>p.jsx("option",{value:k.id,children:k.label},k.id))})]})})})()]}),p.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center gap-3",children:[p.jsxs("p",{className:"text-[10px] text-muted-foreground/70 flex-1",children:["Providers are detected from installed CLI tools. You must be authenticated with each CLI independently."," ",p.jsx("a",{href:"https://plannotator.ai/docs/guides/ai-features/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Learn more"})]}),p.jsx("button",{onClick:g,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity flex-shrink-0",children:"Done"})]})]})}),document.body)},ER="plannotator-diff-type-setup-done";function aP(){return Ee.getItem(ER)!=="true"}function iP(){Ee.setItem(ER,"true")}const rP=[{value:"unstaged",label:"Unstaged",description:"Changes not yet staged. Matches `git diff`"},{value:"uncommitted",label:"All Changes",description:"Staged and unstaged combined. Matches `git diff HEAD`"},{value:"staged",label:"Staged",description:"Only changes added to the index. Matches `git diff --staged`"}],oP=({onComplete:t})=>{const[e,n]=E.useState(()=>Tn.get("defaultDiffType")),a=()=>{Tn.set("defaultDiffType",e),iP(),t(e)};return no.createPortal(p.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:p.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[p.jsxs("div",{className:"p-5 border-b border-border",children:[p.jsx("h3",{className:"font-semibold text-base mb-2",children:"Default Diff View"}),p.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which changes to show when you open a code review. You can always switch between views during a session."})]}),p.jsx("div",{className:"p-4 space-y-2",children:rP.map(r=>p.jsxs("button",{type:"button",onClick:()=>n(r.value),className:`w-full flex items-start gap-3 p-3 rounded-lg border transition-colors text-left ${e===r.value?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/30 hover:bg-muted/50"}`,children:[p.jsx("div",{className:`mt-0.5 w-4 h-4 rounded-full border-2 flex-shrink-0 flex items-center justify-center ${e===r.value?"border-primary":"border-muted-foreground/40"}`,children:e===r.value&&p.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"})}),p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-medium",children:r.label}),p.jsx("div",{className:"text-xs text-muted-foreground",children:r.description})]})]},r.value))}),p.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center gap-3",children:[p.jsx("p",{className:"text-[10px] text-muted-foreground/70 flex-1",children:"You can change this later in Settings > Display."}),p.jsx("button",{onClick:a,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity flex-shrink-0",children:"Done"})]})]})}),document.body)};function TB({storageKey:t,defaultWidth:e=288,minWidth:n=200,maxWidth:a=600,side:r="right"}){const[s,c]=E.useState(()=>{const v=Ee.getItem(t);if(v){const C=Number(v);if(!Number.isNaN(C)&&C>=n&&C<=a)return C}return e}),[d,u]=E.useState(!1),A=E.useRef(0),g=E.useRef(0),b=E.useRef(s),h=E.useCallback(v=>{b.current=v,c(v)},[]),y=E.useCallback(v=>{v.preventDefault(),A.current=v.clientX,g.current=b.current,u(!0)},[]),_=E.useCallback(v=>{v.preventDefault(),A.current=v.touches[0].clientX,g.current=b.current,u(!0)},[]);E.useEffect(()=>{if(!d)return;const v=S=>"touches"in S?S.touches[0]?.clientX??S.changedTouches[0]?.clientX??0:S.clientX,C=S=>{const I=v(S),Q=r==="right"?A.current-I:I-A.current;h(Math.min(a,Math.max(n,g.current+Q)))},x=()=>{u(!1),Ee.setItem(t,String(b.current))};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",x),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("touchend",x),document.addEventListener("touchcancel",x),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",x),document.removeEventListener("touchmove",C),document.removeEventListener("touchend",x),document.removeEventListener("touchcancel",x)}},[d,n,a,t,r,h]);const k=E.useCallback(()=>{h(e),Ee.setItem(t,String(e))},[e,t,h]);return{width:s,isDragging:d,handleProps:{isDragging:d,onMouseDown:y,onTouchStart:_,onDoubleClick:k}}}const sP=500;function cP(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n} minute${n!==1?"s":""} ago`;const a=Math.floor(n/60);if(a<24)return`${a} hour${a!==1?"s":""} ago`;const r=Math.floor(a/24);return`${r} day${r!==1?"s":""} ago`}function lP({annotations:t,viewedFiles:e,isApiMode:n,submitted:a}){const[r,s]=E.useState(null),c=E.useRef(null),d=E.useRef(null),u=E.useRef(!1);E.useEffect(()=>{n&&fetch("/api/draft").then(b=>b.ok?b.json():null).then(b=>{const h=Array.isArray(b?.codeAnnotations)?b.codeAnnotations.length:0,y=Array.isArray(b?.viewedFiles)?b.viewedFiles.length:0;(h>0||y>0)&&(c.current=b,s({count:h,viewedCount:y,timeAgo:cP(b?.ts||0)})),u.current=!0}).catch(()=>{u.current=!0})},[n]),E.useEffect(()=>{if(!(!n||a)&&u.current&&!(t.length===0&&e.size===0))return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{const b={codeAnnotations:t,viewedFiles:[...e],ts:Date.now()};fetch("/api/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}).catch(()=>{})},sP),()=>{d.current&&clearTimeout(d.current)}},[t,e,n,a]);const A=E.useCallback(()=>{const b=c.current;return s(null),c.current=null,{annotations:b?.codeAnnotations??[],viewedFiles:b?.viewedFiles??[]}},[]),g=E.useCallback(()=>{s(null),c.current=null,fetch("/api/draft",{method:"DELETE"}).catch(()=>{})},[]);return{draftBanner:r,restoreDraft:A,dismissDraft:g}}const dP=new Set(["uncommitted","unstaged"]);function uP({activeDiffBase:t,onFileViewed:e}){const[n,a]=E.useState(new Set),[r,s]=E.useState(null),[c,d]=E.useState(null),u=E.useRef(),A=dP.has(t),g=E.useRef(n);g.current=n;const b=E.useCallback(async y=>{const _=g.current.has(y);s(y),d(null),clearTimeout(u.current);try{const k=await fetch("/api/git-add",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:y,undo:_})});if(!k.ok){const v=await k.json().catch(()=>({error:"Failed"}));throw new Error(v.error||"Failed")}a(v=>{const C=new Set(v);return _?C.delete(y):C.add(y),C}),_||e(y)}catch(k){const v=k instanceof Error?k.message:"Git add failed";d(v),u.current=setTimeout(()=>d(null),3e3)}finally{s(null)}},[e]),h=E.useCallback(()=>{a(new Set),d(null),clearTimeout(u.current)},[]);return{stagedFiles:n,stagingFile:r,canStageFiles:A,stageFile:b,resetStagedFiles:h,stageError:c}}const d_=()=>Math.random().toString(36).substring(2,9);function pP({patch:t,providerId:e,model:n,reasoningEffort:a}){const[r,s]=E.useState(null),[c,d]=E.useState([]),[u,A]=E.useState(!1),[g,b]=E.useState(!1),[h,y]=E.useState(null),[_,k]=E.useState([]),v=E.useRef(null),C=E.useRef(null);C.current=r;const x=E.useCallback(async R=>{A(!0);try{const N=await fetch("/api/ai/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:{mode:"code-review",review:{patch:t}},...e&&{providerId:e},...n&&{model:n},...a&&{reasoningEffort:a}}),signal:R});if(!N.ok){const P=await N.json().catch(()=>({error:"Failed to create AI session"}));throw new Error(P.error||`HTTP ${N.status}`)}const F=await N.json();return s(F.sessionId),F.sessionId}finally{A(!1)}},[t,e,n,a]),S=E.useCallback(async R=>{v.current&&v.current.abort();const N=new AbortController;v.current=N,y(null);const F=d_(),P={id:F,prompt:R.prompt,filePath:R.filePath,lineStart:R.lineStart,lineEnd:R.lineEnd,side:R.side,selectedCode:R.selectedCode,createdAt:Date.now()},T={questionId:F,text:"",isStreaming:!0,createdAt:Date.now()};d(L=>[...L,{question:P,response:T}]),b(!0);try{let L=C.current;L||(L=await x(N.signal));let Y=R.prompt;if(R.filePath&&R.lineStart!=null&&R.lineEnd!=null){const te=R.lineStart===R.lineEnd?`line ${R.lineStart}`:`lines ${R.lineStart}-${R.lineEnd}`,oe=R.side==="new"?"new (added)":"old (removed)",de=R.selectedCode?`
|
|
83
|
+
---`})]}),p.jsx("div",{className:"border-t border-border/30"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),p.jsx("button",{role:"switch","aria-checked":v.autoSave,onClick:()=>rt({autoSave:!v.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${v.autoSave?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${v.autoSave?"translate-x-6":"translate-x-1"}`})})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),p.jsx("button",{role:"switch","aria-checked":v.vaultBrowserEnabled,onClick:()=>rt({vaultBrowserEnabled:!v.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${v.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${v.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),h==="bear"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),p.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),p.jsx("button",{role:"switch","aria-checked":D.enabled,onClick:()=>Ht({enabled:!D.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${D.enabled?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${D.enabled?"translate-x-6":"translate-x-1"}`})})]}),D.enabled&&p.jsxs("div",{className:"mt-3 space-y-3",children:[p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),p.jsx("input",{type:"text",value:D.customTags,onChange:ae=>Ht({customTags:ae.target.value}),onBlur:ae=>Ht({customTags:QM(ae.target.value)}),placeholder:"plan, work",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),p.jsxs("select",{value:D.tagPosition,onChange:ae=>Ht({tagPosition:ae.target.value}),className:"w-full px-3 py-2 bg-muted rounded-lg text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",children:[p.jsx("option",{value:"append",children:"Append (end of note)"}),p.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),p.jsx("div",{className:"border-t border-border/30"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),p.jsx("button",{role:"switch","aria-checked":D.autoSave,onClick:()=>Ht({autoSave:!D.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${D.autoSave?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${D.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),h==="octarine"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),p.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),p.jsx("button",{role:"switch","aria-checked":N.enabled,onClick:()=>hn({enabled:!N.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${N.enabled?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${N.enabled?"translate-x-6":"translate-x-1"}`})})]}),N.enabled&&p.jsxs("div",{className:"mt-3 space-y-3",children:[p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),p.jsx("input",{type:"text",value:N.workspace,onChange:ae=>hn({workspace:ae.target.value}),placeholder:"My Workspace",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),p.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[p.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),p.jsx("input",{type:"text",value:N.folder,onChange:ae=>hn({folder:ae.target.value}),placeholder:"plannotator",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),p.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",N.workspace||"..."," / ",N.folder||"plannotator","/"]}),p.jsx("div",{className:"border-t border-border/30"}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),p.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),p.jsx("button",{role:"switch","aria-checked":N.autoSave,onClick:()=>hn({autoSave:!N.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${N.autoSave?"bg-primary":"bg-muted"}`,children:p.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${N.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body)]})},hR=({onClick:t,disabled:e=!1,isLoading:n=!1,label:a="Send Feedback",shortLabel:r,loadingLabel:s="Sending...",shortLoadingLabel:c,title:d="Send Feedback",muted:u=!1})=>p.jsxs("button",{onClick:t,disabled:e,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${u?"opacity-50 cursor-not-allowed bg-accent/10 text-accent/50":e?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:d,children:[p.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"hidden md:inline lg:hidden",children:n?c??s:r}),p.jsx("span",{className:"hidden lg:inline",children:n?s:a})]}):p.jsx("span",{className:"hidden md:inline",children:n?s:a})]}),yR=({onClick:t,disabled:e=!1,isLoading:n=!1,label:a="Approve",loadingLabel:r="Approving...",mobileLabel:s="OK",mobileLoadingLabel:c="...",title:d,dimmed:u=!1,muted:A=!1})=>p.jsxs("button",{onClick:t,disabled:e,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${A?"opacity-40 cursor-not-allowed bg-muted text-muted-foreground":e?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":u?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,title:d,children:[p.jsx("span",{className:"md:hidden",children:n?c:s}),p.jsx("span",{className:"hidden md:inline",children:n?r:a})]}),wR=({onClick:t,disabled:e=!1,isLoading:n=!1,title:a="Close session without sending feedback"})=>p.jsxs("button",{onClick:t,disabled:e||n,className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${e||n?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"}`,title:a,children:[p.jsx("span",{className:"md:hidden",children:n?"...":"✕"}),p.jsx("span",{className:"hidden md:inline",children:n?"Closing...":"Close"})]}),P8=({totalAnnotationCount:t,isSendingFeedback:e,isApproving:n,isExiting:a,onSendFeedback:r,onApprove:s,onExit:c})=>{const d=e||n||a,u=t>0;return p.jsxs(p.Fragment,{children:[p.jsx(wR,{onClick:c,disabled:d,isLoading:a}),u&&p.jsx(hR,{onClick:r,disabled:d,isLoading:e,label:"Send Feedback",shortLabel:"Send",loadingLabel:"Sending...",title:"Send feedback"}),p.jsxs("div",{className:"relative group/approve inline-flex items-center",children:[p.jsx(yR,{onClick:s,disabled:d,isLoading:n,dimmed:t>0,title:"Approve - no changes needed"}),t>0&&p.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[p.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),p.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),"Your ",t," annotation",t!==1?"s":""," won't be sent if you approve."]})]})]})},j8="https://api.github.com/repos/backnotprop/plannotator/releases/latest",QB={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function G8(t,e){const n=s=>s.replace(/^v/,""),a=n(t).split(".").map(Number),r=n(e).split(".").map(Number);for(let s=0;s<Math.max(a.length,r.length);s++){const c=a[s]||0,d=r[s]||0;if(d>c)return!0;if(d<c)return!1}return!1}function z8(){const[t,e]=E.useState(null);return E.useEffect(()=>{(async()=>{try{const a="0.17.9",s=new URLSearchParams(window.location.search).get("preview-update");if(s){const h=s.replace(/^v/,"");e({currentVersion:a,latestVersion:s,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${h}`,featureHighlight:QB[h]});return}const c=await fetch(j8);if(!c.ok)return;const d=await c.json(),u=d.tag_name,A=G8(a,u),g=u.replace(/^v/,""),b=QB[g];e({currentVersion:a,latestVersion:u,updateAvailable:A,releaseUrl:d.html_url,featureHighlight:b})}catch(a){console.debug("Update check failed:",a)}})()},[]),t}const q8="pi install npm:@plannotator/pi-extension";function U8(t){return YM&&!t?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const H8=({origin:t,isWSL:e=!1})=>{const n=z8(),[a,r]=E.useState(!1),[s,c]=E.useState(!1),A=new URLSearchParams(window.location.search).get("preview-origin")||t,g=A==="pi",b=A==="opencode",h=g?q8:U8(e);if(!n?.updateAvailable||s)return null;const y=async()=>{try{await navigator.clipboard.writeText(h),r(!0),setTimeout(()=>r(!1),2e3)}catch(k){console.error("Failed to copy:",k)}};return n.featureHighlight?p.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:p.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[p.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:p.jsxs("div",{className:"flex items-start justify-between gap-3",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:p.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),p.jsxs("div",{children:[p.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.featureHighlight.title}),p.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",n.latestVersion]})]})]}),p.jsx("button",{onClick:()=>c(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:p.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),p.jsxs("div",{className:"px-5 py-4",children:[p.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:n.featureHighlight.description}),p.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",n.currentVersion]}),b&&p.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),g&&p.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),p.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[p.jsx("button",{onClick:y,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:a?"Copied!":"Copy install command"}),p.jsx("a",{href:n.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):p.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:p.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:p.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),p.jsx("button",{onClick:()=>c(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:p.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),p.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[n.latestVersion," is available (you have ",n.currentVersion,")"]}),p.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[p.jsx("button",{onClick:y,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:a?"Copied!":"Copy install command"}),p.jsx("a",{href:n.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})};function NB(t){window.close(),setTimeout(()=>{window.closed||t()},300)}function Y8(t){const[e,n]=E.useState({phase:"idle"});E.useEffect(()=>{if(!t)return;const r=q1();r==="0"?(NB(()=>n({phase:"closeFailed"})),n({phase:"closed"})):n(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[t]),E.useEffect(()=>{if(e.phase!=="counting")return;if(e.remaining<=0){NB(()=>n({phase:"closeFailed"}));return}const r=setTimeout(()=>n(s=>s.phase==="counting"?{phase:"counting",remaining:s.remaining-1}:s),1e3);return()=>clearTimeout(r)},[e]);const a=E.useCallback(()=>{U1("3"),n({phase:"counting",remaining:3})},[]);return{state:e,enableAndStart:a}}const $8=()=>p.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),K8=()=>p.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function W8({submitted:t,title:e,subtitle:n,agentLabel:a}){const{state:r,enableAndStart:s}=Y8(!!t);if(!t)return null;const c=t==="approved";return p.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:p.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[p.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${c?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:c?p.jsx($8,{}):p.jsx(K8,{})}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),p.jsx("p",{className:"text-muted-foreground",children:n})]}),p.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",p.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),p.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),p.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",a,"."]})]}):p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",p.jsx("span",{className:"text-foreground font-medium",children:a}),"."]}),r.phase==="prompt"?p.jsxs(p.Fragment,{children:[p.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[p.jsx("input",{type:"checkbox",checked:!1,onChange:s,className:"accent-primary"}),p.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),p.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):p.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const Z8=({className:t})=>p.jsx("svg",{className:t,viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z"})}),V8=({className:t})=>p.jsxs("svg",{className:t,viewBox:"90 90 200 195",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M282.83 170.73l-.27-.69-26.14-68.22a6.81 6.81 0 00-2.69-3.24 7 7 0 00-8 .43 7 7 0 00-2.32 3.52l-17.65 54h-71.47l-17.65-54a6.86 6.86 0 00-2.32-3.53 7 7 0 00-8-.43 6.87 6.87 0 00-2.69 3.24L97.44 170l-.26.69a48.54 48.54 0 0016.1 56.1l.09.07.24.17 39.82 29.82 19.7 14.91 12 9.06a8.07 8.07 0 009.76 0l12-9.06 19.7-14.91 40.06-30 .1-.08a48.56 48.56 0 0016.08-56.04z"}),p.jsx("path",{d:"M282.83 170.73l-.27-.69a88.3 88.3 0 00-35.15 15.8L190 229.25c19.55 14.79 36.57 27.64 36.57 27.64l40.06-30 .1-.08a48.56 48.56 0 0016.1-56.08z",opacity:"0.7"}),p.jsx("path",{d:"M153.43 256.89l19.7 14.91 12 9.06a8.07 8.07 0 009.76 0l12-9.06 19.7-14.91s-17.04-12.89-36.59-27.64c-19.55 14.75-36.57 27.64-36.57 27.64z",opacity:"0.85"}),p.jsx("path",{d:"M132.58 185.84A88.19 88.19 0 0097.44 170l-.26.69a48.54 48.54 0 0016.1 56.1l.09.07.24.17 39.82 29.82s17-12.85 36.57-27.64z",opacity:"0.7"})]}),RB=({className:t})=>p.jsx("svg",{className:t,viewBox:"0 0 768 1024",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{d:"M320 256h-64v64h64v-64z m0-128h-64v64h64v-64z m384-128c-32 0-608 0-640 0s-64 32-64 64 0 736 0 768 32 64 64 64 128 0 128 0v128l96-96 96 96v-128s288 0 320 0 64-32 64-64 0-736 0-768-32-64-64-64z m0 800c0 16-15 32-32 32s-288 0-288 0v-64h-192v64s-79 0-96 0-32-17-32-32 0-96 0-96h640s0 80 0 96z m0-160h-512v-576h513l-1 576z m-384-128h-64v64h64v-64z m0-128h-64v64h64v-64z"})}),J8=({className:t})=>p.jsx("svg",{className:t,viewBox:"0 0 768 1024",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{d:"M704 722s0-306 0-402-96-192-192-192c-64 0-64 0-64 0v-128l-192 192 192 192v-128s32 0 64 0 64 32 64 64 0 402 0 402c-38 22-64 63-64 110 0 71 57 128 128 128s128-57 128-128c0-47-26-88-64-110z m-64 174c-35 0-64-29-64-64s29-64 64-64 64 29 64 64-29 64-64 64z m-512-832c-71 0-128 57-128 128 0 47 26 88 64 110v419c-38 22-64 63-64 110 0 71 57 128 128 128s128-57 128-128c0-47-26-88-64-110v-419c38-22 64-63 64-110 0-71-57-128-128-128z m0 832c-35 0-64-29-64-64s29-64 64-64 64 29 64 64-29 64-64 64z m0-640c-35 0-64-29-64-64s29-64 64-64 64 29 64 64-29 64-64 64z"})});function X8(t){return t.platform==="github"?"GitHub":"GitLab"}function _R(t){return t.platform==="github"?"PR":"MR"}function kR(t){return t.platform==="github"?`#${t.number}`:`!${t.iid}`}function vR(t){return t.platform==="github"?`${t.owner}/${t.repo}`:t.projectPath}const CR="plannotator-ai-setup-done";function eP(){return Ee.getItem(CR)!=="true"}function tP(){Ee.setItem(CR,"true")}const nP=({isOpen:t,providers:e,onComplete:n})=>{const[a,r]=E.useState(null),[s,c]=E.useState(()=>ao().preferredModels);if(!t||e.length===0)return null;const d=a??e[0]?.id??null,u=b=>{r(b)},A=(b,h)=>{xN(b,h),c(y=>({...y,[b]:h}))},g=()=>{if(!d)return;const b=ao();RA({...b,providerId:d}),tP(),n(d)};return no.createPortal(p.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:p.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[p.jsxs("div",{className:"p-5 border-b border-border",children:[p.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[p.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:p.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"})})}),p.jsx("h3",{className:"font-semibold text-base",children:"AI-Assisted Code Review"})]}),p.jsx("p",{className:"text-sm text-muted-foreground",children:"Ask questions about code changes inline or in a side chat. Select lines in a diff, click the sparkle, and get streaming answers with full diff context."})]}),p.jsxs("div",{className:"p-4",children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:"Choose your default provider"}),p.jsx("div",{className:"grid grid-cols-2 gap-2",children:e.map(b=>{const h=tA(b.name),y=h.icon,_=d===b.id;return p.jsxs("button",{type:"button",onClick:()=>u(b.id),className:`flex items-center gap-2.5 p-3 rounded-lg border transition-colors text-left ${_?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/30 hover:bg-muted/50"}`,children:[p.jsx("div",{className:"w-7 h-7 rounded-md bg-muted flex items-center justify-center text-muted-foreground flex-shrink-0",children:p.jsx(y,{className:"w-4.5 h-4.5"})}),p.jsx("span",{className:"text-sm font-medium",children:h.label}),_&&p.jsx("svg",{className:"w-3.5 h-3.5 text-primary ml-auto flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},b.id)})}),d&&(()=>{const h=e.find(k=>k.id===d)?.models??[];if(h.length<=1)return null;const y=h.find(k=>k.default)??h[0],_=s[d]??y?.id??"";return p.jsx("div",{className:"mt-3",children:p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-xs text-muted-foreground",children:"Model"}),p.jsx("select",{value:_,onChange:k=>A(d,k.target.value),className:"flex-1 text-xs bg-muted rounded px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-primary/50 cursor-pointer",children:h.map(k=>p.jsx("option",{value:k.id,children:k.label},k.id))})]})})})()]}),p.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center gap-3",children:[p.jsxs("p",{className:"text-[10px] text-muted-foreground/70 flex-1",children:["Providers are detected from installed CLI tools. You must be authenticated with each CLI independently."," ",p.jsx("a",{href:"https://plannotator.ai/docs/guides/ai-features/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Learn more"})]}),p.jsx("button",{onClick:g,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity flex-shrink-0",children:"Done"})]})]})}),document.body)},ER="plannotator-diff-type-setup-done";function aP(){return Ee.getItem(ER)!=="true"}function iP(){Ee.setItem(ER,"true")}const rP=[{value:"unstaged",label:"Unstaged",description:"Changes not yet staged. Matches `git diff`"},{value:"uncommitted",label:"All Changes",description:"Staged and unstaged combined. Matches `git diff HEAD`"},{value:"staged",label:"Staged",description:"Only changes added to the index. Matches `git diff --staged`"}],oP=({onComplete:t})=>{const[e,n]=E.useState(()=>Tn.get("defaultDiffType")),a=()=>{Tn.set("defaultDiffType",e),iP(),t(e)};return no.createPortal(p.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:p.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[p.jsxs("div",{className:"p-5 border-b border-border",children:[p.jsx("h3",{className:"font-semibold text-base mb-2",children:"Default Diff View"}),p.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which changes to show when you open a code review. You can always switch between views during a session."})]}),p.jsx("div",{className:"p-4 space-y-2",children:rP.map(r=>p.jsxs("button",{type:"button",onClick:()=>n(r.value),className:`w-full flex items-start gap-3 p-3 rounded-lg border transition-colors text-left ${e===r.value?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/30 hover:bg-muted/50"}`,children:[p.jsx("div",{className:`mt-0.5 w-4 h-4 rounded-full border-2 flex-shrink-0 flex items-center justify-center ${e===r.value?"border-primary":"border-muted-foreground/40"}`,children:e===r.value&&p.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"})}),p.jsxs("div",{children:[p.jsx("div",{className:"text-sm font-medium",children:r.label}),p.jsx("div",{className:"text-xs text-muted-foreground",children:r.description})]})]},r.value))}),p.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center gap-3",children:[p.jsx("p",{className:"text-[10px] text-muted-foreground/70 flex-1",children:"You can change this later in Settings > Display."}),p.jsx("button",{onClick:a,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity flex-shrink-0",children:"Done"})]})]})}),document.body)};function TB({storageKey:t,defaultWidth:e=288,minWidth:n=200,maxWidth:a=600,side:r="right"}){const[s,c]=E.useState(()=>{const v=Ee.getItem(t);if(v){const C=Number(v);if(!Number.isNaN(C)&&C>=n&&C<=a)return C}return e}),[d,u]=E.useState(!1),A=E.useRef(0),g=E.useRef(0),b=E.useRef(s),h=E.useCallback(v=>{b.current=v,c(v)},[]),y=E.useCallback(v=>{v.preventDefault(),A.current=v.clientX,g.current=b.current,u(!0)},[]),_=E.useCallback(v=>{v.preventDefault(),A.current=v.touches[0].clientX,g.current=b.current,u(!0)},[]);E.useEffect(()=>{if(!d)return;const v=S=>"touches"in S?S.touches[0]?.clientX??S.changedTouches[0]?.clientX??0:S.clientX,C=S=>{const I=v(S),Q=r==="right"?A.current-I:I-A.current;h(Math.min(a,Math.max(n,g.current+Q)))},x=()=>{u(!1),Ee.setItem(t,String(b.current))};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",x),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("touchend",x),document.addEventListener("touchcancel",x),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",x),document.removeEventListener("touchmove",C),document.removeEventListener("touchend",x),document.removeEventListener("touchcancel",x)}},[d,n,a,t,r,h]);const k=E.useCallback(()=>{h(e),Ee.setItem(t,String(e))},[e,t,h]);return{width:s,isDragging:d,handleProps:{isDragging:d,onMouseDown:y,onTouchStart:_,onDoubleClick:k}}}const sP=500;function cP(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n} minute${n!==1?"s":""} ago`;const a=Math.floor(n/60);if(a<24)return`${a} hour${a!==1?"s":""} ago`;const r=Math.floor(a/24);return`${r} day${r!==1?"s":""} ago`}function lP({annotations:t,viewedFiles:e,isApiMode:n,submitted:a}){const[r,s]=E.useState(null),c=E.useRef(null),d=E.useRef(null),u=E.useRef(!1);E.useEffect(()=>{n&&fetch("/api/draft").then(b=>b.ok?b.json():null).then(b=>{const h=Array.isArray(b?.codeAnnotations)?b.codeAnnotations.length:0,y=Array.isArray(b?.viewedFiles)?b.viewedFiles.length:0;(h>0||y>0)&&(c.current=b,s({count:h,viewedCount:y,timeAgo:cP(b?.ts||0)})),u.current=!0}).catch(()=>{u.current=!0})},[n]),E.useEffect(()=>{if(!(!n||a)&&u.current&&!(t.length===0&&e.size===0))return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{const b={codeAnnotations:t,viewedFiles:[...e],ts:Date.now()};fetch("/api/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}).catch(()=>{})},sP),()=>{d.current&&clearTimeout(d.current)}},[t,e,n,a]);const A=E.useCallback(()=>{const b=c.current;return s(null),c.current=null,{annotations:b?.codeAnnotations??[],viewedFiles:b?.viewedFiles??[]}},[]),g=E.useCallback(()=>{s(null),c.current=null,fetch("/api/draft",{method:"DELETE"}).catch(()=>{})},[]);return{draftBanner:r,restoreDraft:A,dismissDraft:g}}const dP=new Set(["uncommitted","unstaged"]);function uP({activeDiffBase:t,onFileViewed:e}){const[n,a]=E.useState(new Set),[r,s]=E.useState(null),[c,d]=E.useState(null),u=E.useRef(),A=dP.has(t),g=E.useRef(n);g.current=n;const b=E.useCallback(async y=>{const _=g.current.has(y);s(y),d(null),clearTimeout(u.current);try{const k=await fetch("/api/git-add",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:y,undo:_})});if(!k.ok){const v=await k.json().catch(()=>({error:"Failed"}));throw new Error(v.error||"Failed")}a(v=>{const C=new Set(v);return _?C.delete(y):C.add(y),C}),_||e(y)}catch(k){const v=k instanceof Error?k.message:"Git add failed";d(v),u.current=setTimeout(()=>d(null),3e3)}finally{s(null)}},[e]),h=E.useCallback(()=>{a(new Set),d(null),clearTimeout(u.current)},[]);return{stagedFiles:n,stagingFile:r,canStageFiles:A,stageFile:b,resetStagedFiles:h,stageError:c}}const d_=()=>Math.random().toString(36).substring(2,9);function pP({patch:t,providerId:e,model:n,reasoningEffort:a}){const[r,s]=E.useState(null),[c,d]=E.useState([]),[u,A]=E.useState(!1),[g,b]=E.useState(!1),[h,y]=E.useState(null),[_,k]=E.useState([]),v=E.useRef(null),C=E.useRef(null);C.current=r;const x=E.useCallback(async R=>{A(!0);try{const N=await fetch("/api/ai/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:{mode:"code-review",review:{patch:t}},...e&&{providerId:e},...n&&{model:n},...a&&{reasoningEffort:a}}),signal:R});if(!N.ok){const P=await N.json().catch(()=>({error:"Failed to create AI session"}));throw new Error(P.error||`HTTP ${N.status}`)}const F=await N.json();return s(F.sessionId),F.sessionId}finally{A(!1)}},[t,e,n,a]),S=E.useCallback(async R=>{v.current&&v.current.abort();const N=new AbortController;v.current=N,y(null);const F=d_(),P={id:F,prompt:R.prompt,filePath:R.filePath,lineStart:R.lineStart,lineEnd:R.lineEnd,side:R.side,selectedCode:R.selectedCode,createdAt:Date.now()},T={questionId:F,text:"",isStreaming:!0,createdAt:Date.now()};d(L=>[...L,{question:P,response:T}]),b(!0);try{let L=C.current;L||(L=await x(N.signal));let Y=R.prompt;if(R.filePath&&R.lineStart!=null&&R.lineEnd!=null){const te=R.lineStart===R.lineEnd?`line ${R.lineStart}`:`lines ${R.lineStart}-${R.lineEnd}`,oe=R.side==="new"?"new (added)":"old (removed)",de=R.selectedCode?`
|
|
84
84
|
\`\`\`
|
|
85
85
|
${R.selectedCode}
|
|
86
86
|
\`\`\`
|
|
@@ -6363,7 +6363,7 @@ ${t}`:t;return q2(b)}catch{return}},[t]),[u,A]=E.useState({type:a,css:""});retur
|
|
|
6363
6363
|
[data-diffs-header] { display: none !important; }
|
|
6364
6364
|
${v}
|
|
6365
6365
|
`})});return()=>cancelAnimationFrame(g)},[a,r.fontFamily,r.fontSize]),d?p.jsxs("div",{className:`rounded overflow-hidden border border-border/20 ${n??""}`,children:[p.jsx("div",{className:"overflow-hidden",style:s?void 0:{maxHeight:e},children:p.jsx(z2,{fileDiff:d,options:{themeType:u.type,unsafeCSS:u.css,diffStyle:"unified",disableLineNumbers:!0,disableFileHeader:!0,disableBackground:!0,overflow:"wrap"}})}),!s&&p.jsx("button",{onClick:g=>{g.stopPropagation(),c(!0)},className:"w-full text-[10px] text-muted-foreground hover:text-foreground py-1 bg-muted/20 border-t border-border/20 transition-colors",children:"Show full context"})]}):null},xW={APPROVED:{bg:"bg-success/15",text:"text-success",label:"Approved"},CHANGES_REQUESTED:{bg:"bg-destructive/15",text:"text-destructive",label:"Changes Requested"},COMMENTED:{bg:"bg-muted",text:"text-muted-foreground",label:"Commented"},DISMISSED:{bg:"bg-muted",text:"text-muted-foreground/60",label:"Dismissed"}};function ik(t){if(!t)return"";const e=new Date(t).getTime();if(isNaN(e))return"";const n=Date.now()-e,a=Math.floor(n/6e4),r=Math.floor(a/60),s=Math.floor(r/24);return a<1?"just now":a<60?`${a}m ago`:r<24?`${r}h ago`:s<30?`${s}d ago`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function $w(t){return t.kind==="comment"?t.data.createdAt:t.kind==="review"?t.data.submittedAt:t.data.comments[0]?.createdAt??""}function rk(t){return t.kind==="thread"?t.data.comments[0]?.author??"":t.data.author}function BW(t){return t.kind==="thread"?t.data.comments.map(e=>e.body).join(" "):t.data.body}function IW(t,e){const n=e.toLowerCase(),a=rk(t).toLowerCase(),r=BW(t).toLowerCase();return t.kind==="thread"?a.includes(n)||r.includes(n)||t.data.path.toLowerCase().includes(n):a.includes(n)||r.includes(n)}const SW=Ke.memo(({context:t,platformUser:e})=>{const[n,a]=E.useState(""),[r,s]=E.useState(!1),[c,d]=E.useState(!1),[u,A]=E.useState(!1),[g,b]=E.useState(null),[h,y]=E.useState(new Set),[_,k]=E.useState(new Set),v=E.useRef(null),C=E.useRef(null),x=E.useMemo(()=>{const T=[...t.comments.map(L=>({kind:"comment",data:L})),...t.reviews.filter(L=>L.state!=="COMMENTED"||L.body).map(L=>({kind:"review",data:L})),...(t.reviewThreads??[]).filter(L=>L.comments.length>0).map(L=>({kind:"thread",data:L}))];return T.sort((L,Y)=>new Date($w(L)).getTime()-new Date($w(Y)).getTime()),T},[t.comments,t.reviews,t.reviewThreads]),S=E.useMemo(()=>[...new Set(x.map(T=>rk(T)).filter(Boolean))].sort(),[x]),I=E.useMemo(()=>{let T=x;return c&&(T=T.filter(L=>L.kind!=="thread"||!L.data.isResolved)),u&&(T=T.filter(L=>L.kind!=="thread"||!L.data.isOutdated)),_.size>0&&(T=T.filter(L=>!_.has(rk(L)))),n.trim()&&(T=T.filter(L=>IW(L,n.trim()))),T},[x,n,_,c,u]),Q=E.useMemo(()=>r?[...I].reverse():I,[I,r]);E.useEffect(()=>{if(!g||!v.current)return;const T=v.current.querySelector(`[data-comment-id="${CSS.escape(g)}"]`);T&&T.scrollIntoView({behavior:"smooth",block:"center"})},[g]),E.useEffect(()=>{const T=L=>{(L.metaKey||L.ctrlKey)&&L.shiftKey&&L.key.toLowerCase()==="f"&&(L.preventDefault(),C.current?.focus())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]);const D=E.useCallback(T=>{y(L=>{const Y=new Set(L);return Y.has(T)?Y.delete(T):Y.add(T),Y})},[]),R=E.useCallback(()=>{y(new Set(Q.map(T=>T.data.id)))},[Q]),N=E.useCallback(()=>y(new Set),[]),F=E.useCallback(T=>{T.key==="Escape"&&(n?a(""):T.target.blur(),T.stopPropagation())},[n]),P=E.useCallback(()=>{a(""),k(new Set),d(!1),A(!1)},[]);return x.length===0?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center px-8",children:[p.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/50 flex items-center justify-center mb-3",children:p.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),p.jsx("p",{className:"text-xs text-muted-foreground",children:"No comments on this PR."})]}):(n.trim()||_.size>0,p.jsxs("div",{ref:v,className:"h-full flex flex-col",children:[p.jsxs("div",{className:"flex-shrink-0 bg-background border-b border-border/30 px-8 py-2 space-y-2",children:[p.jsxs("div",{className:"relative",children:[p.jsx("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/40",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),p.jsx("input",{ref:C,value:n,onChange:T=>a(T.target.value),onKeyDown:F,placeholder:"Search comments...",className:"w-full pl-8 py-1.5 pr-20 bg-muted rounded text-xs text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-1 focus:ring-primary/50"}),p.jsxs("div",{className:"absolute right-2.5 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[n.trim()&&p.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[I.length," of ",x.length]}),n&&p.jsx("button",{onClick:()=>a(""),className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",children:p.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto min-w-0",children:[_.size>0&&p.jsx("button",{onClick:()=>k(new Set),className:"text-[10px] px-1.5 py-0.5 rounded text-primary hover:underline whitespace-nowrap",children:"Show all"}),S.map(T=>p.jsx(QW,{label:T===e?`${T} (you)`:T,excluded:_.has(T),onClick:()=>{k(L=>{const Y=new Set(L);return Y.has(T)?Y.delete(T):Y.add(T),Y})}},T))]}),p.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[p.jsx("button",{onClick:()=>d(T=>!T),className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${c?"bg-success/15 text-success":"bg-muted text-muted-foreground hover:text-foreground"}`,title:c?"Show resolved threads":"Hide resolved threads",children:"Resolved"}),p.jsx("button",{onClick:()=>A(T=>!T),className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${u?"bg-warning/15 text-warning":"bg-muted text-muted-foreground hover:text-foreground"}`,title:u?"Show outdated threads":"Hide outdated threads",children:"Outdated"}),p.jsx("div",{className:"w-px h-3 bg-border/30 mx-0.5"}),p.jsx("button",{onClick:()=>s(T=>!T),className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:r?"Newest":"Oldest"}),p.jsx("button",{onClick:R,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",title:"Collapse all",children:p.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 14h16M4 10h16"})})}),p.jsx("button",{onClick:N,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",title:"Expand all",children:p.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})})]})]})]}),p.jsx(oo,{className:"flex-1 min-h-0",children:p.jsx("div",{className:"px-8 py-4",children:p.jsx("div",{className:"space-y-3 max-w-2xl",children:Q.length===0?p.jsxs("div",{className:"text-center py-8",children:[p.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No comments match your filters."}),p.jsx("button",{onClick:P,className:"text-[10px] text-primary hover:underline",children:"Clear filters"})]}):Q.map(T=>{const L=T.data.id,Y=g===L,X=h.has(L);if(T.kind==="thread")return p.jsx(DW,{thread:T.data,isSelected:Y,isCollapsed:X,onSelect:()=>b(Y?null:L),onToggleCollapse:()=>D(L)},L);const O=T.kind==="review"?T.data:null,U=O&&O.state!=="COMMENTED"?xW[O.state]??null:null;return p.jsxs("div",{"data-comment-id":L,onClick:()=>b(Y?null:L),className:`group/card rounded bg-card border p-3 cursor-pointer transition-all duration-150 shadow-[0_1px_3px_rgba(0,0,0,0.06)] ${Y?"border-primary/20 bg-primary/5 ring-1 ring-primary/10":"border-border/40 hover:shadow-[0_2px_6px_rgba(0,0,0,0.08)]"}`,children:[p.jsxs("div",{className:"flex items-center justify-between",onClick:te=>{te.stopPropagation(),D(L)},children:[p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[p.jsx("span",{className:"text-xs font-semibold text-foreground truncate",children:T.data.author||"unknown"}),U&&p.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded flex-shrink-0 ${U.bg} ${U.text}`,children:U.label})]}),p.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p.jsx("span",{className:"text-[10px] text-muted-foreground",children:ik($w(T))}),p.jsx("svg",{className:`w-3 h-3 text-muted-foreground/40 transition-transform duration-150 ${X?"":"rotate-180"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]})]}),!X&&T.data.body&&p.jsx("div",{className:"mt-2 text-xs text-foreground/80 leading-relaxed review-comment-markdown",children:p.jsx(QA,{markdown:T.data.body})}),!X&&p.jsx(nF,{url:(T.kind==="comment",T.data.url),body:T.data.body})]},L)})})})})]}))});function DW({thread:t,isSelected:e,isCollapsed:n,onSelect:a,onToggleCollapse:r}){const[s,c]=E.useState(!1),d=t.comments[0];if(!d)return null;const u=t.comments.slice(1),A=t.isResolved||t.isOutdated,g=t.startLine&&t.line&&t.startLine!==t.line?`L${t.startLine}–${t.line}`:t.line?`L${t.line}`:"";return p.jsxs("div",{"data-comment-id":t.id,onClick:a,className:`group/card rounded border p-3 cursor-pointer transition-all duration-150 ${A?"bg-card/50 shadow-[0_1px_2px_rgba(0,0,0,0.03)]":"bg-card shadow-[0_1px_3px_rgba(0,0,0,0.06)]"} ${e?"border-primary/20 bg-primary/5 ring-1 ring-primary/10":"border-border/40 hover:shadow-[0_2px_6px_rgba(0,0,0,0.08)]"}`,children:[p.jsxs("div",{className:"flex items-center justify-between",onClick:b=>{b.stopPropagation(),r()},children:[p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[p.jsx("span",{className:`text-xs font-semibold truncate ${t.isResolved?"line-through text-muted-foreground":"text-foreground"}`,children:d.author||"unknown"}),t.isOutdated&&p.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-warning/15 text-warning flex-shrink-0",children:"Outdated"}),t.isResolved&&p.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-success/15 text-success flex-shrink-0",children:"Resolved"}),t.path&&p.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground truncate flex-shrink min-w-0",children:[t.path.split("/").pop(),g?`:${g}`:""]})]}),p.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u.length>0&&p.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[u.length," repl",u.length===1?"y":"ies"]}),p.jsx("span",{className:"text-[10px] text-muted-foreground",children:ik(d.createdAt)}),p.jsx("svg",{className:`w-3 h-3 text-muted-foreground/40 transition-transform duration-150 ${n?"":"rotate-180"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]})]}),!n&&p.jsxs(p.Fragment,{children:[d.diffHunk&&p.jsx("div",{className:"mt-2",children:p.jsx(EW,{hunk:d.diffHunk,maxHeight:96})}),d.body&&p.jsxs("div",{className:`relative mt-2 ${A&&!s?"max-h-16 overflow-hidden":""}`,children:[p.jsx("div",{className:`text-xs leading-relaxed review-comment-markdown ${A&&!s?"text-muted-foreground":"text-foreground/80"}`,children:p.jsx(QA,{markdown:d.body})}),A&&!s&&p.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-card to-transparent pointer-events-none"})]}),A&&!s&&p.jsxs("button",{onClick:b=>{b.stopPropagation(),c(!0)},className:"mt-1 text-[10px] text-primary/70 hover:text-primary transition-colors",children:["Show full comment",u.length>0?` + ${u.length} repl${u.length===1?"y":"ies"}`:""]}),(!A||s)&&u.length>0&&p.jsx("div",{className:"mt-2 ml-4 space-y-2 border-l border-border/30 pl-3",children:u.map(b=>p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[p.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:b.author}),p.jsx("span",{className:"text-[10px] text-muted-foreground",children:ik(b.createdAt)})]}),p.jsx("div",{className:"text-xs text-foreground/80 leading-relaxed review-comment-markdown",children:p.jsx(QA,{markdown:b.body})})]},b.id))}),p.jsx(nF,{url:d.url,body:d.body})]})]})}function nF({url:t,body:e}){return!t&&!e?null:p.jsxs("div",{className:"mt-2 pt-2 border-t border-border/20 flex items-center justify-end gap-1 opacity-0 group-hover/card:opacity-100 transition-opacity duration-100",children:[t&&p.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:n=>n.stopPropagation(),className:"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted/30 transition-colors",children:[p.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})}),t.includes("gitlab")?"View on GitLab":"View on GitHub"]}),p.jsx(io,{text:e,variant:"inline",label:"Copy"})]})}function QW({label:t,excluded:e,onClick:n}){return p.jsx("button",{onClick:n,className:`text-[10px] px-1.5 py-0.5 rounded whitespace-nowrap transition-colors ${e?"bg-muted/50 text-muted-foreground/40 line-through":"bg-muted text-muted-foreground hover:text-foreground"}`,title:e?`Show ${t}`:`Hide ${t}`,children:t})}const NW=()=>{const{prContext:t,isPRContextLoading:e,prContextError:n,fetchPRContext:a,platformUser:r}=Vc();return E.useEffect(()=>{!t&&!n&&!e&&a()},[t,n,e,a]),e?p.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Loading comments…"}):n?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-3 px-6 text-center",children:[p.jsx("div",{className:"text-destructive text-sm",children:n}),p.jsx("button",{type:"button",onClick:a,className:"px-2.5 py-1 rounded-md text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",children:"Retry"})]}):t?p.jsx("div",{className:"h-full overflow-hidden",children:p.jsx(SW,{context:t,platformUser:r})}):null},RW={APPROVED:{bg:"bg-success/15",text:"text-success",label:"Approved"},CHANGES_REQUESTED:{bg:"bg-destructive/15",text:"text-destructive",label:"Changes Requested"},REVIEW_REQUIRED:{bg:"bg-yellow-500/15",text:"text-yellow-500",label:"Review Required"}},L1={CLEAN:{bg:"bg-success/15",text:"text-success",label:"Ready to merge"},BLOCKED:{bg:"bg-yellow-500/15",text:"text-yellow-500",label:"Blocked"},BEHIND:{bg:"bg-yellow-500/15",text:"text-yellow-500",label:"Behind base branch"},DIRTY:{bg:"bg-destructive/15",text:"text-destructive",label:"Has conflicts"},UNKNOWN:{bg:"bg-muted",text:"text-muted-foreground",label:"Unknown"}};function TW({check:t}){return t.status!=="COMPLETED"?p.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}):t.conclusion==="SUCCESS"?p.jsx("svg",{className:"w-3.5 h-3.5 text-success",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):t.conclusion==="FAILURE"||t.conclusion==="TIMED_OUT"?p.jsx("svg",{className:"w-3.5 h-3.5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):t.conclusion==="SKIPPED"||t.conclusion==="NEUTRAL"?p.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20 12H4"})}):p.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("circle",{cx:"12",cy:"12",r:"10"})})}const FW=({context:t})=>{const e=E.useMemo(()=>{const u=new Map;for(const A of t.checks){const g=A.workflowName||"Other",b=u.get(g)||[];b.push(A),u.set(g,b)}return u},[t.checks]),n=E.useMemo(()=>{const u=t.checks.length,A=t.checks.filter(y=>y.conclusion==="SUCCESS").length,g=t.checks.filter(y=>y.conclusion==="FAILURE"||y.conclusion==="TIMED_OUT").length,b=t.checks.filter(y=>y.status!=="COMPLETED").length,h=t.checks.filter(y=>y.conclusion==="SKIPPED"||y.conclusion==="NEUTRAL").length;return{total:u,passed:A,failed:g,pending:b,skipped:h}},[t.checks]),a=t.state==="MERGED",r=t.state==="CLOSED",s=RW[t.reviewDecision],c=a?{bg:"bg-violet-500/15",text:"text-violet-400",label:"Merged"}:r?{bg:"bg-destructive/15",text:"text-destructive",label:"Closed"}:L1[t.mergeStateStatus]??L1.UNKNOWN,d=!a&&!r&&t.mergeable==="CONFLICTING";return p.jsxs("div",{className:"px-8 py-4 space-y-4 max-w-2xl",children:[p.jsxs("div",{className:"space-y-2",children:[p.jsx("h3",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Merge Status"}),p.jsxs("div",{className:"space-y-1.5",children:[s&&p.jsx("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded ${s.bg}`,children:p.jsx("span",{className:`text-xs font-medium ${s.text}`,children:s.label})}),p.jsx("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded ${c.bg}`,children:p.jsx("span",{className:`text-xs font-medium ${c.text}`,children:d?"Has merge conflicts":c.label})})]})]}),t.checks.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Checks"}),p.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:[n.passed,"/",n.total," passed",n.failed>0&&p.jsxs("span",{className:"text-destructive ml-1",children:[n.failed," failed"]}),n.pending>0&&p.jsxs("span",{className:"text-yellow-500 ml-1",children:[n.pending," pending"]})]})]}),p.jsx("div",{className:"space-y-4",children:Array.from(e.entries()).map(([u,A])=>p.jsxs("div",{children:[p.jsx("div",{className:"text-[10px] font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider",children:u}),p.jsx("div",{className:"space-y-1",children:A.map((g,b)=>p.jsxs("a",{href:g.detailsUrl||void 0,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/30 transition-colors group cursor-pointer",children:[p.jsx(TW,{check:g}),p.jsx("span",{className:"text-xs text-primary/70 truncate group-hover:text-primary group-hover:underline",children:g.name}),p.jsx("svg",{className:"w-3 h-3 text-muted-foreground/30 ml-auto flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]},`${g.name}-${b}`))})]},u))})]}),t.checks.length===0&&!s&&p.jsx("div",{className:"flex flex-col items-center justify-center h-24 text-center",children:p.jsx("p",{className:"text-xs text-muted-foreground",children:"No checks configured."})})]})},LW=()=>{const{prContext:t,isPRContextLoading:e,prContextError:n,fetchPRContext:a}=Vc();return E.useEffect(()=>{!t&&!n&&!e&&a()},[t,n,e,a]),e?p.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Loading checks…"}):n?p.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-3 px-6 text-center",children:[p.jsx("div",{className:"text-destructive text-sm",children:n}),p.jsx("button",{type:"button",onClick:a,className:"px-2.5 py-1 rounded-md text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",children:"Retry"})]}):t?p.jsx(oo,{className:"h-full",children:p.jsx(FW,{context:t})}):null},MW={[fr.DIFF]:pW,[fr.AGENT_JOB_DETAIL]:gW,[fr.PR_SUMMARY]:CW,[fr.PR_COMMENTS]:NW,[fr.PR_CHECKS]:LW},OW=t=>{const[e,n]=E.useState(t.api.title??t.api.id);E.useEffect(()=>{const r=t.api.onDidTitleChange(()=>{n(t.api.title??t.api.id)});return()=>r.dispose()},[t.api]);const a=r=>{r.stopPropagation(),t.api.close()};return p.jsxs("div",{className:"dv-review-tab",title:e,children:[p.jsx("span",{className:"dv-review-tab-label",children:e}),p.jsx("button",{className:"dv-review-tab-close",onClick:a,"aria-label":"Close",children:p.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:p.jsx("path",{d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.707.708L7.293 8l-3.646 3.646.707.708L8 8.707z"})})})]})};function PW(t){const[e,n]=E.useState(null),[a,r]=E.useState(!1),[s,c]=E.useState(null),d=E.useRef(!1),u=E.useCallback(async()=>{if(!(!t||d.current)){d.current=!0,r(!0),c(null);try{const A=await fetch("/api/pr-context");if(!A.ok){const b=await A.json().catch(()=>({}));throw new Error(b.error||`HTTP ${A.status}`)}const g=await A.json();n(g)}catch(A){const g=A instanceof Error?A.message:"Failed to load PR context";c(g),d.current=!1}finally{r(!1)}}},[t]);return{prContext:e,isLoading:a,error:s,fetchContext:u}}function Kw(t){const e=[],n=t.split(/^diff --git /m).filter(Boolean);for(const a of n){const r=a.split(`
|
|
6366
|
-
`),s=r[0]?.match(/a\/(.+) b\/(.+)/);if(!s)continue;const c=s[1],d=s[2];let u=0,A=0;for(const g of r)g.startsWith("+")&&!g.startsWith("+++")&&u++,g.startsWith("-")&&!g.startsWith("---")&&A++;e.push({path:d,oldPath:c!==d?c:void 0,patch:"diff --git "+a,additions:u,deletions:A})}return e}function M1(t){return t.split("/").pop()??t}const jW=()=>{const{resolvedMode:t}=Pd(),[e,n]=E.useState(null),[a,r]=E.useState([]),[s,c]=E.useState(0),[d,u]=E.useState([]),[A,g]=E.useState(null),[b,h]=E.useState(null),[y,_]=E.useState(!1),[k,v]=E.useState(!1),[C,x]=E.useState(!1),[S,I]=E.useState(!1),[Q,D]=E.useState(!0),R=zn("diffStyle"),N=zn("diffOverflow"),F=zn("diffIndicators"),P=zn("diffLineDiffType"),T=zn("diffShowLineNumbers"),L=zn("diffShowBackground"),Y=zn("diffFontFamily"),X=zn("diffFontSize");E.useEffect(()=>{Y?(K1(Y),document.documentElement.style.setProperty("--diff-font-override",`'${Y}', monospace`)):document.documentElement.style.removeProperty("--diff-font-override"),X?document.documentElement.style.setProperty("--diff-font-size-override",X):document.documentElement.style.removeProperty("--diff-font-size-override")},[Y,X]);const[q,O]=E.useState(!0),[U,te]=E.useState(null),[oe,de]=E.useState("idle"),[j,W]=E.useState(new Set),[H,ee]=E.useState(!1),[Z,ce]=E.useState(null),[ie,ge]=E.useState(),[se,$]=E.useState(!1),[pe,me]=E.useState("uncommitted"),[Ie,Ne]=E.useState(null),[He,Je]=E.useState(null),[lt,xt]=E.useState(!1),[gt,Le]=E.useState(null),[nt,dt]=E.useState(!1),[At,Xe]=E.useState(!1),[yt,vt]=E.useState(!1),[rt,Ht]=E.useState(!1),[hn,yn]=E.useState(!1),[kn,tn]=E.useState(!1),[un,zt]=E.useState(!0),[Bt,Rt]=E.useState(null);E.useEffect(()=>{document.title=Bt?`${Bt.display} · Code Review`:"Code Review"},[Bt]);const[et,ae]=E.useState(null),[Re,Ye]=E.useState(()=>Ee.getItem("plannotator-review-dest")==="agent"?"agent":"platform"),[Dt,Se]=E.useState(!1),[Be,z]=E.useState(!1),[be,_e]=E.useState(null),[Me,Ot]=E.useState(null),[bt,Oe]=E.useState(null),[Fe,Ue]=E.useState(""),[Yt,_t]=E.useState(()=>{const J=Ee.getItem("plannotator-platform-open-pr");if(J!==null)return J!=="false";const he=Ee.getItem("plannotator-github-open-pr");return he!==null?(Ee.setItem("plannotator-platform-open-pr",he),he!=="false"):!0}),pn=Re==="platform"&&!!et,qn=et?X8(et):"GitHub",Mn=et?_R(et):"PR",_a=et?kR(et):"",An=et?vR(et):"",nn="0.17.8",ka=zn("displayName");E.useCallback(()=>{h(null)},[]);const{editorAnnotations:va,deleteEditorAnnotation:Xi}=CP(),{externalAnnotations:On,updateExternalAnnotation:er,deleteExternalAnnotation:ze}=BP({enabled:!!Z}),V=QP({enabled:!!Z}),[ke,je]=E.useState(null),Tt=E.useRef(a);Tt.current=a;const Jt=E.useRef(!0),{prContext:ft,isLoading:Nn,error:Un,fetchContext:Zn}=PW(et??null),xe=E.useCallback(J=>{const he=a.find($e=>$e.path===J);if(!he)return;if(!ke){const $e=a.findIndex(ht=>ht.path===J);$e!==-1&&c($e);return}const Te=ke.getPanel(Ec);if(Te){if(bA(Te.params)===J){ke.activePanel?.id!==Ec&&Te.api.setActive();const ht=a.findIndex($t=>$t.path===J);ht!==-1&&c(ht),Jt.current=!1;return}h(null),Te.api.updateParameters({filePath:J}),Te.api.setTitle(M1(he.path)),Te.api.setActive()}else h(null),ke.addPanel({id:Ec,component:fr.DIFF,title:M1(he.path),params:{filePath:J}});c(a.findIndex($e=>$e.path===J)),Jt.current=!1},[ke,a]),Pe=E.useCallback(J=>{xe(J.filePath)},[xe]),{searchQuery:ut,debouncedSearchQuery:Ft,isSearchPending:an,isSearchOpen:Hn,activeSearchMatchId:ma,activeSearchMatch:ra,activeFileSearchMatches:en,searchMatches:ga,searchGroups:Uo,searchInputRef:vr,openSearch:tr,closeSearch:Ni,clearSearch:Cr,stepSearchMatch:oa,handleSearchInputChange:so,handleSelectSearchMatch:nr}=kP({files:a,activeFilePath:a[s]?.path??null,onRevealMatch:Pe}),vn=a.length>0,Yn=vn||!!Ie?.diffOptions?.length||!!Ie?.worktrees?.length,rn=E.useMemo(()=>On.length===0?d:[...d.filter(he=>he.source?!On.some(Te=>Te.source===he.source&&Te.type===he.type&&Te.filePath===he.filePath&&Te.lineStart===he.lineStart&&Te.lineEnd===he.lineEnd&&Te.side===he.side):!0),...On],[d,On]),ui=E.useRef(rn);ui.current=rn;const{draftBanner:We,restoreDraft:Er,dismissDraft:Sn}=lP({annotations:rn,viewedFiles:j,isApiMode:!!Z,submitted:!!rt}),qt=E.useCallback(()=>{const J=Er();J.annotations.length>0&&u(J.annotations),J.viewedFiles.length>0&&W(new Set(J.viewedFiles))},[Er]),[Ra,Pa]=E.useState(!1),[Ri,pi]=E.useState([]),[De,Ge]=E.useState(()=>{const J=ao(),he=J.providerId;return{providerId:he,model:he?J.preferredModels[he]??null:null,reasoningEffort:null}}),[ot,Ct]=E.useState(!1),[on,ba]=E.useState(!1),[co,lo]=E.useState(!1),[uo,Ai]=E.useState(!1),[rl,xr]=E.useState(void 0),sn=pP({patch:e?.rawPatch??"",providerId:De.providerId,model:De.model,reasoningEffort:De.reasoningEffort});E.useEffect(()=>{fetch("/api/ai/capabilities").then(J=>J.ok?J.json():null).then(J=>{if(J?.available){Pa(!0);const he=J.providers??[];pi(he),he.length>0&&eP()&&Ct(!0)}ba(!0)}).catch(()=>{ba(!0)})},[]);const Rs=E.useCallback(J=>{Ge(he=>{const Te={...he,...J};J.providerId!==void 0&&J.providerId!==he.providerId&&(Te.model=J.providerId?lO(J.providerId):null);const $e=ao();return RA({...$e,providerId:Te.providerId}),Te}),sn.resetSession()},[sn]),Ho=E.useCallback(J=>{if(!b||!a[s])return;const he=Math.min(b.start,b.end),Te=Math.max(b.start,b.end),$e=b.side==="additions"?"new":"old",ht=u_(a[s].patch,he,Te,$e);sn.ask({prompt:J,filePath:a[s].path,lineStart:he,lineEnd:Te,side:$e,selectedCode:ht||void 0})},[b,a,s,sn]),ol=E.useCallback(J=>{xr("ai"),O(!0),J&&(sa(J),setTimeout(()=>sa(null),500))},[]),Ts=E.useCallback((J,he,Te,$e)=>{xe(J),h({start:he,end:Te,side:$e==="new"?"additions":"deletions"})},[xe]),Yo=E.useMemo(()=>{if(!b||!a[s])return[];const J=a[s].path,he=Math.min(b.start,b.end),Te=Math.max(b.start,b.end),$e=b.side==="additions"?"new":"old";return sn.messages.filter(ht=>{const $t=ht.question;return $t.filePath===J&&$t.side===$e&&$t.lineStart!=null&&$t.lineEnd!=null&&$t.lineStart<=Te&&$t.lineEnd>=he})},[b,a,s,sn.messages]),[Wd,sa]=E.useState(null),ar=E.useCallback(J=>{sa(J),xr("ai"),O(!0),setTimeout(()=>sa(null),500)},[]),Fs=E.useCallback(J=>{sn.ask({prompt:J})},[sn.ask]),Br=TB({storageKey:"plannotator-review-panel-width"}),sl=TB({storageKey:"plannotator-filetree-width",defaultWidth:256,minWidth:160,maxWidth:400,side:"left"}),cl=Br.isDragging||sl.isDragging,ll=E.useCallback(J=>{je(J.api),J.api.onDidActivePanelChange(Te=>{if(!Te||!X6(Te.id))return;const $e=bA(Te.params);if(!$e)return;const ht=Tt.current.findIndex($t=>$t.path===$e);ht!==-1&&c(ht)});const he=()=>{const $e=(J.api.totalPanels===1&&J.api.groups.length===1?J.api.groups[0]?.panels[0]:void 0)?.id===Ec;for(const ht of J.api.groups)ht.header.hidden=$e};J.api.onDidAddPanel(he),J.api.onDidRemovePanel(he),J.api.onDidAddGroup(he),J.api.onDidRemoveGroup(he),J.api.onDidMovePanel(he),J.api.onDidLayoutChange(he),he()},[]);E.useEffect(()=>{!ke||!Jt.current||a.length===0||xe(a[0].path)},[ke,a,xe]);const $o=E.useCallback(J=>{const he=ke;if(!he)return;const Te=W6(J),$e=he.getPanel(Te);if($e){$e.api.setActive();return}const ht=V.jobs.find($t=>$t.id===J);he.addPanel({id:Te,component:fr.AGENT_JOB_DETAIL,title:ht?.label??`Job ${J.slice(0,8)}`,params:{jobId:J}})},[ke,V.jobs]),Ir=E.useCallback(J=>{const he=ke;if(!he)return;const Te={summary:{id:Z6,component:fr.PR_SUMMARY,title:"PR Summary"},comments:{id:V6,component:fr.PR_COMMENTS,title:"PR Comments"},checks:{id:J6,component:fr.PR_CHECKS,title:"PR Checks"}}[J],$e=he.getPanel(Te.id);if($e){$e.api.setActive();return}he.addPanel({id:Te.id,component:Te.component,title:Te.title})},[ke]);E.useEffect(()=>{const J=he=>{if((he.metaKey||he.ctrlKey)&&he.key.toLowerCase()==="f"&&!LB(he.target)){vn&&(he.preventDefault(),tr());return}if((he.key==="Enter"||he.key==="F3")&&ga.length>0&&!an&&!LB(he.target)){he.preventDefault(),oa(he.shiftKey?-1:1);return}he.key==="Escape"&&(Dt?Se(!1):y?_(!1):Hn?ut?Cr():Ni():ut&&Cr()),(he.metaKey||he.ctrlKey)&&he.shiftKey&&he.key==="c"&&(he.preventDefault(),iu())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[y,Dt,Hn,ut,ga,an,tr,oa,Cr,Ni,vn]),E.useEffect(()=>{fetch("/api/diff").then(J=>{if(!J.ok)throw new Error("Not in API mode");return J.json()}).then(J=>{Tn.init(J.serverConfig),ge(J.serverConfig?.gitUser);const he=Kw(J.rawPatch);n({files:he,rawPatch:J.rawPatch,gitRef:J.gitRef,origin:J.origin,diffType:J.diffType,gitContext:J.gitContext,sharingEnabled:J.sharingEnabled}),r(he),J.origin&&ce(J.origin),J.diffType&&me(J.diffType),J.gitContext&&Ne(J.gitContext),J.agentCwd&&Je(J.agentCwd),J.sharingEnabled!==void 0&&zt(J.sharingEnabled),J.repoInfo&&Rt(J.repoInfo),J.prMetadata&&ae(J.prMetadata),J.platformUser&&Ot(J.platformUser),J.viewedFiles&&J.viewedFiles.length>0&&W(new Set(J.viewedFiles)),J.error&&Le(J.error),J.isWSL&&$(!0),J.diffType&&!J.prMetadata&&J.gitContext?.vcsType!=="p4"&&aP()&&Ai(!0)}).catch(()=>{const J=Kw(iQ);n({files:J,rawPatch:iQ,gitRef:"demo"}),r(J)}).finally(()=>D(!1))},[]),E.useEffect(()=>{uo&&on&&!ot&&(Ai(!1),lo(!0))},[uo,on,ot]);const dl=E.useCallback(J=>{Tn.set("diffStyle",J)},[]),Zd=E.useCallback(J=>{h(J)},[]),Vd=E.useCallback((J,he,Te,$e,ht,$t,Ca)=>{if(!b||!a[s])return;const Vn=Math.min(b.start,b.end),at=Math.max(b.start,b.end),Qr={id:d_(),type:J,scope:"line",filePath:a[s].path,lineStart:Vn,lineEnd:at,side:b.side==="additions"?"new":"old",text:he,suggestedCode:Te,originalCode:$e,...Ca&&{charStart:Ca.charStart,charEnd:Ca.charEnd,tokenText:Ca.tokenText},createdAt:Date.now(),author:ka,conventionalLabel:ht,decorations:$t};u(Fi=>[...Fi,Qr]),h(null)},[b,a,s,ka]),Jd=E.useCallback(J=>{const he=a[s],Te=J.trim();if(!he||!Te)return;const $e={id:d_(),type:"comment",scope:"file",filePath:he.path,lineStart:1,lineEnd:1,side:"new",text:Te,createdAt:Date.now(),author:ka};u(ht=>[...ht,$e])},[a,s,ka]),Ls=E.useCallback((J,he,Te,$e,ht,$t)=>{const Ca=ui.current.find(at=>at.id===J),Vn={...he!==void 0&&{text:he},...Te!==void 0&&{suggestedCode:Te},...$e!==void 0&&{originalCode:$e},...ht!==void 0&&{conventionalLabel:ht??void 0},...$t!==void 0&&{decorations:$t}};if(Ca?.source&&On.some(at=>at.id===J)){er(J,Vn);return}u(at=>at.map(Qr=>Qr.id===J?{...Qr,...Vn}:Qr))},[er,On]),ul=E.useCallback(J=>{if(ui.current.find(Te=>Te.id===J)?.source&&On.some(Te=>Te.id===J)){ze(J),A===J&&g(null);return}u(Te=>Te.filter($e=>$e.id!==J)),A===J&&g(null)},[A,ze,On]),um=E.useCallback((J,he)=>{u(Te=>Te.map($e=>$e.author===J?{...$e,author:he}:$e))},[]),pm=E.useCallback(J=>{const he=a[J];he&&xe(he.path)},[a,xe]),Am=E.useCallback(J=>{const he=a[J];he&&xe(he.path)},[a,xe]),Xd=E.useCallback(J=>{const he=a[J];he&&xe(he.path)},[a,xe]),Ms=E.useCallback(J=>{W(he=>{const Te=new Set(he),$e=!he.has(J);return $e?Te.add(J):Te.delete(J),et&&et.platform==="github"&&fetch("/api/pr-viewed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePaths:[J],viewed:$e})}).catch(()=>{}),Te})},[et]),{activeWorktreePath:Ti,activeDiffBase:Sr}=E.useMemo(()=>{if(pe.startsWith("worktree:")){const J=pe.slice(9),he=J.lastIndexOf(":");if(he!==-1){const Te=J.slice(he+1);if(["uncommitted","staged","unstaged","last-commit","branch"].includes(Te))return{activeWorktreePath:J.slice(0,he),activeDiffBase:Te}}return{activeWorktreePath:J,activeDiffBase:"uncommitted"}}return{activeWorktreePath:null,activeDiffBase:pe}},[pe]),mm=E.useCallback(J=>W(he=>new Set(he).add(J)),[]),{stagedFiles:pl,stagingFile:Os,canStageFiles:gm,stageFile:eu,resetStagedFiles:tu,stageError:Al}=uP({activeDiffBase:Sr,onFileViewed:mm}),nu=gm&&!et,Ps=E.useCallback(async J=>{xt(!0);try{const he=await fetch("/api/diff/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({diffType:J})});if(!he.ok)throw new Error("Failed to switch diff");const Te=await he.json(),$e=Kw(Te.rawPatch);ke?.getPanel(Ec)?.api.close(),Jt.current=!0,n(ht=>ht&&{...ht,rawPatch:Te.rawPatch,gitRef:Te.gitRef,diffType:Te.diffType}),r($e),me(Te.diffType),c(0),h(null),Le(Te.error||null),tu()}catch(he){console.error("Failed to switch diff:",he),Le(he instanceof Error?he.message:"Failed to switch diff")}finally{xt(!1)}},[ke,tu]),au=E.useCallback(async J=>{const he=Ti?`worktree:${Ti}:${J}`:J;he!==pe&&await Ps(he)},[pe,Ti,Ps]),bm=E.useCallback(async J=>{if(J===Ti)return;const he=J?`worktree:${J}:uncommitted`:"uncommitted";await Ps(he)},[Ti,Ps]),ml=E.useCallback(J=>{if(!J){g(null);return}const he=rn.find($e=>$e.id===J);if(!he){g(J);return}const Te=a.findIndex($e=>$e.path===he.filePath);Te!==-1&&Xd(Te),g(J)},[rn,a,Xd]),fm=E.useMemo(()=>({files:a,focusedFileIndex:s,focusedFilePath:a[s]?.path??null,diffStyle:R,diffOverflow:N,diffIndicators:F,lineDiffType:P,disableLineNumbers:!T,disableBackground:!L,fontFamily:Y||void 0,fontSize:X||void 0,allAnnotations:rn,externalAnnotations:On,selectedAnnotationId:A,pendingSelection:b,onLineSelection:Zd,onAddAnnotation:Vd,onAddFileComment:Jd,onEditAnnotation:Ls,onSelectAnnotation:ml,onDeleteAnnotation:ul,viewedFiles:j,onToggleViewed:Ms,stagedFiles:pl,stagingFile:Os,onStage:eu,canStageFiles:nu,stageError:Al,searchQuery:an?"":Ft,isSearchPending:an,debouncedSearchQuery:Ft,activeFileSearchMatches:en,activeSearchMatchId:ma,activeSearchMatch:ra?.filePath===a[s]?.path?ra:null,aiAvailable:Ra,aiMessages:sn.messages,onAskAI:Ho,isAILoading:sn.isCreatingSession||sn.isStreaming,onViewAIResponse:ol,onClickAIMarker:ar,aiHistoryForSelection:Yo,agentJobs:V.jobs,prMetadata:et,prContext:ft,isPRContextLoading:Nn,prContextError:Un,fetchPRContext:Zn,platformUser:Me,openDiffFile:xe}),[a,s,R,N,F,P,T,L,Y,X,rn,On,A,b,Zd,Vd,Jd,Ls,ml,ul,j,Ms,pl,Os,eu,nu,Al,an,Ft,en,ma,ra,Ra,sn.messages,sn.isCreatingSession,sn.isStreaming,Ho,ol,ar,Yo,V.jobs,et,ft,Nn,Un,Zn,Me,xe]),hm=E.useMemo(()=>({jobLogs:V.jobLogs}),[V.jobLogs]),iu=E.useCallback(async()=>{if(e)try{await navigator.clipboard.writeText(e.rawPatch),de("success"),setTimeout(()=>de("idle"),2e3)}catch(J){console.error("Failed to copy:",J),de("error"),setTimeout(()=>de("idle"),2e3)}},[e]),ym=E.useCallback(async()=>{if(rn.length===0){I(!0);return}try{const J=I_(rn,et);await navigator.clipboard.writeText(J),te("Feedback copied!"),setTimeout(()=>te(null),2e3)}catch(J){console.error("Failed to copy:",J),te("Failed to copy"),setTimeout(()=>te(null),2e3)}},[rn,et]),Dr=E.useMemo(()=>{let J=I_(rn,et);return va.length>0&&(J+=TP(va)),J},[rn,et,va]),Rn=rn.length+va.length,gl=E.useCallback(async()=>{if(Rn===0){I(!0);return}dt(!0);try{const J=Xp(),he=cB(J);if((await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:!1,feedback:Dr,annotations:rn,...he&&{agentSwitch:he}})})).ok)Ht("feedback");else throw new Error("Failed to send")}catch(J){console.error("Failed to send feedback:",J),te("Failed to send"),setTimeout(()=>te(null),2e3),dt(!1)}},[Rn,Dr,rn]),js=E.useCallback(async()=>{vt(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)Ht("exited");else throw new Error("Failed to exit")}catch(J){console.error("Failed to exit review:",J),vt(!1)}},[]),Ko=E.useCallback(async()=>{Xe(!0);try{if((await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:!0,feedback:"LGTM - no changes requested.",annotations:[]})})).ok)Ht("approved");else throw new Error("Failed to send")}catch(J){console.error("Failed to approve:",J),te("Failed to send"),setTimeout(()=>te(null),2e3),Xe(!1)}},[]),bl=E.useCallback((J,he)=>{const Te=rn.filter(at=>(at.scope??"line")==="line"),$e=rn.filter(at=>at.scope==="file"),ht=[];if($e.length>0)for(const at of $e)at.text&&ht.push(`**${at.filePath}:** ${at.text}`);const $t=ht.length>0?`${he?he+`
|
|
6366
|
+
`),s=r[0]?.match(/a\/(.+) b\/(.+)/);if(!s)continue;const c=s[1],d=s[2];let u=0,A=0;for(const g of r)g.startsWith("+")&&!g.startsWith("+++")&&u++,g.startsWith("-")&&!g.startsWith("---")&&A++;e.push({path:d,oldPath:c!==d?c:void 0,patch:"diff --git "+a,additions:u,deletions:A})}return e}function M1(t){return t.split("/").pop()??t}const jW=()=>{const{resolvedMode:t}=Pd(),[e,n]=E.useState(null),[a,r]=E.useState([]),[s,c]=E.useState(0),[d,u]=E.useState([]),[A,g]=E.useState(null),[b,h]=E.useState(null),[y,_]=E.useState(!1),[k,v]=E.useState(!1),[C,x]=E.useState(!1),[S,I]=E.useState(!1),[Q,D]=E.useState(!0),R=zn("diffStyle"),N=zn("diffOverflow"),F=zn("diffIndicators"),P=zn("diffLineDiffType"),T=zn("diffShowLineNumbers"),L=zn("diffShowBackground"),Y=zn("diffFontFamily"),X=zn("diffFontSize");E.useEffect(()=>{Y?(K1(Y),document.documentElement.style.setProperty("--diff-font-override",`'${Y}', monospace`)):document.documentElement.style.removeProperty("--diff-font-override"),X?document.documentElement.style.setProperty("--diff-font-size-override",X):document.documentElement.style.removeProperty("--diff-font-size-override")},[Y,X]);const[q,O]=E.useState(!0),[U,te]=E.useState(null),[oe,de]=E.useState("idle"),[j,W]=E.useState(new Set),[H,ee]=E.useState(!1),[Z,ce]=E.useState(null),[ie,ge]=E.useState(),[se,$]=E.useState(!1),[pe,me]=E.useState("uncommitted"),[Ie,Ne]=E.useState(null),[He,Je]=E.useState(null),[lt,xt]=E.useState(!1),[gt,Le]=E.useState(null),[nt,dt]=E.useState(!1),[At,Xe]=E.useState(!1),[yt,vt]=E.useState(!1),[rt,Ht]=E.useState(!1),[hn,yn]=E.useState(!1),[kn,tn]=E.useState(!1),[un,zt]=E.useState(!0),[Bt,Rt]=E.useState(null);E.useEffect(()=>{document.title=Bt?`${Bt.display} · Code Review`:"Code Review"},[Bt]);const[et,ae]=E.useState(null),[Re,Ye]=E.useState(()=>Ee.getItem("plannotator-review-dest")==="agent"?"agent":"platform"),[Dt,Se]=E.useState(!1),[Be,z]=E.useState(!1),[be,_e]=E.useState(null),[Me,Ot]=E.useState(null),[bt,Oe]=E.useState(null),[Fe,Ue]=E.useState(""),[Yt,_t]=E.useState(()=>{const J=Ee.getItem("plannotator-platform-open-pr");if(J!==null)return J!=="false";const he=Ee.getItem("plannotator-github-open-pr");return he!==null?(Ee.setItem("plannotator-platform-open-pr",he),he!=="false"):!0}),pn=Re==="platform"&&!!et,qn=et?X8(et):"GitHub",Mn=et?_R(et):"PR",_a=et?kR(et):"",An=et?vR(et):"",nn="0.17.9",ka=zn("displayName");E.useCallback(()=>{h(null)},[]);const{editorAnnotations:va,deleteEditorAnnotation:Xi}=CP(),{externalAnnotations:On,updateExternalAnnotation:er,deleteExternalAnnotation:ze}=BP({enabled:!!Z}),V=QP({enabled:!!Z}),[ke,je]=E.useState(null),Tt=E.useRef(a);Tt.current=a;const Jt=E.useRef(!0),{prContext:ft,isLoading:Nn,error:Un,fetchContext:Zn}=PW(et??null),xe=E.useCallback(J=>{const he=a.find($e=>$e.path===J);if(!he)return;if(!ke){const $e=a.findIndex(ht=>ht.path===J);$e!==-1&&c($e);return}const Te=ke.getPanel(Ec);if(Te){if(bA(Te.params)===J){ke.activePanel?.id!==Ec&&Te.api.setActive();const ht=a.findIndex($t=>$t.path===J);ht!==-1&&c(ht),Jt.current=!1;return}h(null),Te.api.updateParameters({filePath:J}),Te.api.setTitle(M1(he.path)),Te.api.setActive()}else h(null),ke.addPanel({id:Ec,component:fr.DIFF,title:M1(he.path),params:{filePath:J}});c(a.findIndex($e=>$e.path===J)),Jt.current=!1},[ke,a]),Pe=E.useCallback(J=>{xe(J.filePath)},[xe]),{searchQuery:ut,debouncedSearchQuery:Ft,isSearchPending:an,isSearchOpen:Hn,activeSearchMatchId:ma,activeSearchMatch:ra,activeFileSearchMatches:en,searchMatches:ga,searchGroups:Uo,searchInputRef:vr,openSearch:tr,closeSearch:Ni,clearSearch:Cr,stepSearchMatch:oa,handleSearchInputChange:so,handleSelectSearchMatch:nr}=kP({files:a,activeFilePath:a[s]?.path??null,onRevealMatch:Pe}),vn=a.length>0,Yn=vn||!!Ie?.diffOptions?.length||!!Ie?.worktrees?.length,rn=E.useMemo(()=>On.length===0?d:[...d.filter(he=>he.source?!On.some(Te=>Te.source===he.source&&Te.type===he.type&&Te.filePath===he.filePath&&Te.lineStart===he.lineStart&&Te.lineEnd===he.lineEnd&&Te.side===he.side):!0),...On],[d,On]),ui=E.useRef(rn);ui.current=rn;const{draftBanner:We,restoreDraft:Er,dismissDraft:Sn}=lP({annotations:rn,viewedFiles:j,isApiMode:!!Z,submitted:!!rt}),qt=E.useCallback(()=>{const J=Er();J.annotations.length>0&&u(J.annotations),J.viewedFiles.length>0&&W(new Set(J.viewedFiles))},[Er]),[Ra,Pa]=E.useState(!1),[Ri,pi]=E.useState([]),[De,Ge]=E.useState(()=>{const J=ao(),he=J.providerId;return{providerId:he,model:he?J.preferredModels[he]??null:null,reasoningEffort:null}}),[ot,Ct]=E.useState(!1),[on,ba]=E.useState(!1),[co,lo]=E.useState(!1),[uo,Ai]=E.useState(!1),[rl,xr]=E.useState(void 0),sn=pP({patch:e?.rawPatch??"",providerId:De.providerId,model:De.model,reasoningEffort:De.reasoningEffort});E.useEffect(()=>{fetch("/api/ai/capabilities").then(J=>J.ok?J.json():null).then(J=>{if(J?.available){Pa(!0);const he=J.providers??[];pi(he),he.length>0&&eP()&&Ct(!0)}ba(!0)}).catch(()=>{ba(!0)})},[]);const Rs=E.useCallback(J=>{Ge(he=>{const Te={...he,...J};J.providerId!==void 0&&J.providerId!==he.providerId&&(Te.model=J.providerId?lO(J.providerId):null);const $e=ao();return RA({...$e,providerId:Te.providerId}),Te}),sn.resetSession()},[sn]),Ho=E.useCallback(J=>{if(!b||!a[s])return;const he=Math.min(b.start,b.end),Te=Math.max(b.start,b.end),$e=b.side==="additions"?"new":"old",ht=u_(a[s].patch,he,Te,$e);sn.ask({prompt:J,filePath:a[s].path,lineStart:he,lineEnd:Te,side:$e,selectedCode:ht||void 0})},[b,a,s,sn]),ol=E.useCallback(J=>{xr("ai"),O(!0),J&&(sa(J),setTimeout(()=>sa(null),500))},[]),Ts=E.useCallback((J,he,Te,$e)=>{xe(J),h({start:he,end:Te,side:$e==="new"?"additions":"deletions"})},[xe]),Yo=E.useMemo(()=>{if(!b||!a[s])return[];const J=a[s].path,he=Math.min(b.start,b.end),Te=Math.max(b.start,b.end),$e=b.side==="additions"?"new":"old";return sn.messages.filter(ht=>{const $t=ht.question;return $t.filePath===J&&$t.side===$e&&$t.lineStart!=null&&$t.lineEnd!=null&&$t.lineStart<=Te&&$t.lineEnd>=he})},[b,a,s,sn.messages]),[Wd,sa]=E.useState(null),ar=E.useCallback(J=>{sa(J),xr("ai"),O(!0),setTimeout(()=>sa(null),500)},[]),Fs=E.useCallback(J=>{sn.ask({prompt:J})},[sn.ask]),Br=TB({storageKey:"plannotator-review-panel-width"}),sl=TB({storageKey:"plannotator-filetree-width",defaultWidth:256,minWidth:160,maxWidth:400,side:"left"}),cl=Br.isDragging||sl.isDragging,ll=E.useCallback(J=>{je(J.api),J.api.onDidActivePanelChange(Te=>{if(!Te||!X6(Te.id))return;const $e=bA(Te.params);if(!$e)return;const ht=Tt.current.findIndex($t=>$t.path===$e);ht!==-1&&c(ht)});const he=()=>{const $e=(J.api.totalPanels===1&&J.api.groups.length===1?J.api.groups[0]?.panels[0]:void 0)?.id===Ec;for(const ht of J.api.groups)ht.header.hidden=$e};J.api.onDidAddPanel(he),J.api.onDidRemovePanel(he),J.api.onDidAddGroup(he),J.api.onDidRemoveGroup(he),J.api.onDidMovePanel(he),J.api.onDidLayoutChange(he),he()},[]);E.useEffect(()=>{!ke||!Jt.current||a.length===0||xe(a[0].path)},[ke,a,xe]);const $o=E.useCallback(J=>{const he=ke;if(!he)return;const Te=W6(J),$e=he.getPanel(Te);if($e){$e.api.setActive();return}const ht=V.jobs.find($t=>$t.id===J);he.addPanel({id:Te,component:fr.AGENT_JOB_DETAIL,title:ht?.label??`Job ${J.slice(0,8)}`,params:{jobId:J}})},[ke,V.jobs]),Ir=E.useCallback(J=>{const he=ke;if(!he)return;const Te={summary:{id:Z6,component:fr.PR_SUMMARY,title:"PR Summary"},comments:{id:V6,component:fr.PR_COMMENTS,title:"PR Comments"},checks:{id:J6,component:fr.PR_CHECKS,title:"PR Checks"}}[J],$e=he.getPanel(Te.id);if($e){$e.api.setActive();return}he.addPanel({id:Te.id,component:Te.component,title:Te.title})},[ke]);E.useEffect(()=>{const J=he=>{if((he.metaKey||he.ctrlKey)&&he.key.toLowerCase()==="f"&&!LB(he.target)){vn&&(he.preventDefault(),tr());return}if((he.key==="Enter"||he.key==="F3")&&ga.length>0&&!an&&!LB(he.target)){he.preventDefault(),oa(he.shiftKey?-1:1);return}he.key==="Escape"&&(Dt?Se(!1):y?_(!1):Hn?ut?Cr():Ni():ut&&Cr()),(he.metaKey||he.ctrlKey)&&he.shiftKey&&he.key==="c"&&(he.preventDefault(),iu())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[y,Dt,Hn,ut,ga,an,tr,oa,Cr,Ni,vn]),E.useEffect(()=>{fetch("/api/diff").then(J=>{if(!J.ok)throw new Error("Not in API mode");return J.json()}).then(J=>{Tn.init(J.serverConfig),ge(J.serverConfig?.gitUser);const he=Kw(J.rawPatch);n({files:he,rawPatch:J.rawPatch,gitRef:J.gitRef,origin:J.origin,diffType:J.diffType,gitContext:J.gitContext,sharingEnabled:J.sharingEnabled}),r(he),J.origin&&ce(J.origin),J.diffType&&me(J.diffType),J.gitContext&&Ne(J.gitContext),J.agentCwd&&Je(J.agentCwd),J.sharingEnabled!==void 0&&zt(J.sharingEnabled),J.repoInfo&&Rt(J.repoInfo),J.prMetadata&&ae(J.prMetadata),J.platformUser&&Ot(J.platformUser),J.viewedFiles&&J.viewedFiles.length>0&&W(new Set(J.viewedFiles)),J.error&&Le(J.error),J.isWSL&&$(!0),J.diffType&&!J.prMetadata&&J.gitContext?.vcsType!=="p4"&&aP()&&Ai(!0)}).catch(()=>{const J=Kw(iQ);n({files:J,rawPatch:iQ,gitRef:"demo"}),r(J)}).finally(()=>D(!1))},[]),E.useEffect(()=>{uo&&on&&!ot&&(Ai(!1),lo(!0))},[uo,on,ot]);const dl=E.useCallback(J=>{Tn.set("diffStyle",J)},[]),Zd=E.useCallback(J=>{h(J)},[]),Vd=E.useCallback((J,he,Te,$e,ht,$t,Ca)=>{if(!b||!a[s])return;const Vn=Math.min(b.start,b.end),at=Math.max(b.start,b.end),Qr={id:d_(),type:J,scope:"line",filePath:a[s].path,lineStart:Vn,lineEnd:at,side:b.side==="additions"?"new":"old",text:he,suggestedCode:Te,originalCode:$e,...Ca&&{charStart:Ca.charStart,charEnd:Ca.charEnd,tokenText:Ca.tokenText},createdAt:Date.now(),author:ka,conventionalLabel:ht,decorations:$t};u(Fi=>[...Fi,Qr]),h(null)},[b,a,s,ka]),Jd=E.useCallback(J=>{const he=a[s],Te=J.trim();if(!he||!Te)return;const $e={id:d_(),type:"comment",scope:"file",filePath:he.path,lineStart:1,lineEnd:1,side:"new",text:Te,createdAt:Date.now(),author:ka};u(ht=>[...ht,$e])},[a,s,ka]),Ls=E.useCallback((J,he,Te,$e,ht,$t)=>{const Ca=ui.current.find(at=>at.id===J),Vn={...he!==void 0&&{text:he},...Te!==void 0&&{suggestedCode:Te},...$e!==void 0&&{originalCode:$e},...ht!==void 0&&{conventionalLabel:ht??void 0},...$t!==void 0&&{decorations:$t}};if(Ca?.source&&On.some(at=>at.id===J)){er(J,Vn);return}u(at=>at.map(Qr=>Qr.id===J?{...Qr,...Vn}:Qr))},[er,On]),ul=E.useCallback(J=>{if(ui.current.find(Te=>Te.id===J)?.source&&On.some(Te=>Te.id===J)){ze(J),A===J&&g(null);return}u(Te=>Te.filter($e=>$e.id!==J)),A===J&&g(null)},[A,ze,On]),um=E.useCallback((J,he)=>{u(Te=>Te.map($e=>$e.author===J?{...$e,author:he}:$e))},[]),pm=E.useCallback(J=>{const he=a[J];he&&xe(he.path)},[a,xe]),Am=E.useCallback(J=>{const he=a[J];he&&xe(he.path)},[a,xe]),Xd=E.useCallback(J=>{const he=a[J];he&&xe(he.path)},[a,xe]),Ms=E.useCallback(J=>{W(he=>{const Te=new Set(he),$e=!he.has(J);return $e?Te.add(J):Te.delete(J),et&&et.platform==="github"&&fetch("/api/pr-viewed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePaths:[J],viewed:$e})}).catch(()=>{}),Te})},[et]),{activeWorktreePath:Ti,activeDiffBase:Sr}=E.useMemo(()=>{if(pe.startsWith("worktree:")){const J=pe.slice(9),he=J.lastIndexOf(":");if(he!==-1){const Te=J.slice(he+1);if(["uncommitted","staged","unstaged","last-commit","branch"].includes(Te))return{activeWorktreePath:J.slice(0,he),activeDiffBase:Te}}return{activeWorktreePath:J,activeDiffBase:"uncommitted"}}return{activeWorktreePath:null,activeDiffBase:pe}},[pe]),mm=E.useCallback(J=>W(he=>new Set(he).add(J)),[]),{stagedFiles:pl,stagingFile:Os,canStageFiles:gm,stageFile:eu,resetStagedFiles:tu,stageError:Al}=uP({activeDiffBase:Sr,onFileViewed:mm}),nu=gm&&!et,Ps=E.useCallback(async J=>{xt(!0);try{const he=await fetch("/api/diff/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({diffType:J})});if(!he.ok)throw new Error("Failed to switch diff");const Te=await he.json(),$e=Kw(Te.rawPatch);ke?.getPanel(Ec)?.api.close(),Jt.current=!0,n(ht=>ht&&{...ht,rawPatch:Te.rawPatch,gitRef:Te.gitRef,diffType:Te.diffType}),r($e),me(Te.diffType),c(0),h(null),Le(Te.error||null),tu()}catch(he){console.error("Failed to switch diff:",he),Le(he instanceof Error?he.message:"Failed to switch diff")}finally{xt(!1)}},[ke,tu]),au=E.useCallback(async J=>{const he=Ti?`worktree:${Ti}:${J}`:J;he!==pe&&await Ps(he)},[pe,Ti,Ps]),bm=E.useCallback(async J=>{if(J===Ti)return;const he=J?`worktree:${J}:uncommitted`:"uncommitted";await Ps(he)},[Ti,Ps]),ml=E.useCallback(J=>{if(!J){g(null);return}const he=rn.find($e=>$e.id===J);if(!he){g(J);return}const Te=a.findIndex($e=>$e.path===he.filePath);Te!==-1&&Xd(Te),g(J)},[rn,a,Xd]),fm=E.useMemo(()=>({files:a,focusedFileIndex:s,focusedFilePath:a[s]?.path??null,diffStyle:R,diffOverflow:N,diffIndicators:F,lineDiffType:P,disableLineNumbers:!T,disableBackground:!L,fontFamily:Y||void 0,fontSize:X||void 0,allAnnotations:rn,externalAnnotations:On,selectedAnnotationId:A,pendingSelection:b,onLineSelection:Zd,onAddAnnotation:Vd,onAddFileComment:Jd,onEditAnnotation:Ls,onSelectAnnotation:ml,onDeleteAnnotation:ul,viewedFiles:j,onToggleViewed:Ms,stagedFiles:pl,stagingFile:Os,onStage:eu,canStageFiles:nu,stageError:Al,searchQuery:an?"":Ft,isSearchPending:an,debouncedSearchQuery:Ft,activeFileSearchMatches:en,activeSearchMatchId:ma,activeSearchMatch:ra?.filePath===a[s]?.path?ra:null,aiAvailable:Ra,aiMessages:sn.messages,onAskAI:Ho,isAILoading:sn.isCreatingSession||sn.isStreaming,onViewAIResponse:ol,onClickAIMarker:ar,aiHistoryForSelection:Yo,agentJobs:V.jobs,prMetadata:et,prContext:ft,isPRContextLoading:Nn,prContextError:Un,fetchPRContext:Zn,platformUser:Me,openDiffFile:xe}),[a,s,R,N,F,P,T,L,Y,X,rn,On,A,b,Zd,Vd,Jd,Ls,ml,ul,j,Ms,pl,Os,eu,nu,Al,an,Ft,en,ma,ra,Ra,sn.messages,sn.isCreatingSession,sn.isStreaming,Ho,ol,ar,Yo,V.jobs,et,ft,Nn,Un,Zn,Me,xe]),hm=E.useMemo(()=>({jobLogs:V.jobLogs}),[V.jobLogs]),iu=E.useCallback(async()=>{if(e)try{await navigator.clipboard.writeText(e.rawPatch),de("success"),setTimeout(()=>de("idle"),2e3)}catch(J){console.error("Failed to copy:",J),de("error"),setTimeout(()=>de("idle"),2e3)}},[e]),ym=E.useCallback(async()=>{if(rn.length===0){I(!0);return}try{const J=I_(rn,et);await navigator.clipboard.writeText(J),te("Feedback copied!"),setTimeout(()=>te(null),2e3)}catch(J){console.error("Failed to copy:",J),te("Failed to copy"),setTimeout(()=>te(null),2e3)}},[rn,et]),Dr=E.useMemo(()=>{let J=I_(rn,et);return va.length>0&&(J+=TP(va)),J},[rn,et,va]),Rn=rn.length+va.length,gl=E.useCallback(async()=>{if(Rn===0){I(!0);return}dt(!0);try{const J=Xp(),he=cB(J);if((await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:!1,feedback:Dr,annotations:rn,...he&&{agentSwitch:he}})})).ok)Ht("feedback");else throw new Error("Failed to send")}catch(J){console.error("Failed to send feedback:",J),te("Failed to send"),setTimeout(()=>te(null),2e3),dt(!1)}},[Rn,Dr,rn]),js=E.useCallback(async()=>{vt(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)Ht("exited");else throw new Error("Failed to exit")}catch(J){console.error("Failed to exit review:",J),vt(!1)}},[]),Ko=E.useCallback(async()=>{Xe(!0);try{if((await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approved:!0,feedback:"LGTM - no changes requested.",annotations:[]})})).ok)Ht("approved");else throw new Error("Failed to send")}catch(J){console.error("Failed to approve:",J),te("Failed to send"),setTimeout(()=>te(null),2e3),Xe(!1)}},[]),bl=E.useCallback((J,he)=>{const Te=rn.filter(at=>(at.scope??"line")==="line"),$e=rn.filter(at=>at.scope==="file"),ht=[];if($e.length>0)for(const at of $e)at.text&&ht.push(`**${at.filePath}:** ${at.text}`);const $t=ht.length>0?`${he?he+`
|
|
6367
6367
|
|
|
6368
6368
|
`:""}Review from Plannotator
|
|
6369
6369
|
|