trident-git 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +11 -11
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/credentials/github/repos/route.js +1 -1
- package/.next/server/app/api/credentials/github/repos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/credentials/route.js +1 -1
- package/.next/server/app/api/credentials/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/custom-scripts/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/open/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/open-terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/action/route.js +1 -1
- package/.next/server/app/api/git/action/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/branches/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/log/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repos/clone/route.js +1 -1
- package/.next/server/app/api/repos/clone/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/credentials/page_client-reference-manifest.js +1 -1
- package/.next/server/app/credentials.html +1 -1
- package/.next/server/app/credentials.rsc +2 -2
- package/.next/server/app/credentials.segments/_full.segment.rsc +2 -2
- package/.next/server/app/credentials.segments/_head.segment.rsc +1 -1
- package/.next/server/app/credentials.segments/_index.segment.rsc +2 -2
- package/.next/server/app/credentials.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/credentials.segments/credentials/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/credentials.segments/credentials.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/changes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/changes.html +1 -1
- package/.next/server/app/workspace/changes.rsc +2 -2
- package/.next/server/app/workspace/changes.segments/_full.segment.rsc +2 -2
- package/.next/server/app/workspace/changes.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace/changes.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace/changes.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace/changes.segments/workspace/changes/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/workspace/changes.segments/workspace/changes.segment.rsc +1 -1
- package/.next/server/app/workspace/changes.segments/workspace.segment.rsc +1 -1
- package/.next/server/app/workspace/conflicts/page.js +1 -1
- package/.next/server/app/workspace/conflicts/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/conflicts.html +1 -1
- package/.next/server/app/workspace/conflicts.rsc +2 -2
- package/.next/server/app/workspace/conflicts.segments/_full.segment.rsc +2 -2
- package/.next/server/app/workspace/conflicts.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace/conflicts.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace/conflicts.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace/conflicts.segments/workspace/conflicts/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/workspace/conflicts.segments/workspace/conflicts.segment.rsc +1 -1
- package/.next/server/app/workspace/conflicts.segments/workspace.segment.rsc +1 -1
- package/.next/server/app/workspace/custom-scripts/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/custom-scripts.html +1 -1
- package/.next/server/app/workspace/custom-scripts.rsc +2 -2
- package/.next/server/app/workspace/custom-scripts.segments/_full.segment.rsc +2 -2
- package/.next/server/app/workspace/custom-scripts.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace/custom-scripts.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace/custom-scripts.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace/custom-scripts.segments/workspace/custom-scripts/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/workspace/custom-scripts.segments/workspace/custom-scripts.segment.rsc +1 -1
- package/.next/server/app/workspace/custom-scripts.segments/workspace.segment.rsc +1 -1
- package/.next/server/app/workspace/history/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/history.html +1 -1
- package/.next/server/app/workspace/history.rsc +3 -3
- package/.next/server/app/workspace/history.segments/_full.segment.rsc +3 -3
- package/.next/server/app/workspace/history.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace/history.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace/history.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace/history.segments/workspace/history/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/workspace/history.segments/workspace/history.segment.rsc +1 -1
- package/.next/server/app/workspace/history.segments/workspace.segment.rsc +1 -1
- package/.next/server/app/workspace/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/settings.html +1 -1
- package/.next/server/app/workspace/settings.rsc +2 -2
- package/.next/server/app/workspace/settings.segments/_full.segment.rsc +2 -2
- package/.next/server/app/workspace/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace/settings.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace/settings.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace/settings.segments/workspace/settings/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/workspace/settings.segments/workspace/settings.segment.rsc +1 -1
- package/.next/server/app/workspace/settings.segments/workspace.segment.rsc +1 -1
- package/.next/server/app/workspace/stashes/page.js +1 -1
- package/.next/server/app/workspace/stashes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/workspace/stashes.html +1 -1
- package/.next/server/app/workspace/stashes.rsc +2 -2
- package/.next/server/app/workspace/stashes.segments/_full.segment.rsc +2 -2
- package/.next/server/app/workspace/stashes.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace/stashes.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace/stashes.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace/stashes.segments/workspace/stashes/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/workspace/stashes.segments/workspace/stashes.segment.rsc +1 -1
- package/.next/server/app/workspace/stashes.segments/workspace.segment.rsc +1 -1
- package/.next/server/app/workspace.html +1 -1
- package/.next/server/app/workspace.rsc +3 -3
- package/.next/server/app/workspace.segments/_full.segment.rsc +3 -3
- package/.next/server/app/workspace.segments/_head.segment.rsc +1 -1
- package/.next/server/app/workspace.segments/_index.segment.rsc +2 -2
- package/.next/server/app/workspace.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/workspace.segments/workspace/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/workspace.segments/workspace.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +11 -11
- package/.next/server/chunks/392.js +1 -1
- package/.next/server/chunks/471.js +4 -4
- package/.next/server/chunks/764.js +1 -1
- package/.next/server/chunks/781.js +1 -1
- package/.next/server/chunks/809.js +2 -2
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{2944-c04b0be485b3d705.js → 2944-3a21e9fcdcbde59a.js} +6 -6
- package/.next/static/css/{bbef38f40623ee1a.css → 5252d6b6376d39f0.css} +1 -1
- package/package.json +1 -1
- /package/.next/static/{6dJepuRCio_5p_26Y1Tco → 0r-ek2qXgjmDwBoQvuinU}/_buildManifest.js +0 -0
- /package/.next/static/{6dJepuRCio_5p_26Y1Tco → 0r-ek2qXgjmDwBoQvuinU}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2944],{302:(e,t,a)=>{a.d(t,{v:()=>o});var s=a(2115);let l=[],n=0,r=!1;function i(e){let t,a=(t=l[l.length-1])||null;if(a){if("Escape"===e.key){e.preventDefault(),a.onEscape();return}"Enter"===e.key&&a.onEnter&&!function(e){if(e.defaultPrevented||e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return!0;let t=e.target;if(!t)return!1;if(t.isContentEditable)return!0;let a=t.tagName;return"TEXTAREA"===a||"BUTTON"===a||"SELECT"===a||"OPTION"===a||"A"===a}(e)&&(e.preventDefault(),a.onEnter())}}function o(e,t,a){let o=(0,s.useRef)(t),c=(0,s.useRef)(a);(0,s.useEffect)(()=>{o.current=t},[t]),(0,s.useEffect)(()=>{c.current=a},[a]),(0,s.useEffect)(()=>{if(!e)return;let t=++n;return l.push({id:t,onEscape:()=>o.current(),onEnter:()=>c.current?.()}),!r&&"u">typeof document&&(document.addEventListener("keydown",i),r=!0),()=>{let e=l.findIndex(e=>e.id===t);e>=0&&l.splice(e,1),r&&"u">typeof document&&!(l.length>0)&&(document.removeEventListener("keydown",i),r=!1)}},[e])}},2944:(e,t,a)=>{a.d(t,{u:()=>z});var s=a(5155),l=a(696),n=a(5625),r=a(2115);function i(e){let t=0x811c9dc5;for(let a=0;a<e.length;a++)t^=e.charCodeAt(a),t=Math.imul(t,0x1000193);return t>>>0}var o=a(8599);function c({children:e,items:t,containerClassName:a="w-full"}){let[l,n]=(0,r.useState)(!1),[i,c]=(0,r.useState)({x:0,y:0}),d=(0,r.useRef)(null),h=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!l)return;let e=e=>{d.current&&!d.current.contains(e.target)&&h.current&&!h.current.contains(e.target)&&n(!1)},t=e=>{"Escape"===e.key&&n(!1)};return setTimeout(()=>{document.addEventListener("click",e),document.addEventListener("contextmenu",e),document.addEventListener("keydown",t)},0),()=>{document.removeEventListener("click",e),document.removeEventListener("contextmenu",e),document.removeEventListener("keydown",t)}},[l]),(0,r.useEffect)(()=>{if(!l||!d.current)return;let e=d.current;requestAnimationFrame(()=>{let a=document.createElement("div");a.style.position="absolute",a.style.visibility="hidden",a.style.whiteSpace="nowrap",a.style.pointerEvents="none";let s=window.getComputedStyle(e);a.style.fontSize=s.fontSize,a.style.fontFamily=s.fontFamily,a.style.fontWeight=s.fontWeight,a.style.padding="0.5rem 0.75rem",a.style.boxSizing="border-box",document.body.appendChild(a);let l=0;t.forEach(e=>{a.textContent=e.label;let t=a.getBoundingClientRect().width+20*!!e.icon+16*!!e.children?.length;t>l&&(l=t)}),document.body.removeChild(a);let n=Math.max(l+32,280);e.style.width=`${n}px`,e.style.minWidth=`${n}px`;let r=e.getBoundingClientRect(),o=window.innerWidth,c=window.innerHeight,d=i.x,h=i.y;r.right>o&&(d=o-r.width-10),d<10&&(d=10),r.bottom>c&&(h=c-r.height-10),h<10&&(h=10),(d!==i.x||h!==i.y)&&(e.style.left=`${d}px`,e.style.top=`${h}px`)})},[l,i,t]);let m=(e,t)=>{let a=!!e.children?.length;return(0,s.jsxs)("li",{className:(0,o.cn)(a&&"relative group/submenu"),children:[(0,s.jsxs)("a",{onClick:t=>{t.stopPropagation(),e.disabled||a||(e.onClick?.(),n(!1))},className:(0,o.cn)("flex items-center gap-2","whitespace-nowrap",e.danger&&"text-error",e.disabled&&"opacity-40 pointer-events-none",a&&"flex items-center justify-between gap-3"),children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[e.icon&&(0,s.jsx)("span",{className:"inline-flex shrink-0 opacity-80",children:e.icon}),(0,s.jsx)("span",{children:e.labelNode??e.label})]}),a&&(0,s.jsx)("i",{className:"iconoir-nav-arrow-right text-[12px]","aria-hidden":"true"})]}),a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden group-hover/submenu:block absolute left-full top-0 h-full w-3"}),(0,s.jsx)("ul",{className:"hidden group-hover/submenu:block absolute left-[calc(100%-1px)] top-0 menu !m-0 p-2 shadow-lg bg-base-100 rounded-box border border-base-200 min-w-[220px] z-[10000] [&:before]:hidden",children:e.children.map((e,a)=>m(e,`${t}-${a}`))})]})]},t)};return(0,s.jsxs)("div",{ref:h,className:a,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),c({x:e.clientX,y:e.clientY}),n(!0)},children:[e,l&&(0,s.jsx)("ul",{ref:d,className:"fixed z-[9999] menu p-2 shadow-lg bg-base-100 rounded-box border border-base-200",style:{left:`${i.x}px`,top:`${i.y}px`},children:t.map((e,t)=>m(e,`menu-${t}`))})]})}function d({text:e,searchQuery:t}){if(!t||!e)return(0,s.jsx)(s.Fragment,{children:e});let a=t.toLowerCase(),l=e.toLowerCase(),n=[],r=0,i=l.indexOf(a);for(;-1!==i;)i>r&&n.push({text:e.slice(r,i),highlighted:!1}),n.push({text:e.slice(i,i+a.length),highlighted:!0}),r=i+a.length,i=l.indexOf(a,r);return(r<e.length&&n.push({text:e.slice(r),highlighted:!1}),0===n.length)?(0,s.jsx)(s.Fragment,{children:e}):(0,s.jsx)(s.Fragment,{children:n.map((e,t)=>e.highlighted?(0,s.jsx)("mark",{className:"bg-warning text-warning-content rounded-sm px-0.5",children:e.text},t):(0,s.jsx)("span",{children:e.text},t))})}let h=(0,r.forwardRef)(function({commits:e,onSelectCommit:t,onResetToCommit:a,onRevertCommit:l,onCreateTag:n,onCherryPickCommit:h,onCherryPickSelectedCommits:m,onRewordCommit:u,selectedHash:x,selectedHashes:p,onEndReached:f,isLoadingMore:b,currentBranch:g,hiddenBranches:j,localBranches:N=[],trackingInfo:y,getBranchTagContextMenuItems:v},k){let w=(0,r.useCallback)(e=>e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/remotes/")?e.slice(13):e.startsWith("remotes/")?e.slice(8):e,[]),C=(0,r.useCallback)(e=>e.startsWith("tag:")?e.replace(/^tag:\s*/,"").trim():e,[]),S=(0,r.useMemo)(()=>(function(e,t={}){let a=[],s=new Set(t.localBranches??[]),l=[],n=[],r=[];function o(){for(let e=0;e<l.length;e++)if(null===l[e])return e;return l.length}function c(e){let t,a=r[e],s=a?(t=i(a),`hsl(${t%360} 82% 52%)`):n[e]??`hsl(${47*e%360} 78% 56%)`;return n[e]=s,s}return e.forEach((e,i)=>{var d;let h=[];for(let t=0;t<l.length;t++)l[t]===e.hash&&h.push(t);let m=h.length>0?h[0]:-1;for(-1===m&&(m=o());l.length<=m;)l.push(null),r.push(null),n.push(void 0);"__LOCAL_CHANGES__"===e.hash&&t.currentBranch&&(r[m]=t.currentBranch);let u=function(e,t){if(0===e.length)return null;let a=e.find(e=>t.has(e));return a||e[0]}((d=e.refs)?d.replace(/^\s*\((.*)\)\s*$/,"$1").split(",").map(e=>e.trim()).filter(Boolean).map(e=>e.replace(/^HEAD\s*->\s*/,"").trim()).map(e=>e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/remotes/")?e.slice(13):e.startsWith("remotes/")?e.slice(8):e).filter(e=>!e.startsWith("tag:")).filter(e=>"HEAD"!==e).filter(e=>!/\/HEAD$/.test(e)):[],s);if(u){let e=function(e,t){let a,s;if(t.has(e))return e;let l=-1===(s=(a=e.startsWith("remotes/")?e.slice(8):e).indexOf("/"))?null:a.slice(s+1);return l&&t.has(l)?l:e}(u,s);(function(e,t,a){return!t||a.has(e)&&!a.has(t)})(e,r[m],s)&&(r[m]=e)}let x=c(m),p={...e,x:m,y:i,color:x,paths:[],isMerge:e.parents.length>1},f=h.filter(e=>e!==m),b=new Set(f);for(let e=0;e<l.length;e++)e===m||null===l[e]||b.has(e)||p.paths.push({x1:e,y1:i,x2:e,y2:i+1,color:c(e),type:"straight"});for(let e of(l[m]=null,f)){if(i>0){let t=a[a.length-1];t&&(t.paths=t.paths.filter(t=>"straight"!==t.type||t.x1!==e||t.y1!==i-1||t.x2!==e||t.y2!==i))}p.paths.push({x1:e,y1:i-1,x2:m,y2:i,color:c(e),type:"merge"}),l[e]=null,r[e]=null,n[e]=void 0}let g=e.parents;if(g.length>0){let e=g[0];l[m]=e,p.paths.push({x1:m,y1:i,x2:m,y2:i+1,color:x,type:"straight"});for(let e=1;e<g.length;e++){let t=g[e],a=l.indexOf(t);if(-1!==a)p.paths.push({x1:m,y1:i,x2:a,y2:i+1,color:c(a),type:"fork"});else{let e=o();for(;l.length<=e;)l.push(null),r.push(null),n.push(void 0);l[e]=t,p.paths.push({x1:m,y1:i,x2:e,y2:i+1,color:c(e),type:"fork"})}}}null===l[m]&&(r[m]=null,n[m]=void 0),a.push(p)}),a})(e,{localBranches:N,currentBranch:g}),[e,N,g]),E=(0,r.useRef)(null),R=(0,r.useRef)(null),[$,B]=(0,r.useState)(!1),[P,F]=(0,r.useState)("");(0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),B(!0),setTimeout(()=>R.current?.focus(),0)),"Escape"===e.key&&$&&(B(!1),F(""))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[$]);let M=(0,r.useCallback)(()=>{B(!1),F("")},[]);if((0,r.useImperativeHandle)(k,()=>({scrollToCommit:e=>{if(!S||0===S.length)return!1;let t=S.findIndex(t=>t.hash===e);if(-1===t)return!1;if(E.current){let e=24*t-E.current.clientHeight/2+12;E.current.scrollTop=Math.max(0,e)}return!0}}),[S]),!S||0===S.length)return null;let A=(Math.max(...S.map(e=>e.x),0)+1)*12+20,D=24*S.length;return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100 overflow-hidden font-mono text-sm select-none",children:[$&&(0,s.jsxs)("div",{className:"sticky top-0 z-30 bg-base-100 border-b border-base-300 px-2 py-2 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"opacity-50",children:"\uD83D\uDD0D"}),(0,s.jsx)("input",{ref:R,type:"text",placeholder:"Search in commits...",value:P,onChange:e=>F(e.target.value),className:"input input-bordered input-sm flex-1 text-sm",autoFocus:!0}),(0,s.jsx)("div",{className:"tooltip tooltip-left z-50","data-tip":"Close search (Esc)",children:(0,s.jsx)("button",{onClick:M,className:"btn btn-ghost btn-sm btn-square",children:"✖️"})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto h-full max-w-full px-2",onScroll:e=>{let{scrollTop:t,clientHeight:a,scrollHeight:s}=e.currentTarget;s-t-a<100&&f?.()},ref:E,children:(0,s.jsxs)("div",{className:"relative min-w-full",style:{height:D},children:[(0,s.jsxs)("svg",{width:A,height:D,className:"absolute top-0 left-0 pointer-events-none z-10",children:[S.map(e=>(0,s.jsx)("g",{children:e.paths.map((e,t)=>{let a=12*e.x1+6,l=24*e.y1+12,n=12*e.x2+6,r=24*e.y2+12,i="";if("straight"===e.type)i=`M ${a} ${l} L ${n} ${r}`;else{let e=l+12,t=r-12;i=`M ${a} ${l} C ${a} ${e}, ${n} ${t}, ${n} ${r}`}return(0,s.jsx)("path",{d:i,stroke:e.color,strokeWidth:2,fill:"none",strokeLinecap:"round"},t)})},e.hash)),S.map(e=>{let t="__LOCAL_CHANGES__"===e.hash;return(0,s.jsx)("circle",{cx:12*e.x+6,cy:24*e.y+12,r:3,fill:t?"var(--fallback-b1, oklch(var(--b1)))":e.color,stroke:e.color,strokeWidth:2,className:t?"fill-base-100":void 0},`dot-${e.hash}`)})]}),(0,s.jsxs)("div",{style:{width:"100%"},children:[S.map(e=>{let r="__LOCAL_CHANGES__"===e.hash,f=p?p.has(e.hash):x===e.hash,b=p?.size??+!!x,k=r?[]:[{label:"Reset to here",icon:(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"}),onClick:()=>a?.(e.hash)}];if(!r&&l&&k.push({label:"Revert commit",icon:(0,s.jsx)("i",{className:"iconoir-u-turn-arrow-left text-[14px]","aria-hidden":"true"}),onClick:()=>l(e.hash,e.message)}),!r&&n&&k.push({label:"Create tag",icon:(0,s.jsx)("i",{className:"iconoir-bookmark text-[14px]","aria-hidden":"true"}),onClick:()=>n(e.hash)}),!r&&h&&k.push({label:"Cherry-pick commit",icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>h(e.hash,e.message)}),!r&&m&&b>1&&f&&k.push({label:`Cherry-pick ${b} selected commits`,icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:m}),!r&&u&&N&&N.length>0){let t=e.refs?e.refs.replace(/[()]/g,"").split(",").map(e=>e.trim()):[],a=null;for(let e of t){let t=e.replace(/^HEAD\s*->\s*/,"");if(N.includes(t)&&(a=t,g&&t===g))break}a&&k.push({label:"Reword commit",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>u(e.hash,e.message,e.body??"",a)})}let S=(()=>{if(!e.refs||r)return[];let t=e.refs.replace(/^\s*\((.*)\)\s*$/,"$1").split(",").map(e=>{let t=e.startsWith("HEAD -> "),a=w(e.replace(/^HEAD\s*->\s*/,"").trim());return{raw:e,name:a,isHead:t}}),a=[],s=new Set,l=e=>j&&(j.has(e)||j.has(`remotes/${e}`));return t.forEach((e,n)=>{if(!s.has(n)&&N.includes(e.name)&&!l(e.name)){let l=y?.[e.name];if(l&&l.upstream){let r=w(l.upstream.trim()),i=new Set([r,w(`remotes/${r}`),w(`refs/remotes/${r}`)]),o=t.findIndex((e,t)=>t!==n&&!s.has(t)&&i.has(e.name));if(-1!==o){let l=t[o],i=r.split("/")[0];a.push({displayName:`${e.name} (${i})`,primaryRef:e.name,secondaryRef:l.name,isHead:e.isHead}),s.add(n),s.add(o);return}}}}),t.forEach((e,t)=>{!s.has(t)&&(l(e.name)||a.push({displayName:C(e.name),primaryRef:e.name,isHead:e.isHead}))}),a})(),E=(0,s.jsxs)("div",{className:(0,o.cn)("flex items-center hover:bg-base-200 border-b border-base-200 last:border-0 cursor-pointer transition-colors text-xs",f&&"bg-primary/10"),style:{height:24},onClick:a=>t?.(e.hash,{isMultiSelect:a.metaKey||a.ctrlKey,isRangeSelect:a.shiftKey}),children:[(0,s.jsx)("div",{style:{width:A,flexShrink:0}}),(0,s.jsxs)("div",{className:"flex flex-1 gap-4 overflow-hidden pr-4 items-center",children:[(0,s.jsxs)("div",{className:"flex-1 truncate flex items-center gap-2",children:[S.map((e,t)=>{let a=g&&(e.primaryRef===g||e.isHead&&e.primaryRef===g),l=e.primaryRef.startsWith("tag:")?{textColor:"#374151",backgroundColor:"#e5e7eb"}:function(e){let t,a,s,l,n,r,o,c,d,h=i(e),m=h%360,u=72+(h>>>9)%20,x=84+(h>>>17)%8,p=1.05/((d=function({r:e,g:t,b:a}){let s=e=>{let t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return .2126*s(e)+.7152*s(t)+.0722*s(a)}((a=u/100*(1-Math.abs(2*(t=x/100)-1)),l=a*(1-Math.abs((s=m/60)%2-1)),n=0,r=0,o=0,s>=0&&s<1?(n=a,r=l):s>=1&&s<2?(n=l,r=a):s>=2&&s<3?(r=a,o=l):s>=3&&s<4?(r=l,o=a):s>=4&&s<5?(n=l,o=a):(n=a,o=l),{r:Math.round((n+(c=t-a/2))*255),g:Math.round((r+c)*255),b:Math.round((o+c)*255)})))+.05)>=(d+.05)/.05?"#ffffff":"#111827";return{backgroundColor:`hsl(${m} ${u}% ${x}%)`,textColor:p}}(e.primaryRef),n=(0,s.jsx)("span",{className:(0,o.cn)("text-[10px] px-1.5 rounded-full whitespace-nowrap shrink-0",a&&"font-bold"),style:{color:l.textColor,backgroundColor:l.backgroundColor},title:e.displayName,children:(0,s.jsx)(d,{text:e.displayName,searchQuery:P})}),r=v?.(e.primaryRef)||[];return 0===r.length?(0,s.jsx)("span",{className:"shrink-0",children:n},t):(0,s.jsx)(c,{items:r,containerClassName:"inline-flex shrink-0",children:n},t)}),(0,s.jsx)("span",{className:(0,o.cn)("truncate min-w-0 max-w-[600px]",r?"italic text-base-content/80":"",f?"font-semibold text-primary":""),title:e.message,children:(0,s.jsx)(d,{text:e.message,searchQuery:P})})]}),(0,s.jsx)("div",{className:"w-32 truncate opacity-70 text-right",children:r?null:(0,s.jsx)(d,{text:e.author_name,searchQuery:P})}),(0,s.jsx)("div",{className:"w-20 truncate opacity-50 font-mono text-right",children:r?null:(0,s.jsx)(d,{text:e.hash.substring(0,7),searchQuery:P})}),(0,s.jsx)("div",{className:"w-32 truncate opacity-70 text-right",children:r?null:new Date(e.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]});return 0===k.length?(0,s.jsx)("div",{children:E},e.hash):(0,s.jsx)(c,{items:k,children:E},e.hash)}),b&&(0,s.jsxs)("div",{className:"flex items-center justify-center py-8 border-b border-base-300",children:[(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"}),(0,s.jsx)("span",{className:"ml-2 text-sm opacity-70",children:"Loading more commits..."})]})]})]})})]})});var m=a(302),u=a(6695),x=a(460),p=a(6162),f=a(4254);function b({status:e}){switch(e){case"A":return(0,s.jsx)("i",{className:"iconoir-plus-circle text-[16px] text-success","aria-hidden":"true"});case"D":return(0,s.jsx)("i",{className:"iconoir-minus-circle text-[16px] text-error","aria-hidden":"true"});case"M":return(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[16px] text-warning","aria-hidden":"true"});default:return(0,s.jsx)("i",{className:"iconoir-page text-[16px] opacity-50","aria-hidden":"true"})}}function g({node:e,selectedFile:t,expandedFolders:a,onToggleFolder:l,onSelectFile:n,depth:r=0}){let i=Array.from(e.children.values()).sort((e,t)=>{let a=e.children.size>0,s=t.children.size>0;return a&&!s?-1:!a&&s?1:e.name.localeCompare(t.name)});return(0,s.jsx)(s.Fragment,{children:i.map(e=>{if(e.children.size>0){let i=a.has(e.path);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 text-xs rounded cursor-pointer hover:bg-base-200 transition-colors opacity-80",style:{paddingLeft:`${12*r+8}px`},onClick:()=>l(e.path),title:e.path,children:[(0,s.jsx)("span",{className:"text-[10px] opacity-70",children:i?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[14px] opacity-70","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e.name})]}),i&&(0,s.jsx)(g,{node:e,selectedFile:t,expandedFolders:a,onToggleFolder:l,onSelectFile:n,depth:r+1})]},e.path)}if(!e.file)return null;let i=e.file;return(0,s.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 px-2 py-1.5 text-xs rounded cursor-pointer hover:bg-base-200 transition-colors",t===i.path&&"bg-base-200 font-medium"),style:{paddingLeft:`${12*r+8}px`},onClick:()=>n(i.path),title:i.path,children:[(0,s.jsx)(b,{status:i.status}),(0,s.jsx)("span",{className:"truncate flex-1 font-mono",children:e.name})]},e.path)})})}function j({repoPath:e,commitHash:t,fromCommitHash:a,toCommitHash:n,filePath:i,splitView:c}){let{data:d,isLoading:h}=(0,l.st)(e,i,{commitHash:t,fromCommitHash:a,toCommitHash:n}),{resolvedTheme:m}=(0,x.D)(),u=`${t??""}:${a??""}:${n??""}:${i}`,[b,g]=(0,r.useState)(null),j=b===u,N=(0,r.useRef)(null);if((0,r.useEffect)(()=>{let e=requestAnimationFrame(()=>{N.current?.scrollTo({top:0,left:0})});return()=>cancelAnimationFrame(e)},[i,t,a,n,h]),h)return(0,s.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})});if(!d)return(0,s.jsx)("div",{className:"flex items-center justify-center p-8 opacity-50",children:"No diff available"});if((0,o.u)(i))return(0,s.jsx)(f.K,{filePath:i,imageDiff:d.imageDiff});if((0,o.kO)(i,d.left,d.right))return(0,s.jsx)("div",{className:"flex items-center justify-center p-8 opacity-50",children:"Binary file - diff not available"});let y=d.diff||"",v=y.length,k=(0,o.tq)(y);return(v>102400||k>3e3)&&!j?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center p-8",children:[(0,s.jsx)("i",{className:"iconoir-warning-triangle text-[32px] text-warning","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Large Diff Detected"}),(0,s.jsxs)("p",{className:"opacity-70",children:["This diff is large (",Math.round(v/1024),"KB, ~",k," changed lines) and may freeze your browser if rendered."]})]}),(0,s.jsx)("button",{className:"btn btn-outline",onClick:()=>g(u),children:"Show Diff Anyway"})]}):(0,s.jsx)("div",{ref:N,className:"overflow-auto h-full",children:(0,s.jsx)(p.O,{oldValue:d.left||"",newValue:d.right||"",splitView:c,useDarkTheme:"dark"===m})})}function N({repoPath:e,commitHash:t=null,fromCommitHash:a=null,toCommitHash:n=null}){let i=!!a&&!!n,c=i?`${a}..${n}`:t??"none",{data:d,isLoading:h}=(0,l.gg)(e,{commitHash:t,fromCommitHash:a,toCommitHash:n}),[u,x]=(0,r.useState)({}),[p,f]=(0,r.useState)(!1),[b,N]=(0,r.useState)({}),y=(0,r.useMemo)(()=>(function(e){let t={name:"",path:"",children:new Map};for(let a of e){let e=a.path.split("/").filter(Boolean),s=t,l="";for(let t=0;t<e.length;t++){let n=e[t];l=l?`${l}/${n}`:n,s.children.has(n)||s.children.set(n,{name:n,path:l,children:new Map}),s=s.children.get(n),t===e.length-1&&(s.file=a)}}return t})(d?.files??[]),[d?.files]),v=(0,r.useMemo)(()=>(function e(t){let a=[];return Array.from(t.children.values()).forEach(t=>{t.children.size>0&&(a.push(t.path),a.push(...e(t)))}),a})(y),[y]),k=(0,r.useMemo)(()=>b[c]??new Set,[b,c]),w="git-web:diff-view-split",[C,S]=(0,r.useState)(()=>{try{let e=localStorage.getItem(w);return null===e||JSON.parse(e)}catch(e){return console.error("Failed to load split view preference:",e),!0}}),E=(0,r.useRef)(null),R=(0,r.useMemo)(()=>{let e=d?.files??[];if(0===e.length)return null;let t=u[c]??null;return t&&e.some(e=>e.path===t)?t:e[0].path},[d?.files,u,c]),$=(0,r.useCallback)(e=>{x(t=>(t[c]??null)===e?t:{...t,[c]:e})},[c]);(0,r.useEffect)(()=>{try{localStorage.setItem(w,JSON.stringify(C))}catch(e){console.error("Failed to save split view preference:",e)}},[C]),(0,r.useEffect)(()=>{if(!R)return;let e=requestAnimationFrame(()=>{E.current?.scrollTo({top:0,left:0})});return()=>cancelAnimationFrame(e)},[R,c]),(0,m.v)(p,()=>f(!1)),(0,r.useEffect)(()=>{if(!p)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[p]);let B=(0,r.useMemo)(()=>{let e=new Set;return v.forEach(t=>{k.has(t)||e.add(t)}),R&&(function(e){let t=e.split("/").filter(Boolean),a=[];for(let e=1;e<t.length;e++)a.push(t.slice(0,e).join("/"));return a})(R).forEach(t=>e.add(t)),e},[v,k,R]),P=(0,r.useCallback)(e=>{N(t=>{let a=new Set(t[c]??new Set);return a.has(e)?a.delete(e):a.add(e),{...t,[c]:a}})},[c]);return h?(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})}):d&&0!==d.files.length?(0,s.jsxs)("div",{className:(0,o.cn)("flex h-full",p&&"fixed inset-0 z-[80] h-auto bg-base-100 shadow-2xl"),children:[(0,s.jsxs)("div",{className:"w-64 border-r border-base-300 flex flex-col bg-base-200/30 shrink-0",children:[(0,s.jsxs)("div",{className:"px-3 py-2 text-xs font-bold opacity-70 border-b border-base-300 bg-base-100",children:[d.files.length," file",1!==d.files.length?"s":""," changed"]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:(0,s.jsx)("div",{className:"p-1",children:(0,s.jsx)(g,{node:y,selectedFile:R,expandedFolders:B,onToggleFolder:P,onSelectFile:$})})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:R?(0,s.jsxs)("div",{className:"h-full flex flex-col",children:[(0,s.jsxs)("div",{className:"px-4 py-2 text-xs font-mono opacity-70 border-b border-base-300 bg-base-100 shrink-0 truncate flex items-center justify-between",children:[(0,s.jsx)("span",{className:"truncate",children:R}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[(0,s.jsx)("label",{htmlFor:"commit-diff-split-view",className:"text-[10px] uppercase tracking-wider font-bold cursor-pointer opacity-70",children:"Split View"}),(0,s.jsx)("input",{type:"checkbox",id:"commit-diff-split-view",checked:C,onChange:e=>S(e.target.checked),className:"toggle toggle-xs toggle-primary"}),(0,s.jsx)("button",{type:"button",className:"btn btn-ghost btn-xs btn-square",onClick:()=>f(e=>!e),"aria-label":p?"Exit full-page diff view":"Expand diff viewer to full page",title:p?"Exit full-page diff view":"Expand diff viewer to full page",children:(0,s.jsx)("i",{className:(0,o.cn)(p?"iconoir-collapse":"iconoir-maximize","text-[14px]"),"aria-hidden":"true"})})]})]}),(0,s.jsx)("div",{ref:E,className:"flex-1 overflow-auto diff-viewer-wrapper",children:(0,s.jsx)(j,{repoPath:e,commitHash:t,fromCommitHash:a,toCommitHash:n,filePath:R,splitView:C},`${c}:${R}`)})]}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full opacity-70 text-sm",children:"Select a file to view changes"})})]}):(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full opacity-50",children:i?"No changes in selected commit range":"No changes in this commit"})}function y({repoPath:e,filePath:t}){let{data:a,isLoading:n}=(0,l.xV)(e,t),i=(0,r.useRef)(null),c="git-web:diff-view-split",[d,h]=(0,r.useState)(()=>{try{let e=localStorage.getItem(c);return null===e||JSON.parse(e)}catch(e){return console.error("Failed to load split view preference:",e),!0}}),[m,u]=(0,r.useState)(null),b=m===t,{resolvedTheme:g}=(0,x.D)();if((0,r.useEffect)(()=>{try{localStorage.setItem(c,JSON.stringify(d))}catch(e){console.error("Failed to save split view preference:",e)}},[d]),(0,r.useEffect)(()=>{if(n)return;let e=requestAnimationFrame(()=>{i.current?.scrollTo({top:0,left:0})});return()=>cancelAnimationFrame(e)},[t,n]),n)return(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})});if(!a)return(0,s.jsx)("div",{className:"flex items-center justify-center h-full opacity-50",children:"No diff available"});if((0,o.u)(t))return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100",children:[(0,s.jsx)("div",{className:"flex items-center justify-between px-4 h-[57px] border-b border-base-300 shrink-0 bg-base-100",children:(0,s.jsx)("span",{className:"text-sm font-mono truncate max-w-[70%]",title:t,children:t})}),(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(f.K,{filePath:t,imageDiff:a.imageDiff})})]});if((0,o.kO)(t,a.left,a.right))return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100",children:[(0,s.jsx)("div",{className:"flex items-center justify-between px-4 h-[57px] border-b border-base-300 shrink-0 bg-base-100",children:(0,s.jsx)("span",{className:"text-sm font-mono truncate max-w-[70%]",title:t,children:t})}),(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center opacity-50",children:"Binary file - diff not available"})]});let j=a.diff||"",N=j.length,y=(0,o.tq)(j),v=N>102400||y>3e3;return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 h-[57px] border-b border-base-300 shrink-0 bg-base-100",children:[(0,s.jsx)("span",{className:"text-sm font-mono truncate max-w-[70%]",title:t,children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("label",{htmlFor:"split-view",className:"text-[10px] uppercase tracking-wider font-bold cursor-pointer opacity-70",children:"Split View"}),(0,s.jsx)("input",{type:"checkbox",id:"split-view",checked:d,onChange:e=>h(e.target.checked),className:"toggle toggle-sm toggle-primary"})]})]}),(0,s.jsx)("div",{ref:i,className:"flex-1 overflow-auto diff-viewer-wrapper",children:v&&!b?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center p-4",children:[(0,s.jsx)("i",{className:"iconoir-warning-triangle text-[40px] text-warning","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Large Diff Detected"}),(0,s.jsxs)("p",{className:"opacity-70",children:["This diff is large (",Math.round(N/1024),"KB, ~",y," changed lines) and may freeze your browser if rendered."]})]}),(0,s.jsx)("button",{className:"btn btn-outline",onClick:()=>u(t),children:"Show Diff Anyway"})]}):(0,s.jsx)(p.O,{oldValue:a.left||"",newValue:a.right||"",splitView:d,useDarkTheme:"dark"===g})})]})}let v=[];function k(e,t){let a=e.trim(),s=t.replace(/\r\n/g,"\n");return s.trim()?`${a}
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2944],{302:(e,a,t)=>{t.d(a,{v:()=>o});var s=t(2115);let l=[],n=0,r=!1;function i(e){let a,t=(a=l[l.length-1])||null;if(t){if("Escape"===e.key){e.preventDefault(),t.onEscape();return}"Enter"===e.key&&t.onEnter&&!function(e){if(e.defaultPrevented||e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return!0;let a=e.target;if(!a)return!1;if(a.isContentEditable)return!0;let t=a.tagName;return"TEXTAREA"===t||"BUTTON"===t||"SELECT"===t||"OPTION"===t||"A"===t}(e)&&(e.preventDefault(),t.onEnter())}}function o(e,a,t){let o=(0,s.useRef)(a),c=(0,s.useRef)(t);(0,s.useEffect)(()=>{o.current=a},[a]),(0,s.useEffect)(()=>{c.current=t},[t]),(0,s.useEffect)(()=>{if(!e)return;let a=++n;return l.push({id:a,onEscape:()=>o.current(),onEnter:()=>c.current?.()}),!r&&"u">typeof document&&(document.addEventListener("keydown",i),r=!0),()=>{let e=l.findIndex(e=>e.id===a);e>=0&&l.splice(e,1),r&&"u">typeof document&&!(l.length>0)&&(document.removeEventListener("keydown",i),r=!1)}},[e])}},2944:(e,a,t)=>{t.d(a,{u:()=>z});var s=t(5155),l=t(696),n=t(5625),r=t(2115);function i(e){let a=0x811c9dc5;for(let t=0;t<e.length;t++)a^=e.charCodeAt(t),a=Math.imul(a,0x1000193);return a>>>0}var o=t(8599);function c({children:e,items:a,containerClassName:t="w-full"}){let[l,n]=(0,r.useState)(!1),[i,c]=(0,r.useState)({x:0,y:0}),d=(0,r.useRef)(null),h=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!l)return;let e=e=>{d.current&&!d.current.contains(e.target)&&h.current&&!h.current.contains(e.target)&&n(!1)},a=e=>{"Escape"===e.key&&n(!1)};return setTimeout(()=>{document.addEventListener("click",e),document.addEventListener("contextmenu",e),document.addEventListener("keydown",a)},0),()=>{document.removeEventListener("click",e),document.removeEventListener("contextmenu",e),document.removeEventListener("keydown",a)}},[l]),(0,r.useEffect)(()=>{if(!l||!d.current)return;let e=d.current;requestAnimationFrame(()=>{let t=document.createElement("div");t.style.position="absolute",t.style.visibility="hidden",t.style.whiteSpace="nowrap",t.style.pointerEvents="none";let s=window.getComputedStyle(e);t.style.fontSize=s.fontSize,t.style.fontFamily=s.fontFamily,t.style.fontWeight=s.fontWeight,t.style.padding="0.5rem 0.75rem",t.style.boxSizing="border-box",document.body.appendChild(t);let l=0;a.forEach(e=>{t.textContent=e.label;let a=t.getBoundingClientRect().width+20*!!e.icon+16*!!e.children?.length;a>l&&(l=a)}),document.body.removeChild(t);let n=Math.max(l+32,280);e.style.width=`${n}px`,e.style.minWidth=`${n}px`;let r=e.getBoundingClientRect(),o=window.innerWidth,c=window.innerHeight,d=i.x,h=i.y;r.right>o&&(d=o-r.width-10),d<10&&(d=10),r.bottom>c&&(h=c-r.height-10),h<10&&(h=10),(d!==i.x||h!==i.y)&&(e.style.left=`${d}px`,e.style.top=`${h}px`)})},[l,i,a]);let m=(e,a)=>{let t=!!e.children?.length;return(0,s.jsxs)("li",{className:(0,o.cn)(t&&"relative group/submenu"),children:[(0,s.jsxs)("a",{onClick:a=>{a.stopPropagation(),e.disabled||t||(e.onClick?.(),n(!1))},className:(0,o.cn)("flex items-center gap-2","whitespace-nowrap",e.danger&&"text-error",e.disabled&&"opacity-40 pointer-events-none",t&&"flex items-center justify-between gap-3"),children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[e.icon&&(0,s.jsx)("span",{className:"inline-flex shrink-0 opacity-80",children:e.icon}),(0,s.jsx)("span",{children:e.labelNode??e.label})]}),t&&(0,s.jsx)("i",{className:"iconoir-nav-arrow-right text-[12px]","aria-hidden":"true"})]}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden group-hover/submenu:block absolute left-full top-0 h-full w-3"}),(0,s.jsx)("ul",{className:"hidden group-hover/submenu:block absolute left-[calc(100%-1px)] top-0 menu !m-0 p-2 shadow-lg bg-base-100 rounded-box border border-base-200 min-w-[220px] z-[10000] [&:before]:hidden",children:e.children.map((e,t)=>m(e,`${a}-${t}`))})]})]},a)};return(0,s.jsxs)("div",{ref:h,className:t,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),c({x:e.clientX,y:e.clientY}),n(!0)},children:[e,l&&(0,s.jsx)("ul",{ref:d,className:"fixed z-[9999] menu p-2 shadow-lg bg-base-100 rounded-box border border-base-200",style:{left:`${i.x}px`,top:`${i.y}px`},children:a.map((e,a)=>m(e,`menu-${a}`))})]})}function d({text:e,searchQuery:a}){if(!a||!e)return(0,s.jsx)(s.Fragment,{children:e});let t=a.toLowerCase(),l=e.toLowerCase(),n=[],r=0,i=l.indexOf(t);for(;-1!==i;)i>r&&n.push({text:e.slice(r,i),highlighted:!1}),n.push({text:e.slice(i,i+t.length),highlighted:!0}),r=i+t.length,i=l.indexOf(t,r);return(r<e.length&&n.push({text:e.slice(r),highlighted:!1}),0===n.length)?(0,s.jsx)(s.Fragment,{children:e}):(0,s.jsx)(s.Fragment,{children:n.map((e,a)=>e.highlighted?(0,s.jsx)("mark",{className:"bg-warning text-warning-content rounded-sm px-0.5",children:e.text},a):(0,s.jsx)("span",{children:e.text},a))})}let h=(0,r.forwardRef)(function({commits:e,onSelectCommit:a,onResetToCommit:t,onRevertCommit:l,onCreateTag:n,onCherryPickCommit:h,onCherryPickSelectedCommits:m,onRewordCommit:u,selectedHash:x,selectedHashes:p,onEndReached:b,isLoadingMore:f,currentBranch:g,hiddenBranches:j,localBranches:N=[],trackingInfo:y,getBranchTagContextMenuItems:v},k){let w=(0,r.useCallback)(e=>e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/remotes/")?e.slice(13):e.startsWith("remotes/")?e.slice(8):e,[]),C=(0,r.useCallback)(e=>e.startsWith("tag:")?e.replace(/^tag:\s*/,"").trim():e,[]),S=(0,r.useMemo)(()=>(function(e,a={}){let t=[],s=new Set(a.localBranches??[]),l=[],n=[],r=[];function o(){for(let e=0;e<l.length;e++)if(null===l[e])return e;return l.length}function c(e){let a,t=r[e],s=t?(a=i(t),`hsl(${a%360} 82% 52%)`):n[e]??`hsl(${47*e%360} 78% 56%)`;return n[e]=s,s}return e.forEach((e,i)=>{var d;let h=[];for(let a=0;a<l.length;a++)l[a]===e.hash&&h.push(a);let m=h.length>0?h[0]:-1;for(-1===m&&(m=o());l.length<=m;)l.push(null),r.push(null),n.push(void 0);"__LOCAL_CHANGES__"===e.hash&&a.currentBranch&&(r[m]=a.currentBranch);let u=function(e,a){if(0===e.length)return null;let t=e.find(e=>a.has(e));return t||e[0]}((d=e.refs)?d.replace(/^\s*\((.*)\)\s*$/,"$1").split(",").map(e=>e.trim()).filter(Boolean).map(e=>e.replace(/^HEAD\s*->\s*/,"").trim()).map(e=>e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/remotes/")?e.slice(13):e.startsWith("remotes/")?e.slice(8):e).filter(e=>!e.startsWith("tag:")).filter(e=>"HEAD"!==e).filter(e=>!/\/HEAD$/.test(e)):[],s);if(u){let e=function(e,a){let t,s;if(a.has(e))return e;let l=-1===(s=(t=e.startsWith("remotes/")?e.slice(8):e).indexOf("/"))?null:t.slice(s+1);return l&&a.has(l)?l:e}(u,s);(function(e,a,t){return!a||t.has(e)&&!t.has(a)})(e,r[m],s)&&(r[m]=e)}let x=c(m),p={...e,x:m,y:i,color:x,paths:[],isMerge:e.parents.length>1},b=h.filter(e=>e!==m),f=new Set(b);for(let e=0;e<l.length;e++)e===m||null===l[e]||f.has(e)||p.paths.push({x1:e,y1:i,x2:e,y2:i+1,color:c(e),type:"straight"});for(let e of(l[m]=null,b)){if(i>0){let a=t[t.length-1];a&&(a.paths=a.paths.filter(a=>"straight"!==a.type||a.x1!==e||a.y1!==i-1||a.x2!==e||a.y2!==i))}p.paths.push({x1:e,y1:i-1,x2:m,y2:i,color:c(e),type:"merge"}),l[e]=null,r[e]=null,n[e]=void 0}let g=e.parents;if(g.length>0){let e=g[0];l[m]=e,p.paths.push({x1:m,y1:i,x2:m,y2:i+1,color:x,type:"straight"});for(let e=1;e<g.length;e++){let a=g[e],t=l.indexOf(a);if(-1!==t)p.paths.push({x1:m,y1:i,x2:t,y2:i+1,color:c(t),type:"fork"});else{let e=o();for(;l.length<=e;)l.push(null),r.push(null),n.push(void 0);l[e]=a,p.paths.push({x1:m,y1:i,x2:e,y2:i+1,color:c(e),type:"fork"})}}}null===l[m]&&(r[m]=null,n[m]=void 0),t.push(p)}),t})(e,{localBranches:N,currentBranch:g}),[e,N,g]),E=(0,r.useRef)(null),R=(0,r.useRef)(null),[$,B]=(0,r.useState)(!1),[P,F]=(0,r.useState)("");(0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),B(!0),setTimeout(()=>R.current?.focus(),0)),"Escape"===e.key&&$&&(B(!1),F(""))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[$]);let M=(0,r.useCallback)(()=>{B(!1),F("")},[]);if((0,r.useImperativeHandle)(k,()=>({scrollToCommit:e=>{if(!S||0===S.length)return!1;let a=S.findIndex(a=>a.hash===e);if(-1===a)return!1;if(E.current){let e=24*a-E.current.clientHeight/2+12;E.current.scrollTop=Math.max(0,e)}return!0}}),[S]),!S||0===S.length)return null;let A=(Math.max(...S.map(e=>e.x),0)+1)*12+20,D=24*S.length;return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100 overflow-hidden font-mono text-sm select-none",children:[$&&(0,s.jsxs)("div",{className:"sticky top-0 z-30 bg-base-100 border-b border-base-300 px-2 py-2 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"opacity-50",children:"\uD83D\uDD0D"}),(0,s.jsx)("input",{ref:R,type:"text",placeholder:"Search in commits...",value:P,onChange:e=>F(e.target.value),className:"input input-bordered input-sm flex-1 text-sm",autoFocus:!0}),(0,s.jsx)("div",{className:"tooltip tooltip-left z-50","data-tip":"Close search (Esc)",children:(0,s.jsx)("button",{onClick:M,className:"btn btn-ghost btn-sm btn-square",children:"✖️"})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto h-full max-w-full px-2",onScroll:e=>{let{scrollTop:a,clientHeight:t,scrollHeight:s}=e.currentTarget;s-a-t<100&&b?.()},ref:E,children:(0,s.jsxs)("div",{className:"relative min-w-full",style:{height:D},children:[(0,s.jsxs)("svg",{width:A,height:D,className:"absolute top-0 left-0 pointer-events-none z-10",children:[S.map(e=>(0,s.jsx)("g",{children:e.paths.map((e,a)=>{let t=12*e.x1+6,l=24*e.y1+12,n=12*e.x2+6,r=24*e.y2+12,i="";if("straight"===e.type)i=`M ${t} ${l} L ${n} ${r}`;else{let e=l+12,a=r-12;i=`M ${t} ${l} C ${t} ${e}, ${n} ${a}, ${n} ${r}`}return(0,s.jsx)("path",{d:i,stroke:e.color,strokeWidth:2,fill:"none",strokeLinecap:"round"},a)})},e.hash)),S.map(e=>{let a="__LOCAL_CHANGES__"===e.hash;return(0,s.jsx)("circle",{cx:12*e.x+6,cy:24*e.y+12,r:3,fill:a?"var(--fallback-b1, oklch(var(--b1)))":e.color,stroke:e.color,strokeWidth:2,className:a?"fill-base-100":void 0},`dot-${e.hash}`)})]}),(0,s.jsxs)("div",{style:{width:"100%"},children:[S.map(e=>{let r="__LOCAL_CHANGES__"===e.hash,b=p?p.has(e.hash):x===e.hash,f=p?.size??+!!x,k=r?[]:[{label:"Reset to here",icon:(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"}),onClick:()=>t?.(e.hash)}];if(!r&&l&&k.push({label:"Revert commit",icon:(0,s.jsx)("i",{className:"iconoir-u-turn-arrow-left text-[14px]","aria-hidden":"true"}),onClick:()=>l(e.hash,e.message)}),!r&&n&&k.push({label:"Create tag",icon:(0,s.jsx)("i",{className:"iconoir-bookmark text-[14px]","aria-hidden":"true"}),onClick:()=>n(e.hash)}),!r&&h&&k.push({label:"Cherry-pick commit",icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>h(e.hash,e.message)}),!r&&m&&f>1&&b&&k.push({label:`Cherry-pick ${f} selected commits`,icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:m}),!r&&u&&N&&N.length>0){let a=e.refs?e.refs.replace(/[()]/g,"").split(",").map(e=>e.trim()):[],t=null;for(let e of a){let a=e.replace(/^HEAD\s*->\s*/,"");if(N.includes(a)&&(t=a,g&&a===g))break}t&&k.push({label:"Reword commit",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>u(e.hash,e.message,e.body??"",t)})}let S=(()=>{if(!e.refs||r)return[];let a=e.refs.replace(/^\s*\((.*)\)\s*$/,"$1").split(",").map(e=>{let a=e.startsWith("HEAD -> "),t=w(e.replace(/^HEAD\s*->\s*/,"").trim());return{raw:e,name:t,isHead:a}}),t=[],s=new Set,l=e=>j&&(j.has(e)||j.has(`remotes/${e}`));return a.forEach((e,n)=>{if(!s.has(n)&&N.includes(e.name)&&!l(e.name)){let l=y?.[e.name];if(l&&l.upstream){let r=w(l.upstream.trim()),i=new Set([r,w(`remotes/${r}`),w(`refs/remotes/${r}`)]),o=a.findIndex((e,a)=>a!==n&&!s.has(a)&&i.has(e.name));if(-1!==o){let l=a[o],i=r.split("/")[0];t.push({displayName:`${e.name} (${i})`,primaryRef:e.name,secondaryRef:l.name,isHead:e.isHead}),s.add(n),s.add(o);return}}}}),a.forEach((e,a)=>{!s.has(a)&&(l(e.name)||t.push({displayName:C(e.name),primaryRef:e.name,isHead:e.isHead}))}),t})(),E=(0,s.jsxs)("div",{className:(0,o.cn)("flex items-center hover:bg-base-200 border-b border-base-200 last:border-0 cursor-pointer transition-colors text-xs",b&&"bg-primary/10"),style:{height:24},onClick:t=>a?.(e.hash,{isMultiSelect:t.metaKey||t.ctrlKey,isRangeSelect:t.shiftKey}),children:[(0,s.jsx)("div",{style:{width:A,flexShrink:0}}),(0,s.jsxs)("div",{className:"flex flex-1 gap-4 overflow-hidden pr-4 items-center",children:[(0,s.jsxs)("div",{className:"flex-1 truncate flex items-center gap-2",children:[S.map((e,a)=>{let t=g&&(e.primaryRef===g||e.isHead&&e.primaryRef===g),l=e.primaryRef.startsWith("tag:")?{textColor:"#374151",backgroundColor:"#e5e7eb"}:function(e){let a,t,s,l,n,r,o,c,d,h=i(e),m=h%360,u=72+(h>>>9)%20,x=84+(h>>>17)%8,p=1.05/((d=function({r:e,g:a,b:t}){let s=e=>{let a=e/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)};return .2126*s(e)+.7152*s(a)+.0722*s(t)}((t=u/100*(1-Math.abs(2*(a=x/100)-1)),l=t*(1-Math.abs((s=m/60)%2-1)),n=0,r=0,o=0,s>=0&&s<1?(n=t,r=l):s>=1&&s<2?(n=l,r=t):s>=2&&s<3?(r=t,o=l):s>=3&&s<4?(r=l,o=t):s>=4&&s<5?(n=l,o=t):(n=t,o=l),{r:Math.round((n+(c=a-t/2))*255),g:Math.round((r+c)*255),b:Math.round((o+c)*255)})))+.05)>=(d+.05)/.05?"#ffffff":"#111827";return{backgroundColor:`hsl(${m} ${u}% ${x}%)`,textColor:p}}(e.primaryRef),n=(0,s.jsx)("span",{className:(0,o.cn)("text-[10px] px-1.5 rounded-full whitespace-nowrap shrink-0",t&&"font-bold"),style:{color:l.textColor,backgroundColor:l.backgroundColor},title:e.displayName,children:(0,s.jsx)(d,{text:e.displayName,searchQuery:P})}),r=v?.(e.primaryRef)||[];return 0===r.length?(0,s.jsx)("span",{className:"shrink-0",children:n},a):(0,s.jsx)(c,{items:r,containerClassName:"inline-flex shrink-0",children:n},a)}),(0,s.jsx)("span",{className:(0,o.cn)("truncate min-w-0 max-w-[600px]",r?"italic text-base-content/80":"",b?"font-semibold text-primary":""),title:e.message,children:(0,s.jsx)(d,{text:e.message,searchQuery:P})})]}),(0,s.jsx)("div",{className:"w-32 truncate opacity-70 text-right commit-author",children:r?null:(0,s.jsx)(d,{text:e.author_name,searchQuery:P})}),(0,s.jsx)("div",{className:"w-20 truncate opacity-50 font-mono text-right commit-hash",children:r?null:(0,s.jsx)(d,{text:e.hash.substring(0,7),searchQuery:P})}),(0,s.jsx)("div",{className:"w-32 truncate opacity-70 text-right",children:r?null:new Date(e.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})})]})]});return 0===k.length?(0,s.jsx)("div",{children:E},e.hash):(0,s.jsx)(c,{items:k,children:E},e.hash)}),f&&(0,s.jsxs)("div",{className:"flex items-center justify-center py-8 border-b border-base-300",children:[(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"}),(0,s.jsx)("span",{className:"ml-2 text-sm opacity-70",children:"Loading more commits..."})]})]})]})})]})});var m=t(302),u=t(6695),x=t(460),p=t(6162),b=t(4254);function f({status:e}){switch(e){case"A":return(0,s.jsx)("i",{className:"iconoir-plus-circle text-[16px] text-success","aria-hidden":"true"});case"D":return(0,s.jsx)("i",{className:"iconoir-minus-circle text-[16px] text-error","aria-hidden":"true"});case"M":return(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[16px] text-warning","aria-hidden":"true"});default:return(0,s.jsx)("i",{className:"iconoir-page text-[16px] opacity-50","aria-hidden":"true"})}}function g({node:e,selectedFile:a,expandedFolders:t,onToggleFolder:l,onSelectFile:n,depth:r=0}){let i=Array.from(e.children.values()).sort((e,a)=>{let t=e.children.size>0,s=a.children.size>0;return t&&!s?-1:!t&&s?1:e.name.localeCompare(a.name)});return(0,s.jsx)(s.Fragment,{children:i.map(e=>{if(e.children.size>0){let i=t.has(e.path);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 text-xs rounded cursor-pointer hover:bg-base-200 transition-colors opacity-80",style:{paddingLeft:`${12*r+8}px`},onClick:()=>l(e.path),title:e.path,children:[(0,s.jsx)("span",{className:"text-[10px] opacity-70",children:i?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[14px] opacity-70","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e.name})]}),i&&(0,s.jsx)(g,{node:e,selectedFile:a,expandedFolders:t,onToggleFolder:l,onSelectFile:n,depth:r+1})]},e.path)}if(!e.file)return null;let i=e.file;return(0,s.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 px-2 py-1.5 text-xs rounded cursor-pointer hover:bg-base-200 transition-colors",a===i.path&&"bg-base-200 font-medium"),style:{paddingLeft:`${12*r+8}px`},onClick:()=>n(i.path),title:i.path,children:[(0,s.jsx)(f,{status:i.status}),(0,s.jsx)("span",{className:"truncate flex-1 font-mono",children:e.name})]},e.path)})})}function j({repoPath:e,commitHash:a,fromCommitHash:t,toCommitHash:n,filePath:i,splitView:c}){let{data:d,isLoading:h}=(0,l.st)(e,i,{commitHash:a,fromCommitHash:t,toCommitHash:n}),{resolvedTheme:m}=(0,x.D)(),u=`${a??""}:${t??""}:${n??""}:${i}`,[f,g]=(0,r.useState)(null),j=f===u,N=(0,r.useRef)(null);if((0,r.useEffect)(()=>{let e=requestAnimationFrame(()=>{N.current?.scrollTo({top:0,left:0})});return()=>cancelAnimationFrame(e)},[i,a,t,n,h]),h)return(0,s.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})});if(!d)return(0,s.jsx)("div",{className:"flex items-center justify-center p-8 opacity-50",children:"No diff available"});if((0,o.u)(i))return(0,s.jsx)(b.K,{filePath:i,imageDiff:d.imageDiff});if((0,o.kO)(i,d.left,d.right))return(0,s.jsx)("div",{className:"flex items-center justify-center p-8 opacity-50",children:"Binary file - diff not available"});let y=d.diff||"",v=y.length,k=(0,o.tq)(y);return(v>102400||k>3e3)&&!j?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center p-8",children:[(0,s.jsx)("i",{className:"iconoir-warning-triangle text-[32px] text-warning","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Large Diff Detected"}),(0,s.jsxs)("p",{className:"opacity-70",children:["This diff is large (",Math.round(v/1024),"KB, ~",k," changed lines) and may freeze your browser if rendered."]})]}),(0,s.jsx)("button",{className:"btn btn-outline",onClick:()=>g(u),children:"Show Diff Anyway"})]}):(0,s.jsx)("div",{ref:N,className:"overflow-auto h-full",children:(0,s.jsx)(p.O,{oldValue:d.left||"",newValue:d.right||"",splitView:c,useDarkTheme:"dark"===m})})}function N({repoPath:e,commitHash:a=null,fromCommitHash:t=null,toCommitHash:n=null}){let i=!!t&&!!n,c=i?`${t}..${n}`:a??"none",{data:d,isLoading:h}=(0,l.gg)(e,{commitHash:a,fromCommitHash:t,toCommitHash:n}),[u,x]=(0,r.useState)({}),[p,b]=(0,r.useState)(!1),[f,N]=(0,r.useState)({}),y=(0,r.useMemo)(()=>(function(e){let a={name:"",path:"",children:new Map};for(let t of e){let e=t.path.split("/").filter(Boolean),s=a,l="";for(let a=0;a<e.length;a++){let n=e[a];l=l?`${l}/${n}`:n,s.children.has(n)||s.children.set(n,{name:n,path:l,children:new Map}),s=s.children.get(n),a===e.length-1&&(s.file=t)}}return a})(d?.files??[]),[d?.files]),v=(0,r.useMemo)(()=>(function e(a){let t=[];return Array.from(a.children.values()).forEach(a=>{a.children.size>0&&(t.push(a.path),t.push(...e(a)))}),t})(y),[y]),k=(0,r.useMemo)(()=>f[c]??new Set,[f,c]),w="git-web:diff-view-split",[C,S]=(0,r.useState)(()=>{try{let e=localStorage.getItem(w);return null===e||JSON.parse(e)}catch(e){return console.error("Failed to load split view preference:",e),!0}}),E=(0,r.useRef)(null),R=(0,r.useMemo)(()=>{let e=d?.files??[];if(0===e.length)return null;let a=u[c]??null;return a&&e.some(e=>e.path===a)?a:e[0].path},[d?.files,u,c]),$=(0,r.useCallback)(e=>{x(a=>(a[c]??null)===e?a:{...a,[c]:e})},[c]);(0,r.useEffect)(()=>{try{localStorage.setItem(w,JSON.stringify(C))}catch(e){console.error("Failed to save split view preference:",e)}},[C]),(0,r.useEffect)(()=>{if(!R)return;let e=requestAnimationFrame(()=>{E.current?.scrollTo({top:0,left:0})});return()=>cancelAnimationFrame(e)},[R,c]),(0,m.v)(p,()=>b(!1)),(0,r.useEffect)(()=>{if(!p)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[p]);let B=(0,r.useMemo)(()=>{let e=new Set;return v.forEach(a=>{k.has(a)||e.add(a)}),R&&(function(e){let a=e.split("/").filter(Boolean),t=[];for(let e=1;e<a.length;e++)t.push(a.slice(0,e).join("/"));return t})(R).forEach(a=>e.add(a)),e},[v,k,R]),P=(0,r.useCallback)(e=>{N(a=>{let t=new Set(a[c]??new Set);return t.has(e)?t.delete(e):t.add(e),{...a,[c]:t}})},[c]);return h?(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})}):d&&0!==d.files.length?(0,s.jsxs)("div",{className:(0,o.cn)("flex h-full",p&&"fixed inset-0 z-[80] h-auto bg-base-100 shadow-2xl"),children:[(0,s.jsxs)("div",{className:"w-64 border-r border-base-300 flex flex-col bg-base-200/30 shrink-0",children:[(0,s.jsxs)("div",{className:"px-3 py-2 text-xs font-bold opacity-70 border-b border-base-300 bg-base-100",children:[d.files.length," file",1!==d.files.length?"s":""," changed"]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:(0,s.jsx)("div",{className:"p-1",children:(0,s.jsx)(g,{node:y,selectedFile:R,expandedFolders:B,onToggleFolder:P,onSelectFile:$})})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:R?(0,s.jsxs)("div",{className:"h-full flex flex-col",children:[(0,s.jsxs)("div",{className:"px-4 py-2 text-xs font-mono opacity-70 border-b border-base-300 bg-base-100 shrink-0 truncate flex items-center justify-between",children:[(0,s.jsx)("span",{className:"truncate",children:R}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[(0,s.jsx)("label",{htmlFor:"commit-diff-split-view",className:"text-[10px] uppercase tracking-wider font-bold cursor-pointer opacity-70",children:"Split View"}),(0,s.jsx)("input",{type:"checkbox",id:"commit-diff-split-view",checked:C,onChange:e=>S(e.target.checked),className:"toggle toggle-xs toggle-primary"}),(0,s.jsx)("button",{type:"button",className:"btn btn-ghost btn-xs btn-square",onClick:()=>b(e=>!e),"aria-label":p?"Exit full-page diff view":"Expand diff viewer to full page",title:p?"Exit full-page diff view":"Expand diff viewer to full page",children:(0,s.jsx)("i",{className:(0,o.cn)(p?"iconoir-collapse":"iconoir-maximize","text-[14px]"),"aria-hidden":"true"})})]})]}),(0,s.jsx)("div",{ref:E,className:"flex-1 overflow-auto diff-viewer-wrapper",children:(0,s.jsx)(j,{repoPath:e,commitHash:a,fromCommitHash:t,toCommitHash:n,filePath:R,splitView:C},`${c}:${R}`)})]}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full opacity-70 text-sm",children:"Select a file to view changes"})})]}):(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full opacity-50",children:i?"No changes in selected commit range":"No changes in this commit"})}function y({repoPath:e,filePath:a}){let{data:t,isLoading:n}=(0,l.xV)(e,a),i=(0,r.useRef)(null),c="git-web:diff-view-split",[d,h]=(0,r.useState)(()=>{try{let e=localStorage.getItem(c);return null===e||JSON.parse(e)}catch(e){return console.error("Failed to load split view preference:",e),!0}}),[m,u]=(0,r.useState)(null),f=m===a,{resolvedTheme:g}=(0,x.D)();if((0,r.useEffect)(()=>{try{localStorage.setItem(c,JSON.stringify(d))}catch(e){console.error("Failed to save split view preference:",e)}},[d]),(0,r.useEffect)(()=>{if(n)return;let e=requestAnimationFrame(()=>{i.current?.scrollTo({top:0,left:0})});return()=>cancelAnimationFrame(e)},[a,n]),n)return(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})});if(!t)return(0,s.jsx)("div",{className:"flex items-center justify-center h-full opacity-50",children:"No diff available"});if((0,o.u)(a))return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100",children:[(0,s.jsx)("div",{className:"flex items-center justify-between px-4 h-[57px] border-b border-base-300 shrink-0 bg-base-100",children:(0,s.jsx)("span",{className:"text-sm font-mono truncate max-w-[70%]",title:a,children:a})}),(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(b.K,{filePath:a,imageDiff:t.imageDiff})})]});if((0,o.kO)(a,t.left,t.right))return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100",children:[(0,s.jsx)("div",{className:"flex items-center justify-between px-4 h-[57px] border-b border-base-300 shrink-0 bg-base-100",children:(0,s.jsx)("span",{className:"text-sm font-mono truncate max-w-[70%]",title:a,children:a})}),(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center opacity-50",children:"Binary file - diff not available"})]});let j=t.diff||"",N=j.length,y=(0,o.tq)(j),v=N>102400||y>3e3;return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-base-100",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 h-[57px] border-b border-base-300 shrink-0 bg-base-100",children:[(0,s.jsx)("span",{className:"text-sm font-mono truncate max-w-[70%]",title:a,children:a}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("label",{htmlFor:"split-view",className:"text-[10px] uppercase tracking-wider font-bold cursor-pointer opacity-70",children:"Split View"}),(0,s.jsx)("input",{type:"checkbox",id:"split-view",checked:d,onChange:e=>h(e.target.checked),className:"toggle toggle-sm toggle-primary"})]})]}),(0,s.jsx)("div",{ref:i,className:"flex-1 overflow-auto diff-viewer-wrapper",children:v&&!f?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center p-4",children:[(0,s.jsx)("i",{className:"iconoir-warning-triangle text-[40px] text-warning","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Large Diff Detected"}),(0,s.jsxs)("p",{className:"opacity-70",children:["This diff is large (",Math.round(N/1024),"KB, ~",y," changed lines) and may freeze your browser if rendered."]})]}),(0,s.jsx)("button",{className:"btn btn-outline",onClick:()=>u(a),children:"Show Diff Anyway"})]}):(0,s.jsx)(p.O,{oldValue:t.left||"",newValue:t.right||"",splitView:d,useDarkTheme:"dark"===g})})]})}let v=[];function k(e,a){let t=e.trim(),s=a.replace(/\r\n/g,"\n");return s.trim()?`${t}
|
|
2
2
|
|
|
3
|
-
${s}`:a}function w(e){let t={name:"",path:"",children:new Map};for(let a of e){let e=a.split("/").filter(Boolean),s=t,l="";for(let t=0;t<e.length;t++){let n=e[t];l=l?`${l}/${n}`:n,s.children.has(n)||s.children.set(n,{name:n,path:l,children:new Map}),s=s.children.get(n),t===e.length-1&&(s.filePath=a)}}return t}function C(e){let t=[];return Array.from(e.children.values()).forEach(e=>{e.children.size>0&&(t.push(e.path),t.push(...C(e)))}),t}function S(e){let t=e.split("/").filter(Boolean),a=[];for(let e=1;e<t.length;e++)a.push(t.slice(0,e).join("/"));return a}function E({node:e,selectedFile:t,expandedFolders:a,onToggleFolder:l,onSelectFile:n,onActionFile:r,actionType:i,actionPending:c,depth:d=0}){let h=Array.from(e.children.values()).sort((e,t)=>{let a=e.children.size>0,s=t.children.size>0;return a&&!s?-1:!a&&s?1:e.name.localeCompare(t.name)});return(0,s.jsx)(s.Fragment,{children:h.map(e=>{if(e.children.size>0){let o=a.has(e.path);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 text-xs rounded cursor-pointer hover:bg-base-300 transition-colors opacity-80",style:{paddingLeft:`${12*d+8}px`},onClick:()=>l(e.path),title:e.path,children:[(0,s.jsx)("span",{className:"text-[10px] opacity-70",children:o?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[14px] opacity-70","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e.name})]}),o&&(0,s.jsx)(E,{node:e,selectedFile:t,expandedFolders:a,onToggleFolder:l,onSelectFile:n,onActionFile:r,actionType:i,actionPending:c,depth:d+1})]},e.path)}let h=e.filePath;return h?(0,s.jsxs)("div",{className:(0,o.cn)("flex items-center justify-between gap-2 px-2 py-1.5 rounded-md cursor-pointer group hover:bg-base-300 transition-colors text-sm",t===h&&"bg-base-300 font-medium text-primary"),style:{paddingLeft:`${12*d+8}px`},onClick:()=>n(h),title:h,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("i",{className:"iconoir-page text-[14px] opacity-70 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate flex-1 font-mono text-xs",children:e.name})]}),(0,s.jsx)("button",{className:(0,o.cn)("btn btn-ghost btn-xs btn-square opacity-0 group-hover:opacity-100 transition-opacity","stage"===i?"text-success hover:bg-success/10":"text-error hover:bg-error/10"),onClick:e=>{e.stopPropagation(),r(h)},disabled:c,children:(0,s.jsx)("i",{className:(0,o.cn)("text-[14px]","stage"===i?"iconoir-plus-circle":"iconoir-minus-circle"),"aria-hidden":"true"})})]},h):null})})}function R({repoPath:e,onClose:t}){let{data:a,isLoading:n,isError:i,error:c,refetch:d}=(0,l.en)(e),{data:h}=(0,l._6)(e),u=(0,l.a3)(),[x,p]=(0,r.useState)(""),[f,b]=(0,r.useState)(""),[g,j]=(0,r.useState)(null),[N,R]=(0,r.useState)(!1),[$,B]=(0,r.useState)(""),[P,F]=(0,r.useState)(!1),[M,A]=(0,r.useState)(!1),[D,L]=(0,r.useState)("main"),[T,_]=(0,r.useState)(new Set),[O,H]=(0,r.useState)(new Set),[I,K]=(0,r.useState)(180),[z,q]=(0,r.useState)(!1),W=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{if(!z||!W.current)return;let t=W.current.startY-e.clientY;K(Math.max(120,Math.min(600,W.current.startHeight+t)))},t=()=>{q(!1),W.current=null,document.body.style.cursor="default",document.body.style.userSelect="auto"};return z&&(window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),document.body.style.cursor="ns-resize",document.body.style.userSelect="none"),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t),document.body.style.cursor="default",document.body.style.userSelect="auto"}},[z]);let G=a?.files??v,U=!!h&&0===h.branches.length,{staged:V,changes:Y}=(0,r.useMemo)(()=>{let e=[],t=[];return G.forEach(a=>{" "!==a.index&&"?"!==a.index&&e.push(a.path),(" "!==a.working_dir||"?"===a.index)&&t.push(a.path)}),{staged:e,changes:t}},[G]),J=(0,r.useMemo)(()=>w(Y),[Y]),Q=(0,r.useMemo)(()=>w(V),[V]),X=(0,r.useMemo)(()=>C(J),[J]),Z=(0,r.useMemo)(()=>C(Q),[Q]),ee=(0,r.useMemo)(()=>{let e=new Set;return X.forEach(t=>{T.has(t)||e.add(t)}),g&&S(g).forEach(t=>e.add(t)),e},[X,T,g]),et=(0,r.useMemo)(()=>{let e=new Set;return Z.forEach(t=>{O.has(t)||e.add(t)}),g&&S(g).forEach(t=>e.add(t)),e},[Z,O,g]),ea=(0,r.useCallback)(e=>{_(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),es=(0,r.useCallback)(e=>{H(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),el=async t=>{await u.mutateAsync({repoPath:e,action:"stage",data:{files:[t]}})},en=async t=>{await u.mutateAsync({repoPath:e,action:"unstage",data:{files:[t]}})},er=async()=>{await u.mutateAsync({repoPath:e,action:"stage",data:{files:["."]}})},ei=async()=>{await u.mutateAsync({repoPath:e,action:"unstage",data:{files:V}})},eo=async()=>{await u.mutateAsync({repoPath:e,action:"stash",data:{message:$||void 0}}),R(!1),B(""),j(null)},ec=async()=>{await u.mutateAsync({repoPath:e,action:"discard",data:{includeUntracked:!0}}),F(!1),j(null)},ed=async()=>{let t=x.trim();if(t){if(U)return void A(!0);await u.mutateAsync({repoPath:e,action:"commit",data:{message:k(t,f)}}),p(""),b(""),j(null)}},eh=async()=>{let t=x.trim(),a=D.trim();t&&a&&(await u.mutateAsync({repoPath:e,action:"commit",data:{message:k(t,f),initialBranch:a}}),p(""),b(""),j(null),A(!1))};(0,m.v)(N,()=>R(!1),()=>{u.isPending||eo()}),(0,m.v)(P,()=>F(!1),()=>{u.isPending||ec()}),(0,m.v)(M,()=>A(!1),()=>{!u.isPending&&D.trim()&&eh()});let em=e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),V.length>0&&x.trim()&&!u.isPending&&ed())};return n?(0,s.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})}):i?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64 flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-error font-bold",children:"Error Loading Status"}),(0,s.jsx)("p",{className:"text-sm opacity-70",children:c?.message||"An unknown error occurred"}),(0,s.jsxs)("button",{onClick:()=>d(),className:"btn btn-outline btn-sm",children:[(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[16px] mr-1","aria-hidden":"true"}),"Try Again"]})]}):a?(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden bg-base-100",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-base-300 bg-base-100 shrink-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-3 min-w-0",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-bold text-sm",children:"Local Changes"}),G.length>0&&(0,s.jsx)("span",{className:"badge badge-sm badge-ghost text-xs",children:V.length>0?`${V.length} staged, ${Y.length} unstaged`:`${Y.length} changes`}),h?.current&&(0,s.jsxs)("span",{className:"text-xs opacity-60 truncate",children:["on ",(0,s.jsx)("span",{className:"font-mono font-semibold",children:h.current})]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:()=>d(),disabled:u.isPending,title:"Refresh status",children:u.isPending?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"})}),t&&(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:t,title:"Close",children:"✕"})]})]}),(0,s.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,s.jsx)("div",{className:"w-64 border-r border-base-300 flex flex-col bg-base-200/30 shrink-0",children:(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,s.jsxs)("div",{className:"p-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 mb-1",children:[(0,s.jsxs)("h3",{className:"text-xs font-bold uppercase tracking-wider opacity-70",children:["Changes (",Y.length,")"]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[0===Y.length&&V.length>0?(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:ei,title:"Unstage All",children:(0,s.jsx)("i",{className:"iconoir-arrow-up text-[14px]","aria-hidden":"true"})}):(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:er,disabled:0===Y.length,title:"Stage All",children:(0,s.jsx)("i",{className:"iconoir-arrow-down text-[14px]","aria-hidden":"true"})}),(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:()=>R(!0),disabled:0===Y.length&&0===V.length,title:"Stash",children:(0,s.jsx)("i",{className:"iconoir-download-square text-[14px]","aria-hidden":"true"})}),(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square text-error hover:bg-error/10",onClick:()=>F(!0),disabled:0===Y.length,title:"Discard All",children:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"})})]})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[0===Y.length&&(0,s.jsx)("p",{className:"px-2 py-1 text-xs opacity-50 italic",children:"No unstaged changes"}),Y.length>0&&(0,s.jsx)(E,{node:J,selectedFile:g,expandedFolders:ee,onToggleFolder:ea,onSelectFile:j,onActionFile:el,actionType:"stage",actionPending:u.isPending})]})]}),(0,s.jsx)("div",{className:"h-px bg-base-300 mx-3 my-1"}),(0,s.jsxs)("div",{className:"p-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 mb-1",children:[(0,s.jsxs)("h3",{className:"text-xs font-bold uppercase tracking-wider opacity-70",children:["Staged (",V.length,")"]}),V.length>0&&(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:ei,title:"Unstage All",children:(0,s.jsx)("i",{className:"iconoir-arrow-up text-[14px]","aria-hidden":"true"})})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[0===V.length&&(0,s.jsx)("p",{className:"px-2 py-1 text-xs opacity-50 italic",children:"No staged changes"}),V.length>0&&(0,s.jsx)(E,{node:Q,selectedFile:g,expandedFolders:et,onToggleFolder:es,onSelectFile:j,onActionFile:en,actionType:"unstage",actionPending:u.isPending})]})]})]})}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col bg-base-100 overflow-hidden min-h-0",children:[(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col min-h-0",children:g?(0,s.jsx)("div",{className:"h-full flex flex-col",children:(0,s.jsx)(y,{repoPath:e,filePath:g})}):(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center opacity-50 p-4",children:[(0,s.jsx)("i",{className:"iconoir-page-flip text-[32px] mb-2 opacity-60","aria-hidden":"true"}),(0,s.jsx)("p",{className:"text-xs font-semibold",children:"Select a file to view changes"})]})}),(0,s.jsx)("div",{className:"h-1.5 cursor-ns-resize flex items-center justify-center hover:bg-base-200 transition-colors group shrink-0 border-t border-base-300",onMouseDown:e=>{e.preventDefault(),q(!0),W.current={startY:e.clientY,startHeight:I}},children:(0,s.jsx)("div",{className:"w-8 h-1 rounded-full bg-base-300 group-hover:bg-base-400 transition-colors"})}),(0,s.jsx)("div",{className:"flex flex-col border-t border-base-300 bg-base-100 shrink-0",style:{height:I},children:(0,s.jsxs)("div",{className:"flex-1 p-3 overflow-y-auto flex flex-col gap-2",children:[(0,s.jsx)("input",{type:"text",placeholder:"Commit subject...",value:x,onChange:e=>p(e.target.value),onKeyDown:em,className:"input input-bordered input-sm w-full text-sm font-sans shrink-0"}),(0,s.jsx)("textarea",{placeholder:"Commit message body (optional)...",value:f,onChange:e=>b(e.target.value),onKeyDown:em,className:"textarea textarea-bordered textarea-sm w-full text-sm resize-none font-sans flex-1 min-h-[48px]"}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 shrink-0 pt-0.5",children:[(0,s.jsxs)("span",{className:"text-[11px] opacity-40",children:[(0,s.jsx)("kbd",{className:"kbd kbd-xs",children:"⌘"}),"+",(0,s.jsx)("kbd",{className:"kbd kbd-xs",children:"Enter"})," to commit"]}),(0,s.jsxs)("button",{className:"btn btn-primary btn-sm",onClick:ed,disabled:0===V.length||!x.trim()||u.isPending,children:[u.isPending?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs mr-1"}):(0,s.jsx)("i",{className:"iconoir-check text-[14px] mr-1","aria-hidden":"true"}),"Commit Changes"]})]})]})})]})]}),N&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Stash Changes"}),(0,s.jsx)("p",{className:"py-4 opacity-70",children:"Save your local modifications to a new stash entry."}),(0,s.jsx)("div",{className:"py-2",children:(0,s.jsx)("input",{type:"text",placeholder:"Stash message (optional)",value:$,onChange:e=>B(e.target.value),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eo())},className:"input input-bordered w-full"})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>R(!1),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:eo,disabled:u.isPending,children:[u.isPending&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Stash"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>R(!1),children:"close"})})]}),P&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Discard Changes"}),(0,s.jsx)("p",{className:"py-4",children:"Are you sure you want to discard all unstaged changes and new files? This action cannot be undone."}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>F(!1),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:ec,disabled:u.isPending,children:[u.isPending&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Discard"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>F(!1),children:"close"})})]}),M&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"First Commit Branch"}),(0,s.jsx)("p",{className:"py-4 opacity-70",children:"This repository has no commits yet. Choose the branch name for the first commit."}),(0,s.jsx)("div",{className:"py-2",children:(0,s.jsx)("input",{type:"text",placeholder:"Branch name",value:D,onChange:e=>L((0,o.L9)(e.target.value)),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eh())},className:"input input-bordered w-full"})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>A(!1),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:eh,disabled:!D.trim()||u.isPending,children:[u.isPending&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Commit to Branch"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>A(!1),children:"close"})})]})]}):(0,s.jsx)("div",{className:"flex items-center justify-center h-64 opacity-70",children:"No status data available"})}function $(e,t=""){let a={name:"",children:new Map};for(let s of e){let e=s.split("/"),l=a;for(let a=0;a<e.length;a++){let n=e[a];l.children.has(n)||l.children.set(n,{name:n,children:new Map}),l=l.children.get(n),a===e.length-1&&(l.fullPath=t?`${t}/${s}`:s)}}return a}function B(e,t,a){if(t[e])return t[e];let s=e.split("/");for(let e=s.length-1;e>0;e--){let a=s.slice(0,e).join("/");if(t[a])return t[a]}if(a){let e=a.split("/");for(let a=e.length;a>0;a--){let s=e.slice(0,a).join("/");if(t[s])return t[s]}}return null}function P(e){return Array.from(e.children.values()).sort((e,t)=>{let a=e.children.size>0&&!e.fullPath,s=t.children.size>0&&!t.fullPath;return a&&!s?-1:!a&&s?1:e.name.localeCompare(t.name)})}function F(e,t,a=""){let s=[];for(let l of P(e)){if(void 0!==l.fullPath){s.push(l.fullPath);continue}let e=a?`${a}/${l.name}`:l.name;t.has(e)&&s.push(...F(l,t,e))}return s}function M(e){let t=[];for(let a of P(e)){if(a.fullPath){t.push(a.fullPath);continue}t.push(...M(a))}return t}function A({type:e,isActive:t,isInherited:a,onClick:l,showOnHover:n}){return(0,s.jsx)("button",{className:(0,o.cn)("p-0.5 rounded hover:bg-base-300 transition-colors shrink-0 cursor-pointer text-xs",t&&"bg-primary/10",a&&"opacity-50",!t&&!n&&"opacity-0 group-hover:opacity-100"),onClick:l,title:"visible"===e?t?"Remove visible filter":"Show only this branch":t?"Remove hide filter":"Hide this branch",children:"visible"===e?(0,s.jsx)("i",{className:"iconoir-eye text-[14px]","aria-hidden":"true"}):(0,s.jsx)("i",{className:"iconoir-eye-closed text-[14px]","aria-hidden":"true"})})}function D({name:e,groupPath:t,icon:a,isExpanded:l,onToggle:n,visibilityMap:r,onToggleVisibility:i,depth:c=0}){let d=r[t],h=t.includes("/")?t.split("/").slice(0,-1).join("/"):void 0,m=h?r[h]:null,u=d||m,x=!d&&null!==m;return(0,s.jsxs)("div",{className:(0,o.cn)("group flex items-center gap-1 px-2 py-1.5 text-sm rounded-md cursor-pointer hover:bg-base-200 transition-colors font-medium"),style:{paddingLeft:`${12*c+8}px`},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",onClick:n,children:[(0,s.jsx)("span",{className:"text-xs opacity-70",children:l?"▼":"▶"}),(0,s.jsx)("span",{className:"shrink-0",children:a}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:e})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto",children:[(0,s.jsx)(A,{type:"visible",isActive:"visible"===d||x&&"visible"===u,isInherited:x&&"visible"===u,onClick:e=>{e.stopPropagation(),i(t,"visible")},showOnHover:"visible"===d||x&&"visible"===u}),(0,s.jsx)(A,{type:"hidden",isActive:"hidden"===d||x&&"hidden"===u,isInherited:x&&"hidden"===u,onClick:e=>{e.stopPropagation(),i(t,"hidden")},showOnHover:"hidden"===d||x&&"hidden"===u})]})]})}function L({node:e,currentBranch:t,expandedFolders:a,onToggleFolder:l,onCheckout:n,onCheckoutToLocal:r,onCreateBranch:i,onDeleteBranch:d,onRenameBranch:h,onRenameRemoteBranch:m,onRebase:u,onMerge:x,onPushToRemote:p,onPullFromRemote:f,getBranchContextMenuItems:b,onBranchClick:g,onBranchContextMenu:j,onDeleteBranchGroup:N,selectedBranches:y,visibilityMap:v,onToggleVisibility:k,parentPath:w="",depth:C=0,groupPath:S,isRemote:E=!1,trackingInfo:R}){let $=Array.from(e.children.values()).sort((e,t)=>{let a=e.children.size>0&&!e.fullPath,s=t.children.size>0&&!t.fullPath;return a&&!s?-1:!a&&s?1:e.name.localeCompare(t.name)});return(0,s.jsx)(s.Fragment,{children:$.map(e=>{let $=void 0!==e.fullPath,P=e.children.size>0&&!$,F=e.fullPath||(w?`${w}/${e.name}`:e.name),D=a.has(F),T=$&&e.fullPath===t,_=v[F],O=B(F,v,S),H=!_&&null!==O;if(P){let w=M(e).filter(e=>e!==t);return(0,s.jsxs)("div",{children:[(0,s.jsx)(c,{items:[{label:"Delete",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>N(w),danger:!0,disabled:0===w.length}],children:(0,s.jsxs)("div",{className:(0,o.cn)("group flex items-center gap-1 px-2 py-1.5 text-sm rounded-md cursor-pointer hover:bg-base-200 transition-colors opacity-70 select-none"),style:{paddingLeft:`${12*C+8}px`},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 flex-1 min-w-0",onClick:()=>l(F),children:[(0,s.jsx)("span",{className:"text-xs opacity-70",children:D?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[16px] shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:e.name})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto",children:[(0,s.jsx)(A,{type:"visible",isActive:"visible"===_||H&&"visible"===O,isInherited:H&&"visible"===O,onClick:e=>{e.stopPropagation(),k(F,"visible")},showOnHover:"visible"===_||H&&"visible"===O}),(0,s.jsx)(A,{type:"hidden",isActive:"hidden"===_||H&&"hidden"===O,isInherited:H&&"hidden"===O,onClick:e=>{e.stopPropagation(),k(F,"hidden")},showOnHover:"hidden"===_||H&&"hidden"===O})]})]})}),D&&(0,s.jsx)(L,{node:e,currentBranch:t,expandedFolders:a,onToggleFolder:l,onCheckout:n,onCheckoutToLocal:r,onCreateBranch:i,onDeleteBranch:d,onRenameBranch:h,onRenameRemoteBranch:m,onRebase:u,onMerge:x,onPushToRemote:p,onPullFromRemote:f,getBranchContextMenuItems:b,onBranchClick:g,onBranchContextMenu:j,onDeleteBranchGroup:N,selectedBranches:y,visibilityMap:v,onToggleVisibility:k,parentPath:F,depth:C+1,groupPath:S,isRemote:E,trackingInfo:R})]},F)}let I=!E&&e.fullPath?R?.[e.fullPath]:void 0,K=I&&(I.ahead>0||I.behind>0),z=b({branchRef:e.fullPath,branchLeafName:e.name,currentBranch:t,isRemote:E,selectedBranchRefs:y.has(e.fullPath)?Array.from(y):[e.fullPath]}),q=y.has(e.fullPath);return(0,s.jsx)(c,{items:z,children:(0,s.jsxs)("div",{className:(0,o.cn)("group flex items-center gap-2 px-2 py-1.5 text-sm rounded-md cursor-pointer transition-colors select-none",!q&&"hover:bg-base-200",q&&"bg-primary/10 hover:bg-primary/20",T&&"bg-base-200 font-medium text-primary"),style:{paddingLeft:`${12*C+8}px`},onContextMenu:()=>j?.(e.fullPath),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",onClick:t=>g?.(e.fullPath,{isMultiSelect:t.metaKey||t.ctrlKey,isRangeSelect:t.shiftKey}),onDoubleClick:()=>!T&&n(e.fullPath),children:[T?(0,s.jsx)("span",{className:"w-3 h-3 flex items-center justify-center shrink-0",children:(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary"})}):E?(0,s.jsx)("i",{className:"iconoir-globe text-[14px] opacity-50 shrink-0","aria-hidden":"true"}):(0,s.jsx)("i",{className:"iconoir-git-branch text-[14px] opacity-50 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",title:e.fullPath,children:e.name}),K&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs opacity-70 shrink-0",title:`${I.ahead} ahead, ${I.behind} behind ${I.upstream}`,children:[I.ahead>0&&(0,s.jsxs)("span",{className:"flex items-center gap-0.5 text-xs",children:[(0,s.jsx)("i",{className:"iconoir-arrow-up text-[12px]","aria-hidden":"true"}),(0,s.jsx)("span",{children:I.ahead})]}),I.behind>0&&(0,s.jsxs)("span",{className:"flex items-center gap-0.5 text-xs",children:[(0,s.jsx)("i",{className:"iconoir-arrow-down text-[12px]","aria-hidden":"true"}),(0,s.jsx)("span",{children:I.behind})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto",children:[(0,s.jsx)(A,{type:"visible",isActive:"visible"===_||H&&"visible"===O,isInherited:H&&"visible"===O,onClick:e=>{e.stopPropagation(),k(F,"visible")},showOnHover:"visible"===_||H&&"visible"===O}),(0,s.jsx)(A,{type:"hidden",isActive:"hidden"===_||H&&"hidden"===O,isInherited:H&&"hidden"===O,onClick:e=>{e.stopPropagation(),k(F,"hidden")},showOnHover:"hidden"===_||H&&"hidden"===O})]})]})},e.fullPath)})})}var T=a(3321);function _(e){return Math.min(Math.max(e,100),900)}function O(e){return Math.min(Math.max(e,.15),.75)}function H(e){let t=e.indexOf("/");return t<=0||t>=e.length-1?null:{remote:e.slice(0,t),branch:e.slice(t+1)}}async function I(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{return document.execCommand("copy"),!0}catch{return!1}finally{document.body.removeChild(t)}}}let K={isOpen:!1,executionId:null,scriptName:"",branchRef:"",output:"",status:"idle",error:null};function z({repoPath:e}){let t=(0,n.jE)(),{data:a}=(0,l.t0)(),i=(0,l.Y5)(),d=(0,T.useRouter)(),x=(0,T.useSearchParams)(),p=(x.get("branch")??"").trim(),f=(0,r.useRef)(null),b=(0,r.useRef)(null),[g,j]=(0,r.useState)(100),{data:y,isLoading:v,isError:k,error:w,refetch:C,isFetching:S}=(0,l._X)(e,g),{data:E,isLoading:P,refetch:A}=(0,l._6)(e),z=E?.current?.trim()??"",{data:q,refetch:W}=(0,l.en)(e),G=!!(q?.files&&q.files.length>0),[U,V]=(0,r.useState)(null),[Y,J]=(0,r.useState)([]),[Q,X]=(0,r.useState)(null),Z=(0,r.useRef)(0),ee=(0,r.useCallback)(()=>{let e=Date.now();e-Z.current<500||(Z.current=e,Promise.all([A(),C(),W()]))},[A,C,W]);(0,r.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&ee()},t=()=>{"visible"===document.visibilityState&&ee()};return document.addEventListener("visibilitychange",e),window.addEventListener("focus",t),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",t)}},[ee]);let et=(0,r.useCallback)(e=>{V(e),J(e?[e]:[]),X(e)},[]);(0,r.useEffect)(()=>{et(null),sD([]),sT(null)},[e,et]),(0,r.useEffect)(()=>{G||"__LOCAL_CHANGES__"!==U||et(null)},[G,U,et]);let{mutateAsync:ea}=(0,l.a3)(),es=(0,r.useCallback)(()=>{let e=new URLSearchParams(x.toString()).toString();d.push(e?`/workspace/conflicts?${e}`:"/workspace/conflicts")},[d,x]),el=(0,r.useCallback)(e=>{if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("conflict")||t.includes("could not apply")||t.includes("fix conflicts")||t.includes("resolve all conflicts")||t.includes("merge --continue")||t.includes("rebase --continue")},[]);(0,r.useEffect)(()=>{f.current=null,b.current=null},[e]),(0,r.useEffect)(()=>{if(!p||!E)return;let t=`${e}:${p}`;if(f.current!==t){if(E.current===p){f.current=t;return}if(!E.branches.includes(p)){f.current=t,(0,u.oR)({type:"error",title:"Branch Not Found",description:`Branch "${p}" does not exist in this repository.`});return}f.current=t,(async()=>{try{await ea({repoPath:e,action:"checkout",data:{branch:p}})}catch(e){console.error(e)}})()}},[E,e,p,ea]);let[en,er]=(0,r.useState)(!1),[ei,eo]=(0,r.useState)(""),[ec,ed]=(0,r.useState)(null),[eh,em]=(0,r.useState)(!1),[eu,ex]=(0,r.useState)(!1),[ep,ef]=(0,r.useState)(null),[eb,eg]=(0,r.useState)(""),[ej,eN]=(0,r.useState)(!1),[ey,ev]=(0,r.useState)(!1),[ek,ew]=(0,r.useState)(!1),[eC,eS]=(0,r.useState)([]),[eE,eR]=(0,r.useState)(!1),[e$,eB]=(0,r.useState)(!1),[eP,eF]=(0,r.useState)(!1),[eM,eA]=(0,r.useState)(null),[eD,eL]=(0,r.useState)(!1),[eT,e_]=(0,r.useState)(!1),[eO,eH]=(0,r.useState)(null),[eI,eK]=(0,r.useState)(!1),[ez,eq]=(0,r.useState)(!1),[eW,eG]=(0,r.useState)(!1),[eU,eV]=(0,r.useState)([]),[eY,eJ]=(0,r.useState)(!1),[eQ,eX]=(0,r.useState)(!1),[eZ,e0]=(0,r.useState)(!1),[e1,e2]=(0,r.useState)(!1),[e4,e3]=(0,r.useState)(null),[e5,e7]=(0,r.useState)(null),[e6,e8]=(0,r.useState)(""),[e9,te]=(0,r.useState)(!1),[tt,ta]=(0,r.useState)(!1),[ts,tl]=(0,r.useState)(!1),[tn,tr]=(0,r.useState)(null),[ti,to]=(0,r.useState)(""),[tc,td]=(0,r.useState)(!1),[th,tm]=(0,r.useState)(!1),[tu,tx]=(0,r.useState)(null),[tp,tf]=(0,r.useState)(!1),[tb,tg]=(0,r.useState)(!1),[tj,tN]=(0,r.useState)("origin"),[ty,tv]=(0,r.useState)(""),[tk,tw]=(0,r.useState)(!1),[tC,tS]=(0,r.useState)(!1),[tE,tR]=(0,r.useState)(null),[t$,tB]=(0,r.useState)(null),[tP,tF]=(0,r.useState)(!0),[tM,tA]=(0,r.useState)(!1),[tD,tL]=(0,r.useState)("checking"),tT=(0,r.useCallback)(()=>{tS(!1),tR(null),tB(null),tL("checking")},[]),[t_,tO]=(0,r.useState)(!1),[tH,tI]=(0,r.useState)(null),[tK,tz]=(0,r.useState)(null),[tq,tW]=(0,r.useState)(!1),[tG,tU]=(0,r.useState)(!1),[tV,tY]=(0,r.useState)(!1),[tJ,tQ]=(0,r.useState)(""),[tX,tZ]=(0,r.useState)(!1),[t0,t1]=(0,r.useState)("checking"),t2=(0,r.useCallback)(()=>{tO(!1),tI(null),tz(null),t1("checking")},[]),[t4,t3]=(0,r.useState)(!1),[t5,t7]=(0,r.useState)(null),[t6,t8]=(0,r.useState)([]),[t9,ae]=(0,r.useState)(""),[at,aa]=(0,r.useState)([]),[as,al]=(0,r.useState)(""),[an,ar]=(0,r.useState)(null),[ai,ao]=(0,r.useState)(!1),[ac,ad]=(0,r.useState)(!1),[ah,am]=(0,r.useState)(!0),[au,ax]=(0,r.useState)(!1),[ap,af]=(0,r.useState)(""),[ab,ag]=(0,r.useState)(!1),[aj,aN]=(0,r.useState)(null),[ay,av]=(0,r.useState)(!1),[ak,aw]=(0,r.useState)(!1),[aC,aS]=(0,r.useState)(!1),[aE,aR]=(0,r.useState)(null),[a$,aB]=(0,r.useState)([]),[aP,aF]=(0,r.useState)(""),[aM,aA]=(0,r.useState)([]),[aD,aL]=(0,r.useState)(""),[aT,a_]=(0,r.useState)(null),[aO,aH]=(0,r.useState)(!0),[aI,aK]=(0,r.useState)(!1),[az,aq]=(0,r.useState)(!1),[aW,aG]=(0,r.useState)(null),[aU,aV]=(0,r.useState)(!1),[aY,aJ]=(0,r.useState)(!1),[aQ,aX]=(0,r.useState)(!1),[aZ,a0]=(0,r.useState)(!1),[a1,a2]=(0,r.useState)(!1),[a4,a3]=(0,r.useState)(!1),[a5,a7]=(0,r.useState)(null),[a6,a8]=(0,r.useState)(""),[a9,se]=(0,r.useState)(!1),[st,sa]=(0,r.useState)(!1),[ss,sl]=(0,r.useState)(null),[sn,sr]=(0,r.useState)("stash-and-reapply"),[si,so]=(0,r.useState)(!1),[sc,sd]=(0,r.useState)(!1),[sh,sm]=(0,r.useState)(null),[su,sx]=(0,r.useState)(!1),[sp,sf]=(0,r.useState)(!1),[sb,sg]=(0,r.useState)(null),[sj,sN]=(0,r.useState)(!1),[sy,sv]=(0,r.useState)(!1),[sk,sw]=(0,r.useState)(null),[sC,sS]=(0,r.useState)(""),[sE,sR]=(0,r.useState)(""),[s$,sB]=(0,r.useState)(!1),sP=(0,r.useRef)(null),[sF,sM]=(0,r.useState)(null),[sA,sD]=(0,r.useState)([]),[sL,sT]=(0,r.useState)(null),[s_,sO]=(0,r.useState)(!1),sH=(0,r.useRef)(null),[sI,sK]=(0,r.useState)(K),[sz,sq]=(0,r.useState)(!1),[sW,sG]=(0,r.useState)(!1),[sU,sV]=(0,r.useState)(!1),sY="starting"===sI.status||"running"===sI.status,sJ="completed"===sI.status||"failed"===sI.status||"canceled"===sI.status;(0,r.useEffect)(()=>{sJ&&sI.executionId&&t.invalidateQueries({queryKey:["git",e]})},[sJ,sI.executionId,t,e]);let sQ=(0,r.useCallback)(()=>{e2(!1),e3(null),e7(null),e8(""),te(!1)},[]),sX=(0,r.useCallback)(()=>{tl(!1),tr(null),to("")},[]),sZ=(0,r.useCallback)(()=>{tm(!1),tx(null)},[]),s0=(0,r.useCallback)(()=>{tg(!1),tN("origin"),tv("")},[]),s1=(0,r.useCallback)(()=>{sv(!1),sw(null),sS(""),sR("")},[]),s2=(0,r.useCallback)(()=>{sK(K),sV(!1),sq(!1)},[]),s4=(0,r.useCallback)(()=>{if(st){si||(sa(!1),sl(null));return}if(eQ){eX(!1),eV([]);return}if(a4)return void a3(!1);if(en){er(!1),ed(null);return}if(eu){ex(!1),ef(null),eg(""),eN(!1);return}if(aC)return void aS(!1);if(t4)return void t3(!1);if(t_)return void t2();if(tC)return void tT();if(e1)return void sQ();if(ts)return void sX();if(th)return void sZ();if(tb)return void s0();if(eW){eG(!1),eV([]);return}if(ek){ew(!1),eS([]),eR(!1);return}if(eP){eF(!1),eA(null);return}if(eT){e_(!1),eH(null),eK(!1);return}if(sy)return void s1();if(sc)return void sd(!1);if(sp){sf(!1),sg(null);return}s_?sO(!1):sI.isOpen&&sJ&&s2()},[eQ,a4,en,eu,aC,t4,t2,t_,tT,tC,e1,sQ,ts,sX,th,sZ,tb,s0,eW,ek,eP,eT,sy,s1,sc,sp,s_,sI.isOpen,sJ,s2,st,si]),s3=sc||sp||sy||ek||eP||eT||eQ||eW||e1||ts||th||tb||tC||t_||t4||aC||en||eu||a4||st||s_||sI.isOpen;(0,m.v)(s3,s4,()=>{if(st){si||nE();return}if(eQ){eZ||nT();return}if(a4){a6&&!a9&&nN();return}if(en){ei&&!eh&&n_();return}if(eu){eb.trim()&&!ey&&nH();return}if(aC){!aI&&a$.length>0&&aP&&aD&&nb();return}if(t4){!ab&&t6.length>0&&t9&&as&&nx();return}if(t_){tX||nd();return}if(tC){tM||ni();return}if(e1){let e=e5?e6===e5.branch:e6===e4;!e6||e||tt||na();return}if(ts){let e=ti.trim();e&&e!==(tn??"").trim()&&!tc&&ns();return}if(th){tu&&!tp&&nl();return}if(tb){tj.trim()&&ty.trim()&&!tk&&nn();return}if(eW){eY||nL();return}if(ek){e$||l6();return}if(eP){eM&&!eD&&l9();return}if(eT){eO&&!ez&&l8();return}if(sy){sC.trim()&&!s$&&nP();return}if(sc){su||n$();return}if(sp){sj||nB();return}sI.isOpen&&sJ&&s2()});let s5="git-web:history-panel-height",s7="git-web:history-commit-details-message-ratio",[s6,s8]=(0,r.useState)(300),[s9,le]=(0,r.useState)(!1),lt=(0,r.useRef)(null),[la,ls]=(0,r.useState)(.28),[ll,ln]=(0,r.useState)(!1),lr=(0,r.useRef)(null),li=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(a?.historyPanelHeight)s8(_(a.historyPanelHeight));else try{let e=localStorage.getItem(s5);if(e){let t=parseInt(e,10);!isNaN(t)&&t>=100&&t<=900&&s8(t)}}catch(e){console.error("Failed to load panel height from localStorage:",e)}},[a?.historyPanelHeight]),(0,r.useEffect)(()=>{try{localStorage.setItem(s5,String(s6))}catch(e){console.error("Failed to save panel height to localStorage:",e)}},[s6]),(0,r.useEffect)(()=>{try{let e=localStorage.getItem(s7);if(!e)return;let t=parseFloat(e);Number.isNaN(t)||ls(O(t))}catch(e){console.error("Failed to load commit details ratio from localStorage:",e)}},[]),(0,r.useEffect)(()=>{try{localStorage.setItem(s7,String(la))}catch(e){console.error("Failed to save commit details ratio to localStorage:",e)}},[la]),(0,r.useEffect)(()=>{!s9&&li.current&&(i.mutate({historyPanelHeight:s6}),li.current=!1)},[s9,s6,i]);let lo=(0,r.useCallback)(e=>{e.preventDefault(),le(!0),lt.current={startY:e.clientY,startHeight:s6}},[s6]);(0,r.useEffect)(()=>{if(!s9)return;let e=e=>{if(!lt.current)return;let t=lt.current.startY-e.clientY;s8(_(lt.current.startHeight+t)),li.current=!0},t=()=>{le(!1),lt.current=null};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[s9]);let lc=(0,r.useCallback)(e=>{e.preventDefault(),ln(!0)},[]);(0,r.useEffect)(()=>{if(!ll)return;let e=e=>{let t=lr.current;if(!t)return;let a=t.getBoundingClientRect();a.height<=0||ls(O((e.clientY-a.top)/a.height))},t=()=>{ln(!1)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),document.body.style.cursor="ns-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[ll]),(0,r.useEffect)(()=>{if(!s_)return;let e=e=>{sH.current&&!sH.current.contains(e.target)&&sO(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[s_]);let ld=(0,r.useMemo)(()=>E?.branches?$(E.branches):null,[E?.branches]),lh=(0,r.useMemo)(()=>{if(!E?.remotes)return null;var e=E.remotes;let t=new Map;for(let[a,s]of Object.entries(e))t.set(a,$(s,`remotes/${a}`));return t},[E?.remotes]),lm=(0,r.useMemo)(()=>{let e=new Set;for(let t of E?.branches??[])e.add(t);for(let[t,a]of Object.entries(E?.remotes??{}))for(let s of a)e.add(`remotes/${t}/${s}`);return e},[E?.branches,E?.remotes]),lu=(0,r.useMemo)(()=>new Set(sA),[sA]),lx=(0,l.GK)(e),lp=(0,l.Lp)(),lf=(0,r.useMemo)(()=>(lx?.customScripts??[]).filter(e=>"branch"===e.target&&"run-bash-script"===e.action&&e.name.trim().length>0&&e.content.trim().length>0),[lx?.customScripts]),[lb,lg]=(0,r.useState)(!0),[lj,lN]=(0,r.useState)(!0),[ly,lv]=(0,r.useState)(!0),[lk,lw]=(0,r.useState)({}),[lC,lS]=(0,r.useState)(new Set),lE=(0,r.useMemo)(()=>{let e=[];if(lb&&ld&&e.push(...F(ld,lC)),lj&&lh)for(let[t,a]of Array.from(lh.entries())){let s=`__remotes__/${t}`;lC.has(s)&&e.push(...F(a,lC,`remotes/${t}`))}return e},[lC,ld,lb,lh,lj]);(0,r.useEffect)(()=>{if(0===sA.length)return;let e=sA.filter(e=>lm.has(e));e.length!==sA.length&&sD(e),sL&&!lm.has(sL)&&sT(e.length>0?e[e.length-1]:null)},[lm,sL,sA]);let lR=(0,r.useRef)(null);(0,r.useEffect)(()=>{lx&&lx.path!==lR.current&&(lR.current=lx.path,void 0!==lx.localGroupExpanded&&lg(lx.localGroupExpanded),void 0!==lx.remotesGroupExpanded&&lN(lx.remotesGroupExpanded),void 0!==lx.worktreesGroupExpanded&&lv(lx.worktreesGroupExpanded),lx.expandedFolders&&lS(new Set(lx.expandedFolders)),lx.visibilityMap&&lw(lx.visibilityMap))},[lx]);let l$=(0,r.useCallback)(t=>{lp.mutate({path:e,updates:t})},[e,lp]),lB=(0,r.useCallback)(()=>{let e=!lb;lg(e),l$({localGroupExpanded:e})},[lb,l$]),lP=(0,r.useCallback)(()=>{let e=!lj;lN(e),l$({remotesGroupExpanded:e})},[lj,l$]),lF=(0,r.useCallback)(()=>{let e=!ly;lv(e),l$({worktreesGroupExpanded:e})},[l$,ly]),lM=(0,r.useCallback)(e=>{lS(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),l$({expandedFolders:Array.from(a)}),a})},[l$]),lA=(0,r.useCallback)((e,t)=>{lw(a=>{let s={...a};s[e]===t?delete s[e]:s[e]=t;let l={};return Object.entries(s).forEach(([e,t])=>{("visible"===t||"hidden"===t)&&(l[e]=t)}),l$({visibilityMap:l}),s})},[l$]),lD=(0,r.useCallback)(()=>{lw({}),l$({visibilityMap:{}})},[l$]),lL=(0,r.useCallback)((e,t)=>{let a=B(e,lk);if(a)return a;if(t){let t=e.split("/");if(t.length>=2&&"remotes"===t[0]){let e=t[1],a=lk[`__remotes__/${e}`];if(a)return a;let s=lk.__remotes__;if(s)return s}}else{let e=lk.__local__;if(e)return e}return null},[lk]),lT=(0,r.useMemo)(()=>{if(!y?.all||!E?.branches||!E?.branchCommits)return y?.all||[];let e=Object.values(lk).some(e=>"visible"===e),t=Object.values(lk).some(e=>"hidden"===e);if(!e&&!t)return y.all;let a=[...E.branches.map(e=>({branch:e,isRemote:!1}))];if(E.remotes)for(let[e,t]of Object.entries(E.remotes))for(let s of t)a.push({branch:`remotes/${e}/${s}`,isRemote:!0});let s=new Set,l=new Set,n=new Set;for(let{branch:e,isRemote:t}of a){let a=lL(e,t);"visible"===a?s.add(e):"hidden"===a?l.add(e):n.add(e)}let r=new Map(y.all.map(e=>[e.hash,e])),i=(e,t)=>{let a=[e];for(;a.length>0;){let e=a.pop();if(t.has(e))continue;let s=r.get(e);if(s)for(let l of(t.add(e),s.parents||[]))t.has(l)||a.push(l)}},o=new Set;for(let e of s){let t=E.branchCommits[e];t&&i(t,o)}if(e)return y.all.filter(e=>o.has(e.hash));if(t){let e=new Set;for(let t of n){let a=E.branchCommits[t];a&&i(a,e)}return y.all.filter(t=>e.has(t.hash))}return y.all},[y?.all,E?.branches,E?.branchCommits,E?.remotes,lk,lL]),l_=E?.current?.trim()||q?.current?.trim()||"",lO=(0,r.useMemo)(()=>l_&&E?.branchCommits?.[l_]?E.branchCommits[l_]:y?.all&&y.all.length>0?y.all[0].hash:null,[l_,E?.branchCommits,y?.all]),lH=(0,r.useMemo)(()=>G?[{hash:"__LOCAL_CHANGES__",message:"(local changes)",date:new Date().toISOString(),refs:"",body:"",author_name:"",author_email:"",parents:lO?[lO]:[]},...lT]:lT,[G,lT,lO]),lI=(0,r.useMemo)(()=>new Set(Y),[Y]),lK=(0,r.useMemo)(()=>lH.map(e=>e.hash),[lH]),lz=(0,r.useMemo)(()=>U&&"__LOCAL_CHANGES__"!==U?y?.all.find(e=>e.hash===U):null,[y?.all,U]),lq=(0,r.useMemo)(()=>{if(!y?.all||Y.length<2||Y.includes("__LOCAL_CHANGES__"))return null;let e=new Map(y.all.map(e=>[e.hash,e])),t=new Map(lK.map((e,t)=>[e,t])),a=Array.from(new Set(Y)).filter(e=>t.has(e)).sort((e,a)=>(t.get(e)??Number.MAX_SAFE_INTEGER)-(t.get(a)??Number.MAX_SAFE_INTEGER));if(a.length<2)return null;let s=a[0],l=a[a.length-1],n=e.get(s),r=e.get(l);return n&&r?{latestHash:s,oldestHash:l,latestCommit:n,oldestCommit:r}:null},[lK,y?.all,Y]),lW=!!lq;(0,r.useEffect)(()=>{if(0===lK.length){(U||Y.length>0||Q)&&et(null);return}let e=new Set(lK),t=Y.filter(t=>e.has(t));t.length!==Y.length&&J(t),U&&!e.has(U)&&V(t.length>0?t[t.length-1]:null),Q&&!e.has(Q)&&X(t.length>0?t[t.length-1]:null)},[lK,U,Y,Q,et]);let lG=(0,r.useCallback)((e,t)=>{let a=t?.isRangeSelect??!1,s=t?.isMultiSelect??!1;if(a){let t=Q??U??e,a=lK.indexOf(t),s=lK.indexOf(e);if(-1!==a&&-1!==s){let[l,n]=a<s?[a,s]:[s,a];J(lK.slice(l,n+1)),V(e),X(t);return}}if(s){if(lI.has(e)){let t=Y.filter(t=>t!==e);J(t),V(a=>a!==e?a:t.length>0?t[t.length-1]:null),Q===e&&X(t.length>0?t[t.length-1]:null)}else J([...Y,e]),V(e),X(e);return}et(e)},[lK,lI,Y,U,Q,et]),lU=(0,r.useMemo)(()=>lT.filter(e=>lI.has(e.hash)).reverse(),[lT,lI]),lV=(0,r.useMemo)(()=>Object.values(lk).some(e=>"visible"===e||"hidden"===e),[lk]),lY=(0,r.useMemo)(()=>{let e=new Set;if(E?.branches)for(let t of E.branches)"hidden"===lL(t,!1)&&e.add(t);if(E?.remotes)for(let[t,a]of Object.entries(E.remotes))for(let s of a){let a=`remotes/${t}/${s}`;"hidden"===lL(a,!0)&&e.add(a)}return e},[E?.branches,E?.remotes,lL]);(0,r.useEffect)(()=>{lV&&lT.length<50&&!S&&g<5e3&&y?.all&&y.all.length>=g&&j(e=>Math.min(e+100,5e3))},[lV,lT.length,S,g,y?.all]),(0,r.useEffect)(()=>{sF&&y?.all&&!S&&(y.all.some(e=>e.hash===sF)?requestAnimationFrame(()=>{sP.current?.scrollToCommit(sF)&&(et(sF),sM(null))}):g<5e3?j(e=>e+100):(console.warn("Could not find commit after loading 5000 commits"),sM(null)))},[sF,y?.all,S,g,et]);let lJ=(0,r.useCallback)(e=>{if(!E?.branchCommits)return;let t=E.branchCommits[e];if(t){if(y?.all?.some(e=>e.hash===t)&&sP.current&&sP.current.scrollToCommit(t))return void et(t);sM(t),et(t)}},[E?.branchCommits,y?.all,et]);(0,r.useEffect)(()=>{if(!p||!E?.branchCommits||z!==p)return;let t=`${e}:${p}`;b.current!==t&&(b.current=t,lJ(p))},[z,E?.branchCommits,e,p,lJ]);let lQ=(0,r.useCallback)((e,t)=>{let a=t?.isRangeSelect??!1,s=t?.isMultiSelect??!1;if(a){let t=sL??e,a=lE.indexOf(t),s=lE.indexOf(e);if(-1!==a&&-1!==s){let[l,n]=a<s?[a,s]:[s,a],r=lE.slice(l,n+1);lu.has(e)?sD(sA.filter(e=>!r.includes(e))):sD(Array.from(new Set([...sA,...r]))),sT(t)}else sD([e]),sT(e);return}if(s){lu.has(e)?sD(sA.filter(t=>t!==e)):sD([...sA,e]),sT(e);return}sD([e]),sT(e),lJ(e)},[sL,lE,lJ,sA,lu]),lX=(0,r.useCallback)(e=>{lu.has(e)||(sD([e]),sT(e))},[lu]),lZ=(0,r.useCallback)(async(t,a)=>{sV(!1),sq(!1),sK({isOpen:!0,executionId:null,scriptName:t.name,branchRef:a,output:"",status:"starting",error:null});try{let s=await fetch("/api/custom-scripts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"start",repoPath:e,branchRef:a,scriptContent:t.content})}),l=await s.json();if(!s.ok)throw Error(l.error||"Failed to start script execution");let n=[];l.previousBranch&&l.checkedOutBranch&&l.previousBranch!==l.checkedOutBranch&&n.push(`[info] Checked out ${l.checkedOutBranch} (from ${l.previousBranch})`),sK(e=>({...e,executionId:l.executionId,output:[n.join("\n"),l.output].filter(Boolean).join("\n"),status:l.status,error:null}))}catch(e){sK(t=>({...t,status:"failed",error:e.message,output:t.output?`${t.output}
|
|
4
|
-
[error] ${e.message}`:`[error] ${e.message}`}))}},[e]),l0=(0,r.useCallback)(async()=>{if(sI.executionId&&sY){sq(!0);try{let e=await fetch("/api/custom-scripts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"cancel",executionId:sI.executionId})}),
|
|
5
|
-
[error] ${e.message}`})),sq(!1)}}},[sI.executionId,sY]),l1=(0,r.useCallback)(async()=>{if(sW)return;sG(!0);let e=await I(sI.output);sG(!1),sV(e),e&&setTimeout(()=>sV(!1),1500)},[sW,sI.output]);(0,r.useEffect)(()=>{if(!sI.executionId||!sY)return;let e=!1,
|
|
6
|
-
[error] ${t.message}`:`[error] ${t.message}`}))}};return a(),()=>{e=!0,t&&clearTimeout(t)}},[sI.executionId,sY]);let l2=e=>{let t=e.filter(e=>e!==l_);0!==t.length&&(eS(t),eR(!1),ew(!0))},l4=e=>{l2([e])},l3=(0,r.useCallback)(e=>{let t=e.trim();t&&(eA(t),eF(!0))},[]),l5=(0,r.useCallback)(()=>{e_(!1),eH(null),eK(!1)},[]),l7=(0,r.useCallback)(e=>{e&&(eH(e),eK(!1),e_(!0))},[]),l6=async()=>{if(0!==eC.length){eB(!0);try{let t=new Map,a=(e,a,s)=>{t.has(e)||t.set(e,{branchRef:a,run:s})},l=new Set;if(eE)for(let e of eC){if(e.startsWith("remotes/"))continue;let t=E?.trackingInfo?.[e];t?.upstream&&l.add(t.upstream)}for(let t of l){let[s,...l]=t.split("/"),n=l.join("/");if(s&&n){let t=`${s}/${n}`;a(`remote:${t}`,t,()=>ea({repoPath:e,action:"delete-remote-branch",data:{remote:s,branch:n},suppressErrorToast:!0}))}}for(let t of eC){if(t.startsWith("remotes/")){let s=t.split("/");if(s.length>=3){let t=s[1],l=s.slice(2).join("/"),n=`${t}/${l}`;a(`remote:${n}`,n,()=>ea({repoPath:e,action:"delete-remote-branch",data:{remote:t,branch:l},suppressErrorToast:!0}))}continue}a(`local:${t}`,t,()=>ea({repoPath:e,action:"delete-branch",data:{branch:t},suppressErrorToast:!0}))}let n=Array.from(t.values()),r=(await Promise.allSettled(n.map(e=>e.run()))).flatMap((e,t)=>{if("fulfilled"===e.status)return[];let a=n[t].branchRef;return console.error(`Failed to delete branch "${a}":`,e.reason),[a]});r.length>0&&(0,u.oR)({type:"error",title:1===r.length?"Failed to Delete 1 Branch":`Failed to Delete ${r.length} Branches`,description:(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{children:"The following branches could not be deleted:"}),(0,s.jsx)("ul",{className:"mt-1 max-h-40 overflow-y-auto list-disc pl-5",children:r.map(e=>(0,s.jsx)("li",{className:"break-all",children:e},e))})]}),duration:1e4}),ew(!1),eS([]),eR(!1),sD([]),sT(null)}catch(e){console.error(e)}finally{eB(!1)}}},l8=async()=>{if(eO){eq(!0);try{if(await ea({repoPath:e,action:"delete-tag",data:{tag:eO}}),eI&&nK)try{await ea({repoPath:e,action:"delete-remote-tag",data:{remote:nK,tag:eO}})}catch(e){console.error("Failed to delete remote tag:",e)}l5()}catch(e){console.error(e)}finally{eq(!1)}}},l9=async()=>{if(eM){eL(!0);try{await ea({repoPath:e,action:"delete-worktree",data:{path:eM}}),eF(!1),eA(null)}catch(e){console.error(e)}finally{eL(!1)}}},ne=e=>{e3(e),e7(null),e8(e),te(!1),e2(!0)},nt=e=>{let t=e.split("/");if(t.length<3||"remotes"!==t[0])return;let a=t[1],s=t.slice(2).join("/");a&&s&&(e3(e),e7({remote:a,branch:s}),e8(s),te(!1),e2(!0))},na=async()=>{if(e4&&e6){if(e5?e5.branch===e6:e4===e6)return void sQ();ta(!0);try{e5?await ea({repoPath:e,action:"rename-remote-branch",data:{remote:e5.remote,oldName:e5.branch,newName:e6}}):await ea({repoPath:e,action:"rename-branch",data:{oldName:e4,newName:e6,renameTrackingRemote:e9}}),sQ()}catch(e){console.error(e)}finally{ta(!1)}}},ns=async()=>{if(!tn)return;let t=tn.trim(),a=ti.trim();if(t&&a){if(t===a)return void sX();td(!0);try{await ea({repoPath:e,action:"rename-remote",data:{oldName:t,newName:a}}),sX()}catch(e){console.error(e)}finally{td(!1)}}},nl=async()=>{if(!tu)return;let t=tu.trim();if(t){tf(!0);try{await ea({repoPath:e,action:"delete-remote",data:{name:t}}),sZ()}catch(e){console.error(e)}finally{tf(!1)}}},nn=async()=>{let t=tj.trim(),a=ty.trim();if(t&&a){tw(!0);try{await ea({repoPath:e,action:"add-remote",data:{name:t,url:a}}),s0()}catch(e){console.error(e)}finally{tw(!1)}}},nr=({sourceBranch:e,targetBranch:t})=>{tR(e),tB(t),tF(!0),tL("checking"),tS(!0)},ni=async()=>{if(tE&&t$){tA(!0);try{await ea({repoPath:e,action:"checkout",data:{branch:tE}}),await ea({repoPath:e,action:"rebase",data:{ontoBranch:t$,stashChanges:tP}}),tT()}catch(e){el(e)&&(tT(),es(),(0,u.oR)({type:"warning",title:"Rebase Conflict Detected",description:"Redirected to the conflict resolver. Resolve conflicted files, then continue or abort.",duration:12e3})),console.error(e)}finally{tA(!1)}}};(0,r.useEffect)(()=>{if(!tC||!tE||!t$)return;let t=!1;return tL("checking"),(async()=>{try{let a=await ea({repoPath:e,action:"check-rebase-conflicts",data:{sourceBranch:tE,ontoBranch:t$}});t||tL(a.hasConflicts?"has-conflicts":"no-conflict")}catch(e){console.error(e),t||tL("has-conflicts")}})(),()=>{t=!0}},[tC,tE,t$,e,ea]);let no=({sourceBranch:e,targetBranch:t})=>{tI(t),tz(e),tW(!1),tU(!1),tY(!1),tQ(""),t1("checking"),tO(!0)},nc=(0,r.useCallback)(t=>{if(tU(t),t){if(!tK)return void tQ("");(async()=>{try{let t=await ea({repoPath:e,action:"get-latest-commit-message",data:{branch:tK}});tQ("string"==typeof t?.message?t.message:"")}catch(e){console.error(e),tQ("")}})()}},[tK,e,ea]),nd=async()=>{if(tH&&tK){tZ(!0);try{await ea({repoPath:e,action:"checkout",data:{branch:tH}}),await ea({repoPath:e,action:"merge",data:{targetBranch:tK,rebaseBeforeMerge:tq,squash:tG,fastForward:tV,squashMessage:tG?tJ:void 0}}),t2()}catch(e){el(e)&&(t2(),es(),(0,u.oR)({type:"warning",title:"Merge Conflict Detected",description:"Redirected to the conflict resolver. Resolve conflicted files, then continue or abort.",duration:12e3})),console.error(e)}finally{tZ(!1)}}};(0,r.useEffect)(()=>{if(!t_||!tK||!tH)return;let t=!1;return t1("checking"),(async()=>{try{let a=await ea({repoPath:e,action:"check-merge-conflicts",data:{sourceBranch:tK,targetBranch:tH}});t||t1(a.hasConflicts?"has-conflicts":"no-conflict")}catch(e){console.error(e),t||t1("has-conflicts")}})(),()=>{t=!0}},[t_,tK,tH,e,ea]);let nh=async t=>{t7(t),aN(null),t8([]),aa([]),ae(""),al(""),ar(null),ao(!1),ad(!1),am(!0),ax(!1),af(""),t3(!0),av(!0);try{let a=await ea({repoPath:e,action:"get-remotes",data:{}});if(!a.remotes||0===a.remotes.length){aN("No remote repository configured. Please add a remote first."),av(!1);return}t8(a.remotes);let s=await ea({repoPath:e,action:"get-tracking-branch",data:{branch:t}});ar(s.tracking);let l=s.tracking?.remote,n=l&&a.remotes.includes(l)?l:a.remotes[0];ae(n),aw(!0);let r=await ea({repoPath:e,action:"get-remote-branches",data:{remote:n}});aa(r.branches||[]),s.tracking?.remote===n&&s.tracking?.branch?al(s.tracking.branch):(r.branches?.includes(t),al(t))}catch(e){console.error(e),aN(e.message||"Failed to load remote information")}finally{av(!1),aw(!1)}},nm=async t=>{ae(t),aw(!0),aa([]);try{let a=await ea({repoPath:e,action:"get-remote-branches",data:{remote:t}});aa(a.branches||[]),an?.remote===t&&an?.branch?al(an.branch):al(t5||"")}catch(e){console.error(e),aN(e.message||"Failed to load remote branches")}finally{aw(!1)}},nu=(0,r.useCallback)(t=>{if(ax(t),t){if(!t5)return void af("");(async()=>{try{let t=await ea({repoPath:e,action:"get-latest-commit-message",data:{branch:t5}});af("string"==typeof t?.message?t.message:"")}catch(e){console.error(e),af("")}})()}},[t5,e,ea]),nx=async()=>{if(t5&&t9&&as){ag(!0),aN(null);try{let t=!at.includes(as)||an?.remote!==t9||an?.branch!==as;await ea({repoPath:e,action:"push-to-remote",data:{localBranch:t5,remote:t9,remoteBranch:as,rebaseFirst:!ac&&ai,forcePush:ac,pushLocalOnlyTags:ah,setUpstream:t,squash:au,squashMessage:ap}}),await ea({repoPath:e,action:"fetch",data:{remote:t9}}),t3(!1),t7(null)}catch(e){console.error(e),aN(e.message||"Failed to push to remote")}finally{ag(!1)}}},np=async t=>{aR(t),aG(null),aB([]),aA([]),aF(""),aL(""),a_(null),aH(!0),aS(!0),aV(!0);try{let a=await ea({repoPath:e,action:"get-remotes",data:{}});if(!a.remotes||0===a.remotes.length){aG("No remote repository configured. Please add a remote first."),aV(!1);return}aB(a.remotes);let s=await ea({repoPath:e,action:"get-tracking-branch",data:{branch:t}});a_(s.tracking);let l=s.tracking?.remote,n=l&&a.remotes.includes(l)?l:a.remotes[0];aF(n),aJ(!0);let r=await ea({repoPath:e,action:"get-remote-branches",data:{remote:n}});aA(r.branches||[]),s.tracking?.remote===n&&s.tracking?.branch?aL(s.tracking.branch):aL("")}catch(e){console.error(e),aG(e.message||"Failed to load remote information")}finally{aV(!1),aJ(!1)}},nf=async t=>{aF(t),aJ(!0),aA([]),aL("");try{let a=await ea({repoPath:e,action:"get-remote-branches",data:{remote:t}});aA(a.branches||[]),aT?.remote===t&&aT?.branch?aL(aT.branch):aL("")}catch(e){console.error(e),aG(e.message||"Failed to load remote branches")}finally{aJ(!1)}},nb=async()=>{if(aE&&aP&&aD){aK(!0),aG(null);try{await ea({repoPath:e,action:"pull-from-remote",data:{localBranch:aE,remote:aP,remoteBranch:aD,rebase:aO}}),aS(!1),aR(null)}catch(e){console.error(e),aG(e.message||"Failed to pull from remote")}finally{aK(!1)}}},ng=e=>{a7(e),a8(e.split("/").slice(2).join("/")),a3(!0)},nj=(0,r.useMemo)(()=>ss?"local"===ss.type?ss.branch:ss.localBranch:"",[ss]),nN=async()=>{if(a5&&a6){if(G){a3(!1),sl({type:"remote",remoteBranch:a5,localBranch:a6}),sr("stash-and-reapply"),sa(!0);return}se(!0);try{await ea({repoPath:e,action:"checkout-to-local",data:{remoteBranch:a5,localBranch:a6}}),a3(!1),a7(null),a8("")}catch(e){console.error(e)}finally{se(!1)}}},ny=async()=>{aX(!0);try{await ea({repoPath:e,action:"fetch",data:{allRemotes:!0}})}catch(e){console.error(e)}finally{aX(!1)}},nv=(0,r.useCallback)(async()=>{if(!aZ){a0(!0);try{let t=await fetch("/api/fs/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a.error||"Failed to open repository folder")}catch(e){(0,u.oR)({type:"error",title:"Failed to Open Repo Folder",description:e instanceof Error?e.message:"Unknown error"})}finally{a0(!1)}}},[aZ,e]),nk=(0,r.useCallback)(async()=>{if(!a1){a2(!0);try{let t=await fetch("/api/fs/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a.error||"Failed to open terminal")}catch(e){(0,u.oR)({type:"error",title:"Failed to Open Terminal",description:e instanceof Error?e.message:"Unknown error"})}finally{a2(!1)}}},[a1,e]),nw=(0,r.useCallback)((e,t)=>{if(t)return;let a=window.location.origin;try{window.top?.location?.origin&&(a=window.top.location.origin)}catch{}let s=`${a}/workspace?path=${encodeURIComponent(e)}`;window.open(s,"_blank","noopener,noreferrer")},[]),nC=async t=>{try{await ea({repoPath:e,action:"fetch",data:{remote:t}})}catch(e){console.error(e)}},nS=async t=>{if(t!==l_){if(G){sl({type:"local",branch:t}),sr("stash-and-reapply"),sa(!0);return}try{await ea({repoPath:e,action:"checkout",data:{branch:t}})}catch(e){console.error(e)}}},nE=async()=>{if(ss){so(!0);try{"local"===ss.type?await ea({repoPath:e,action:"checkout",data:{branch:ss.branch,switchStrategy:sn}}):(await ea({repoPath:e,action:"checkout-to-local",data:{remoteBranch:ss.remoteBranch,localBranch:ss.localBranch,switchStrategy:sn}}),a7(null),a8("")),sa(!1),sl(null)}catch(e){console.error(e)}finally{so(!1)}}},nR=async e=>{sm(e),sd(!0)},n$=async()=>{if(sh){sx(!0);try{await ea({repoPath:e,action:"reset",data:{commitHash:sh,mode:"hard"}}),sd(!1),sm(null)}catch(e){console.error(e)}finally{sx(!1)}}},nB=async()=>{if(sb){sN(!0);try{await ea({repoPath:e,action:"revert",data:{commitHash:sb.hash}}),sf(!1),sg(null)}catch(e){console.error(e)}finally{sN(!1)}}},nP=async()=>{if(sk&&sC.trim()){sB(!0);try{let t,a;await ea({repoPath:e,action:"reword",data:{commitHash:sk.hash,message:(t=sC.trim(),(a=sE.replace(/\r\n/g,"\n")).trim()?`${t}
|
|
3
|
+
${s}`:t}function w(e){let a={name:"",path:"",children:new Map};for(let t of e){let e=t.split("/").filter(Boolean),s=a,l="";for(let a=0;a<e.length;a++){let n=e[a];l=l?`${l}/${n}`:n,s.children.has(n)||s.children.set(n,{name:n,path:l,children:new Map}),s=s.children.get(n),a===e.length-1&&(s.filePath=t)}}return a}function C(e){let a=[];return Array.from(e.children.values()).forEach(e=>{e.children.size>0&&(a.push(e.path),a.push(...C(e)))}),a}function S(e){let a=e.split("/").filter(Boolean),t=[];for(let e=1;e<a.length;e++)t.push(a.slice(0,e).join("/"));return t}function E({node:e,selectedFile:a,expandedFolders:t,onToggleFolder:l,onSelectFile:n,onActionFile:r,actionType:i,actionPending:c,depth:d=0}){let h=Array.from(e.children.values()).sort((e,a)=>{let t=e.children.size>0,s=a.children.size>0;return t&&!s?-1:!t&&s?1:e.name.localeCompare(a.name)});return(0,s.jsx)(s.Fragment,{children:h.map(e=>{if(e.children.size>0){let o=t.has(e.path);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 text-xs rounded cursor-pointer hover:bg-base-300 transition-colors opacity-80",style:{paddingLeft:`${12*d+8}px`},onClick:()=>l(e.path),title:e.path,children:[(0,s.jsx)("span",{className:"text-[10px] opacity-70",children:o?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[14px] opacity-70","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate flex-1",children:e.name})]}),o&&(0,s.jsx)(E,{node:e,selectedFile:a,expandedFolders:t,onToggleFolder:l,onSelectFile:n,onActionFile:r,actionType:i,actionPending:c,depth:d+1})]},e.path)}let h=e.filePath;return h?(0,s.jsxs)("div",{className:(0,o.cn)("flex items-center justify-between gap-2 px-2 py-1.5 rounded-md cursor-pointer group hover:bg-base-300 transition-colors text-sm",a===h&&"bg-base-300 font-medium text-primary"),style:{paddingLeft:`${12*d+8}px`},onClick:()=>n(h),title:h,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("i",{className:"iconoir-page text-[14px] opacity-70 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate flex-1 font-mono text-xs",children:e.name})]}),(0,s.jsx)("button",{className:(0,o.cn)("btn btn-ghost btn-xs btn-square opacity-0 group-hover:opacity-100 transition-opacity","stage"===i?"text-success hover:bg-success/10":"text-error hover:bg-error/10"),onClick:e=>{e.stopPropagation(),r(h)},disabled:c,children:(0,s.jsx)("i",{className:(0,o.cn)("text-[14px]","stage"===i?"iconoir-plus-circle":"iconoir-minus-circle"),"aria-hidden":"true"})})]},h):null})})}function R({repoPath:e,onClose:a}){let{data:t,isLoading:n,isError:i,error:c,refetch:d}=(0,l.en)(e),{data:h}=(0,l._6)(e),u=(0,l.a3)(),[x,p]=(0,r.useState)(""),[b,f]=(0,r.useState)(""),[g,j]=(0,r.useState)(null),[N,R]=(0,r.useState)(!1),[$,B]=(0,r.useState)(""),[P,F]=(0,r.useState)(!1),[M,A]=(0,r.useState)(!1),[D,L]=(0,r.useState)("main"),[T,_]=(0,r.useState)(new Set),[O,H]=(0,r.useState)(new Set),[I,K]=(0,r.useState)(180),[z,q]=(0,r.useState)(!1),W=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{if(!z||!W.current)return;let a=W.current.startY-e.clientY;K(Math.max(120,Math.min(600,W.current.startHeight+a)))},a=()=>{q(!1),W.current=null,document.body.style.cursor="default",document.body.style.userSelect="auto"};return z&&(window.addEventListener("mousemove",e),window.addEventListener("mouseup",a),document.body.style.cursor="ns-resize",document.body.style.userSelect="none"),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",a),document.body.style.cursor="default",document.body.style.userSelect="auto"}},[z]);let G=t?.files??v,U=!!h&&0===h.branches.length,{staged:V,changes:Y}=(0,r.useMemo)(()=>{let e=[],a=[];return G.forEach(t=>{" "!==t.index&&"?"!==t.index&&e.push(t.path),(" "!==t.working_dir||"?"===t.index)&&a.push(t.path)}),{staged:e,changes:a}},[G]),J=(0,r.useMemo)(()=>w(Y),[Y]),Q=(0,r.useMemo)(()=>w(V),[V]),X=(0,r.useMemo)(()=>C(J),[J]),Z=(0,r.useMemo)(()=>C(Q),[Q]),ee=(0,r.useMemo)(()=>{let e=new Set;return X.forEach(a=>{T.has(a)||e.add(a)}),g&&S(g).forEach(a=>e.add(a)),e},[X,T,g]),ea=(0,r.useMemo)(()=>{let e=new Set;return Z.forEach(a=>{O.has(a)||e.add(a)}),g&&S(g).forEach(a=>e.add(a)),e},[Z,O,g]),et=(0,r.useCallback)(e=>{_(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),es=(0,r.useCallback)(e=>{H(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),el=async a=>{await u.mutateAsync({repoPath:e,action:"stage",data:{files:[a]}})},en=async a=>{await u.mutateAsync({repoPath:e,action:"unstage",data:{files:[a]}})},er=async()=>{await u.mutateAsync({repoPath:e,action:"stage",data:{files:["."]}})},ei=async()=>{await u.mutateAsync({repoPath:e,action:"unstage",data:{files:V}})},eo=async()=>{await u.mutateAsync({repoPath:e,action:"stash",data:{message:$||void 0}}),R(!1),B(""),j(null)},ec=async()=>{await u.mutateAsync({repoPath:e,action:"discard",data:{includeUntracked:!0}}),F(!1),j(null)},ed=async()=>{let a=x.trim();if(a){if(U)return void A(!0);await u.mutateAsync({repoPath:e,action:"commit",data:{message:k(a,b)}}),p(""),f(""),j(null)}},eh=async()=>{let a=x.trim(),t=D.trim();a&&t&&(await u.mutateAsync({repoPath:e,action:"commit",data:{message:k(a,b),initialBranch:t}}),p(""),f(""),j(null),A(!1))};(0,m.v)(N,()=>R(!1),()=>{u.isPending||eo()}),(0,m.v)(P,()=>F(!1),()=>{u.isPending||ec()}),(0,m.v)(M,()=>A(!1),()=>{!u.isPending&&D.trim()&&eh()});let em=e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),V.length>0&&x.trim()&&!u.isPending&&ed())};return n?(0,s.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})}):i?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64 flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-error font-bold",children:"Error Loading Status"}),(0,s.jsx)("p",{className:"text-sm opacity-70",children:c?.message||"An unknown error occurred"}),(0,s.jsxs)("button",{onClick:()=>d(),className:"btn btn-outline btn-sm",children:[(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[16px] mr-1","aria-hidden":"true"}),"Try Again"]})]}):t?(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden bg-base-100",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-base-300 bg-base-100 shrink-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-3 min-w-0",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-bold text-sm",children:"Local Changes"}),G.length>0&&(0,s.jsx)("span",{className:"badge badge-sm badge-ghost text-xs",children:V.length>0?`${V.length} staged, ${Y.length} unstaged`:`${Y.length} changes`}),h?.current&&(0,s.jsxs)("span",{className:"text-xs opacity-60 truncate",children:["on ",(0,s.jsx)("span",{className:"font-mono font-semibold",children:h.current})]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:()=>d(),disabled:u.isPending,title:"Refresh status",children:u.isPending?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"})}),a&&(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:a,title:"Close",children:"✕"})]})]}),(0,s.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,s.jsx)("div",{className:"w-64 border-r border-base-300 flex flex-col bg-base-200/30 shrink-0",children:(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,s.jsxs)("div",{className:"p-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 mb-1",children:[(0,s.jsxs)("h3",{className:"text-xs font-bold uppercase tracking-wider opacity-70",children:["Changes (",Y.length,")"]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[0===Y.length&&V.length>0?(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:ei,title:"Unstage All",children:(0,s.jsx)("i",{className:"iconoir-arrow-up text-[14px]","aria-hidden":"true"})}):(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:er,disabled:0===Y.length,title:"Stage All",children:(0,s.jsx)("i",{className:"iconoir-arrow-down text-[14px]","aria-hidden":"true"})}),(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:()=>R(!0),disabled:0===Y.length&&0===V.length,title:"Stash",children:(0,s.jsx)("i",{className:"iconoir-download-square text-[14px]","aria-hidden":"true"})}),(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square text-error hover:bg-error/10",onClick:()=>F(!0),disabled:0===Y.length,title:"Discard All",children:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"})})]})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[0===Y.length&&(0,s.jsx)("p",{className:"px-2 py-1 text-xs opacity-50 italic",children:"No unstaged changes"}),Y.length>0&&(0,s.jsx)(E,{node:J,selectedFile:g,expandedFolders:ee,onToggleFolder:et,onSelectFile:j,onActionFile:el,actionType:"stage",actionPending:u.isPending})]})]}),(0,s.jsx)("div",{className:"h-px bg-base-300 mx-3 my-1"}),(0,s.jsxs)("div",{className:"p-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 mb-1",children:[(0,s.jsxs)("h3",{className:"text-xs font-bold uppercase tracking-wider opacity-70",children:["Staged (",V.length,")"]}),V.length>0&&(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:ei,title:"Unstage All",children:(0,s.jsx)("i",{className:"iconoir-arrow-up text-[14px]","aria-hidden":"true"})})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[0===V.length&&(0,s.jsx)("p",{className:"px-2 py-1 text-xs opacity-50 italic",children:"No staged changes"}),V.length>0&&(0,s.jsx)(E,{node:Q,selectedFile:g,expandedFolders:ea,onToggleFolder:es,onSelectFile:j,onActionFile:en,actionType:"unstage",actionPending:u.isPending})]})]})]})}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col bg-base-100 overflow-hidden min-h-0",children:[(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col min-h-0",children:g?(0,s.jsx)("div",{className:"h-full flex flex-col",children:(0,s.jsx)(y,{repoPath:e,filePath:g})}):(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center opacity-50 p-4",children:[(0,s.jsx)("i",{className:"iconoir-page-flip text-[32px] mb-2 opacity-60","aria-hidden":"true"}),(0,s.jsx)("p",{className:"text-xs font-semibold",children:"Select a file to view changes"})]})}),(0,s.jsx)("div",{className:"h-1.5 cursor-ns-resize flex items-center justify-center hover:bg-base-200 transition-colors group shrink-0 border-t border-base-300",onMouseDown:e=>{e.preventDefault(),q(!0),W.current={startY:e.clientY,startHeight:I}},children:(0,s.jsx)("div",{className:"w-8 h-1 rounded-full bg-base-300 group-hover:bg-base-400 transition-colors"})}),(0,s.jsx)("div",{className:"flex flex-col border-t border-base-300 bg-base-100 shrink-0",style:{height:I},children:(0,s.jsxs)("div",{className:"flex-1 p-3 overflow-y-auto flex flex-col gap-2",children:[(0,s.jsx)("input",{type:"text",placeholder:"Commit subject...",value:x,onChange:e=>p(e.target.value),onKeyDown:em,className:"input input-bordered input-sm w-full text-sm font-sans shrink-0"}),(0,s.jsx)("textarea",{placeholder:"Commit message body (optional)...",value:b,onChange:e=>f(e.target.value),onKeyDown:em,className:"textarea textarea-bordered textarea-sm w-full text-sm resize-none font-sans flex-1 min-h-[48px]"}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 shrink-0 pt-0.5",children:[(0,s.jsxs)("span",{className:"text-[11px] opacity-40",children:[(0,s.jsx)("kbd",{className:"kbd kbd-xs",children:"⌘"}),"+",(0,s.jsx)("kbd",{className:"kbd kbd-xs",children:"Enter"})," to commit"]}),(0,s.jsxs)("button",{className:"btn btn-primary btn-sm",onClick:ed,disabled:0===V.length||!x.trim()||u.isPending,children:[u.isPending?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs mr-1"}):(0,s.jsx)("i",{className:"iconoir-check text-[14px] mr-1","aria-hidden":"true"}),"Commit Changes"]})]})]})})]})]}),N&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Stash Changes"}),(0,s.jsx)("p",{className:"py-4 opacity-70",children:"Save your local modifications to a new stash entry."}),(0,s.jsx)("div",{className:"py-2",children:(0,s.jsx)("input",{type:"text",placeholder:"Stash message (optional)",value:$,onChange:e=>B(e.target.value),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eo())},className:"input input-bordered w-full"})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>R(!1),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:eo,disabled:u.isPending,children:[u.isPending&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Stash"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>R(!1),children:"close"})})]}),P&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Discard Changes"}),(0,s.jsx)("p",{className:"py-4",children:"Are you sure you want to discard all unstaged changes and new files? This action cannot be undone."}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>F(!1),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:ec,disabled:u.isPending,children:[u.isPending&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Discard"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>F(!1),children:"close"})})]}),M&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"First Commit Branch"}),(0,s.jsx)("p",{className:"py-4 opacity-70",children:"This repository has no commits yet. Choose the branch name for the first commit."}),(0,s.jsx)("div",{className:"py-2",children:(0,s.jsx)("input",{type:"text",placeholder:"Branch name",value:D,onChange:e=>L((0,o.L9)(e.target.value)),autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eh())},className:"input input-bordered w-full"})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>A(!1),children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:eh,disabled:!D.trim()||u.isPending,children:[u.isPending&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Commit to Branch"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>A(!1),children:"close"})})]})]}):(0,s.jsx)("div",{className:"flex items-center justify-center h-64 opacity-70",children:"No status data available"})}function $(e,a=""){let t={name:"",children:new Map};for(let s of e){let e=s.split("/"),l=t;for(let t=0;t<e.length;t++){let n=e[t];l.children.has(n)||l.children.set(n,{name:n,children:new Map}),l=l.children.get(n),t===e.length-1&&(l.fullPath=a?`${a}/${s}`:s)}}return t}function B(e,a,t){if(a[e])return a[e];let s=e.split("/");for(let e=s.length-1;e>0;e--){let t=s.slice(0,e).join("/");if(a[t])return a[t]}if(t){let e=t.split("/");for(let t=e.length;t>0;t--){let s=e.slice(0,t).join("/");if(a[s])return a[s]}}return null}function P(e){return Array.from(e.children.values()).sort((e,a)=>{let t=e.children.size>0&&!e.fullPath,s=a.children.size>0&&!a.fullPath;return t&&!s?-1:!t&&s?1:e.name.localeCompare(a.name)})}function F(e,a,t=""){let s=[];for(let l of P(e)){if(void 0!==l.fullPath){s.push(l.fullPath);continue}let e=t?`${t}/${l.name}`:l.name;a.has(e)&&s.push(...F(l,a,e))}return s}function M(e){let a=[];for(let t of P(e)){if(t.fullPath){a.push(t.fullPath);continue}a.push(...M(t))}return a}function A({type:e,isActive:a,isInherited:t,onClick:l,showOnHover:n}){return(0,s.jsx)("button",{className:(0,o.cn)("p-0.5 rounded hover:bg-base-300 transition-colors shrink-0 cursor-pointer text-xs",a&&"bg-primary/10",t&&"opacity-50",!a&&!n&&"opacity-0 group-hover:opacity-100"),onClick:l,title:"visible"===e?a?"Remove visible filter":"Show only this branch":a?"Remove hide filter":"Hide this branch",children:"visible"===e?(0,s.jsx)("i",{className:"iconoir-eye text-[14px]","aria-hidden":"true"}):(0,s.jsx)("i",{className:"iconoir-eye-closed text-[14px]","aria-hidden":"true"})})}function D({name:e,groupPath:a,icon:t,isExpanded:l,onToggle:n,visibilityMap:r,onToggleVisibility:i,depth:c=0}){let d=r[a],h=a.includes("/")?a.split("/").slice(0,-1).join("/"):void 0,m=h?r[h]:null,u=d||m,x=!d&&null!==m;return(0,s.jsxs)("div",{className:(0,o.cn)("group flex items-center gap-1 px-2 py-1.5 text-sm rounded-md cursor-pointer hover:bg-base-200 transition-colors font-medium"),style:{paddingLeft:`${12*c+8}px`},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",onClick:n,children:[(0,s.jsx)("span",{className:"text-xs opacity-70",children:l?"▼":"▶"}),(0,s.jsx)("span",{className:"shrink-0",children:t}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:e})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto",children:[(0,s.jsx)(A,{type:"visible",isActive:"visible"===d||x&&"visible"===u,isInherited:x&&"visible"===u,onClick:e=>{e.stopPropagation(),i(a,"visible")},showOnHover:"visible"===d||x&&"visible"===u}),(0,s.jsx)(A,{type:"hidden",isActive:"hidden"===d||x&&"hidden"===u,isInherited:x&&"hidden"===u,onClick:e=>{e.stopPropagation(),i(a,"hidden")},showOnHover:"hidden"===d||x&&"hidden"===u})]})]})}function L({node:e,currentBranch:a,expandedFolders:t,onToggleFolder:l,onCheckout:n,onCheckoutToLocal:r,onCreateBranch:i,onDeleteBranch:d,onRenameBranch:h,onRenameRemoteBranch:m,onRebase:u,onMerge:x,onPushToRemote:p,onPullFromRemote:b,getBranchContextMenuItems:f,onBranchClick:g,onBranchContextMenu:j,onDeleteBranchGroup:N,selectedBranches:y,visibilityMap:v,onToggleVisibility:k,parentPath:w="",depth:C=0,groupPath:S,isRemote:E=!1,trackingInfo:R}){let $=Array.from(e.children.values()).sort((e,a)=>{let t=e.children.size>0&&!e.fullPath,s=a.children.size>0&&!a.fullPath;return t&&!s?-1:!t&&s?1:e.name.localeCompare(a.name)});return(0,s.jsx)(s.Fragment,{children:$.map(e=>{let $=void 0!==e.fullPath,P=e.children.size>0&&!$,F=e.fullPath||(w?`${w}/${e.name}`:e.name),D=t.has(F),T=$&&e.fullPath===a,_=v[F],O=B(F,v,S),H=!_&&null!==O;if(P){let w=M(e).filter(e=>e!==a);return(0,s.jsxs)("div",{children:[(0,s.jsx)(c,{items:[{label:"Delete",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>N(w),danger:!0,disabled:0===w.length}],children:(0,s.jsxs)("div",{className:(0,o.cn)("group flex items-center gap-1 px-2 py-1.5 text-sm rounded-md cursor-pointer hover:bg-base-200 transition-colors opacity-70 select-none"),style:{paddingLeft:`${12*C+8}px`},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 flex-1 min-w-0",onClick:()=>l(F),children:[(0,s.jsx)("span",{className:"text-xs opacity-70",children:D?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[16px] shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:e.name})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto",children:[(0,s.jsx)(A,{type:"visible",isActive:"visible"===_||H&&"visible"===O,isInherited:H&&"visible"===O,onClick:e=>{e.stopPropagation(),k(F,"visible")},showOnHover:"visible"===_||H&&"visible"===O}),(0,s.jsx)(A,{type:"hidden",isActive:"hidden"===_||H&&"hidden"===O,isInherited:H&&"hidden"===O,onClick:e=>{e.stopPropagation(),k(F,"hidden")},showOnHover:"hidden"===_||H&&"hidden"===O})]})]})}),D&&(0,s.jsx)(L,{node:e,currentBranch:a,expandedFolders:t,onToggleFolder:l,onCheckout:n,onCheckoutToLocal:r,onCreateBranch:i,onDeleteBranch:d,onRenameBranch:h,onRenameRemoteBranch:m,onRebase:u,onMerge:x,onPushToRemote:p,onPullFromRemote:b,getBranchContextMenuItems:f,onBranchClick:g,onBranchContextMenu:j,onDeleteBranchGroup:N,selectedBranches:y,visibilityMap:v,onToggleVisibility:k,parentPath:F,depth:C+1,groupPath:S,isRemote:E,trackingInfo:R})]},F)}let I=!E&&e.fullPath?R?.[e.fullPath]:void 0,K=I&&(I.ahead>0||I.behind>0),z=f({branchRef:e.fullPath,branchLeafName:e.name,currentBranch:a,isRemote:E,selectedBranchRefs:y.has(e.fullPath)?Array.from(y):[e.fullPath]}),q=y.has(e.fullPath);return(0,s.jsx)(c,{items:z,children:(0,s.jsxs)("div",{className:(0,o.cn)("group flex items-center gap-2 px-2 py-1.5 text-sm rounded-md cursor-pointer transition-colors select-none",!q&&"hover:bg-base-200",q&&"bg-primary/10 hover:bg-primary/20",T&&"bg-base-200 font-medium text-primary"),style:{paddingLeft:`${12*C+8}px`},onContextMenu:()=>j?.(e.fullPath),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",onClick:a=>g?.(e.fullPath,{isMultiSelect:a.metaKey||a.ctrlKey,isRangeSelect:a.shiftKey}),onDoubleClick:()=>!T&&n(e.fullPath),children:[T?(0,s.jsx)("span",{className:"w-3 h-3 flex items-center justify-center shrink-0",children:(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary"})}):E?(0,s.jsx)("i",{className:"iconoir-globe text-[14px] opacity-50 shrink-0","aria-hidden":"true"}):(0,s.jsx)("i",{className:"iconoir-git-branch text-[14px] opacity-50 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",title:e.fullPath,children:e.name}),K&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs opacity-70 shrink-0",title:`${I.ahead} ahead, ${I.behind} behind ${I.upstream}`,children:[I.ahead>0&&(0,s.jsxs)("span",{className:"flex items-center gap-0.5 text-xs",children:[(0,s.jsx)("i",{className:"iconoir-arrow-up text-[12px]","aria-hidden":"true"}),(0,s.jsx)("span",{children:I.ahead})]}),I.behind>0&&(0,s.jsxs)("span",{className:"flex items-center gap-0.5 text-xs",children:[(0,s.jsx)("i",{className:"iconoir-arrow-down text-[12px]","aria-hidden":"true"}),(0,s.jsx)("span",{children:I.behind})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5 ml-auto",children:[(0,s.jsx)(A,{type:"visible",isActive:"visible"===_||H&&"visible"===O,isInherited:H&&"visible"===O,onClick:e=>{e.stopPropagation(),k(F,"visible")},showOnHover:"visible"===_||H&&"visible"===O}),(0,s.jsx)(A,{type:"hidden",isActive:"hidden"===_||H&&"hidden"===O,isInherited:H&&"hidden"===O,onClick:e=>{e.stopPropagation(),k(F,"hidden")},showOnHover:"hidden"===_||H&&"hidden"===O})]})]})},e.fullPath)})})}var T=t(3321);function _(e){return Math.min(Math.max(e,100),900)}function O(e){return Math.min(Math.max(e,.15),.75)}function H(e){let a=e.indexOf("/");return a<=0||a>=e.length-1?null:{remote:e.slice(0,a),branch:e.slice(a+1)}}async function I(e){try{return await navigator.clipboard.writeText(e),!0}catch{let a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.select();try{return document.execCommand("copy"),!0}catch{return!1}finally{document.body.removeChild(a)}}}let K={isOpen:!1,executionId:null,scriptName:"",branchRef:"",output:"",status:"idle",error:null};function z({repoPath:e}){let a=(0,n.jE)(),{data:t}=(0,l.t0)(),i=(0,l.Y5)(),d=(0,T.useRouter)(),x=(0,T.useSearchParams)(),p=(x.get("branch")??"").trim(),b=(0,r.useRef)(null),f=(0,r.useRef)(null),[g,j]=(0,r.useState)(100),{data:y,isLoading:v,isError:k,error:w,refetch:C,isFetching:S}=(0,l._X)(e,g),{data:E,isLoading:P,refetch:A}=(0,l._6)(e),z=E?.current?.trim()??"",{data:q,refetch:W}=(0,l.en)(e),G=!!(q?.files&&q.files.length>0),[U,V]=(0,r.useState)(null),[Y,J]=(0,r.useState)([]),[Q,X]=(0,r.useState)(null),Z=(0,r.useRef)(0),ee=(0,r.useCallback)(()=>{let e=Date.now();e-Z.current<500||(Z.current=e,Promise.all([A(),C(),W()]))},[A,C,W]);(0,r.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&ee()},a=()=>{"visible"===document.visibilityState&&ee()};return document.addEventListener("visibilitychange",e),window.addEventListener("focus",a),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",a)}},[ee]);let ea=(0,r.useCallback)(e=>{V(e),J(e?[e]:[]),X(e)},[]);(0,r.useEffect)(()=>{ea(null),sD([]),sT(null)},[e,ea]),(0,r.useEffect)(()=>{G||"__LOCAL_CHANGES__"!==U||ea(null)},[G,U,ea]);let{mutateAsync:et}=(0,l.a3)(),es=(0,r.useCallback)(()=>{let e=new URLSearchParams(x.toString()).toString();d.push(e?`/workspace/conflicts?${e}`:"/workspace/conflicts")},[d,x]),el=(0,r.useCallback)(e=>{if(!(e instanceof Error))return!1;let a=e.message.toLowerCase();return a.includes("conflict")||a.includes("could not apply")||a.includes("fix conflicts")||a.includes("resolve all conflicts")||a.includes("merge --continue")||a.includes("rebase --continue")},[]);(0,r.useEffect)(()=>{b.current=null,f.current=null},[e]),(0,r.useEffect)(()=>{if(!p||!E)return;let a=`${e}:${p}`;if(b.current!==a){if(E.current===p){b.current=a;return}if(!E.branches.includes(p)){b.current=a,(0,u.oR)({type:"error",title:"Branch Not Found",description:`Branch "${p}" does not exist in this repository.`});return}b.current=a,(async()=>{try{await et({repoPath:e,action:"checkout",data:{branch:p}})}catch(e){console.error(e)}})()}},[E,e,p,et]);let[en,er]=(0,r.useState)(!1),[ei,eo]=(0,r.useState)(""),[ec,ed]=(0,r.useState)(null),[eh,em]=(0,r.useState)(!1),[eu,ex]=(0,r.useState)(!1),[ep,eb]=(0,r.useState)(null),[ef,eg]=(0,r.useState)(""),[ej,eN]=(0,r.useState)(!1),[ey,ev]=(0,r.useState)(!1),[ek,ew]=(0,r.useState)(!1),[eC,eS]=(0,r.useState)([]),[eE,eR]=(0,r.useState)(!1),[e$,eB]=(0,r.useState)(!1),[eP,eF]=(0,r.useState)(!1),[eM,eA]=(0,r.useState)(null),[eD,eL]=(0,r.useState)(!1),[eT,e_]=(0,r.useState)(!1),[eO,eH]=(0,r.useState)(null),[eI,eK]=(0,r.useState)(!1),[ez,eq]=(0,r.useState)(!1),[eW,eG]=(0,r.useState)(!1),[eU,eV]=(0,r.useState)([]),[eY,eJ]=(0,r.useState)(!1),[eQ,eX]=(0,r.useState)(!1),[eZ,e0]=(0,r.useState)(!1),[e1,e2]=(0,r.useState)(!1),[e4,e3]=(0,r.useState)(null),[e5,e7]=(0,r.useState)(null),[e6,e8]=(0,r.useState)(""),[e9,ae]=(0,r.useState)(!1),[aa,at]=(0,r.useState)(!1),[as,al]=(0,r.useState)(!1),[an,ar]=(0,r.useState)(null),[ai,ao]=(0,r.useState)(""),[ac,ad]=(0,r.useState)(!1),[ah,am]=(0,r.useState)(!1),[au,ax]=(0,r.useState)(null),[ap,ab]=(0,r.useState)(!1),[af,ag]=(0,r.useState)(!1),[aj,aN]=(0,r.useState)("origin"),[ay,av]=(0,r.useState)(""),[ak,aw]=(0,r.useState)(!1),[aC,aS]=(0,r.useState)(!1),[aE,aR]=(0,r.useState)(null),[a$,aB]=(0,r.useState)(null),[aP,aF]=(0,r.useState)(!0),[aM,aA]=(0,r.useState)(!1),[aD,aL]=(0,r.useState)("checking"),aT=(0,r.useCallback)(()=>{aS(!1),aR(null),aB(null),aL("checking")},[]),[a_,aO]=(0,r.useState)(!1),[aH,aI]=(0,r.useState)(null),[aK,az]=(0,r.useState)(null),[aq,aW]=(0,r.useState)(!1),[aG,aU]=(0,r.useState)(!1),[aV,aY]=(0,r.useState)(!1),[aJ,aQ]=(0,r.useState)(""),[aX,aZ]=(0,r.useState)(!1),[a0,a1]=(0,r.useState)("checking"),a2=(0,r.useCallback)(()=>{aO(!1),aI(null),az(null),a1("checking")},[]),[a4,a3]=(0,r.useState)(!1),[a5,a7]=(0,r.useState)(null),[a6,a8]=(0,r.useState)([]),[a9,te]=(0,r.useState)(""),[ta,tt]=(0,r.useState)([]),[ts,tl]=(0,r.useState)(""),[tn,tr]=(0,r.useState)(null),[ti,to]=(0,r.useState)(!1),[tc,td]=(0,r.useState)(!1),[th,tm]=(0,r.useState)(!0),[tu,tx]=(0,r.useState)(!1),[tp,tb]=(0,r.useState)(""),[tf,tg]=(0,r.useState)(!1),[tj,tN]=(0,r.useState)(null),[ty,tv]=(0,r.useState)(!1),[tk,tw]=(0,r.useState)(!1),[tC,tS]=(0,r.useState)(!1),[tE,tR]=(0,r.useState)(null),[t$,tB]=(0,r.useState)([]),[tP,tF]=(0,r.useState)(""),[tM,tA]=(0,r.useState)([]),[tD,tL]=(0,r.useState)(""),[tT,t_]=(0,r.useState)(null),[tO,tH]=(0,r.useState)(!0),[tI,tK]=(0,r.useState)(!1),[tz,tq]=(0,r.useState)(!1),[tW,tG]=(0,r.useState)(null),[tU,tV]=(0,r.useState)(!1),[tY,tJ]=(0,r.useState)(!1),[tQ,tX]=(0,r.useState)(!1),[tZ,t0]=(0,r.useState)(!1),[t1,t2]=(0,r.useState)(!1),[t4,t3]=(0,r.useState)(!1),[t5,t7]=(0,r.useState)(null),[t6,t8]=(0,r.useState)(""),[t9,se]=(0,r.useState)(!1),[sa,st]=(0,r.useState)(!1),[ss,sl]=(0,r.useState)(null),[sn,sr]=(0,r.useState)("stash-and-reapply"),[si,so]=(0,r.useState)(!1),[sc,sd]=(0,r.useState)(!1),[sh,sm]=(0,r.useState)(null),[su,sx]=(0,r.useState)(!1),[sp,sb]=(0,r.useState)(!1),[sf,sg]=(0,r.useState)(null),[sj,sN]=(0,r.useState)(!1),[sy,sv]=(0,r.useState)(!1),[sk,sw]=(0,r.useState)(null),[sC,sS]=(0,r.useState)(""),[sE,sR]=(0,r.useState)(""),[s$,sB]=(0,r.useState)(!1),sP=(0,r.useRef)(null),[sF,sM]=(0,r.useState)(null),[sA,sD]=(0,r.useState)([]),[sL,sT]=(0,r.useState)(null),[s_,sO]=(0,r.useState)(!1),sH=(0,r.useRef)(null),[sI,sK]=(0,r.useState)(K),[sz,sq]=(0,r.useState)(!1),[sW,sG]=(0,r.useState)(!1),[sU,sV]=(0,r.useState)(!1),sY="starting"===sI.status||"running"===sI.status,sJ="completed"===sI.status||"failed"===sI.status||"canceled"===sI.status;(0,r.useEffect)(()=>{sJ&&sI.executionId&&a.invalidateQueries({queryKey:["git",e]})},[sJ,sI.executionId,a,e]);let sQ=(0,r.useCallback)(()=>{e2(!1),e3(null),e7(null),e8(""),ae(!1)},[]),sX=(0,r.useCallback)(()=>{al(!1),ar(null),ao("")},[]),sZ=(0,r.useCallback)(()=>{am(!1),ax(null)},[]),s0=(0,r.useCallback)(()=>{ag(!1),aN("origin"),av("")},[]),s1=(0,r.useCallback)(()=>{sv(!1),sw(null),sS(""),sR("")},[]),s2=(0,r.useCallback)(()=>{sK(K),sV(!1),sq(!1)},[]),s4=(0,r.useCallback)(()=>{if(sa){si||(st(!1),sl(null));return}if(eQ){eX(!1),eV([]);return}if(t4)return void t3(!1);if(en){er(!1),ed(null);return}if(eu){ex(!1),eb(null),eg(""),eN(!1);return}if(tC)return void tS(!1);if(a4)return void a3(!1);if(a_)return void a2();if(aC)return void aT();if(e1)return void sQ();if(as)return void sX();if(ah)return void sZ();if(af)return void s0();if(eW){eG(!1),eV([]);return}if(ek){ew(!1),eS([]),eR(!1);return}if(eP){eF(!1),eA(null);return}if(eT){e_(!1),eH(null),eK(!1);return}if(sy)return void s1();if(sc)return void sd(!1);if(sp){sb(!1),sg(null);return}s_?sO(!1):sI.isOpen&&sJ&&s2()},[eQ,t4,en,eu,tC,a4,a2,a_,aT,aC,e1,sQ,as,sX,ah,sZ,af,s0,eW,ek,eP,eT,sy,s1,sc,sp,s_,sI.isOpen,sJ,s2,sa,si]),s3=sc||sp||sy||ek||eP||eT||eQ||eW||e1||as||ah||af||aC||a_||a4||tC||en||eu||t4||sa||s_||sI.isOpen;(0,m.v)(s3,s4,()=>{if(sa){si||nE();return}if(eQ){eZ||nT();return}if(t4){t6&&!t9&&nN();return}if(en){ei&&!eh&&n_();return}if(eu){ef.trim()&&!ey&&nH();return}if(tC){!tI&&t$.length>0&&tP&&tD&&nf();return}if(a4){!tf&&a6.length>0&&a9&&ts&&nx();return}if(a_){aX||nd();return}if(aC){aM||ni();return}if(e1){let e=e5?e6===e5.branch:e6===e4;!e6||e||aa||nt();return}if(as){let e=ai.trim();e&&e!==(an??"").trim()&&!ac&&ns();return}if(ah){au&&!ap&&nl();return}if(af){aj.trim()&&ay.trim()&&!ak&&nn();return}if(eW){eY||nL();return}if(ek){e$||l6();return}if(eP){eM&&!eD&&l9();return}if(eT){eO&&!ez&&l8();return}if(sy){sC.trim()&&!s$&&nP();return}if(sc){su||n$();return}if(sp){sj||nB();return}sI.isOpen&&sJ&&s2()});let s5="git-web:history-panel-height",s7="git-web:history-commit-details-message-ratio",[s6,s8]=(0,r.useState)(300),[s9,le]=(0,r.useState)(!1),la=(0,r.useRef)(null),[lt,ls]=(0,r.useState)(.28),[ll,ln]=(0,r.useState)(!1),lr=(0,r.useRef)(null),li=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(t?.historyPanelHeight)s8(_(t.historyPanelHeight));else try{let e=localStorage.getItem(s5);if(e){let a=parseInt(e,10);!isNaN(a)&&a>=100&&a<=900&&s8(a)}}catch(e){console.error("Failed to load panel height from localStorage:",e)}},[t?.historyPanelHeight]),(0,r.useEffect)(()=>{try{localStorage.setItem(s5,String(s6))}catch(e){console.error("Failed to save panel height to localStorage:",e)}},[s6]),(0,r.useEffect)(()=>{try{let e=localStorage.getItem(s7);if(!e)return;let a=parseFloat(e);Number.isNaN(a)||ls(O(a))}catch(e){console.error("Failed to load commit details ratio from localStorage:",e)}},[]),(0,r.useEffect)(()=>{try{localStorage.setItem(s7,String(lt))}catch(e){console.error("Failed to save commit details ratio to localStorage:",e)}},[lt]),(0,r.useEffect)(()=>{!s9&&li.current&&(i.mutate({historyPanelHeight:s6}),li.current=!1)},[s9,s6,i]);let lo=(0,r.useCallback)(e=>{e.preventDefault(),le(!0),la.current={startY:e.clientY,startHeight:s6}},[s6]);(0,r.useEffect)(()=>{if(!s9)return;let e=e=>{if(!la.current)return;let a=la.current.startY-e.clientY;s8(_(la.current.startHeight+a)),li.current=!0},a=()=>{le(!1),la.current=null};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[s9]);let lc=(0,r.useCallback)(e=>{e.preventDefault(),ln(!0)},[]);(0,r.useEffect)(()=>{if(!ll)return;let e=e=>{let a=lr.current;if(!a)return;let t=a.getBoundingClientRect();t.height<=0||ls(O((e.clientY-t.top)/t.height))},a=()=>{ln(!1)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),document.body.style.cursor="ns-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a),document.body.style.cursor="",document.body.style.userSelect=""}},[ll]),(0,r.useEffect)(()=>{if(!s_)return;let e=e=>{sH.current&&!sH.current.contains(e.target)&&sO(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[s_]);let ld=(0,r.useMemo)(()=>E?.branches?$(E.branches):null,[E?.branches]),lh=(0,r.useMemo)(()=>{if(!E?.remotes)return null;var e=E.remotes;let a=new Map;for(let[t,s]of Object.entries(e))a.set(t,$(s,`remotes/${t}`));return a},[E?.remotes]),lm=(0,r.useMemo)(()=>{let e=new Set;for(let a of E?.branches??[])e.add(a);for(let[a,t]of Object.entries(E?.remotes??{}))for(let s of t)e.add(`remotes/${a}/${s}`);return e},[E?.branches,E?.remotes]),lu=(0,r.useMemo)(()=>new Set(sA),[sA]),lx=(0,l.GK)(e),lp=(0,l.Lp)(),lb=(0,r.useMemo)(()=>(lx?.customScripts??[]).filter(e=>"branch"===e.target&&"run-bash-script"===e.action&&e.name.trim().length>0&&e.content.trim().length>0),[lx?.customScripts]),[lf,lg]=(0,r.useState)(!0),[lj,lN]=(0,r.useState)(!0),[ly,lv]=(0,r.useState)(!0),[lk,lw]=(0,r.useState)({}),[lC,lS]=(0,r.useState)(new Set),lE=(0,r.useMemo)(()=>{let e=[];if(lf&&ld&&e.push(...F(ld,lC)),lj&&lh)for(let[a,t]of Array.from(lh.entries())){let s=`__remotes__/${a}`;lC.has(s)&&e.push(...F(t,lC,`remotes/${a}`))}return e},[lC,ld,lf,lh,lj]);(0,r.useEffect)(()=>{if(0===sA.length)return;let e=sA.filter(e=>lm.has(e));e.length!==sA.length&&sD(e),sL&&!lm.has(sL)&&sT(e.length>0?e[e.length-1]:null)},[lm,sL,sA]);let lR=(0,r.useRef)(null);(0,r.useEffect)(()=>{lx&&lx.path!==lR.current&&(lR.current=lx.path,void 0!==lx.localGroupExpanded&&lg(lx.localGroupExpanded),void 0!==lx.remotesGroupExpanded&&lN(lx.remotesGroupExpanded),void 0!==lx.worktreesGroupExpanded&&lv(lx.worktreesGroupExpanded),lx.expandedFolders&&lS(new Set(lx.expandedFolders)),lx.visibilityMap&&lw(lx.visibilityMap))},[lx]);let l$=(0,r.useCallback)(a=>{lp.mutate({path:e,updates:a})},[e,lp]),lB=(0,r.useCallback)(()=>{let e=!lf;lg(e),l$({localGroupExpanded:e})},[lf,l$]),lP=(0,r.useCallback)(()=>{let e=!lj;lN(e),l$({remotesGroupExpanded:e})},[lj,l$]),lF=(0,r.useCallback)(()=>{let e=!ly;lv(e),l$({worktreesGroupExpanded:e})},[l$,ly]),lM=(0,r.useCallback)(e=>{lS(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),l$({expandedFolders:Array.from(t)}),t})},[l$]),lA=(0,r.useCallback)((e,a)=>{lw(t=>{let s={...t};s[e]===a?delete s[e]:s[e]=a;let l={};return Object.entries(s).forEach(([e,a])=>{("visible"===a||"hidden"===a)&&(l[e]=a)}),l$({visibilityMap:l}),s})},[l$]),lD=(0,r.useCallback)(()=>{lw({}),l$({visibilityMap:{}})},[l$]),lL=(0,r.useCallback)((e,a)=>{let t=B(e,lk);if(t)return t;if(a){let a=e.split("/");if(a.length>=2&&"remotes"===a[0]){let e=a[1],t=lk[`__remotes__/${e}`];if(t)return t;let s=lk.__remotes__;if(s)return s}}else{let e=lk.__local__;if(e)return e}return null},[lk]),lT=(0,r.useMemo)(()=>{if(!y?.all||!E?.branches||!E?.branchCommits)return y?.all||[];let e=Object.values(lk).some(e=>"visible"===e),a=Object.values(lk).some(e=>"hidden"===e);if(!e&&!a)return y.all;let t=[...E.branches.map(e=>({branch:e,isRemote:!1}))];if(E.remotes)for(let[e,a]of Object.entries(E.remotes))for(let s of a)t.push({branch:`remotes/${e}/${s}`,isRemote:!0});let s=new Set,l=new Set,n=new Set;for(let{branch:e,isRemote:a}of t){let t=lL(e,a);"visible"===t?s.add(e):"hidden"===t?l.add(e):n.add(e)}let r=new Map(y.all.map(e=>[e.hash,e])),i=(e,a)=>{let t=[e];for(;t.length>0;){let e=t.pop();if(a.has(e))continue;let s=r.get(e);if(s)for(let l of(a.add(e),s.parents||[]))a.has(l)||t.push(l)}},o=new Set;for(let e of s){let a=E.branchCommits[e];a&&i(a,o)}if(e)return y.all.filter(e=>o.has(e.hash));if(a){let e=new Set;for(let a of n){let t=E.branchCommits[a];t&&i(t,e)}return y.all.filter(a=>e.has(a.hash))}return y.all},[y?.all,E?.branches,E?.branchCommits,E?.remotes,lk,lL]),l_=E?.current?.trim()||q?.current?.trim()||"",lO=(0,r.useMemo)(()=>l_&&E?.branchCommits?.[l_]?E.branchCommits[l_]:y?.all&&y.all.length>0?y.all[0].hash:null,[l_,E?.branchCommits,y?.all]),lH=(0,r.useMemo)(()=>G?[{hash:"__LOCAL_CHANGES__",message:"(local changes)",date:new Date().toISOString(),refs:"",body:"",author_name:"",author_email:"",parents:lO?[lO]:[]},...lT]:lT,[G,lT,lO]),lI=(0,r.useMemo)(()=>new Set(Y),[Y]),lK=(0,r.useMemo)(()=>lH.map(e=>e.hash),[lH]),lz=(0,r.useMemo)(()=>U&&"__LOCAL_CHANGES__"!==U?y?.all.find(e=>e.hash===U):null,[y?.all,U]),lq=(0,r.useMemo)(()=>{if(!y?.all||Y.length<2||Y.includes("__LOCAL_CHANGES__"))return null;let e=new Map(y.all.map(e=>[e.hash,e])),a=new Map(lK.map((e,a)=>[e,a])),t=Array.from(new Set(Y)).filter(e=>a.has(e)).sort((e,t)=>(a.get(e)??Number.MAX_SAFE_INTEGER)-(a.get(t)??Number.MAX_SAFE_INTEGER));if(t.length<2)return null;let s=t[0],l=t[t.length-1],n=e.get(s),r=e.get(l);return n&&r?{latestHash:s,oldestHash:l,latestCommit:n,oldestCommit:r}:null},[lK,y?.all,Y]),lW=!!lq;(0,r.useEffect)(()=>{if(0===lK.length){(U||Y.length>0||Q)&&ea(null);return}let e=new Set(lK),a=Y.filter(a=>e.has(a));a.length!==Y.length&&J(a),U&&!e.has(U)&&V(a.length>0?a[a.length-1]:null),Q&&!e.has(Q)&&X(a.length>0?a[a.length-1]:null)},[lK,U,Y,Q,ea]);let lG=(0,r.useCallback)((e,a)=>{let t=a?.isRangeSelect??!1,s=a?.isMultiSelect??!1;if(t){let a=Q??U??e,t=lK.indexOf(a),s=lK.indexOf(e);if(-1!==t&&-1!==s){let[l,n]=t<s?[t,s]:[s,t];J(lK.slice(l,n+1)),V(e),X(a);return}}if(s){if(lI.has(e)){let a=Y.filter(a=>a!==e);J(a),V(t=>t!==e?t:a.length>0?a[a.length-1]:null),Q===e&&X(a.length>0?a[a.length-1]:null)}else J([...Y,e]),V(e),X(e);return}ea(e)},[lK,lI,Y,U,Q,ea]),lU=(0,r.useMemo)(()=>lT.filter(e=>lI.has(e.hash)).reverse(),[lT,lI]),lV=(0,r.useMemo)(()=>Object.values(lk).some(e=>"visible"===e||"hidden"===e),[lk]),lY=(0,r.useMemo)(()=>{let e=new Set;if(E?.branches)for(let a of E.branches)"hidden"===lL(a,!1)&&e.add(a);if(E?.remotes)for(let[a,t]of Object.entries(E.remotes))for(let s of t){let t=`remotes/${a}/${s}`;"hidden"===lL(t,!0)&&e.add(t)}return e},[E?.branches,E?.remotes,lL]);(0,r.useEffect)(()=>{lV&&lT.length<50&&!S&&g<5e3&&y?.all&&y.all.length>=g&&j(e=>Math.min(e+100,5e3))},[lV,lT.length,S,g,y?.all]),(0,r.useEffect)(()=>{sF&&y?.all&&!S&&(y.all.some(e=>e.hash===sF)?requestAnimationFrame(()=>{sP.current?.scrollToCommit(sF)&&(ea(sF),sM(null))}):g<5e3?j(e=>e+100):(console.warn("Could not find commit after loading 5000 commits"),sM(null)))},[sF,y?.all,S,g,ea]);let lJ=(0,r.useCallback)(e=>{if(!E?.branchCommits)return;let a=E.branchCommits[e];if(a){if(y?.all?.some(e=>e.hash===a)&&sP.current&&sP.current.scrollToCommit(a))return void ea(a);sM(a),ea(a)}},[E?.branchCommits,y?.all,ea]);(0,r.useEffect)(()=>{if(!p||!E?.branchCommits||z!==p)return;let a=`${e}:${p}`;f.current!==a&&(f.current=a,lJ(p))},[z,E?.branchCommits,e,p,lJ]);let lQ=(0,r.useCallback)((e,a)=>{let t=a?.isRangeSelect??!1,s=a?.isMultiSelect??!1;if(t){let a=sL??e,t=lE.indexOf(a),s=lE.indexOf(e);if(-1!==t&&-1!==s){let[l,n]=t<s?[t,s]:[s,t],r=lE.slice(l,n+1);lu.has(e)?sD(sA.filter(e=>!r.includes(e))):sD(Array.from(new Set([...sA,...r]))),sT(a)}else sD([e]),sT(e);return}if(s){lu.has(e)?sD(sA.filter(a=>a!==e)):sD([...sA,e]),sT(e);return}sD([e]),sT(e),lJ(e)},[sL,lE,lJ,sA,lu]),lX=(0,r.useCallback)(e=>{lu.has(e)||(sD([e]),sT(e))},[lu]),lZ=(0,r.useCallback)(async(a,t)=>{sV(!1),sq(!1),sK({isOpen:!0,executionId:null,scriptName:a.name,branchRef:t,output:"",status:"starting",error:null});try{let s=await fetch("/api/custom-scripts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"start",repoPath:e,branchRef:t,scriptContent:a.content})}),l=await s.json();if(!s.ok)throw Error(l.error||"Failed to start script execution");let n=[];l.previousBranch&&l.checkedOutBranch&&l.previousBranch!==l.checkedOutBranch&&n.push(`[info] Checked out ${l.checkedOutBranch} (from ${l.previousBranch})`),sK(e=>({...e,executionId:l.executionId,output:[n.join("\n"),l.output].filter(Boolean).join("\n"),status:l.status,error:null}))}catch(e){sK(a=>({...a,status:"failed",error:e.message,output:a.output?`${a.output}
|
|
4
|
+
[error] ${e.message}`:`[error] ${e.message}`}))}},[e]),l0=(0,r.useCallback)(async()=>{if(sI.executionId&&sY){sq(!0);try{let e=await fetch("/api/custom-scripts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"cancel",executionId:sI.executionId})}),a=await e.json();if(!e.ok)throw Error(a.error||"Failed to cancel script execution");sK(e=>({...e,output:a.output,status:a.status})),"running"!==a.status&&"starting"!==a.status&&sq(!1)}catch(e){sK(a=>({...a,output:`${a.output}
|
|
5
|
+
[error] ${e.message}`})),sq(!1)}}},[sI.executionId,sY]),l1=(0,r.useCallback)(async()=>{if(sW)return;sG(!0);let e=await I(sI.output);sG(!1),sV(e),e&&setTimeout(()=>sV(!1),1500)},[sW,sI.output]);(0,r.useEffect)(()=>{if(!sI.executionId||!sY)return;let e=!1,a=null,t=async()=>{try{let s=await fetch("/api/custom-scripts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:"status",executionId:sI.executionId})}),l=await s.json();if(!s.ok)throw Error(l.error||"Failed to fetch script execution output");if(e)return;let n=l.status;sK(e=>e.executionId!==l.executionId?e:{...e,output:l.output,status:n,error:null}),"running"===n?a=setTimeout(t,450):sq(!1)}catch(a){if(e)return;sq(!1),sK(e=>({...e,status:"failed",error:a.message,output:e.output?`${e.output}
|
|
6
|
+
[error] ${a.message}`:`[error] ${a.message}`}))}};return t(),()=>{e=!0,a&&clearTimeout(a)}},[sI.executionId,sY]);let l2=e=>{let a=e.filter(e=>e!==l_);0!==a.length&&(eS(a),eR(!1),ew(!0))},l4=e=>{l2([e])},l3=(0,r.useCallback)(e=>{let a=e.trim();a&&(eA(a),eF(!0))},[]),l5=(0,r.useCallback)(()=>{e_(!1),eH(null),eK(!1)},[]),l7=(0,r.useCallback)(e=>{e&&(eH(e),eK(!1),e_(!0))},[]),l6=async()=>{if(0!==eC.length){eB(!0);try{let a=new Map,t=(e,t,s)=>{a.has(e)||a.set(e,{branchRef:t,run:s})},l=new Set;if(eE)for(let e of eC){if(e.startsWith("remotes/"))continue;let a=E?.trackingInfo?.[e];a?.upstream&&l.add(a.upstream)}for(let a of l){let[s,...l]=a.split("/"),n=l.join("/");if(s&&n){let a=`${s}/${n}`;t(`remote:${a}`,a,()=>et({repoPath:e,action:"delete-remote-branch",data:{remote:s,branch:n},suppressErrorToast:!0}))}}for(let a of eC){if(a.startsWith("remotes/")){let s=a.split("/");if(s.length>=3){let a=s[1],l=s.slice(2).join("/"),n=`${a}/${l}`;t(`remote:${n}`,n,()=>et({repoPath:e,action:"delete-remote-branch",data:{remote:a,branch:l},suppressErrorToast:!0}))}continue}t(`local:${a}`,a,()=>et({repoPath:e,action:"delete-branch",data:{branch:a},suppressErrorToast:!0}))}let n=Array.from(a.values()),r=(await Promise.allSettled(n.map(e=>e.run()))).flatMap((e,a)=>{if("fulfilled"===e.status)return[];let t=n[a].branchRef;return console.error(`Failed to delete branch "${t}":`,e.reason),[t]});r.length>0&&(0,u.oR)({type:"error",title:1===r.length?"Failed to Delete 1 Branch":`Failed to Delete ${r.length} Branches`,description:(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{children:"The following branches could not be deleted:"}),(0,s.jsx)("ul",{className:"mt-1 max-h-40 overflow-y-auto list-disc pl-5",children:r.map(e=>(0,s.jsx)("li",{className:"break-all",children:e},e))})]}),duration:1e4}),ew(!1),eS([]),eR(!1),sD([]),sT(null)}catch(e){console.error(e)}finally{eB(!1)}}},l8=async()=>{if(eO){eq(!0);try{if(await et({repoPath:e,action:"delete-tag",data:{tag:eO}}),eI&&nK)try{await et({repoPath:e,action:"delete-remote-tag",data:{remote:nK,tag:eO}})}catch(e){console.error("Failed to delete remote tag:",e)}l5()}catch(e){console.error(e)}finally{eq(!1)}}},l9=async()=>{if(eM){eL(!0);try{await et({repoPath:e,action:"delete-worktree",data:{path:eM}}),eF(!1),eA(null)}catch(e){console.error(e)}finally{eL(!1)}}},ne=e=>{e3(e),e7(null),e8(e),ae(!1),e2(!0)},na=e=>{let a=e.split("/");if(a.length<3||"remotes"!==a[0])return;let t=a[1],s=a.slice(2).join("/");t&&s&&(e3(e),e7({remote:t,branch:s}),e8(s),ae(!1),e2(!0))},nt=async()=>{if(e4&&e6){if(e5?e5.branch===e6:e4===e6)return void sQ();at(!0);try{e5?await et({repoPath:e,action:"rename-remote-branch",data:{remote:e5.remote,oldName:e5.branch,newName:e6}}):await et({repoPath:e,action:"rename-branch",data:{oldName:e4,newName:e6,renameTrackingRemote:e9}}),sQ()}catch(e){console.error(e)}finally{at(!1)}}},ns=async()=>{if(!an)return;let a=an.trim(),t=ai.trim();if(a&&t){if(a===t)return void sX();ad(!0);try{await et({repoPath:e,action:"rename-remote",data:{oldName:a,newName:t}}),sX()}catch(e){console.error(e)}finally{ad(!1)}}},nl=async()=>{if(!au)return;let a=au.trim();if(a){ab(!0);try{await et({repoPath:e,action:"delete-remote",data:{name:a}}),sZ()}catch(e){console.error(e)}finally{ab(!1)}}},nn=async()=>{let a=aj.trim(),t=ay.trim();if(a&&t){aw(!0);try{await et({repoPath:e,action:"add-remote",data:{name:a,url:t}}),s0()}catch(e){console.error(e)}finally{aw(!1)}}},nr=({sourceBranch:e,targetBranch:a})=>{aR(e),aB(a),aF(!0),aL("checking"),aS(!0)},ni=async()=>{if(aE&&a$){aA(!0);try{await et({repoPath:e,action:"checkout",data:{branch:aE}}),await et({repoPath:e,action:"rebase",data:{ontoBranch:a$,stashChanges:aP}}),aT()}catch(e){el(e)&&(aT(),es(),(0,u.oR)({type:"warning",title:"Rebase Conflict Detected",description:"Redirected to the conflict resolver. Resolve conflicted files, then continue or abort.",duration:12e3})),console.error(e)}finally{aA(!1)}}};(0,r.useEffect)(()=>{if(!aC||!aE||!a$)return;let a=!1;return aL("checking"),(async()=>{try{let t=await et({repoPath:e,action:"check-rebase-conflicts",data:{sourceBranch:aE,ontoBranch:a$}});a||aL(t.hasConflicts?"has-conflicts":"no-conflict")}catch(e){console.error(e),a||aL("has-conflicts")}})(),()=>{a=!0}},[aC,aE,a$,e,et]);let no=({sourceBranch:e,targetBranch:a})=>{aI(a),az(e),aW(!1),aU(!1),aY(!1),aQ(""),a1("checking"),aO(!0)},nc=(0,r.useCallback)(a=>{if(aU(a),a){if(!aK)return void aQ("");(async()=>{try{let a=await et({repoPath:e,action:"get-latest-commit-message",data:{branch:aK}});aQ("string"==typeof a?.message?a.message:"")}catch(e){console.error(e),aQ("")}})()}},[aK,e,et]),nd=async()=>{if(aH&&aK){aZ(!0);try{await et({repoPath:e,action:"checkout",data:{branch:aH}}),await et({repoPath:e,action:"merge",data:{targetBranch:aK,rebaseBeforeMerge:aq,squash:aG,fastForward:aV,squashMessage:aG?aJ:void 0}}),a2()}catch(e){el(e)&&(a2(),es(),(0,u.oR)({type:"warning",title:"Merge Conflict Detected",description:"Redirected to the conflict resolver. Resolve conflicted files, then continue or abort.",duration:12e3})),console.error(e)}finally{aZ(!1)}}};(0,r.useEffect)(()=>{if(!a_||!aK||!aH)return;let a=!1;return a1("checking"),(async()=>{try{let t=await et({repoPath:e,action:"check-merge-conflicts",data:{sourceBranch:aK,targetBranch:aH}});a||a1(t.hasConflicts?"has-conflicts":"no-conflict")}catch(e){console.error(e),a||a1("has-conflicts")}})(),()=>{a=!0}},[a_,aK,aH,e,et]);let nh=async a=>{a7(a),tN(null),a8([]),tt([]),te(""),tl(""),tr(null),to(!1),td(!1),tm(!0),tx(!1),tb(""),a3(!0),tv(!0);try{let t=await et({repoPath:e,action:"get-remotes",data:{}});if(!t.remotes||0===t.remotes.length){tN("No remote repository configured. Please add a remote first."),tv(!1);return}a8(t.remotes);let s=await et({repoPath:e,action:"get-tracking-branch",data:{branch:a}});tr(s.tracking);let l=s.tracking?.remote,n=l&&t.remotes.includes(l)?l:t.remotes[0];te(n),tw(!0);let r=await et({repoPath:e,action:"get-remote-branches",data:{remote:n}});tt(r.branches||[]),s.tracking?.remote===n&&s.tracking?.branch?tl(s.tracking.branch):(r.branches?.includes(a),tl(a))}catch(e){console.error(e),tN(e.message||"Failed to load remote information")}finally{tv(!1),tw(!1)}},nm=async a=>{te(a),tw(!0),tt([]);try{let t=await et({repoPath:e,action:"get-remote-branches",data:{remote:a}});tt(t.branches||[]),tn?.remote===a&&tn?.branch?tl(tn.branch):tl(a5||"")}catch(e){console.error(e),tN(e.message||"Failed to load remote branches")}finally{tw(!1)}},nu=(0,r.useCallback)(a=>{if(tx(a),a){if(!a5)return void tb("");(async()=>{try{let a=await et({repoPath:e,action:"get-latest-commit-message",data:{branch:a5}});tb("string"==typeof a?.message?a.message:"")}catch(e){console.error(e),tb("")}})()}},[a5,e,et]),nx=async()=>{if(a5&&a9&&ts){tg(!0),tN(null);try{let a=!ta.includes(ts)||tn?.remote!==a9||tn?.branch!==ts;await et({repoPath:e,action:"push-to-remote",data:{localBranch:a5,remote:a9,remoteBranch:ts,rebaseFirst:!tc&&ti,forcePush:tc,pushLocalOnlyTags:th,setUpstream:a,squash:tu,squashMessage:tp}}),await et({repoPath:e,action:"fetch",data:{remote:a9}}),a3(!1),a7(null)}catch(e){console.error(e),tN(e.message||"Failed to push to remote")}finally{tg(!1)}}},np=async a=>{tR(a),tG(null),tB([]),tA([]),tF(""),tL(""),t_(null),tH(!0),tS(!0),tV(!0);try{let t=await et({repoPath:e,action:"get-remotes",data:{}});if(!t.remotes||0===t.remotes.length){tG("No remote repository configured. Please add a remote first."),tV(!1);return}tB(t.remotes);let s=await et({repoPath:e,action:"get-tracking-branch",data:{branch:a}});t_(s.tracking);let l=s.tracking?.remote,n=l&&t.remotes.includes(l)?l:t.remotes[0];tF(n),tJ(!0);let r=await et({repoPath:e,action:"get-remote-branches",data:{remote:n}});tA(r.branches||[]),s.tracking?.remote===n&&s.tracking?.branch?tL(s.tracking.branch):tL("")}catch(e){console.error(e),tG(e.message||"Failed to load remote information")}finally{tV(!1),tJ(!1)}},nb=async a=>{tF(a),tJ(!0),tA([]),tL("");try{let t=await et({repoPath:e,action:"get-remote-branches",data:{remote:a}});tA(t.branches||[]),tT?.remote===a&&tT?.branch?tL(tT.branch):tL("")}catch(e){console.error(e),tG(e.message||"Failed to load remote branches")}finally{tJ(!1)}},nf=async()=>{if(tE&&tP&&tD){tK(!0),tG(null);try{await et({repoPath:e,action:"pull-from-remote",data:{localBranch:tE,remote:tP,remoteBranch:tD,rebase:tO}}),tS(!1),tR(null)}catch(e){console.error(e),tG(e.message||"Failed to pull from remote")}finally{tK(!1)}}},ng=e=>{t7(e),t8(e.split("/").slice(2).join("/")),t3(!0)},nj=(0,r.useMemo)(()=>ss?"local"===ss.type?ss.branch:ss.localBranch:"",[ss]),nN=async()=>{if(t5&&t6){if(G){t3(!1),sl({type:"remote",remoteBranch:t5,localBranch:t6}),sr("stash-and-reapply"),st(!0);return}se(!0);try{await et({repoPath:e,action:"checkout-to-local",data:{remoteBranch:t5,localBranch:t6}}),t3(!1),t7(null),t8("")}catch(e){console.error(e)}finally{se(!1)}}},ny=async()=>{tX(!0);try{await et({repoPath:e,action:"fetch",data:{allRemotes:!0}})}catch(e){console.error(e)}finally{tX(!1)}},nv=(0,r.useCallback)(async()=>{if(!tZ){t0(!0);try{let a=await fetch("/api/fs/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),t=await a.json().catch(()=>({}));if(!a.ok)throw Error(t.error||"Failed to open repository folder")}catch(e){(0,u.oR)({type:"error",title:"Failed to Open Repo Folder",description:e instanceof Error?e.message:"Unknown error"})}finally{t0(!1)}}},[tZ,e]),nk=(0,r.useCallback)(async()=>{if(!t1){t2(!0);try{let a=await fetch("/api/fs/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),t=await a.json().catch(()=>({}));if(!a.ok)throw Error(t.error||"Failed to open terminal")}catch(e){(0,u.oR)({type:"error",title:"Failed to Open Terminal",description:e instanceof Error?e.message:"Unknown error"})}finally{t2(!1)}}},[t1,e]),nw=(0,r.useCallback)((e,a)=>{if(a)return;let t=window.location.origin;try{window.top?.location?.origin&&(t=window.top.location.origin)}catch{}let s=`${t}/workspace?path=${encodeURIComponent(e)}`;window.open(s,"_blank","noopener,noreferrer")},[]),nC=async a=>{try{await et({repoPath:e,action:"fetch",data:{remote:a}})}catch(e){console.error(e)}},nS=async a=>{if(a!==l_){if(G){sl({type:"local",branch:a}),sr("stash-and-reapply"),st(!0);return}try{await et({repoPath:e,action:"checkout",data:{branch:a}})}catch(e){console.error(e)}}},nE=async()=>{if(ss){so(!0);try{"local"===ss.type?await et({repoPath:e,action:"checkout",data:{branch:ss.branch,switchStrategy:sn}}):(await et({repoPath:e,action:"checkout-to-local",data:{remoteBranch:ss.remoteBranch,localBranch:ss.localBranch,switchStrategy:sn}}),t7(null),t8("")),st(!1),sl(null)}catch(e){console.error(e)}finally{so(!1)}}},nR=async e=>{sm(e),sd(!0)},n$=async()=>{if(sh){sx(!0);try{await et({repoPath:e,action:"reset",data:{commitHash:sh,mode:"hard"}}),sd(!1),sm(null)}catch(e){console.error(e)}finally{sx(!1)}}},nB=async()=>{if(sf){sN(!0);try{await et({repoPath:e,action:"revert",data:{commitHash:sf.hash}}),sb(!1),sg(null)}catch(e){console.error(e)}finally{sN(!1)}}},nP=async()=>{if(sk&&sC.trim()){sB(!0);try{let a,t;await et({repoPath:e,action:"reword",data:{commitHash:sk.hash,message:(a=sC.trim(),(t=sE.replace(/\r\n/g,"\n")).trim()?`${a}
|
|
7
7
|
|
|
8
|
-
${a}`:t),branch:sk.branch}}),s1()}catch(e){console.error(e)}finally{sB(!1)}}},nF=e=>{if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("cherry-pick")&&t.includes("already in progress")},nM=e=>{if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("could not apply")||t.includes("conflict")||t.includes("cherry-pick --continue")},nA=(0,r.useCallback)(async t=>{1===t.length?await ea({repoPath:e,action:"cherry-pick",data:{commitHash:t[0]}}):await ea({repoPath:e,action:"cherry-pick-multiple",data:{commitHashes:t}})},[e,ea]),nD=(0,r.useCallback)(async()=>{try{await ea({repoPath:e,action:"cherry-pick-abort"})}catch(e){console.error(e)}finally{eG(!1),eX(!1),eV([])}},[e,ea]),nL=async()=>{if(0!==eU.length){eJ(!0);try{let e=eU.map(e=>e.hash);await nA(e),eG(!1),eV([])}catch(e){nF(e)?(eG(!1),eX(!0)):nM(e)&&await nD(),console.error(e)}finally{eJ(!1)}}},nT=async()=>{if(0===eU.length)return void eX(!1);e0(!0);try{await ea({repoPath:e,action:"cherry-pick-abort"});let t=eU.map(e=>e.hash);await nA(t),eX(!1),eV([])}catch(e){nF(e)?eX(!0):nM(e)&&await nD(),console.error(e)}finally{e0(!1)}},n_=async()=>{if(ei){em(!0);try{await ea({repoPath:e,action:"branch",data:{branch:ei,fromRef:ec||void 0}}),er(!1),eo(""),ed(null)}catch(e){console.error(e)}finally{em(!1)}}},nO=e=>{ed(e||null),er(!0)},nH=async()=>{if(ep&&eb.trim()){ev(!0);try{await ea({repoPath:e,action:"create-tag",data:{tagName:eb.trim(),commitHash:ep,pushToRemote:ej}}),ex(!1),ef(null),eg(""),eN(!1)}catch(e){console.error(e)}finally{ev(!1)}}},nI=E?.trackingInfo,nK=(0,r.useMemo)(()=>Object.keys(E?.remoteUrls??{}).sort((e,t)=>"origin"===e?-1:"origin"===t?1:e.localeCompare(t)),[E?.remoteUrls])[0]||null,nz=(0,r.useMemo)(()=>{let e=[];for(let t of eC){if(t.startsWith("remotes/"))continue;let a=nI?.[t]?.upstream;a&&e.push(a)}return Array.from(new Set(e))},[eC,nI]),nq=(0,r.useMemo)(()=>!e4||e5?null:nI?.[e4]??null,[e4,e5,nI]),nW=q?.files?.length,nG=l_||(P?"Loading branches...":"Detached HEAD"),nU=l_&&"number"==typeof nW&&nW>0?`${l_} (${nW})`:nG,nV=(0,r.useMemo)(()=>{if(!l_)return null;let e=nI?.[l_];if(!e?.upstream)return null;let t=H(e.upstream);return t?{upstream:e.upstream,...t}:null},[l_,nI]),nY=(0,r.useMemo)(()=>{let e=[];for(let t of E?.branches??[]){let a=nI?.[t]?.upstream;if(!a)continue;let s=H(a);s&&e.push({localBranch:t,remote:s.remote,remoteBranch:s.branch})}return e},[E?.branches,nI]),nJ=(0,r.useMemo)(()=>P?"Loading branches...":l_?nV?null:`Branch "${l_}" has no tracking remote branch`:"Not on a local branch",[l_,nV,P]),nQ=(0,r.useMemo)(()=>P?"Loading branches...":0===nY.length?"No local branches with tracking remote branches":null,[P,nY.length]),nX=(0,r.useMemo)(()=>P?"Loading branches...":l_?null:"Not on a local branch",[l_,P]),nZ=async()=>{if(az||0===nY.length)return;aq(!0);let t=[];try{for(let a of nY)try{await ea({repoPath:e,action:"pull-from-remote",data:{localBranch:a.localBranch,remote:a.remote,remoteBranch:a.remoteBranch,rebase:!0},suppressErrorToast:!0}),t.push(a.localBranch)}catch(l){let e=l instanceof Error?l.message:"Unknown error",s=t.length>0?`Pulled ${t.length} branch${1===t.length?"":"es"} before failure.`:"No branches were updated.";(0,u.oR)({type:"error",title:`Pull All Failed on "${a.localBranch}"`,description:`${e} ${s}`,duration:12e3});return}(0,u.oR)({type:"success",title:1===t.length?"Pulled 1 Branch":`Pulled ${t.length} Branches`,description:"Updated all local branches that have tracking remote branches."})}finally{aq(!1)}},n0=e=>{let t=function(e,t){let{branchRef:a,branchLeafName:l,currentBranch:n,isRemote:r,selectedBranchRefs:i}=e,o=!r&&a===n,c=i&&i.length>0?i:[a],d=c.length>1,h=[];return o||r||h.push({label:"Checkout",icon:(0,s.jsx)("i",{className:"iconoir-arrow-right text-[14px]","aria-hidden":"true"}),onClick:()=>t.onCheckout(a)}),r&&h.push({label:"Checkout to local",icon:(0,s.jsx)("i",{className:"iconoir-arrow-down text-[14px]","aria-hidden":"true"}),onClick:()=>t.onCheckoutToLocal(a)}),h.push({label:"Create Branch",icon:(0,s.jsx)("i",{className:"iconoir-plus-circle text-[14px]","aria-hidden":"true"}),onClick:()=>t.onCreateBranch(a)}),r||h.push({label:"Rename Branch",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>t.onRenameBranch(a)}),r&&h.push({label:"Rename branch",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>t.onRenameRemoteBranch(a)}),r||h.push({label:"Push to Remote",icon:(0,s.jsx)("i",{className:"iconoir-arrow-up text-[14px]","aria-hidden":"true"}),onClick:()=>t.onPushToRemote(a)}),r||h.push({label:"Pull from Remote",icon:(0,s.jsx)("i",{className:"iconoir-arrow-down text-[14px]","aria-hidden":"true"}),onClick:()=>t.onPullFromRemote(a)}),!o&&n&&(h.push({label:`Rebase ${n} onto ${l}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Rebase ",(0,s.jsx)("span",{className:"font-bold",children:n})," onto ",l]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>t.onRebase({sourceBranch:n,targetBranch:a})}),h.push({label:`Rebase ${l} onto ${n}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Rebase ",l," onto ",(0,s.jsx)("span",{className:"font-bold",children:n})]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>t.onRebase({sourceBranch:a,targetBranch:n})}),h.push({label:`Merge ${n} into ${l}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Merge ",(0,s.jsx)("span",{className:"font-bold",children:n})," into ",l]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>t.onMerge({sourceBranch:n,targetBranch:a})}),h.push({label:`Merge ${l} into ${n}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Merge ",l," into ",(0,s.jsx)("span",{className:"font-bold",children:n})]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>t.onMerge({sourceBranch:a,targetBranch:n})})),o||(d?h.push({label:`Delete Selected Branches (${c.length})`,icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>t.onDeleteBranches(c),danger:!0}):h.push({label:"Delete Branch",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>t.onDeleteBranch(a),danger:!0})),h}(e,{onCheckout:nS,onCheckoutToLocal:ng,onCreateBranch:nO,onDeleteBranch:l4,onDeleteBranches:l2,onRenameBranch:ne,onRenameRemoteBranch:nt,onRebase:nr,onMerge:no,onPushToRemote:nh,onPullFromRemote:np});return lf.length>0&&t.push({label:"Custom scripts",icon:(0,s.jsx)("i",{className:"iconoir-terminal text-[14px]","aria-hidden":"true"}),children:lf.map(t=>({label:t.name,icon:(0,s.jsx)("i",{className:"iconoir-play text-[14px]","aria-hidden":"true"}),onClick:()=>{lZ(t,e.branchRef)}}))}),t},n1=(0,r.useMemo)(()=>new Set(E?.branches??[]),[E?.branches]),n2=(0,r.useMemo)(()=>{let e=new Map;if(!E?.remotes)return e;for(let[t,a]of Object.entries(E.remotes))for(let s of a)e.set(`${t}/${s}`,`remotes/${t}/${s}`);return e},[E?.remotes]),n4=(0,r.useMemo)(()=>ld?M(ld).filter(e=>e!==l_):[],[ld,l_]),n3=E?.worktrees??[],n5=(0,s.jsxs)("div",{className:"w-[22rem] max-w-[calc(100vw-2rem)] flex flex-col border border-base-300 bg-base-100 rounded-box shadow-xl overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-4 border-b border-base-300 flex items-center justify-between bg-base-100 h-[57px] shrink-0",children:[(0,s.jsx)("h2",{className:"font-bold text-lg",children:"Branches"}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[lV&&(0,s.jsx)("div",{className:"tooltip tooltip-left z-20","data-tip":"Clear filters",children:(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:lD,children:(0,s.jsx)("i",{className:"iconoir-filter text-[16px]","aria-hidden":"true"})})}),(0,s.jsx)("div",{className:"tooltip tooltip-left z-20","data-tip":"Create Branch",children:(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:()=>nO(),children:(0,s.jsx)("i",{className:"iconoir-plus-circle text-[16px]","aria-hidden":"true"})})})]})]}),(0,s.jsx)("div",{className:"max-h-[70vh] overflow-auto",children:(0,s.jsxs)("div",{className:"p-2 space-y-0.5",children:[ld&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c,{items:[{label:"Delete",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>l2(n4),danger:!0,disabled:0===n4.length}],children:(0,s.jsx)(D,{name:"Branches",groupPath:"__local__",icon:(0,s.jsx)("i",{className:"iconoir-git-branch text-[14px]","aria-hidden":"true"}),isExpanded:lb,onToggle:lB,visibilityMap:lk,onToggleVisibility:lA})}),lb&&(0,s.jsx)(L,{node:ld,currentBranch:E?.current,expandedFolders:lC,onToggleFolder:lM,onCheckout:nS,onCheckoutToLocal:ng,onCreateBranch:()=>nO(),onDeleteBranch:l4,onRenameBranch:ne,onRenameRemoteBranch:nt,onRebase:nr,onMerge:no,onPushToRemote:nh,onPullFromRemote:np,getBranchContextMenuItems:n0,onBranchClick:lQ,onBranchContextMenu:lX,onDeleteBranchGroup:l2,selectedBranches:lu,visibilityMap:lk,onToggleVisibility:lA,depth:1,groupPath:"__local__",trackingInfo:E?.trackingInfo})]}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c,{items:[{label:"Fetch from all remotes",icon:(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"}),onClick:ny},{label:"Add remote",icon:(0,s.jsx)("i",{className:"iconoir-plus-circle text-[14px]","aria-hidden":"true"}),onClick:()=>{tN("origin"),tv(""),tg(!0)}}],children:(0,s.jsx)(D,{name:"Remotes",groupPath:"__remotes__",icon:(0,s.jsx)("i",{className:"iconoir-globe text-[14px]","aria-hidden":"true"}),isExpanded:lj,onToggle:lP,visibilityMap:lk,onToggleVisibility:lA})}),lj&&P&&!lh&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2 py-2 text-sm opacity-70",style:{paddingLeft:"20px"},children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsx)("span",{children:"Loading remotes..."})]}),lj&&lh&&Array.from(lh.entries()).map(([e,t])=>{let a=`__remotes__/${e}`,l=lC.has(a);return(0,s.jsxs)("div",{children:[(0,s.jsx)(c,{items:[{label:`Fetch from ${e}`,icon:(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"}),onClick:()=>nC(e)},{label:"Rename",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>{tr(e),to(e),tl(!0)}},{label:"Delete",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>{e&&(tx(e),tm(!0))},danger:!0}],children:(0,s.jsx)(D,{name:e,groupPath:a,icon:(0,s.jsx)("i",{className:"iconoir-globe text-[14px] opacity-50","aria-hidden":"true"}),isExpanded:l,onToggle:()=>lM(a),visibilityMap:lk,onToggleVisibility:lA,depth:1})}),l&&(0,s.jsx)(L,{node:t,currentBranch:E?.current,expandedFolders:lC,onToggleFolder:lM,onCheckout:nS,onCheckoutToLocal:ng,onCreateBranch:()=>nO(),onDeleteBranch:l4,onRenameBranch:ne,onRenameRemoteBranch:nt,onRebase:nr,onMerge:no,onPushToRemote:nh,onPullFromRemote:np,getBranchContextMenuItems:n0,onBranchClick:lQ,onBranchContextMenu:lX,onDeleteBranchGroup:l2,selectedBranches:lu,visibilityMap:lk,onToggleVisibility:lA,depth:2,groupPath:a,isRemote:!0,trackingInfo:E?.trackingInfo})]},e)})]}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"group flex items-center gap-1 px-2 py-1.5 text-sm rounded-md cursor-pointer hover:bg-base-200 transition-colors font-medium",onClick:lF,children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-xs opacity-70",children:ly?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[14px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:"Worktrees"})]}),(0,s.jsx)("span",{className:"text-xs opacity-60",children:n3.length})]}),ly&&P&&0===n3.length&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2 py-2 text-sm opacity-70",style:{paddingLeft:"20px"},children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsx)("span",{children:"Loading worktrees..."})]}),ly&&!P&&0===n3.length&&(0,s.jsx)("div",{className:"px-2 py-2 text-sm opacity-70",style:{paddingLeft:"20px"},children:"No worktrees found"}),ly&&n3.map(e=>{let t=(0,s.jsxs)("button",{type:"button",className:(0,o.cn)("group flex w-full items-center gap-2 px-2 py-1.5 text-sm rounded-md transition-colors text-left",e.isCurrent?"cursor-default opacity-85":"cursor-pointer hover:bg-base-200"),style:{paddingLeft:"20px"},onClick:()=>nw(e.path,e.isCurrent),title:e.path,disabled:e.isCurrent,children:[(0,s.jsx)("i",{className:`iconoir-folder text-[14px] shrink-0 ${e.isCurrent?"text-primary":"opacity-60"}`,"aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:e.path}),e.branch&&(0,s.jsx)("span",{className:"shrink-0 text-xs opacity-60",children:e.branch}),e.isCurrent&&(0,s.jsx)("span",{className:"shrink-0 text-xs text-primary font-medium",children:"current"})]});return e.isCurrent?(0,s.jsx)("div",{children:t},e.path):(0,s.jsx)(c,{items:[{label:"Delete worktree",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>l3(e.path),danger:!0}],children:t},e.path)})]})]})})]});return v&&100===g?(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})}):k?(0,s.jsxs)("div",{className:"flex items-center justify-center p-8 h-full flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-error font-medium",children:"Error Loading History"}),(0,s.jsx)("p",{className:"text-sm opacity-70",children:w?.message||"An unknown error occurred"}),(0,s.jsxs)("button",{onClick:()=>void C(),className:"btn btn-outline btn-sm",children:[(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[16px] mr-1","aria-hidden":"true"}),"Try Again"]})]}):y?(0,s.jsxs)("div",{className:"flex h-full overflow-hidden",children:[sc&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Reset to Commit"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to hard reset branch ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"Detached HEAD"})," to commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:sh?.substring(0,7)}),"?",(0,s.jsx)("br",{}),(0,s.jsx)("span",{className:"text-error font-bold",children:"Warning: This will discard all local changes and commits after this point. This action cannot be undone."})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>sd(!1),disabled:su,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:n$,disabled:su,children:[su&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Reset"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>sd(!1),children:"close"})})]}),sp&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Revert Commit"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to revert commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:sb?.hash.substring(0,7)})," on ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"current"}),"?"]}),sb?.message&&(0,s.jsx)("div",{className:"rounded border border-base-300 bg-base-200/40 px-3 py-2 text-xs break-words",children:sb.message}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{sf(!1),sg(null)},disabled:sj,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nB,disabled:sj,children:[sj&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Revert"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{sf(!1),sg(null)},children:"close"})})]}),sy&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Reword Commit"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Reword commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:sk?.hash.substring(0,7)})," on branch ",(0,s.jsx)("span",{className:"font-bold",children:sk?.branch}),"."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full font-mono text-sm mb-3",value:sC,onChange:e=>sS(e.target.value),autoFocus:!0,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&sC.trim()&&!s$&&(e.preventDefault(),nP())},placeholder:"Commit subject",disabled:s$}),(0,s.jsx)("textarea",{className:"textarea textarea-bordered w-full h-32 font-mono text-sm",value:sE,onChange:e=>sR(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&sC.trim()&&!s$&&(e.preventDefault(),nP())},placeholder:"Commit message body (optional)",disabled:s$}),sk?.branch!==E?.current&&(0,s.jsx)("div",{className:"alert alert-warning text-xs mt-2 py-2",children:(0,s.jsxs)("span",{children:["This will briefly checkout ",(0,s.jsx)("b",{children:sk?.branch})," to amend the commit."]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:s1,disabled:s$,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nP,disabled:!sC.trim()||s$,children:[s$&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Reword"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:s1,children:"close"})})]}),ek&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:eC.length>1?"Delete Branches":"Delete Branch"}),eC.length>1?(0,s.jsxs)("div",{className:"py-4 space-y-3",children:[(0,s.jsxs)("p",{className:"break-words",children:["Are you sure you want to delete ",(0,s.jsxs)("span",{className:"font-bold",children:[eC.length," selected branches"]}),"? This action cannot be undone."]}),(0,s.jsx)("div",{className:"max-h-44 overflow-auto rounded border border-base-300 bg-base-200/40 p-2 space-y-1",children:eC.map(e=>(0,s.jsx)("div",{className:"text-xs min-w-0 break-all",children:e.startsWith("remotes/")?e.slice(8):e},e))})]}):(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete the branch ",(0,s.jsx)("span",{className:"font-bold break-all",children:eC[0]?.startsWith("remotes/")?eC[0].slice(8):eC[0]}),"? This action cannot be undone."]}),nz.length>0&&(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start items-start gap-2 min-w-0",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:eE,onChange:e=>eR(e.target.checked),disabled:e$}),(0,s.jsx)("span",{className:"label-text break-words whitespace-normal",children:1===nz.length?(0,s.jsxs)(s.Fragment,{children:["Delete tracking remote branch ",(0,s.jsx)("span",{className:"font-mono opacity-70 break-all",children:nz[0]})]}):(0,s.jsxs)(s.Fragment,{children:["Delete ",nz.length," tracking remote branches"]})})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{ew(!1),eS([]),eR(!1)},disabled:e$,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:l6,disabled:e$,children:[e$&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{ew(!1),eS([]),eR(!1)},children:"close"})})]}),eP&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Delete Worktree"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete the worktree ",(0,s.jsx)("span",{className:"font-bold break-all",children:eM}),"?"]}),(0,s.jsx)("p",{className:"text-sm text-error break-words",children:"This will remove the worktree from git and remove its working directory."}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{eF(!1),eA(null)},disabled:eD,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:()=>void l9(),disabled:eD||!eM,children:[eD&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{eF(!1),eA(null)},children:"close"})})]}),eT&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Delete Tag"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete the tag ",(0,s.jsx)("span",{className:"font-bold break-all",children:eO}),"? This action cannot be undone."]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start items-start gap-2 min-w-0",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:eI,onChange:e=>eK(e.target.checked),disabled:ez||!nK}),(0,s.jsx)("span",{className:"label-text break-words whitespace-normal",children:nK?(0,s.jsxs)(s.Fragment,{children:["Also delete from remote ",(0,s.jsx)("span",{className:"font-mono opacity-70",children:nK})]}):"No remote configured"})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:l5,disabled:ez,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:l8,disabled:ez||!eO,children:[ez&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:l5,children:"close"})})]}),eW&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Cherry Pick"}),(0,s.jsx)("p",{className:"text-sm opacity-70 mt-1",children:eU.length>1?"Apply selected commits from oldest to newest":"Apply changes from the selected commit"}),1===eU.length?(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure to apply ",(0,s.jsx)("span",{className:"font-bold font-mono break-all",children:eU[0]?.hash})," ",(0,s.jsx)("span",{className:"font-bold break-words",children:eU[0]?.message})," to ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"current"})," branch?"]}):(0,s.jsxs)("div",{className:"py-4 space-y-3",children:[(0,s.jsxs)("p",{className:"break-words",children:["Are you sure to apply ",(0,s.jsxs)("span",{className:"font-bold",children:[eU.length," selected commits"]})," to ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"current"})," branch?"]}),(0,s.jsx)("div",{className:"max-h-44 overflow-auto rounded border border-base-300 bg-base-200/40 p-2 space-y-1",children:eU.map(e=>(0,s.jsxs)("div",{className:"text-xs min-w-0",children:[(0,s.jsx)("span",{className:"font-mono opacity-70",children:e.hash.slice(0,7)})," ",(0,s.jsx)("span",{className:"break-words",children:e.message})]},e.hash))})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{eG(!1),eV([])},disabled:eY,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nL,disabled:eY,children:[eY&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{eG(!1),eV([])},children:"close"})})]}),eQ&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Cherry Pick In Progress"}),(0,s.jsx)("p",{className:"text-sm opacity-70 mt-1",children:"Another cherry-pick operation is currently in progress."}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Abort the in-progress cherry-pick and continue with ",eU.length>1?"the selected commits":"this commit","?"]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{eX(!1),eV([])},disabled:eZ,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-warning",onClick:()=>void nT(),disabled:eZ,children:[eZ&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Abort and Continue"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{eX(!1),eV([])},children:"close"})})]}),e1&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:e5?"Rename Remote Branch":"Rename Branch"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Enter a new name for the branch ",(0,s.jsx)("span",{className:"font-bold break-all",children:e4}),". Press ",(0,s.jsx)("kbd",{className:"kbd kbd-sm",children:"Enter"})," to confirm."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:e6,onChange:e=>e8((0,o.L9)(e.target.value)),placeholder:"New branch name",disabled:tt,autoFocus:!0,onKeyDown:e=>{let t="Enter"===e.key&&(e.metaKey||e.ctrlKey),a=e5?e6===e5.branch:e6===e4;t&&e6&&!a&&!tt&&na()}}),!e5&&nq?.upstream&&(0,s.jsx)("div",{className:"form-control mt-2",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start items-start gap-2 min-w-0",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:e9,onChange:e=>te(e.target.checked),disabled:tt}),(0,s.jsxs)("span",{className:"label-text break-words whitespace-normal",children:["Also rename tracking remote branch ",(0,s.jsx)("span",{className:"font-mono opacity-70 break-all",children:nq.upstream})]})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:sQ,disabled:tt,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:na,disabled:!e6||(e5?e6===e5.branch:e6===e4)||tt,children:[tt&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Rename"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:sQ,children:"close"})})]}),ts&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Rename Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Enter a new name for remote ",(0,s.jsx)("span",{className:"font-bold break-all",children:tn}),". Press ",(0,s.jsx)("kbd",{className:"kbd kbd-sm",children:"Enter"})," to confirm."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:ti,onChange:e=>to(e.target.value),placeholder:"New remote name",disabled:tc,autoFocus:!0,onKeyDown:e=>{let t="Enter"===e.key&&(e.metaKey||e.ctrlKey),a=ti.trim(),s=a===(tn??"").trim();t&&a&&!s&&!tc&&ns()}}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:sX,disabled:tc,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:ns,disabled:!ti.trim()||ti.trim()===(tn??"").trim()||tc,children:[tc&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Rename"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:sX,children:"close"})})]}),th&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Delete Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete remote ",(0,s.jsx)("span",{className:"font-bold break-all",children:tu}),"? This removes all tracking branches for that remote."]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:sZ,disabled:tp,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:nl,disabled:!tu||tp,children:[tp&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:sZ,children:"close"})})]}),tb&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Add Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Add a new remote by providing a name and URL. Press ",(0,s.jsx)("kbd",{className:"kbd kbd-sm",children:"Enter"})," to confirm."]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label pt-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote name"})}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:tj,onChange:e=>tN(e.target.value),placeholder:"origin",disabled:tk,autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label pt-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote URL"})}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:ty,onChange:e=>tv(e.target.value),placeholder:"https://github.com/owner/repo.git",disabled:tk,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&tj.trim()&&ty.trim()&&!tk&&nn()}})]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:s0,disabled:tk,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nn,disabled:!tj.trim()||!ty.trim()||tk,children:[tk&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Add"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:s0,children:"close"})})]}),tC&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Rebase"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Copy commits from one branch to another.",(0,s.jsx)("br",{}),"Are you sure to rebase ",(0,s.jsx)("span",{className:"font-bold break-all",children:tE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:t$}),"?"]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:tP,onChange:e=>tF(e.target.checked),disabled:tM}),(0,s.jsx)("span",{className:"label-text",children:"Stash and reapply local changes"})]})}),!tP&&(0,s.jsx)("p",{className:"text-xs text-warning mt-2 ml-6",children:"Warning: All local changes will be discarded."}),"checking"===tD?(0,s.jsxs)("div",{className:"alert alert-info text-sm mt-4 py-2",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsxs)("span",{children:["Checking conflicts for rebasing ",(0,s.jsx)("span",{className:"font-bold break-all",children:tE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:t$}),"..."]})]}):"no-conflict"===tD?(0,s.jsxs)("div",{className:"alert alert-success text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-check-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["No conflict: rebasing ",(0,s.jsx)("span",{className:"font-bold break-all",children:tE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:t$})," will not cause conflicts."]})]}):(0,s.jsxs)("div",{className:"alert alert-warning text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-warning-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["Conflicts detected: rebasing ",(0,s.jsx)("span",{className:"font-bold break-all",children:tE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:t$})," will cause conflicts."]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:tT,disabled:tM,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:ni,disabled:tM,children:[tM&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:tT,children:"close"})})]}),t_&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Merge"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Merge branch into another one.",(0,s.jsx)("br",{}),"Are you sure to merge ",(0,s.jsx)("span",{className:"font-bold break-all",children:tK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:tH}),"?"]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:tq,onChange:e=>tW(e.target.checked),disabled:tX}),(0,s.jsx)("span",{className:"label-text",children:"Rebase before merge"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:tG,onChange:e=>nc(e.target.checked),disabled:tX}),(0,s.jsx)("span",{className:"label-text",children:"Squash before merge"})]})}),tG&&(0,s.jsx)("textarea",{className:"textarea textarea-bordered w-full mt-2",placeholder:"Commit message for squash merge",value:tJ,onChange:e=>tQ(e.target.value),disabled:tX,autoFocus:!0}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:tV,onChange:e=>tY(e.target.checked),disabled:tX}),(0,s.jsx)("span",{className:"label-text",children:"Fast forward merge"})]})}),"checking"===t0?(0,s.jsxs)("div",{className:"alert alert-info text-sm mt-4 py-2",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsxs)("span",{children:["Checking conflicts for merging ",(0,s.jsx)("span",{className:"font-bold break-all",children:tK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:tH}),"..."]})]}):"no-conflict"===t0?(0,s.jsxs)("div",{className:"alert alert-success text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-check-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["No conflict: merging ",(0,s.jsx)("span",{className:"font-bold break-all",children:tK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:tH})," will not cause conflicts."]})]}):(0,s.jsxs)("div",{className:"alert alert-warning text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-warning-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["Conflicts detected: merging ",(0,s.jsx)("span",{className:"font-bold break-all",children:tK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:tH})," will cause conflicts."]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:t2,disabled:tX,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nd,disabled:tX,children:[tX&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:t2,children:"close"})})]}),t4&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Push to Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Push ",(0,s.jsx)("span",{className:"font-bold break-all",children:t5})," to a remote repository."]}),aj&&0===t6.length?(0,s.jsxs)("div",{className:"alert alert-error",children:[(0,s.jsx)("span",{className:"text-xl",children:"⚠️"}),(0,s.jsx)("span",{children:aj})]}):ay?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)("span",{className:"loading loading-spinner loading-lg"})}):(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Repository"})}),(0,s.jsx)("select",{className:"select select-bordered w-64",value:t9,onChange:e=>nm(e.target.value),disabled:ab,children:t6.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Branch"})}),(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1 w-64",children:[ak?(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-base-200 opacity-70 w-full",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Loading branches..."]}):(0,s.jsxs)("select",{className:"select select-bordered w-full",value:as,onChange:e=>al(e.target.value),disabled:ab,children:[t5&&!at.includes(t5)&&(0,s.jsxs)("option",{value:t5,children:[t5," (new)"]}),at.map(e=>(0,s.jsxs)("option",{value:e,children:[e,an?.remote===t9&&an?.branch===e?" (tracking)":""]},e))]}),as&&!at.includes(as)&&(0,s.jsx)("div",{className:"label",children:(0,s.jsx)("span",{className:"label-text-alt text-warning",children:"New branch will be created"})})]})]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:ai,onChange:e=>ao(e.target.checked),disabled:ab||ac}),(0,s.jsx)("span",{className:"label-text",children:"Rebase onto remote branch before pushing"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm checkbox-error",checked:ac,onChange:e=>ad(e.target.checked),disabled:ab}),(0,s.jsx)("span",{className:"label-text text-error",children:"Force push"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:ah,onChange:e=>am(e.target.checked),disabled:ab}),(0,s.jsx)("span",{className:"label-text",children:"Push all tags"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:au,onChange:e=>nu(e.target.checked),disabled:ab}),(0,s.jsx)("span",{className:"label-text",children:"Squash local commits before push"})]})}),au&&(0,s.jsx)("textarea",{className:"textarea textarea-bordered w-full",placeholder:"Commit message for squash",value:ap,onChange:e=>af(e.target.value),disabled:ab,autoFocus:!0}),aj&&(0,s.jsx)("div",{className:"alert alert-error text-sm",children:(0,s.jsx)("span",{children:aj})})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>t3(!1),disabled:ab,children:"Cancel"}),t6.length>0&&(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nx,disabled:ab||!t9||!as,children:[ab&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Push"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>t3(!1),children:"close"})})]}),aC&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Pull from Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Pull changes from a remote branch into ",(0,s.jsx)("span",{className:"font-bold break-all",children:aE}),"."]}),aW&&0===a$.length?(0,s.jsx)("div",{className:"alert alert-error",children:(0,s.jsx)("span",{children:aW})}):aU?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)("span",{className:"loading loading-spinner loading-lg"})}):(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Repository"})}),(0,s.jsx)("select",{className:"select select-bordered w-64",value:aP,onChange:e=>nf(e.target.value),disabled:aI,children:a$.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Branch"})}),aY?(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-base-200 opacity-70 w-64",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Loading branches..."]}):(0,s.jsx)("select",{className:"select select-bordered w-64",value:aD,onChange:e=>aL(e.target.value),disabled:aI,children:aM.map(e=>(0,s.jsxs)("option",{value:e,children:[e,aT?.remote===aP&&aT?.branch===e?" (tracking)":""]},e))})]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:aO,onChange:e=>aH(e.target.checked),disabled:aI}),(0,s.jsx)("span",{className:"label-text",children:"Rebase onto remote branch"})]})}),aW&&(0,s.jsx)("div",{className:"alert alert-error text-sm",children:(0,s.jsx)("span",{children:aW})})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>aS(!1),disabled:aI,children:"Cancel"}),a$.length>0&&(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nb,disabled:aI||!aP||!aD,children:[aI&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Pull"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>aS(!1),children:"close"})})]}),eu&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Create Tag"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Create a new tag at commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:ep?.substring(0,7)}),"."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full font-mono",value:eb,onChange:e=>eg(e.target.value),placeholder:"Tag name",disabled:ey,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&eb.trim()&&!ey&&(e.preventDefault(),nH())}}),(0,s.jsx)("div",{className:"form-control mt-3",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:ej,onChange:e=>eN(e.target.checked),disabled:ey}),(0,s.jsx)("span",{className:"label-text",children:"Push tag to remote after creation"})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{ex(!1),ef(null),eg(""),eN(!1)},disabled:ey,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nH,disabled:!eb.trim()||ey,children:[ey&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Create"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{ex(!1),ef(null),eg(""),eN(!1)},children:"close"})})]}),en&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Create New Branch"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Create a new branch from"," ",(0,s.jsx)("span",{className:"font-bold break-all",children:ec?ec.replace(/^remotes\//,""):"current HEAD"}),"."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:ei,onChange:e=>eo((0,o.L9)(e.target.value)),placeholder:"Branch name",disabled:eh,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&ei&&!eh&&(e.preventDefault(),n_())}}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{er(!1),ed(null)},disabled:eh,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:n_,disabled:!ei||eh,children:[eh&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Create & Checkout"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{er(!1),ed(null)},children:"close"})})]}),a4&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Checkout to Local Branch"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Create a local branch from ",(0,s.jsx)("span",{className:"font-bold break-all",children:a5?.replace(/^remotes\//,"")})," and set up tracking."]}),(0,s.jsxs)("div",{className:"form-control w-full",children:[(0,s.jsx)("label",{className:"label",children:(0,s.jsx)("span",{className:"label-text",children:"Local Branch Name"})}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:a6,onChange:e=>a8((0,o.L9)(e.target.value)),placeholder:"Local branch name",disabled:a9,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&a6&&!a9&&(e.preventDefault(),nN())}})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>a3(!1),disabled:a9,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nN,disabled:!a6||a9,children:[a9&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Checkout"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>a3(!1),children:"close"})})]}),st&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-full bg-warning/15 text-warning flex items-center justify-center shrink-0",children:(0,s.jsx)("i",{className:"iconoir-warning-triangle text-[20px]","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Uncommitted Changes"}),(0,s.jsxs)("p",{className:"text-sm opacity-80 mt-1",children:["You have uncommitted changes in your workspace. Choose how to handle your changes before switching to branch"," ",(0,s.jsx)("span",{className:"font-bold font-mono text-primary break-all",children:nj}),":"]})]})]}),(0,s.jsxs)("div",{className:"space-y-2.5 my-5",children:[(0,s.jsxs)("label",{className:(0,o.cn)("flex items-start gap-3 p-3.5 rounded-lg border cursor-pointer transition-colors select-none","stash-and-reapply"===sn?"border-primary bg-primary/5 shadow-xs":"border-base-300 hover:bg-base-200/50"),onClick:()=>sr("stash-and-reapply"),children:[(0,s.jsx)("input",{type:"radio",name:"switchBranchStrategy",className:"radio radio-primary radio-sm mt-0.5",checked:"stash-and-reapply"===sn,onChange:()=>sr("stash-and-reapply"),disabled:si}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"font-semibold text-sm flex items-center gap-2",children:[(0,s.jsx)("span",{children:"Stash and reapply"}),(0,s.jsx)("span",{className:"badge badge-xs badge-primary/20 text-primary font-normal",children:"Default"})]}),(0,s.jsxs)("p",{className:"text-xs opacity-70 mt-0.5 leading-relaxed",children:["Stash current changes, switch to ",(0,s.jsx)("span",{className:"font-mono font-medium",children:nj}),", and reapply your changes."]})]})]}),(0,s.jsxs)("label",{className:(0,o.cn)("flex items-start gap-3 p-3.5 rounded-lg border cursor-pointer transition-colors select-none","discard"===sn?"border-error bg-error/5 shadow-xs":"border-base-300 hover:bg-base-200/50"),onClick:()=>sr("discard"),children:[(0,s.jsx)("input",{type:"radio",name:"switchBranchStrategy",className:"radio radio-error radio-sm mt-0.5",checked:"discard"===sn,onChange:()=>sr("discard"),disabled:si}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"font-semibold text-sm text-error flex items-center gap-1.5",children:[(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),(0,s.jsx)("span",{children:"Discard changes"})]}),(0,s.jsxs)("p",{className:"text-xs opacity-70 mt-0.5 leading-relaxed",children:["Permanently discard all uncommitted changes before switching. ",(0,s.jsx)("span",{className:"text-error font-medium",children:"This cannot be undone."})]})]})]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{type:"button",className:"btn",onClick:()=>{sa(!1),sl(null)},disabled:si,children:"Cancel"}),(0,s.jsxs)("button",{type:"button",className:(0,o.cn)("btn","discard"===sn?"btn-error":"btn-primary"),onClick:nE,disabled:si,children:[si&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{type:"button",onClick:()=>{si||(sa(!1),sl(null))},children:"close"})})]}),sI.isOpen&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box max-w-4xl",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("h3",{className:"font-bold text-lg truncate",children:["Custom Script: ",sI.scriptName]}),(0,s.jsxs)("p",{className:"text-xs opacity-70 mt-1 break-all",children:["Branch: ",sI.branchRef]})]}),(0,s.jsx)("span",{className:(0,o.cn)("badge badge-sm shrink-0","running"===sI.status||"starting"===sI.status?"badge-info":"completed"===sI.status?"badge-success":"failed"===sI.status?"badge-error":"canceled"===sI.status?"badge-warning":"badge-ghost"),children:sI.status})]}),(0,s.jsx)("div",{className:"mt-4 border border-base-300 rounded bg-base-200/40",children:(0,s.jsx)("pre",{className:"p-3 font-mono text-xs overflow-auto max-h-[50vh] whitespace-pre-wrap break-words",children:sI.output||"Waiting for output..."})}),sI.error&&(0,s.jsx)("div",{className:"alert alert-error py-2 mt-3",children:(0,s.jsx)("span",{children:sI.error})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsxs)("button",{className:"btn btn-warning",onClick:()=>void l0(),disabled:!sY||sz,children:[sz&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Cancel"]}),(0,s.jsxs)("button",{className:"btn btn-outline",onClick:()=>void l1(),disabled:sW,children:[sW&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),sU?"Copied":"Copy"]}),(0,s.jsx)("button",{className:"btn btn-primary",onClick:()=>{sK(K),sV(!1),sq(!1)},disabled:!sJ,children:"Done"})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:e=>{sJ?(sK(K),sV(!1),sq(!1)):e.preventDefault()},children:"close"})})]}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 bg-base-100",children:[(0,s.jsxs)("div",{className:"h-[57px] flex items-center justify-between gap-3 px-6 border-b border-base-300 shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("h1",{className:"font-bold text-lg",children:"History"}),(0,s.jsxs)("div",{className:"relative",ref:sH,children:[(0,s.jsxs)("button",{className:"btn btn-sm gap-2 max-w-[24rem]",onClick:()=>sO(e=>!e),title:nU,children:[(0,s.jsx)("span",{className:"truncate",children:nU}),(0,s.jsx)("i",{className:(0,o.cn)("iconoir-nav-arrow-down text-[16px] shrink-0 transition-transform",s_&&"rotate-180"),"aria-hidden":"true"})]}),s_&&(0,s.jsx)("div",{className:"absolute left-0 top-full mt-2 z-50",children:n5})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,s.jsxs)("button",{className:"btn btn-sm gap-2",onClick:()=>void ny(),disabled:aQ||az||aC||t4,title:"Fetch latest changes from all remotes",children:[aQ?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-refresh text-[16px]","aria-hidden":"true"}),"Fetch"]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2",onClick:()=>{l_&&!nJ&&np(l_)},disabled:!!nJ||az||aC||t4,title:nJ||`Pull from ${nV?.upstream}`,children:[aU?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-arrow-down text-[16px]","aria-hidden":"true"}),"Pull"]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2",onClick:()=>void nZ(),disabled:!!nQ||aC||t4||az,title:nQ||"Pull all local branches from tracking remote branches",children:[az?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-arrow-down text-[16px]","aria-hidden":"true"}),"Pull All"]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2",onClick:()=>{l_&&!nX&&nh(l_)},disabled:!!nX||az||aC||t4,title:nX||(nV?`Push to ${nV.upstream}`:"Push current branch to remote"),children:[ay?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-arrow-up text-[16px]","aria-hidden":"true"}),"Push"]})]})]}),(0,s.jsxs)("div",{className:"shrink-0 flex items-center gap-2",children:[(0,s.jsxs)("button",{className:"btn btn-sm gap-2",onClick:()=>void nk(),disabled:a1,title:"Open terminal in repository folder",children:[a1?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-terminal text-[16px]","aria-hidden":"true"}),"Open Terminal"]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2",onClick:()=>void nv(),disabled:aZ,title:"Open repository folder in Finder",children:[aZ?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-folder text-[16px]","aria-hidden":"true"}),"Open Repo Folder"]})]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden relative",children:lV&&P?(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner loading-lg opacity-50"})}):(0,s.jsx)(h,{ref:sP,commits:lH,selectedHash:U||void 0,selectedHashes:lI,onSelectCommit:lG,onResetToCommit:nR,onRevertCommit:(e,t)=>{sg({hash:e,message:t}),sf(!0)},onCreateTag:e=>{ef(e),eg(""),eN(!1),ex(!0)},onCherryPickCommit:(e,t)=>{eV([{hash:e,message:t}]),eG(!0)},onCherryPickSelectedCommits:()=>{lU.length<2||(eV(lU.map(e=>({hash:e.hash,message:e.message}))),eG(!0))},onRewordCommit:(e,t,a,s)=>{sw({hash:e,subject:t,body:a,branch:s}),sS(t),sR(a),sv(!0)},localBranches:E?.branches||[],trackingInfo:E?.trackingInfo,onEndReached:()=>{!S&&y.all.length>=g&&j(e=>e+50)},isLoadingMore:S&&g>100,currentBranch:E?.current,hiddenBranches:lY,getBranchTagContextMenuItems:e=>{if(e.startsWith("tag:")){let t=e.replace(/^tag:\s*/,"").trim();return t?[{label:"Delete Tag",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>l7(t),danger:!0}]:null}if(n1.has(e))return n0({branchRef:e,branchLeafName:e.split("/").pop()||e,currentBranch:l_,isRemote:!1});let t=n2.get(e);return t?n0({branchRef:t,branchLeafName:t.split("/").pop()||e,currentBranch:l_,isRemote:!0}):null}})}),U&&(0,s.jsxs)("div",{className:"flex flex-col overflow-hidden border-t border-base-300 bg-base-200/30",style:{height:s6},children:[(0,s.jsx)("div",{className:(0,o.cn)("h-1.5 cursor-ns-resize flex items-center justify-center hover:bg-base-200 transition-colors group shrink-0",s9&&"bg-base-200"),onMouseDown:lo,children:(0,s.jsx)("div",{className:"w-8 h-1 rounded-full bg-base-300 group-hover:bg-base-content/20 transition-colors"})}),"__LOCAL_CHANGES__"===U?(0,s.jsx)("div",{className:"flex-1 overflow-hidden min-h-0 flex flex-col",children:(0,s.jsx)(R,{repoPath:e,onClose:()=>et(null)})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-row items-center py-2 px-4 border-b border-base-300 bg-base-100 shrink-0 justify-between gap-4",children:[(0,s.jsx)("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:lW&&lq?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"text-sm font-bold truncate",children:[lq.latestHash.substring(0,7),": ",lq.latestCommit.message]}),(0,s.jsxs)("div",{className:"text-sm font-bold truncate opacity-75",children:[lq.oldestHash.substring(0,7),": ",lq.oldestCommit.message]})]})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-sm font-bold truncate",children:lz?.message}),(0,s.jsx)("span",{className:"text-xs font-mono opacity-50 shrink-0",children:U.substring(0,7)})]})}),(0,s.jsx)("div",{className:"flex items-center gap-1 shrink-0",children:(0,s.jsx)("button",{className:"ml-2 btn btn-ghost btn-xs btn-square",onClick:()=>et(null),title:"Close",children:"✕"})})]}),lW&&lq?(0,s.jsxs)("div",{className:"flex-1 overflow-hidden min-h-0 flex flex-col bg-base-100",children:[(0,s.jsx)("div",{className:"px-4 pt-2 pb-1 text-[10px] uppercase tracking-wider font-bold opacity-60 border-b border-base-300 bg-base-100 shrink-0",children:"Changes"}),(0,s.jsx)("div",{className:"flex-1 min-h-0",children:(0,s.jsx)(N,{repoPath:e,fromCommitHash:lq.oldestHash,toCommitHash:lq.latestHash})})]}):(0,s.jsxs)("div",{ref:lr,className:"flex-1 overflow-hidden bg-base-100 grid",style:{gridTemplateRows:`${la}fr 6px ${1-la}fr`},children:[(0,s.jsxs)("div",{className:"border-b border-base-300 bg-base-100 min-h-0 flex flex-col",children:[(0,s.jsx)("div",{className:"px-4 pt-3 pb-1 text-[10px] uppercase tracking-wider font-bold opacity-60",children:"Message"}),(0,s.jsx)("div",{className:"px-4 pb-3 overflow-auto flex-1 min-h-0",children:(0,s.jsx)("div",{className:"text-xs opacity-70 whitespace-pre-wrap font-mono",children:lz?(lz.body?.trim()?`${lz.message}
|
|
8
|
+
${t}`:a),branch:sk.branch}}),s1()}catch(e){console.error(e)}finally{sB(!1)}}},nF=e=>{if(!(e instanceof Error))return!1;let a=e.message.toLowerCase();return a.includes("cherry-pick")&&a.includes("already in progress")},nM=e=>{if(!(e instanceof Error))return!1;let a=e.message.toLowerCase();return a.includes("could not apply")||a.includes("conflict")||a.includes("cherry-pick --continue")},nA=(0,r.useCallback)(async a=>{1===a.length?await et({repoPath:e,action:"cherry-pick",data:{commitHash:a[0]}}):await et({repoPath:e,action:"cherry-pick-multiple",data:{commitHashes:a}})},[e,et]),nD=(0,r.useCallback)(async()=>{try{await et({repoPath:e,action:"cherry-pick-abort"})}catch(e){console.error(e)}finally{eG(!1),eX(!1),eV([])}},[e,et]),nL=async()=>{if(0!==eU.length){eJ(!0);try{let e=eU.map(e=>e.hash);await nA(e),eG(!1),eV([])}catch(e){nF(e)?(eG(!1),eX(!0)):nM(e)&&await nD(),console.error(e)}finally{eJ(!1)}}},nT=async()=>{if(0===eU.length)return void eX(!1);e0(!0);try{await et({repoPath:e,action:"cherry-pick-abort"});let a=eU.map(e=>e.hash);await nA(a),eX(!1),eV([])}catch(e){nF(e)?eX(!0):nM(e)&&await nD(),console.error(e)}finally{e0(!1)}},n_=async()=>{if(ei){em(!0);try{await et({repoPath:e,action:"branch",data:{branch:ei,fromRef:ec||void 0}}),er(!1),eo(""),ed(null)}catch(e){console.error(e)}finally{em(!1)}}},nO=e=>{ed(e||null),er(!0)},nH=async()=>{if(ep&&ef.trim()){ev(!0);try{await et({repoPath:e,action:"create-tag",data:{tagName:ef.trim(),commitHash:ep,pushToRemote:ej}}),ex(!1),eb(null),eg(""),eN(!1)}catch(e){console.error(e)}finally{ev(!1)}}},nI=E?.trackingInfo,nK=(0,r.useMemo)(()=>Object.keys(E?.remoteUrls??{}).sort((e,a)=>"origin"===e?-1:"origin"===a?1:e.localeCompare(a)),[E?.remoteUrls])[0]||null,nz=(0,r.useMemo)(()=>{let e=[];for(let a of eC){if(a.startsWith("remotes/"))continue;let t=nI?.[a]?.upstream;t&&e.push(t)}return Array.from(new Set(e))},[eC,nI]),nq=(0,r.useMemo)(()=>!e4||e5?null:nI?.[e4]??null,[e4,e5,nI]),nW=q?.files?.length,nG=l_||(P?"Loading branches...":"Detached HEAD"),nU=l_&&"number"==typeof nW&&nW>0?`${l_} (${nW})`:nG,nV=(0,r.useMemo)(()=>{if(!l_)return null;let e=nI?.[l_];if(!e?.upstream)return null;let a=H(e.upstream);return a?{upstream:e.upstream,...a}:null},[l_,nI]),nY=(0,r.useMemo)(()=>{let e=[];for(let a of E?.branches??[]){let t=nI?.[a]?.upstream;if(!t)continue;let s=H(t);s&&e.push({localBranch:a,remote:s.remote,remoteBranch:s.branch})}return e},[E?.branches,nI]),nJ=(0,r.useMemo)(()=>P?"Loading branches...":l_?nV?null:`Branch "${l_}" has no tracking remote branch`:"Not on a local branch",[l_,nV,P]),nQ=(0,r.useMemo)(()=>P?"Loading branches...":0===nY.length?"No local branches with tracking remote branches":null,[P,nY.length]),nX=(0,r.useMemo)(()=>P?"Loading branches...":l_?null:"Not on a local branch",[l_,P]),nZ=async()=>{if(tz||0===nY.length)return;tq(!0);let a=[];try{for(let t of nY)try{await et({repoPath:e,action:"pull-from-remote",data:{localBranch:t.localBranch,remote:t.remote,remoteBranch:t.remoteBranch,rebase:!0},suppressErrorToast:!0}),a.push(t.localBranch)}catch(l){let e=l instanceof Error?l.message:"Unknown error",s=a.length>0?`Pulled ${a.length} branch${1===a.length?"":"es"} before failure.`:"No branches were updated.";(0,u.oR)({type:"error",title:`Pull All Failed on "${t.localBranch}"`,description:`${e} ${s}`,duration:12e3});return}(0,u.oR)({type:"success",title:1===a.length?"Pulled 1 Branch":`Pulled ${a.length} Branches`,description:"Updated all local branches that have tracking remote branches."})}finally{tq(!1)}},n0=e=>{let a=function(e,a){let{branchRef:t,branchLeafName:l,currentBranch:n,isRemote:r,selectedBranchRefs:i}=e,o=!r&&t===n,c=i&&i.length>0?i:[t],d=c.length>1,h=[];return o||r||h.push({label:"Checkout",icon:(0,s.jsx)("i",{className:"iconoir-arrow-right text-[14px]","aria-hidden":"true"}),onClick:()=>a.onCheckout(t)}),r&&h.push({label:"Checkout to local",icon:(0,s.jsx)("i",{className:"iconoir-arrow-down text-[14px]","aria-hidden":"true"}),onClick:()=>a.onCheckoutToLocal(t)}),h.push({label:"Create Branch",icon:(0,s.jsx)("i",{className:"iconoir-plus-circle text-[14px]","aria-hidden":"true"}),onClick:()=>a.onCreateBranch(t)}),r||h.push({label:"Rename Branch",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>a.onRenameBranch(t)}),r&&h.push({label:"Rename branch",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>a.onRenameRemoteBranch(t)}),r||h.push({label:"Push to Remote",icon:(0,s.jsx)("i",{className:"iconoir-arrow-up text-[14px]","aria-hidden":"true"}),onClick:()=>a.onPushToRemote(t)}),r||h.push({label:"Pull from Remote",icon:(0,s.jsx)("i",{className:"iconoir-arrow-down text-[14px]","aria-hidden":"true"}),onClick:()=>a.onPullFromRemote(t)}),!o&&n&&(h.push({label:`Rebase ${n} onto ${l}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Rebase ",(0,s.jsx)("span",{className:"font-bold",children:n})," onto ",l]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>a.onRebase({sourceBranch:n,targetBranch:t})}),h.push({label:`Rebase ${l} onto ${n}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Rebase ",l," onto ",(0,s.jsx)("span",{className:"font-bold",children:n})]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>a.onRebase({sourceBranch:t,targetBranch:n})}),h.push({label:`Merge ${n} into ${l}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Merge ",(0,s.jsx)("span",{className:"font-bold",children:n})," into ",l]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>a.onMerge({sourceBranch:n,targetBranch:t})}),h.push({label:`Merge ${l} into ${n}`,labelNode:(0,s.jsxs)(s.Fragment,{children:["Merge ",l," into ",(0,s.jsx)("span",{className:"font-bold",children:n})]}),icon:(0,s.jsx)("i",{className:"iconoir-git-fork text-[14px]","aria-hidden":"true"}),onClick:()=>a.onMerge({sourceBranch:t,targetBranch:n})})),o||(d?h.push({label:`Delete Selected Branches (${c.length})`,icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>a.onDeleteBranches(c),danger:!0}):h.push({label:"Delete Branch",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>a.onDeleteBranch(t),danger:!0})),h}(e,{onCheckout:nS,onCheckoutToLocal:ng,onCreateBranch:nO,onDeleteBranch:l4,onDeleteBranches:l2,onRenameBranch:ne,onRenameRemoteBranch:na,onRebase:nr,onMerge:no,onPushToRemote:nh,onPullFromRemote:np});return lb.length>0&&a.push({label:"Custom scripts",icon:(0,s.jsx)("i",{className:"iconoir-terminal text-[14px]","aria-hidden":"true"}),children:lb.map(a=>({label:a.name,icon:(0,s.jsx)("i",{className:"iconoir-play text-[14px]","aria-hidden":"true"}),onClick:()=>{lZ(a,e.branchRef)}}))}),a},n1=(0,r.useMemo)(()=>new Set(E?.branches??[]),[E?.branches]),n2=(0,r.useMemo)(()=>{let e=new Map;if(!E?.remotes)return e;for(let[a,t]of Object.entries(E.remotes))for(let s of t)e.set(`${a}/${s}`,`remotes/${a}/${s}`);return e},[E?.remotes]),n4=(0,r.useMemo)(()=>ld?M(ld).filter(e=>e!==l_):[],[ld,l_]),n3=E?.worktrees??[],n5=(0,s.jsxs)("div",{className:"w-[22rem] max-w-[calc(100vw-2rem)] flex flex-col border border-base-300 bg-base-100 rounded-box shadow-xl overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-4 border-b border-base-300 flex items-center justify-between bg-base-100 h-[57px] shrink-0",children:[(0,s.jsx)("h2",{className:"font-bold text-lg",children:"Branches"}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[lV&&(0,s.jsx)("div",{className:"tooltip tooltip-left z-20","data-tip":"Clear filters",children:(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:lD,children:(0,s.jsx)("i",{className:"iconoir-filter text-[16px]","aria-hidden":"true"})})}),(0,s.jsx)("div",{className:"tooltip tooltip-left z-20","data-tip":"Create Branch",children:(0,s.jsx)("button",{className:"btn btn-ghost btn-xs btn-square",onClick:()=>nO(),children:(0,s.jsx)("i",{className:"iconoir-plus-circle text-[16px]","aria-hidden":"true"})})})]})]}),(0,s.jsx)("div",{className:"max-h-[70vh] overflow-auto",children:(0,s.jsxs)("div",{className:"p-2 space-y-0.5",children:[ld&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c,{items:[{label:"Delete",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>l2(n4),danger:!0,disabled:0===n4.length}],children:(0,s.jsx)(D,{name:"Branches",groupPath:"__local__",icon:(0,s.jsx)("i",{className:"iconoir-git-branch text-[14px]","aria-hidden":"true"}),isExpanded:lf,onToggle:lB,visibilityMap:lk,onToggleVisibility:lA})}),lf&&(0,s.jsx)(L,{node:ld,currentBranch:E?.current,expandedFolders:lC,onToggleFolder:lM,onCheckout:nS,onCheckoutToLocal:ng,onCreateBranch:()=>nO(),onDeleteBranch:l4,onRenameBranch:ne,onRenameRemoteBranch:na,onRebase:nr,onMerge:no,onPushToRemote:nh,onPullFromRemote:np,getBranchContextMenuItems:n0,onBranchClick:lQ,onBranchContextMenu:lX,onDeleteBranchGroup:l2,selectedBranches:lu,visibilityMap:lk,onToggleVisibility:lA,depth:1,groupPath:"__local__",trackingInfo:E?.trackingInfo})]}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c,{items:[{label:"Fetch from all remotes",icon:(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"}),onClick:ny},{label:"Add remote",icon:(0,s.jsx)("i",{className:"iconoir-plus-circle text-[14px]","aria-hidden":"true"}),onClick:()=>{aN("origin"),av(""),ag(!0)}}],children:(0,s.jsx)(D,{name:"Remotes",groupPath:"__remotes__",icon:(0,s.jsx)("i",{className:"iconoir-globe text-[14px]","aria-hidden":"true"}),isExpanded:lj,onToggle:lP,visibilityMap:lk,onToggleVisibility:lA})}),lj&&P&&!lh&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2 py-2 text-sm opacity-70",style:{paddingLeft:"20px"},children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsx)("span",{children:"Loading remotes..."})]}),lj&&lh&&Array.from(lh.entries()).map(([e,a])=>{let t=`__remotes__/${e}`,l=lC.has(t);return(0,s.jsxs)("div",{children:[(0,s.jsx)(c,{items:[{label:`Fetch from ${e}`,icon:(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[14px]","aria-hidden":"true"}),onClick:()=>nC(e)},{label:"Rename",icon:(0,s.jsx)("i",{className:"iconoir-edit-pencil text-[14px]","aria-hidden":"true"}),onClick:()=>{ar(e),ao(e),al(!0)}},{label:"Delete",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>{e&&(ax(e),am(!0))},danger:!0}],children:(0,s.jsx)(D,{name:e,groupPath:t,icon:(0,s.jsx)("i",{className:"iconoir-globe text-[14px] opacity-50","aria-hidden":"true"}),isExpanded:l,onToggle:()=>lM(t),visibilityMap:lk,onToggleVisibility:lA,depth:1})}),l&&(0,s.jsx)(L,{node:a,currentBranch:E?.current,expandedFolders:lC,onToggleFolder:lM,onCheckout:nS,onCheckoutToLocal:ng,onCreateBranch:()=>nO(),onDeleteBranch:l4,onRenameBranch:ne,onRenameRemoteBranch:na,onRebase:nr,onMerge:no,onPushToRemote:nh,onPullFromRemote:np,getBranchContextMenuItems:n0,onBranchClick:lQ,onBranchContextMenu:lX,onDeleteBranchGroup:l2,selectedBranches:lu,visibilityMap:lk,onToggleVisibility:lA,depth:2,groupPath:t,isRemote:!0,trackingInfo:E?.trackingInfo})]},e)})]}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"group flex items-center gap-1 px-2 py-1.5 text-sm rounded-md cursor-pointer hover:bg-base-200 transition-colors font-medium",onClick:lF,children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-xs opacity-70",children:ly?"▼":"▶"}),(0,s.jsx)("i",{className:"iconoir-folder text-[14px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:"Worktrees"})]}),(0,s.jsx)("span",{className:"text-xs opacity-60",children:n3.length})]}),ly&&P&&0===n3.length&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2 py-2 text-sm opacity-70",style:{paddingLeft:"20px"},children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsx)("span",{children:"Loading worktrees..."})]}),ly&&!P&&0===n3.length&&(0,s.jsx)("div",{className:"px-2 py-2 text-sm opacity-70",style:{paddingLeft:"20px"},children:"No worktrees found"}),ly&&n3.map(e=>{let a=(0,s.jsxs)("button",{type:"button",className:(0,o.cn)("group flex w-full items-center gap-2 px-2 py-1.5 text-sm rounded-md transition-colors text-left",e.isCurrent?"cursor-default opacity-85":"cursor-pointer hover:bg-base-200"),style:{paddingLeft:"20px"},onClick:()=>nw(e.path,e.isCurrent),title:e.path,disabled:e.isCurrent,children:[(0,s.jsx)("i",{className:`iconoir-folder text-[14px] shrink-0 ${e.isCurrent?"text-primary":"opacity-60"}`,"aria-hidden":"true"}),(0,s.jsx)("span",{className:"truncate min-w-0 flex-1",children:e.path}),e.branch&&(0,s.jsx)("span",{className:"shrink-0 text-xs opacity-60",children:e.branch}),e.isCurrent&&(0,s.jsx)("span",{className:"shrink-0 text-xs text-primary font-medium",children:"current"})]});return e.isCurrent?(0,s.jsx)("div",{children:a},e.path):(0,s.jsx)(c,{items:[{label:"Delete worktree",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>l3(e.path),danger:!0}],children:a},e.path)})]})]})})]});return v&&100===g?(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner text-base-content/50"})}):k?(0,s.jsxs)("div",{className:"flex items-center justify-center p-8 h-full flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-error font-medium",children:"Error Loading History"}),(0,s.jsx)("p",{className:"text-sm opacity-70",children:w?.message||"An unknown error occurred"}),(0,s.jsxs)("button",{onClick:()=>void C(),className:"btn btn-outline btn-sm",children:[(0,s.jsx)("i",{className:"iconoir-refresh-circle text-[16px] mr-1","aria-hidden":"true"}),"Try Again"]})]}):y?(0,s.jsxs)("div",{className:"flex h-full overflow-hidden",children:[sc&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Reset to Commit"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to hard reset branch ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"Detached HEAD"})," to commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:sh?.substring(0,7)}),"?",(0,s.jsx)("br",{}),(0,s.jsx)("span",{className:"text-error font-bold",children:"Warning: This will discard all local changes and commits after this point. This action cannot be undone."})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>sd(!1),disabled:su,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:n$,disabled:su,children:[su&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Reset"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>sd(!1),children:"close"})})]}),sp&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Revert Commit"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to revert commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:sf?.hash.substring(0,7)})," on ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"current"}),"?"]}),sf?.message&&(0,s.jsx)("div",{className:"rounded border border-base-300 bg-base-200/40 px-3 py-2 text-xs break-words",children:sf.message}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{sb(!1),sg(null)},disabled:sj,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nB,disabled:sj,children:[sj&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Revert"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{sb(!1),sg(null)},children:"close"})})]}),sy&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Reword Commit"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Reword commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:sk?.hash.substring(0,7)})," on branch ",(0,s.jsx)("span",{className:"font-bold",children:sk?.branch}),"."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full font-mono text-sm mb-3",value:sC,onChange:e=>sS(e.target.value),autoFocus:!0,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&sC.trim()&&!s$&&(e.preventDefault(),nP())},placeholder:"Commit subject",disabled:s$}),(0,s.jsx)("textarea",{className:"textarea textarea-bordered w-full h-32 font-mono text-sm",value:sE,onChange:e=>sR(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&sC.trim()&&!s$&&(e.preventDefault(),nP())},placeholder:"Commit message body (optional)",disabled:s$}),sk?.branch!==E?.current&&(0,s.jsx)("div",{className:"alert alert-warning text-xs mt-2 py-2",children:(0,s.jsxs)("span",{children:["This will briefly checkout ",(0,s.jsx)("b",{children:sk?.branch})," to amend the commit."]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:s1,disabled:s$,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nP,disabled:!sC.trim()||s$,children:[s$&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Reword"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:s1,children:"close"})})]}),ek&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:eC.length>1?"Delete Branches":"Delete Branch"}),eC.length>1?(0,s.jsxs)("div",{className:"py-4 space-y-3",children:[(0,s.jsxs)("p",{className:"break-words",children:["Are you sure you want to delete ",(0,s.jsxs)("span",{className:"font-bold",children:[eC.length," selected branches"]}),"? This action cannot be undone."]}),(0,s.jsx)("div",{className:"max-h-44 overflow-auto rounded border border-base-300 bg-base-200/40 p-2 space-y-1",children:eC.map(e=>(0,s.jsx)("div",{className:"text-xs min-w-0 break-all",children:e.startsWith("remotes/")?e.slice(8):e},e))})]}):(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete the branch ",(0,s.jsx)("span",{className:"font-bold break-all",children:eC[0]?.startsWith("remotes/")?eC[0].slice(8):eC[0]}),"? This action cannot be undone."]}),nz.length>0&&(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start items-start gap-2 min-w-0",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:eE,onChange:e=>eR(e.target.checked),disabled:e$}),(0,s.jsx)("span",{className:"label-text break-words whitespace-normal",children:1===nz.length?(0,s.jsxs)(s.Fragment,{children:["Delete tracking remote branch ",(0,s.jsx)("span",{className:"font-mono opacity-70 break-all",children:nz[0]})]}):(0,s.jsxs)(s.Fragment,{children:["Delete ",nz.length," tracking remote branches"]})})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{ew(!1),eS([]),eR(!1)},disabled:e$,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:l6,disabled:e$,children:[e$&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{ew(!1),eS([]),eR(!1)},children:"close"})})]}),eP&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Delete Worktree"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete the worktree ",(0,s.jsx)("span",{className:"font-bold break-all",children:eM}),"?"]}),(0,s.jsx)("p",{className:"text-sm text-error break-words",children:"This will remove the worktree from git and remove its working directory."}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{eF(!1),eA(null)},disabled:eD,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:()=>void l9(),disabled:eD||!eM,children:[eD&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{eF(!1),eA(null)},children:"close"})})]}),eT&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Delete Tag"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete the tag ",(0,s.jsx)("span",{className:"font-bold break-all",children:eO}),"? This action cannot be undone."]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start items-start gap-2 min-w-0",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:eI,onChange:e=>eK(e.target.checked),disabled:ez||!nK}),(0,s.jsx)("span",{className:"label-text break-words whitespace-normal",children:nK?(0,s.jsxs)(s.Fragment,{children:["Also delete from remote ",(0,s.jsx)("span",{className:"font-mono opacity-70",children:nK})]}):"No remote configured"})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:l5,disabled:ez,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:l8,disabled:ez||!eO,children:[ez&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:l5,children:"close"})})]}),eW&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Cherry Pick"}),(0,s.jsx)("p",{className:"text-sm opacity-70 mt-1",children:eU.length>1?"Apply selected commits from oldest to newest":"Apply changes from the selected commit"}),1===eU.length?(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure to apply ",(0,s.jsx)("span",{className:"font-bold font-mono break-all",children:eU[0]?.hash})," ",(0,s.jsx)("span",{className:"font-bold break-words",children:eU[0]?.message})," to ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"current"})," branch?"]}):(0,s.jsxs)("div",{className:"py-4 space-y-3",children:[(0,s.jsxs)("p",{className:"break-words",children:["Are you sure to apply ",(0,s.jsxs)("span",{className:"font-bold",children:[eU.length," selected commits"]})," to ",(0,s.jsx)("span",{className:"font-bold break-all",children:E?.current||"current"})," branch?"]}),(0,s.jsx)("div",{className:"max-h-44 overflow-auto rounded border border-base-300 bg-base-200/40 p-2 space-y-1",children:eU.map(e=>(0,s.jsxs)("div",{className:"text-xs min-w-0",children:[(0,s.jsx)("span",{className:"font-mono opacity-70",children:e.hash.slice(0,7)})," ",(0,s.jsx)("span",{className:"break-words",children:e.message})]},e.hash))})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{eG(!1),eV([])},disabled:eY,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nL,disabled:eY,children:[eY&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{eG(!1),eV([])},children:"close"})})]}),eQ&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Cherry Pick In Progress"}),(0,s.jsx)("p",{className:"text-sm opacity-70 mt-1",children:"Another cherry-pick operation is currently in progress."}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Abort the in-progress cherry-pick and continue with ",eU.length>1?"the selected commits":"this commit","?"]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{eX(!1),eV([])},disabled:eZ,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-warning",onClick:()=>void nT(),disabled:eZ,children:[eZ&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Abort and Continue"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{eX(!1),eV([])},children:"close"})})]}),e1&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:e5?"Rename Remote Branch":"Rename Branch"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Enter a new name for the branch ",(0,s.jsx)("span",{className:"font-bold break-all",children:e4}),". Press ",(0,s.jsx)("kbd",{className:"kbd kbd-sm",children:"Enter"})," to confirm."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:e6,onChange:e=>e8((0,o.L9)(e.target.value)),placeholder:"New branch name",disabled:aa,autoFocus:!0,onKeyDown:e=>{let a="Enter"===e.key&&(e.metaKey||e.ctrlKey),t=e5?e6===e5.branch:e6===e4;a&&e6&&!t&&!aa&&nt()}}),!e5&&nq?.upstream&&(0,s.jsx)("div",{className:"form-control mt-2",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start items-start gap-2 min-w-0",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:e9,onChange:e=>ae(e.target.checked),disabled:aa}),(0,s.jsxs)("span",{className:"label-text break-words whitespace-normal",children:["Also rename tracking remote branch ",(0,s.jsx)("span",{className:"font-mono opacity-70 break-all",children:nq.upstream})]})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:sQ,disabled:aa,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nt,disabled:!e6||(e5?e6===e5.branch:e6===e4)||aa,children:[aa&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Rename"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:sQ,children:"close"})})]}),as&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Rename Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Enter a new name for remote ",(0,s.jsx)("span",{className:"font-bold break-all",children:an}),". Press ",(0,s.jsx)("kbd",{className:"kbd kbd-sm",children:"Enter"})," to confirm."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:ai,onChange:e=>ao(e.target.value),placeholder:"New remote name",disabled:ac,autoFocus:!0,onKeyDown:e=>{let a="Enter"===e.key&&(e.metaKey||e.ctrlKey),t=ai.trim(),s=t===(an??"").trim();a&&t&&!s&&!ac&&ns()}}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:sX,disabled:ac,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:ns,disabled:!ai.trim()||ai.trim()===(an??"").trim()||ac,children:[ac&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Rename"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:sX,children:"close"})})]}),ah&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Delete Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Are you sure you want to delete remote ",(0,s.jsx)("span",{className:"font-bold break-all",children:au}),"? This removes all tracking branches for that remote."]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:sZ,disabled:ap,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-error",onClick:nl,disabled:!au||ap,children:[ap&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Delete"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:sZ,children:"close"})})]}),af&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Add Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Add a new remote by providing a name and URL. Press ",(0,s.jsx)("kbd",{className:"kbd kbd-sm",children:"Enter"})," to confirm."]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label pt-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote name"})}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:aj,onChange:e=>aN(e.target.value),placeholder:"origin",disabled:ak,autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label pt-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote URL"})}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:ay,onChange:e=>av(e.target.value),placeholder:"https://github.com/owner/repo.git",disabled:ak,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&aj.trim()&&ay.trim()&&!ak&&nn()}})]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:s0,disabled:ak,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nn,disabled:!aj.trim()||!ay.trim()||ak,children:[ak&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Add"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:s0,children:"close"})})]}),aC&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Rebase"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Copy commits from one branch to another.",(0,s.jsx)("br",{}),"Are you sure to rebase ",(0,s.jsx)("span",{className:"font-bold break-all",children:aE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:a$}),"?"]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:aP,onChange:e=>aF(e.target.checked),disabled:aM}),(0,s.jsx)("span",{className:"label-text",children:"Stash and reapply local changes"})]})}),!aP&&(0,s.jsx)("p",{className:"text-xs text-warning mt-2 ml-6",children:"Warning: All local changes will be discarded."}),"checking"===aD?(0,s.jsxs)("div",{className:"alert alert-info text-sm mt-4 py-2",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsxs)("span",{children:["Checking conflicts for rebasing ",(0,s.jsx)("span",{className:"font-bold break-all",children:aE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:a$}),"..."]})]}):"no-conflict"===aD?(0,s.jsxs)("div",{className:"alert alert-success text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-check-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["No conflict: rebasing ",(0,s.jsx)("span",{className:"font-bold break-all",children:aE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:a$})," will not cause conflicts."]})]}):(0,s.jsxs)("div",{className:"alert alert-warning text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-warning-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["Conflicts detected: rebasing ",(0,s.jsx)("span",{className:"font-bold break-all",children:aE})," onto ",(0,s.jsx)("span",{className:"font-bold break-all",children:a$})," will cause conflicts."]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:aT,disabled:aM,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:ni,disabled:aM,children:[aM&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:aT,children:"close"})})]}),a_&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Merge"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Merge branch into another one.",(0,s.jsx)("br",{}),"Are you sure to merge ",(0,s.jsx)("span",{className:"font-bold break-all",children:aK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:aH}),"?"]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:aq,onChange:e=>aW(e.target.checked),disabled:aX}),(0,s.jsx)("span",{className:"label-text",children:"Rebase before merge"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:aG,onChange:e=>nc(e.target.checked),disabled:aX}),(0,s.jsx)("span",{className:"label-text",children:"Squash before merge"})]})}),aG&&(0,s.jsx)("textarea",{className:"textarea textarea-bordered w-full mt-2",placeholder:"Commit message for squash merge",value:aJ,onChange:e=>aQ(e.target.value),disabled:aX,autoFocus:!0}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:aV,onChange:e=>aY(e.target.checked),disabled:aX}),(0,s.jsx)("span",{className:"label-text",children:"Fast forward merge"})]})}),"checking"===a0?(0,s.jsxs)("div",{className:"alert alert-info text-sm mt-4 py-2",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),(0,s.jsxs)("span",{children:["Checking conflicts for merging ",(0,s.jsx)("span",{className:"font-bold break-all",children:aK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:aH}),"..."]})]}):"no-conflict"===a0?(0,s.jsxs)("div",{className:"alert alert-success text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-check-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["No conflict: merging ",(0,s.jsx)("span",{className:"font-bold break-all",children:aK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:aH})," will not cause conflicts."]})]}):(0,s.jsxs)("div",{className:"alert alert-warning text-sm mt-4 py-2",children:[(0,s.jsx)("i",{className:"iconoir-warning-circle-solid text-[18px]","aria-hidden":"true"}),(0,s.jsxs)("span",{children:["Conflicts detected: merging ",(0,s.jsx)("span",{className:"font-bold break-all",children:aK})," into ",(0,s.jsx)("span",{className:"font-bold break-all",children:aH})," will cause conflicts."]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:a2,disabled:aX,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nd,disabled:aX,children:[aX&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:a2,children:"close"})})]}),a4&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Push to Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Push ",(0,s.jsx)("span",{className:"font-bold break-all",children:a5})," to a remote repository."]}),tj&&0===a6.length?(0,s.jsxs)("div",{className:"alert alert-error",children:[(0,s.jsx)("span",{className:"text-xl",children:"⚠️"}),(0,s.jsx)("span",{children:tj})]}):ty?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)("span",{className:"loading loading-spinner loading-lg"})}):(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Repository"})}),(0,s.jsx)("select",{className:"select select-bordered w-64",value:a9,onChange:e=>nm(e.target.value),disabled:tf,children:a6.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Branch"})}),(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1 w-64",children:[tk?(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-base-200 opacity-70 w-full",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Loading branches..."]}):(0,s.jsxs)("select",{className:"select select-bordered w-full",value:ts,onChange:e=>tl(e.target.value),disabled:tf,children:[a5&&!ta.includes(a5)&&(0,s.jsxs)("option",{value:a5,children:[a5," (new)"]}),ta.map(e=>(0,s.jsxs)("option",{value:e,children:[e,tn?.remote===a9&&tn?.branch===e?" (tracking)":""]},e))]}),ts&&!ta.includes(ts)&&(0,s.jsx)("div",{className:"label",children:(0,s.jsx)("span",{className:"label-text-alt text-warning",children:"New branch will be created"})})]})]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:ti,onChange:e=>to(e.target.checked),disabled:tf||tc}),(0,s.jsx)("span",{className:"label-text",children:"Rebase onto remote branch before pushing"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm checkbox-error",checked:tc,onChange:e=>td(e.target.checked),disabled:tf}),(0,s.jsx)("span",{className:"label-text text-error",children:"Force push"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:th,onChange:e=>tm(e.target.checked),disabled:tf}),(0,s.jsx)("span",{className:"label-text",children:"Push all tags"})]})}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:tu,onChange:e=>nu(e.target.checked),disabled:tf}),(0,s.jsx)("span",{className:"label-text",children:"Squash local commits before push"})]})}),tu&&(0,s.jsx)("textarea",{className:"textarea textarea-bordered w-full",placeholder:"Commit message for squash",value:tp,onChange:e=>tb(e.target.value),disabled:tf,autoFocus:!0}),tj&&(0,s.jsx)("div",{className:"alert alert-error text-sm",children:(0,s.jsx)("span",{children:tj})})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>a3(!1),disabled:tf,children:"Cancel"}),a6.length>0&&(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nx,disabled:tf||!a9||!ts,children:[tf&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Push"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>a3(!1),children:"close"})})]}),tC&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Pull from Remote"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Pull changes from a remote branch into ",(0,s.jsx)("span",{className:"font-bold break-all",children:tE}),"."]}),tW&&0===t$.length?(0,s.jsx)("div",{className:"alert alert-error",children:(0,s.jsx)("span",{children:tW})}):tU?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)("span",{className:"loading loading-spinner loading-lg"})}):(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Repository"})}),(0,s.jsx)("select",{className:"select select-bordered w-64",value:tP,onChange:e=>nb(e.target.value),disabled:tI,children:t$.map(e=>(0,s.jsx)("option",{value:e,children:e},e))})]}),(0,s.jsxs)("div",{className:"form-control w-full flex flex-row items-center justify-between gap-4",children:[(0,s.jsx)("label",{className:"label flex-shrink-0",children:(0,s.jsx)("span",{className:"label-text",children:"Remote Branch"})}),tY?(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-base-200 opacity-70 w-64",children:[(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Loading branches..."]}):(0,s.jsx)("select",{className:"select select-bordered w-64",value:tD,onChange:e=>tL(e.target.value),disabled:tI,children:tM.map(e=>(0,s.jsxs)("option",{value:e,children:[e,tT?.remote===tP&&tT?.branch===e?" (tracking)":""]},e))})]}),(0,s.jsx)("div",{className:"form-control",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:tO,onChange:e=>tH(e.target.checked),disabled:tI}),(0,s.jsx)("span",{className:"label-text",children:"Rebase onto remote branch"})]})}),tW&&(0,s.jsx)("div",{className:"alert alert-error text-sm",children:(0,s.jsx)("span",{children:tW})})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>tS(!1),disabled:tI,children:"Cancel"}),t$.length>0&&(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nf,disabled:tI||!tP||!tD,children:[tI&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Pull"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>tS(!1),children:"close"})})]}),eu&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Create Tag"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Create a new tag at commit ",(0,s.jsx)("span",{className:"font-mono bg-base-200 px-1 rounded",children:ep?.substring(0,7)}),"."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full font-mono",value:ef,onChange:e=>eg(e.target.value),placeholder:"Tag name",disabled:ey,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&ef.trim()&&!ey&&(e.preventDefault(),nH())}}),(0,s.jsx)("div",{className:"form-control mt-3",children:(0,s.jsxs)("label",{className:"label cursor-pointer justify-start gap-2",children:[(0,s.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:ej,onChange:e=>eN(e.target.checked),disabled:ey}),(0,s.jsx)("span",{className:"label-text",children:"Push tag to remote after creation"})]})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{ex(!1),eb(null),eg(""),eN(!1)},disabled:ey,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nH,disabled:!ef.trim()||ey,children:[ey&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Create"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{ex(!1),eb(null),eg(""),eN(!1)},children:"close"})})]}),en&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Create New Branch"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Create a new branch from"," ",(0,s.jsx)("span",{className:"font-bold break-all",children:ec?ec.replace(/^remotes\//,""):"current HEAD"}),"."]}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:ei,onChange:e=>eo((0,o.L9)(e.target.value)),placeholder:"Branch name",disabled:eh,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&ei&&!eh&&(e.preventDefault(),n_())}}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>{er(!1),ed(null)},disabled:eh,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:n_,disabled:!ei||eh,children:[eh&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Create & Checkout"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>{er(!1),ed(null)},children:"close"})})]}),t4&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Checkout to Local Branch"}),(0,s.jsxs)("p",{className:"py-4 break-words",children:["Create a local branch from ",(0,s.jsx)("span",{className:"font-bold break-all",children:t5?.replace(/^remotes\//,"")})," and set up tracking."]}),(0,s.jsxs)("div",{className:"form-control w-full",children:[(0,s.jsx)("label",{className:"label",children:(0,s.jsx)("span",{className:"label-text",children:"Local Branch Name"})}),(0,s.jsx)("input",{type:"text",className:"input input-bordered w-full",value:t6,onChange:e=>t8((0,o.L9)(e.target.value)),placeholder:"Local branch name",disabled:t9,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&t6&&!t9&&(e.preventDefault(),nN())}})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{className:"btn",onClick:()=>t3(!1),disabled:t9,children:"Cancel"}),(0,s.jsxs)("button",{className:"btn btn-primary",onClick:nN,disabled:!t6||t9,children:[t9&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"})," Checkout"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:()=>t3(!1),children:"close"})})]}),sa&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-full bg-warning/15 text-warning flex items-center justify-center shrink-0",children:(0,s.jsx)("i",{className:"iconoir-warning-triangle text-[20px]","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h3",{className:"font-bold text-lg",children:"Uncommitted Changes"}),(0,s.jsxs)("p",{className:"text-sm opacity-80 mt-1",children:["You have uncommitted changes in your workspace. Choose how to handle your changes before switching to branch"," ",(0,s.jsx)("span",{className:"font-bold font-mono text-primary break-all",children:nj}),":"]})]})]}),(0,s.jsxs)("div",{className:"space-y-2.5 my-5",children:[(0,s.jsxs)("label",{className:(0,o.cn)("flex items-start gap-3 p-3.5 rounded-lg border cursor-pointer transition-colors select-none","stash-and-reapply"===sn?"border-primary bg-primary/5 shadow-xs":"border-base-300 hover:bg-base-200/50"),onClick:()=>sr("stash-and-reapply"),children:[(0,s.jsx)("input",{type:"radio",name:"switchBranchStrategy",className:"radio radio-primary radio-sm mt-0.5",checked:"stash-and-reapply"===sn,onChange:()=>sr("stash-and-reapply"),disabled:si}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"font-semibold text-sm flex items-center gap-2",children:[(0,s.jsx)("span",{children:"Stash and reapply"}),(0,s.jsx)("span",{className:"badge badge-xs badge-primary/20 text-primary font-normal",children:"Default"})]}),(0,s.jsxs)("p",{className:"text-xs opacity-70 mt-0.5 leading-relaxed",children:["Stash current changes, switch to ",(0,s.jsx)("span",{className:"font-mono font-medium",children:nj}),", and reapply your changes."]})]})]}),(0,s.jsxs)("label",{className:(0,o.cn)("flex items-start gap-3 p-3.5 rounded-lg border cursor-pointer transition-colors select-none","discard"===sn?"border-error bg-error/5 shadow-xs":"border-base-300 hover:bg-base-200/50"),onClick:()=>sr("discard"),children:[(0,s.jsx)("input",{type:"radio",name:"switchBranchStrategy",className:"radio radio-error radio-sm mt-0.5",checked:"discard"===sn,onChange:()=>sr("discard"),disabled:si}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"font-semibold text-sm text-error flex items-center gap-1.5",children:[(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),(0,s.jsx)("span",{children:"Discard changes"})]}),(0,s.jsxs)("p",{className:"text-xs opacity-70 mt-0.5 leading-relaxed",children:["Permanently discard all uncommitted changes before switching. ",(0,s.jsx)("span",{className:"text-error font-medium",children:"This cannot be undone."})]})]})]})]}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsx)("button",{type:"button",className:"btn",onClick:()=>{st(!1),sl(null)},disabled:si,children:"Cancel"}),(0,s.jsxs)("button",{type:"button",className:(0,o.cn)("btn","discard"===sn?"btn-error":"btn-primary"),onClick:nE,disabled:si,children:[si&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Confirm"]})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{type:"button",onClick:()=>{si||(st(!1),sl(null))},children:"close"})})]}),sI.isOpen&&(0,s.jsxs)("dialog",{className:"modal modal-open",children:[(0,s.jsxs)("div",{className:"modal-box max-w-4xl",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("h3",{className:"font-bold text-lg truncate",children:["Custom Script: ",sI.scriptName]}),(0,s.jsxs)("p",{className:"text-xs opacity-70 mt-1 break-all",children:["Branch: ",sI.branchRef]})]}),(0,s.jsx)("span",{className:(0,o.cn)("badge badge-sm shrink-0","running"===sI.status||"starting"===sI.status?"badge-info":"completed"===sI.status?"badge-success":"failed"===sI.status?"badge-error":"canceled"===sI.status?"badge-warning":"badge-ghost"),children:sI.status})]}),(0,s.jsx)("div",{className:"mt-4 border border-base-300 rounded bg-base-200/40",children:(0,s.jsx)("pre",{className:"p-3 font-mono text-xs overflow-auto max-h-[50vh] whitespace-pre-wrap break-words",children:sI.output||"Waiting for output..."})}),sI.error&&(0,s.jsx)("div",{className:"alert alert-error py-2 mt-3",children:(0,s.jsx)("span",{children:sI.error})}),(0,s.jsxs)("div",{className:"modal-action",children:[(0,s.jsxs)("button",{className:"btn btn-warning",onClick:()=>void l0(),disabled:!sY||sz,children:[sz&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Cancel"]}),(0,s.jsxs)("button",{className:"btn btn-outline",onClick:()=>void l1(),disabled:sW,children:[sW&&(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}),sU?"Copied":"Copy"]}),(0,s.jsx)("button",{className:"btn btn-primary",onClick:()=>{sK(K),sV(!1),sq(!1)},disabled:!sJ,children:"Done"})]})]}),(0,s.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,s.jsx)("button",{onClick:e=>{sJ?(sK(K),sV(!1),sq(!1)):e.preventDefault()},children:"close"})})]}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 bg-base-100",children:[(0,s.jsxs)("div",{className:"h-[57px] flex items-center justify-between gap-3 px-6 border-b border-base-300 shrink-0 history-header",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("h1",{className:"font-bold text-lg",children:"History"}),(0,s.jsxs)("div",{className:"relative",ref:sH,children:[(0,s.jsxs)("button",{className:"btn btn-sm gap-2 max-w-[24rem] header-icon-btn",onClick:()=>sO(e=>!e),title:nU,"aria-label":nU,children:[(0,s.jsx)("span",{className:"truncate branch-selector-label",children:nU}),(0,s.jsx)("i",{className:(0,o.cn)("iconoir-nav-arrow-down text-[16px] shrink-0 transition-transform",s_&&"rotate-180"),"aria-hidden":"true"})]}),s_&&(0,s.jsx)("div",{className:"absolute left-0 top-full mt-2 z-50",children:n5})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,s.jsxs)("button",{className:"btn btn-sm gap-2 header-icon-btn",onClick:()=>void ny(),disabled:tQ||tz||tC||a4,title:"Fetch latest changes from all remotes","aria-label":"Fetch",children:[tQ?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-refresh text-[16px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"header-btn-label",children:"Fetch"})]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2 header-icon-btn",onClick:()=>{l_&&!nJ&&np(l_)},disabled:!!nJ||tz||tC||a4,title:nJ||`Pull from ${nV?.upstream}`,"aria-label":"Pull",children:[tU?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-arrow-down text-[16px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"header-btn-label",children:"Pull"})]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2 header-icon-btn",onClick:()=>void nZ(),disabled:!!nQ||tC||a4||tz,title:nQ||"Pull all local branches from tracking remote branches","aria-label":"Pull All",children:[tz?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-fast-arrow-down text-[16px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"header-btn-label",children:"Pull All"})]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2 header-icon-btn",onClick:()=>{l_&&!nX&&nh(l_)},disabled:!!nX||tz||tC||a4,title:nX||(nV?`Push to ${nV.upstream}`:"Push current branch to remote"),"aria-label":"Push",children:[ty?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-arrow-up text-[16px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"header-btn-label",children:"Push"})]})]})]}),(0,s.jsxs)("div",{className:"shrink-0 flex items-center gap-2",children:[(0,s.jsxs)("button",{className:"btn btn-sm gap-2 header-icon-btn",onClick:()=>void nk(),disabled:t1,title:"Open terminal in repository folder","aria-label":"Open Terminal",children:[t1?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-terminal text-[16px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"header-btn-label",children:"Open Terminal"})]}),(0,s.jsxs)("button",{className:"btn btn-sm gap-2 header-icon-btn",onClick:()=>void nv(),disabled:tZ,title:"Open repository folder in Finder","aria-label":"Open Repo Folder",children:[tZ?(0,s.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,s.jsx)("i",{className:"iconoir-folder text-[16px]","aria-hidden":"true"}),(0,s.jsx)("span",{className:"header-btn-label",children:"Open Repo Folder"})]})]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden relative",children:lV&&P?(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)("span",{className:"loading loading-spinner loading-lg opacity-50"})}):(0,s.jsx)(h,{ref:sP,commits:lH,selectedHash:U||void 0,selectedHashes:lI,onSelectCommit:lG,onResetToCommit:nR,onRevertCommit:(e,a)=>{sg({hash:e,message:a}),sb(!0)},onCreateTag:e=>{eb(e),eg(""),eN(!1),ex(!0)},onCherryPickCommit:(e,a)=>{eV([{hash:e,message:a}]),eG(!0)},onCherryPickSelectedCommits:()=>{lU.length<2||(eV(lU.map(e=>({hash:e.hash,message:e.message}))),eG(!0))},onRewordCommit:(e,a,t,s)=>{sw({hash:e,subject:a,body:t,branch:s}),sS(a),sR(t),sv(!0)},localBranches:E?.branches||[],trackingInfo:E?.trackingInfo,onEndReached:()=>{!S&&y.all.length>=g&&j(e=>e+50)},isLoadingMore:S&&g>100,currentBranch:E?.current,hiddenBranches:lY,getBranchTagContextMenuItems:e=>{if(e.startsWith("tag:")){let a=e.replace(/^tag:\s*/,"").trim();return a?[{label:"Delete Tag",icon:(0,s.jsx)("i",{className:"iconoir-trash text-[14px]","aria-hidden":"true"}),onClick:()=>l7(a),danger:!0}]:null}if(n1.has(e))return n0({branchRef:e,branchLeafName:e.split("/").pop()||e,currentBranch:l_,isRemote:!1});let a=n2.get(e);return a?n0({branchRef:a,branchLeafName:a.split("/").pop()||e,currentBranch:l_,isRemote:!0}):null}})}),U&&(0,s.jsxs)("div",{className:"flex flex-col overflow-hidden border-t border-base-300 bg-base-200/30",style:{height:s6},children:[(0,s.jsx)("div",{className:(0,o.cn)("h-1.5 cursor-ns-resize flex items-center justify-center hover:bg-base-200 transition-colors group shrink-0",s9&&"bg-base-200"),onMouseDown:lo,children:(0,s.jsx)("div",{className:"w-8 h-1 rounded-full bg-base-300 group-hover:bg-base-content/20 transition-colors"})}),"__LOCAL_CHANGES__"===U?(0,s.jsx)("div",{className:"flex-1 overflow-hidden min-h-0 flex flex-col",children:(0,s.jsx)(R,{repoPath:e,onClose:()=>ea(null)})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-row items-center py-2 px-4 border-b border-base-300 bg-base-100 shrink-0 justify-between gap-4",children:[(0,s.jsx)("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:lW&&lq?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"text-sm font-bold truncate",children:[lq.latestHash.substring(0,7),": ",lq.latestCommit.message]}),(0,s.jsxs)("div",{className:"text-sm font-bold truncate opacity-75",children:[lq.oldestHash.substring(0,7),": ",lq.oldestCommit.message]})]})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-sm font-bold truncate",children:lz?.message}),(0,s.jsx)("span",{className:"text-xs font-mono opacity-50 shrink-0",children:U.substring(0,7)})]})}),(0,s.jsx)("div",{className:"flex items-center gap-1 shrink-0",children:(0,s.jsx)("button",{className:"ml-2 btn btn-ghost btn-xs btn-square",onClick:()=>ea(null),title:"Close",children:"✕"})})]}),lW&&lq?(0,s.jsxs)("div",{className:"flex-1 overflow-hidden min-h-0 flex flex-col bg-base-100",children:[(0,s.jsx)("div",{className:"px-4 pt-2 pb-1 text-[10px] uppercase tracking-wider font-bold opacity-60 border-b border-base-300 bg-base-100 shrink-0",children:"Changes"}),(0,s.jsx)("div",{className:"flex-1 min-h-0",children:(0,s.jsx)(N,{repoPath:e,fromCommitHash:lq.oldestHash,toCommitHash:lq.latestHash})})]}):(0,s.jsxs)("div",{ref:lr,className:"flex-1 overflow-hidden bg-base-100 grid",style:{gridTemplateRows:`${lt}fr 6px ${1-lt}fr`},children:[(0,s.jsxs)("div",{className:"border-b border-base-300 bg-base-100 min-h-0 flex flex-col",children:[(0,s.jsx)("div",{className:"px-4 pt-3 pb-1 text-[10px] uppercase tracking-wider font-bold opacity-60",children:"Message"}),(0,s.jsx)("div",{className:"px-4 pb-3 overflow-auto flex-1 min-h-0",children:(0,s.jsx)("div",{className:"text-xs opacity-70 whitespace-pre-wrap font-mono",children:lz?(lz.body?.trim()?`${lz.message}
|
|
9
9
|
|
|
10
10
|
${lz.body}`:lz.message).replace(/\r\n/g,"\n").replace(/\\r\\n/g,"\n").replace(/\\n/g,"\n"):"No additional message"})})]}),(0,s.jsx)("div",{className:(0,o.cn)("cursor-ns-resize flex items-center justify-center hover:bg-base-200/60 transition-colors",ll&&"bg-base-200/60"),onMouseDown:lc,children:(0,s.jsx)("div",{className:"w-8 h-1 rounded-full bg-base-300"})}),(0,s.jsxs)("div",{className:"flex-1 overflow-hidden min-h-0 flex flex-col",children:[(0,s.jsx)("div",{className:"px-4 pt-2 pb-1 text-[10px] uppercase tracking-wider font-bold opacity-60 border-b border-base-300 bg-base-100 shrink-0",children:"Changes"}),(0,s.jsx)("div",{className:"flex-1 min-h-0",children:(0,s.jsx)(N,{repoPath:e,commitHash:U})})]})]})]})]})]})]}):(0,s.jsx)("div",{className:"flex items-center justify-center p-8 h-full opacity-70",children:"No history data available"})}}}]);
|