@plannotator/opencode 0.19.15 → 0.19.17

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/plannotator.html CHANGED
@@ -967,7 +967,7 @@ ${t.themeCSS}`),t.fontFamily!==void 0&&(n+=`
967
967
  }
968
968
  }
969
969
  `})});async function Xye(t){const e=JSON.stringify(t),n=new TextEncoder().encode(e),a=new CompressionStream("deflate-raw"),r=a.writable.getWriter();r.write(n),r.close();const i=await new Response(a.readable).arrayBuffer(),A=new Uint8Array(i);let o="";for(let l=0;l<A.length;l++)o+=String.fromCharCode(A[l]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function n_(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=atob(e),a=Uint8Array.from(n,s=>s.charCodeAt(0)),r=new DecompressionStream("deflate-raw"),i=r.writable.getWriter();i.write(a),i.close();const A=await new Response(r.readable).arrayBuffer(),o=new TextDecoder().decode(A);return JSON.parse(o)}async function vrt(t){const e=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt"]),n=crypto.getRandomValues(new Uint8Array(12)),a=new TextEncoder().encode(t),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,a),i=new Uint8Array(n.length+r.byteLength);i.set(n,0),i.set(new Uint8Array(r),n.length);const A=await crypto.subtle.exportKey("raw",e);return{ciphertext:mre(i),key:mre(new Uint8Array(A))}}async function Drt(t,e){const n=hre(t),a=hre(e),r=n.slice(0,12),i=n.slice(12),A=await crypto.subtle.importKey("raw",a.buffer,{name:"AES-GCM",length:256},!1,["decrypt"]),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},A,i);return new TextDecoder().decode(o)}function mre(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function hre(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=atob(e);return Uint8Array.from(n,a=>a.charCodeAt(0))}function LC(t){if(t?.length)return t.map(e=>{if(typeof e=="string"){const n=e.split("/").pop()?.replace(/\.[^.]+$/,"")||"image";return{path:e,name:n}}return{path:e[0],name:e[1]}})}function AY(t){if(t?.length)return t.map(e=>[e.path,e.name])}function $ye(t){return t.map(e=>{const n=e.author||null,a=AY(e.images);return e.type===oa.GLOBAL_COMMENT?["G",e.text||"",n,a]:e.type===oa.DELETION?["D",e.originalText,n,a]:e.isQuickLabel?["C",e.originalText,e.text||"",n,a??void 0,1]:["C",e.originalText,e.text||"",n,a]})}function Yx(t,e,n){const a={D:oa.DELETION,C:oa.COMMENT,G:oa.GLOBAL_COMMENT};return t.map((r,i)=>{const A=r[0];if(A==="G"){const g=r[1],p=r[2],m=r[3];return{id:`shared-${i}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:oa.GLOBAL_COMMENT,text:g||void 0,originalText:"",createdA:Date.now()+i,author:p||void 0,images:LC(m),...n?.[i]?{source:n[i]}:{}}}const o=r[1],s=A==="D"?void 0:r[2],l=A==="D"?r[2]:r[3],d=A==="D"?r[3]:r[4],u=A==="C"&&r.length>5&&r[5]===1?!0:void 0;return{id:`shared-${i}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:a[A],text:s||void 0,originalText:o,createdA:Date.now()+i,author:l||void 0,images:LC(d),...u?{isQuickLabel:u}:{},...e?.[i]?{diffContext:e[i]}:{},...n?.[i]?{source:n[i]}:{}}})}function eQe(t){const e=t.map(n=>n.diffContext||null);return e.some(n=>n!==null)?e:null}function tQe(t){const e=t.map(n=>n.source||void 0);return e.some(n=>n!==void 0)?e:null}async function xrt(t,e,n,a=nQe,r){if(r)return null;const i=eQe(e),A=tQe(e),o={p:t,a:$ye(e),g:n?.length?AY(n):void 0,...i?{d:i}:{},...A?{s:A}:{}},s=await Xye(o);return`${a}/#${s}`}async function Srt(){const e=window.location.hash.slice(1).split("?")[0];if(!e)return null;try{return await n_(e)}catch(n){return console.warn("Failed to parse share hash:",n),null}}function _rt(t){const e=new Blob([t]).size;return e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`}const CP="https://plannotator-paste.plannotator.workers.dev",nQe="https://share.plannotator.ai";async function Rrt(t,e,n,a,r){const i=a?.pasteApiUrl??CP,A=a?.shareBaseUrl??nQe;try{const o=eQe(e),s=tQe(e),l={p:t,a:$ye(e),g:n?.length?AY(n):void 0,...o?{d:o}:{},...s?{s}:{},...r?{h:r,r:"html"}:{}},d=await Xye(l),{ciphertext:u,key:g}=await vrt(d),p=await fetch(`${i}/api/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:u}),signal:AbortSignal.timeout(5e3)});if(!p.ok)return console.warn(`[sharing] Paste service returned ${p.status}`),null;const m=await p.json(),f=i!==CP?`&paste=${btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}`:"";return{shortUrl:`${A}/p/${m.id}#key=${g}${f}`,id:m.id}}catch(o){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",o),null}}async function fre(t,e=CP,n){try{const a=await fetch(`${e}/api/paste/${t}`,{signal:AbortSignal.timeout(1e4)});if(!a.ok)return console.warn(`[sharing] Paste fetch returned ${a.status} for id ${t}`),null;const r=await a.json();if(n){const i=await Drt(r.data,n);return await n_(i)}return await n_(r.data)}catch(a){return console.warn("[sharing] Failed to load from paste ID:",a),null}}function bre(t){const e=t.replace(/^#/,"").split("?")[0];return e.length>=30&&/^[A-Za-z0-9_-]+$/.test(e)&&/[A-Z]/.test(e)}function Nrt(t,e,n,a,r,i,A,o,s,l,d,u){const[g,p]=q.useState(!1),[m,f]=q.useState(!0),[b,C]=q.useState(""),[I,B]=q.useState(""),[Q,k]=q.useState(""),[_,D]=q.useState(!1),[x,S]=q.useState(""),[L,N]=q.useState(null),[G,P]=q.useState(null),[R,U]=q.useState(""),F=q.useCallback(()=>{N(null),P(null)},[]),T=q.useCallback(()=>U(""),[]),O=q.useCallback(async()=>{try{const Z=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(Z){const oe=Z[1],ee=window.location.hash.slice(1),he=new URLSearchParams(ee),ae=he.get("key")??void 0,Ae=he.get("paste")?atob(he.get("paste").replace(/-/g,"+").replace(/_/g,"/")):void 0,ce=await fre(oe,Ae??s,ae);if(ce){ce.h&&ce.r==="html"?(d?.(ce.h),u?.("html"),a("")):(a(ce.p),u?.("markdown"),d?.(""));const ie=Yx(ce.a,ce.d,ce.s);if(r(ie),ce.g?.length){const le=LC(ce.g)??[];i(le),P(le)}N(ie),p(!0),k(window.location.href),A?.();const ge=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",ge),!0}return U("Failed to load shared plan — the link may be expired or incomplete."),!1}const $=window.location.hash.slice(1);if(!bre($))return!1;const V=await Srt();if(V){V.h&&V.r==="html"?(d?.(V.h),u?.("html"),a("")):(a(V.p),u?.("markdown"),d?.(""));const oe=Yx(V.a,V.d,V.s);if(r(oe),V.g?.length){const ee=LC(V.g)??[];i(ee),P(ee)}return N(oe),p(!0),A?.(),window.history.replaceState({},"",window.location.pathname),!0}return $&&U("Failed to load shared plan — the URL may have been truncated by your browser."),!1}catch(Z){return console.error("Failed to load from share hash:",Z),U("Failed to load shared plan — an unexpected error occurred."),!1}},[a,r,i,A,s,d,u]);q.useEffect(()=>{O().finally(()=>f(!1))},[]),q.useEffect(()=>{const Z=()=>{bre(window.location.hash)&&O()};return window.addEventListener("hashchange",Z),()=>window.removeEventListener("hashchange",Z)},[O]);const H=q.useCallback(async()=>{try{const Z=await xrt(t,e,n,o,l);C(Z??""),B(Z?_rt(Z):"")}catch(Z){console.error("Failed to generate share URL:",Z),C(""),B("")}},[t,e,n,o,l]);q.useEffect(()=>{H()},[H]);const j=q.useRef(!1);q.useEffect(()=>{if(g){j.current=!0;return}if(j.current){j.current=!1;return}k(""),S("")},[t,e,l,g]);const K=q.useCallback(async()=>{if(!(!t&&!l)){D(!0),S("");try{const Z=await Rrt(t,e,n,{pasteApiUrl:s,shareBaseUrl:o},l);Z?k(Z.shortUrl):(k(""),S("Short URL service unavailable"))}catch{k(""),S("Failed to generate short URL")}finally{D(!1)}}},[t,e,n,o,s,l]),z=q.useCallback(async Z=>{try{let $;const V=Z.match(/\/p\/([A-Za-z0-9]{6,16})(?:#(.*))?(?:\?|$)/);if(V){const ae=V[1],Ae=new URLSearchParams(V[2]??""),ce=Ae.get("key")??void 0,ie=Ae.get("paste")?atob(Ae.get("paste").replace(/-/g,"+").replace(/_/g,"/")):void 0,ge=await fre(ae,ie??s,ce);if(!ge)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};$=ge}else{const ae=Z.indexOf("#");if(ae===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const Ae=Z.slice(ae+1);if(!Ae)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};$=await n_(Ae)}let oe="Unknown Plan";if($.p){const ae=$.p.trim().split(`
970
- `).find(Ae=>Ae.startsWith("#"));ae&&(oe=ae.replace(/^#+\s*/,"").trim())}else if($.h){const ae=$.h.match(/<title[^>]*>([^<]+)<\/title>/i);ae&&(oe=ae[1].trim())}const ee=Yx($.a,$.d,$.s);if(ee.length===0)return{success:!0,count:0,planTitle:oe,error:"No annotations found in share link"};const he=ee.filter(ae=>!e.some(Ae=>Ae.originalText===ae.originalText&&Ae.type===ae.type&&Ae.text===ae.text));if(he.length>0&&(r(ae=>{const Ae=ee.filter(ie=>!ae.some(ge=>ge.originalText===ie.originalText&&ge.type===ie.type&&ge.text===ie.text));if(Ae.length===0)return ae;const ce=[...ae,...Ae];return N(ce),ce}),$.g?.length)){const ae=LC($.g)??[];i(Ae=>{const ce=new Set(Ae.map(ge=>ge.path)),ie=ae.filter(ge=>!ce.has(ge.path));return ie.length>0?[...Ae,...ie]:Ae}),P(ae)}return{success:!0,count:he.length,planTitle:oe}}catch($){return{success:!1,count:0,planTitle:"",error:$ instanceof Error?$.message:"Failed to decompress share URL"}}},[e,n,r,i,s]);return{isSharedSession:g,isLoadingShared:m,shareUrl:b,shareUrlSize:I,shortShareUrl:Q,isGeneratingShortUrl:_,shortUrlError:x,pendingSharedAnnotations:L,sharedGlobalAttachments:G,clearPendingSharedAnnotations:F,refreshShareUrl:H,generateShortUrl:K,importFromShareUrl:z,shareLoadError:R,clearShareLoadError:T}}var qx=(t=>(t.Approve="approve",t.Feedback="feedback",t))(qx||{});function Mrt(t=window.location){const e=new URLSearchParams(t.search);let n=e.get("cb"),a=e.get("ct");if(!n||!a){const r=t.hash.indexOf("?");if(r!==-1){const i=new URLSearchParams(t.hash.slice(r+1));n=n??i.get("cb"),a=a??i.get("ct")}}if(!n||!a)return null;try{const{protocol:r}=new URL(n);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:n,token:a}}async function Frt(t,e,n){const a=t==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(e.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,token:e.token,annotated_url:n})});return r.ok?{type:"success",message:a}:{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."}}}const aQe="plannotator-agent-switch",rQe="plannotator-agent-custom",Lrt=[{value:"build",label:"Build",description:"Switch to build agent after approval"},{value:"custom",label:"Custom",description:"Switch to a custom agent after approval"},{value:"disabled",label:"Disabled",description:"Stay on current agent after approval"}],Trt={switchTo:"build"};function GR(){const t=jt.getItem(aQe),e=jt.getItem(rQe)||void 0;return t?{switchTo:t,customName:e}:Trt}function iQe(t){jt.setItem(aQe,t.switchTo),t.customName&&jt.setItem(rQe,t.customName)}function Grt(t){if(t.switchTo!=="disabled")return t.switchTo==="custom"&&t.customName?t.customName:t.switchTo}function AQe(t){const[e,n]=q.useState([]),[a,r]=q.useState(!1);q.useEffect(()=>{t==="opencode"&&(r(!0),fetch("/api/agents").then(o=>o.json()).then(o=>{o.agents?.length&&n(o.agents)}).catch(()=>{n([])}).finally(()=>{r(!1)}))},[t]);const i=q.useCallback(o=>e.length===0?!0:e.some(s=>s.id.toLowerCase()===o.toLowerCase()),[e]),A=q.useCallback(()=>{if(e.length===0)return null;const o=GR();return o.switchTo==="disabled"?null:o.switchTo==="custom"?o.customName&&!i(o.customName)?`Agent "${o.customName}" not found in OpenCode. It may cause errors.`:null:i(o.switchTo)?null:`Agent "${o.switchTo}" not found in OpenCode. Select another or it may cause errors.`},[e,i]);return{agents:e,isLoading:a,validateAgent:i,getAgentWarning:A}}function Ort(t,e,n){const[a,r]=q.useState(null),i=q.useRef(null);return q.useEffect(()=>{const A=n??t.current;if(!A)return;const o=A.querySelectorAll('[data-block-type="heading"]');if(o.length===0)return;const s=new Map;return i.current=new IntersectionObserver(l=>{l.forEach(g=>{s.set(g.target,g.isIntersecting)});let d=null,u=1/0;for(const[g,p]of s)if(p){const m=g.getBoundingClientRect();m.top<u&&(u=m.top,d=g)}if(d){const g=d.getAttribute("data-block-id");g&&r(g)}},{root:A,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),o.forEach(l=>{i.current?.observe(l)}),()=>{i.current?.disconnect()}},[t,e,n]),a}function Cre(t){window.close(),setTimeout(()=>{window.closed||t()},300)}function Urt(t){const[e,n]=q.useState({phase:"idle"});q.useEffect(()=>{if(!t)return;const r=qpe();r==="0"?(Cre(()=>n({phase:"closeFailed"})),n({phase:"closed"})):n(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[t]),q.useEffect(()=>{if(e.phase!=="counting")return;if(e.remaining<=0){Cre(()=>n({phase:"closeFailed"}));return}const r=setTimeout(()=>n(i=>i.phase==="counting"?{phase:"counting",remaining:i.remaining-1}:i),1e3);return()=>clearTimeout(r)},[e]);const a=q.useCallback(()=>{jpe("3"),n({phase:"counting",remaining:3})},[]);return{state:e,enableAndStart:a}}const Prt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),Krt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.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 Hrt({submitted:t,title:e,subtitle:n,agentLabel:a}){const{state:r,enableAndStart:i}=Urt(!!t);if(!t)return null;const A=t==="approved";return y.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:y.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[y.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?y.jsx(Prt,{}):y.jsx(Krt,{})}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),y.jsx("p",{className:"text-muted-foreground",children:n})]}),y.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",y.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),y.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",a,"."]})]}):y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",y.jsx("span",{className:"text-foreground font-medium",children:a}),"."]}),r.phase==="prompt"?y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[y.jsx("input",{type:"checkbox",checked:!1,onChange:i,className:"accent-primary"}),y.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const Yrt="https://api.github.com/repos/backnotprop/plannotator/releases/latest",Ere={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function qrt(t,e){const n=i=>i.replace(/^v/,""),a=n(t).split(".").map(Number),r=n(e).split(".").map(Number);for(let i=0;i<Math.max(a.length,r.length);i++){const A=a[i]||0,o=r[i]||0;if(o>A)return!0;if(o<A)return!1}return!1}function jrt(){const[t,e]=q.useState(null);return q.useEffect(()=>{(async()=>{try{const a="0.19.15",i=new URLSearchParams(window.location.search).get("preview-update");if(i){const g=i.replace(/^v/,"");e({currentVersion:a,latestVersion:i,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${g}`,featureHighlight:Ere[g]});return}const A=await fetch(Yrt);if(!A.ok)return;const o=await A.json(),s=o.tag_name,l=qrt(a,s),d=s.replace(/^v/,""),u=Ere[d];e({currentVersion:a,latestVersion:s,updateAvailable:l,releaseUrl:o.html_url,featureHighlight:u})}catch(a){console.debug("Update check failed:",a)}})()},[]),t}const zrt="pi install npm:@plannotator/pi-extension";function Jrt(t){return O9e&&!t?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const Wrt=({origin:t,isWSL:e=!1})=>{const n=jrt(),[a,r]=q.useState(!1),[i,A]=q.useState(!1),l=new URLSearchParams(window.location.search).get("preview-origin")||t,d=l==="pi",u=l==="opencode",g=d?zrt:Jrt(e);if(!n?.updateAvailable||i)return null;const p=async()=>{try{await navigator.clipboard.writeText(g),r(!0),setTimeout(()=>r(!1),2e3)}catch(f){console.error("Failed to copy:",f)}};return n.featureHighlight?y.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:y.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[y.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:y.jsxs("div",{className:"flex items-start justify-between gap-3",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{children:[y.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.featureHighlight.title}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",n.latestVersion]})]})]}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),y.jsxs("div",{className:"px-5 py-4",children:[y.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:n.featureHighlight.description}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",n.currentVersion]}),u&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),d&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),y.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[y.jsx("button",{onClick:p,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"}),y.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"})]})]})]})}):y.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:y.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[n.latestVersion," is available (you have ",n.currentVersion,")"]}),y.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[y.jsx("button",{onClick:p,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"}),y.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"})]})]})]})})})},oQe="plannotator-default-notes-app";function sQe(){return jt.getItem(oQe)||"ask"}function Ire(t){jt.setItem(oQe,t)}const cQe="plannotator-save-enabled",EP="plannotator-save-path";function a_(){const t=jt.getItem(cQe),e=jt.getItem(EP);return{enabled:t!=="false",customPath:e||null}}function Zrt(t){jt.setItem(cQe,String(t.enabled)),t.customPath?jt.setItem(EP,t.customPath):jt.removeItem(EP)}const lQe="plannotator-toc-enabled",dQe="plannotator-sticky-actions-enabled",uQe="plannotator-plan-width",C8=[{id:"compact",label:"Compact",px:832,hint:"Best for reading. Ideal line length for laptops and focused review."},{id:"default",label:"Default",px:1040,hint:"Balanced. More room for code blocks without sacrificing readability."},{id:"wide",label:"Wide",px:1280,hint:"For large monitors. Best with diagrams and wide code."}];function IP(){const t=jt.getItem(uQe);return{tocEnabled:jt.getItem(lQe)!=="false",stickyActionsEnabled:jt.getItem(dQe)!=="false",planWidth:t==="compact"||t==="default"||t==="wide"?t:"compact"}}function Vrt(t){jt.setItem(lQe,String(t.tocEnabled)),jt.setItem(dQe,String(t.stickyActionsEnabled)),jt.setItem(uQe,t.planWidth)}const gQe="plannotator-editor-mode",Xrt="selection";function $rt(){const t=jt.getItem(gQe);return t==="selection"||t==="comment"||t==="redline"||t==="quickLabel"?t:Xrt}function eit(t){jt.setItem(gQe,t)}const pQe="plannotator-input-method",tit="drag";function nit(){const t=jt.getItem(pQe);return t==="drag"||t==="pinpoint"?t:tit}function ait(t){jt.setItem(pQe,t)}const rit=300,iit=300;function Ait(t,e){const n=q.useRef("idle"),a=q.useRef(0),r=q.useRef(void 0),i=q.useRef(t);q.useEffect(()=>{n.current==="idle"&&(i.current=t)},[t]);const A=q.useCallback(o=>o==="drag"?"pinpoint":"drag",[]);q.useEffect(()=>{const o=l=>{if(l.key!=="Alt"||l.repeat)return;const d=l.target?.tagName;d==="INPUT"||d==="TEXTAREA"||l.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(n.current==="idle"?(i.current=t,a.current=Date.now(),n.current="held",e(A(t))):n.current==="tapped"&&(clearTimeout(r.current),n.current="idle",i.current=A(i.current)))},s=l=>{l.key==="Alt"&&n.current==="held"&&(Date.now()-a.current>=iit?(e(i.current),n.current="idle"):(n.current="tapped",r.current=setTimeout(()=>{n.current==="tapped"&&(e(i.current),n.current="idle")},rit)))};return window.addEventListener("keydown",o),window.addEventListener("keyup",s),()=>{clearTimeout(r.current),window.removeEventListener("keydown",o),window.removeEventListener("keyup",s)}},[t,e,A])}function oit(){q.useEffect(()=>{const t=()=>document.documentElement.classList.add("plannotator-print"),e=()=>document.documentElement.classList.remove("plannotator-print"),n=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",t),window.addEventListener("afterprint",e),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",e),document.removeEventListener("visibilitychange",n),document.documentElement.classList.remove("plannotator-print")}},[])}function Bre({storageKey:t,defaultWidth:e=288,minWidth:n=200,maxWidth:a=600,side:r="right"}){const[i,A]=q.useState(()=>{const b=jt.getItem(t);if(b){const C=Number(b);if(!Number.isNaN(C)&&C>=n&&C<=a)return C}return e}),[o,s]=q.useState(!1),l=q.useRef(0),d=q.useRef(0),u=q.useRef(i),g=q.useCallback(b=>{u.current=b,A(b)},[]),p=q.useCallback(b=>{b.preventDefault(),l.current=b.clientX,d.current=u.current,s(!0)},[]),m=q.useCallback(b=>{b.preventDefault(),l.current=b.touches[0].clientX,d.current=u.current,s(!0)},[]);q.useEffect(()=>{if(!o)return;const b=B=>"touches"in B?B.touches[0]?.clientX??B.changedTouches[0]?.clientX??0:B.clientX,C=B=>{const Q=b(B),k=r==="right"?l.current-Q:Q-l.current;g(Math.min(a,Math.max(n,d.current+k)))},I=()=>{s(!1),jt.setItem(t,String(u.current))};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",I),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("touchend",I),document.addEventListener("touchcancel",I),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",C),document.removeEventListener("touchend",I),document.removeEventListener("touchcancel",I)}},[o,n,a,t,r,g]);const f=q.useCallback(()=>{g(e),jt.setItem(t,String(e))},[e,t,g]);return{width:i,isDragging:o,handleProps:{isDragging:o,onMouseDown:p,onTouchStart:m,onDoubleClick:f}}}const yre=({isDragging:t,onMouseDown:e,onTouchStart:n,onDoubleClick:a,className:r,side:i})=>y.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[y.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${t?"bg-primary/50":"group-hover:bg-border"}`}),y.jsx("div",{className:`absolute inset-y-0 ${i==="left"?"-right-2 -left-1":i==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:e,onTouchStart:n,onDoubleClick:a})]});function sit(){const t=q.useRef(null),[e,n]=q.useState(null),a=q.useCallback(r=>{const i=r;t.current=i,n(i)},[]);return{ref:t,viewport:e,onViewportReady:a}}const mQe="plannotator-permission-mode",oY="plannotator-permission-mode-configured",BP=[{value:"acceptEdits",label:"Auto-accept Edits",description:"Auto-approve file edits, ask for other tools"},{value:"bypassPermissions",label:"Bypass Permissions",description:"Auto-approve all tool calls (equivalent to --dangerously-skip-permissions)"},{value:"default",label:"Manual Approval",description:"Manually approve each tool call"}],cit="acceptEdits";function hQe(){const t=jt.getItem(mQe),e=jt.getItem(oY)==="true";return{mode:t||cit,configured:e}}function fQe(t){jt.setItem(mQe,t),jt.setItem(oY,"true")}function lit(){return jt.getItem(oY)!=="true"}const dit=({isOpen:t,onComplete:e})=>{const[n,a]=q.useState("acceptEdits");if(!t)return null;const r=()=>{fQe(n),e(n)};return Ci.createPortal(y.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:y.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[y.jsxs("div",{className:"p-5 border-b border-border",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[y.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:y.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"})})}),y.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),y.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."}),y.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",y.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),y.jsx("div",{className:"p-4 space-y-2",children:BP.map(i=>y.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${n===i.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[y.jsx("input",{type:"radio",name:"permissionMode",value:i.value,checked:n===i.value,onChange:()=>a(i.value),className:"mt-0.5 accent-primary"}),y.jsxs("div",{className:"flex-1",children:[y.jsx("div",{className:"text-sm font-medium",children:i.label}),y.jsx("div",{className:"text-xs text-muted-foreground",children:i.description})]})]},i.value))}),y.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[y.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),y.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 uit(t,e){const[n,a]=q.useState(t),[r,i]=q.useState("toc"),A=q.useCallback(l=>{a(!0),l&&i(l)},[]),o=q.useCallback(()=>{a(!1)},[]),s=q.useCallback(l=>{n?r===l?a(!1):i(l):(a(!0),i(l))},[n,r]);return{isOpen:n,activeTab:r,open:A,close:o,toggleTab:s}}class bQe{diff(e,n,a={}){let r;typeof a=="function"?(r=a,a={}):"callback"in a&&(r=a.callback);const i=this.castInput(e,a),A=this.castInput(n,a),o=this.removeEmpty(this.tokenize(i,a)),s=this.removeEmpty(this.tokenize(A,a));return this.diffWithOptionsObj(o,s,a,r)}diffWithOptionsObj(e,n,a,r){var i;const A=I=>{if(I=this.postProcess(I,a),r){setTimeout(function(){r(I)},0);return}else return I},o=n.length,s=e.length;let l=1,d=o+s;a.maxEditLength!=null&&(d=Math.min(d,a.maxEditLength));const u=(i=a.timeout)!==null&&i!==void 0?i:1/0,g=Date.now()+u,p=[{oldPos:-1,lastComponent:void 0}];let m=this.extractCommon(p[0],n,e,0,a);if(p[0].oldPos+1>=s&&m+1>=o)return A(this.buildValues(p[0].lastComponent,n,e));let f=-1/0,b=1/0;const C=()=>{for(let I=Math.max(f,-l);I<=Math.min(b,l);I+=2){let B;const Q=p[I-1],k=p[I+1];Q&&(p[I-1]=void 0);let _=!1;if(k){const x=k.oldPos-I;_=k&&0<=x&&x<o}const D=Q&&Q.oldPos+1<s;if(!_&&!D){p[I]=void 0;continue}if(!D||_&&Q.oldPos<k.oldPos?B=this.addToPath(k,!0,!1,0,a):B=this.addToPath(Q,!1,!0,1,a),m=this.extractCommon(B,n,e,I,a),B.oldPos+1>=s&&m+1>=o)return A(this.buildValues(B.lastComponent,n,e))||!0;p[I]=B,B.oldPos+1>=s&&(b=Math.min(b,I-1)),m+1>=o&&(f=Math.max(f,I+1))}l++};if(r)(function I(){setTimeout(function(){if(l>d||Date.now()>g)return r(void 0);C()||I()},0)})();else for(;l<=d&&Date.now()<=g;){const I=C();if(I)return I}}addToPath(e,n,a,r,i){const A=e.lastComponent;return A&&!i.oneChangePerToken&&A.added===n&&A.removed===a?{oldPos:e.oldPos+r,lastComponent:{count:A.count+1,added:n,removed:a,previousComponent:A.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:a,previousComponent:A}}}extractCommon(e,n,a,r,i){const A=n.length,o=a.length;let s=e.oldPos,l=s-r,d=0;for(;l+1<A&&s+1<o&&this.equals(a[s+1],n[l+1],i);)l++,s++,d++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,l}equals(e,n,a){return a.comparator?a.comparator(e,n):e===n||!!a.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let a=0;a<e.length;a++)e[a]&&n.push(e[a]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,a){const r=[];let i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();const A=r.length;let o=0,s=0,l=0;for(;o<A;o++){const d=r[o];if(d.removed)d.value=this.join(a.slice(l,l+d.count)),l+=d.count;else{if(!d.added&&this.useLongestToken){let u=n.slice(s,s+d.count);u=u.map(function(g,p){const m=a[l+p];return m.length>g.length?m:g}),d.value=this.join(u)}else d.value=this.join(n.slice(s,s+d.count));s+=d.count,d.added||(l+=d.count)}}return r}}const Qre="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class git extends bQe{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${Qre}]+|[^\\S\\n\\r]+|[^${Qre}]`,"ug");return e.match(n)||[]}}const pit=new git;function mit(t,e,n){return pit.diff(t,e,n)}class hit extends bQe{constructor(){super(...arguments),this.tokenize=Cit}equals(e,n,a){return a.ignoreWhitespace?((!a.newlineIsToken||!e.includes(`
970
+ `).find(Ae=>Ae.startsWith("#"));ae&&(oe=ae.replace(/^#+\s*/,"").trim())}else if($.h){const ae=$.h.match(/<title[^>]*>([^<]+)<\/title>/i);ae&&(oe=ae[1].trim())}const ee=Yx($.a,$.d,$.s);if(ee.length===0)return{success:!0,count:0,planTitle:oe,error:"No annotations found in share link"};const he=ee.filter(ae=>!e.some(Ae=>Ae.originalText===ae.originalText&&Ae.type===ae.type&&Ae.text===ae.text));if(he.length>0&&(r(ae=>{const Ae=ee.filter(ie=>!ae.some(ge=>ge.originalText===ie.originalText&&ge.type===ie.type&&ge.text===ie.text));if(Ae.length===0)return ae;const ce=[...ae,...Ae];return N(ce),ce}),$.g?.length)){const ae=LC($.g)??[];i(Ae=>{const ce=new Set(Ae.map(ge=>ge.path)),ie=ae.filter(ge=>!ce.has(ge.path));return ie.length>0?[...Ae,...ie]:Ae}),P(ae)}return{success:!0,count:he.length,planTitle:oe}}catch($){return{success:!1,count:0,planTitle:"",error:$ instanceof Error?$.message:"Failed to decompress share URL"}}},[e,n,r,i,s]);return{isSharedSession:g,isLoadingShared:m,shareUrl:b,shareUrlSize:I,shortShareUrl:Q,isGeneratingShortUrl:_,shortUrlError:x,pendingSharedAnnotations:L,sharedGlobalAttachments:G,clearPendingSharedAnnotations:F,refreshShareUrl:H,generateShortUrl:K,importFromShareUrl:z,shareLoadError:R,clearShareLoadError:T}}var qx=(t=>(t.Approve="approve",t.Feedback="feedback",t))(qx||{});function Mrt(t=window.location){const e=new URLSearchParams(t.search);let n=e.get("cb"),a=e.get("ct");if(!n||!a){const r=t.hash.indexOf("?");if(r!==-1){const i=new URLSearchParams(t.hash.slice(r+1));n=n??i.get("cb"),a=a??i.get("ct")}}if(!n||!a)return null;try{const{protocol:r}=new URL(n);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:n,token:a}}async function Frt(t,e,n){const a=t==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(e.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,token:e.token,annotated_url:n})});return r.ok?{type:"success",message:a}:{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."}}}const aQe="plannotator-agent-switch",rQe="plannotator-agent-custom",Lrt=[{value:"build",label:"Build",description:"Switch to build agent after approval"},{value:"custom",label:"Custom",description:"Switch to a custom agent after approval"},{value:"disabled",label:"Disabled",description:"Stay on current agent after approval"}],Trt={switchTo:"build"};function GR(){const t=jt.getItem(aQe),e=jt.getItem(rQe)||void 0;return t?{switchTo:t,customName:e}:Trt}function iQe(t){jt.setItem(aQe,t.switchTo),t.customName&&jt.setItem(rQe,t.customName)}function Grt(t){if(t.switchTo!=="disabled")return t.switchTo==="custom"&&t.customName?t.customName:t.switchTo}function AQe(t){const[e,n]=q.useState([]),[a,r]=q.useState(!1);q.useEffect(()=>{t==="opencode"&&(r(!0),fetch("/api/agents").then(o=>o.json()).then(o=>{o.agents?.length&&n(o.agents)}).catch(()=>{n([])}).finally(()=>{r(!1)}))},[t]);const i=q.useCallback(o=>e.length===0?!0:e.some(s=>s.id.toLowerCase()===o.toLowerCase()),[e]),A=q.useCallback(()=>{if(e.length===0)return null;const o=GR();return o.switchTo==="disabled"?null:o.switchTo==="custom"?o.customName&&!i(o.customName)?`Agent "${o.customName}" not found in OpenCode. It may cause errors.`:null:i(o.switchTo)?null:`Agent "${o.switchTo}" not found in OpenCode. Select another or it may cause errors.`},[e,i]);return{agents:e,isLoading:a,validateAgent:i,getAgentWarning:A}}function Ort(t,e,n){const[a,r]=q.useState(null),i=q.useRef(null);return q.useEffect(()=>{const A=n??t.current;if(!A)return;const o=A.querySelectorAll('[data-block-type="heading"]');if(o.length===0)return;const s=new Map;return i.current=new IntersectionObserver(l=>{l.forEach(g=>{s.set(g.target,g.isIntersecting)});let d=null,u=1/0;for(const[g,p]of s)if(p){const m=g.getBoundingClientRect();m.top<u&&(u=m.top,d=g)}if(d){const g=d.getAttribute("data-block-id");g&&r(g)}},{root:A,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),o.forEach(l=>{i.current?.observe(l)}),()=>{i.current?.disconnect()}},[t,e,n]),a}function Cre(t){window.close(),setTimeout(()=>{window.closed||t()},300)}function Urt(t){const[e,n]=q.useState({phase:"idle"});q.useEffect(()=>{if(!t)return;const r=qpe();r==="0"?(Cre(()=>n({phase:"closeFailed"})),n({phase:"closed"})):n(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[t]),q.useEffect(()=>{if(e.phase!=="counting")return;if(e.remaining<=0){Cre(()=>n({phase:"closeFailed"}));return}const r=setTimeout(()=>n(i=>i.phase==="counting"?{phase:"counting",remaining:i.remaining-1}:i),1e3);return()=>clearTimeout(r)},[e]);const a=q.useCallback(()=>{jpe("3"),n({phase:"counting",remaining:3})},[]);return{state:e,enableAndStart:a}}const Prt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),Krt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.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 Hrt({submitted:t,title:e,subtitle:n,agentLabel:a}){const{state:r,enableAndStart:i}=Urt(!!t);if(!t)return null;const A=t==="approved";return y.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:y.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[y.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?y.jsx(Prt,{}):y.jsx(Krt,{})}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),y.jsx("p",{className:"text-muted-foreground",children:n})]}),y.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",y.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),y.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",a,"."]})]}):y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",y.jsx("span",{className:"text-foreground font-medium",children:a}),"."]}),r.phase==="prompt"?y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[y.jsx("input",{type:"checkbox",checked:!1,onChange:i,className:"accent-primary"}),y.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const Yrt="https://api.github.com/repos/backnotprop/plannotator/releases/latest",Ere={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function qrt(t,e){const n=i=>i.replace(/^v/,""),a=n(t).split(".").map(Number),r=n(e).split(".").map(Number);for(let i=0;i<Math.max(a.length,r.length);i++){const A=a[i]||0,o=r[i]||0;if(o>A)return!0;if(o<A)return!1}return!1}function jrt(){const[t,e]=q.useState(null);return q.useEffect(()=>{(async()=>{try{const a="0.19.17",i=new URLSearchParams(window.location.search).get("preview-update");if(i){const g=i.replace(/^v/,"");e({currentVersion:a,latestVersion:i,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${g}`,featureHighlight:Ere[g]});return}const A=await fetch(Yrt);if(!A.ok)return;const o=await A.json(),s=o.tag_name,l=qrt(a,s),d=s.replace(/^v/,""),u=Ere[d];e({currentVersion:a,latestVersion:s,updateAvailable:l,releaseUrl:o.html_url,featureHighlight:u})}catch(a){console.debug("Update check failed:",a)}})()},[]),t}const zrt="pi install npm:@plannotator/pi-extension";function Jrt(t){return O9e&&!t?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const Wrt=({origin:t,isWSL:e=!1})=>{const n=jrt(),[a,r]=q.useState(!1),[i,A]=q.useState(!1),l=new URLSearchParams(window.location.search).get("preview-origin")||t,d=l==="pi",u=l==="opencode",g=d?zrt:Jrt(e);if(!n?.updateAvailable||i)return null;const p=async()=>{try{await navigator.clipboard.writeText(g),r(!0),setTimeout(()=>r(!1),2e3)}catch(f){console.error("Failed to copy:",f)}};return n.featureHighlight?y.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:y.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[y.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:y.jsxs("div",{className:"flex items-start justify-between gap-3",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{children:[y.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.featureHighlight.title}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",n.latestVersion]})]})]}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),y.jsxs("div",{className:"px-5 py-4",children:[y.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:n.featureHighlight.description}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",n.currentVersion]}),u&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),d&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),y.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[y.jsx("button",{onClick:p,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"}),y.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"})]})]})]})}):y.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:y.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[n.latestVersion," is available (you have ",n.currentVersion,")"]}),y.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[y.jsx("button",{onClick:p,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"}),y.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"})]})]})]})})})},oQe="plannotator-default-notes-app";function sQe(){return jt.getItem(oQe)||"ask"}function Ire(t){jt.setItem(oQe,t)}const cQe="plannotator-save-enabled",EP="plannotator-save-path";function a_(){const t=jt.getItem(cQe),e=jt.getItem(EP);return{enabled:t!=="false",customPath:e||null}}function Zrt(t){jt.setItem(cQe,String(t.enabled)),t.customPath?jt.setItem(EP,t.customPath):jt.removeItem(EP)}const lQe="plannotator-toc-enabled",dQe="plannotator-sticky-actions-enabled",uQe="plannotator-plan-width",C8=[{id:"compact",label:"Compact",px:832,hint:"Best for reading. Ideal line length for laptops and focused review."},{id:"default",label:"Default",px:1040,hint:"Balanced. More room for code blocks without sacrificing readability."},{id:"wide",label:"Wide",px:1280,hint:"For large monitors. Best with diagrams and wide code."}];function IP(){const t=jt.getItem(uQe);return{tocEnabled:jt.getItem(lQe)!=="false",stickyActionsEnabled:jt.getItem(dQe)!=="false",planWidth:t==="compact"||t==="default"||t==="wide"?t:"compact"}}function Vrt(t){jt.setItem(lQe,String(t.tocEnabled)),jt.setItem(dQe,String(t.stickyActionsEnabled)),jt.setItem(uQe,t.planWidth)}const gQe="plannotator-editor-mode",Xrt="selection";function $rt(){const t=jt.getItem(gQe);return t==="selection"||t==="comment"||t==="redline"||t==="quickLabel"?t:Xrt}function eit(t){jt.setItem(gQe,t)}const pQe="plannotator-input-method",tit="drag";function nit(){const t=jt.getItem(pQe);return t==="drag"||t==="pinpoint"?t:tit}function ait(t){jt.setItem(pQe,t)}const rit=300,iit=300;function Ait(t,e){const n=q.useRef("idle"),a=q.useRef(0),r=q.useRef(void 0),i=q.useRef(t);q.useEffect(()=>{n.current==="idle"&&(i.current=t)},[t]);const A=q.useCallback(o=>o==="drag"?"pinpoint":"drag",[]);q.useEffect(()=>{const o=l=>{if(l.key!=="Alt"||l.repeat)return;const d=l.target?.tagName;d==="INPUT"||d==="TEXTAREA"||l.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(n.current==="idle"?(i.current=t,a.current=Date.now(),n.current="held",e(A(t))):n.current==="tapped"&&(clearTimeout(r.current),n.current="idle",i.current=A(i.current)))},s=l=>{l.key==="Alt"&&n.current==="held"&&(Date.now()-a.current>=iit?(e(i.current),n.current="idle"):(n.current="tapped",r.current=setTimeout(()=>{n.current==="tapped"&&(e(i.current),n.current="idle")},rit)))};return window.addEventListener("keydown",o),window.addEventListener("keyup",s),()=>{clearTimeout(r.current),window.removeEventListener("keydown",o),window.removeEventListener("keyup",s)}},[t,e,A])}function oit(){q.useEffect(()=>{const t=()=>document.documentElement.classList.add("plannotator-print"),e=()=>document.documentElement.classList.remove("plannotator-print"),n=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",t),window.addEventListener("afterprint",e),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",e),document.removeEventListener("visibilitychange",n),document.documentElement.classList.remove("plannotator-print")}},[])}function Bre({storageKey:t,defaultWidth:e=288,minWidth:n=200,maxWidth:a=600,side:r="right"}){const[i,A]=q.useState(()=>{const b=jt.getItem(t);if(b){const C=Number(b);if(!Number.isNaN(C)&&C>=n&&C<=a)return C}return e}),[o,s]=q.useState(!1),l=q.useRef(0),d=q.useRef(0),u=q.useRef(i),g=q.useCallback(b=>{u.current=b,A(b)},[]),p=q.useCallback(b=>{b.preventDefault(),l.current=b.clientX,d.current=u.current,s(!0)},[]),m=q.useCallback(b=>{b.preventDefault(),l.current=b.touches[0].clientX,d.current=u.current,s(!0)},[]);q.useEffect(()=>{if(!o)return;const b=B=>"touches"in B?B.touches[0]?.clientX??B.changedTouches[0]?.clientX??0:B.clientX,C=B=>{const Q=b(B),k=r==="right"?l.current-Q:Q-l.current;g(Math.min(a,Math.max(n,d.current+k)))},I=()=>{s(!1),jt.setItem(t,String(u.current))};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",I),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("touchend",I),document.addEventListener("touchcancel",I),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",C),document.removeEventListener("touchend",I),document.removeEventListener("touchcancel",I)}},[o,n,a,t,r,g]);const f=q.useCallback(()=>{g(e),jt.setItem(t,String(e))},[e,t,g]);return{width:i,isDragging:o,handleProps:{isDragging:o,onMouseDown:p,onTouchStart:m,onDoubleClick:f}}}const yre=({isDragging:t,onMouseDown:e,onTouchStart:n,onDoubleClick:a,className:r,side:i})=>y.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[y.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${t?"bg-primary/50":"group-hover:bg-border"}`}),y.jsx("div",{className:`absolute inset-y-0 ${i==="left"?"-right-2 -left-1":i==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:e,onTouchStart:n,onDoubleClick:a})]});function sit(){const t=q.useRef(null),[e,n]=q.useState(null),a=q.useCallback(r=>{const i=r;t.current=i,n(i)},[]);return{ref:t,viewport:e,onViewportReady:a}}const mQe="plannotator-permission-mode",oY="plannotator-permission-mode-configured",BP=[{value:"acceptEdits",label:"Auto-accept Edits",description:"Auto-approve file edits, ask for other tools"},{value:"bypassPermissions",label:"Bypass Permissions",description:"Auto-approve all tool calls (equivalent to --dangerously-skip-permissions)"},{value:"default",label:"Manual Approval",description:"Manually approve each tool call"}],cit="acceptEdits";function hQe(){const t=jt.getItem(mQe),e=jt.getItem(oY)==="true";return{mode:t||cit,configured:e}}function fQe(t){jt.setItem(mQe,t),jt.setItem(oY,"true")}function lit(){return jt.getItem(oY)!=="true"}const dit=({isOpen:t,onComplete:e})=>{const[n,a]=q.useState("acceptEdits");if(!t)return null;const r=()=>{fQe(n),e(n)};return Ci.createPortal(y.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:y.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[y.jsxs("div",{className:"p-5 border-b border-border",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[y.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:y.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"})})}),y.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),y.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."}),y.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",y.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),y.jsx("div",{className:"p-4 space-y-2",children:BP.map(i=>y.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${n===i.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[y.jsx("input",{type:"radio",name:"permissionMode",value:i.value,checked:n===i.value,onChange:()=>a(i.value),className:"mt-0.5 accent-primary"}),y.jsxs("div",{className:"flex-1",children:[y.jsx("div",{className:"text-sm font-medium",children:i.label}),y.jsx("div",{className:"text-xs text-muted-foreground",children:i.description})]})]},i.value))}),y.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[y.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),y.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 uit(t,e){const[n,a]=q.useState(t),[r,i]=q.useState("toc"),A=q.useCallback(l=>{a(!0),l&&i(l)},[]),o=q.useCallback(()=>{a(!1)},[]),s=q.useCallback(l=>{n?r===l?a(!1):i(l):(a(!0),i(l))},[n,r]);return{isOpen:n,activeTab:r,open:A,close:o,toggleTab:s}}class bQe{diff(e,n,a={}){let r;typeof a=="function"?(r=a,a={}):"callback"in a&&(r=a.callback);const i=this.castInput(e,a),A=this.castInput(n,a),o=this.removeEmpty(this.tokenize(i,a)),s=this.removeEmpty(this.tokenize(A,a));return this.diffWithOptionsObj(o,s,a,r)}diffWithOptionsObj(e,n,a,r){var i;const A=I=>{if(I=this.postProcess(I,a),r){setTimeout(function(){r(I)},0);return}else return I},o=n.length,s=e.length;let l=1,d=o+s;a.maxEditLength!=null&&(d=Math.min(d,a.maxEditLength));const u=(i=a.timeout)!==null&&i!==void 0?i:1/0,g=Date.now()+u,p=[{oldPos:-1,lastComponent:void 0}];let m=this.extractCommon(p[0],n,e,0,a);if(p[0].oldPos+1>=s&&m+1>=o)return A(this.buildValues(p[0].lastComponent,n,e));let f=-1/0,b=1/0;const C=()=>{for(let I=Math.max(f,-l);I<=Math.min(b,l);I+=2){let B;const Q=p[I-1],k=p[I+1];Q&&(p[I-1]=void 0);let _=!1;if(k){const x=k.oldPos-I;_=k&&0<=x&&x<o}const D=Q&&Q.oldPos+1<s;if(!_&&!D){p[I]=void 0;continue}if(!D||_&&Q.oldPos<k.oldPos?B=this.addToPath(k,!0,!1,0,a):B=this.addToPath(Q,!1,!0,1,a),m=this.extractCommon(B,n,e,I,a),B.oldPos+1>=s&&m+1>=o)return A(this.buildValues(B.lastComponent,n,e))||!0;p[I]=B,B.oldPos+1>=s&&(b=Math.min(b,I-1)),m+1>=o&&(f=Math.max(f,I+1))}l++};if(r)(function I(){setTimeout(function(){if(l>d||Date.now()>g)return r(void 0);C()||I()},0)})();else for(;l<=d&&Date.now()<=g;){const I=C();if(I)return I}}addToPath(e,n,a,r,i){const A=e.lastComponent;return A&&!i.oneChangePerToken&&A.added===n&&A.removed===a?{oldPos:e.oldPos+r,lastComponent:{count:A.count+1,added:n,removed:a,previousComponent:A.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:a,previousComponent:A}}}extractCommon(e,n,a,r,i){const A=n.length,o=a.length;let s=e.oldPos,l=s-r,d=0;for(;l+1<A&&s+1<o&&this.equals(a[s+1],n[l+1],i);)l++,s++,d++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,l}equals(e,n,a){return a.comparator?a.comparator(e,n):e===n||!!a.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let a=0;a<e.length;a++)e[a]&&n.push(e[a]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,a){const r=[];let i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();const A=r.length;let o=0,s=0,l=0;for(;o<A;o++){const d=r[o];if(d.removed)d.value=this.join(a.slice(l,l+d.count)),l+=d.count;else{if(!d.added&&this.useLongestToken){let u=n.slice(s,s+d.count);u=u.map(function(g,p){const m=a[l+p];return m.length>g.length?m:g}),d.value=this.join(u)}else d.value=this.join(n.slice(s,s+d.count));s+=d.count,d.added||(l+=d.count)}}return r}}const Qre="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class git extends bQe{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${Qre}]+|[^\\S\\n\\r]+|[^${Qre}]`,"ug");return e.match(n)||[]}}const pit=new git;function mit(t,e,n){return pit.diff(t,e,n)}class hit extends bQe{constructor(){super(...arguments),this.tokenize=Cit}equals(e,n,a){return a.ignoreWhitespace?((!a.newlineIsToken||!e.includes(`
971
971
  `))&&(e=e.trim()),(!a.newlineIsToken||!n.includes(`
972
972
  `))&&(n=n.trim())):a.ignoreNewlineAtEof&&!a.newlineIsToken&&(e.endsWith(`
973
973
  `)&&(e=e.slice(0,-1)),n.endsWith(`
@@ -1739,7 +1739,7 @@ On the server side, update packages/server/index.ts to register the new WebSocke
1739
1739
  created: ${new Date().toISOString().slice(0,19)}Z
1740
1740
  source: plannotator
1741
1741
  tags: [plan, ...]
1742
- ---`})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":I.autoSave,onClick:()=>At({autoSave:!I.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${I.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${I.autoSave?"translate-x-6":"translate-x-1"}`})})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),y.jsx("button",{role:"switch","aria-checked":I.vaultBrowserEnabled,onClick:()=>At({vaultBrowserEnabled:!I.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${I.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${I.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),m==="bear"&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),y.jsx("button",{role:"switch","aria-checked":x.enabled,onClick:()=>_e({enabled:!x.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x.enabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.enabled?"translate-x-6":"translate-x-1"}`})})]}),x.enabled&&y.jsxs("div",{className:"mt-3 space-y-3",children:[y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),y.jsx("input",{type:"text",value:x.customTags,onChange:Ee=>_e({customTags:Ee.target.value}),onBlur:Ee=>_e({customTags:bnt(Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),y.jsxs("select",{value:x.tagPosition,onChange:Ee=>_e({tagPosition:Ee.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:[y.jsx("option",{value:"append",children:"Append (end of note)"}),y.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":x.autoSave,onClick:()=>_e({autoSave:!x.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${x.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),m==="octarine"&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),y.jsx("button",{role:"switch","aria-checked":L.enabled,onClick:()=>$e({enabled:!L.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${L.enabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${L.enabled?"translate-x-6":"translate-x-1"}`})})]}),L.enabled&&y.jsxs("div",{className:"mt-3 space-y-3",children:[y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),y.jsx("input",{type:"text",value:L.workspace,onChange:Ee=>$e({workspace:Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),y.jsx("input",{type:"text",value:L.folder,onChange:Ee=>$e({folder:Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),y.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",L.workspace||"..."," / ",L.folder||"plannotator","/"]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":L.autoSave,onClick:()=>$e({autoSave:!L.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${L.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${L.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body),g&&Ci.createPortal(y.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col pointer-events-none",children:[y.jsx("div",{className:"flex-1"}),y.jsxs("div",{className:"pointer-events-auto w-full bg-card border-t-2 border-primary/30 shadow-[0_-4px_20px_rgba(0,0,0,0.4)] flex flex-col max-h-[35vh] overflow-hidden",onClick:Ee=>Ee.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border flex-shrink-0",children:[y.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Theme Preview"}),y.jsx("button",{onClick:()=>{p(!1),u(!0)},className:"px-2.5 py-1 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:"Done"})]}),y.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:y.jsx(Jie,{compact:!0})})]})]}),document.body)]})},rpt=({className:t,panelClassName:e,renderTrigger:n,children:a})=>{const[r,i]=q.useState(!1),A=q.useRef(null);return q.useEffect(()=>{if(!r)return;const o=l=>{A.current&&!A.current.contains(l.target)&&i(!1)},s=l=>{l.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",s)}},[r]),y.jsxs("div",{ref:A,className:t?`relative ${t}`:"relative",children:[n({isOpen:r,toggleMenu:()=>i(o=>!o)}),r&&y.jsx("div",{className:e??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:a({closeMenu:()=>i(!1)})})]})},Zl=({onClick:t,icon:e,label:n,subtitle:a,badge:r})=>y.jsxs("button",{onClick:t,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[y.jsx("span",{className:"text-muted-foreground",children:e}),a?y.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[y.jsx("span",{children:n}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:a})]}):y.jsx("span",{className:"flex-1",children:n}),r]}),gD=()=>y.jsx("div",{className:"my-1 border-t border-border"}),Vie=({children:t})=>y.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),ipt=({className:t="w-3.5 h-3.5"})=>y.jsxs("svg",{className:`${t} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[y.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),y.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),y.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"}),y.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),Apt=({appVersion:t,onOpenSettings:e,onOpenExport:n,onCopyAgentInstructions:a,onDownloadAnnotations:r,onPrint:i,onCopyShareLink:A,onOpenImport:o,onSaveToObsidian:s,onSaveToBear:l,onSaveToOctarine:d,sharingEnabled:u,isApiMode:g,agentInstructionsEnabled:p,obsidianConfigured:m,bearConfigured:f,octarineConfigured:b})=>{const{theme:C,setTheme:I}=JH(),B=g&&(m||f||b);return y.jsx(rpt,{renderTrigger:({isOpen:Q,toggleMenu:k})=>y.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 ${Q?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Options","aria-label":"Options","aria-expanded":Q,children:[Q?y.jsx(spt,{}):y.jsx(opt,{}),y.jsx("span",{className:"hidden md:inline",children:"Options"})]}),children:({closeMenu:Q})=>y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[y.jsx(Vie,{children:"Theme"}),y.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(k=>y.jsxs("button",{onClick:()=>{Q(),I(k)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${C===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[k==="light"?y.jsx(Zwe,{}):k==="dark"?y.jsx(Vwe,{}):y.jsx(Xwe,{}),y.jsx("span",{className:"capitalize",children:k})]},k))})]}),y.jsx(gD,{}),y.jsx(Zl,{onClick:()=>{Q(),e()},icon:y.jsx(cpt,{}),label:"Settings"}),y.jsx(Zl,{onClick:()=>{Q(),n()},icon:y.jsx(lpt,{}),label:"Export"}),p&&y.jsx(Zl,{onClick:()=>{Q(),a()},icon:y.jsx(ipt,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),y.jsx(gD,{}),y.jsx(Zl,{onClick:()=>{Q(),r()},icon:y.jsx(dpt,{}),label:"Download Annotations"}),y.jsx(Zl,{onClick:()=>{Q(),i()},icon:y.jsx(upt,{}),label:"Print / Save as PDF",subtitle:"Choose 'Save as PDF' in the print dialog"}),u&&y.jsx(Zl,{onClick:()=>{Q(),A()},icon:y.jsx(gpt,{}),label:"Copy Share Link"}),u&&y.jsx(Zl,{onClick:()=>{Q(),o()},icon:y.jsx(ppt,{}),label:"Import Review"}),B&&y.jsxs(y.Fragment,{children:[y.jsx(gD,{}),m&&y.jsx(Zl,{onClick:()=>{Q(),s()},icon:y.jsx(Y8,{}),label:"Save to Obsidian"}),f&&y.jsx(Zl,{onClick:()=>{Q(),l()},icon:y.jsx(Y8,{}),label:"Save to Bear"}),b&&y.jsx(Zl,{onClick:()=>{Q(),d()},icon:y.jsx(Y8,{}),label:"Save to Octarine"})]}),y.jsx(gD,{}),y.jsxs("div",{className:"px-3 py-2 space-y-2",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(Vie,{children:"Plannotator"}),y.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",t]})]}),y.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[y.jsx("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",onClick:Q,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Release notes"}),y.jsx("a",{href:"https://github.com/backnotprop/plannotator",target:"_blank",rel:"noopener noreferrer",onClick:Q,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Project repo"})]})]})]})})},opt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),spt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),cpt=()=>y.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[y.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"}),y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),lpt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),dpt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),upt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),gpt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),ppt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),Y8=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),mpt=qt.memo(({isApiMode:t,annotateMode:e,archiveMode:n,gate:a,isSharedSession:r,origin:i,isSubmitting:A,isExiting:o,isPanelOpen:s,hasAnyAnnotations:l,linkedDocIsActive:d,callbackShareUrlReady:u,canShareCurrentSession:g,agentName:p,availableAgents:m,showAnnotationsWarning:f,callbackConfig:b,taterMode:C,mobileSettingsOpen:I,gitUser:B,onCallbackFeedback:Q,onCallbackApprove:k,onAnnotateExit:_,onAnnotateFeedback:D,onAnnotateApprove:x,onFeedback:S,onApprove:L,onAnnotationPanelToggle:N,onArchiveCopy:G,onArchiveDone:P,onTaterModeChange:R,onIdentityChange:U,onUIPreferencesChange:F,onOpenSettings:T,onCloseSettings:O,onOpenExport:H,onCopyAgentInstructions:j,onDownloadAnnotations:K,onPrint:z,onCopyShareLink:Z,onOpenImport:$,onSaveToObsidian:V,onSaveToBear:oe,onSaveToOctarine:ee,appVersion:he,agentInstructionsEnabled:ae,obsidianConfigured:Ae,bearConfigured:ce,octarineConfigured:ie})=>y.jsxs("header",{"data-app-header":"true",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:[y.jsx(hpt,{}),y.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[b&&!t&&r&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),y.jsx(K8,{onClick:Q,disabled:A||!u,isLoading:A,title:"Send feedback to bot"}),y.jsx(jie,{onClick:k,disabled:A||!u,isLoading:A,title:"Approve design and notify bot"})]}),t&&!d&&n&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:G,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:[y.jsx("span",{className:"hidden md:inline",children:"Copy"}),y.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})]}),y.jsx("button",{onClick:P,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"})]}),t&&(!d||e)&&!n&&y.jsxs(y.Fragment,{children:[e?y.jsxs(y.Fragment,{children:[y.jsx(Egt,{onClick:_,disabled:A||o,isLoading:o}),l&&y.jsx(K8,{onClick:D,disabled:A||o,isLoading:A,label:"Send Annotations",title:"Send Annotations"})]}):y.jsx(K8,{onClick:S,disabled:A,isLoading:A,label:"Send Feedback",title:"Send Feedback"}),(!e||a)&&(i==="opencode"&&!e&&m.length>0?y.jsx(ygt,{onApprove:L,agents:m,disabled:A,isLoading:A}):y.jsxs("div",{className:"relative group/approve",children:[y.jsx(jie,{onClick:L,disabled:A||e&&o,isLoading:A,dimmed:!e&&(i==="claude-code"||i==="gemini-cli")&&f,title:e?"Approve — no changes requested":void 0}),!e&&(i==="claude-code"||i==="gemini-cli")&&f&&y.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:[y.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),y.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),p," doesn't support feedback on approval. Your annotations won't be seen."]})]})),y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),y.jsx("button",{onClick:N,className:`p-1.5 rounded-md text-xs font-medium transition-all ${s?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:s?"Hide annotations":"Show annotations",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsx("div",{className:"hidden",children:y.jsx(apt,{taterMode:C,onTaterModeChange:R,onIdentityChange:U,origin:i,onUIPreferencesChange:F,externalOpen:I,onExternalClose:O,gitUser:B})}),y.jsx(Apt,{appVersion:he,onOpenSettings:T,onOpenExport:H,onCopyAgentInstructions:j,onDownloadAnnotations:K,onPrint:z,onCopyShareLink:Z,onOpenImport:$,onSaveToObsidian:V,onSaveToBear:oe,onSaveToOctarine:ee,sharingEnabled:g,isApiMode:t,agentInstructionsEnabled:ae,obsidianConfigured:Ae,bearConfigured:ce,octarineConfigured:ie})]})]})),hpt=()=>y.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:y.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:y.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),fpt=hgt,bpt=()=>{const[t,e]=q.useState(fpt),[n,a]=q.useState([]),[r,i]=q.useState([]),[A,o]=q.useState(null),[s,l]=q.useState(null),d=q.useMemo(()=>wge(t).frontmatter,[t]),u=q.useMemo(()=>LQ(t),[t]),[g,p]=q.useState(!1),[m,f]=q.useState(!1),[b,C]=q.useState(!1),[I,B]=q.useState(!1),[Q,k]=q.useState(!1),[_,D]=q.useState("close"),[x,S]=q.useState(!1),[L,N]=q.useState(""),[G,P]=q.useState(()=>window.innerWidth>=768),[R,U]=q.useState(!1),[F,T]=q.useState($rt),[O,H]=q.useState(nit),[j,K]=q.useState(()=>jt.getItem("plannotator-tater-mode")==="true"),[z,Z]=q.useState(()=>IP()),$=q.useRef(null),[V,oe]=q.useState("full");q.useLayoutEffect(()=>{const Ke=$.current;if(!Ke)return;const Pt=cn=>cn>=800?"full":cn>=680?"short":"icon";oe(Pt(Ke.getBoundingClientRect().width));const zt=new ResizeObserver(([cn])=>{const ma=Pt(cn.contentRect.width);oe(Qa=>Qa===ma?Qa:ma)});return zt.observe(Ke),()=>zt.disconnect()},[]);const[ee,he]=q.useState(!1),[ae,Ae]=q.useState(null),[ce,ie]=q.useState(),[ge,le]=q.useState(!1),[we,me]=q.useState([]),[He,se]=q.useState(!1),[Xe,De]=q.useState(!1),[tt,nt]=q.useState(null),[dt,Pe]=q.useState(),[ot,qe]=q.useState(!1),[ze,At]=q.useState("markdown"),[_e,$e]=q.useState(""),[fe,ve]=q.useState(),[X,Qe]=q.useState(void 0),[Ie,Ne]=q.useState(!0),[Me,Ue]=q.useState(!1),[Ee,xe]=q.useState(!1),[We,rt]=q.useState(null),[mt,Ce]=q.useState(null),[Oe,Te]=q.useState(!1),[at,Mt]=q.useState("bypassPermissions"),[kt,re]=q.useState(!0),[pt,ct]=q.useState(void 0),[xt,_t]=q.useState(void 0),[Lt,ut]=q.useState(null),[Rt,Xt]=q.useState(null),[Ft,An]=q.useState(null),Mn=q.useRef(null),xn=q.useRef(z.tocEnabled);q.useEffect(()=>{document.title=Lt?`${Lt.display} · Plannotator`:"Plannotator"},[Lt]);const[bn,Ln]=q.useState(),[On,Et]=q.useState(!1),[be,et]=q.useState("clean"),[vt,mn]=q.useState(null),[Sn,rn]=q.useState(null),jn=sBe(),sa=q.useRef(null),{ref:fa,viewport:Ut,onViewportReady:It}=sit();oit();const Gt=Bre({storageKey:"plannotator-panel-width"}),Tt=Bre({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),St=Gt.isDragging||Tt.isDragging,Jt=uit(IP().tocEnabled),Le=q.useMemo(()=>u.some(Ke=>Ke.type==="heading"&&(Ke.level??0)<=3),[u]),xa=q.useCallback(Ke=>{if(Ft===null){Ke?.sidebarTab&&Jt.open(Ke.sidebarTab),Ke?.panelOpen===!0?P(!0):Ke?.panelOpen===!1&&P(!1);return}const Pt=Mn.current,zt=bgt(Pt,Ke);An(null),Mn.current=null,zt.sidebarOpen&&zt.sidebarTab?Jt.open(zt.sidebarTab):Jt.close(),zt.panelOpen!==void 0&&P(zt.panelOpen)},[Ft,Jt.close,Jt.open]),Ge=q.useCallback(Ke=>{if(Ft!==null){xa({restore:!1,sidebarTab:Ke,panelOpen:!1});return}Jt.open(Ke)},[xa,Ft,Jt.open]),Hn=q.useCallback(Ke=>{if(Ft!==null){xa({restore:!1,sidebarTab:Ke,panelOpen:!1});return}Jt.toggleTab(Ke)},[xa,Ft,Jt.toggleTab]),qo=q.useCallback(()=>{if(Ft!==null){xa({restore:!1,panelOpen:!0});return}P(Ke=>!Ke)},[xa,Ft]);q.useEffect(()=>{Ft===null&&xn.current!==z.tocEnabled&&(xn.current=z.tocEnabled,z.tocEnabled&&Le?Jt.open("toc"):z.tocEnabled||Jt.close())},[Ft,Jt.close,Jt.open,z.tocEnabled,Le]),q.useEffect(()=>{u.length!==0&&(Le||Jt.activeTab==="toc"&&Jt.isOpen&&Jt.close())},[u,Le]),q.useEffect(()=>{Jt.activeTab==="toc"&&On&&Et(!1)},[Jt.activeTab]),q.useEffect(()=>{if(!On)return;const Ke=Pt=>{Pt.key==="Escape"&&Et(!1)};return document.addEventListener("keydown",Ke),()=>document.removeEventListener("keydown",Ke)},[On]);const Ua=Vit(t,vt,Sn),go=q.useMemo(()=>({...Jt,open:Ge,toggleTab:Hn}),[Ge,Jt.activeTab,Jt.close,Jt.isOpen,Hn]),wn=Xit({markdown:t,annotations:n,selectedAnnotationId:A,globalAttachments:we,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setGlobalAttachments:me,viewerRef:sa,sidebar:go,sourceFilePath:fe,sourceConverted:ot}),sr=q.useMemo(()=>wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):X?.includes("/")?X:void 0,[wn.filepath,X]),Wa=$it({buildUrl:q.useCallback(Ke=>sr?`/api/doc?path=${encodeURIComponent(Ke)}&base=${encodeURIComponent(sr)}`:`/api/doc?path=${encodeURIComponent(Ke)}`,[sr])}),ya=rAt({markdown:t,viewerRef:sa,linkedDocHook:wn,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setSubmitted:rt}),yi=q.useMemo(()=>fgt({archiveMode:ya.archiveMode,isPlanDiffActive:On}),[ya.archiveMode,On]),po=q.useCallback(Ke=>{yi&&(Ft===null&&(Mn.current={sidebarIsOpen:Jt.isOpen,sidebarTab:Jt.activeTab,panelOpen:G}),An(Ke),Jt.close(),P(!1))},[yi,G,Ft,Jt.activeTab,Jt.close,Jt.isOpen]),Mr=q.useCallback(Ke=>{Ft===Ke?xa():po(Ke)},[po,xa,Ft]);q.useEffect(()=>{!yi&&Ft!==null&&xa()},[yi,xa,Ft]);const Ca=uAt(),Za=q.useMemo(()=>Wae()?fp(hp()):"",[z]),Cn=q.useMemo(()=>!!Rt||Tre()||Wae(),[Rt,z]),_n=q.useMemo(()=>{const Ke=Rt?[Rt]:[],Pt=Tre()?sY().directories:[];return[...new Set([...Ke,...Pt])]},[Rt,z]);q.useEffect(()=>{Cn||Ca.setActiveFile(null)},[Cn]),q.useEffect(()=>{Za||Ca.clearVaultDirs()},[Za]),q.useEffect(()=>{if(Jt.activeTab==="files"&&Cn){if(_n.length>0){const Ke=Ca.dirs.filter(zt=>!zt.isVault).map(zt=>zt.path);(_n.some(zt=>!Ke.includes(zt))||Ke.some(zt=>!_n.includes(zt)))&&Ca.fetchAll(_n)}Za&&!Ca.dirs.find(Ke=>Ke.isVault&&Ke.path===Za&&!Ke.error)&&Ca.addVaultDir(Za)}},[Jt.activeTab,Cn,_n,Za]);const ir=qt.useCallback((Ke,Pt)=>{const cn=Ca.dirs.find(ma=>ma.path===Pt)?.isVault?ma=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Pt)}&path=${encodeURIComponent(ma)}`:ma=>`/api/doc?path=${encodeURIComponent(ma)}&base=${encodeURIComponent(Pt)}`;wn.open(Ke,cn,"files"),Ca.setActiveFile(Ke)},[wn,Ca]),ua=qt.useCallback(Ke=>{if(Ca.dirs.find(zt=>zt.path===Ca.activeDirPath)?.isVault&&Ca.activeDirPath)wn.open(Ke,zt=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Ca.activeDirPath)}&path=${encodeURIComponent(zt)}`);else if(Ca.activeFile&&Ca.activeDirPath){const zt=wn.filepath?.replace(/\/[^/]+$/,"")||Ca.activeDirPath;wn.open(Ke,cn=>`/api/doc?path=${encodeURIComponent(cn)}&base=${encodeURIComponent(zt)}`)}else{const zt=wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):X?.includes("/")?X:void 0;zt?wn.open(Ke,cn=>`/api/doc?path=${encodeURIComponent(cn)}&base=${encodeURIComponent(zt)}`):wn.open(Ke)}},[Ca.dirs,Ca.activeDirPath,Ca.activeFile,wn,X]),ui=qt.useCallback(()=>{wn.back(),Ca.setActiveFile(null),ya.clearSelection()},[wn,Ca,ya]),Ya=q.useMemo(()=>{const Ke=new Map;for(const[Pt,zt]of wn.getDocAnnotations()){const cn=zt.annotations.length+zt.globalAttachments.length;cn>0&&Ke.set(Pt,cn)}return Ke},[wn.getDocAnnotations,n,we]),fA=q.useMemo(()=>{const Ke=Ca.dirs.map(zt=>zt.path);if(Ke.length===0)return Ya;const Pt=new Map;for(const[zt,cn]of Ya)Ke.some(ma=>zt.startsWith(ma+"/"))&&Pt.set(zt,cn);return Pt},[Ya,Ca.dirs]),gi=fA.size>0,en=q.useMemo(()=>{const Ke=wn.filepath;let Pt=0,zt=0;for(const[cn,ma]of Ya)cn!==Ke&&(Pt+=ma,zt++);return Pt>0?{count:Pt,files:zt}:void 0},[Ya,wn.filepath]),[J,te]=q.useState(),pe=qt.useRef(),ke=qt.useCallback(()=>{const Ke=new Set(Ya.keys());Ke.size!==0&&((!Jt.isOpen||Jt.activeTab!=="files")&&Ge("files"),pe.current&&clearTimeout(pe.current),te(void 0),requestAnimationFrame(()=>{te(Ke),pe.current=setTimeout(()=>te(void 0),1200)}))},[Ya,Ge,Jt,gi]),Ye=tt==="folder"?"file list":tt==="file"?"file":tt==="message"?"message":"plan",it=q.useMemo(()=>u.filter(Ke=>Ke.type==="heading").length,[u]),ft=Ort(fa,it,Ut),{editorAnnotations:Ct,deleteEditorAnnotation:on}=AAt(),{externalAnnotations:Un,updateExternalAnnotation:Zn,deleteExternalAnnotation:pa}=cAt({enabled:ee}),{reset:da}=lAt({viewerRef:sa,externalAnnotations:Un,enabled:ee&&!wn.isActive&&!On,planKey:t}),sn=q.useMemo(()=>Un.length===0?n:[...n.filter(Pt=>Pt.source?!Un.some(zt=>zt.source===Pt.source&&zt.type===Pt.type&&zt.originalText===Pt.originalText):!0),...Un],[n,Un]),Yn=q.useMemo(()=>sn.filter(Ke=>!!Ke.diffContext),[sn]),hr=q.useMemo(()=>sn.filter(Ke=>!Ke.diffContext),[sn]),Zr=q.useMemo(()=>sn.length>0||r.length>0||Ct.length>0||wn.docAnnotationCount>0||we.length>0,[sn.length,r.length,Ct.length,wn.docAnnotationCount,we.length]),Zi=sn.length+r.length+Ct.length+wn.docAnnotationCount+we.length,Ar=kt&&r.length===0,{isSharedSession:xr,isLoadingShared:jo,shareUrl:Vr,shareUrlSize:Kl,shortShareUrl:fr,isGeneratingShortUrl:yI,shortUrlError:Dm,pendingSharedAnnotations:Wd,clearPendingSharedAnnotations:QI,generateShortUrl:pM,importFromShareUrl:mM,shareLoadError:ek,clearShareLoadError:wI}=Nrt(t,sn,we,e,a,me,()=>{Ne(!1)},pt,xt,_e,$e,At),{draftBanner:xm,restoreDraft:tk,dismissDraft:hM}=aAt({annotations:sn,codeAnnotations:r,globalAttachments:we,isApiMode:ee,isSharedSession:xr,submitted:!!We}),fM=qt.useCallback(()=>{const{annotations:Ke,codeAnnotations:Pt,globalAttachments:zt}=tk();(Ke.length>0||Pt.length>0||zt.length>0)&&(a(Ke),i(Pt),zt.length>0&&me(zt),setTimeout(()=>{sa.current?.applySharedAnnotations(Ke.filter(cn=>!cn.diffContext))},100))},[tk]),{agents:bM,getAgentWarning:Sm}=AQe(ae);q.useEffect(()=>{if(Wd&&Wd.length>0){const Ke=setTimeout(()=>{sa.current?.clearAllHighlights(),sa.current?.applySharedAnnotations(Wd.filter(Pt=>!Pt.diffContext)),QI(),da()},100);return()=>clearTimeout(Ke)}},[Wd,QI,da]);const CM=q.useCallback(Ke=>{K(Ke),jt.setItem("plannotator-tater-mode",String(Ke))},[]),nk=Ke=>{T(Ke),eit(Ke)},kI=Ke=>{H(Ke),ait(Ke)};Ait(O,kI),q.useEffect(()=>{jo||xr||fetch("/api/plan").then(Ke=>{if(!Ke.ok)throw new Error("Not in API mode");return Ke.json()}).then(Ke=>{Ai.init(Ke.serverConfig),ie(Ke.serverConfig?.gitUser),Ke.mode==="archive"?(e(Ke.plan||""),Ke.archivePlans&&ya.init(Ke.archivePlans),ya.fetchPlans(),re(!1),Jt.open("archive")):Ke.renderAs==="html"&&Ke.rawHtml?(At("html"),$e(Ke.rawHtml),e("")):Ke.mode==="annotate-folder"?e(""):Ke.plan&&e(Ke.plan),he(!0),(Ke.mode==="annotate"||Ke.mode==="annotate-last"||Ke.mode==="annotate-folder")&&(se(!0),De(Ke.gate??!1)),Ke.mode==="annotate-folder"&&Jt.open("files"),Ke.mode&&Ke.mode!=="archive"&&nt(Ke.mode==="annotate-last"?"message":Ke.mode==="annotate-folder"?"folder":"file"),Pe(Ke.sourceInfo??void 0),qe(!!Ke.sourceConverted),Ke.filePath&&(Qe(Ke.mode==="annotate-folder"?Ke.filePath:Ke.filePath.replace(/\/[^/]+$/,"")),Ke.mode==="annotate"&&ve(Ke.filePath)),Ke.sharingEnabled!==void 0&&re(Ke.sharingEnabled),Ke.shareBaseUrl&&ct(Ke.shareBaseUrl),Ke.pasteApiUrl&&_t(Ke.pasteApiUrl),Ke.repoInfo&&ut(Ke.repoInfo),Ke.projectRoot&&Xt(Ke.projectRoot),Ke.previousPlan!==void 0&&mn(Ke.previousPlan),Ke.versionInfo&&rn(Ke.versionInfo),Ke.origin&&(Ae(Ke.origin),Ke.origin==="claude-code"&&lit()&&Te(!0),Mt(hQe().mode)),Ke.isWSL&&le(!0)}).catch(()=>{he(!1)}).finally(()=>Ne(!1))},[jo,xr]);const vI=q.useRef(!1),kg=q.useRef({}),Vf=q.useRef(null);q.useEffect(()=>{vI.current=!1,kg.current={},Vf.current=null},[t]),q.useEffect(()=>{if(!ee||!t||xr||He||ya.archiveMode||vI.current)return;const Ke={},Pt=[],zt=hp();if(zt.autoSave&&zt.enabled){const cr=fp(zt);cr&&(Ke.obsidian={vaultPath:cr,folder:zt.folder||"plannotator",plan:t,...zt.filenameFormat&&{filenameFormat:zt.filenameFormat},...zt.filenameSeparator&&zt.filenameSeparator!=="space"&&{filenameSeparator:zt.filenameSeparator}},Pt.push("Obsidian"))}const cn=Ch();cn.autoSave&&cn.enabled&&(Ke.bear={plan:t,customTags:cn.customTags,tagPosition:cn.tagPosition},Pt.push("Bear"));const ma=MC();if(ma.autoSave&&tD()&&(Ke.octarine={plan:t,workspace:ma.workspace,folder:ma.folder||"plannotator"},Pt.push("Octarine")),Pt.length===0)return;vI.current=!0;const Qa=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke)}).then(cr=>cr.json()).then(cr=>{const Mi={...Ke.obsidian?{obsidian:!!cr.results?.obsidian?.success}:{},...Ke.bear?{bear:!!cr.results?.bear?.success}:{},...Ke.octarine?{octarine:!!cr.results?.octarine?.success}:{}};kg.current=Mi;const $d=Pt.filter(zA=>!cr.results?.[zA.toLowerCase()]?.success);return $d.length===0?_s.success(`Auto-saved to ${Pt.join(" & ")}`):_s.error(`Auto-save failed for ${$d.join(" & ")}`),Mi}).catch(()=>(kg.current={},_s.error("Auto-save failed"),{}));Vf.current=Qa},[ee,t,xr,He]),q.useEffect(()=>{const Ke=Pt=>{const zt=Pt.clipboardData?.items;if(zt){for(const cn of zt)if(cn.type.startsWith("image/")){Pt.preventDefault();const ma=cn.getAsFile();if(ma){const Qa=zU(ma.name,we.map(Mi=>Mi.name)),cr=URL.createObjectURL(ma);Ce({file:ma,blobUrl:cr,initialName:Qa})}break}}};return document.addEventListener("paste",Ke),()=>document.removeEventListener("paste",Ke)},[we]);const EM=async(Ke,Pt,zt)=>{if(mt)try{const cn=new FormData,ma=Pt?new File([Ke],"annotated.png",{type:"image/png"}):mt.file;cn.append("file",ma);const Qa=await fetch("/api/upload",{method:"POST",body:cn});if(Qa.ok){const cr=await Qa.json();me(Mi=>[...Mi,{path:cr.path,name:zt}])}}catch{}finally{URL.revokeObjectURL(mt.blobUrl),Ce(null)}},IM=()=>{mt&&(URL.revokeObjectURL(mt.blobUrl),Ce(null))},vg=async()=>{Ue(!0);try{const Ke=hp(),Pt=Ch(),zt=MC(),cn=a_(),ma=Pt.autoSave&&Vf.current?await Vf.current:kg.current,Qa={};ae==="claude-code"&&(Qa.permissionMode=at);const cr=Grt(GR());cr&&(Qa.agentSwitch=cr),Qa.planSave={enabled:cn.enabled,...cn.customPath&&{customPath:cn.customPath}};const Mi=fp(Ke);Ke.enabled&&Mi&&(Qa.obsidian={vaultPath:Mi,folder:Ke.folder||"plannotator",plan:t,...Ke.filenameFormat&&{filenameFormat:Ke.filenameFormat},...Ke.filenameSeparator&&Ke.filenameSeparator!=="space"&&{filenameSeparator:Ke.filenameSeparator}}),Pt.enabled&&!(Pt.autoSave&&ma.bear)&&(Qa.bear={plan:t,customTags:Pt.customTags,tagPosition:Pt.tagPosition}),tD()&&(Qa.octarine={plan:t,workspace:zt.workspace,folder:zt.folder||"plannotator"});const $d=Array.from(wn.getDocAnnotations().values()).some(zA=>zA.annotations.length>0||zA.globalAttachments.length>0);(sn.length>0||r.length>0||we.length>0||$d||Ct.length>0)&&(Qa.feedback=Zd),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qa)}),rt("approved")}catch{Ue(!1)}},DI=async()=>{Ue(!0);try{const Ke=a_();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Zd,planSave:{enabled:Ke.enabled,...Ke.customPath&&{customPath:Ke.customPath}}})}),rt("denied")}catch{Ue(!1)}},xI=async()=>{Ue(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Zd,annotations:sn,codeAnnotations:r})}),rt("denied")}catch{Ue(!1)}},Xf=async()=>{Ue(!0);try{await fetch("/api/approve",{method:"POST"}),rt("approved")}catch{Ue(!1)}},SI=q.useCallback(async()=>{xe(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)rt("exited");else throw new Error("Failed to exit")}catch{xe(!1)}},[]);q.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="Enter"||!(Pt.metaKey||Pt.ctrlKey))return;const zt=Pt.target?.tagName;if(zt==="INPUT"||zt==="TEXTAREA"||g||m||b||I||Q||x||Oe||mt||We||Me||Ee||!ee||wn.isActive)return;if(Pt.preventDefault(),He){if(Xe&&!Zr){Xf();return}xI();return}const cn=wn.getDocAnnotations(),ma=Array.from(cn.values()).some(Qa=>Qa.annotations.length>0||Qa.globalAttachments.length>0);if(sn.length===0&&r.length===0&&Ct.length===0&&!ma){if(ae==="opencode"){const Qa=Sm();if(Qa){N(Qa),S(!0);return}}vg()}else DI()};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[g,m,b,I,Q,x,Oe,mt,We,Me,Ee,ee,wn.isActive,n.length,r.length,Un.length,He,Xe,Zr,ae,Sm]);const $f=Ke=>{a(Pt=>[...Pt,Ke]),o(Ke.id),l(null),Ft===null&&P(!0)},eb=qt.useCallback(Ke=>{o(Ke),Ke&&l(null),Ke&&jn&&Ft===null&&P(!0)},[jn,Ft]),BM=qt.useCallback(Ke=>{const Pt={id:pAt("code-ann"),type:"comment",scope:"line",filePath:Ke.filePath,lineStart:Ke.lineStart,lineEnd:Ke.lineEnd,side:"new",text:Ke.text,images:Ke.images,originalCode:Ke.originalCode,createdAt:Date.now(),author:Ai.get("displayName")||void 0};i(zt=>[...zt,Pt]),o(null),l(Pt.id),Ft===null&&P(!0)},[Ft]),yM=qt.useCallback(Ke=>{const Pt=r.find(zt=>zt.id===Ke);Pt&&(o(null),l(Ke),Wa.open(Pt.filePath),jn&&Ft===null&&P(!0))},[r,Wa.open,jn,Ft]),ak=qt.useCallback(Ke=>{i(Pt=>Pt.filter(zt=>zt.id!==Ke)),s===Ke&&l(null)},[s]),tb=qt.useCallback((Ke,Pt)=>{i(zt=>zt.map(cn=>cn.id===Ke?{...cn,...Pt}:cn))},[]),Dg=Ke=>{sa.current?.removeHighlight(Ke),a(Pt=>Pt.filter(zt=>zt.id!==Ke)),A===Ke&&o(null)},_I=Cgt({blocks:u,annotations:n,addAnnotation:$f,removeAnnotation:Dg}),rk=Ke=>{const Pt=sn.find(zt=>zt.id===Ke);if(Pt?.source&&Un.some(zt=>zt.id===Ke)){pa(Ke),A===Ke&&o(null);return}Ke.startsWith("ann-checkbox-")&&Pt&&_I.revertOverride(Pt.blockId),Dg(Ke)},ik=(Ke,Pt)=>{if(sn.find(cn=>cn.id===Ke)?.source&&Un.some(cn=>cn.id===Ke)){Zn(Ke,Pt);return}a(cn=>cn.map(ma=>ma.id===Ke?{...ma,...Pt}:ma))},Ak=q.useCallback((Ke,Pt)=>{a(zt=>zt.map(cn=>cn.author===Ke?{...cn,author:Pt}:cn)),i(zt=>zt.map(cn=>cn.author===Ke?{...cn,author:Pt}:cn))},[]),RI=Ke=>{me(Pt=>[...Pt,Ke])},NI=Ke=>{me(Pt=>Pt.filter(zt=>zt.path!==Ke))},xg=Ke=>{},Zd=q.useMemo(()=>{const Ke=wn.getDocAnnotations(),Pt=Array.from(Ke.values()).some(Mi=>Mi.annotations.length>0||Mi.globalAttachments.length>0),zt=sn.length>0||we.length>0,cn=Ct.length>0,ma=r.length>0;if(!zt&&!Pt&&!cn&&!ma)return"User reviewed the document and has no feedback.";const Qa=wn.isActive?Ke.get(wn.filepath??"")?.isConverted??!1:ot;let cr=zt?PMe(u,sn,we,tt==="message"?"Message Feedback":tt==="folder"?"Folder Feedback":tt==="file"?"File Feedback":"Plan Feedback",tt??"plan",{sourceConverted:Qa}):"";if(Pt){const Mi=new Map(Ke);for(const[$d,zA]of Mi)zA.markdown&&Mi.set($d,{...zA,blocks:LQ(zA.markdown)});cr+=KMe(Mi)}return cn&&(cr+=HMe(Ct)),ma&&(cr+=YMe(r)),cr},[u,sn,we,wn.getDocAnnotations,Ct,r,ot,tt,wn.isActive,wn.filepath]),_m=qt.useMemo(()=>Mrt(),[]),nb=qt.useCallback(async Ke=>{if(!(!_m||Me||!Vr&&!fr)){Ue(!0);try{const Pt=await Frt(Ke,_m,fr||Vr);Pt&&(Pt.type==="success"?(_s.success(Pt.message),rt(Ke===qx.Approve?"approved":"denied")):_s.error(Pt.message))}finally{Ue(!1)}}},[_m,Me,Vr,fr]),ok=qt.useCallback(()=>nb(qx.Approve),[nb]),sk=qt.useCallback(()=>nb(qx.Feedback),[nb]),Vd=()=>{const Ke=new Blob([Zd],{type:"text/plain"}),Pt=URL.createObjectURL(Ke),zt=document.createElement("a");zt.href=Pt,zt.download="annotations.md",zt.click(),URL.revokeObjectURL(Pt),_s.success("Downloaded annotations")},Wc=async Ke=>{const Pt={};if(Ke==="obsidian"){const cn=hp(),ma=fp(cn);ma&&(Pt.obsidian={vaultPath:ma,folder:cn.folder||"plannotator",plan:t,...cn.filenameFormat&&{filenameFormat:cn.filenameFormat},...cn.filenameSeparator&&cn.filenameSeparator!=="space"&&{filenameSeparator:cn.filenameSeparator}})}if(Ke==="bear"){const cn=Ch();Pt.bear={plan:t,customTags:cn.customTags,tagPosition:cn.tagPosition}}if(Ke==="octarine"){const cn=MC();Pt.octarine={plan:t,workspace:cn.workspace,folder:cn.folder||"plannotator"}}const zt=Ke==="obsidian"?"Obsidian":Ke==="bear"?"Bear":"Octarine";try{const Qa=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pt)})).json()).results?.[Ke];Qa?.success?_s.success(`Saved to ${zt}`):_s.error(Qa?.error||"Save failed")}catch{_s.error("Save failed")}},ck=async()=>{const Ke=dAt(window.location.origin);try{await navigator.clipboard.writeText(Ke),_s.success("Agent instructions copied")}catch{_s.error("Failed to copy")}},Rm=async()=>{const Ke=fr||Vr;if(Ke)try{await navigator.clipboard.writeText(Ke),_s.success("Share link copied")}catch{_s.error("Failed to copy")}};q.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="s"||!(Pt.metaKey||Pt.ctrlKey))return;const zt=Pt.target?.tagName;if(zt==="INPUT"||zt==="TEXTAREA"||g||b||I||Q||x||Oe||mt||We||!ee)return;Pt.preventDefault();const cn=sQe(),ma=Jae(),Qa=Ch().enabled,cr=tD();cn==="download"?Vd():cn==="obsidian"&&ma?Wc("obsidian"):cn==="bear"&&Qa?Wc("bear"):cn==="octarine"&&cr?Wc("octarine"):(Ln("notes"),p(!0))};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[g,b,I,Q,x,Oe,mt,We,ee,t,Zd]),q.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="p"||!(Pt.metaKey||Pt.ctrlKey))return;const zt=Pt.target?.tagName;zt==="INPUT"||zt==="TEXTAREA"||g||b||I||Q||x||Oe||mt||We||(Pt.preventDefault(),window.print())};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[g,b,I,Q,x,Oe,mt,We]);const Zc=q.useMemo(()=>LMe(ae),[ae]),mo=q.useRef({handleApprove:vg,handleDeny:DI,handleAnnotateApprove:Xf,handleAnnotateFeedback:xI,handleAnnotateExit:SI,handleQuickSaveToNotes:Wc,handleDownloadAnnotations:Vd,handleCopyAgentInstructions:ck,handleCopyShareLink:Rm,getAgentWarning:Sm,getDocAnnotations:wn.getDocAnnotations});mo.current={handleApprove:vg,handleDeny:DI,handleAnnotateApprove:Xf,handleAnnotateFeedback:xI,handleAnnotateExit:SI,handleQuickSaveToNotes:Wc,handleDownloadAnnotations:Vd,handleCopyAgentInstructions:ck,handleCopyShareLink:Rm,getAgentWarning:Sm,getDocAnnotations:wn.getDocAnnotations};const MI=q.useCallback(()=>{Zr?(D("close"),k(!0)):mo.current.handleAnnotateExit()},[Zr]),FI=q.useCallback(()=>{const Ke=mo.current,Pt=Ke.getDocAnnotations(),zt=Array.from(Pt.values()).some(cn=>cn.annotations.length>0||cn.globalAttachments.length>0);sn.length===0&&r.length===0&&Ct.length===0&&!zt?C(!0):Ke.handleDeny()},[sn.length,r.length,Ct.length]),lk=q.useCallback(()=>{const Ke=mo.current;if(He){if(Zr){D("approve"),k(!0);return}Ke.handleAnnotateApprove();return}if(ae==="claude-code"&&(sn.length>0||r.length>0)){B(!0);return}if(ae==="opencode"){const Pt=Ke.getAgentWarning();if(Pt){N(Pt),S(!0);return}}Ke.handleApprove()},[He,Zr,ae,sn.length,r.length]),dk=q.useCallback(()=>mo.current.handleAnnotateFeedback(),[]),uk=q.useCallback(()=>mo.current.handleAnnotateApprove(),[]),QM=q.useCallback(()=>mo.current.handleDownloadAnnotations(),[]),wM=q.useCallback(()=>mo.current.handleCopyAgentInstructions(),[]),kM=q.useCallback(()=>mo.current.handleCopyShareLink(),[]),vM=q.useCallback(()=>U(!0),[]),DM=q.useCallback(()=>U(!1),[]),ho=q.useCallback(()=>{Ln(void 0),p(!0)},[]),Nm=q.useCallback(()=>window.print(),[]),gk=q.useCallback(()=>f(!0),[]),pk=q.useCallback(()=>mo.current.handleQuickSaveToNotes("obsidian"),[]),mk=q.useCallback(()=>mo.current.handleQuickSaveToNotes("octarine"),[]),hk=q.useCallback(()=>mo.current.handleQuickSaveToNotes("bear"),[]),ab=q.useMemo(()=>({compact:832,default:1040,wide:1280})[z.planWidth]??832,[z.planWidth]),Xd=yi&&Ft==="wide"?null:ab;return y.jsx(ynt,{defaultTheme:"dark",children:y.jsx(drt,{delayDuration:900,skipDelayDuration:200,disableHoverableContent:!0,children:y.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[y.jsx(mpt,{isApiMode:ee,annotateMode:He,archiveMode:ya.archiveMode,gate:Xe,isSharedSession:xr,origin:ae,isSubmitting:Me,isExiting:Ee,isPanelOpen:G,hasAnyAnnotations:Zr,linkedDocIsActive:wn.isActive,callbackShareUrlReady:_m?!!(Vr||fr):!0,canShareCurrentSession:Ar,agentName:Zc,availableAgents:bM,showAnnotationsWarning:sn.length>0||r.length>0,callbackConfig:_m,taterMode:j,mobileSettingsOpen:R,gitUser:ce,onCallbackFeedback:sk,onCallbackApprove:ok,onAnnotateExit:MI,onAnnotateFeedback:dk,onAnnotateApprove:uk,onFeedback:FI,onApprove:lk,onAnnotationPanelToggle:qo,onArchiveCopy:ya.copy,onArchiveDone:ya.done,onTaterModeChange:CM,onIdentityChange:Ak,onUIPreferencesChange:Z,onOpenSettings:vM,onCloseSettings:DM,onOpenExport:ho,onCopyAgentInstructions:wM,onDownloadAnnotations:QM,onPrint:Nm,onCopyShareLink:kM,onOpenImport:gk,onSaveToObsidian:pk,onSaveToBear:hk,onSaveToOctarine:mk,appVersion:"0.19.15",agentInstructionsEnabled:ee&&!ya.archiveMode&&!He,obsidianConfigured:Jae(),bearConfigured:Ch().enabled,octarineConfigured:tD()}),wn.error&&y.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[y.jsx("span",{className:"text-xs text-destructive",children:wn.error}),y.jsx("button",{onClick:wn.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),y.jsx(ABe.Provider,{value:Ut,children:y.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${St?"select-none":""}`,children:[j&&y.jsx(krt,{}),Ft===null&&!Jt.isOpen&&y.jsx(mAt,{activeTab:Jt.activeTab,onToggleTab:Hn,hasDiff:Ua.hasPreviousVersion,showVersionsTab:Sn!==null&&Sn.totalVersions>1,showFilesTab:Cn&&!ya.archiveMode,hasFileAnnotations:gi,className:"hidden lg:flex absolute left-0 top-0 z-10"}),Jt.isOpen&&y.jsxs(y.Fragment,{children:[y.jsx(vAt,{activeTab:Jt.activeTab,onTabChange:Ke=>{Hn(Ke),Ke==="archive"&&!ya.archiveMode&&ya.fetchPlans()},onClose:Jt.close,width:Tt.width,blocks:u,annotations:n,activeSection:ft,onTocNavigate:xg,linkedDocFilepath:wn.filepath,onLinkedDocBack:wn.isActive?ui:void 0,backLabel:Ye,showFilesTab:Cn&&!ya.archiveMode,fileAnnotationCounts:fA,highlightedFiles:J,fileBrowser:Ca,onFilesSelectFile:ir,onFilesFetchAll:()=>Ca.fetchAll(_n),onFilesRetryVaultDir:Ke=>Ca.addVaultDir(Ke),hasFileAnnotations:gi,showVersionsTab:Sn!==null&&Sn.totalVersions>1,versionInfo:Sn,versions:Ua.versions,selectedBaseVersion:Ua.diffBaseVersion,onSelectBaseVersion:Ua.selectBaseVersion,isPlanDiffActive:On,hasPreviousVersion:Ua.hasPreviousVersion,onActivatePlanDiff:()=>Et(!0),isLoadingVersions:Ua.isLoadingVersions,isSelectingVersion:Ua.isSelectingVersion,fetchingVersion:Ua.fetchingVersion,onFetchVersions:Ua.fetchVersions,showArchiveTab:ee&&!He,archivePlans:ya.plans,selectedArchiveFile:ya.selectedFile,onArchiveSelect:ya.select,isLoadingArchive:ya.isLoading}),y.jsx(yre,{...Tt.handleProps,className:"hidden lg:block",side:"left"})]}),y.jsxs(c0,{element:"main",className:`flex-1 min-w-0 bg-grid ${!Jt.isOpen&&Ft===null?"lg:pl-[30px]":""}`,"data-print-region":"document",onViewportReady:It,children:[y.jsx(Gb,{isOpen:!!xm,onClose:hM,onConfirm:fM,title:"Draft Recovered",message:xm?`Found ${xm.count} annotation${xm.count!==1?"s":""} from ${xm.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),y.jsxs("div",{ref:$,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:[!On&&!ya.archiveMode&&z.stickyActionsEnabled&&y.jsx(Irt,{inputMethod:O,onInputMethodChange:kI,mode:F,onModeChange:nk,taterMode:j,repoInfo:Lt,planDiffStats:Ua.diffStats,isPlanDiffActive:On,hasPreviousVersion:Ua.hasPreviousVersion,onPlanDiffToggle:()=>Et(!On),archiveInfo:ya.currentInfo,maxWidth:Xd,remountToken:wn.isActive?`doc:${wn.filepath}`:"plan"}),!On&&!ya.archiveMode&&y.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:Xd==null?void 0:{maxWidth:Xd},children:y.jsx(Jye,{inputMethod:O,onInputMethodChange:kI,mode:F,onModeChange:nk,taterMode:j})}),Ua.diffBlocks&&Ua.diffStats&&y.jsx("div",{className:"w-full flex justify-center",style:{display:On?void 0:"none"},children:y.jsx(UAt,{diffBlocks:Ua.diffBlocks,diffStats:Ua.diffStats,diffMode:be,onDiffModeChange:et,onPlanDiffToggle:()=>Et(!1),repoInfo:Lt,baseVersionLabel:Ua.diffBaseVersion!=null?`v${Ua.diffBaseVersion}`:void 0,baseVersion:Ua.diffBaseVersion??void 0,maxWidth:ab,annotations:Yn,onAddAnnotation:$f,onSelectAnnotation:eb,selectedAnnotationId:A,mode:F})}),tt==="folder"&&!t&&!wn.isActive&&y.jsx("div",{className:"w-full flex justify-center",children:y.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[y.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),y.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),y.jsxs("div",{className:"w-full flex justify-center relative",style:{display:On&&Ua.diffBlocks||tt==="folder"&&!t&&!wn.isActive?"none":void 0},children:[yi&&!On&&!ya.archiveMode&&y.jsx("div",{"data-print-hide":!0,className:"absolute -top-5 left-0 right-0 mx-auto w-full flex justify-end pointer-events-none",style:Xd===null?void 0:{maxWidth:Xd??832},children:y.jsx("div",{className:`pointer-events-auto flex items-center gap-1.5 text-[11px] tracking-wide ${j?"mr-[60px]":"mr-[4px]"}`,children:["wide","focus"].map((Ke,Pt)=>y.jsxs(qt.Fragment,{children:[Pt>0&&y.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/30 select-none",children:"|"}),y.jsx(urt,{side:"top",align:"end",content:Ke==="wide"?"Hide panels and expand document width":"Hide panels, keep document width",children:y.jsx("button",{type:"button",onClick:()=>Mr(Ke),"aria-pressed":Ft===Ke,className:`cursor-pointer rounded-sm transition-colors duration-150 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:opacity-80 ${Ft===Ke?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,children:Ke.charAt(0).toUpperCase()+Ke.slice(1)})})]},Ke))})}),ze==="html"?y.jsx(oBe,{ref:sa,rawHtml:_e,annotations:hr,onAddAnnotation:$f,onSelectAnnotation:eb,selectedAnnotationId:A,mode:F,globalAttachments:we,onAddGlobalAttachment:RI,onRemoveGlobalAttachment:NI,maxWidth:Xd}):y.jsx(Wet,{ref:sa,blocks:u,markdown:t,frontmatter:d,annotations:hr,onAddAnnotation:$f,onSelectAnnotation:eb,selectedAnnotationId:A,mode:F,inputMethod:O,taterMode:j,globalAttachments:we,onAddGlobalAttachment:RI,onRemoveGlobalAttachment:NI,repoInfo:Lt,stickyActions:z.stickyActionsEnabled,planDiffStats:wn.isActive?null:Ua.diffStats,isPlanDiffActive:On,onPlanDiffToggle:()=>Et(!On),hasPreviousVersion:!wn.isActive&&Ua.hasPreviousVersion,showDemoBadge:!ee&&!jo&&!xr,maxWidth:Xd,onOpenLinkedDoc:ua,onOpenCodeFile:Wa.open,linkedDocInfo:wn.isActive?{filepath:wn.filepath,onBack:ui,label:Ca.dirs.find(Ke=>Ke.path===Ca.activeDirPath)?.isVault?"Vault File":Ca.activeFile?"File":void 0,backLabel:Ye}:null,imageBaseDir:X,codePathBaseDir:sr,copyLabel:tt==="message"?"Copy message":tt==="file"||tt==="folder"?"Copy file":void 0,archiveInfo:ya.currentInfo,sourceInfo:dt,onToggleCheckbox:_I.toggle,checkboxOverrides:_I.overrides,actionsLabelMode:V},wn.isActive?`doc:${wn.filepath}`:"plan")]})]})]}),G&&Ft===null&&y.jsx(yre,{...Gt.handleProps,className:"hidden md:block",side:"right"}),y.jsx(unt,{isOpen:G&&Ft===null,blocks:u,annotations:sn,selectedId:A??s,onSelect:eb,onDelete:rk,onEdit:ik,codeAnnotations:r,onSelectCodeAnnotation:yM,onDeleteCodeAnnotation:ak,onEditCodeAnnotation:tb,sharingEnabled:Ar,width:Gt.width,editorAnnotations:Ct,onDeleteEditorAnnotation:on,onClose:()=>P(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(vge(Zd))},onShare:Ar&&(Vr||fr)?()=>{P(!1),Ln("share"),p(!0)}:void 0,otherFileAnnotations:en,onOtherFileAnnotationsClick:ke})]})}),Wa.popoutProps&&y.jsx(mgt,{...Wa.popoutProps,annotations:r.filter(Ke=>Ke.filePath===Wa.popoutProps?.filepath),selectedAnnotationId:s,onAddAnnotation:BM,onEditAnnotation:tb,onDeleteAnnotation:ak,onSelectAnnotation:Ke=>{o(null),l(Ke)}}),y.jsx(Ent,{isOpen:g,onClose:()=>{p(!1),Ln(void 0)},shareUrl:Vr,shareUrlSize:Kl,shortShareUrl:fr,isGeneratingShortUrl:yI,shortUrlError:Dm,onGenerateShortUrl:pM,annotationsOutput:Zd,annotationCount:sn.length+r.length,taterSprite:j?y.jsx(iY,{}):void 0,sharingEnabled:Ar,markdown:t,isApiMode:ee,initialTab:bn}),y.jsx(Int,{isOpen:m,onClose:()=>f(!1),onImport:mM,shareBaseUrl:pt}),y.jsx(Gb,{isOpen:b,onClose:()=>C(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Zc} will use your annotations to revise the plan.`,variant:"info"}),y.jsx(Gb,{isOpen:I,onClose:()=>B(!1),onConfirm:()=>{B(!1),vg()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:[Zc," doesn't yet support feedback on approval. Your ",sn.length+r.length," annotation",sn.length+r.length!==1?"s":""," will be lost."]}),subMessage:y.jsxs(y.Fragment,{children:["To send feedback, use ",y.jsx("strong",{children:"Send Feedback"})," instead.",y.jsx("br",{}),y.jsx("br",{}),"Want this feature? Upvote these issues:",y.jsx("br",{}),y.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",y.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}),y.jsx(Gb,{isOpen:Q,onClose:()=>k(!1),onConfirm:()=>{k(!1),_==="approve"?Xf():SI()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:["You have ",Zi," annotation",Zi!==1?"s":""," that will be lost if you ",_==="approve"?"approve":"close","."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:_==="approve"?"Approve Anyway":"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(Gb,{isOpen:x,onClose:()=>S(!1),onConfirm:()=>{S(!1),vg()},title:"Agent Not Found",message:L,subMessage:y.jsxs(y.Fragment,{children:["You can change the agent in ",y.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(Gb,{isOpen:!!ek&&!ee,onClose:wI,title:"Shared Plan Could Not Be Loaded",message:ek,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),y.jsx(FMe,{position:"top-right",offset:64,toastOptions:{style:{"--normal-bg":"var(--card)","--normal-border":"var(--border)","--normal-text":"var(--foreground)","--success-bg":"oklch(from var(--success) l c h / 0.15)","--success-border":"oklch(from var(--success) l c h / 0.3)","--success-text":"var(--success)","--error-bg":"oklch(from var(--destructive) l c h / 0.15)","--error-border":"oklch(from var(--destructive) l c h / 0.3)","--error-text":"var(--destructive)"}}}),y.jsx(Hrt,{submitted:We,title:ya.archiveMode?"Archive Closed":We==="exited"?"Session Closed":We==="approved"?He?"Approved":"Plan Approved":He?"Annotations Sent":"Feedback Sent",subtitle:We==="exited"?"Annotation session closed without feedback.":ya.archiveMode?"You can reopen with plannotator archive.":We==="approved"?He?`${Zc} will proceed.`:`${Zc} will proceed with the implementation.`:He?`${Zc} will address your annotations on the ${tt==="message"?"message":tt==="folder"?"files":"file"}.`:`${Zc} will revise the plan based on your annotations.`,agentLabel:Zc}),y.jsx(Wrt,{origin:ae,isWSL:ge}),y.jsx(Vpe,{isOpen:!!mt,imageSrc:mt?.blobUrl??"",initialName:mt?.initialName,onAccept:EM,onClose:IM}),y.jsx(dit,{isOpen:Oe,onComplete:Ke=>{Mt(Ke),Te(!1)}})]})})})},t0e=document.getElementById("root");if(!t0e)throw new Error("Could not find root element to mount to");const Cpt=sMe.createRoot(t0e);Cpt.render(y.jsx(qt.StrictMode,{children:y.jsx(bpt,{})}));class ns{constructor(e,n,a){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=n,this.end=a}static range(e,n){return n?!e||!e.loc||!n.loc||e.loc.lexer!==n.loc.lexer?null:new ns(e.loc.lexer,e.loc.start,n.loc.end):e&&e.loc}}class js{constructor(e,n){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=n}range(e,n){return new js(n,ns.range(this,e))}}class nn{constructor(e,n){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var a="KaTeX parse error: "+e,r,i,A=n&&n.loc;if(A&&A.start<=A.end){var o=A.lexer.input;r=A.start,i=A.end,r===o.length?a+=" at end of input: ":a+=" at position "+(r+1)+": ";var s=o.slice(r,i).replace(/[^]/g,"$&̲"),l;r>15?l="…"+o.slice(r-15,r):l=o.slice(0,r);var d;i+15<o.length?d=o.slice(i,i+15)+"…":d=o.slice(i),a+=l+s+d}var u=new Error(a);return u.name="ParseError",u.__proto__=nn.prototype,u.position=r,r!=null&&i!=null&&(u.length=i-r),u.rawMessage=e,u}}nn.prototype.__proto__=Error.prototype;var Ept=function(e,n){return e===void 0?n:e},Ipt=/([A-Z])/g,Bpt=function(e){return e.replace(Ipt,"-$1").toLowerCase()},ypt={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Qpt=/[&><"']/g;function wpt(t){return String(t).replace(Qpt,e=>ypt[e])}var n0e=function t(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?t(e.body[0]):e:e.type==="font"?t(e.body):e},kpt=function(e){var n=n0e(e);return n.type==="mathord"||n.type==="textord"||n.type==="atom"},vpt=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},Dpt=function(e){var n=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return n?n[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(n[1])?null:n[1].toLowerCase():"_relative"},tr={deflt:Ept,escape:wpt,hyphenate:Bpt,getBaseElem:n0e,isCharacterBox:kpt,protocolFromUrl:Dpt},kQ={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:t=>"#"+t},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:(t,e)=>(e.push(t),e)},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:t=>Math.max(0,t),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:t=>Math.max(0,t),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:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function xpt(t){if(t.default)return t.default;var e=t.type,n=Array.isArray(e)?e[0]:e;if(typeof n!="string")return n.enum[0];switch(n){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class DY{constructor(e){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,e=e||{};for(var n in kQ)if(kQ.hasOwnProperty(n)){var a=kQ[n];this[n]=e[n]!==void 0?a.processor?a.processor(e[n]):e[n]:xpt(a)}}reportNonstrict(e,n,a){var r=this.strict;if(typeof r=="function"&&(r=r(e,n,a)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new nn("LaTeX-incompatible input and strict mode is set to 'error': "+(n+" ["+e+"]"),a);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(n+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]"))}}useStrictBehavior(e,n,a){var r=this.strict;if(typeof r=="function")try{r=r(e,n,a)}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': "+(n+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]")),!1)}isTrusted(e){if(e.url&&!e.protocol){var n=tr.protocolFromUrl(e.url);if(n==null)return!1;e.protocol=n}var a=typeof this.trust=="function"?this.trust(e):this.trust;return!!a}}class $g{constructor(e,n,a){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=n,this.cramped=a}sup(){return ud[Spt[this.id]]}sub(){return ud[_pt[this.id]]}fracNum(){return ud[Rpt[this.id]]}fracDen(){return ud[Npt[this.id]]}cramp(){return ud[Mpt[this.id]]}text(){return ud[Fpt[this.id]]}isTight(){return this.size>=2}}var xY=0,E_=1,UC=2,Zu=3,Cw=4,_c=5,yE=6,So=7,ud=[new $g(xY,0,!1),new $g(E_,0,!0),new $g(UC,1,!1),new $g(Zu,1,!0),new $g(Cw,2,!1),new $g(_c,2,!0),new $g(yE,3,!1),new $g(So,3,!0)],Spt=[Cw,_c,Cw,_c,yE,So,yE,So],_pt=[_c,_c,_c,_c,So,So,So,So],Rpt=[UC,Zu,Cw,_c,yE,So,yE,So],Npt=[Zu,Zu,_c,_c,So,So,So,So],Mpt=[E_,E_,Zu,Zu,_c,_c,So,So],Fpt=[xY,E_,UC,Zu,UC,Zu,UC,Zu],Jn={DISPLAY:ud[xY],TEXT:ud[UC],SCRIPT:ud[Cw],SCRIPTSCRIPT:ud[yE]},ZP=[{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 Lpt(t){for(var e=0;e<ZP.length;e++)for(var n=ZP[e],a=0;a<n.blocks.length;a++){var r=n.blocks[a];if(t>=r[0]&&t<=r[1])return n.name}return null}var $x=[];ZP.forEach(t=>t.blocks.forEach(e=>$x.push(...e)));function a0e(t){for(var e=0;e<$x.length;e+=2)if(t>=$x[e]&&t<=$x[e+1])return!0;return!1}var Hb=80,Tpt=function(e,n){return"M95,"+(622+e+n)+`
1742
+ ---`})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":I.autoSave,onClick:()=>At({autoSave:!I.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${I.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${I.autoSave?"translate-x-6":"translate-x-1"}`})})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),y.jsx("button",{role:"switch","aria-checked":I.vaultBrowserEnabled,onClick:()=>At({vaultBrowserEnabled:!I.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${I.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${I.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),m==="bear"&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),y.jsx("button",{role:"switch","aria-checked":x.enabled,onClick:()=>_e({enabled:!x.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x.enabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.enabled?"translate-x-6":"translate-x-1"}`})})]}),x.enabled&&y.jsxs("div",{className:"mt-3 space-y-3",children:[y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),y.jsx("input",{type:"text",value:x.customTags,onChange:Ee=>_e({customTags:Ee.target.value}),onBlur:Ee=>_e({customTags:bnt(Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),y.jsxs("select",{value:x.tagPosition,onChange:Ee=>_e({tagPosition:Ee.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:[y.jsx("option",{value:"append",children:"Append (end of note)"}),y.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":x.autoSave,onClick:()=>_e({autoSave:!x.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${x.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),m==="octarine"&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),y.jsx("button",{role:"switch","aria-checked":L.enabled,onClick:()=>$e({enabled:!L.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${L.enabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${L.enabled?"translate-x-6":"translate-x-1"}`})})]}),L.enabled&&y.jsxs("div",{className:"mt-3 space-y-3",children:[y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),y.jsx("input",{type:"text",value:L.workspace,onChange:Ee=>$e({workspace:Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),y.jsx("input",{type:"text",value:L.folder,onChange:Ee=>$e({folder:Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),y.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",L.workspace||"..."," / ",L.folder||"plannotator","/"]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":L.autoSave,onClick:()=>$e({autoSave:!L.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${L.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${L.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body),g&&Ci.createPortal(y.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col pointer-events-none",children:[y.jsx("div",{className:"flex-1"}),y.jsxs("div",{className:"pointer-events-auto w-full bg-card border-t-2 border-primary/30 shadow-[0_-4px_20px_rgba(0,0,0,0.4)] flex flex-col max-h-[35vh] overflow-hidden",onClick:Ee=>Ee.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border flex-shrink-0",children:[y.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Theme Preview"}),y.jsx("button",{onClick:()=>{p(!1),u(!0)},className:"px-2.5 py-1 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:"Done"})]}),y.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:y.jsx(Jie,{compact:!0})})]})]}),document.body)]})},rpt=({className:t,panelClassName:e,renderTrigger:n,children:a})=>{const[r,i]=q.useState(!1),A=q.useRef(null);return q.useEffect(()=>{if(!r)return;const o=l=>{A.current&&!A.current.contains(l.target)&&i(!1)},s=l=>{l.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",s)}},[r]),y.jsxs("div",{ref:A,className:t?`relative ${t}`:"relative",children:[n({isOpen:r,toggleMenu:()=>i(o=>!o)}),r&&y.jsx("div",{className:e??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:a({closeMenu:()=>i(!1)})})]})},Zl=({onClick:t,icon:e,label:n,subtitle:a,badge:r})=>y.jsxs("button",{onClick:t,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[y.jsx("span",{className:"text-muted-foreground",children:e}),a?y.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[y.jsx("span",{children:n}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:a})]}):y.jsx("span",{className:"flex-1",children:n}),r]}),gD=()=>y.jsx("div",{className:"my-1 border-t border-border"}),Vie=({children:t})=>y.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),ipt=({className:t="w-3.5 h-3.5"})=>y.jsxs("svg",{className:`${t} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[y.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),y.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),y.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"}),y.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),Apt=({appVersion:t,onOpenSettings:e,onOpenExport:n,onCopyAgentInstructions:a,onDownloadAnnotations:r,onPrint:i,onCopyShareLink:A,onOpenImport:o,onSaveToObsidian:s,onSaveToBear:l,onSaveToOctarine:d,sharingEnabled:u,isApiMode:g,agentInstructionsEnabled:p,obsidianConfigured:m,bearConfigured:f,octarineConfigured:b})=>{const{theme:C,setTheme:I}=JH(),B=g&&(m||f||b);return y.jsx(rpt,{renderTrigger:({isOpen:Q,toggleMenu:k})=>y.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 ${Q?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Options","aria-label":"Options","aria-expanded":Q,children:[Q?y.jsx(spt,{}):y.jsx(opt,{}),y.jsx("span",{className:"hidden md:inline",children:"Options"})]}),children:({closeMenu:Q})=>y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[y.jsx(Vie,{children:"Theme"}),y.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(k=>y.jsxs("button",{onClick:()=>{Q(),I(k)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${C===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[k==="light"?y.jsx(Zwe,{}):k==="dark"?y.jsx(Vwe,{}):y.jsx(Xwe,{}),y.jsx("span",{className:"capitalize",children:k})]},k))})]}),y.jsx(gD,{}),y.jsx(Zl,{onClick:()=>{Q(),e()},icon:y.jsx(cpt,{}),label:"Settings"}),y.jsx(Zl,{onClick:()=>{Q(),n()},icon:y.jsx(lpt,{}),label:"Export"}),p&&y.jsx(Zl,{onClick:()=>{Q(),a()},icon:y.jsx(ipt,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),y.jsx(gD,{}),y.jsx(Zl,{onClick:()=>{Q(),r()},icon:y.jsx(dpt,{}),label:"Download Annotations"}),y.jsx(Zl,{onClick:()=>{Q(),i()},icon:y.jsx(upt,{}),label:"Print / Save as PDF",subtitle:"Choose 'Save as PDF' in the print dialog"}),u&&y.jsx(Zl,{onClick:()=>{Q(),A()},icon:y.jsx(gpt,{}),label:"Copy Share Link"}),u&&y.jsx(Zl,{onClick:()=>{Q(),o()},icon:y.jsx(ppt,{}),label:"Import Review"}),B&&y.jsxs(y.Fragment,{children:[y.jsx(gD,{}),m&&y.jsx(Zl,{onClick:()=>{Q(),s()},icon:y.jsx(Y8,{}),label:"Save to Obsidian"}),f&&y.jsx(Zl,{onClick:()=>{Q(),l()},icon:y.jsx(Y8,{}),label:"Save to Bear"}),b&&y.jsx(Zl,{onClick:()=>{Q(),d()},icon:y.jsx(Y8,{}),label:"Save to Octarine"})]}),y.jsx(gD,{}),y.jsxs("div",{className:"px-3 py-2 space-y-2",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(Vie,{children:"Plannotator"}),y.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",t]})]}),y.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[y.jsx("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",onClick:Q,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Release notes"}),y.jsx("a",{href:"https://github.com/backnotprop/plannotator",target:"_blank",rel:"noopener noreferrer",onClick:Q,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Project repo"})]})]})]})})},opt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),spt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),cpt=()=>y.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[y.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"}),y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),lpt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),dpt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),upt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),gpt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),ppt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),Y8=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),mpt=qt.memo(({isApiMode:t,annotateMode:e,archiveMode:n,gate:a,isSharedSession:r,origin:i,isSubmitting:A,isExiting:o,isPanelOpen:s,hasAnyAnnotations:l,linkedDocIsActive:d,callbackShareUrlReady:u,canShareCurrentSession:g,agentName:p,availableAgents:m,showAnnotationsWarning:f,callbackConfig:b,taterMode:C,mobileSettingsOpen:I,gitUser:B,onCallbackFeedback:Q,onCallbackApprove:k,onAnnotateExit:_,onAnnotateFeedback:D,onAnnotateApprove:x,onFeedback:S,onApprove:L,onAnnotationPanelToggle:N,onArchiveCopy:G,onArchiveDone:P,onTaterModeChange:R,onIdentityChange:U,onUIPreferencesChange:F,onOpenSettings:T,onCloseSettings:O,onOpenExport:H,onCopyAgentInstructions:j,onDownloadAnnotations:K,onPrint:z,onCopyShareLink:Z,onOpenImport:$,onSaveToObsidian:V,onSaveToBear:oe,onSaveToOctarine:ee,appVersion:he,agentInstructionsEnabled:ae,obsidianConfigured:Ae,bearConfigured:ce,octarineConfigured:ie})=>y.jsxs("header",{"data-app-header":"true",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:[y.jsx(hpt,{}),y.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[b&&!t&&r&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),y.jsx(K8,{onClick:Q,disabled:A||!u,isLoading:A,title:"Send feedback to bot"}),y.jsx(jie,{onClick:k,disabled:A||!u,isLoading:A,title:"Approve design and notify bot"})]}),t&&!d&&n&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:G,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:[y.jsx("span",{className:"hidden md:inline",children:"Copy"}),y.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})]}),y.jsx("button",{onClick:P,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"})]}),t&&(!d||e)&&!n&&y.jsxs(y.Fragment,{children:[e?y.jsxs(y.Fragment,{children:[y.jsx(Egt,{onClick:_,disabled:A||o,isLoading:o}),l&&y.jsx(K8,{onClick:D,disabled:A||o,isLoading:A,label:"Send Annotations",title:"Send Annotations"})]}):y.jsx(K8,{onClick:S,disabled:A,isLoading:A,label:"Send Feedback",title:"Send Feedback"}),(!e||a)&&(i==="opencode"&&!e&&m.length>0?y.jsx(ygt,{onApprove:L,agents:m,disabled:A,isLoading:A}):y.jsxs("div",{className:"relative group/approve",children:[y.jsx(jie,{onClick:L,disabled:A||e&&o,isLoading:A,dimmed:!e&&(i==="claude-code"||i==="gemini-cli")&&f,title:e?"Approve — no changes requested":void 0}),!e&&(i==="claude-code"||i==="gemini-cli")&&f&&y.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:[y.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),y.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),p," doesn't support feedback on approval. Your annotations won't be seen."]})]})),y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),y.jsx("button",{onClick:N,className:`p-1.5 rounded-md text-xs font-medium transition-all ${s?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:s?"Hide annotations":"Show annotations",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsx("div",{className:"hidden",children:y.jsx(apt,{taterMode:C,onTaterModeChange:R,onIdentityChange:U,origin:i,onUIPreferencesChange:F,externalOpen:I,onExternalClose:O,gitUser:B})}),y.jsx(Apt,{appVersion:he,onOpenSettings:T,onOpenExport:H,onCopyAgentInstructions:j,onDownloadAnnotations:K,onPrint:z,onCopyShareLink:Z,onOpenImport:$,onSaveToObsidian:V,onSaveToBear:oe,onSaveToOctarine:ee,sharingEnabled:g,isApiMode:t,agentInstructionsEnabled:ae,obsidianConfigured:Ae,bearConfigured:ce,octarineConfigured:ie})]})]})),hpt=()=>y.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:y.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:y.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),fpt=hgt,bpt=()=>{const[t,e]=q.useState(fpt),[n,a]=q.useState([]),[r,i]=q.useState([]),[A,o]=q.useState(null),[s,l]=q.useState(null),d=q.useMemo(()=>wge(t).frontmatter,[t]),u=q.useMemo(()=>LQ(t),[t]),[g,p]=q.useState(!1),[m,f]=q.useState(!1),[b,C]=q.useState(!1),[I,B]=q.useState(!1),[Q,k]=q.useState(!1),[_,D]=q.useState("close"),[x,S]=q.useState(!1),[L,N]=q.useState(""),[G,P]=q.useState(()=>window.innerWidth>=768),[R,U]=q.useState(!1),[F,T]=q.useState($rt),[O,H]=q.useState(nit),[j,K]=q.useState(()=>jt.getItem("plannotator-tater-mode")==="true"),[z,Z]=q.useState(()=>IP()),$=q.useRef(null),[V,oe]=q.useState("full");q.useLayoutEffect(()=>{const Ke=$.current;if(!Ke)return;const Pt=cn=>cn>=800?"full":cn>=680?"short":"icon";oe(Pt(Ke.getBoundingClientRect().width));const zt=new ResizeObserver(([cn])=>{const ma=Pt(cn.contentRect.width);oe(Qa=>Qa===ma?Qa:ma)});return zt.observe(Ke),()=>zt.disconnect()},[]);const[ee,he]=q.useState(!1),[ae,Ae]=q.useState(null),[ce,ie]=q.useState(),[ge,le]=q.useState(!1),[we,me]=q.useState([]),[He,se]=q.useState(!1),[Xe,De]=q.useState(!1),[tt,nt]=q.useState(null),[dt,Pe]=q.useState(),[ot,qe]=q.useState(!1),[ze,At]=q.useState("markdown"),[_e,$e]=q.useState(""),[fe,ve]=q.useState(),[X,Qe]=q.useState(void 0),[Ie,Ne]=q.useState(!0),[Me,Ue]=q.useState(!1),[Ee,xe]=q.useState(!1),[We,rt]=q.useState(null),[mt,Ce]=q.useState(null),[Oe,Te]=q.useState(!1),[at,Mt]=q.useState("bypassPermissions"),[kt,re]=q.useState(!0),[pt,ct]=q.useState(void 0),[xt,_t]=q.useState(void 0),[Lt,ut]=q.useState(null),[Rt,Xt]=q.useState(null),[Ft,An]=q.useState(null),Mn=q.useRef(null),xn=q.useRef(z.tocEnabled);q.useEffect(()=>{document.title=Lt?`${Lt.display} · Plannotator`:"Plannotator"},[Lt]);const[bn,Ln]=q.useState(),[On,Et]=q.useState(!1),[be,et]=q.useState("clean"),[vt,mn]=q.useState(null),[Sn,rn]=q.useState(null),jn=sBe(),sa=q.useRef(null),{ref:fa,viewport:Ut,onViewportReady:It}=sit();oit();const Gt=Bre({storageKey:"plannotator-panel-width"}),Tt=Bre({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),St=Gt.isDragging||Tt.isDragging,Jt=uit(IP().tocEnabled),Le=q.useMemo(()=>u.some(Ke=>Ke.type==="heading"&&(Ke.level??0)<=3),[u]),xa=q.useCallback(Ke=>{if(Ft===null){Ke?.sidebarTab&&Jt.open(Ke.sidebarTab),Ke?.panelOpen===!0?P(!0):Ke?.panelOpen===!1&&P(!1);return}const Pt=Mn.current,zt=bgt(Pt,Ke);An(null),Mn.current=null,zt.sidebarOpen&&zt.sidebarTab?Jt.open(zt.sidebarTab):Jt.close(),zt.panelOpen!==void 0&&P(zt.panelOpen)},[Ft,Jt.close,Jt.open]),Ge=q.useCallback(Ke=>{if(Ft!==null){xa({restore:!1,sidebarTab:Ke,panelOpen:!1});return}Jt.open(Ke)},[xa,Ft,Jt.open]),Hn=q.useCallback(Ke=>{if(Ft!==null){xa({restore:!1,sidebarTab:Ke,panelOpen:!1});return}Jt.toggleTab(Ke)},[xa,Ft,Jt.toggleTab]),qo=q.useCallback(()=>{if(Ft!==null){xa({restore:!1,panelOpen:!0});return}P(Ke=>!Ke)},[xa,Ft]);q.useEffect(()=>{Ft===null&&xn.current!==z.tocEnabled&&(xn.current=z.tocEnabled,z.tocEnabled&&Le?Jt.open("toc"):z.tocEnabled||Jt.close())},[Ft,Jt.close,Jt.open,z.tocEnabled,Le]),q.useEffect(()=>{u.length!==0&&(Le||Jt.activeTab==="toc"&&Jt.isOpen&&Jt.close())},[u,Le]),q.useEffect(()=>{Jt.activeTab==="toc"&&On&&Et(!1)},[Jt.activeTab]),q.useEffect(()=>{if(!On)return;const Ke=Pt=>{Pt.key==="Escape"&&Et(!1)};return document.addEventListener("keydown",Ke),()=>document.removeEventListener("keydown",Ke)},[On]);const Ua=Vit(t,vt,Sn),go=q.useMemo(()=>({...Jt,open:Ge,toggleTab:Hn}),[Ge,Jt.activeTab,Jt.close,Jt.isOpen,Hn]),wn=Xit({markdown:t,annotations:n,selectedAnnotationId:A,globalAttachments:we,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setGlobalAttachments:me,viewerRef:sa,sidebar:go,sourceFilePath:fe,sourceConverted:ot}),sr=q.useMemo(()=>wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):X?.includes("/")?X:void 0,[wn.filepath,X]),Wa=$it({buildUrl:q.useCallback(Ke=>sr?`/api/doc?path=${encodeURIComponent(Ke)}&base=${encodeURIComponent(sr)}`:`/api/doc?path=${encodeURIComponent(Ke)}`,[sr])}),ya=rAt({markdown:t,viewerRef:sa,linkedDocHook:wn,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setSubmitted:rt}),yi=q.useMemo(()=>fgt({archiveMode:ya.archiveMode,isPlanDiffActive:On}),[ya.archiveMode,On]),po=q.useCallback(Ke=>{yi&&(Ft===null&&(Mn.current={sidebarIsOpen:Jt.isOpen,sidebarTab:Jt.activeTab,panelOpen:G}),An(Ke),Jt.close(),P(!1))},[yi,G,Ft,Jt.activeTab,Jt.close,Jt.isOpen]),Mr=q.useCallback(Ke=>{Ft===Ke?xa():po(Ke)},[po,xa,Ft]);q.useEffect(()=>{!yi&&Ft!==null&&xa()},[yi,xa,Ft]);const Ca=uAt(),Za=q.useMemo(()=>Wae()?fp(hp()):"",[z]),Cn=q.useMemo(()=>!!Rt||Tre()||Wae(),[Rt,z]),_n=q.useMemo(()=>{const Ke=Rt?[Rt]:[],Pt=Tre()?sY().directories:[];return[...new Set([...Ke,...Pt])]},[Rt,z]);q.useEffect(()=>{Cn||Ca.setActiveFile(null)},[Cn]),q.useEffect(()=>{Za||Ca.clearVaultDirs()},[Za]),q.useEffect(()=>{if(Jt.activeTab==="files"&&Cn){if(_n.length>0){const Ke=Ca.dirs.filter(zt=>!zt.isVault).map(zt=>zt.path);(_n.some(zt=>!Ke.includes(zt))||Ke.some(zt=>!_n.includes(zt)))&&Ca.fetchAll(_n)}Za&&!Ca.dirs.find(Ke=>Ke.isVault&&Ke.path===Za&&!Ke.error)&&Ca.addVaultDir(Za)}},[Jt.activeTab,Cn,_n,Za]);const ir=qt.useCallback((Ke,Pt)=>{const cn=Ca.dirs.find(ma=>ma.path===Pt)?.isVault?ma=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Pt)}&path=${encodeURIComponent(ma)}`:ma=>`/api/doc?path=${encodeURIComponent(ma)}&base=${encodeURIComponent(Pt)}`;wn.open(Ke,cn,"files"),Ca.setActiveFile(Ke)},[wn,Ca]),ua=qt.useCallback(Ke=>{if(Ca.dirs.find(zt=>zt.path===Ca.activeDirPath)?.isVault&&Ca.activeDirPath)wn.open(Ke,zt=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Ca.activeDirPath)}&path=${encodeURIComponent(zt)}`);else if(Ca.activeFile&&Ca.activeDirPath){const zt=wn.filepath?.replace(/\/[^/]+$/,"")||Ca.activeDirPath;wn.open(Ke,cn=>`/api/doc?path=${encodeURIComponent(cn)}&base=${encodeURIComponent(zt)}`)}else{const zt=wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):X?.includes("/")?X:void 0;zt?wn.open(Ke,cn=>`/api/doc?path=${encodeURIComponent(cn)}&base=${encodeURIComponent(zt)}`):wn.open(Ke)}},[Ca.dirs,Ca.activeDirPath,Ca.activeFile,wn,X]),ui=qt.useCallback(()=>{wn.back(),Ca.setActiveFile(null),ya.clearSelection()},[wn,Ca,ya]),Ya=q.useMemo(()=>{const Ke=new Map;for(const[Pt,zt]of wn.getDocAnnotations()){const cn=zt.annotations.length+zt.globalAttachments.length;cn>0&&Ke.set(Pt,cn)}return Ke},[wn.getDocAnnotations,n,we]),fA=q.useMemo(()=>{const Ke=Ca.dirs.map(zt=>zt.path);if(Ke.length===0)return Ya;const Pt=new Map;for(const[zt,cn]of Ya)Ke.some(ma=>zt.startsWith(ma+"/"))&&Pt.set(zt,cn);return Pt},[Ya,Ca.dirs]),gi=fA.size>0,en=q.useMemo(()=>{const Ke=wn.filepath;let Pt=0,zt=0;for(const[cn,ma]of Ya)cn!==Ke&&(Pt+=ma,zt++);return Pt>0?{count:Pt,files:zt}:void 0},[Ya,wn.filepath]),[J,te]=q.useState(),pe=qt.useRef(),ke=qt.useCallback(()=>{const Ke=new Set(Ya.keys());Ke.size!==0&&((!Jt.isOpen||Jt.activeTab!=="files")&&Ge("files"),pe.current&&clearTimeout(pe.current),te(void 0),requestAnimationFrame(()=>{te(Ke),pe.current=setTimeout(()=>te(void 0),1200)}))},[Ya,Ge,Jt,gi]),Ye=tt==="folder"?"file list":tt==="file"?"file":tt==="message"?"message":"plan",it=q.useMemo(()=>u.filter(Ke=>Ke.type==="heading").length,[u]),ft=Ort(fa,it,Ut),{editorAnnotations:Ct,deleteEditorAnnotation:on}=AAt(),{externalAnnotations:Un,updateExternalAnnotation:Zn,deleteExternalAnnotation:pa}=cAt({enabled:ee}),{reset:da}=lAt({viewerRef:sa,externalAnnotations:Un,enabled:ee&&!wn.isActive&&!On,planKey:t}),sn=q.useMemo(()=>Un.length===0?n:[...n.filter(Pt=>Pt.source?!Un.some(zt=>zt.source===Pt.source&&zt.type===Pt.type&&zt.originalText===Pt.originalText):!0),...Un],[n,Un]),Yn=q.useMemo(()=>sn.filter(Ke=>!!Ke.diffContext),[sn]),hr=q.useMemo(()=>sn.filter(Ke=>!Ke.diffContext),[sn]),Zr=q.useMemo(()=>sn.length>0||r.length>0||Ct.length>0||wn.docAnnotationCount>0||we.length>0,[sn.length,r.length,Ct.length,wn.docAnnotationCount,we.length]),Zi=sn.length+r.length+Ct.length+wn.docAnnotationCount+we.length,Ar=kt&&r.length===0,{isSharedSession:xr,isLoadingShared:jo,shareUrl:Vr,shareUrlSize:Kl,shortShareUrl:fr,isGeneratingShortUrl:yI,shortUrlError:Dm,pendingSharedAnnotations:Wd,clearPendingSharedAnnotations:QI,generateShortUrl:pM,importFromShareUrl:mM,shareLoadError:ek,clearShareLoadError:wI}=Nrt(t,sn,we,e,a,me,()=>{Ne(!1)},pt,xt,_e,$e,At),{draftBanner:xm,restoreDraft:tk,dismissDraft:hM}=aAt({annotations:sn,codeAnnotations:r,globalAttachments:we,isApiMode:ee,isSharedSession:xr,submitted:!!We}),fM=qt.useCallback(()=>{const{annotations:Ke,codeAnnotations:Pt,globalAttachments:zt}=tk();(Ke.length>0||Pt.length>0||zt.length>0)&&(a(Ke),i(Pt),zt.length>0&&me(zt),setTimeout(()=>{sa.current?.applySharedAnnotations(Ke.filter(cn=>!cn.diffContext))},100))},[tk]),{agents:bM,getAgentWarning:Sm}=AQe(ae);q.useEffect(()=>{if(Wd&&Wd.length>0){const Ke=setTimeout(()=>{sa.current?.clearAllHighlights(),sa.current?.applySharedAnnotations(Wd.filter(Pt=>!Pt.diffContext)),QI(),da()},100);return()=>clearTimeout(Ke)}},[Wd,QI,da]);const CM=q.useCallback(Ke=>{K(Ke),jt.setItem("plannotator-tater-mode",String(Ke))},[]),nk=Ke=>{T(Ke),eit(Ke)},kI=Ke=>{H(Ke),ait(Ke)};Ait(O,kI),q.useEffect(()=>{jo||xr||fetch("/api/plan").then(Ke=>{if(!Ke.ok)throw new Error("Not in API mode");return Ke.json()}).then(Ke=>{Ai.init(Ke.serverConfig),ie(Ke.serverConfig?.gitUser),Ke.mode==="archive"?(e(Ke.plan||""),Ke.archivePlans&&ya.init(Ke.archivePlans),ya.fetchPlans(),re(!1),Jt.open("archive")):Ke.renderAs==="html"&&Ke.rawHtml?(At("html"),$e(Ke.rawHtml),e("")):Ke.mode==="annotate-folder"?e(""):Ke.plan&&e(Ke.plan),he(!0),(Ke.mode==="annotate"||Ke.mode==="annotate-last"||Ke.mode==="annotate-folder")&&(se(!0),De(Ke.gate??!1)),Ke.mode==="annotate-folder"&&Jt.open("files"),Ke.mode&&Ke.mode!=="archive"&&nt(Ke.mode==="annotate-last"?"message":Ke.mode==="annotate-folder"?"folder":"file"),Pe(Ke.sourceInfo??void 0),qe(!!Ke.sourceConverted),Ke.filePath&&(Qe(Ke.mode==="annotate-folder"?Ke.filePath:Ke.filePath.replace(/\/[^/]+$/,"")),Ke.mode==="annotate"&&ve(Ke.filePath)),Ke.sharingEnabled!==void 0&&re(Ke.sharingEnabled),Ke.shareBaseUrl&&ct(Ke.shareBaseUrl),Ke.pasteApiUrl&&_t(Ke.pasteApiUrl),Ke.repoInfo&&ut(Ke.repoInfo),Ke.projectRoot&&Xt(Ke.projectRoot),Ke.previousPlan!==void 0&&mn(Ke.previousPlan),Ke.versionInfo&&rn(Ke.versionInfo),Ke.origin&&(Ae(Ke.origin),Ke.origin==="claude-code"&&lit()&&Te(!0),Mt(hQe().mode)),Ke.isWSL&&le(!0)}).catch(()=>{he(!1)}).finally(()=>Ne(!1))},[jo,xr]);const vI=q.useRef(!1),kg=q.useRef({}),Vf=q.useRef(null);q.useEffect(()=>{vI.current=!1,kg.current={},Vf.current=null},[t]),q.useEffect(()=>{if(!ee||!t||xr||He||ya.archiveMode||vI.current)return;const Ke={},Pt=[],zt=hp();if(zt.autoSave&&zt.enabled){const cr=fp(zt);cr&&(Ke.obsidian={vaultPath:cr,folder:zt.folder||"plannotator",plan:t,...zt.filenameFormat&&{filenameFormat:zt.filenameFormat},...zt.filenameSeparator&&zt.filenameSeparator!=="space"&&{filenameSeparator:zt.filenameSeparator}},Pt.push("Obsidian"))}const cn=Ch();cn.autoSave&&cn.enabled&&(Ke.bear={plan:t,customTags:cn.customTags,tagPosition:cn.tagPosition},Pt.push("Bear"));const ma=MC();if(ma.autoSave&&tD()&&(Ke.octarine={plan:t,workspace:ma.workspace,folder:ma.folder||"plannotator"},Pt.push("Octarine")),Pt.length===0)return;vI.current=!0;const Qa=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke)}).then(cr=>cr.json()).then(cr=>{const Mi={...Ke.obsidian?{obsidian:!!cr.results?.obsidian?.success}:{},...Ke.bear?{bear:!!cr.results?.bear?.success}:{},...Ke.octarine?{octarine:!!cr.results?.octarine?.success}:{}};kg.current=Mi;const $d=Pt.filter(zA=>!cr.results?.[zA.toLowerCase()]?.success);return $d.length===0?_s.success(`Auto-saved to ${Pt.join(" & ")}`):_s.error(`Auto-save failed for ${$d.join(" & ")}`),Mi}).catch(()=>(kg.current={},_s.error("Auto-save failed"),{}));Vf.current=Qa},[ee,t,xr,He]),q.useEffect(()=>{const Ke=Pt=>{const zt=Pt.clipboardData?.items;if(zt){for(const cn of zt)if(cn.type.startsWith("image/")){Pt.preventDefault();const ma=cn.getAsFile();if(ma){const Qa=zU(ma.name,we.map(Mi=>Mi.name)),cr=URL.createObjectURL(ma);Ce({file:ma,blobUrl:cr,initialName:Qa})}break}}};return document.addEventListener("paste",Ke),()=>document.removeEventListener("paste",Ke)},[we]);const EM=async(Ke,Pt,zt)=>{if(mt)try{const cn=new FormData,ma=Pt?new File([Ke],"annotated.png",{type:"image/png"}):mt.file;cn.append("file",ma);const Qa=await fetch("/api/upload",{method:"POST",body:cn});if(Qa.ok){const cr=await Qa.json();me(Mi=>[...Mi,{path:cr.path,name:zt}])}}catch{}finally{URL.revokeObjectURL(mt.blobUrl),Ce(null)}},IM=()=>{mt&&(URL.revokeObjectURL(mt.blobUrl),Ce(null))},vg=async()=>{Ue(!0);try{const Ke=hp(),Pt=Ch(),zt=MC(),cn=a_(),ma=Pt.autoSave&&Vf.current?await Vf.current:kg.current,Qa={};ae==="claude-code"&&(Qa.permissionMode=at);const cr=Grt(GR());cr&&(Qa.agentSwitch=cr),Qa.planSave={enabled:cn.enabled,...cn.customPath&&{customPath:cn.customPath}};const Mi=fp(Ke);Ke.enabled&&Mi&&(Qa.obsidian={vaultPath:Mi,folder:Ke.folder||"plannotator",plan:t,...Ke.filenameFormat&&{filenameFormat:Ke.filenameFormat},...Ke.filenameSeparator&&Ke.filenameSeparator!=="space"&&{filenameSeparator:Ke.filenameSeparator}}),Pt.enabled&&!(Pt.autoSave&&ma.bear)&&(Qa.bear={plan:t,customTags:Pt.customTags,tagPosition:Pt.tagPosition}),tD()&&(Qa.octarine={plan:t,workspace:zt.workspace,folder:zt.folder||"plannotator"});const $d=Array.from(wn.getDocAnnotations().values()).some(zA=>zA.annotations.length>0||zA.globalAttachments.length>0);(sn.length>0||r.length>0||we.length>0||$d||Ct.length>0)&&(Qa.feedback=Zd),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qa)}),rt("approved")}catch{Ue(!1)}},DI=async()=>{Ue(!0);try{const Ke=a_();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Zd,planSave:{enabled:Ke.enabled,...Ke.customPath&&{customPath:Ke.customPath}}})}),rt("denied")}catch{Ue(!1)}},xI=async()=>{Ue(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Zd,annotations:sn,codeAnnotations:r})}),rt("denied")}catch{Ue(!1)}},Xf=async()=>{Ue(!0);try{await fetch("/api/approve",{method:"POST"}),rt("approved")}catch{Ue(!1)}},SI=q.useCallback(async()=>{xe(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)rt("exited");else throw new Error("Failed to exit")}catch{xe(!1)}},[]);q.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="Enter"||!(Pt.metaKey||Pt.ctrlKey))return;const zt=Pt.target?.tagName;if(zt==="INPUT"||zt==="TEXTAREA"||g||m||b||I||Q||x||Oe||mt||We||Me||Ee||!ee||wn.isActive)return;if(Pt.preventDefault(),He){if(Xe&&!Zr){Xf();return}xI();return}const cn=wn.getDocAnnotations(),ma=Array.from(cn.values()).some(Qa=>Qa.annotations.length>0||Qa.globalAttachments.length>0);if(sn.length===0&&r.length===0&&Ct.length===0&&!ma){if(ae==="opencode"){const Qa=Sm();if(Qa){N(Qa),S(!0);return}}vg()}else DI()};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[g,m,b,I,Q,x,Oe,mt,We,Me,Ee,ee,wn.isActive,n.length,r.length,Un.length,He,Xe,Zr,ae,Sm]);const $f=Ke=>{a(Pt=>[...Pt,Ke]),o(Ke.id),l(null),Ft===null&&P(!0)},eb=qt.useCallback(Ke=>{o(Ke),Ke&&l(null),Ke&&jn&&Ft===null&&P(!0)},[jn,Ft]),BM=qt.useCallback(Ke=>{const Pt={id:pAt("code-ann"),type:"comment",scope:"line",filePath:Ke.filePath,lineStart:Ke.lineStart,lineEnd:Ke.lineEnd,side:"new",text:Ke.text,images:Ke.images,originalCode:Ke.originalCode,createdAt:Date.now(),author:Ai.get("displayName")||void 0};i(zt=>[...zt,Pt]),o(null),l(Pt.id),Ft===null&&P(!0)},[Ft]),yM=qt.useCallback(Ke=>{const Pt=r.find(zt=>zt.id===Ke);Pt&&(o(null),l(Ke),Wa.open(Pt.filePath),jn&&Ft===null&&P(!0))},[r,Wa.open,jn,Ft]),ak=qt.useCallback(Ke=>{i(Pt=>Pt.filter(zt=>zt.id!==Ke)),s===Ke&&l(null)},[s]),tb=qt.useCallback((Ke,Pt)=>{i(zt=>zt.map(cn=>cn.id===Ke?{...cn,...Pt}:cn))},[]),Dg=Ke=>{sa.current?.removeHighlight(Ke),a(Pt=>Pt.filter(zt=>zt.id!==Ke)),A===Ke&&o(null)},_I=Cgt({blocks:u,annotations:n,addAnnotation:$f,removeAnnotation:Dg}),rk=Ke=>{const Pt=sn.find(zt=>zt.id===Ke);if(Pt?.source&&Un.some(zt=>zt.id===Ke)){pa(Ke),A===Ke&&o(null);return}Ke.startsWith("ann-checkbox-")&&Pt&&_I.revertOverride(Pt.blockId),Dg(Ke)},ik=(Ke,Pt)=>{if(sn.find(cn=>cn.id===Ke)?.source&&Un.some(cn=>cn.id===Ke)){Zn(Ke,Pt);return}a(cn=>cn.map(ma=>ma.id===Ke?{...ma,...Pt}:ma))},Ak=q.useCallback((Ke,Pt)=>{a(zt=>zt.map(cn=>cn.author===Ke?{...cn,author:Pt}:cn)),i(zt=>zt.map(cn=>cn.author===Ke?{...cn,author:Pt}:cn))},[]),RI=Ke=>{me(Pt=>[...Pt,Ke])},NI=Ke=>{me(Pt=>Pt.filter(zt=>zt.path!==Ke))},xg=Ke=>{},Zd=q.useMemo(()=>{const Ke=wn.getDocAnnotations(),Pt=Array.from(Ke.values()).some(Mi=>Mi.annotations.length>0||Mi.globalAttachments.length>0),zt=sn.length>0||we.length>0,cn=Ct.length>0,ma=r.length>0;if(!zt&&!Pt&&!cn&&!ma)return"User reviewed the document and has no feedback.";const Qa=wn.isActive?Ke.get(wn.filepath??"")?.isConverted??!1:ot;let cr=zt?PMe(u,sn,we,tt==="message"?"Message Feedback":tt==="folder"?"Folder Feedback":tt==="file"?"File Feedback":"Plan Feedback",tt??"plan",{sourceConverted:Qa}):"";if(Pt){const Mi=new Map(Ke);for(const[$d,zA]of Mi)zA.markdown&&Mi.set($d,{...zA,blocks:LQ(zA.markdown)});cr+=KMe(Mi)}return cn&&(cr+=HMe(Ct)),ma&&(cr+=YMe(r)),cr},[u,sn,we,wn.getDocAnnotations,Ct,r,ot,tt,wn.isActive,wn.filepath]),_m=qt.useMemo(()=>Mrt(),[]),nb=qt.useCallback(async Ke=>{if(!(!_m||Me||!Vr&&!fr)){Ue(!0);try{const Pt=await Frt(Ke,_m,fr||Vr);Pt&&(Pt.type==="success"?(_s.success(Pt.message),rt(Ke===qx.Approve?"approved":"denied")):_s.error(Pt.message))}finally{Ue(!1)}}},[_m,Me,Vr,fr]),ok=qt.useCallback(()=>nb(qx.Approve),[nb]),sk=qt.useCallback(()=>nb(qx.Feedback),[nb]),Vd=()=>{const Ke=new Blob([Zd],{type:"text/plain"}),Pt=URL.createObjectURL(Ke),zt=document.createElement("a");zt.href=Pt,zt.download="annotations.md",zt.click(),URL.revokeObjectURL(Pt),_s.success("Downloaded annotations")},Wc=async Ke=>{const Pt={};if(Ke==="obsidian"){const cn=hp(),ma=fp(cn);ma&&(Pt.obsidian={vaultPath:ma,folder:cn.folder||"plannotator",plan:t,...cn.filenameFormat&&{filenameFormat:cn.filenameFormat},...cn.filenameSeparator&&cn.filenameSeparator!=="space"&&{filenameSeparator:cn.filenameSeparator}})}if(Ke==="bear"){const cn=Ch();Pt.bear={plan:t,customTags:cn.customTags,tagPosition:cn.tagPosition}}if(Ke==="octarine"){const cn=MC();Pt.octarine={plan:t,workspace:cn.workspace,folder:cn.folder||"plannotator"}}const zt=Ke==="obsidian"?"Obsidian":Ke==="bear"?"Bear":"Octarine";try{const Qa=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pt)})).json()).results?.[Ke];Qa?.success?_s.success(`Saved to ${zt}`):_s.error(Qa?.error||"Save failed")}catch{_s.error("Save failed")}},ck=async()=>{const Ke=dAt(window.location.origin);try{await navigator.clipboard.writeText(Ke),_s.success("Agent instructions copied")}catch{_s.error("Failed to copy")}},Rm=async()=>{const Ke=fr||Vr;if(Ke)try{await navigator.clipboard.writeText(Ke),_s.success("Share link copied")}catch{_s.error("Failed to copy")}};q.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="s"||!(Pt.metaKey||Pt.ctrlKey))return;const zt=Pt.target?.tagName;if(zt==="INPUT"||zt==="TEXTAREA"||g||b||I||Q||x||Oe||mt||We||!ee)return;Pt.preventDefault();const cn=sQe(),ma=Jae(),Qa=Ch().enabled,cr=tD();cn==="download"?Vd():cn==="obsidian"&&ma?Wc("obsidian"):cn==="bear"&&Qa?Wc("bear"):cn==="octarine"&&cr?Wc("octarine"):(Ln("notes"),p(!0))};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[g,b,I,Q,x,Oe,mt,We,ee,t,Zd]),q.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="p"||!(Pt.metaKey||Pt.ctrlKey))return;const zt=Pt.target?.tagName;zt==="INPUT"||zt==="TEXTAREA"||g||b||I||Q||x||Oe||mt||We||(Pt.preventDefault(),window.print())};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[g,b,I,Q,x,Oe,mt,We]);const Zc=q.useMemo(()=>LMe(ae),[ae]),mo=q.useRef({handleApprove:vg,handleDeny:DI,handleAnnotateApprove:Xf,handleAnnotateFeedback:xI,handleAnnotateExit:SI,handleQuickSaveToNotes:Wc,handleDownloadAnnotations:Vd,handleCopyAgentInstructions:ck,handleCopyShareLink:Rm,getAgentWarning:Sm,getDocAnnotations:wn.getDocAnnotations});mo.current={handleApprove:vg,handleDeny:DI,handleAnnotateApprove:Xf,handleAnnotateFeedback:xI,handleAnnotateExit:SI,handleQuickSaveToNotes:Wc,handleDownloadAnnotations:Vd,handleCopyAgentInstructions:ck,handleCopyShareLink:Rm,getAgentWarning:Sm,getDocAnnotations:wn.getDocAnnotations};const MI=q.useCallback(()=>{Zr?(D("close"),k(!0)):mo.current.handleAnnotateExit()},[Zr]),FI=q.useCallback(()=>{const Ke=mo.current,Pt=Ke.getDocAnnotations(),zt=Array.from(Pt.values()).some(cn=>cn.annotations.length>0||cn.globalAttachments.length>0);sn.length===0&&r.length===0&&Ct.length===0&&!zt?C(!0):Ke.handleDeny()},[sn.length,r.length,Ct.length]),lk=q.useCallback(()=>{const Ke=mo.current;if(He){if(Zr){D("approve"),k(!0);return}Ke.handleAnnotateApprove();return}if(ae==="claude-code"&&(sn.length>0||r.length>0)){B(!0);return}if(ae==="opencode"){const Pt=Ke.getAgentWarning();if(Pt){N(Pt),S(!0);return}}Ke.handleApprove()},[He,Zr,ae,sn.length,r.length]),dk=q.useCallback(()=>mo.current.handleAnnotateFeedback(),[]),uk=q.useCallback(()=>mo.current.handleAnnotateApprove(),[]),QM=q.useCallback(()=>mo.current.handleDownloadAnnotations(),[]),wM=q.useCallback(()=>mo.current.handleCopyAgentInstructions(),[]),kM=q.useCallback(()=>mo.current.handleCopyShareLink(),[]),vM=q.useCallback(()=>U(!0),[]),DM=q.useCallback(()=>U(!1),[]),ho=q.useCallback(()=>{Ln(void 0),p(!0)},[]),Nm=q.useCallback(()=>window.print(),[]),gk=q.useCallback(()=>f(!0),[]),pk=q.useCallback(()=>mo.current.handleQuickSaveToNotes("obsidian"),[]),mk=q.useCallback(()=>mo.current.handleQuickSaveToNotes("octarine"),[]),hk=q.useCallback(()=>mo.current.handleQuickSaveToNotes("bear"),[]),ab=q.useMemo(()=>({compact:832,default:1040,wide:1280})[z.planWidth]??832,[z.planWidth]),Xd=yi&&Ft==="wide"?null:ab;return y.jsx(ynt,{defaultTheme:"dark",children:y.jsx(drt,{delayDuration:900,skipDelayDuration:200,disableHoverableContent:!0,children:y.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[y.jsx(mpt,{isApiMode:ee,annotateMode:He,archiveMode:ya.archiveMode,gate:Xe,isSharedSession:xr,origin:ae,isSubmitting:Me,isExiting:Ee,isPanelOpen:G,hasAnyAnnotations:Zr,linkedDocIsActive:wn.isActive,callbackShareUrlReady:_m?!!(Vr||fr):!0,canShareCurrentSession:Ar,agentName:Zc,availableAgents:bM,showAnnotationsWarning:sn.length>0||r.length>0,callbackConfig:_m,taterMode:j,mobileSettingsOpen:R,gitUser:ce,onCallbackFeedback:sk,onCallbackApprove:ok,onAnnotateExit:MI,onAnnotateFeedback:dk,onAnnotateApprove:uk,onFeedback:FI,onApprove:lk,onAnnotationPanelToggle:qo,onArchiveCopy:ya.copy,onArchiveDone:ya.done,onTaterModeChange:CM,onIdentityChange:Ak,onUIPreferencesChange:Z,onOpenSettings:vM,onCloseSettings:DM,onOpenExport:ho,onCopyAgentInstructions:wM,onDownloadAnnotations:QM,onPrint:Nm,onCopyShareLink:kM,onOpenImport:gk,onSaveToObsidian:pk,onSaveToBear:hk,onSaveToOctarine:mk,appVersion:"0.19.17",agentInstructionsEnabled:ee&&!ya.archiveMode&&!He,obsidianConfigured:Jae(),bearConfigured:Ch().enabled,octarineConfigured:tD()}),wn.error&&y.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[y.jsx("span",{className:"text-xs text-destructive",children:wn.error}),y.jsx("button",{onClick:wn.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),y.jsx(ABe.Provider,{value:Ut,children:y.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${St?"select-none":""}`,children:[j&&y.jsx(krt,{}),Ft===null&&!Jt.isOpen&&y.jsx(mAt,{activeTab:Jt.activeTab,onToggleTab:Hn,hasDiff:Ua.hasPreviousVersion,showVersionsTab:Sn!==null&&Sn.totalVersions>1,showFilesTab:Cn&&!ya.archiveMode,hasFileAnnotations:gi,className:"hidden lg:flex absolute left-0 top-0 z-10"}),Jt.isOpen&&y.jsxs(y.Fragment,{children:[y.jsx(vAt,{activeTab:Jt.activeTab,onTabChange:Ke=>{Hn(Ke),Ke==="archive"&&!ya.archiveMode&&ya.fetchPlans()},onClose:Jt.close,width:Tt.width,blocks:u,annotations:n,activeSection:ft,onTocNavigate:xg,linkedDocFilepath:wn.filepath,onLinkedDocBack:wn.isActive?ui:void 0,backLabel:Ye,showFilesTab:Cn&&!ya.archiveMode,fileAnnotationCounts:fA,highlightedFiles:J,fileBrowser:Ca,onFilesSelectFile:ir,onFilesFetchAll:()=>Ca.fetchAll(_n),onFilesRetryVaultDir:Ke=>Ca.addVaultDir(Ke),hasFileAnnotations:gi,showVersionsTab:Sn!==null&&Sn.totalVersions>1,versionInfo:Sn,versions:Ua.versions,selectedBaseVersion:Ua.diffBaseVersion,onSelectBaseVersion:Ua.selectBaseVersion,isPlanDiffActive:On,hasPreviousVersion:Ua.hasPreviousVersion,onActivatePlanDiff:()=>Et(!0),isLoadingVersions:Ua.isLoadingVersions,isSelectingVersion:Ua.isSelectingVersion,fetchingVersion:Ua.fetchingVersion,onFetchVersions:Ua.fetchVersions,showArchiveTab:ee&&!He,archivePlans:ya.plans,selectedArchiveFile:ya.selectedFile,onArchiveSelect:ya.select,isLoadingArchive:ya.isLoading}),y.jsx(yre,{...Tt.handleProps,className:"hidden lg:block",side:"left"})]}),y.jsxs(c0,{element:"main",className:`flex-1 min-w-0 bg-grid ${!Jt.isOpen&&Ft===null?"lg:pl-[30px]":""}`,"data-print-region":"document",onViewportReady:It,children:[y.jsx(Gb,{isOpen:!!xm,onClose:hM,onConfirm:fM,title:"Draft Recovered",message:xm?`Found ${xm.count} annotation${xm.count!==1?"s":""} from ${xm.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),y.jsxs("div",{ref:$,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:[!On&&!ya.archiveMode&&z.stickyActionsEnabled&&y.jsx(Irt,{inputMethod:O,onInputMethodChange:kI,mode:F,onModeChange:nk,taterMode:j,repoInfo:Lt,planDiffStats:Ua.diffStats,isPlanDiffActive:On,hasPreviousVersion:Ua.hasPreviousVersion,onPlanDiffToggle:()=>Et(!On),archiveInfo:ya.currentInfo,maxWidth:Xd,remountToken:wn.isActive?`doc:${wn.filepath}`:"plan"}),!On&&!ya.archiveMode&&y.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:Xd==null?void 0:{maxWidth:Xd},children:y.jsx(Jye,{inputMethod:O,onInputMethodChange:kI,mode:F,onModeChange:nk,taterMode:j})}),Ua.diffBlocks&&Ua.diffStats&&y.jsx("div",{className:"w-full flex justify-center",style:{display:On?void 0:"none"},children:y.jsx(UAt,{diffBlocks:Ua.diffBlocks,diffStats:Ua.diffStats,diffMode:be,onDiffModeChange:et,onPlanDiffToggle:()=>Et(!1),repoInfo:Lt,baseVersionLabel:Ua.diffBaseVersion!=null?`v${Ua.diffBaseVersion}`:void 0,baseVersion:Ua.diffBaseVersion??void 0,maxWidth:ab,annotations:Yn,onAddAnnotation:$f,onSelectAnnotation:eb,selectedAnnotationId:A,mode:F})}),tt==="folder"&&!t&&!wn.isActive&&y.jsx("div",{className:"w-full flex justify-center",children:y.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[y.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),y.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),y.jsxs("div",{className:"w-full flex justify-center relative",style:{display:On&&Ua.diffBlocks||tt==="folder"&&!t&&!wn.isActive?"none":void 0},children:[yi&&!On&&!ya.archiveMode&&y.jsx("div",{"data-print-hide":!0,className:"absolute -top-5 left-0 right-0 mx-auto w-full flex justify-end pointer-events-none",style:Xd===null?void 0:{maxWidth:Xd??832},children:y.jsx("div",{className:`pointer-events-auto flex items-center gap-1.5 text-[11px] tracking-wide ${j?"mr-[60px]":"mr-[4px]"}`,children:["wide","focus"].map((Ke,Pt)=>y.jsxs(qt.Fragment,{children:[Pt>0&&y.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/30 select-none",children:"|"}),y.jsx(urt,{side:"top",align:"end",content:Ke==="wide"?"Hide panels and expand document width":"Hide panels, keep document width",children:y.jsx("button",{type:"button",onClick:()=>Mr(Ke),"aria-pressed":Ft===Ke,className:`cursor-pointer rounded-sm transition-colors duration-150 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:opacity-80 ${Ft===Ke?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,children:Ke.charAt(0).toUpperCase()+Ke.slice(1)})})]},Ke))})}),ze==="html"?y.jsx(oBe,{ref:sa,rawHtml:_e,annotations:hr,onAddAnnotation:$f,onSelectAnnotation:eb,selectedAnnotationId:A,mode:F,globalAttachments:we,onAddGlobalAttachment:RI,onRemoveGlobalAttachment:NI,maxWidth:Xd}):y.jsx(Wet,{ref:sa,blocks:u,markdown:t,frontmatter:d,annotations:hr,onAddAnnotation:$f,onSelectAnnotation:eb,selectedAnnotationId:A,mode:F,inputMethod:O,taterMode:j,globalAttachments:we,onAddGlobalAttachment:RI,onRemoveGlobalAttachment:NI,repoInfo:Lt,stickyActions:z.stickyActionsEnabled,planDiffStats:wn.isActive?null:Ua.diffStats,isPlanDiffActive:On,onPlanDiffToggle:()=>Et(!On),hasPreviousVersion:!wn.isActive&&Ua.hasPreviousVersion,showDemoBadge:!ee&&!jo&&!xr,maxWidth:Xd,onOpenLinkedDoc:ua,onOpenCodeFile:Wa.open,linkedDocInfo:wn.isActive?{filepath:wn.filepath,onBack:ui,label:Ca.dirs.find(Ke=>Ke.path===Ca.activeDirPath)?.isVault?"Vault File":Ca.activeFile?"File":void 0,backLabel:Ye}:null,imageBaseDir:X,codePathBaseDir:sr,copyLabel:tt==="message"?"Copy message":tt==="file"||tt==="folder"?"Copy file":void 0,archiveInfo:ya.currentInfo,sourceInfo:dt,onToggleCheckbox:_I.toggle,checkboxOverrides:_I.overrides,actionsLabelMode:V},wn.isActive?`doc:${wn.filepath}`:"plan")]})]})]}),G&&Ft===null&&y.jsx(yre,{...Gt.handleProps,className:"hidden md:block",side:"right"}),y.jsx(unt,{isOpen:G&&Ft===null,blocks:u,annotations:sn,selectedId:A??s,onSelect:eb,onDelete:rk,onEdit:ik,codeAnnotations:r,onSelectCodeAnnotation:yM,onDeleteCodeAnnotation:ak,onEditCodeAnnotation:tb,sharingEnabled:Ar,width:Gt.width,editorAnnotations:Ct,onDeleteEditorAnnotation:on,onClose:()=>P(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(vge(Zd))},onShare:Ar&&(Vr||fr)?()=>{P(!1),Ln("share"),p(!0)}:void 0,otherFileAnnotations:en,onOtherFileAnnotationsClick:ke})]})}),Wa.popoutProps&&y.jsx(mgt,{...Wa.popoutProps,annotations:r.filter(Ke=>Ke.filePath===Wa.popoutProps?.filepath),selectedAnnotationId:s,onAddAnnotation:BM,onEditAnnotation:tb,onDeleteAnnotation:ak,onSelectAnnotation:Ke=>{o(null),l(Ke)}}),y.jsx(Ent,{isOpen:g,onClose:()=>{p(!1),Ln(void 0)},shareUrl:Vr,shareUrlSize:Kl,shortShareUrl:fr,isGeneratingShortUrl:yI,shortUrlError:Dm,onGenerateShortUrl:pM,annotationsOutput:Zd,annotationCount:sn.length+r.length,taterSprite:j?y.jsx(iY,{}):void 0,sharingEnabled:Ar,markdown:t,isApiMode:ee,initialTab:bn}),y.jsx(Int,{isOpen:m,onClose:()=>f(!1),onImport:mM,shareBaseUrl:pt}),y.jsx(Gb,{isOpen:b,onClose:()=>C(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Zc} will use your annotations to revise the plan.`,variant:"info"}),y.jsx(Gb,{isOpen:I,onClose:()=>B(!1),onConfirm:()=>{B(!1),vg()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:[Zc," doesn't yet support feedback on approval. Your ",sn.length+r.length," annotation",sn.length+r.length!==1?"s":""," will be lost."]}),subMessage:y.jsxs(y.Fragment,{children:["To send feedback, use ",y.jsx("strong",{children:"Send Feedback"})," instead.",y.jsx("br",{}),y.jsx("br",{}),"Want this feature? Upvote these issues:",y.jsx("br",{}),y.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",y.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}),y.jsx(Gb,{isOpen:Q,onClose:()=>k(!1),onConfirm:()=>{k(!1),_==="approve"?Xf():SI()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:["You have ",Zi," annotation",Zi!==1?"s":""," that will be lost if you ",_==="approve"?"approve":"close","."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:_==="approve"?"Approve Anyway":"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(Gb,{isOpen:x,onClose:()=>S(!1),onConfirm:()=>{S(!1),vg()},title:"Agent Not Found",message:L,subMessage:y.jsxs(y.Fragment,{children:["You can change the agent in ",y.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(Gb,{isOpen:!!ek&&!ee,onClose:wI,title:"Shared Plan Could Not Be Loaded",message:ek,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),y.jsx(FMe,{position:"top-right",offset:64,toastOptions:{style:{"--normal-bg":"var(--card)","--normal-border":"var(--border)","--normal-text":"var(--foreground)","--success-bg":"oklch(from var(--success) l c h / 0.15)","--success-border":"oklch(from var(--success) l c h / 0.3)","--success-text":"var(--success)","--error-bg":"oklch(from var(--destructive) l c h / 0.15)","--error-border":"oklch(from var(--destructive) l c h / 0.3)","--error-text":"var(--destructive)"}}}),y.jsx(Hrt,{submitted:We,title:ya.archiveMode?"Archive Closed":We==="exited"?"Session Closed":We==="approved"?He?"Approved":"Plan Approved":He?"Annotations Sent":"Feedback Sent",subtitle:We==="exited"?"Annotation session closed without feedback.":ya.archiveMode?"You can reopen with plannotator archive.":We==="approved"?He?`${Zc} will proceed.`:`${Zc} will proceed with the implementation.`:He?`${Zc} will address your annotations on the ${tt==="message"?"message":tt==="folder"?"files":"file"}.`:`${Zc} will revise the plan based on your annotations.`,agentLabel:Zc}),y.jsx(Wrt,{origin:ae,isWSL:ge}),y.jsx(Vpe,{isOpen:!!mt,imageSrc:mt?.blobUrl??"",initialName:mt?.initialName,onAccept:EM,onClose:IM}),y.jsx(dit,{isOpen:Oe,onComplete:Ke=>{Mt(Ke),Te(!1)}})]})})})},t0e=document.getElementById("root");if(!t0e)throw new Error("Could not find root element to mount to");const Cpt=sMe.createRoot(t0e);Cpt.render(y.jsx(qt.StrictMode,{children:y.jsx(bpt,{})}));class ns{constructor(e,n,a){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=n,this.end=a}static range(e,n){return n?!e||!e.loc||!n.loc||e.loc.lexer!==n.loc.lexer?null:new ns(e.loc.lexer,e.loc.start,n.loc.end):e&&e.loc}}class js{constructor(e,n){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=n}range(e,n){return new js(n,ns.range(this,e))}}class nn{constructor(e,n){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var a="KaTeX parse error: "+e,r,i,A=n&&n.loc;if(A&&A.start<=A.end){var o=A.lexer.input;r=A.start,i=A.end,r===o.length?a+=" at end of input: ":a+=" at position "+(r+1)+": ";var s=o.slice(r,i).replace(/[^]/g,"$&̲"),l;r>15?l="…"+o.slice(r-15,r):l=o.slice(0,r);var d;i+15<o.length?d=o.slice(i,i+15)+"…":d=o.slice(i),a+=l+s+d}var u=new Error(a);return u.name="ParseError",u.__proto__=nn.prototype,u.position=r,r!=null&&i!=null&&(u.length=i-r),u.rawMessage=e,u}}nn.prototype.__proto__=Error.prototype;var Ept=function(e,n){return e===void 0?n:e},Ipt=/([A-Z])/g,Bpt=function(e){return e.replace(Ipt,"-$1").toLowerCase()},ypt={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Qpt=/[&><"']/g;function wpt(t){return String(t).replace(Qpt,e=>ypt[e])}var n0e=function t(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?t(e.body[0]):e:e.type==="font"?t(e.body):e},kpt=function(e){var n=n0e(e);return n.type==="mathord"||n.type==="textord"||n.type==="atom"},vpt=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},Dpt=function(e){var n=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return n?n[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(n[1])?null:n[1].toLowerCase():"_relative"},tr={deflt:Ept,escape:wpt,hyphenate:Bpt,getBaseElem:n0e,isCharacterBox:kpt,protocolFromUrl:Dpt},kQ={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:t=>"#"+t},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:(t,e)=>(e.push(t),e)},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:t=>Math.max(0,t),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:t=>Math.max(0,t),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:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function xpt(t){if(t.default)return t.default;var e=t.type,n=Array.isArray(e)?e[0]:e;if(typeof n!="string")return n.enum[0];switch(n){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class DY{constructor(e){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,e=e||{};for(var n in kQ)if(kQ.hasOwnProperty(n)){var a=kQ[n];this[n]=e[n]!==void 0?a.processor?a.processor(e[n]):e[n]:xpt(a)}}reportNonstrict(e,n,a){var r=this.strict;if(typeof r=="function"&&(r=r(e,n,a)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new nn("LaTeX-incompatible input and strict mode is set to 'error': "+(n+" ["+e+"]"),a);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(n+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]"))}}useStrictBehavior(e,n,a){var r=this.strict;if(typeof r=="function")try{r=r(e,n,a)}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': "+(n+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]")),!1)}isTrusted(e){if(e.url&&!e.protocol){var n=tr.protocolFromUrl(e.url);if(n==null)return!1;e.protocol=n}var a=typeof this.trust=="function"?this.trust(e):this.trust;return!!a}}class $g{constructor(e,n,a){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=n,this.cramped=a}sup(){return ud[Spt[this.id]]}sub(){return ud[_pt[this.id]]}fracNum(){return ud[Rpt[this.id]]}fracDen(){return ud[Npt[this.id]]}cramp(){return ud[Mpt[this.id]]}text(){return ud[Fpt[this.id]]}isTight(){return this.size>=2}}var xY=0,E_=1,UC=2,Zu=3,Cw=4,_c=5,yE=6,So=7,ud=[new $g(xY,0,!1),new $g(E_,0,!0),new $g(UC,1,!1),new $g(Zu,1,!0),new $g(Cw,2,!1),new $g(_c,2,!0),new $g(yE,3,!1),new $g(So,3,!0)],Spt=[Cw,_c,Cw,_c,yE,So,yE,So],_pt=[_c,_c,_c,_c,So,So,So,So],Rpt=[UC,Zu,Cw,_c,yE,So,yE,So],Npt=[Zu,Zu,_c,_c,So,So,So,So],Mpt=[E_,E_,Zu,Zu,_c,_c,So,So],Fpt=[xY,E_,UC,Zu,UC,Zu,UC,Zu],Jn={DISPLAY:ud[xY],TEXT:ud[UC],SCRIPT:ud[Cw],SCRIPTSCRIPT:ud[yE]},ZP=[{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 Lpt(t){for(var e=0;e<ZP.length;e++)for(var n=ZP[e],a=0;a<n.blocks.length;a++){var r=n.blocks[a];if(t>=r[0]&&t<=r[1])return n.name}return null}var $x=[];ZP.forEach(t=>t.blocks.forEach(e=>$x.push(...e)));function a0e(t){for(var e=0;e<$x.length;e+=2)if(t>=$x[e]&&t<=$x[e+1])return!0;return!1}var Hb=80,Tpt=function(e,n){return"M95,"+(622+e+n)+`
1743
1743
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
1744
1744
  c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
1745
1745
  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