@pi-chamber/web 1.0.5-rc.2 → 1.0.5-rc.4
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/bin/lib/DOCUMENTATION.md +1 -1
- package/bin/lib/commands-status.js +3 -2
- package/bin/lib/commands-status.test.js +62 -0
- package/dist/assets/{DiagramView-BWG8peHt.js → DiagramView-CiAfS52a.js} +1 -1
- package/dist/assets/{DiffView-C_uRNQMT.js → DiffView-CEAAlJ4b.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-DlH8IWDL.js → FileSaveConflictDialog-yvhJRLj7.js} +1 -1
- package/dist/assets/{FilesView-RnF9JBPu.js → FilesView-DAEtByHZ.js} +1 -1
- package/dist/assets/{GitHubDetailScaffold-BTRvUnwh.js → GitHubDetailScaffold-CtFeWl_3.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-CGi8p2zF.js → GitHubLinkPicker-BEB6WkNO.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-XckcmdeA.js → GitHubListPrimitives-BilsEUSt.js} +1 -1
- package/dist/assets/{GitView-DyPJ8Oay.js → GitView-C19-aC7A.js} +3 -3
- package/dist/assets/{IssuesSurface-rQ78ziEu.js → IssuesSurface-zvICpciG.js} +2 -2
- package/dist/assets/{JsonTreeView-Cy5NKUzx.js → JsonTreeView-D99tzKTq.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-C5AlnAbG.js → MarkdownRendererImpl-CRfobHRu.js} +1 -1
- package/dist/assets/{PatchDiff-D6048My1.js → PatchDiff-Fbf3Mt_o.js} +1 -1
- package/dist/assets/{PierreDiffViewer-_000TWrM.js → PierreDiffViewer-C2nEOax_.js} +1 -1
- package/dist/assets/{PullRequestsSurface-eACi4Yxm.js → PullRequestsSurface-DMWgrwmP.js} +2 -2
- package/dist/assets/{SessionSwitcherContent-CFMjBIfH.js → SessionSwitcherContent-DByH7H41.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-CINW_ydZ.js → SessionSwitcherDropdown-D-kE5IJ_.js} +2 -2
- package/dist/assets/{SessionUnreadDot-YZJi4IFP.js → SessionUnreadDot-DNbvtMOd.js} +1 -1
- package/dist/assets/{SettingsView-DBiQXIji.js → SettingsView-BhXkRsZT.js} +4 -4
- package/dist/assets/{SettingsWindow-Wvd56oG1.js → SettingsWindow-B1_mMQyb.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DeDXQNWw.js → ToolOutputDialog-BO3d88qF.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-DuN8fldE.js → ToolPartDiffPreview-BgbLfmmd.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BYVjUxk9.js → VirtualizedFileDiff-D7kxYBDG.js} +1 -1
- package/dist/assets/{collapsible-BOcd0lzY.js → collapsible-9MJx4VhA.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-E4gJTgVF.js → computeVirtualFileMetrics-8pZIB8G2.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-CcGZtZsz.js → contextFileOpenGuard-BNtzRA7B.js} +1 -1
- package/dist/assets/{gitStatusPredicates-C2H7tf7t.js → gitStatusPredicates-B7adeDSu.js} +1 -1
- package/dist/assets/{githubLink-DTEEkgAl.js → githubLink-DVRaj2ms.js} +1 -1
- package/dist/assets/{index-BKc_DF05.js → index-B7HgGIB0.js} +1 -1
- package/dist/assets/{index-DsQIBAWK.css → index-BwoW_-vk.css} +1 -1
- package/dist/assets/{index-DWSrsQWl.js → index-D4n3TVp2.js} +2 -2
- package/dist/assets/{main-BNoO2jRw.js → main-BWWBkkNK.js} +4 -4
- package/dist/assets/{main-DnCR4Jva.js → main-C-nlfc4f.js} +2 -2
- package/dist/assets/{markdownCore-CP1hsIRw.js → markdownCore-B6YzRefV.js} +1 -1
- package/dist/assets/{miniChat-BBI_B4OS.js → miniChat-b8DbqBHL.js} +2 -2
- package/dist/assets/{mobile-dRWyYBgl.js → mobile-BDDUPrDt.js} +2 -2
- package/dist/assets/{nativeFileSave-CFuugNKV.js → nativeFileSave-BJsGPh58.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-Cw78V7mw.js → pi-session-focus-preference-gLalTsQo.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-kdzNWs8-.js → renderDiffWithHighlighter-BamhejwM.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-uVOQvccp.js → renderElectronMiniChatApp-CiWui-Wg.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-BdeYSXwS.js → renderFileWithHighlighter-CFlqKZg7.js} +1 -1
- package/dist/assets/{renderMobileApp-Cdg1IAhJ.js → renderMobileApp-C27Xb0G7.js} +3 -3
- package/dist/assets/{runtimeEndpointReset-thviM404.js → runtimeEndpointReset-O-OHpVl7.js} +6 -6
- package/dist/assets/{runtimeSurface-Der4qUnI.js → runtimeSurface-k1Eit61v.js} +1 -1
- package/dist/assets/{useAppFontEffects-Bd0btzjJ.js → useAppFontEffects-B6Bro-YP.js} +77 -77
- package/dist/assets/{useFilesViewSearch-Yvk43YOy.js → useFilesViewSearch-jAAdikwo.js} +1 -1
- package/dist/assets/{useGitHubRemoteSearch-BUjSEnXC.js → useGitHubRemoteSearch-BoCzq4zs.js} +1 -1
- package/dist/assets/{useSwitcherItems-D2opwbRZ.js → useSwitcherItems-C8IKoSTL.js} +1 -1
- package/dist/assets/{web-components-BeROQeen.js → web-components-DTteDmIQ.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/tailscale/DOCUMENTATION.md +34 -5
- package/server/lib/tailscale/public-dns.js +72 -0
- package/server/lib/tailscale/service.js +126 -3
- package/server/lib/tailscale/tailscale.test.js +318 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as c}from"./vendor-react-DASdDPIk.js";import{t as l,aV as W}from"./useAppFontEffects-
|
|
1
|
+
import{R as c}from"./vendor-react-DASdDPIk.js";import{t as l,aV as W}from"./useAppFontEffects-B6Bro-YP.js";import{K as D}from"./index-D4n3TVp2.js";const V=e=>{const t=u(e);if(!t)return"";if(t==="/"||/^[A-Za-z]:\/$/.test(t))return t;const s=t.lastIndexOf("/");if(s<0)return t;if(s===0)return"/";const n=t.slice(0,s);return/^[A-Za-z]:$/.test(n)?`${n}/`:n},v=e=>e.slice().sort((t,s)=>t.type!==s.type?t.type==="directory"?-1:1:t.name.localeCompare(s.name)),u=e=>{if(!e)return"";const t=e.replace(/\\/g,"/"),s=t.startsWith("//");let n=t.replace(/\/+/g,"/");s&&!n.startsWith("//")&&(n=`/${n}`);const i=n==="/",a=/^[A-Za-z]:\/$/.test(n);return!i&&!a&&(n=n.replace(/\/+$/,"")),n},M=e=>e.startsWith("/")||e.startsWith("//")||/^[A-Za-z]:\//.test(e),y=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,S=(e,t)=>{const s=u(t),n=u(e);if(!s||!n)return!1;const i=y(s),a=y(n);return a===i||a.startsWith(`${i}/`)},N=(e,t)=>{const s=u(t),n=u(e);if(!S(n,s))return[];const a=n.slice(s.length).replace(/^\//,"").split("/"),w=[];let r=s;for(let d=0;d<a.length-1;d++)r=r?`${r}/${a[d]}`:a[d],w.push(r);return w},Z=(e,t)=>{if(!t)return"";const s=u(t);if(!e||!S(s,e))return s;const n=s.slice(e.length);return n.startsWith("/")?n.slice(1):n},x=new Set(["node_modules"]),q=e=>x.has(e),L=e=>{const t=u(e);return t==="node_modules"||t.endsWith("/node_modules")||t.includes("/node_modules/")},B=e=>{const s=(e instanceof Error?e.message:String(e??"")).toLowerCase();return s.includes("is a directory")||s.includes("eisdir")},H=e=>{const s=(e instanceof Error?e.message:String(e??"")).toLowerCase();return s.includes("file not found")||s.includes("enoent")||s.includes("no such file")||s.includes("does not exist")},O=2e5,U=e=>{let t=0,s=0;for(let n=0;n<e.length;n+=1)e.charCodeAt(n)===10&&(n>0&&e.charCodeAt(n-1)===13?t+=1:s+=1);return t>s?`\r
|
|
2
2
|
`:`
|
|
3
3
|
`},_=e=>e.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as e,bV as Ne,bW as Ce,bX as ke,bY as Se,bZ as Re,aL as He}from"./vendor-boot-EC6IyLt1.js";import{R as d}from"./vendor-react-DASdDPIk.js";import{e as L,n as Ge,m as Le}from"./index-DWSrsQWl.js";import{B as N,I as H,ao as Pe,t as U,cJ as Me,cK as Ee,cL as De,cM as Fe,cN as Te,z as ze,A,by as $e,a as Ie,bM as Be,bL as te,cV as Ae,ai as le,al as ce,an as ue,aq as _e,cW as X,as as Ke,cH as de,cI as me,cX as Oe,cY as qe,cZ as We}from"./useAppFontEffects-Bd0btzjJ.js";import{am as ne,_ as Ve,an as Ye,ao as Ue}from"./runtimeEndpointReset-thviM404.js";import{a as Xe,G as he,c as Qe,d as Ze,e as Je,f as es,b as ss,g as ts,h as ns,i as rs}from"./GitHubListPrimitives-XckcmdeA.js";import{c as as}from"./vendor-zustand-CUi8eEds.js";import{K as fe,C as is,D as os}from"./GitHubDetailScaffold-BTRvUnwh.js";const pe=s=>s?s.kind==="rate-limited"?{reason:"rate-limited",retryAt:s.retryAt??null}:s.kind==="failed"?{reason:"failed",message:s.message}:{reason:s.reason,scopes:s.scopes??[]}:{reason:"failed",message:"GitHub request failed"},_=({command:s,label:t})=>{const i=d.useCallback(()=>{Pe(s).then(a=>{U[a.ok?"success":"error"](a.ok?"Command copied":"Failed to copy command")}).catch(()=>U.error("Failed to copy command"))},[s]);return e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5",children:[e.jsx("code",{className:"min-w-0 truncate rounded bg-[var(--surface-muted)] px-1.5 py-0.5 font-mono typography-micro text-foreground",children:s}),e.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-interactive-hover hover:text-foreground",title:t??`Copy ${s}`,"aria-label":t??`Copy ${s}`,children:e.jsx(H,{name:"file-copy",className:"size-3.5"})})]})},k=({icon:s,title:t,description:i,children:a})=>e.jsx(Xe,{icon:s,title:t,description:i,action:a?e.jsx("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:a}):void 0}),D=({info:s,onRetry:t,isRetrying:i})=>{const a=t?e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:i,children:[e.jsx(H,{name:"refresh",className:"size-3.5"}),i?"Checking…":"Check again"]}):null;switch(s.reason){case"gh-missing":return e.jsxs(k,{icon:"github-fill",title:"GitHub CLI not found",description:"Install the GitHub CLI on the machine running PiChamber to browse pull requests and issues.",children:[e.jsx(_,{command:"gh --version",label:"Copy gh version check"}),a]});case"gh-outdated":return e.jsxs(k,{icon:"github-fill",title:"GitHub CLI too old",description:"Update gh on the machine running PiChamber, then check again.",children:[e.jsx(_,{command:"gh upgrade",label:"Copy gh upgrade command"}),a]});case"gh-unauthenticated":return e.jsxs(k,{icon:"github-fill",title:"Not signed in",description:"Run gh auth login on the machine running PiChamber, then check again.",children:[e.jsx(_,{command:"gh auth login",label:"Copy gh auth login command"}),a]});case"not-github":return e.jsx(k,{icon:"git-repository",title:"Not a GitHub repository",description:"This directory is a git repository, but none of its remotes point at GitHub."});case"no-repository":return e.jsx(k,{icon:"git-repository",title:"No repository here",description:"Open a directory inside a git repository to browse pull requests and issues."});case"no-access":return e.jsx(k,{icon:"lock",title:"No access",description:"The signed-in GitHub account cannot access this repository. Check the remote and the account in Settings.",children:a});case"scope-missing":{const r=(s.scopes??[]).filter(Boolean),n=r.length>0?`gh auth refresh -s ${r.join(" ")}`:"gh auth refresh -s repo";return e.jsxs(k,{icon:"shield-keyhole",title:"Missing token scope",description:`The GitHub token needs ${r.length>0?r.join(", "):"more scope"}. Run this on the machine running PiChamber, then check again.`,children:[e.jsx(_,{command:n,label:"Copy gh auth refresh command"}),a]})}case"rate-limited":{const r=s.retryAt?new Date(s.retryAt).toLocaleTimeString():null;return e.jsx(k,{icon:"hourglass",title:"Rate limited",description:r?`GitHub rate limit reached. Try again after ${r}.`:"GitHub rate limit reached. Try again shortly.",children:a})}default:return e.jsx(k,{icon:"error-warning",title:"Something went wrong",description:s.message||"GitHub request failed",children:a})}},ls=s=>s.map(t=>({host:t.host,owner:t.owner,repo:t.repo,relativePath:t.relativePath,kind:t.kind,submodule:t.submodule,disabledReason:t.disabledReason??null,ref:t.host&&t.owner&&t.repo?`${t.host}/${t.owner}/${t.repo}`:""})),cs=s=>s.kind==="enclosing"?"enclosing":s.kind==="nested"?"nested":s.submodule?"submodule":null,re=({entries:s,value:t,onChange:i,ariaLabel:a})=>{const r=s.find(n=>n.ref===t)??null;return e.jsxs(Me,{value:t??"",onValueChange:i,children:[e.jsx(Ee,{size:"sm",className:"min-w-0 max-w-56","aria-label":a??"Select repository",children:e.jsx(De,{placeholder:"Select repository",children:n=>{const o=s.find(l=>l.ref===n)??r;return!o||!o.ref?"Select repository":e.jsxs("span",{className:"block truncate",children:[o.relativePath," · ",o.owner,"/",o.repo]})}})}),e.jsx(Fe,{children:s.map(n=>{const o=!n.ref||!!n.disabledReason,l=cs(n);return e.jsx(Te,{value:n.ref,disabled:o,children:e.jsxs("span",{className:L("flex min-w-0 items-center gap-1.5",o&&"opacity-60"),children:[e.jsx(H,{name:"git-repository",className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 truncate",children:[n.relativePath," · ",n.owner&&n.repo?`${n.owner}/${n.repo}`:"not on GitHub"]}),l?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:l}):null,n.disabledReason?e.jsxs("span",{className:"shrink-0 typography-micro text-muted-foreground",children:["· ",n.disabledReason]}):null]})},`${n.ref||n.relativePath}:${n.relativePath}`)})})]})},Gs=({directory:s,isRefreshing:t,onRefresh:i,children:a})=>{const n=ze().github??null,o=A(p=>p.entriesByDirectory[Ge(s.trim())]??null),l=A(p=>p.ensureScope),c=A(p=>p.refreshScope),u=A(p=>p.setSelectedRepo),m=$e(s||null),h=ne(p=>p.status),g=ne(p=>p.refresh);d.useEffect(()=>{!s||!n||(l(s,n),g(n))},[s,n,l,g]);const C=d.useCallback(()=>{if(i){i();return}n&&(c(s,n,{force:!0}),g(n,{force:!0}))},[i,n,c,g,s]);if(!n)return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})});if(o?.isLoading&&!o.scope&&!o.error)return e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsx(he,{label:"Finding GitHub repositories"})});if(o?.error&&!o.scope)return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:pe(o.error),onRetry:C,isRetrying:t||o.isLoading})});const j=o?.scope??null;if(j&&!h?.installed)return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:{reason:"gh-missing"},onRetry:C,isRetrying:t})});const x=j?ls(j.repositories):[],f=x.filter(p=>!!(p.ref&&!p.disabledReason));if(j&&f.length===0){const p=j.topLevel?"not-github":"no-repository";return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:{reason:p}})})}if(!m)return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:e.jsx(re,{entries:x,value:m,onChange:p=>u(s,p)})}),e.jsxs("div",{className:"flex flex-col items-start gap-2 p-4",children:[e.jsx("div",{className:"typography-ui-header text-foreground",children:"Select a repository"}),e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Several repositories are in scope. Pick one to browse."})]})]});const b=f.length>1;return e.jsxs("div",{className:"flex h-full flex-col",children:[b?e.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:e.jsx(re,{entries:x,value:m,onChange:p=>u(s,p)})}):null,e.jsx("div",{className:"min-h-0 flex-1",children:a({repo:m,directory:s})})]})},Ls=({copy:s,busy:t,destructive:i,disabled:a,disabledReason:r,label:n,variant:o="default",icon:l,onConfirm:c})=>{const[u,m]=d.useState(!1);return e.jsxs(Ne,{open:u,onOpenChange:h=>{t||m(h)},children:[e.jsxs(Ce,{render:e.jsx(N,{type:"button",variant:o,size:"xs",className:"shrink-0",disabled:a||t,title:r??n,"aria-label":n}),children:[l,n]}),e.jsx(ke,{children:e.jsx(Se,{side:"bottom",align:"start",sideOffset:6,collisionPadding:8,className:"z-50",children:e.jsxs(Re,{"aria-label":s.title,className:"w-64 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsx("p",{className:"typography-ui-label text-foreground",children:s.title}),e.jsx("p",{className:"mt-1 typography-micro text-muted-foreground",children:s.detail}),e.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[e.jsx(N,{type:"button",variant:"outline",size:"xs",disabled:t,onClick:()=>m(!1),children:"Cancel"}),e.jsx(N,{type:"button",variant:i?"destructive":"default",size:"xs",disabled:t,onClick:()=>{Promise.resolve(c()).finally(()=>m(!1))},"aria-label":s.confirm,children:t?s.progress:s.confirm})]})]})})})]})},Ps=async(s,t)=>{if(!t?.listGitWorktrees)return;const i=Ie.getState().projects,a=Be(i,te.getState()),n=Ae(i,a,s)?.path??s;try{await te.getState().refreshProject(n,t,{force:!0})}catch{}},y=(s,t)=>`${s}#${t}`,xe=Object.freeze([]),us=Object.freeze({comments:xe,summary:"",verdict:"comment",commentDraft:""});let ae=0;const ds=()=>(ae+=1,`pending-review-comment-${ae}`),R=(s,t)=>s.entries[t]??us,S=(s,t,i)=>({...s.entries,[t]:{...R(s,t),...i}}),P=as()((s,t)=>({entries:{},addComment:(i,a,r)=>{const n=r.id??ds(),o=y(i,a);return s(l=>({entries:S(l,o,{comments:[...R(l,o).comments,{...r,id:n}]})})),n},removeComment:(i,a,r)=>{const n=y(i,a);s(o=>{const l=R(o,n).comments,c=l.filter(u=>u.id!==r);if(c.length===l.length)return o;if(c.length===0&&R(o,n).summary===""&&R(o,n).commentDraft===""){const u={...o.entries};return delete u[n],{entries:u}}return{entries:S(o,n,{comments:c})}})},removeComments:(i,a,r)=>{if(r.length===0)return;const n=y(i,a),o=new Set(r);s(l=>{const c=R(l,n).comments,u=c.filter(m=>!o.has(m.id));return u.length===c.length?l:{entries:S(l,n,{comments:u})}})},clearComments:(i,a)=>{const r=y(i,a);s(n=>(n.entries[r]?.comments.length??0)===0?n:{entries:S(n,r,{comments:[]})})},setSummary:(i,a,r)=>{const n=y(i,a);t().entries[n]?.summary!==r&&s(o=>({entries:S(o,n,{summary:r})}))},clearSummary:(i,a,r)=>{const n=y(i,a);s(o=>R(o,n).summary!==r?o:{entries:S(o,n,{summary:""})})},setVerdict:(i,a,r)=>{const n=y(i,a);t().entries[n]?.verdict!==r&&s(o=>({entries:S(o,n,{verdict:r})}))},setCommentDraft:(i,a,r)=>{const n=y(i,a);t().entries[n]?.commentDraft!==r&&s(o=>({entries:S(o,n,{commentDraft:r})}))},clearCommentDraft:(i,a)=>{const r=y(i,a);s(n=>R(n,r).commentDraft===""?n:{entries:S(n,r,{commentDraft:""})})},resetForRuntimeSwitch:()=>s({entries:{}})}));typeof window<"u"&&Le(()=>{P.getState().resetForRuntimeSwitch()});const Ms=(s,t)=>P(i=>i.entries[y(s,t)]?.comments??xe),Es=(s,t)=>P(i=>i.entries[y(s,t)]?.summary??""),Ds=(s,t)=>P(i=>i.entries[y(s,t)]?.verdict??"comment"),Fs=(s,t)=>P(i=>i.entries[y(s,t)]?.comments.length??0),ms=300,Ts=(s,t)=>{const i=y(s,t),a=P(h=>h.entries[i]?.commentDraft??""),[r,n]=d.useState(a),o=d.useRef(r);o.current=r;const l=d.useRef(a);l.current=a;const c=d.useRef(a);d.useEffect(()=>{o.current===c.current&&a!==c.current&&(c.current=a,n(a))},[a]);const u=d.useCallback(()=>{const h=o.current;h!==c.current&&(c.current=h,P.getState().setCommentDraft(s,t,h))},[s,t]),m=d.useCallback(h=>{n(h)},[]);return d.useEffect(()=>{if(r===c.current)return;const h=setTimeout(u,ms);return()=>clearTimeout(h)},[r,u]),d.useEffect(()=>()=>u(),[u]),{draft:r,onDraftChange:m,flushDraft:u}},hs=240,zs=({draft:s,onDraftChange:t,placeholder:i="Leave a comment",ariaLabel:a="Leave a comment",busy:r,error:n,disabledReason:o,followUp:l,onSubmitComment:c,onDraftBlur:u})=>{const m=d.useRef(null),[h,g]=d.useState(!1),C=d.useRef(null);d.useLayoutEffect(()=>{const f=m.current;if(!f)return;f.style.height="0px",f.style.height=`${Math.min(f.scrollHeight,hs)}px`;let b=C.current;if(!b){const w=getComputedStyle(f);b={lineHeight:Number.parseFloat(w.lineHeight)||20,padding:Number.parseFloat(w.paddingTop)+Number.parseFloat(w.paddingBottom)||0},C.current=b}const p=f.scrollHeight-b.padding>b.lineHeight*1.5;g(w=>w===p?w:p)},[s]);const j=s.trim().length===0,x=r!==null;return e.jsxs("form",{className:"flex flex-col gap-2 border-t border-border/60 pt-5","aria-label":a,onSubmit:f=>{f.preventDefault(),c()},children:[e.jsxs("div",{className:`flex ${h?"items-end":"items-center"} gap-1.5 rounded-md border border-border bg-[var(--surface-elevated)] py-1 pr-1 focus-within:border-[var(--interactive-focus-ring)]`,children:[e.jsx(Ve,{simple:!0,ref:m,rows:1,value:s,placeholder:`${i} (⌘↩)`,"aria-label":a,disabled:x,onChange:f=>t(f.target.value),onBlur:()=>u?.(),outerClassName:"min-w-0 flex-1",className:"min-h-0 w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 py-1 typography-ui text-foreground shadow-none outline-none placeholder:text-muted-foreground focus-visible:ring-0",onKeyDown:f=>{f.nativeEvent.isComposing||f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&!f.shiftKey&&!f.altKey&&!f.repeat&&(f.preventDefault(),f.stopPropagation(),!j&&!x&&c())}}),!j&&l&&l.allowed?e.jsx(N,{type:"button",variant:"ghost",size:"xs",disabled:x,title:l.reason??l.label,onClick:l.onRun,children:r===l.id?l.busyLabel:l.label}):null,e.jsx(N,{type:"button",variant:"default",size:"xs",disabled:j||x,title:o??"Post comment",onClick:c,children:r==="comment"?"Posting…":"Comment"})]}),n?e.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:n}):null]})},fs=async s=>{const t=s.notify??((r,n)=>U[r](n)),i=await s.postComment(s.trimmed);if(!i.ok){const r=i.error?.kind==="failed"&&i.error.message?i.error.message:"Failed to post comment";throw t("error",r),new Error(r)}if(s.afterPost(),s.action==="comment"){t("success","Comment posted");return}const a=await s.runFollowUp(s.action);if(!a.ok){const r=s.verbs[s.action],n=a.error?.kind==="failed"&&a.error.message?a.error.message:`Failed to ${r}`;throw t("error",n),new Error(n)}t("success",s.doneLabels[s.action])},$s=s=>{const[t,i]=d.useState(null),[a,r]=d.useState(null),n=d.useRef(s);n.current=s;const o=d.useCallback(async(l,c)=>{const u=c.trim(),m=n.current;if(!(u.length===0||t!==null)){i(l),r(null);try{await fs({trimmed:u,action:l,postComment:m.postComment,runFollowUp:m.runFollowUp,verbs:m.verbs,doneLabels:m.doneLabels,afterPost:m.afterPost})}catch(h){r(h instanceof Error?h.message:"Failed to post comment")}finally{i(null)}}},[t]);return{busy:t,error:a,submit:o}},ie=({label:s,value:t,options:i,currentLabel:a,onChange:r})=>e.jsxs(Oe,{children:[e.jsxs(qe,{children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx("span",{className:"min-w-0 max-w-32 truncate typography-micro text-muted-foreground",children:a})]}),e.jsx(We,{className:"min-w-48",children:e.jsxs(de,{value:t,onValueChange:n=>{typeof n=="string"&&n!==t&&r(n)},children:[e.jsx(X,{children:s}),i.map(n=>e.jsx(me,{value:n.id,closeOnClick:!1,children:n.label},n.id))]})})]}),ps=({stateValue:s,stateOptions:t,onStateChange:i,involvementValue:a,involvementOptions:r,onInvolvementChange:n,labelsValue:o,onLabelsChange:l})=>{const c=t.find(g=>g.id===s)?.label??s,u=r.find(g=>g.id===a)?.label??a,m=(o??"").trim().length>0,h=(s!==t[0]?.id?1:0)+(a!==r[0]?.id?1:0)+(m?1:0);return e.jsxs(le,{modal:!1,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(N,{type:"button",variant:"ghost",size:"sm","aria-label":"Filters",title:"Filters",className:"h-8 shrink-0 gap-1.5 px-2 normal-case",children:[e.jsx(H,{name:"equalizer",className:"size-4","aria-hidden":"true"}),e.jsx("span",{children:"Filters"}),h>0?e.jsx("span",{className:"rounded-full bg-[var(--surface-muted)] px-1.5 typography-micro tabular-nums text-muted-foreground",children:h}):null]})}),e.jsxs(ue,{align:"end",className:"w-64",children:[e.jsx(ie,{label:"State",value:s,options:t,currentLabel:c,onChange:i}),e.jsx(ie,{label:"Involvement",value:a,options:r,currentLabel:u,onChange:n}),l?e.jsxs(e.Fragment,{children:[e.jsx(_e,{}),e.jsx(X,{children:"Labels"}),e.jsxs("div",{className:"px-2 pb-2",children:[e.jsx(Ke,{value:o??"",onChange:g=>l(g.target.value),placeholder:"bug, enhancement","aria-label":"Filter by labels",className:"h-7"}),e.jsx("p",{className:"mt-1 typography-micro text-muted-foreground",children:"Comma-separated. Or type label:bug in search."})]})]}):null]})]})},xs=({value:s,options:t,onChange:i,ariaLabel:a})=>e.jsxs(le,{modal:!1,children:[e.jsx(ce,{asChild:!0,children:e.jsx(N,{type:"button",variant:"ghost",size:"sm","aria-label":a,title:a,className:"h-8 w-8 shrink-0 p-0",children:e.jsx(H,{name:"expand-up-down",className:"size-4","aria-hidden":"true"})})}),e.jsx(ue,{align:"end",className:"w-52",children:e.jsxs(de,{value:s,onValueChange:r=>{typeof r=="string"&&r!==s&&i(r)},children:[e.jsx(X,{children:"Sort"}),t.map(r=>e.jsx(me,{value:r.id,children:r.label},r.id))]})})]}),oe=({isRefreshing:s,onRefresh:t,label:i,presentation:a="toolbar"})=>a==="desktop"?e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:s,title:i??"Refresh","aria-label":i??"Refresh GitHub data",className:"h-8 w-8 shrink-0 p-0",children:e.jsx(H,{name:"refresh",className:L("size-4",s&&"animate-spin"),"aria-hidden":"true"})}):a==="drawer"?e.jsx(N,{type:"button",variant:"ghost",size:"icon",onClick:t,disabled:s,title:i??"Refresh","aria-label":i??"Refresh GitHub data",className:"shrink-0",children:e.jsx(H,{name:"refresh",className:L("size-4",s&&"animate-spin"),"aria-hidden":"true"})}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:s,title:i??"Refresh","aria-label":i??"Refresh GitHub data",className:"h-8 w-8 shrink-0 p-0",children:e.jsx(H,{name:"refresh",className:L("size-4",s&&"animate-spin"),"aria-hidden":"true"})}),Is=({items:s,renderRow:t,hasMore:i,isLoadingMore:a,isLoading:r,isRefreshing:n,stale:o,error:l,searchValue:c,onSearchChange:u,searchPlaceholder:m,searchAriaLabel:h,toolbarControls:g,primaryAction:C,headerActionsSlot:j=null,headerActionsPresentation:x="drawer",isDefaultFilters:f,stateLabel:b,kindSingular:p,kindPlural:w,noItemsTitle:F,noItemsBody:M,noItemsIcon:K,noItemsAction:Q,listAriaLabel:E,skeletonLabel:ge,updatedAtOf:O,countComplete:q=!0,incompleteNotice:T=null,remote:v=null,numberJump:z=null,numberJumpKind:be,onClearFilters:je,onLoadMore:ye,onRetry:$,onOpen:we})=>{const Z=d.useMemo(()=>{if(s.length===0)return null;const G=s.length===1&&q?`1 ${p}`:`${s.length}${q?"":"+"} ${w}`;let B=0;for(const se of s){const Y=O(se)?Date.parse(O(se)):NaN;Number.isFinite(Y)&&Y>B&&(B=Y)}const ee=B>0?fe(new Date(B).toISOString()):"";return`${G} · ${b.toLowerCase()}${ee?` · updated ${ee}`:""}`},[s,b,p,w,q,O]),I=!!l&&s.length===0,W=!I&&r&&s.length===0,V=j??null,ve=x??"drawer",J=n||r;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o?e.jsx(Qe,{onRetry:$}):null,e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-3 py-2",children:[e.jsx(Ze,{value:c,onChange:u,placeholder:m,ariaLabel:h}),g,V?null:e.jsxs(e.Fragment,{children:[C,e.jsx(oe,{isRefreshing:J,onRefresh:$,presentation:"toolbar"})]})]}),V?He.createPortal(e.jsxs(e.Fragment,{children:[C,e.jsx(oe,{isRefreshing:J,onRefresh:$,presentation:ve})]}),V):null,I?e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(D,{info:pe(l),onRetry:$,isRetrying:r})}):W?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(he,{label:ge})}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",role:"list","aria-label":E,children:[s.length===0&&z==null?e.jsx(Je,{kind:f?"no-items":"no-match",noItemsTitle:F,noItemsBody:f?M:void 0,noItemsIcon:K,noItemsAction:f?Q:void 0,onClearFilters:f?void 0:je}):e.jsxs(e.Fragment,{children:[s.length>0?e.jsx("ul",{className:"flex flex-col p-1",children:s.map(G=>e.jsx(d.Fragment,{children:t(G)},G.number))}):null,z!=null?e.jsx(es,{number:z,kindLabel:be,onOpen:()=>we(z)}):null]}),e.jsx(ss,{hasMore:i,isLoading:a||r,onLoadMore:ye}),v&&(v.isSearching||v.error||v.items.length>0)?e.jsx(ts,{title:"More results from GitHub",isSearching:v.isSearching,error:v.error,hasResults:v.items.length>0,hasMore:v.hasMore,isLoadingMore:v.isLoadingMore,onRetry:v.onRetry,onLoadMore:v.onLoadMore,children:e.jsx("ul",{className:"flex flex-col",children:v.items.map(G=>e.jsx(d.Fragment,{children:t(G)},G.number))})}):null]}),!I&&!W&&T?e.jsx(ns,{matchSummary:T.summary,searching:T.searching,onSearchAll:T.onSearchAll}):null,!I&&!W&&Z?e.jsx(rs,{summary:Z}):null]})},Bs=({stateValue:s,stateOptions:t,onStateChange:i,involvementValue:a,involvementOptions:r,onInvolvementChange:n,labelsValue:o,onLabelsChange:l,sortValue:c,sortOptions:u,onSortChange:m,sortAriaLabel:h})=>e.jsxs(e.Fragment,{children:[e.jsx(ps,{stateValue:s,stateOptions:t,onStateChange:i,involvementValue:a,involvementOptions:r,onInvolvementChange:n,labelsValue:o,onLabelsChange:l}),e.jsx(xs,{value:c,options:u,onChange:m,ariaLabel:h})]}),gs="shrink-0 font-mono typography-micro tabular-nums text-muted-foreground",bs=({glyph:s,below:t})=>e.jsxs("span",{className:"flex w-4 shrink-0 flex-col items-center gap-0.5",children:[e.jsx("span",{className:"inline-flex",children:s}),t?e.jsx("span",{className:"inline-flex",children:t}):null]}),As=({login:s,avatarUrl:t})=>e.jsxs("span",{className:"inline-flex min-w-0 shrink-0 items-center gap-1",title:s??"ghost",children:[e.jsx(is,{login:s,avatarUrl:t,size:"xs"}),e.jsx("span",{className:"truncate",children:s??"ghost"})]}),_s=({head:s,base:t})=>e.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:s,children:s}),e.jsx("span",{className:"shrink-0",children:"→"}),e.jsx("span",{className:"max-w-[45%] shrink-0 truncate",title:t,children:t})]}),js=[{show:""},{show:"hidden @xl/github-row:inline-flex"},{show:"hidden @3xl/github-row:inline-flex"}],ys=["hidden @xl/github-row:hidden","hidden @xl/github-row:inline-flex @3xl/github-row:hidden",""],Ks=({labels:s})=>s.length===0?null:e.jsx("span",{className:"flex min-w-0 shrink-0 items-center gap-1",children:js.map((t,i)=>{const a=s[i];if(!a)return null;const r=s.length-i-1;return e.jsxs("span",{className:L("min-w-0",t.show),children:[e.jsx(os,{name:a.name,color:a.color}),r>0?e.jsxs("span",{className:L("ml-0.5 shrink-0",ys[i]),"aria-label":`${r} more labels`,children:["+",r]}):null]},a.name)})}),Os=({glyph:s,glyphBelow:t,number:i,title:a,signals:r,status:n,meta:o,updatedAt:l,selected:c,onOpen:u,ariaLabel:m})=>e.jsxs("button",{type:"button",onClick:u,"aria-label":m,"aria-current":c?"true":void 0,className:L("@container/github-row group/github-row flex w-full items-center gap-2 rounded-md px-2 py-1 text-left",c?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:[e.jsx(bs,{glyph:s,below:t}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:gs,children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:a,children:a}),r?e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:r}):null,n?e.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:n}):null]}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 overflow-hidden typography-micro text-muted-foreground",children:[o,l?e.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap tabular-nums",children:fe(l)}):null]})]})]}),qs=s=>{const{repo:t,query:i,queryKey:a,autoRemote:r,indexNumbers:n,visibleItems:o,searchText:l,useRemoteEntry:c,runSearch:u,runLoadMore:m}=s,[h,g]=d.useState(!1),[C,j]=d.useState(null);d.useEffect(()=>j(null),[t]);const x=c(t,i),f=r||C===a||x!=null,b=d.useCallback(()=>{g(!0),u(i).catch(()=>null).finally(()=>g(!1))},[i,u]);d.useEffect(()=>{if(!r||x?.data||x?.isLoading||x?.error||h)return;const E=setTimeout(b,400);return()=>clearTimeout(E)},[r,a,x?.data,x?.isLoading,x?.error,h,b]);const p=d.useCallback(()=>{j(a),b()},[a,b]),w=d.useCallback(()=>{g(!0),m(i).catch(()=>null).finally(()=>g(!1))},[i,m]),F=d.useMemo(()=>Ye(x?.data?.items??[],n),[x?.data?.items,n]),M=Ue(l),K=M!=null&&!o.some(E=>E.number===M)?M:null;return{remoteView:d.useMemo(()=>f?{items:F,isSearching:h||(x?.isLoading??!1),isLoadingMore:h,hasMore:x?.data?.nextCursor!=null,error:x?.error??null,onSearchAll:p,onLoadMore:w,onRetry:b}:null,[f,F,h,x?.isLoading,x?.data?.nextCursor,x?.error,p,w,b]),numberJump:K,remotePending:h,handleSearchAll:p}};export{zs as G,Ms as a,Ts as b,$s as c,Es as d,Ds as e,Fs as f,D as g,Ls as h,Os as i,As as j,_s as k,Is as l,Bs as m,Gs as n,qs as o,Ks as p,Ps as r,pe as t,P as u};
|
|
1
|
+
import{k as e,bV as Ne,bW as Ce,bX as ke,bY as Se,bZ as Re,aL as He}from"./vendor-boot-EC6IyLt1.js";import{R as d}from"./vendor-react-DASdDPIk.js";import{e as L,n as Ge,m as Le}from"./index-D4n3TVp2.js";import{B as N,I as H,ao as Pe,t as U,cJ as Me,cK as Ee,cL as De,cM as Fe,cN as Te,z as ze,A,by as $e,a as Ie,bM as Be,bL as te,cV as Ae,ai as le,al as ce,an as ue,aq as _e,cW as X,as as Ke,cH as de,cI as me,cX as Oe,cY as qe,cZ as We}from"./useAppFontEffects-B6Bro-YP.js";import{am as ne,_ as Ve,an as Ye,ao as Ue}from"./runtimeEndpointReset-O-OHpVl7.js";import{a as Xe,G as he,c as Qe,d as Ze,e as Je,f as es,b as ss,g as ts,h as ns,i as rs}from"./GitHubListPrimitives-BilsEUSt.js";import{c as as}from"./vendor-zustand-CUi8eEds.js";import{K as fe,C as is,D as os}from"./GitHubDetailScaffold-CtFeWl_3.js";const pe=s=>s?s.kind==="rate-limited"?{reason:"rate-limited",retryAt:s.retryAt??null}:s.kind==="failed"?{reason:"failed",message:s.message}:{reason:s.reason,scopes:s.scopes??[]}:{reason:"failed",message:"GitHub request failed"},_=({command:s,label:t})=>{const i=d.useCallback(()=>{Pe(s).then(a=>{U[a.ok?"success":"error"](a.ok?"Command copied":"Failed to copy command")}).catch(()=>U.error("Failed to copy command"))},[s]);return e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5",children:[e.jsx("code",{className:"min-w-0 truncate rounded bg-[var(--surface-muted)] px-1.5 py-0.5 font-mono typography-micro text-foreground",children:s}),e.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-interactive-hover hover:text-foreground",title:t??`Copy ${s}`,"aria-label":t??`Copy ${s}`,children:e.jsx(H,{name:"file-copy",className:"size-3.5"})})]})},k=({icon:s,title:t,description:i,children:a})=>e.jsx(Xe,{icon:s,title:t,description:i,action:a?e.jsx("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:a}):void 0}),D=({info:s,onRetry:t,isRetrying:i})=>{const a=t?e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:i,children:[e.jsx(H,{name:"refresh",className:"size-3.5"}),i?"Checking…":"Check again"]}):null;switch(s.reason){case"gh-missing":return e.jsxs(k,{icon:"github-fill",title:"GitHub CLI not found",description:"Install the GitHub CLI on the machine running PiChamber to browse pull requests and issues.",children:[e.jsx(_,{command:"gh --version",label:"Copy gh version check"}),a]});case"gh-outdated":return e.jsxs(k,{icon:"github-fill",title:"GitHub CLI too old",description:"Update gh on the machine running PiChamber, then check again.",children:[e.jsx(_,{command:"gh upgrade",label:"Copy gh upgrade command"}),a]});case"gh-unauthenticated":return e.jsxs(k,{icon:"github-fill",title:"Not signed in",description:"Run gh auth login on the machine running PiChamber, then check again.",children:[e.jsx(_,{command:"gh auth login",label:"Copy gh auth login command"}),a]});case"not-github":return e.jsx(k,{icon:"git-repository",title:"Not a GitHub repository",description:"This directory is a git repository, but none of its remotes point at GitHub."});case"no-repository":return e.jsx(k,{icon:"git-repository",title:"No repository here",description:"Open a directory inside a git repository to browse pull requests and issues."});case"no-access":return e.jsx(k,{icon:"lock",title:"No access",description:"The signed-in GitHub account cannot access this repository. Check the remote and the account in Settings.",children:a});case"scope-missing":{const r=(s.scopes??[]).filter(Boolean),n=r.length>0?`gh auth refresh -s ${r.join(" ")}`:"gh auth refresh -s repo";return e.jsxs(k,{icon:"shield-keyhole",title:"Missing token scope",description:`The GitHub token needs ${r.length>0?r.join(", "):"more scope"}. Run this on the machine running PiChamber, then check again.`,children:[e.jsx(_,{command:n,label:"Copy gh auth refresh command"}),a]})}case"rate-limited":{const r=s.retryAt?new Date(s.retryAt).toLocaleTimeString():null;return e.jsx(k,{icon:"hourglass",title:"Rate limited",description:r?`GitHub rate limit reached. Try again after ${r}.`:"GitHub rate limit reached. Try again shortly.",children:a})}default:return e.jsx(k,{icon:"error-warning",title:"Something went wrong",description:s.message||"GitHub request failed",children:a})}},ls=s=>s.map(t=>({host:t.host,owner:t.owner,repo:t.repo,relativePath:t.relativePath,kind:t.kind,submodule:t.submodule,disabledReason:t.disabledReason??null,ref:t.host&&t.owner&&t.repo?`${t.host}/${t.owner}/${t.repo}`:""})),cs=s=>s.kind==="enclosing"?"enclosing":s.kind==="nested"?"nested":s.submodule?"submodule":null,re=({entries:s,value:t,onChange:i,ariaLabel:a})=>{const r=s.find(n=>n.ref===t)??null;return e.jsxs(Me,{value:t??"",onValueChange:i,children:[e.jsx(Ee,{size:"sm",className:"min-w-0 max-w-56","aria-label":a??"Select repository",children:e.jsx(De,{placeholder:"Select repository",children:n=>{const o=s.find(l=>l.ref===n)??r;return!o||!o.ref?"Select repository":e.jsxs("span",{className:"block truncate",children:[o.relativePath," · ",o.owner,"/",o.repo]})}})}),e.jsx(Fe,{children:s.map(n=>{const o=!n.ref||!!n.disabledReason,l=cs(n);return e.jsx(Te,{value:n.ref,disabled:o,children:e.jsxs("span",{className:L("flex min-w-0 items-center gap-1.5",o&&"opacity-60"),children:[e.jsx(H,{name:"git-repository",className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 truncate",children:[n.relativePath," · ",n.owner&&n.repo?`${n.owner}/${n.repo}`:"not on GitHub"]}),l?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:l}):null,n.disabledReason?e.jsxs("span",{className:"shrink-0 typography-micro text-muted-foreground",children:["· ",n.disabledReason]}):null]})},`${n.ref||n.relativePath}:${n.relativePath}`)})})]})},Gs=({directory:s,isRefreshing:t,onRefresh:i,children:a})=>{const n=ze().github??null,o=A(p=>p.entriesByDirectory[Ge(s.trim())]??null),l=A(p=>p.ensureScope),c=A(p=>p.refreshScope),u=A(p=>p.setSelectedRepo),m=$e(s||null),h=ne(p=>p.status),g=ne(p=>p.refresh);d.useEffect(()=>{!s||!n||(l(s,n),g(n))},[s,n,l,g]);const C=d.useCallback(()=>{if(i){i();return}n&&(c(s,n,{force:!0}),g(n,{force:!0}))},[i,n,c,g,s]);if(!n)return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})});if(o?.isLoading&&!o.scope&&!o.error)return e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsx(he,{label:"Finding GitHub repositories"})});if(o?.error&&!o.scope)return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:pe(o.error),onRetry:C,isRetrying:t||o.isLoading})});const j=o?.scope??null;if(j&&!h?.installed)return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:{reason:"gh-missing"},onRetry:C,isRetrying:t})});const x=j?ls(j.repositories):[],f=x.filter(p=>!!(p.ref&&!p.disabledReason));if(j&&f.length===0){const p=j.topLevel?"not-github":"no-repository";return e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(D,{info:{reason:p}})})}if(!m)return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:e.jsx(re,{entries:x,value:m,onChange:p=>u(s,p)})}),e.jsxs("div",{className:"flex flex-col items-start gap-2 p-4",children:[e.jsx("div",{className:"typography-ui-header text-foreground",children:"Select a repository"}),e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Several repositories are in scope. Pick one to browse."})]})]});const b=f.length>1;return e.jsxs("div",{className:"flex h-full flex-col",children:[b?e.jsx("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-2",children:e.jsx(re,{entries:x,value:m,onChange:p=>u(s,p)})}):null,e.jsx("div",{className:"min-h-0 flex-1",children:a({repo:m,directory:s})})]})},Ls=({copy:s,busy:t,destructive:i,disabled:a,disabledReason:r,label:n,variant:o="default",icon:l,onConfirm:c})=>{const[u,m]=d.useState(!1);return e.jsxs(Ne,{open:u,onOpenChange:h=>{t||m(h)},children:[e.jsxs(Ce,{render:e.jsx(N,{type:"button",variant:o,size:"xs",className:"shrink-0",disabled:a||t,title:r??n,"aria-label":n}),children:[l,n]}),e.jsx(ke,{children:e.jsx(Se,{side:"bottom",align:"start",sideOffset:6,collisionPadding:8,className:"z-50",children:e.jsxs(Re,{"aria-label":s.title,className:"w-64 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsx("p",{className:"typography-ui-label text-foreground",children:s.title}),e.jsx("p",{className:"mt-1 typography-micro text-muted-foreground",children:s.detail}),e.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[e.jsx(N,{type:"button",variant:"outline",size:"xs",disabled:t,onClick:()=>m(!1),children:"Cancel"}),e.jsx(N,{type:"button",variant:i?"destructive":"default",size:"xs",disabled:t,onClick:()=>{Promise.resolve(c()).finally(()=>m(!1))},"aria-label":s.confirm,children:t?s.progress:s.confirm})]})]})})})]})},Ps=async(s,t)=>{if(!t?.listGitWorktrees)return;const i=Ie.getState().projects,a=Be(i,te.getState()),n=Ae(i,a,s)?.path??s;try{await te.getState().refreshProject(n,t,{force:!0})}catch{}},y=(s,t)=>`${s}#${t}`,xe=Object.freeze([]),us=Object.freeze({comments:xe,summary:"",verdict:"comment",commentDraft:""});let ae=0;const ds=()=>(ae+=1,`pending-review-comment-${ae}`),R=(s,t)=>s.entries[t]??us,S=(s,t,i)=>({...s.entries,[t]:{...R(s,t),...i}}),P=as()((s,t)=>({entries:{},addComment:(i,a,r)=>{const n=r.id??ds(),o=y(i,a);return s(l=>({entries:S(l,o,{comments:[...R(l,o).comments,{...r,id:n}]})})),n},removeComment:(i,a,r)=>{const n=y(i,a);s(o=>{const l=R(o,n).comments,c=l.filter(u=>u.id!==r);if(c.length===l.length)return o;if(c.length===0&&R(o,n).summary===""&&R(o,n).commentDraft===""){const u={...o.entries};return delete u[n],{entries:u}}return{entries:S(o,n,{comments:c})}})},removeComments:(i,a,r)=>{if(r.length===0)return;const n=y(i,a),o=new Set(r);s(l=>{const c=R(l,n).comments,u=c.filter(m=>!o.has(m.id));return u.length===c.length?l:{entries:S(l,n,{comments:u})}})},clearComments:(i,a)=>{const r=y(i,a);s(n=>(n.entries[r]?.comments.length??0)===0?n:{entries:S(n,r,{comments:[]})})},setSummary:(i,a,r)=>{const n=y(i,a);t().entries[n]?.summary!==r&&s(o=>({entries:S(o,n,{summary:r})}))},clearSummary:(i,a,r)=>{const n=y(i,a);s(o=>R(o,n).summary!==r?o:{entries:S(o,n,{summary:""})})},setVerdict:(i,a,r)=>{const n=y(i,a);t().entries[n]?.verdict!==r&&s(o=>({entries:S(o,n,{verdict:r})}))},setCommentDraft:(i,a,r)=>{const n=y(i,a);t().entries[n]?.commentDraft!==r&&s(o=>({entries:S(o,n,{commentDraft:r})}))},clearCommentDraft:(i,a)=>{const r=y(i,a);s(n=>R(n,r).commentDraft===""?n:{entries:S(n,r,{commentDraft:""})})},resetForRuntimeSwitch:()=>s({entries:{}})}));typeof window<"u"&&Le(()=>{P.getState().resetForRuntimeSwitch()});const Ms=(s,t)=>P(i=>i.entries[y(s,t)]?.comments??xe),Es=(s,t)=>P(i=>i.entries[y(s,t)]?.summary??""),Ds=(s,t)=>P(i=>i.entries[y(s,t)]?.verdict??"comment"),Fs=(s,t)=>P(i=>i.entries[y(s,t)]?.comments.length??0),ms=300,Ts=(s,t)=>{const i=y(s,t),a=P(h=>h.entries[i]?.commentDraft??""),[r,n]=d.useState(a),o=d.useRef(r);o.current=r;const l=d.useRef(a);l.current=a;const c=d.useRef(a);d.useEffect(()=>{o.current===c.current&&a!==c.current&&(c.current=a,n(a))},[a]);const u=d.useCallback(()=>{const h=o.current;h!==c.current&&(c.current=h,P.getState().setCommentDraft(s,t,h))},[s,t]),m=d.useCallback(h=>{n(h)},[]);return d.useEffect(()=>{if(r===c.current)return;const h=setTimeout(u,ms);return()=>clearTimeout(h)},[r,u]),d.useEffect(()=>()=>u(),[u]),{draft:r,onDraftChange:m,flushDraft:u}},hs=240,zs=({draft:s,onDraftChange:t,placeholder:i="Leave a comment",ariaLabel:a="Leave a comment",busy:r,error:n,disabledReason:o,followUp:l,onSubmitComment:c,onDraftBlur:u})=>{const m=d.useRef(null),[h,g]=d.useState(!1),C=d.useRef(null);d.useLayoutEffect(()=>{const f=m.current;if(!f)return;f.style.height="0px",f.style.height=`${Math.min(f.scrollHeight,hs)}px`;let b=C.current;if(!b){const w=getComputedStyle(f);b={lineHeight:Number.parseFloat(w.lineHeight)||20,padding:Number.parseFloat(w.paddingTop)+Number.parseFloat(w.paddingBottom)||0},C.current=b}const p=f.scrollHeight-b.padding>b.lineHeight*1.5;g(w=>w===p?w:p)},[s]);const j=s.trim().length===0,x=r!==null;return e.jsxs("form",{className:"flex flex-col gap-2 border-t border-border/60 pt-5","aria-label":a,onSubmit:f=>{f.preventDefault(),c()},children:[e.jsxs("div",{className:`flex ${h?"items-end":"items-center"} gap-1.5 rounded-md border border-border bg-[var(--surface-elevated)] py-1 pr-1 focus-within:border-[var(--interactive-focus-ring)]`,children:[e.jsx(Ve,{simple:!0,ref:m,rows:1,value:s,placeholder:`${i} (⌘↩)`,"aria-label":a,disabled:x,onChange:f=>t(f.target.value),onBlur:()=>u?.(),outerClassName:"min-w-0 flex-1",className:"min-h-0 w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 py-1 typography-ui text-foreground shadow-none outline-none placeholder:text-muted-foreground focus-visible:ring-0",onKeyDown:f=>{f.nativeEvent.isComposing||f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&!f.shiftKey&&!f.altKey&&!f.repeat&&(f.preventDefault(),f.stopPropagation(),!j&&!x&&c())}}),!j&&l&&l.allowed?e.jsx(N,{type:"button",variant:"ghost",size:"xs",disabled:x,title:l.reason??l.label,onClick:l.onRun,children:r===l.id?l.busyLabel:l.label}):null,e.jsx(N,{type:"button",variant:"default",size:"xs",disabled:j||x,title:o??"Post comment",onClick:c,children:r==="comment"?"Posting…":"Comment"})]}),n?e.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:n}):null]})},fs=async s=>{const t=s.notify??((r,n)=>U[r](n)),i=await s.postComment(s.trimmed);if(!i.ok){const r=i.error?.kind==="failed"&&i.error.message?i.error.message:"Failed to post comment";throw t("error",r),new Error(r)}if(s.afterPost(),s.action==="comment"){t("success","Comment posted");return}const a=await s.runFollowUp(s.action);if(!a.ok){const r=s.verbs[s.action],n=a.error?.kind==="failed"&&a.error.message?a.error.message:`Failed to ${r}`;throw t("error",n),new Error(n)}t("success",s.doneLabels[s.action])},$s=s=>{const[t,i]=d.useState(null),[a,r]=d.useState(null),n=d.useRef(s);n.current=s;const o=d.useCallback(async(l,c)=>{const u=c.trim(),m=n.current;if(!(u.length===0||t!==null)){i(l),r(null);try{await fs({trimmed:u,action:l,postComment:m.postComment,runFollowUp:m.runFollowUp,verbs:m.verbs,doneLabels:m.doneLabels,afterPost:m.afterPost})}catch(h){r(h instanceof Error?h.message:"Failed to post comment")}finally{i(null)}}},[t]);return{busy:t,error:a,submit:o}},ie=({label:s,value:t,options:i,currentLabel:a,onChange:r})=>e.jsxs(Oe,{children:[e.jsxs(qe,{children:[e.jsx("span",{className:"flex-1",children:s}),e.jsx("span",{className:"min-w-0 max-w-32 truncate typography-micro text-muted-foreground",children:a})]}),e.jsx(We,{className:"min-w-48",children:e.jsxs(de,{value:t,onValueChange:n=>{typeof n=="string"&&n!==t&&r(n)},children:[e.jsx(X,{children:s}),i.map(n=>e.jsx(me,{value:n.id,closeOnClick:!1,children:n.label},n.id))]})})]}),ps=({stateValue:s,stateOptions:t,onStateChange:i,involvementValue:a,involvementOptions:r,onInvolvementChange:n,labelsValue:o,onLabelsChange:l})=>{const c=t.find(g=>g.id===s)?.label??s,u=r.find(g=>g.id===a)?.label??a,m=(o??"").trim().length>0,h=(s!==t[0]?.id?1:0)+(a!==r[0]?.id?1:0)+(m?1:0);return e.jsxs(le,{modal:!1,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(N,{type:"button",variant:"ghost",size:"sm","aria-label":"Filters",title:"Filters",className:"h-8 shrink-0 gap-1.5 px-2 normal-case",children:[e.jsx(H,{name:"equalizer",className:"size-4","aria-hidden":"true"}),e.jsx("span",{children:"Filters"}),h>0?e.jsx("span",{className:"rounded-full bg-[var(--surface-muted)] px-1.5 typography-micro tabular-nums text-muted-foreground",children:h}):null]})}),e.jsxs(ue,{align:"end",className:"w-64",children:[e.jsx(ie,{label:"State",value:s,options:t,currentLabel:c,onChange:i}),e.jsx(ie,{label:"Involvement",value:a,options:r,currentLabel:u,onChange:n}),l?e.jsxs(e.Fragment,{children:[e.jsx(_e,{}),e.jsx(X,{children:"Labels"}),e.jsxs("div",{className:"px-2 pb-2",children:[e.jsx(Ke,{value:o??"",onChange:g=>l(g.target.value),placeholder:"bug, enhancement","aria-label":"Filter by labels",className:"h-7"}),e.jsx("p",{className:"mt-1 typography-micro text-muted-foreground",children:"Comma-separated. Or type label:bug in search."})]})]}):null]})]})},xs=({value:s,options:t,onChange:i,ariaLabel:a})=>e.jsxs(le,{modal:!1,children:[e.jsx(ce,{asChild:!0,children:e.jsx(N,{type:"button",variant:"ghost",size:"sm","aria-label":a,title:a,className:"h-8 w-8 shrink-0 p-0",children:e.jsx(H,{name:"expand-up-down",className:"size-4","aria-hidden":"true"})})}),e.jsx(ue,{align:"end",className:"w-52",children:e.jsxs(de,{value:s,onValueChange:r=>{typeof r=="string"&&r!==s&&i(r)},children:[e.jsx(X,{children:"Sort"}),t.map(r=>e.jsx(me,{value:r.id,children:r.label},r.id))]})})]}),oe=({isRefreshing:s,onRefresh:t,label:i,presentation:a="toolbar"})=>a==="desktop"?e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:s,title:i??"Refresh","aria-label":i??"Refresh GitHub data",className:"h-8 w-8 shrink-0 p-0",children:e.jsx(H,{name:"refresh",className:L("size-4",s&&"animate-spin"),"aria-hidden":"true"})}):a==="drawer"?e.jsx(N,{type:"button",variant:"ghost",size:"icon",onClick:t,disabled:s,title:i??"Refresh","aria-label":i??"Refresh GitHub data",className:"shrink-0",children:e.jsx(H,{name:"refresh",className:L("size-4",s&&"animate-spin"),"aria-hidden":"true"})}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:s,title:i??"Refresh","aria-label":i??"Refresh GitHub data",className:"h-8 w-8 shrink-0 p-0",children:e.jsx(H,{name:"refresh",className:L("size-4",s&&"animate-spin"),"aria-hidden":"true"})}),Is=({items:s,renderRow:t,hasMore:i,isLoadingMore:a,isLoading:r,isRefreshing:n,stale:o,error:l,searchValue:c,onSearchChange:u,searchPlaceholder:m,searchAriaLabel:h,toolbarControls:g,primaryAction:C,headerActionsSlot:j=null,headerActionsPresentation:x="drawer",isDefaultFilters:f,stateLabel:b,kindSingular:p,kindPlural:w,noItemsTitle:F,noItemsBody:M,noItemsIcon:K,noItemsAction:Q,listAriaLabel:E,skeletonLabel:ge,updatedAtOf:O,countComplete:q=!0,incompleteNotice:T=null,remote:v=null,numberJump:z=null,numberJumpKind:be,onClearFilters:je,onLoadMore:ye,onRetry:$,onOpen:we})=>{const Z=d.useMemo(()=>{if(s.length===0)return null;const G=s.length===1&&q?`1 ${p}`:`${s.length}${q?"":"+"} ${w}`;let B=0;for(const se of s){const Y=O(se)?Date.parse(O(se)):NaN;Number.isFinite(Y)&&Y>B&&(B=Y)}const ee=B>0?fe(new Date(B).toISOString()):"";return`${G} · ${b.toLowerCase()}${ee?` · updated ${ee}`:""}`},[s,b,p,w,q,O]),I=!!l&&s.length===0,W=!I&&r&&s.length===0,V=j??null,ve=x??"drawer",J=n||r;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o?e.jsx(Qe,{onRetry:$}):null,e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-3 py-2",children:[e.jsx(Ze,{value:c,onChange:u,placeholder:m,ariaLabel:h}),g,V?null:e.jsxs(e.Fragment,{children:[C,e.jsx(oe,{isRefreshing:J,onRefresh:$,presentation:"toolbar"})]})]}),V?He.createPortal(e.jsxs(e.Fragment,{children:[C,e.jsx(oe,{isRefreshing:J,onRefresh:$,presentation:ve})]}),V):null,I?e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(D,{info:pe(l),onRetry:$,isRetrying:r})}):W?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(he,{label:ge})}):e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",role:"list","aria-label":E,children:[s.length===0&&z==null?e.jsx(Je,{kind:f?"no-items":"no-match",noItemsTitle:F,noItemsBody:f?M:void 0,noItemsIcon:K,noItemsAction:f?Q:void 0,onClearFilters:f?void 0:je}):e.jsxs(e.Fragment,{children:[s.length>0?e.jsx("ul",{className:"flex flex-col p-1",children:s.map(G=>e.jsx(d.Fragment,{children:t(G)},G.number))}):null,z!=null?e.jsx(es,{number:z,kindLabel:be,onOpen:()=>we(z)}):null]}),e.jsx(ss,{hasMore:i,isLoading:a||r,onLoadMore:ye}),v&&(v.isSearching||v.error||v.items.length>0)?e.jsx(ts,{title:"More results from GitHub",isSearching:v.isSearching,error:v.error,hasResults:v.items.length>0,hasMore:v.hasMore,isLoadingMore:v.isLoadingMore,onRetry:v.onRetry,onLoadMore:v.onLoadMore,children:e.jsx("ul",{className:"flex flex-col",children:v.items.map(G=>e.jsx(d.Fragment,{children:t(G)},G.number))})}):null]}),!I&&!W&&T?e.jsx(ns,{matchSummary:T.summary,searching:T.searching,onSearchAll:T.onSearchAll}):null,!I&&!W&&Z?e.jsx(rs,{summary:Z}):null]})},Bs=({stateValue:s,stateOptions:t,onStateChange:i,involvementValue:a,involvementOptions:r,onInvolvementChange:n,labelsValue:o,onLabelsChange:l,sortValue:c,sortOptions:u,onSortChange:m,sortAriaLabel:h})=>e.jsxs(e.Fragment,{children:[e.jsx(ps,{stateValue:s,stateOptions:t,onStateChange:i,involvementValue:a,involvementOptions:r,onInvolvementChange:n,labelsValue:o,onLabelsChange:l}),e.jsx(xs,{value:c,options:u,onChange:m,ariaLabel:h})]}),gs="shrink-0 font-mono typography-micro tabular-nums text-muted-foreground",bs=({glyph:s,below:t})=>e.jsxs("span",{className:"flex w-4 shrink-0 flex-col items-center gap-0.5",children:[e.jsx("span",{className:"inline-flex",children:s}),t?e.jsx("span",{className:"inline-flex",children:t}):null]}),As=({login:s,avatarUrl:t})=>e.jsxs("span",{className:"inline-flex min-w-0 shrink-0 items-center gap-1",title:s??"ghost",children:[e.jsx(is,{login:s,avatarUrl:t,size:"xs"}),e.jsx("span",{className:"truncate",children:s??"ghost"})]}),_s=({head:s,base:t})=>e.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:s,children:s}),e.jsx("span",{className:"shrink-0",children:"→"}),e.jsx("span",{className:"max-w-[45%] shrink-0 truncate",title:t,children:t})]}),js=[{show:""},{show:"hidden @xl/github-row:inline-flex"},{show:"hidden @3xl/github-row:inline-flex"}],ys=["hidden @xl/github-row:hidden","hidden @xl/github-row:inline-flex @3xl/github-row:hidden",""],Ks=({labels:s})=>s.length===0?null:e.jsx("span",{className:"flex min-w-0 shrink-0 items-center gap-1",children:js.map((t,i)=>{const a=s[i];if(!a)return null;const r=s.length-i-1;return e.jsxs("span",{className:L("min-w-0",t.show),children:[e.jsx(os,{name:a.name,color:a.color}),r>0?e.jsxs("span",{className:L("ml-0.5 shrink-0",ys[i]),"aria-label":`${r} more labels`,children:["+",r]}):null]},a.name)})}),Os=({glyph:s,glyphBelow:t,number:i,title:a,signals:r,status:n,meta:o,updatedAt:l,selected:c,onOpen:u,ariaLabel:m})=>e.jsxs("button",{type:"button",onClick:u,"aria-label":m,"aria-current":c?"true":void 0,className:L("@container/github-row group/github-row flex w-full items-center gap-2 rounded-md px-2 py-1 text-left",c?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:[e.jsx(bs,{glyph:s,below:t}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:gs,children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:a,children:a}),r?e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:r}):null,n?e.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:n}):null]}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 overflow-hidden typography-micro text-muted-foreground",children:[o,l?e.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap tabular-nums",children:fe(l)}):null]})]})]}),qs=s=>{const{repo:t,query:i,queryKey:a,autoRemote:r,indexNumbers:n,visibleItems:o,searchText:l,useRemoteEntry:c,runSearch:u,runLoadMore:m}=s,[h,g]=d.useState(!1),[C,j]=d.useState(null);d.useEffect(()=>j(null),[t]);const x=c(t,i),f=r||C===a||x!=null,b=d.useCallback(()=>{g(!0),u(i).catch(()=>null).finally(()=>g(!1))},[i,u]);d.useEffect(()=>{if(!r||x?.data||x?.isLoading||x?.error||h)return;const E=setTimeout(b,400);return()=>clearTimeout(E)},[r,a,x?.data,x?.isLoading,x?.error,h,b]);const p=d.useCallback(()=>{j(a),b()},[a,b]),w=d.useCallback(()=>{g(!0),m(i).catch(()=>null).finally(()=>g(!1))},[i,m]),F=d.useMemo(()=>Ye(x?.data?.items??[],n),[x?.data?.items,n]),M=Ue(l),K=M!=null&&!o.some(E=>E.number===M)?M:null;return{remoteView:d.useMemo(()=>f?{items:F,isSearching:h||(x?.isLoading??!1),isLoadingMore:h,hasMore:x?.data?.nextCursor!=null,error:x?.error??null,onSearchAll:p,onLoadMore:w,onRetry:b}:null,[f,F,h,x?.isLoading,x?.data?.nextCursor,x?.error,p,w,b]),numberJump:K,remotePending:h,handleSearchAll:p}};export{zs as G,Ms as a,Ts as b,$s as c,Es as d,Ds as e,Fs as f,D as g,Ls as h,Os as i,As as j,_s as k,Is as l,Bs as m,Gs as n,qs as o,Ks as p,Ps as r,pe as t,P as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as p}from"./vendor-react-DASdDPIk.js";import{aT as z,a as B,b as D,c as L,aY as M,r as j,d as v}from"./useAppFontEffects-
|
|
1
|
+
import{R as p}from"./vendor-react-DASdDPIk.js";import{aT as z,a as B,b as D,c as L,aY as M,r as j,d as v}from"./useAppFontEffects-B6Bro-YP.js";const k=50,P=r=>{if(!r)return null;const s=r.replace(/\\/g,"/");return s==="/"?"/":s.replace(/\/+$/,"")},C=(r,s)=>{const o=P(r),c=P(s);return!o||!c?!1:o===c||o.startsWith(`${c}/`)},R=r=>{if(!r)return null;const s=r.label?.trim();return s||(r.path.split(/[\\/]/).filter(Boolean).at(-1)??r.path)},w=(r,s={})=>{const{scopeProjectId:o=null,maxParents:c=k}=s,u=z({archived:!1}),S=B(e=>e.projects),d=D(e=>e.ids),h=L(e=>e.rankById),b=M(),y=p.useMemo(()=>S.map(e=>({...e,normalizedPath:P(e.path)})).filter(e=>e.normalizedPath),[S]),m=p.useCallback(e=>e?y.filter(i=>C(e,i.normalizedPath)).sort((i,l)=>(l.normalizedPath?.length??0)-(i.normalizedPath?.length??0))[0]??null:null,[y]);return p.useMemo(()=>{if(!r)return[];const e=new Map;for(const t of u){const n=t.parentID;if(!n||t.time?.archived)continue;const a=e.get(n);a?a.push(t):e.set(n,[t])}const g=v(d,h);e.forEach(t=>{t.sort(g)});const i=u.filter(t=>!t.time?.archived).filter(t=>!t.parentID).filter(t=>{if(!o)return!0;const n=j(t);return m(n)?.id===o}).sort(v(d,h)).slice(0,c),l=t=>{const n=e.get(t.id)??[];return{session:t,children:n.map(a=>l(a))}};return i.map(t=>{const n=j(t),a=m(n),I=R(a),f=(n?b.get(n):void 0)??null;return{node:l(t),projectId:a?.id??null,groupDirectory:n,secondaryMeta:{projectLabel:I,branchLabel:f&&f!==I?f:null}}})},[u,b,r,m,c,d,o,h])};export{w as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ci as M,dG as V,dH as Y,dI as K,dJ as j,dM as X,dN as J,dO as $,dP as Q,dK as Z}from"./useAppFontEffects-Bd0btzjJ.js";import{b as ee,t as p,y as I,A as ne,a as G,z as te,B as C}from"./computeVirtualFileMetrics-E4gJTgVF.js";import{t as ie}from"./vendor-hast-util-to-html-BKBhbTDb.js";function U(e,n,t){if(e===n||e==null||n==null)return e===n;const i=new Set(t),a=Object.keys(e),r=new Set(Object.keys(n));for(const s of a)if(r.delete(s),!i.has(s)&&(!(s in n)||e[s]!==n[s]))return!1;for(const s of Array.from(r))if(!i.has(s))return!1;return!0}function Te(e,n){const t=e?.theme??M,i=n?.theme??M,a=R(e),r=R(n);return ee(t,i)&&U(e,n,["theme","parseDiffOptions"])&&U(a,r)}function R(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function H(e,n){return e?.start===n?.start&&e?.end===n?.end&&e?.side===n?.side&&e?.endSide===n?.endSide}function ae(){return p({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[I({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function re(e,n){return e.lineNumber===n.lineNumber&&e.side===n.side}var Ie=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;activeLineHighlightSide;activeLineNumberOnly=!1;editorAttached=!1;proposedSelectedRange;renderedSelectionRange;selectionAnchor;queuedSelectionRender;pointerSession={mode:"idle"};constructor(e,n){this.mode=e,this.options=n}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener("click",this.handlePointerClick),this.pre?.removeEventListener("pointerdown",this.handlePointerDown),this.pre?.removeEventListener("pointermove",this.handlePointerMove),this.pre?.removeEventListener("pointerleave",this.handlePointerLeave),this.pre?.removeAttribute("data-interactive-lines"),this.pre?.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1}setup(e){this.setSelectionDirty();const{usesCustomGutterUtility:n=!1,enableGutterUtility:t=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),t?this.ensureGutterUtilityNode(n):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode==="gutterSelecting"&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectionRange=void 0}setEditorAttached(e){this.editorAttached!==e&&(this.editorAttached=e,this.setSelectionDirty(),this.renderSelection())}isSelectionDirty(){return this.renderedSelectionRange===null}setSelection(e,n){const t=!(e===this.selectedRange||H(e??void 0,this.selectedRange??void 0));!this.isSelectionDirty()&&!t||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.activeLineHighlightSide=n?.activeLineSide,this.activeLineNumberOnly=n?.lineNumberOnly??!1,this.renderSelection(),this.placeUtility(),t&&n?.notify!==!1&&this.notifySelectionCommitted())}getSelection(){return this.selectedRange}getHoveredLine=()=>{const e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode==="diff"&&e.type==="diff-line")return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode==="file"&&e.type==="line")return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{const{onHunkExpand:n,onLineClick:t,onLineNumberClick:i,onTokenClick:a,onMergeConflictActionClick:r}=this.options;n==null&&t==null&&i==null&&r==null&&a==null||this.options.onGutterUtilityClick!=null&&E(e.composedPath())||(k(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",e),this.handlePointerEvent({eventType:"click",event:e}))};handlePointerMove=e=>{if(e.pointerType!=="mouse")return;const{lineHoverHighlight:n="disabled",onLineEnter:t,onLineLeave:i,onTokenEnter:a,onTokenLeave:r,enableGutterUtility:s=!1}=this.options;n==="disabled"&&!s&&t==null&&i==null&&a==null&&r==null||(k(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e}))};handlePointerLeave=e=>{const{__debugPointerEvents:n}=this.options;if(k(n,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){k(n,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:n}){const{__debugPointerEvents:t}=this.options,i=n.composedPath();k(t,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:i});const a=this.resolvePointerTarget(i);k(t,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",a);const{onLineClick:r,onLineNumberClick:s,onLineEnter:l,onLineLeave:o,onTokenClick:d,onTokenEnter:c,onTokenLeave:m,onHunkExpand:h,onMergeConflictActionClick:f}=this.options;switch(e){case"move":{const u=T(a)&&this.hoveredLine?.lineElement===a.lineElement;A(a)&&this.hoveredToken?.tokenElement===a.tokenElement||(this.hoveredToken!=null&&(m?.(this.hoveredToken,n),this.clearHoveredToken()),A(a)&&(this.setHoveredToken(this.toTokenEventBaseProps(a)),c?.(this.hoveredToken,n))),u||(this.hoveredLine!=null&&(o?.({...this.hoveredLine,event:n}),this.clearHoveredLine()),T(a)?(this.setHoveredLine(this.toEventBaseProps(a)),this.placeUtility(),l?.({...this.hoveredLine,event:n})):this.placeUtility());break}case"click":{if(a==null)break;if(de(a)&&f!=null){f(a);break}if(se(a)&&h!=null){h(a.hunkIndex,a.all||n.shiftKey?"both":a.direction,a.all||n.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!T(a))break;A(a)&&d!=null&&d(this.toTokenEventBaseProps(a),n);const u=this.toEventBaseProps(a);s!=null&&a.numberColumn?s({...u,event:n}):r?.({...u,event:n});break}}}syncPointerListeners(e){const{__debugPointerEvents:n,lineHoverHighlight:t="disabled",onLineClick:i,onLineNumberClick:a,onLineEnter:r,onLineLeave:s,onTokenClick:l,onTokenEnter:o,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:m,enableGutterUtility:h=!1,enableLineSelection:f=!1,onGutterUtilityClick:u}=this.options,v=u!=null,b=t!=="disabled"||i!=null||a!=null||r!=null||s!=null||l!=null||o!=null||d!=null||c!=null||m!=null||h||f||v;b&&!this.hasPointerListeners?(e.addEventListener("click",this.handlePointerClick),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointermove",this.handlePointerMove),e.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,k(n,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const x=[];return(n==="both"||n==="click")&&(i!=null&&x.push("onLineClick"),a!=null&&x.push("onLineNumberClick"),c!=null&&x.push("expandable hunk separators"),m!=null&&x.push("merge conflict actions")),x})()),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!b&&this.hasPointerListeners&&(e.removeEventListener("click",this.handlePointerClick),e.removeEventListener("pointerdown",this.handlePointerDown),e.removeEventListener("pointermove",this.handlePointerMove),e.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const g=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",y=this.pointerSession.mode==="gutterSelecting";(!f&&g||!v&&y)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:e,onLineNumberClick:n,enableLineSelection:t=!1}=this.options,i=e!=null,a=n!=null||t;i&&!this.interactiveLinesAttr?(this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0):!i&&this.interactiveLinesAttr&&(this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1),a&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0):!a&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute("data-interactive-line-numbers"),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType==="mouse"&&e.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const n=e.composedPath();E(n)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(n),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){const{enableLineSelection:n=!1}=this.options;if(!n)return;const t=this.resolveSelectionInfo(e,{source:"event-path",requireNumberColumn:!0});if(t==null)return;const{pre:i}=this;if(i==null)return;e.preventDefault();const{lineNumber:a,eventSide:r,lineIndex:s}=t;if(e.shiftKey&&this.selectedRange!=null){const l=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(l==null)return;const o=l.start<=l.end?s>=l.start:s<=l.end;this.selectionAnchor={lineNumber:o?this.selectedRange.start:this.selectedRange.end,side:o?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===a&&this.selectedRange?.end===a){const l={lineNumber:a,side:r};this.selectionAnchor=l,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:l,pending:l},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:a,side:r},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;if(t==null)return;const i=this.currentSelectionEnds(),a=i?.bottom??this.resolveSelectionPoint(e,{source:"event-path",excludeUtility:!1}),r=i?.top??a;a==null||r==null||(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:e.pointerId,anchor:r,current:a},n&&(this.selectionAnchor={lineNumber:r.lineNumber,side:r.side},this.updateSelection(a.lineNumber,a.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange())),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{const{enableLineSelection:n=!1}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionPoint(e,{source:"coordinates-first"});if(t==null)return;this.pointerSession.current=t,n===!0&&this.updateSelection(t.lineNumber,t.side);return}case"selecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case"pendingSingleLineUnselect":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;const i={lineNumber:t.lineNumber,side:t.eventSide};if(re(this.pointerSession.pending,i))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const i=this.resolveSelectionPoint(e,{source:"coordinates-first"});i!=null&&(this.pointerSession.current=i,n&&this.updateSelection(i.lineNumber,i.side)),t?.(this.buildSelectedLineRange(this.pointerSession.anchor,this.pointerSession.current)),this.selectionAnchor=void 0,n&&(this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection();return;case"selecting":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(e){const{lineHoverHighlight:n="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,n!=="disabled"&&((n==="both"||n==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(n==="both"||n==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot==null&&(this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot"),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const n=document.createElement("div");n.innerHTML=ie(ae());const t=n.firstElementChild;if(!(t instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;const n=this.resolvePointerTarget(e);w(n)&&n.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(n))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const e=this.currentSelectionEnds();if(e==null)return!1;const n=this.targetForSelectionPoint(e.bottom);return n==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(n)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){const n={lineNumber:e.start,side:e.side},t={lineNumber:e.end,side:e.endSide??e.side},i=this.selectionPointRowIndex(n),a=this.selectionPointRowIndex(t);if(!(i==null||a==null))return i>a?{top:t,bottom:n}:{top:n,bottom:t}}selectionPointRowIndex(e){const n=this.getLineIndex(e.lineNumber,e.side);if(n!=null)return this.isSplitDiff()?n[1]:n[0]}targetForSelectionPoint(e){if(this.pre==null)return;const n=this.getLineIndex(e.lineNumber,e.side);if(n==null)return;const t=this.mode==="diff"?`${n[0]},${n[1]}`:`${n[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${t}"]`);for(const a of i){if(!(a instanceof HTMLElement))continue;const r=this.resolvePointerTarget(L(a));if(w(r)&&!(this.mode==="diff"&&e.side!=null&&r.side!==e.side))return r}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||(document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&(document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1)}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){this.pointerSession.mode==="pendingSingleLineUnselect"&&(this.pointerSession={mode:"idle"})}selectionInfoFromPath(e,n){const t=this.resolvePointerTarget(e);if(w(t)&&!(n&&!t.numberColumn)&&t.splitLineIndex!=null)return{lineIndex:t.splitLineIndex,lineNumber:t.lineNumber,eventSide:this.mode==="diff"?t.side:void 0}}resolveSelectionInfo(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionInfoFromPath(t,n.requireNumberColumn):void 0}selectionPointFromPath(e){const n=this.resolvePointerTarget(e);if(w(n))return{lineNumber:n.lineNumber,side:this.mode==="diff"?n.side:void 0}}resolveSelectionPoint(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionPointFromPath(t):void 0}resolveSelectionPath(e,n){const t=n.excludeUtility!==!1;switch(n.source){case"event-path":return this.pathFromEventPath(e.composedPath(),t);case"coordinates-first":{const i=this.pathFromCoordinates(e,t);return i!==void 0?i??void 0:this.pathFromEventPath(e.composedPath(),t)}}}pathFromCoordinates(e,n){const t=this.hitTest(e);if(t!==void 0)return t===null?null:this.pathFromElement(t,n)??null}pathFromEventPath(e,n){if(!(n&&E(e))){for(const t of e)if(t instanceof Element)return this.pathFromElement(t,n)}}pathFromElement(e,n){const t=L(e);if(n&&E(t))return;const i=fe(e);return i!=null?L(i):this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){const n=ue(ce(e));if(n==null)return;const t=this.targetForSelectionPoint(n);return t!=null?L(t.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;const n=this.pre?.getRootNode(),t=z(n)?n:z(document)?document:void 0;if(t!=null)return t.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,n){const{getLineIndex:t}=this.options;return t!=null?t(e,n):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,n,t=!0){const i=this.getCurrentSelectionRange();let a;if(e==null)a=null;else{const r=this.selectionAnchor?.side??n,s=this.selectionAnchor?.lineNumber??e;a=this.buildSelectionRange(s,e,r,n)}H(i??void 0,a??void 0)||(this.activeLineHighlightSide=void 0,this.activeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=a:(this.selectedRange=a,this.queuedSelectionRender??=requestAnimationFrame(this.renderSelection)),this.placeUtility(),t&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,n){if(this.pre==null)return;const t=this.getLineIndex(e.start,e.side),i=this.getLineIndex(e.end,e.endSide??e.side);return t!=null&&i!=null?{start:n?t[1]:t[0],end:n?i[1]:i[0]}:void 0}highlightLineNumberOnly(){return this.activeLineHighlightSide!=null?this.activeLineNumberOnly:this.activeLineNumberOnly||this.editorAttached}renderSelection=()=>{if(this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.pre==null||this.renderedSelectionRange===this.selectedRange)return;const e=this.pre.querySelectorAll("[data-selected-line]");for(const o of e)o.removeAttribute("data-selected-line");if(this.renderedSelectionRange=this.selectedRange,this.selectedRange==null)return;const{children:n}=this.pre;if(n.length===0)return;if(n.length>2)throw console.error(n),new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");const t=this.pre.getAttribute("data-diff-type")==="split",i=this.getIndexesFromSelection(this.selectedRange,t);if(i==null)throw console.error({rowRange:i,selectedRange:this.selectedRange}),new Error("InteractionManager.renderSelection: No valid rowRange");const a=i.start===i.end,r=Math.min(i.start,i.end),s=Math.max(i.start,i.end),l=this.highlightLineNumberOnly();for(const o of n){const d=this.activeLineHighlightSide;if(d!=null&&(d==="additions"&&o.hasAttribute("data-deletions")||d==="deletions"&&o.hasAttribute("data-additions")))continue;const[c,m]=o.children,h=m.children.length;if(h!==c.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");for(let f=0;f<h;f++){const u=m.children[f],v=c.children[f];if(!(u instanceof HTMLElement)||!(v instanceof HTMLElement))continue;const b=this.parseLineIndex(u,t);if((b??0)>s)break;if(b==null||b<r)continue;let g=a?"single":b===r?"first":b===s?"last":"";v.setAttribute("data-selected-line",g),!l&&(u.setAttribute("data-selected-line",g),v.nextSibling instanceof HTMLElement&&u.nextSibling instanceof HTMLElement&&(u.nextSibling.hasAttribute("data-line-annotation")||u.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(a?(g="last",u.setAttribute("data-selected-line","first")):b===r?g="":b===s&&u.setAttribute("data-selected-line",""),u.nextSibling.setAttribute("data-selected-line",g),v.nextSibling.setAttribute("data-selected-line",g)))}}};notifySelectionCommitted(){this.options.onLineSelected?.(this.getCurrentSelectionRange()??null)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode==="file"?{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:"diff-line",annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}){return this.mode==="file"?{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,tokenElement:a,tokenText:r}:{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}}buildSelectedLineRange(e,n){return this.buildSelectionRange(e.lineNumber,n.lineNumber,e.side,n.side)}buildSelectionRange(e,n,t,i){return{start:e,end:n,...t!=null?{side:t}:{},...t!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(e){let n=!1,t,i,a,r,s,l,o,d,c,m;for(const f of e){if(!(f instanceof HTMLElement))continue;if(m==null&&f.hasAttribute("data-merge-conflict-action")){const g=f.getAttribute("data-merge-conflict-action")??void 0,y=f.getAttribute("data-merge-conflict-conflict-index")??void 0,x=y!=null?Number.parseInt(y,10):NaN;le(g)&&Number.isFinite(x)&&(m={kind:"merge-conflict-action",resolution:g,conflictIndex:x})}if(l==null&&f.hasAttribute("data-char")){l=f;const g=f.getAttribute("data-char");if(g!=null){const y=Number.parseInt(g,10);if(!Number.isNaN(y)){const x=f.textContent??"",N=y+x.length;(x.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(o={tokenElement:l,lineCharStart:y,lineCharEnd:N,tokenText:x});continue}}}const u=s==null?f.getAttribute("data-column-number")??void 0:void 0;if(u!=null){s=f,c=Number.parseInt(u,10),n=!0,t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}const v=a==null?f.getAttribute("data-line")??void 0:void 0;if(v!=null){a=f,c=Number.parseInt(v,10),t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}if(d==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:f.hasAttribute("data-expand-up")?"up":f.hasAttribute("data-expand-down")?"down":"both",all:f.hasAttribute("data-expand-all-button")};continue}const b=d!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&b!=null){const g=Number.parseInt(b,10);Number.isNaN(g)||(d.hunkIndex=g);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(m!=null)return m;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(a??=r!=null?D(i,`[data-line][data-line-index="${r}"]`):void 0,s??=r!=null?D(i,`[data-column-number][data-line-index="${r}"]`):void 0,i==null||a==null||s==null||t==null||c==null||Number.isNaN(c))return;const h=this.parseLineIndex(a,this.isSplitDiff());return o!=null?this.mode==="file"?{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h,...o}:{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h,...o}:this.mode==="file"?{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h}:{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,n){const t=(e.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(n&&t.length===2)return t[1];if(!n)return t[0]}};function Me({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:n,lineHoverHighlight:t,onGutterUtilityClick:i,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:m,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y},x,N,W){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:oe({enableGutterUtility:n,renderGutterUtility:m,onGutterUtilityClick:i}),usesCustomGutterUtility:m!=null,lineHoverHighlight:t,onGutterUtilityClick:i,onHunkExpand:x,onMergeConflictActionClick:W,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y,getLineIndex:N}}function oe({enableGutterUtility:e,renderGutterUtility:n,onGutterUtilityClick:t}){if(t!=null&&n!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return e??!1}function w(e){return e!=null&&"kind"in e&&e.kind==="line"}function A(e){return e!=null&&"kind"in e&&e.kind==="token"}function T(e){return w(e)||A(e)}function se(e){return"type"in e&&e.type==="line-info"}function de(e){return"kind"in e&&e.kind==="merge-conflict-action"}function le(e){return e==="current"||e==="incoming"||e==="both"}function D(e,n){const t=e?.querySelector(n);return t instanceof HTMLElement?t:void 0}function L(e){const n=[];let t=e;for(;t!=null;)n.push(t),t=t.parentNode;return n}function fe(e){const n=e.closest("[data-line], [data-column-number]");if(n instanceof HTMLElement)return n;const t=e.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');if(!(t instanceof HTMLElement))return;const i=t.previousElementSibling;return i instanceof HTMLElement&&(i.hasAttribute("data-line")||i.hasAttribute("data-column-number"))?i:void 0}function ce(e){const n=e.closest('[slot^="annotation-"]');if(n instanceof HTMLElement)return n.getAttribute("slot")??void 0;if(e instanceof HTMLElement){const t=e.getAttribute("name")??void 0;return t!=null&&t.startsWith("annotation-")?t:void 0}}function ue(e){if(e==null)return;const n=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(n==null)return;const t=Number.parseInt(n[2],10);if(!(!Number.isFinite(t)||t<=0))return{lineNumber:t,side:n[1]}}function z(e){return e!=null&&typeof e.elementFromPoint=="function"}function F(e,n){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return n.hasAttribute("data-deletions")?"deletions":"additions"}}function O(e){const n=e.getAttribute("data-line-type");if(n!=null)switch(n){case"change-deletion":case"change-addition":case"context":case"context-expanded":return n;default:return}}function E(e){for(const n of e)if(n instanceof HTMLElement&&(n.hasAttribute("data-utility-button")||n.hasAttribute("data-gutter-utility-slot")||n.getAttribute("slot")==="gutter-utility-slot"||n.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}function k(e="none",n,...t){switch(e){case"none":return;case"both":break;case"click":if(n!=="click")return;break;case"move":if(n!=="move")return;break}console.log(...t)}var Ue=class S{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){const n=S.resizeObserver??new ResizeObserver(S.handleSharedResizeEntries);return S.resizeObserver=n,n}static handleSharedResizeEntries(n){const t=new Map;for(const i of n){const a=S.managersByElement.get(i.target);if(a==null)continue;const r=t.get(a);r==null?t.set(a,[i]):r.push(i)}for(const[i,a]of t)i.handleResizeEntries(a)}observedNodes=new Map;setup(n,t){const i=new Set;let a=0;const r=new Map(this.observedNodes);this.observedNodes.clear();for(const s of n.children){if(a===2)break;const l=(()=>{if(s instanceof HTMLElement&&s.tagName==="CODE")return s})();if(l==null)continue;a++;let o=r.get(l);if(o!=null&&o.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let d=l.firstElementChild;d instanceof HTMLElement||(d=null),o!=null?(this.observedNodes.set(l,o),r.delete(l),o.numberElement!==d?(o.numberElement!=null&&(this.unobserve(o.numberElement),r.delete(o.numberElement)),d!=null&&(this.observe(d),r.delete(d),this.observedNodes.set(d,o)),o.numberElement=d,o.numberWidth=0):o.numberElement!=null?(r.delete(o.numberElement),this.observedNodes.set(o.numberElement,o)):o.numberWidth=0):(o={type:"code",codeElement:l,numberElement:d,codeWidth:"auto",numberWidth:0},this.observedNodes.set(l,o),this.observe(l),d!=null&&(this.observedNodes.set(d,o),this.observe(d)))}if(a>1&&!t){const s=n.querySelectorAll('[data-line-annotation*=","]'),l=new Map;for(const o of s){if(!(o instanceof HTMLElement))continue;const d=o.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(d)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:d,element:o});continue}let c=l.get(d);c==null&&(c=[],l.set(d,c)),c.push(o)}for(const[o,d]of l){if(d.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",o,d);continue}const[c,m]=d,h=c.firstElementChild,f=m.firstElementChild;if(!(c instanceof HTMLElement)||!(m instanceof HTMLElement)||!(h instanceof HTMLElement)||!(f instanceof HTMLElement))continue;let u=r.get(h);if(u!=null){this.observedNodes.set(h,u),this.observedNodes.set(f,u),r.delete(h),r.delete(f);continue}const v=h.getBoundingClientRect().height,b=f.getBoundingClientRect().height;u={type:"annotations",column1:{container:c,child:h,childHeight:v},column2:{container:m,child:f,childHeight:b},currentHeight:"auto"},i.add({child1:h,child2:f,item:u,newHeight:Math.max(v,b)})}for(const o of i)this.applyNewHeight(o.item,o.newHeight),this.observedNodes.set(o.child1,o.item),this.observedNodes.set(o.child2,o.item),this.observe(o.child1),this.observe(o.child2);i.clear()}for(const[s,l]of r)this.unobserve(s),l.type==="code"?ge(l):pe(l);r.clear()}cleanUp(){for(const n of this.observedNodes.keys())this.unobserve(n);this.observedNodes.clear()}observe(n){const{managersByElement:t}=S,i=t.get(n);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");t.set(n,this),S.getResizeObserver().observe(n)}}unobserve(n){const{managersByElement:t,resizeObserver:i}=S,a=t.get(n);if(a!=null){if(a!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");t.delete(n),i?.unobserve(n),i!=null&&t.size===0&&(i.disconnect(),S.resizeObserver=void 0)}}handleResizeEntries(n){const t=new Map,i=new Set;for(const a of n){const{target:r,borderBoxSize:s,contentBoxSize:l}=a;if(!(r instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",a);continue}const o=this.observedNodes.get(r);if(o==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",a);continue}if(o.type==="annotations"){const d=(()=>{if(r===o.column1.child)return o.column1;if(r===o.column2.child)return o.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:o,target:r});continue}d.childHeight=s[0].blockSize,i.add(o)}else if(o.type==="code"){const d=t.get(o)??{},c=l[0].inlineSize;r===o.codeElement?d.codeInlineSize=c:r===o.numberElement&&(d.numberInlineSize=c),t.set(o,d)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(n){for(const t of n)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=n=>{for(const[t,i]of n){const a=i.codeInlineSize!=null?he(i.codeInlineSize):t.codeWidth,r=i.numberInlineSize!=null?me(i.numberInlineSize):t.numberWidth,s=a!==t.codeWidth,l=r!==t.numberWidth;if(!(!s&&!l)&&(t.codeWidth=a,t.numberWidth=r,s&&t.codeElement.style.setProperty("--diffs-column-width",`${typeof a=="number"?`${a}px`:"auto"}`),l&&t.codeElement.style.setProperty("--diffs-column-number-width",`${r===0?"auto":`${r}px`}`),s||l&&a!=="auto")){const o=typeof a=="number"?Math.max(a-r,0):0;t.codeElement.style.setProperty("--diffs-column-content-width",`${o>0?`${o}px`:"auto"}`)}}};applyNewHeight(n,t){t!==n.currentHeight&&(n.currentHeight=Math.max(t,0),n.column1.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`),n.column2.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`))}};function he(e){const n=Math.max(Math.floor(e),0);return n===0?"auto":n}function me(e){return Math.max(Math.ceil(e),0)}function ge(e){e.codeElement.isConnected&&(e.codeElement.style.removeProperty("--diffs-column-content-width"),e.codeElement.style.removeProperty("--diffs-column-number-width"),e.codeElement.style.removeProperty("--diffs-column-width"))}function pe(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty("--diffs-annotation-min-height"),e.column2.container.isConnected&&e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function Re(e){for(const n of Array.isArray(e)?e:[e])if(!(n==="text"||n==="ansi")&&!ne.has(n))return!1;return!0}function He(e){for(const n of G(e))if(!te.has(n))return!1;return!0}function De(e,n){return e==null||n==null?e===n:e.startingLine===n.startingLine&&e.totalLines===n.totalLines&&e.bufferBefore===n.bufferBefore&&e.bufferAfter===n.bufferAfter}function ze(e){return p({tagName:"div",children:[p({tagName:"div",children:e.annotations?.map(n=>p({tagName:"slot",properties:{name:n}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function be(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}function Fe({fileOrDiff:e,mode:n,stickyHeader:t}){const i="type"in e?e:void 0,a={"data-diffs-header":n,"data-change-type":i?.type,"data-sticky":t?"":void 0};return p({tagName:"div",children:[n==="custom"?p({tagName:"slot",properties:{name:V}}):ve({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:i?.type??"file"}),...n==="custom"?[]:[xe(i)]],properties:a})}function ve({name:e,prevName:n,iconType:t}){const i=[p({tagName:"slot",properties:{name:Y}}),I({name:be(t),properties:{"data-change-icon":t}})];return n!=null&&(i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(n)]})],properties:{"data-prev-name":""}})),i.push(I({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(e)]})],properties:{"data-title":""}})),i.push(p({tagName:"slot",properties:{name:K}})),p({tagName:"div",children:i,properties:{"data-header-content":""}})}function xe(e){const n=[];if(e!=null){let t=0,i=0;for(const a of e.hunks)t+=a.additionLines,i+=a.deletionLines;(i>0||t===0)&&n.push(p({tagName:"span",children:[C(`-${i}`)],properties:{"data-deletions-count":""}})),(t>0||i===0)&&n.push(p({tagName:"span",children:[C(`+${t}`)],properties:{"data-additions-count":""}}))}return n.push(p({tagName:"slot",properties:{name:j}})),p({tagName:"div",children:n,properties:{"data-metadata":""}})}function Oe(e){return p({tagName:"pre",properties:ye(e)})}function ye({diffIndicators:e,disableBackground:n,disableLineNumbers:t,overflow:i,split:a,totalLines:r,type:s,customProperties:l}){return{...l,"data-diff":s==="diff"?"":void 0,"data-file":s==="file"?"":void 0,"data-diff-type":s==="diff"?a?"split":"single":void 0,"data-overflow":i,"data-disable-line-numbers":t?"":void 0,"data-background":n?void 0:"","data-indicators":e==="bars"||e==="classic"?e:void 0,tabIndex:0,style:`--diffs-min-number-column-width-default:${`${r}`.length}ch;`}}function Be(e,{theme:n,preferredHighlighter:t="shiki-js"}){return{langs:[e??"text"],themes:G(n),preferredHighlighter:t}}function $e(e){return`annotation-${"side"in e?`${e.side}-`:""}${e.lineNumber}`}const Ge="-1,-1";function _e(e){return e?.some(n=>n.lineNumber===0)??!1}function qe(e){const n=e[0];return n!=null&&n.length>0?n:void 0}function We(e){return e.startingLine===0&&e.totalLines>0}function Ve(e,n){return p({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${n}`}})}function Ye(e){return e.useTokenTransformer===!0||e.onTokenClick!=null||e.onTokenEnter!=null||e.onTokenLeave!=null}const Ke=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
1
|
+
import{ci as M,dG as V,dH as Y,dI as K,dJ as j,dM as X,dN as J,dO as $,dP as Q,dK as Z}from"./useAppFontEffects-B6Bro-YP.js";import{b as ee,t as p,y as I,A as ne,a as G,z as te,B as C}from"./computeVirtualFileMetrics-8pZIB8G2.js";import{t as ie}from"./vendor-hast-util-to-html-BKBhbTDb.js";function U(e,n,t){if(e===n||e==null||n==null)return e===n;const i=new Set(t),a=Object.keys(e),r=new Set(Object.keys(n));for(const s of a)if(r.delete(s),!i.has(s)&&(!(s in n)||e[s]!==n[s]))return!1;for(const s of Array.from(r))if(!i.has(s))return!1;return!0}function Te(e,n){const t=e?.theme??M,i=n?.theme??M,a=R(e),r=R(n);return ee(t,i)&&U(e,n,["theme","parseDiffOptions"])&&U(a,r)}function R(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function H(e,n){return e?.start===n?.start&&e?.end===n?.end&&e?.side===n?.side&&e?.endSide===n?.endSide}function ae(){return p({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[I({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function re(e,n){return e.lineNumber===n.lineNumber&&e.side===n.side}var Ie=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;activeLineHighlightSide;activeLineNumberOnly=!1;editorAttached=!1;proposedSelectedRange;renderedSelectionRange;selectionAnchor;queuedSelectionRender;pointerSession={mode:"idle"};constructor(e,n){this.mode=e,this.options=n}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener("click",this.handlePointerClick),this.pre?.removeEventListener("pointerdown",this.handlePointerDown),this.pre?.removeEventListener("pointermove",this.handlePointerMove),this.pre?.removeEventListener("pointerleave",this.handlePointerLeave),this.pre?.removeAttribute("data-interactive-lines"),this.pre?.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1}setup(e){this.setSelectionDirty();const{usesCustomGutterUtility:n=!1,enableGutterUtility:t=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),t?this.ensureGutterUtilityNode(n):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode==="gutterSelecting"&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectionRange=void 0}setEditorAttached(e){this.editorAttached!==e&&(this.editorAttached=e,this.setSelectionDirty(),this.renderSelection())}isSelectionDirty(){return this.renderedSelectionRange===null}setSelection(e,n){const t=!(e===this.selectedRange||H(e??void 0,this.selectedRange??void 0));!this.isSelectionDirty()&&!t||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.activeLineHighlightSide=n?.activeLineSide,this.activeLineNumberOnly=n?.lineNumberOnly??!1,this.renderSelection(),this.placeUtility(),t&&n?.notify!==!1&&this.notifySelectionCommitted())}getSelection(){return this.selectedRange}getHoveredLine=()=>{const e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode==="diff"&&e.type==="diff-line")return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode==="file"&&e.type==="line")return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{const{onHunkExpand:n,onLineClick:t,onLineNumberClick:i,onTokenClick:a,onMergeConflictActionClick:r}=this.options;n==null&&t==null&&i==null&&r==null&&a==null||this.options.onGutterUtilityClick!=null&&E(e.composedPath())||(k(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",e),this.handlePointerEvent({eventType:"click",event:e}))};handlePointerMove=e=>{if(e.pointerType!=="mouse")return;const{lineHoverHighlight:n="disabled",onLineEnter:t,onLineLeave:i,onTokenEnter:a,onTokenLeave:r,enableGutterUtility:s=!1}=this.options;n==="disabled"&&!s&&t==null&&i==null&&a==null&&r==null||(k(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e}))};handlePointerLeave=e=>{const{__debugPointerEvents:n}=this.options;if(k(n,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){k(n,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:n}){const{__debugPointerEvents:t}=this.options,i=n.composedPath();k(t,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:i});const a=this.resolvePointerTarget(i);k(t,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",a);const{onLineClick:r,onLineNumberClick:s,onLineEnter:l,onLineLeave:o,onTokenClick:d,onTokenEnter:c,onTokenLeave:m,onHunkExpand:h,onMergeConflictActionClick:f}=this.options;switch(e){case"move":{const u=T(a)&&this.hoveredLine?.lineElement===a.lineElement;A(a)&&this.hoveredToken?.tokenElement===a.tokenElement||(this.hoveredToken!=null&&(m?.(this.hoveredToken,n),this.clearHoveredToken()),A(a)&&(this.setHoveredToken(this.toTokenEventBaseProps(a)),c?.(this.hoveredToken,n))),u||(this.hoveredLine!=null&&(o?.({...this.hoveredLine,event:n}),this.clearHoveredLine()),T(a)?(this.setHoveredLine(this.toEventBaseProps(a)),this.placeUtility(),l?.({...this.hoveredLine,event:n})):this.placeUtility());break}case"click":{if(a==null)break;if(de(a)&&f!=null){f(a);break}if(se(a)&&h!=null){h(a.hunkIndex,a.all||n.shiftKey?"both":a.direction,a.all||n.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!T(a))break;A(a)&&d!=null&&d(this.toTokenEventBaseProps(a),n);const u=this.toEventBaseProps(a);s!=null&&a.numberColumn?s({...u,event:n}):r?.({...u,event:n});break}}}syncPointerListeners(e){const{__debugPointerEvents:n,lineHoverHighlight:t="disabled",onLineClick:i,onLineNumberClick:a,onLineEnter:r,onLineLeave:s,onTokenClick:l,onTokenEnter:o,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:m,enableGutterUtility:h=!1,enableLineSelection:f=!1,onGutterUtilityClick:u}=this.options,v=u!=null,b=t!=="disabled"||i!=null||a!=null||r!=null||s!=null||l!=null||o!=null||d!=null||c!=null||m!=null||h||f||v;b&&!this.hasPointerListeners?(e.addEventListener("click",this.handlePointerClick),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointermove",this.handlePointerMove),e.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,k(n,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const x=[];return(n==="both"||n==="click")&&(i!=null&&x.push("onLineClick"),a!=null&&x.push("onLineNumberClick"),c!=null&&x.push("expandable hunk separators"),m!=null&&x.push("merge conflict actions")),x})()),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),k(n,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!b&&this.hasPointerListeners&&(e.removeEventListener("click",this.handlePointerClick),e.removeEventListener("pointerdown",this.handlePointerDown),e.removeEventListener("pointermove",this.handlePointerMove),e.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const g=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",y=this.pointerSession.mode==="gutterSelecting";(!f&&g||!v&&y)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:e,onLineNumberClick:n,enableLineSelection:t=!1}=this.options,i=e!=null,a=n!=null||t;i&&!this.interactiveLinesAttr?(this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0):!i&&this.interactiveLinesAttr&&(this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1),a&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0):!a&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute("data-interactive-line-numbers"),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType==="mouse"&&e.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const n=e.composedPath();E(n)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(n),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){const{enableLineSelection:n=!1}=this.options;if(!n)return;const t=this.resolveSelectionInfo(e,{source:"event-path",requireNumberColumn:!0});if(t==null)return;const{pre:i}=this;if(i==null)return;e.preventDefault();const{lineNumber:a,eventSide:r,lineIndex:s}=t;if(e.shiftKey&&this.selectedRange!=null){const l=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(l==null)return;const o=l.start<=l.end?s>=l.start:s<=l.end;this.selectionAnchor={lineNumber:o?this.selectedRange.start:this.selectedRange.end,side:o?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===a&&this.selectedRange?.end===a){const l={lineNumber:a,side:r};this.selectionAnchor=l,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:l,pending:l},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:a,side:r},this.updateSelection(a,r,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;if(t==null)return;const i=this.currentSelectionEnds(),a=i?.bottom??this.resolveSelectionPoint(e,{source:"event-path",excludeUtility:!1}),r=i?.top??a;a==null||r==null||(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:e.pointerId,anchor:r,current:a},n&&(this.selectionAnchor={lineNumber:r.lineNumber,side:r.side},this.updateSelection(a.lineNumber,a.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange())),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{const{enableLineSelection:n=!1}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionPoint(e,{source:"coordinates-first"});if(t==null)return;this.pointerSession.current=t,n===!0&&this.updateSelection(t.lineNumber,t.side);return}case"selecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case"pendingSingleLineUnselect":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;const i={lineNumber:t.lineNumber,side:t.eventSide};if(re(this.pointerSession.pending,i))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{const{enableLineSelection:n=!1,onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const i=this.resolveSelectionPoint(e,{source:"coordinates-first"});i!=null&&(this.pointerSession.current=i,n&&this.updateSelection(i.lineNumber,i.side)),t?.(this.buildSelectedLineRange(this.pointerSession.anchor,this.pointerSession.current)),this.selectionAnchor=void 0,n&&(this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection();return;case"selecting":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(e){const{lineHoverHighlight:n="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,n!=="disabled"&&((n==="both"||n==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(n==="both"||n==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot==null&&(this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot"),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const n=document.createElement("div");n.innerHTML=ie(ae());const t=n.firstElementChild;if(!(t instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;const n=this.resolvePointerTarget(e);w(n)&&n.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(n))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const e=this.currentSelectionEnds();if(e==null)return!1;const n=this.targetForSelectionPoint(e.bottom);return n==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(n)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){const n={lineNumber:e.start,side:e.side},t={lineNumber:e.end,side:e.endSide??e.side},i=this.selectionPointRowIndex(n),a=this.selectionPointRowIndex(t);if(!(i==null||a==null))return i>a?{top:t,bottom:n}:{top:n,bottom:t}}selectionPointRowIndex(e){const n=this.getLineIndex(e.lineNumber,e.side);if(n!=null)return this.isSplitDiff()?n[1]:n[0]}targetForSelectionPoint(e){if(this.pre==null)return;const n=this.getLineIndex(e.lineNumber,e.side);if(n==null)return;const t=this.mode==="diff"?`${n[0]},${n[1]}`:`${n[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${t}"]`);for(const a of i){if(!(a instanceof HTMLElement))continue;const r=this.resolvePointerTarget(L(a));if(w(r)&&!(this.mode==="diff"&&e.side!=null&&r.side!==e.side))return r}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||(document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&(document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1)}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){this.pointerSession.mode==="pendingSingleLineUnselect"&&(this.pointerSession={mode:"idle"})}selectionInfoFromPath(e,n){const t=this.resolvePointerTarget(e);if(w(t)&&!(n&&!t.numberColumn)&&t.splitLineIndex!=null)return{lineIndex:t.splitLineIndex,lineNumber:t.lineNumber,eventSide:this.mode==="diff"?t.side:void 0}}resolveSelectionInfo(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionInfoFromPath(t,n.requireNumberColumn):void 0}selectionPointFromPath(e){const n=this.resolvePointerTarget(e);if(w(n))return{lineNumber:n.lineNumber,side:this.mode==="diff"?n.side:void 0}}resolveSelectionPoint(e,n){const t=this.resolveSelectionPath(e,n);return t!=null?this.selectionPointFromPath(t):void 0}resolveSelectionPath(e,n){const t=n.excludeUtility!==!1;switch(n.source){case"event-path":return this.pathFromEventPath(e.composedPath(),t);case"coordinates-first":{const i=this.pathFromCoordinates(e,t);return i!==void 0?i??void 0:this.pathFromEventPath(e.composedPath(),t)}}}pathFromCoordinates(e,n){const t=this.hitTest(e);if(t!==void 0)return t===null?null:this.pathFromElement(t,n)??null}pathFromEventPath(e,n){if(!(n&&E(e))){for(const t of e)if(t instanceof Element)return this.pathFromElement(t,n)}}pathFromElement(e,n){const t=L(e);if(n&&E(t))return;const i=fe(e);return i!=null?L(i):this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){const n=ue(ce(e));if(n==null)return;const t=this.targetForSelectionPoint(n);return t!=null?L(t.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;const n=this.pre?.getRootNode(),t=z(n)?n:z(document)?document:void 0;if(t!=null)return t.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,n){const{getLineIndex:t}=this.options;return t!=null?t(e,n):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,n,t=!0){const i=this.getCurrentSelectionRange();let a;if(e==null)a=null;else{const r=this.selectionAnchor?.side??n,s=this.selectionAnchor?.lineNumber??e;a=this.buildSelectionRange(s,e,r,n)}H(i??void 0,a??void 0)||(this.activeLineHighlightSide=void 0,this.activeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=a:(this.selectedRange=a,this.queuedSelectionRender??=requestAnimationFrame(this.renderSelection)),this.placeUtility(),t&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,n){if(this.pre==null)return;const t=this.getLineIndex(e.start,e.side),i=this.getLineIndex(e.end,e.endSide??e.side);return t!=null&&i!=null?{start:n?t[1]:t[0],end:n?i[1]:i[0]}:void 0}highlightLineNumberOnly(){return this.activeLineHighlightSide!=null?this.activeLineNumberOnly:this.activeLineNumberOnly||this.editorAttached}renderSelection=()=>{if(this.queuedSelectionRender!=null&&(cancelAnimationFrame(this.queuedSelectionRender),this.queuedSelectionRender=void 0),this.pre==null||this.renderedSelectionRange===this.selectedRange)return;const e=this.pre.querySelectorAll("[data-selected-line]");for(const o of e)o.removeAttribute("data-selected-line");if(this.renderedSelectionRange=this.selectedRange,this.selectedRange==null)return;const{children:n}=this.pre;if(n.length===0)return;if(n.length>2)throw console.error(n),new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");const t=this.pre.getAttribute("data-diff-type")==="split",i=this.getIndexesFromSelection(this.selectedRange,t);if(i==null)throw console.error({rowRange:i,selectedRange:this.selectedRange}),new Error("InteractionManager.renderSelection: No valid rowRange");const a=i.start===i.end,r=Math.min(i.start,i.end),s=Math.max(i.start,i.end),l=this.highlightLineNumberOnly();for(const o of n){const d=this.activeLineHighlightSide;if(d!=null&&(d==="additions"&&o.hasAttribute("data-deletions")||d==="deletions"&&o.hasAttribute("data-additions")))continue;const[c,m]=o.children,h=m.children.length;if(h!==c.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");for(let f=0;f<h;f++){const u=m.children[f],v=c.children[f];if(!(u instanceof HTMLElement)||!(v instanceof HTMLElement))continue;const b=this.parseLineIndex(u,t);if((b??0)>s)break;if(b==null||b<r)continue;let g=a?"single":b===r?"first":b===s?"last":"";v.setAttribute("data-selected-line",g),!l&&(u.setAttribute("data-selected-line",g),v.nextSibling instanceof HTMLElement&&u.nextSibling instanceof HTMLElement&&(u.nextSibling.hasAttribute("data-line-annotation")||u.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(a?(g="last",u.setAttribute("data-selected-line","first")):b===r?g="":b===s&&u.setAttribute("data-selected-line",""),u.nextSibling.setAttribute("data-selected-line",g),v.nextSibling.setAttribute("data-selected-line",g)))}}};notifySelectionCommitted(){this.options.onLineSelected?.(this.getCurrentSelectionRange()??null)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode==="file"?{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:"diff-line",annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}){return this.mode==="file"?{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,tokenElement:a,tokenText:r}:{type:"token",lineCharEnd:e,lineCharStart:n,lineNumber:t,side:i,tokenElement:a,tokenText:r}}buildSelectedLineRange(e,n){return this.buildSelectionRange(e.lineNumber,n.lineNumber,e.side,n.side)}buildSelectionRange(e,n,t,i){return{start:e,end:n,...t!=null?{side:t}:{},...t!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(e){let n=!1,t,i,a,r,s,l,o,d,c,m;for(const f of e){if(!(f instanceof HTMLElement))continue;if(m==null&&f.hasAttribute("data-merge-conflict-action")){const g=f.getAttribute("data-merge-conflict-action")??void 0,y=f.getAttribute("data-merge-conflict-conflict-index")??void 0,x=y!=null?Number.parseInt(y,10):NaN;le(g)&&Number.isFinite(x)&&(m={kind:"merge-conflict-action",resolution:g,conflictIndex:x})}if(l==null&&f.hasAttribute("data-char")){l=f;const g=f.getAttribute("data-char");if(g!=null){const y=Number.parseInt(g,10);if(!Number.isNaN(y)){const x=f.textContent??"",N=y+x.length;(x.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(o={tokenElement:l,lineCharStart:y,lineCharEnd:N,tokenText:x});continue}}}const u=s==null?f.getAttribute("data-column-number")??void 0:void 0;if(u!=null){s=f,c=Number.parseInt(u,10),n=!0,t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}const v=a==null?f.getAttribute("data-line")??void 0:void 0;if(v!=null){a=f,c=Number.parseInt(v,10),t=O(f),r=f.getAttribute("data-line-index")??void 0;continue}if(d==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:f.hasAttribute("data-expand-up")?"up":f.hasAttribute("data-expand-down")?"down":"both",all:f.hasAttribute("data-expand-all-button")};continue}const b=d!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&b!=null){const g=Number.parseInt(b,10);Number.isNaN(g)||(d.hunkIndex=g);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(m!=null)return m;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(a??=r!=null?D(i,`[data-line][data-line-index="${r}"]`):void 0,s??=r!=null?D(i,`[data-column-number][data-line-index="${r}"]`):void 0,i==null||a==null||s==null||t==null||c==null||Number.isNaN(c))return;const h=this.parseLineIndex(a,this.isSplitDiff());return o!=null?this.mode==="file"?{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h,...o}:{kind:"token",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h,...o}:this.mode==="file"?{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:void 0,splitLineIndex:h}:{kind:"line",lineType:t,lineElement:a,lineNumber:c,numberColumn:n,numberElement:s,side:F(t,i),splitLineIndex:h}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,n){const t=(e.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(n&&t.length===2)return t[1];if(!n)return t[0]}};function Me({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:n,lineHoverHighlight:t,onGutterUtilityClick:i,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:m,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y},x,N,W){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:oe({enableGutterUtility:n,renderGutterUtility:m,onGutterUtilityClick:i}),usesCustomGutterUtility:m!=null,lineHoverHighlight:t,onGutterUtilityClick:i,onHunkExpand:x,onMergeConflictActionClick:W,onLineClick:a,onLineEnter:r,onLineLeave:s,onLineNumberClick:l,onTokenClick:o,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:u,onLineSelected:v,onLineSelectionStart:b,onLineSelectionChange:g,onLineSelectionEnd:y,getLineIndex:N}}function oe({enableGutterUtility:e,renderGutterUtility:n,onGutterUtilityClick:t}){if(t!=null&&n!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return e??!1}function w(e){return e!=null&&"kind"in e&&e.kind==="line"}function A(e){return e!=null&&"kind"in e&&e.kind==="token"}function T(e){return w(e)||A(e)}function se(e){return"type"in e&&e.type==="line-info"}function de(e){return"kind"in e&&e.kind==="merge-conflict-action"}function le(e){return e==="current"||e==="incoming"||e==="both"}function D(e,n){const t=e?.querySelector(n);return t instanceof HTMLElement?t:void 0}function L(e){const n=[];let t=e;for(;t!=null;)n.push(t),t=t.parentNode;return n}function fe(e){const n=e.closest("[data-line], [data-column-number]");if(n instanceof HTMLElement)return n;const t=e.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');if(!(t instanceof HTMLElement))return;const i=t.previousElementSibling;return i instanceof HTMLElement&&(i.hasAttribute("data-line")||i.hasAttribute("data-column-number"))?i:void 0}function ce(e){const n=e.closest('[slot^="annotation-"]');if(n instanceof HTMLElement)return n.getAttribute("slot")??void 0;if(e instanceof HTMLElement){const t=e.getAttribute("name")??void 0;return t!=null&&t.startsWith("annotation-")?t:void 0}}function ue(e){if(e==null)return;const n=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(n==null)return;const t=Number.parseInt(n[2],10);if(!(!Number.isFinite(t)||t<=0))return{lineNumber:t,side:n[1]}}function z(e){return e!=null&&typeof e.elementFromPoint=="function"}function F(e,n){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return n.hasAttribute("data-deletions")?"deletions":"additions"}}function O(e){const n=e.getAttribute("data-line-type");if(n!=null)switch(n){case"change-deletion":case"change-addition":case"context":case"context-expanded":return n;default:return}}function E(e){for(const n of e)if(n instanceof HTMLElement&&(n.hasAttribute("data-utility-button")||n.hasAttribute("data-gutter-utility-slot")||n.getAttribute("slot")==="gutter-utility-slot"||n.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}function k(e="none",n,...t){switch(e){case"none":return;case"both":break;case"click":if(n!=="click")return;break;case"move":if(n!=="move")return;break}console.log(...t)}var Ue=class S{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){const n=S.resizeObserver??new ResizeObserver(S.handleSharedResizeEntries);return S.resizeObserver=n,n}static handleSharedResizeEntries(n){const t=new Map;for(const i of n){const a=S.managersByElement.get(i.target);if(a==null)continue;const r=t.get(a);r==null?t.set(a,[i]):r.push(i)}for(const[i,a]of t)i.handleResizeEntries(a)}observedNodes=new Map;setup(n,t){const i=new Set;let a=0;const r=new Map(this.observedNodes);this.observedNodes.clear();for(const s of n.children){if(a===2)break;const l=(()=>{if(s instanceof HTMLElement&&s.tagName==="CODE")return s})();if(l==null)continue;a++;let o=r.get(l);if(o!=null&&o.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let d=l.firstElementChild;d instanceof HTMLElement||(d=null),o!=null?(this.observedNodes.set(l,o),r.delete(l),o.numberElement!==d?(o.numberElement!=null&&(this.unobserve(o.numberElement),r.delete(o.numberElement)),d!=null&&(this.observe(d),r.delete(d),this.observedNodes.set(d,o)),o.numberElement=d,o.numberWidth=0):o.numberElement!=null?(r.delete(o.numberElement),this.observedNodes.set(o.numberElement,o)):o.numberWidth=0):(o={type:"code",codeElement:l,numberElement:d,codeWidth:"auto",numberWidth:0},this.observedNodes.set(l,o),this.observe(l),d!=null&&(this.observedNodes.set(d,o),this.observe(d)))}if(a>1&&!t){const s=n.querySelectorAll('[data-line-annotation*=","]'),l=new Map;for(const o of s){if(!(o instanceof HTMLElement))continue;const d=o.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(d)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:d,element:o});continue}let c=l.get(d);c==null&&(c=[],l.set(d,c)),c.push(o)}for(const[o,d]of l){if(d.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",o,d);continue}const[c,m]=d,h=c.firstElementChild,f=m.firstElementChild;if(!(c instanceof HTMLElement)||!(m instanceof HTMLElement)||!(h instanceof HTMLElement)||!(f instanceof HTMLElement))continue;let u=r.get(h);if(u!=null){this.observedNodes.set(h,u),this.observedNodes.set(f,u),r.delete(h),r.delete(f);continue}const v=h.getBoundingClientRect().height,b=f.getBoundingClientRect().height;u={type:"annotations",column1:{container:c,child:h,childHeight:v},column2:{container:m,child:f,childHeight:b},currentHeight:"auto"},i.add({child1:h,child2:f,item:u,newHeight:Math.max(v,b)})}for(const o of i)this.applyNewHeight(o.item,o.newHeight),this.observedNodes.set(o.child1,o.item),this.observedNodes.set(o.child2,o.item),this.observe(o.child1),this.observe(o.child2);i.clear()}for(const[s,l]of r)this.unobserve(s),l.type==="code"?ge(l):pe(l);r.clear()}cleanUp(){for(const n of this.observedNodes.keys())this.unobserve(n);this.observedNodes.clear()}observe(n){const{managersByElement:t}=S,i=t.get(n);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");t.set(n,this),S.getResizeObserver().observe(n)}}unobserve(n){const{managersByElement:t,resizeObserver:i}=S,a=t.get(n);if(a!=null){if(a!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");t.delete(n),i?.unobserve(n),i!=null&&t.size===0&&(i.disconnect(),S.resizeObserver=void 0)}}handleResizeEntries(n){const t=new Map,i=new Set;for(const a of n){const{target:r,borderBoxSize:s,contentBoxSize:l}=a;if(!(r instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",a);continue}const o=this.observedNodes.get(r);if(o==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",a);continue}if(o.type==="annotations"){const d=(()=>{if(r===o.column1.child)return o.column1;if(r===o.column2.child)return o.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:o,target:r});continue}d.childHeight=s[0].blockSize,i.add(o)}else if(o.type==="code"){const d=t.get(o)??{},c=l[0].inlineSize;r===o.codeElement?d.codeInlineSize=c:r===o.numberElement&&(d.numberInlineSize=c),t.set(o,d)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(n){for(const t of n)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=n=>{for(const[t,i]of n){const a=i.codeInlineSize!=null?he(i.codeInlineSize):t.codeWidth,r=i.numberInlineSize!=null?me(i.numberInlineSize):t.numberWidth,s=a!==t.codeWidth,l=r!==t.numberWidth;if(!(!s&&!l)&&(t.codeWidth=a,t.numberWidth=r,s&&t.codeElement.style.setProperty("--diffs-column-width",`${typeof a=="number"?`${a}px`:"auto"}`),l&&t.codeElement.style.setProperty("--diffs-column-number-width",`${r===0?"auto":`${r}px`}`),s||l&&a!=="auto")){const o=typeof a=="number"?Math.max(a-r,0):0;t.codeElement.style.setProperty("--diffs-column-content-width",`${o>0?`${o}px`:"auto"}`)}}};applyNewHeight(n,t){t!==n.currentHeight&&(n.currentHeight=Math.max(t,0),n.column1.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`),n.column2.container.style.setProperty("--diffs-annotation-min-height",`${n.currentHeight}px`))}};function he(e){const n=Math.max(Math.floor(e),0);return n===0?"auto":n}function me(e){return Math.max(Math.ceil(e),0)}function ge(e){e.codeElement.isConnected&&(e.codeElement.style.removeProperty("--diffs-column-content-width"),e.codeElement.style.removeProperty("--diffs-column-number-width"),e.codeElement.style.removeProperty("--diffs-column-width"))}function pe(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty("--diffs-annotation-min-height"),e.column2.container.isConnected&&e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function Re(e){for(const n of Array.isArray(e)?e:[e])if(!(n==="text"||n==="ansi")&&!ne.has(n))return!1;return!0}function He(e){for(const n of G(e))if(!te.has(n))return!1;return!0}function De(e,n){return e==null||n==null?e===n:e.startingLine===n.startingLine&&e.totalLines===n.totalLines&&e.bufferBefore===n.bufferBefore&&e.bufferAfter===n.bufferAfter}function ze(e){return p({tagName:"div",children:[p({tagName:"div",children:e.annotations?.map(n=>p({tagName:"slot",properties:{name:n}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function be(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}function Fe({fileOrDiff:e,mode:n,stickyHeader:t}){const i="type"in e?e:void 0,a={"data-diffs-header":n,"data-change-type":i?.type,"data-sticky":t?"":void 0};return p({tagName:"div",children:[n==="custom"?p({tagName:"slot",properties:{name:V}}):ve({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:i?.type??"file"}),...n==="custom"?[]:[xe(i)]],properties:a})}function ve({name:e,prevName:n,iconType:t}){const i=[p({tagName:"slot",properties:{name:Y}}),I({name:be(t),properties:{"data-change-icon":t}})];return n!=null&&(i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(n)]})],properties:{"data-prev-name":""}})),i.push(I({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(p({tagName:"div",children:[p({tagName:"bdi",children:[C(e)]})],properties:{"data-title":""}})),i.push(p({tagName:"slot",properties:{name:K}})),p({tagName:"div",children:i,properties:{"data-header-content":""}})}function xe(e){const n=[];if(e!=null){let t=0,i=0;for(const a of e.hunks)t+=a.additionLines,i+=a.deletionLines;(i>0||t===0)&&n.push(p({tagName:"span",children:[C(`-${i}`)],properties:{"data-deletions-count":""}})),(t>0||i===0)&&n.push(p({tagName:"span",children:[C(`+${t}`)],properties:{"data-additions-count":""}}))}return n.push(p({tagName:"slot",properties:{name:j}})),p({tagName:"div",children:n,properties:{"data-metadata":""}})}function Oe(e){return p({tagName:"pre",properties:ye(e)})}function ye({diffIndicators:e,disableBackground:n,disableLineNumbers:t,overflow:i,split:a,totalLines:r,type:s,customProperties:l}){return{...l,"data-diff":s==="diff"?"":void 0,"data-file":s==="file"?"":void 0,"data-diff-type":s==="diff"?a?"split":"single":void 0,"data-overflow":i,"data-disable-line-numbers":t?"":void 0,"data-background":n?void 0:"","data-indicators":e==="bars"||e==="classic"?e:void 0,tabIndex:0,style:`--diffs-min-number-column-width-default:${`${r}`.length}ch;`}}function Be(e,{theme:n,preferredHighlighter:t="shiki-js"}){return{langs:[e??"text"],themes:G(n),preferredHighlighter:t}}function $e(e){return`annotation-${"side"in e?`${e.side}-`:""}${e.lineNumber}`}const Ge="-1,-1";function _e(e){return e?.some(n=>n.lineNumber===0)??!1}function qe(e){const n=e[0];return n!=null&&n.length>0?n:void 0}function We(e){return e.startingLine===0&&e.totalLines>0}function Ve(e,n){return p({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${n}`}})}function Ye(e){return e.useTokenTransformer===!0||e.onTokenClick!=null||e.onTokenEnter!=null||e.onTokenLeave!=null}const Ke=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
2
2
|
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
3
3
|
<path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
|
|
4
4
|
</symbol>
|
package/dist/index.html
CHANGED
|
@@ -540,16 +540,16 @@
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
</style>
|
|
543
|
-
<script type="module" crossorigin src="/assets/main-
|
|
543
|
+
<script type="module" crossorigin src="/assets/main-C-nlfc4f.js"></script>
|
|
544
544
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
545
545
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-DASdDPIk.js">
|
|
546
546
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-CUi8eEds.js">
|
|
547
547
|
<link rel="modulepreload" crossorigin href="/assets/vendor-clsx-B-dksMZM.js">
|
|
548
548
|
<link rel="modulepreload" crossorigin href="/assets/vendor-tailwind-merge-CPcsbTWB.js">
|
|
549
549
|
<link rel="modulepreload" crossorigin href="/assets/vendor-fuse.js-Dw8P0qyA.js">
|
|
550
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
551
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeSurface-
|
|
552
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
550
|
+
<link rel="modulepreload" crossorigin href="/assets/index-D4n3TVp2.js">
|
|
551
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeSurface-k1Eit61v.js">
|
|
552
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BwoW_-vk.css">
|
|
553
553
|
<link rel="stylesheet" crossorigin href="/assets/vendor-katex-css-Cp579UoJ.css">
|
|
554
554
|
</head>
|
|
555
555
|
<body class="h-full bg-background text-foreground">
|
package/dist/mini-chat.html
CHANGED
|
@@ -89,15 +89,15 @@
|
|
|
89
89
|
}
|
|
90
90
|
</style>
|
|
91
91
|
|
|
92
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
92
|
+
<script type="module" crossorigin src="/assets/miniChat-b8DbqBHL.js"></script>
|
|
93
93
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
94
94
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-DASdDPIk.js">
|
|
95
95
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-CUi8eEds.js">
|
|
96
96
|
<link rel="modulepreload" crossorigin href="/assets/vendor-clsx-B-dksMZM.js">
|
|
97
97
|
<link rel="modulepreload" crossorigin href="/assets/vendor-tailwind-merge-CPcsbTWB.js">
|
|
98
98
|
<link rel="modulepreload" crossorigin href="/assets/vendor-fuse.js-Dw8P0qyA.js">
|
|
99
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
100
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
99
|
+
<link rel="modulepreload" crossorigin href="/assets/index-D4n3TVp2.js">
|
|
100
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BwoW_-vk.css">
|
|
101
101
|
<link rel="stylesheet" crossorigin href="/assets/vendor-katex-css-Cp579UoJ.css">
|
|
102
102
|
</head>
|
|
103
103
|
<body class="h-full bg-background text-foreground">
|
package/dist/mobile.html
CHANGED
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
})();
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-BDDUPrDt.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-DASdDPIk.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-CUi8eEds.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="/assets/vendor-clsx-B-dksMZM.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="/assets/vendor-tailwind-merge-CPcsbTWB.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="/assets/vendor-fuse.js-Dw8P0qyA.js">
|
|
73
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
74
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
73
|
+
<link rel="modulepreload" crossorigin href="/assets/index-D4n3TVp2.js">
|
|
74
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BwoW_-vk.css">
|
|
75
75
|
<link rel="stylesheet" crossorigin href="/assets/vendor-katex-css-Cp579UoJ.css">
|
|
76
76
|
</head>
|
|
77
77
|
<body class="h-full bg-background text-foreground">
|
package/package.json
CHANGED
|
@@ -25,11 +25,17 @@ Ephemeral Cloudflare quick tunnels were removed; this module is unaffected.
|
|
|
25
25
|
- `service.js`: `createTailscaleService` — persisted config, lifecycle
|
|
26
26
|
(apply on start, remove on stop, reconcile on change), crash-safe mapping
|
|
27
27
|
record, probe-before-advertise (direct fetch plus the `tailscale nc`
|
|
28
|
-
tailnet-path fallback), approval wait,
|
|
28
|
+
tailnet-path fallback), approval wait, the status model, and the
|
|
29
|
+
public-DNS watcher for Funnel (public) `active`. All
|
|
29
30
|
process execution goes through the injected `runner` (argument arrays, no
|
|
30
31
|
shell, bounded timeouts), and the tailnet-path probe goes through the
|
|
31
32
|
injected `tailnetHealthFetch` (built from the resolved executable by
|
|
32
33
|
default); tests inject fakes for both.
|
|
34
|
+
- `public-dns.js`: `createResolvePublicDns` / `defaultResolvePublicDns` —
|
|
35
|
+
public-DNS readiness check for Funnel (public) `active`. Queries A and
|
|
36
|
+
AAAA for the MagicDNS hostname against public resolvers (1.1.1.1,
|
|
37
|
+
8.8.8.8) with a 3s timeout and a single try, and maps the outcome to
|
|
38
|
+
`'found' | 'not-found' | 'error'`. Never throws; sends only the hostname.
|
|
33
39
|
- `nc-probe.js`: `createTailscaleNcHealthFetch` — the tailnet-path fallback
|
|
34
40
|
for the self-probe. Spawns `tailscale nc <host> <port>`, runs a real TLS
|
|
35
41
|
handshake over the child's stdio, and performs the same credential-free
|
|
@@ -191,9 +197,17 @@ loopback-proxies-bypass-auth hole.
|
|
|
191
197
|
|
|
192
198
|
`{ installed, running /* BackendState Running */, loggedIn, magicDnsName,
|
|
193
199
|
httpsCertsAvailable /* from CertDomains when present, else null */,
|
|
194
|
-
config: { enabled, mode, httpsPort }, state, url, approvalUrl, errorCode,
|
|
200
|
+
config: { enabled, mode, httpsPort }, state, url, publicDns, approvalUrl, errorCode,
|
|
195
201
|
errorMessage, authGate: { privateAllowed, publicAllowed } }`
|
|
196
202
|
|
|
203
|
+
`publicDns` is `'pending' | 'ready' | 'unknown' | null`, non-null ONLY while
|
|
204
|
+
`config.mode === 'public'` AND `state === 'active'` (otherwise `null`).
|
|
205
|
+
`pending` means the Funnel mapping is live for tailnet devices but the
|
|
206
|
+
public DNS record is not yet visible from the public internet; `ready`
|
|
207
|
+
means the record was found; `unknown` means the last check failed
|
|
208
|
+
(timeouts, network errors, refused) while polling continues. Missing on
|
|
209
|
+
older servers (the UI treats a missing field as `null`).
|
|
210
|
+
|
|
197
211
|
`authGate` is computed with `checkTailscaleAuthGate` for each mode: private
|
|
198
212
|
may stay allowed via `PICHAMBER_ALLOW_UNAUTHENTICATED_LAN`, public never is.
|
|
199
213
|
The UI disables each mode individually from these flags before the user
|
|
@@ -217,9 +231,10 @@ reports this server's `serverId` — the stable relay signing-key identity
|
|
|
217
231
|
address BEFORE sending a bearer token). `settings.json` is portable (copied
|
|
218
232
|
between hosts) and must never hold host identity. The probe compares against
|
|
219
233
|
the injected `getServerId` (a null/throwing id fails the probe, so the URL
|
|
220
|
-
stays `starting` and is never advertised).
|
|
221
|
-
|
|
222
|
-
|
|
234
|
+
stays `starting` and is never advertised). `starting` keeps re-probing the
|
|
235
|
+
mapping itself with backoff for up to ~10 minutes (probe-before-advertise);
|
|
236
|
+
public DNS readiness for first-use Funnel links is reported separately via
|
|
237
|
+
`publicDns` (see below) and never blocks `active`.
|
|
223
238
|
|
|
224
239
|
When the direct fetch THROWS without an HTTP response (DNS/connect/abort —
|
|
225
240
|
typical on hosts running tailscaled with `--tun=userspace-networking` or
|
|
@@ -233,6 +248,20 @@ override it. For public (funnel) mode the fallback still verifies over the
|
|
|
233
248
|
tailnet path, not the public internet path — it proves the mapping fronts
|
|
234
249
|
this server, not that the public URL is reachable.
|
|
235
250
|
|
|
251
|
+
Public-DNS watcher: when a reconcile reaches `active` in public mode, the
|
|
252
|
+
service sets `publicDns: 'pending'` and starts a watcher for
|
|
253
|
+
`hostInfo.magicDnsName` (no trailing dot) through the injected
|
|
254
|
+
`resolvePublicDns` (public resolvers, never the host resolver): an immediate
|
|
255
|
+
check, then every 30s for the first 20 minutes, then every 2 minutes, until
|
|
256
|
+
`'found'`. `'found'` → `ready` and the watcher stops; `'not-found'` → stay
|
|
257
|
+
`pending`; `'error'` → `'unknown'` (polling continues; a later `'not-found'`
|
|
258
|
+
returns to `'pending'`, `'found'` to `'ready'`). The watcher is tied to the
|
|
259
|
+
reconcile generation exactly like `probeTimer`: any `bumpGeneration()`
|
|
260
|
+
(config change, retry, shutdown, dispose) stops it, timers are `unref()`'d,
|
|
261
|
+
and a stale result after a generation bump never writes status. Tailnet
|
|
262
|
+
devices can use the URL immediately; internet users may see NXDOMAIN until
|
|
263
|
+
`ready` (~10–15 minutes on first use).
|
|
264
|
+
|
|
236
265
|
Error codes: `auth_required` | `not_installed` | `not_running` |
|
|
237
266
|
`not_logged_in` | `permission_denied` (`sudo tailscale set --operator=$USER`)
|
|
238
267
|
| `needs_approval` | `conflict` | `apply_failed` | `remove_failed`
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public DNS readiness check for Tailscale Funnel (public) mode.
|
|
3
|
+
*
|
|
4
|
+
* When Funnel is first enabled, Tailscale takes ~10-15 minutes to publish
|
|
5
|
+
* the public DNS record for `<machine>.<tailnet>.ts.net`. The host's own
|
|
6
|
+
* resolver must NOT be used to check this:
|
|
7
|
+
*
|
|
8
|
+
* - A host using MagicDNS resolves the name to the tailnet IP immediately,
|
|
9
|
+
* so it can never show public readiness.
|
|
10
|
+
* - A host resolver may also have cached the negative (NXDOMAIN) answer.
|
|
11
|
+
*
|
|
12
|
+
* Instead this module queries public resolvers (1.1.1.1, 8.8.8.8) directly.
|
|
13
|
+
* It sends only the hostname — no credentials, nothing else.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import dns from 'node:dns';
|
|
17
|
+
|
|
18
|
+
const PUBLIC_DNS_SERVERS = ['1.1.1.1', '8.8.8.8'];
|
|
19
|
+
const PUBLIC_DNS_TIMEOUT_MS = 3000;
|
|
20
|
+
|
|
21
|
+
const isNotFoundCode = (code) => code === 'ENOTFOUND' || code === 'ENODATA';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a `resolvePublicDns` function with an injectable Resolver factory
|
|
25
|
+
* (tests inject a fake; production uses `dns.promises.Resolver`).
|
|
26
|
+
*
|
|
27
|
+
* Returns `async (hostname) => 'found' | 'not-found' | 'error'`. Never throws.
|
|
28
|
+
*/
|
|
29
|
+
export const createResolvePublicDns = ({ createResolver } = {}) => {
|
|
30
|
+
const newResolver = createResolver
|
|
31
|
+
|| ((options) => new dns.promises.Resolver(options));
|
|
32
|
+
return async (hostname) => {
|
|
33
|
+
try {
|
|
34
|
+
if (typeof hostname !== 'string' || hostname.trim().length === 0) return 'error';
|
|
35
|
+
const name = hostname.trim().replace(/\.$/, '');
|
|
36
|
+
if (!name) return 'error';
|
|
37
|
+
let resolver = null;
|
|
38
|
+
try {
|
|
39
|
+
resolver = newResolver({ timeout: PUBLIC_DNS_TIMEOUT_MS, tries: 1 });
|
|
40
|
+
} catch {
|
|
41
|
+
return 'error';
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
resolver.setServers(PUBLIC_DNS_SERVERS);
|
|
45
|
+
} catch {
|
|
46
|
+
return 'error';
|
|
47
|
+
}
|
|
48
|
+
const settled = await Promise.allSettled([
|
|
49
|
+
resolver.resolve4(name),
|
|
50
|
+
resolver.resolve6(name),
|
|
51
|
+
]);
|
|
52
|
+
try {
|
|
53
|
+
resolver.cancel?.();
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
const found = settled.some(
|
|
57
|
+
(entry) => entry.status === 'fulfilled' && Array.isArray(entry.value) && entry.value.length > 0,
|
|
58
|
+
);
|
|
59
|
+
if (found) return 'found';
|
|
60
|
+
const allNotFound = settled.length > 0 && settled.every(
|
|
61
|
+
(entry) => entry.status === 'rejected' && isNotFoundCode(entry.reason?.code),
|
|
62
|
+
);
|
|
63
|
+
if (allNotFound) return 'not-found';
|
|
64
|
+
return 'error';
|
|
65
|
+
} catch {
|
|
66
|
+
return 'error';
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Production resolver: public resolvers, 3s timeout, single try. Never throws. */
|
|
72
|
+
export const defaultResolvePublicDns = createResolvePublicDns();
|