megareviewer 0.2.13 → 0.2.14

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.
@@ -76,11 +76,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
76
76
  `.repeat(e),kD=e=>`class _ {\nvoid _() {\n${`{
77
77
  `.repeat(e-2)}`,AD=/^(?:@\w|(?:public|protected|private|abstract|static|native|transient|volatile)\b)/,jD=/^(?:[}\])]|default\s*(?:->|:)|(?:if|else|for|while|do|switch|case|return|throw|try|catch|finally|yield|break|continue|var|this|super|assert|new)\b|[\w$.]+(?:\[[^\]]*\])?\s*(?:[-+*/%&|^]?=(?!=)|\+\+|--|\())/,MD=/^\*/,ND=(e,t)=>{if(t!==`java`)return``;let n=e.split(`
78
78
  `).filter(e=>e.trim()!==``),r=n[0];if(r===void 0)return``;let i=MD.test(r.trim()),a=n.find(e=>!/^(?:\*|\/\*|\/\/)/.test(e.trim())),o=i?`/*
79
- `:``;if(a===void 0)return o;let s=PD(a,n),c=a.trim();return(s===0?``:AD.test(c)||s===1&&!jD.test(c)?OD(s):kD(Math.max(s,2)))+o},PD=(e,t)=>{let n=/^[ \t]*/.exec(e)?.[0]??``,r=n.split(` `).length-1;if(r>0)return r+Math.floor((n.length-r)/4);let i=t.some(e=>(/^ */.exec(e)?.[0].length??0)%4==2&&!MD.test(e.trim()));return Math.floor(n.length/(i?2:4))},FD=new Set([`graphql`,`ini`,`json`,`jsonc`,`sql`,`toml`,`xml`,`yaml`]),ID=new Set([`css`,`scss`]),LD=new Set([`css`,`html`,`scss`,`svelte`,`vue`]),RD=new Set([`javascript`,`jsx`,`tsx`,`typescript`]),zD=/\.(md|mdx|rst|txt)$/i,BD=e=>TD({path:e,language:null}),VD=e=>{if(ul(e))return`test`;if(zD.test(e))return`docs`;let t=BD(e);return t===null?`other`:FD.has(t)?`data`:ID.has(t)?`style`:`code`},HD=e=>{let t=BD(e);return t===null||zD.test(e)?`plain`:t===`python`?`python`:RD.has(t)?`script`:FD.has(t)?`data`:LD.has(t)?`markup`:`plain`},UD={test:mg,code:ng,data:Ph,docs:cg,style:Xg,other:ug},WD={python:`text-syntax-function`,script:`text-syntax-number`,data:`text-syntax-string`,markup:`text-syntax-keyword`,plain:`text-muted-foreground`},GD={added:og,deleted:ig},KD=({path:e,status:t,className:n})=>{let r=t===void 0?null:lD[t],i=t===void 0?void 0:GD[t];if(r?.kind===`mark`&&i!==void 0)return(0,J.jsx)(i,{"aria-hidden":`true`,"data-status":t,className:X(`size-3.5 shrink-0`,r.tone,n)});let a=VD(e),o=UD[a];return(0,J.jsx)(o,{"aria-hidden":`true`,"data-role":a,className:X(`size-3.5 shrink-0`,WD[HD(e)],n)})},qD=({path:e,name:t})=>{let n=e.lastIndexOf(`/`)+1;return(0,J.jsxs)(J.Fragment,{children:[n>0&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e.slice(0,n)}),(0,J.jsx)(`span`,{"data-slot":`file-name`,className:X(`font-medium`,t),children:e.slice(n)})]})},JD=({file:e,status:t,className:n})=>{let r=t===void 0?null:lD[t],i=r?.kind===`mark`?r:null;return(0,J.jsxs)(`span`,{"data-slot":`file-path`,className:X(`min-w-0 break-all font-mono text-code`,n),children:[i!==null&&(0,J.jsx)(KD,{path:e.path,status:t,className:`mr-1 inline-block align-[-2px]`}),e.oldPath!==null&&e.oldPath!==e.path?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e.oldPath}),` `,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`renamed to`}),` `,(0,J.jsx)(qD,{path:e.path,name:i?.name})]}):(0,J.jsx)(qD,{path:e.path,name:i?.name}),i!==null&&(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, `,i.label]})]})},YD=({status:e})=>{let t=lD[e];return t?.kind===`chip`?(0,J.jsx)(`span`,{"data-slot":`file-status`,className:X(`shrink-0 rounded-full border px-1.5 text-caption font-medium leading-4`,t.className),children:t.label}):null},XD=(e,t)=>`${e} ${t}${e===1?``:`s`}`,ZD=({callers:e,named:t})=>{let[n,r]=(0,q.useState)(!1),i=(0,q.useId)(),{uses:a,more:o}=e,s=a.filter(e=>ul(e.path)).length,c=a.length-s,l=`${[...c>0?[XD(c,`place`)]:[],...s>0?[XD(s,`test`)]:[]].join(` and `)}${o>0?`, and ${o} more`:``}`;return(0,J.jsxs)(`div`,{"data-slot":`unchanged-uses`,className:`border-b bg-surface-subtle px-3 py-1.5`,children:[(0,J.jsx)(`p`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),className:`min-h-6 rounded-sm text-primary underline-offset-2 hover:underline`,children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.symbol}),` `]}),t?`used`:`Used`,` unchanged in `,l]})}),n&&(0,J.jsxs)(`ul`,{id:i,className:`mt-1.5 flex flex-col gap-2`,children:[a.map(e=>(0,J.jsxs)(`li`,{"data-slot":`unchanged-use`,children:[(0,J.jsxs)(`p`,{"data-slot":`unchanged-place`,className:`font-mono text-code-compact text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-foreground`,children:e.path}),`:`,e.line,e.use===`type`&&(0,J.jsx)(`span`,{children:` type`})]}),(0,J.jsx)(`pre`,{className:`overflow-x-auto rounded-md border bg-background py-1 font-mono text-code-compact`,children:e.excerpt.lines.map((t,n)=>{let r=e.excerpt.start+n,i=r===e.line;return(0,J.jsxs)(`span`,{"data-slot":`unchanged-line`,"data-used":i||void 0,className:X(`block pr-3`,i&&`bg-diff-hunk-bg text-diff-hunk-fg`),children:[(0,J.jsx)(`span`,{className:`tabular inline-block w-12 select-none pr-3 text-right text-diff-gutter-fg`,children:r}),t]},r)})})]},`${e.path}:${e.line}`)),o>0&&(0,J.jsxs)(`li`,{className:`text-muted-foreground`,children:[`and `,o,` more`]})]})]})};function QD(e){return Qv(e.defaultTagName??`div`,e,e)}var $D=cy(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-caption font-medium whitespace-nowrap transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function eO({className:e,variant:t=`default`,render:n,...r}){return QD({defaultTagName:`span`,props:mv({className:X($D({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function tO({status:e,label:t=e.label,className:n}){return(0,J.jsxs)(eO,{variant:`outline`,className:X(e.className,n),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:e.glyph}),t]})}function nO({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=q.useRef(e!==void 0),[a,o]=q.useState(()=>t);return[i&&e!==void 0?e:a,q.useCallback(e=>{i||o(e)},[])]}var rO=q.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function iO(){return q.useContext(rO)}function aO(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Z(i),[,o]=q.useState(0),s=sv(sO).current,c=sv(oO).current,l=q.useRef(0),u=q.useRef(!0),d=q.useRef(null),f=q.useRef(null),p=Z(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Z((e,t)=>{c.set(e,t),p()}),h=Z(e=>{c.delete(e),p()}),g=Z(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!uO(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&dO(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=lO(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Z(()=>{let[e,t]=cO(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Q(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Q(()=>{u.current&&v()}),Q(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Z(e=>(s.add(e),()=>{s.delete(e)})),b=q.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,J.jsx)(rO.Provider,{value:b,children:t})}function oO(){return new Map}function sO(){return new Set}function cO(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>dO(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function lO(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function uO(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function dO(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var fO=q.createContext(void 0);function pO(){let e=q.useContext(fO);if(e===void 0)throw Error(Ov(64));return e}var mO=`data-activation-direction`,hO={tabActivationDirection:e=>({[mO]:e})},gO=q.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=q.useRef([]),[f,p]=q.useState(()=>new Map),[m,h]=nO({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=q.useState(()=>new Map),y=q.useRef(void 0),b=q.useCallback(e=>_O(_,e),[_]),[x,S]=q.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=vO(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;Q(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=Z((e,t)=>{t.activationDirection=vO(m,e,a,_),i?.(e,t),!t.isCanceled&&h(()=>e)}),A=Z((e,t)=>{i?.(e,Ab(t,void 0,void 0,{activationDirection:`none`}))}),j=Z((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),M=q.useCallback(e=>f.get(e),[f]),N=q.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),P=q.useMemo(()=>({getTabElementBySelectedValue:b,getTabIdByPanelValue:N,getTabPanelIdByValue:M,onValueChange:k,orientation:a,registerMountedTabPanel:j,setTabMap:v,tabActivationDirection:T,value:m}),[b,N,M,k,a,j,v,T,m]),F=q.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),I=q.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),L=q.useRef(!u),R=q.useRef(r),ee=q.useRef(u),z=q.useRef(!1);Q(()=>{if(g)return;function e(e,t){h(()=>e),S({previousValue:e,tabActivationDirection:`none`}),A(e,t),L.current=!1}if(_.size===0){z.current&&m!==null&&!y.current?.isConnected&&e(null,qb);return}z.current=!0,y.current=_.keys().next().value;let t=F?.disabled,n=F==null&&m!==null;if(!t&&m===R.current&&(ee.current=!1),ee.current&&t&&m===R.current)return;let r=L.current;if(t||n){let n=I??null;if(m===n){L.current=!1;return}let i=qb;r?i=Jb:t&&(i=Kb),e(n,i)}else r&&F!=null&&(A(m,Jb),L.current=!1)},[I,g,A,F,h,_,m]);let te=Qv(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:hO});return(0,J.jsx)(fO.Provider,{value:P,children:(0,J.jsx)(aO,{elementsRef:d,children:te})})});function _O(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function vO(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=_O(r,e),c=_O(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var yO=`data-composite-item-active`;function bO(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=iO(),u=q.useRef(-1),[d,f]=q.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=q.useRef(null),h=q.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Q(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function xO(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Av(),{ref:i,index:a}=bO(e),o=n===a,s=q.useRef(null),c=Lv(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}var SO=q.createContext(void 0);function CO(){let e=q.useContext(SO);if(e===void 0)throw Error(Ov(65));return e}var wO=q.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=pO(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=CO(),{highlightedIndex:v,onHighlightedIndexChange:y}=Av(),b=gE(o),{compositeProps:x,compositeRef:S,index:C}=xO({metadata:q.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),w=a===u,T=q.useRef(!1),E=q.useRef(null),D=Z(e=>{E.current?.(),E.current=e?g(e):null});Q(()=>{if(T.current){T.current=!1;return}if(!(w&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=Vy(Mv(e));if(t&&Hy(e,t))return}r||y(C)},[w,C,v,y,r,_]);let{getButtonProps:O,buttonRef:k}=Pv({disabled:r,native:s,focusableWhenDisabled:!0}),A=d(a),j=q.useRef(!1),M=q.useRef(!1);function N(e){f(a,Ab(Mb,e.nativeEvent,void 0,{activationDirection:`none`}))}function P(e){w||r||N(e)}function F(e){w||r||h&&(!j.current||M.current)&&N(e)}function I(e){if(w||r)return;j.current=!0,M.current=e.button===0;let t=Mv(e.currentTarget);function n(){j.current=!1,M.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return Qv(`button`,e,{state:{disabled:r,active:w,orientation:p,tabActivationDirection:m},ref:[t,k,S,D],props:[x,{role:`tab`,"aria-controls":A,"aria-selected":w,id:b,onClick:P,onFocus:F,onPointerDown:I,[yO]:w?``:void 0,onKeyDownCapture(){T.current=!0}},l,O],stateAttributesMapping:hO})}),TO=q.createContext(void 0),EO={disableStyleElements:!1};function DO(){return q.useContext(TO)??EO}var OO=`data-index`,kO={...hO,...tb},AO=q.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,style:o,...s}=e,{value:c,getTabIdByPanelValue:l,orientation:u,tabActivationDirection:d,registerMountedTabPanel:f}=pO(),p=gE(),{ref:m,index:h}=bO(),g=r===c,{mounted:_,transitionStatus:v,setMounted:y}=PC(g),b=!_,x=l(r),S={hidden:b,orientation:u,tabActivationDirection:d,transitionStatus:v},C=q.useRef(null),w=Qv(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:UE(!g),[OO]:h},s],stateAttributesMapping:kO});return zC({open:g,ref:C,onComplete(){g||y(!1)}}),Q(()=>{if(!(p==null||b&&!a))return f(r,p)},[b,a,r,p,f]),a||_?w:null});function jO(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var MO=`ArrowUp`,NO=`ArrowDown`,PO=`ArrowLeft`,FO=`ArrowRight`,IO=new Set([MO,NO,PO,FO,`Home`,`End`]),LO=[`Shift`,`Control`,`Alt`,`Meta`];function RO(e){return B_(e)&&e.tagName===`INPUT`}function zO(e){return!!(RO(e)&&e.selectionStart!=null||B_(e)&&e.tagName===`TEXTAREA`)}function BO(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=VO(e,t,`left`),a=HO(e),o=HO(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=VO(e,t,`top`),r=HO(e),i=HO(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function VO(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function HO(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function UO(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=qv}=e,[p,m]=q.useState(0),h=r!=null,g=q.useRef(null),_=Lv(g,c),v=q.useRef([]),y=q.useRef(!1),b=q.useRef(null),x=o??p,S=Z((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];BO(g.current,t,a,n)}}),C=Z(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[x];!t||Gx(e,x,d)?S(WO(e,d)):b.current=t}else t!==x&&S(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)S(i);else if(Gx(t,x,d)){let e=Wx(t,{disabledIndices:d});Bx(t,e)||S(e)}BO(g.current,r,a,n)});Q(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(Gx(e,x,d)){let t=Wx(e,{disabledIndices:d});Bx(e,t)||S(t)}},[d,o,x,v,S]);let w=Z((e,t,n)=>i?i(e,t,n,v):n),T=Z(e=>{let o=e.key===`Home`||e.key===`End`;if(!IO.has(e.key)||!l&&o||GO(e,f)||!g.current)return;let s=a===`rtl`,c=s?PO:FO,p=s?FO:PO,m=n===`vertical`?NO:c,_=n===`vertical`?MO:p,y=Wy(e.nativeEvent);if(y!=null&&zO(y)&&!jO(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=x,C=Vx(v,d),T=Hx(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:x,loopFocus:t,maxIndex:T,minIndex:C,onLoop:w,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=C:e.key===`End`&&(b=T)),b===x&&(E||D)&&(t&&b===T&&E?(b=C,i&&(b=i(e,x,b,v))):t&&b===C&&D?(b=T,i&&(b=i(e,x,b,v))):b=Wx(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==x&&!Bx(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Wy(e.nativeEvent);t&&n!=null&&zO(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function WO(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Gx(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function GO(e,t){for(let n of LO)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function KO(e){let{render:t,className:n,style:r,refs:i=qv,props:a=qv,state:o=Jv,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=UO({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:SE(),disabledIndices:v,modifierKeys:y}),k=Qv(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=q.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,J.jsx)(kv.Provider,{value:A,children:(0,J.jsx)(aO,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var qO=q.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=pO(),[d,f]=q.useState(0),[p,m]=q.useState(null),h=q.useRef(new Set),g=q.useRef(new Set),_=q.useRef(null);Q(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=Z(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=Z(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),b={orientation:c,tabActivationDirection:u},x={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},S=q.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:y,tabsListElement:p}),[n,v,y,p]);return(0,J.jsx)(SO.Provider,{value:S,children:(0,J.jsx)(KO,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:hO,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:qv})})});function JO({className:e,orientation:t=`horizontal`,...n}){return(0,J.jsx)(gO,{"data-slot":`tabs`,"data-orientation":t,className:X(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var YO=cy(`group/tabs-list inline-flex w-fit items-center justify-center rounded-md p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=underline]:rounded-none`,{variants:{variant:{default:`bg-muted`,underline:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function XO({className:e,variant:t=`default`,...n}){return(0,J.jsx)(qO,{"data-slot":`tabs-list`,"data-variant":t,className:X(YO({variant:t}),e),...n})}function ZO({className:e,...t}){return(0,J.jsx)(wO,{"data-slot":`tabs-trigger`,className:X(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-ui font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=underline]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=underline]/tabs-list:bg-transparent group-data-[variant=underline]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground group-data-[variant=default]/tabs-list:data-active:ring-1 group-data-[variant=default]/tabs-list:data-active:ring-muted-foreground`,`after:absolute after:bg-primary after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=underline]/tabs-list:data-active:after:opacity-100`,e),...t})}function QO({className:e,...t}){return(0,J.jsx)(AO,{"data-slot":`tabs-content`,className:X(`flex-1 text-ui -outline-offset-2`,e),...t})}function $O({className:e,onSubmitShortcut:t,onKeyDown:n,...r}){return(0,J.jsx)(`textarea`,{"data-slot":`textarea`,onKeyDown:e=>{n?.(e),t!==void 0&&!e.defaultPrevented&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t())},className:X(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-ui transition-colors placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20`,e),...r})}var ek=[{id:`nextFile`,chords:[{key:`n`}],action:`Next file`,scope:`diff`},{id:`previousFile`,chords:[{key:`p`}],action:`Previous file`,scope:`diff`},{id:`lineDown`,chords:[{key:`ArrowDown`}],action:`Focus the next line`,scope:`diff`},{id:`lineUp`,chords:[{key:`ArrowUp`}],action:`Focus the previous line`,scope:`diff`},{id:`extendDown`,chords:[{key:`ArrowDown`,shift:!0}],action:`Extend the selection down`,scope:`diff`},{id:`extendUp`,chords:[{key:`ArrowUp`,shift:!0}],action:`Extend the selection up`,scope:`diff`},{id:`comment`,chords:[{key:`c`}],action:`Comment on the selected decision, or on the focused change`,scope:`diff`},{id:`openCall`,chords:[{key:`o`}],action:`Show the code a call on the focused line runs; again for the next call`,scope:`diff`},{id:`toggleSplit`,chords:[{key:`u`}],action:`Unified or split diff`,scope:`diff`},{id:`toggleLayout`,chords:[{key:`v`}],action:`Map or overview`,scope:`global`},{id:`moveFile`,chords:[{key:`ArrowLeft`},{key:`ArrowRight`},{key:`ArrowUp`},{key:`ArrowDown`}],action:`Move between files`,scope:`overview`},{id:`openFile`,chords:[{key:`Enter`}],action:`Open the file's code in the map, or a group of files in place`,scope:`overview`},{id:`filterTree`,chords:[{key:`/`}],action:`Filter the files`,scope:`tree`},{id:`openReview`,chords:[{key:`R`,shift:!0}],action:`Open the review to publish`,scope:`global`},{id:`submit`,chords:[{key:`Enter`,mod:!0}],action:`Send the comment or review`,scope:`composer`},{id:`close`,chords:[{key:`Escape`}],action:`Close, clear the highlight, or go back to the overview`,scope:`global`},{id:`help`,chords:[{key:`?`,shift:!0}],action:`Show all shortcuts`,scope:`global`},{id:`focusLink`,chords:[{key:`/`}],action:`Paste a pull request link`,scope:`picker`},{id:`moveRow`,chords:[{key:`ArrowUp`},{key:`ArrowDown`},{key:`ArrowLeft`},{key:`ArrowRight`},{key:`Home`},{key:`End`}],action:`Move between a list's pull requests, or the activity calendar's days`,scope:`picker`},{id:`openRow`,chords:[{key:`Enter`}],action:`Open the pull request`,scope:`picker`},{id:`openInNewTab`,chords:[{key:`Enter`,mod:!0}],action:`Open the pull request or the link in a new tab`,scope:`picker`},{id:`cancelOpening`,chords:[{key:`Escape`}],action:`Stop waiting for a review to open`,scope:`picker`}],tk=new Map(ek.map(e=>[e.id,e])),nk=e=>{let t=tk.get(e);if(t===void 0)throw Error(`No shortcut ${e}`);return t},rk=new Set([`Escape`]),ik=e=>e.mod!==!0&&!rk.has(e.key),ak=e=>e.mod!==!0&&e.key.length===1,ok={ArrowDown:`↓`,ArrowUp:`↑`,ArrowLeft:`←`,ArrowRight:`→`,Enter:`↵`,Escape:`Esc`,Home:`Home`,End:`End`},sk=(e,t)=>{let n=[];return e.mod===!0&&n.push(t?`⌘`:`Ctrl`),e.shift===!0&&e.key!==`?`&&n.push(`⇧`),n.push(ok[e.key]??e.key),n},ck=(e,t,n)=>{let r=n?e.metaKey:e.ctrlKey,i=n?e.ctrlKey:e.metaKey;return e.altKey||i||r!==(t.mod===!0)||t.key.length>1&&e.shiftKey!==(t.shift===!0)?!1:e.key===t.key},lk=e=>e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement&&![`checkbox`,`radio`,`button`,`submit`,`reset`,`range`,`color`,`file`].includes(e.type):!1,uk=(e,t,n)=>{let r=lk(e.target);for(let i of t)for(let t of nk(i).chords)if(ck(e,t,n.mac)&&!(ik(t)&&r)&&(!ak(t)||n.singleKeys))return i;return null},dk=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),fk=`megareviewer:singleKeyShortcuts`,pk=new Set,mk=()=>{try{return window.localStorage.getItem(fk)!==`false`}catch{return!0}},hk=e=>(pk.add(e),window.addEventListener(`storage`,e),()=>{pk.delete(e),window.removeEventListener(`storage`,e)}),gk=()=>[(0,q.useSyncExternalStore)(hk,mk),(0,q.useCallback)(e=>{try{window.localStorage.setItem(fk,String(e))}catch{}for(let e of pk)e()},[])],_k=(e,t=!0)=>{let[n]=gk(),r=(0,q.useRef)(e);r.current=e,(0,q.useEffect)(()=>{if(!t)return;let e=dk(),i=t=>{if(t.defaultPrevented)return;let i=uk(t,ek.filter(e=>r.current[e.id]!==void 0).map(e=>e.id),{mac:e,singleKeys:n});i!==null&&(t.preventDefault(),r.current[i]?.(t))};return window.addEventListener(`keydown`,i),()=>window.removeEventListener(`keydown`,i)},[t,n])};function vk({className:e,...t}){return(0,J.jsx)(`kbd`,{"data-slot":`kbd`,className:X(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm border-b-2 border-border bg-muted px-1 font-mono text-kbd font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background [&_svg:not([class*='size-'])]:size-3`,e),...t})}function yk({className:e,...t}){return(0,J.jsx)(`kbd`,{"data-slot":`kbd-group`,className:X(`inline-flex items-center gap-1`,e),...t})}var bk=({id:e,className:t})=>{let[n]=gk(),r=(0,q.useMemo)(dk,[]),[i]=nk(e).chords;return i===void 0||!n&&ak(i)?null:(0,J.jsx)(yk,{"aria-hidden":`true`,className:X(`shrink-0`,t),children:sk(i,r).map(e=>(0,J.jsx)(vk,{children:e},e))})},xk=({hints:e,className:t})=>(0,J.jsx)(`p`,{"aria-hidden":`true`,"data-slot":`key-hint-line`,className:X(`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,t),children:e.map(({id:e,action:t},n)=>(0,J.jsxs)(q.Fragment,{children:[n>0&&(0,J.jsx)(`span`,{children:`·`}),(0,J.jsx)(bk,{id:e}),(0,J.jsx)(`span`,{children:t})]},e))}),Sk={draft:`bg-review-pending`,open:`bg-thread-marker`,resolved:`bg-review-approved`,outdated:`bg-muted-foreground`},Ck=({as:e=`div`,state:t,className:n,children:r,...i})=>(0,J.jsxs)(e,{"data-slot":`comment-card`,"data-state":t,className:X(`relative rounded-lg border bg-thread-bg py-2.5 pr-4 pl-5 font-sans`,`[&_:is(textarea,input):focus-visible]:-outline-offset-1`,n),...i,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`comment-bar`,className:X(`absolute top-2 bottom-2 left-1.5 w-[3px] rounded-full`,Sk[t])}),r]}),wk=e=>{let t=e.trim().split(/[\s._-]+/).filter(Boolean),n=(t.length===1?[...t[0]??``].slice(0,2):t.slice(0,2).map(e=>[...e][0]??``)).join(``).toUpperCase();return n===``?`?`:n},Tk=6e4,Ek=60*Tk,Dk=24*Ek,Ok=(e,t)=>{let n=Math.max(0,t-Date.parse(e));if(n<Tk)return`just now`;if(n<Ek)return`${Math.floor(n/Tk)}m ago`;if(n<Dk)return`${Math.floor(n/Ek)}h ago`;let r=Math.floor(n/Dk);return r<30?r===1?`yesterday`:`${r} days ago`:new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})},kk=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}),Ak=(e,t,n)=>`${e===`old`?`L`:`R`}${t===null||t===n?n:`${t}–${n}`}`,jk=({children:e})=>(0,J.jsx)(`code`,{className:`rounded-sm bg-diff-hunk-bg px-1 font-mono text-code-compact text-diff-hunk-fg`,children:e}),Mk=e=>{let t=e.map(e=>e.text.endsWith(`\r`)),n=t.includes(!0)&&t.includes(!1);return e.map((e,r)=>({line:e,text:t[r]?e.text.slice(0,-1):e.text,carriageReturn:n&&t[r]===!0}))},Nk=e=>({added:e.lines.filter(e=>e.kind===`add`).length,deleted:e.lines.filter(e=>e.kind===`del`).length}),Pk=(e,t)=>t<=1?`${e}`:`${e}–${e+t-1}`,Fk=e=>e.newLines>0?`lines ${Pk(e.newStart,e.newLines)}`:`deleted lines ${Pk(e.oldStart,e.oldLines)}`,Ik={"token-keyword":`keyword`,"token-string":`string`,"token-string-expression":`string`,"token-function":`function`,"token-comment":`comment`,"token-constant":`number`},Lk=e=>{let t=/^var\(--shiki-([\w-]+)/.exec(e??``)?.[1];return t===void 0?null:Ik[t]??null},Rk=e=>{let t=[];for(let{content:n,color:r}of e){let e=Lk(r),i=t.at(-1);i!==void 0&&i.type===e?t[t.length-1]={text:i.text+n,type:e}:t.push({text:n,type:e})}return t},zk=(e,t,n)=>{let r=0,i=0;return Mk(e.lines).map(({line:e,text:a})=>{let o=e.kind===`del`?t?.[r]:n?.[i];return e.kind!==`add`&&r++,e.kind!==`del`&&i++,o!==void 0&&o.map(e=>e.text).join(``)===a?o:null})},Bk=e=>`var(--shiki-${e})`,Vk=[{scope:[`storage.type.annotation.java`,`punctuation.definition.annotation.java`,`variable.language.java`],color:Bk(`token-constant`)},{scope:[`storage.type.primitive.java`,`storage.type.primitive.array.java`,`keyword.operator.instanceof.java`],color:Bk(`token-keyword`)},{scope:[`storage.type.java`,`storage.type.generic.java`,`storage.type.object.array.java`,`storage.type.generic.wildcard.java`,`entity.other.inherited-class.java`,`meta.function-call.java`,`storage.modifier.package.java`,`storage.modifier.import.java`,`variable.other.object.java`,`variable.other.object.property.java`,`source.java keyword.operator`,`keyword.control.ternary.java`],color:Bk(`foreground`)}],Hk=1e3,Uk=(0,q.createContext)((()=>{let e=null,t=new Map,n=new Map,r=(e,t,r)=>{let i=`${r}\0${t}`,a=n.get(i)??e.getLastGrammarState(t,{lang:r,theme:`hunk`});return n.set(i,a),a},i=async()=>{let[{createHighlighterCore:e,createCssVariablesTheme:t},{createJavaScriptRegexEngine:n}]=await Promise.all([yD(()=>import(`./core-Ck51B_y7.js`),[]),yD(()=>import(`./engine-javascript-D-6se_EF.js`),[])]),r=t({name:`hunk`,variablePrefix:`--shiki-`});return e({themes:[{...r,tokenColors:[...r.tokenColors??[],...Vk.map(({scope:e,color:t})=>({scope:[...e],settings:{foreground:t}}))]}],langs:[],engine:n()})},a=(e,n)=>{let r=t.get(n)??(async()=>{let t=xD[n];return t!==void 0&&(await e.loadLanguage(...(await t()).default),!0)})();return t.set(n,r),r};return{async highlight(t,n){if(xD[n]===void 0)return null;e??=i();let o=await e;if(!await a(o,n))return null;let s=ND(t,n);return o.codeToTokensBase(t,{lang:n,theme:`hunk`,tokenizeMaxLineLength:Hk,...s===``?{}:{grammarState:r(o,s,n)}}).map(e=>Rk(e))}}})()),Wk=new WeakMap,Gk=(e,t,n)=>{let r=Wk.get(e)??new Map;Wk.set(e,r);let i=`${n}\0${t.id}\0${t.oldStart},${t.newStart},${t.lines.length}`,a=r.get(i);if(a!==void 0)return a;let o=Mk(t.lines),s=ED(o),c=(t,r)=>r?e.highlight(t,n):Promise.resolve(null),l={promise:Promise.all([c(s.old,o.some(({line:e})=>e.kind!==`add`)),c(s.new,o.some(({line:e})=>e.kind!==`del`))]).then(([e,n])=>{let r=zk(t,e,n);return l.value=r,r}),value:null};return r.set(i,l),l},Kk=`1200px 0px`,qk=null,Jk=new Map,Yk=(e,t)=>(qk??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(Jk.get(t.target)?.(),Jk.delete(t.target),qk?.unobserve(t.target))},{rootMargin:Kk}),Jk.set(e,t),qk.observe(e),()=>{Jk.delete(e),qk?.unobserve(e)}),Xk=e=>{let[t,n]=(0,q.useState)(()=>typeof IntersectionObserver>`u`);return(0,q.useEffect)(()=>{let r=e.current;if(!(t||r===null))return Yk(r,()=>n(!0))},[e,t]),t},Zk=(e,t,n=!0)=>{let r=(0,q.useContext)(Uk),i=TD(t),a=i===null||!n?null:Gk(r,e,i),[o,s]=(0,q.useState)();return(0,q.useEffect)(()=>{if(a===null)return;let e=!0;return a.promise.then(t=>{e&&s(e=>e?.entry===a?e:{entry:a,tokens:t})}),()=>{e=!1}},[a]),a?.value??(o?.entry===a?o.tokens:null)},Qk=(e,t)=>{let n=(0,q.useContext)(Uk),r=TD(t),[i,a]=(0,q.useState)(null);return(0,q.useEffect)(()=>{if(r===null||e===null)return;let t=!0;return n.highlight(e.join(`
79
+ `:``;if(a===void 0)return o;let s=PD(a,n),c=a.trim();return(s===0?``:AD.test(c)||s===1&&!jD.test(c)?OD(s):kD(Math.max(s,2)))+o},PD=(e,t)=>{let n=/^[ \t]*/.exec(e)?.[0]??``,r=n.split(` `).length-1;if(r>0)return r+Math.floor((n.length-r)/4);let i=t.some(e=>(/^ */.exec(e)?.[0].length??0)%4==2&&!MD.test(e.trim()));return Math.floor(n.length/(i?2:4))},FD=new Set([`graphql`,`ini`,`json`,`jsonc`,`sql`,`toml`,`xml`,`yaml`]),ID=new Set([`css`,`scss`]),LD=new Set([`css`,`html`,`scss`,`svelte`,`vue`]),RD=new Set([`javascript`,`jsx`,`tsx`,`typescript`]),zD=/\.(md|mdx|rst|txt)$/i,BD=e=>TD({path:e,language:null}),VD=e=>{if(ul(e))return`test`;if(zD.test(e))return`docs`;let t=BD(e);return t===null?`other`:FD.has(t)?`data`:ID.has(t)?`style`:`code`},HD=e=>{let t=BD(e);return t===null||zD.test(e)?`plain`:t===`python`?`python`:RD.has(t)?`script`:FD.has(t)?`data`:LD.has(t)?`markup`:`plain`},UD={test:mg,code:ng,data:Ph,docs:cg,style:Xg,other:ug},WD={python:`text-syntax-function`,script:`text-syntax-number`,data:`text-syntax-string`,markup:`text-syntax-keyword`,plain:`text-muted-foreground`},GD={added:og,deleted:ig},KD=({path:e,status:t,className:n})=>{let r=t===void 0?null:lD[t],i=t===void 0?void 0:GD[t];if(r?.kind===`mark`&&i!==void 0)return(0,J.jsx)(i,{"aria-hidden":`true`,"data-status":t,className:X(`size-3.5 shrink-0`,r.tone,n)});let a=VD(e),o=UD[a];return(0,J.jsx)(o,{"aria-hidden":`true`,"data-role":a,className:X(`size-3.5 shrink-0`,WD[HD(e)],n)})},qD=({path:e,name:t})=>{let n=e.lastIndexOf(`/`)+1;return(0,J.jsxs)(J.Fragment,{children:[n>0&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e.slice(0,n)}),(0,J.jsx)(`span`,{"data-slot":`file-name`,className:X(`font-medium`,t),children:e.slice(n)})]})},JD=({file:e,status:t,className:n})=>{let r=t===void 0?null:lD[t],i=r?.kind===`mark`?r:null;return(0,J.jsxs)(`span`,{"data-slot":`file-path`,className:X(`min-w-0 break-all font-mono text-code`,n),children:[i!==null&&(0,J.jsx)(KD,{path:e.path,status:t,className:`mr-1 inline-block align-[-2px]`}),e.oldPath!==null&&e.oldPath!==e.path?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e.oldPath}),` `,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`renamed to`}),` `,(0,J.jsx)(qD,{path:e.path,name:i?.name})]}):(0,J.jsx)(qD,{path:e.path,name:i?.name}),i!==null&&(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, `,i.label]})]})},YD=({status:e})=>{let t=lD[e];return t?.kind===`chip`?(0,J.jsx)(`span`,{"data-slot":`file-status`,className:X(`shrink-0 rounded-full border px-1.5 text-caption font-medium leading-4`,t.className),children:t.label}):null},XD=(e,t)=>`${e} ${t}${e===1?``:`s`}`,ZD=({callers:e,named:t})=>{let[n,r]=(0,q.useState)(!1),i=(0,q.useId)(),{uses:a,more:o}=e,s=a.filter(e=>ul(e.path)).length,c=a.length-s,l=`${[...c>0?[XD(c,`place`)]:[],...s>0?[XD(s,`test`)]:[]].join(` and `)}${o>0?`, and ${o} more`:``}`;return(0,J.jsxs)(`div`,{"data-slot":`unchanged-uses`,className:`border-b bg-surface-subtle px-3 py-1.5`,children:[(0,J.jsx)(`p`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>r(!n),className:`min-h-6 rounded-sm text-primary underline-offset-2 hover:underline`,children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.symbol}),` `]}),t?`used`:`Used`,` unchanged in `,l]})}),n&&(0,J.jsxs)(`ul`,{id:i,className:`mt-1.5 flex flex-col gap-2`,children:[a.map(e=>(0,J.jsxs)(`li`,{"data-slot":`unchanged-use`,children:[(0,J.jsxs)(`p`,{"data-slot":`unchanged-place`,className:`font-mono text-code-compact text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-foreground`,children:e.path}),`:`,e.line,e.use===`type`&&(0,J.jsx)(`span`,{children:` type`})]}),(0,J.jsx)(`pre`,{className:`overflow-x-auto rounded-md border bg-background py-1 font-mono text-code-compact`,children:e.excerpt.lines.map((t,n)=>{let r=e.excerpt.start+n,i=r===e.line;return(0,J.jsxs)(`span`,{"data-slot":`unchanged-line`,"data-used":i||void 0,className:X(`block pr-3`,i&&`bg-diff-hunk-bg text-diff-hunk-fg`),children:[(0,J.jsx)(`span`,{className:`tabular inline-block w-12 select-none pr-3 text-right text-diff-gutter-fg`,children:r}),t]},r)})})]},`${e.path}:${e.line}`)),o>0&&(0,J.jsxs)(`li`,{className:`text-muted-foreground`,children:[`and `,o,` more`]})]})]})};function QD(e){return Qv(e.defaultTagName??`div`,e,e)}var $D=cy(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-caption font-medium whitespace-nowrap transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function eO({className:e,variant:t=`default`,render:n,...r}){return QD({defaultTagName:`span`,props:mv({className:X($D({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function tO({status:e,label:t=e.label,className:n}){return(0,J.jsxs)(eO,{variant:`outline`,className:X(e.className,n),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:e.glyph}),t]})}function nO({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=q.useRef(e!==void 0),[a,o]=q.useState(()=>t);return[i&&e!==void 0?e:a,q.useCallback(e=>{i||o(e)},[])]}var rO=q.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function iO(){return q.useContext(rO)}function aO(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Z(i),[,o]=q.useState(0),s=sv(sO).current,c=sv(oO).current,l=q.useRef(0),u=q.useRef(!0),d=q.useRef(null),f=q.useRef(null),p=Z(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Z((e,t)=>{c.set(e,t),p()}),h=Z(e=>{c.delete(e),p()}),g=Z(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!uO(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&dO(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=lO(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Z(()=>{let[e,t]=cO(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Q(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Q(()=>{u.current&&v()}),Q(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Z(e=>(s.add(e),()=>{s.delete(e)})),b=q.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,J.jsx)(rO.Provider,{value:b,children:t})}function oO(){return new Map}function sO(){return new Set}function cO(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>dO(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function lO(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function uO(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function dO(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var fO=q.createContext(void 0);function pO(){let e=q.useContext(fO);if(e===void 0)throw Error(Ov(64));return e}var mO=`data-activation-direction`,hO={tabActivationDirection:e=>({[mO]:e})},gO=q.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=q.useRef([]),[f,p]=q.useState(()=>new Map),[m,h]=nO({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=q.useState(()=>new Map),y=q.useRef(void 0),b=q.useCallback(e=>_O(_,e),[_]),[x,S]=q.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=vO(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;Q(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=Z((e,t)=>{t.activationDirection=vO(m,e,a,_),i?.(e,t),!t.isCanceled&&h(()=>e)}),A=Z((e,t)=>{i?.(e,Ab(t,void 0,void 0,{activationDirection:`none`}))}),j=Z((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),M=q.useCallback(e=>f.get(e),[f]),N=q.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),P=q.useMemo(()=>({getTabElementBySelectedValue:b,getTabIdByPanelValue:N,getTabPanelIdByValue:M,onValueChange:k,orientation:a,registerMountedTabPanel:j,setTabMap:v,tabActivationDirection:T,value:m}),[b,N,M,k,a,j,v,T,m]),F=q.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),I=q.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),L=q.useRef(!u),R=q.useRef(r),ee=q.useRef(u),z=q.useRef(!1);Q(()=>{if(g)return;function e(e,t){h(()=>e),S({previousValue:e,tabActivationDirection:`none`}),A(e,t),L.current=!1}if(_.size===0){z.current&&m!==null&&!y.current?.isConnected&&e(null,qb);return}z.current=!0,y.current=_.keys().next().value;let t=F?.disabled,n=F==null&&m!==null;if(!t&&m===R.current&&(ee.current=!1),ee.current&&t&&m===R.current)return;let r=L.current;if(t||n){let n=I??null;if(m===n){L.current=!1;return}let i=qb;r?i=Jb:t&&(i=Kb),e(n,i)}else r&&F!=null&&(A(m,Jb),L.current=!1)},[I,g,A,F,h,_,m]);let te=Qv(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:hO});return(0,J.jsx)(fO.Provider,{value:P,children:(0,J.jsx)(aO,{elementsRef:d,children:te})})});function _O(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function vO(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=_O(r,e),c=_O(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var yO=`data-composite-item-active`;function bO(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=iO(),u=q.useRef(-1),[d,f]=q.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=q.useRef(null),h=q.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Q(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function xO(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Av(),{ref:i,index:a}=bO(e),o=n===a,s=q.useRef(null),c=Lv(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}var SO=q.createContext(void 0);function CO(){let e=q.useContext(SO);if(e===void 0)throw Error(Ov(65));return e}var wO=q.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=pO(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=CO(),{highlightedIndex:v,onHighlightedIndexChange:y}=Av(),b=gE(o),{compositeProps:x,compositeRef:S,index:C}=xO({metadata:q.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),w=a===u,T=q.useRef(!1),E=q.useRef(null),D=Z(e=>{E.current?.(),E.current=e?g(e):null});Q(()=>{if(T.current){T.current=!1;return}if(!(w&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=Vy(Mv(e));if(t&&Hy(e,t))return}r||y(C)},[w,C,v,y,r,_]);let{getButtonProps:O,buttonRef:k}=Pv({disabled:r,native:s,focusableWhenDisabled:!0}),A=d(a),j=q.useRef(!1),M=q.useRef(!1);function N(e){f(a,Ab(Mb,e.nativeEvent,void 0,{activationDirection:`none`}))}function P(e){w||r||N(e)}function F(e){w||r||h&&(!j.current||M.current)&&N(e)}function I(e){if(w||r)return;j.current=!0,M.current=e.button===0;let t=Mv(e.currentTarget);function n(){j.current=!1,M.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return Qv(`button`,e,{state:{disabled:r,active:w,orientation:p,tabActivationDirection:m},ref:[t,k,S,D],props:[x,{role:`tab`,"aria-controls":A,"aria-selected":w,id:b,onClick:P,onFocus:F,onPointerDown:I,[yO]:w?``:void 0,onKeyDownCapture(){T.current=!0}},l,O],stateAttributesMapping:hO})}),TO=q.createContext(void 0),EO={disableStyleElements:!1};function DO(){return q.useContext(TO)??EO}var OO=`data-index`,kO={...hO,...tb},AO=q.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,style:o,...s}=e,{value:c,getTabIdByPanelValue:l,orientation:u,tabActivationDirection:d,registerMountedTabPanel:f}=pO(),p=gE(),{ref:m,index:h}=bO(),g=r===c,{mounted:_,transitionStatus:v,setMounted:y}=PC(g),b=!_,x=l(r),S={hidden:b,orientation:u,tabActivationDirection:d,transitionStatus:v},C=q.useRef(null),w=Qv(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:UE(!g),[OO]:h},s],stateAttributesMapping:kO});return zC({open:g,ref:C,onComplete(){g||y(!1)}}),Q(()=>{if(!(p==null||b&&!a))return f(r,p)},[b,a,r,p,f]),a||_?w:null});function jO(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var MO=`ArrowUp`,NO=`ArrowDown`,PO=`ArrowLeft`,FO=`ArrowRight`,IO=new Set([MO,NO,PO,FO,`Home`,`End`]),LO=[`Shift`,`Control`,`Alt`,`Meta`];function RO(e){return B_(e)&&e.tagName===`INPUT`}function zO(e){return!!(RO(e)&&e.selectionStart!=null||B_(e)&&e.tagName===`TEXTAREA`)}function BO(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=VO(e,t,`left`),a=HO(e),o=HO(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=VO(e,t,`top`),r=HO(e),i=HO(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function VO(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function HO(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function UO(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=qv}=e,[p,m]=q.useState(0),h=r!=null,g=q.useRef(null),_=Lv(g,c),v=q.useRef([]),y=q.useRef(!1),b=q.useRef(null),x=o??p,S=Z((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];BO(g.current,t,a,n)}}),C=Z(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[x];!t||Gx(e,x,d)?S(WO(e,d)):b.current=t}else t!==x&&S(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)S(i);else if(Gx(t,x,d)){let e=Wx(t,{disabledIndices:d});Bx(t,e)||S(e)}BO(g.current,r,a,n)});Q(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(Gx(e,x,d)){let t=Wx(e,{disabledIndices:d});Bx(e,t)||S(t)}},[d,o,x,v,S]);let w=Z((e,t,n)=>i?i(e,t,n,v):n),T=Z(e=>{let o=e.key===`Home`||e.key===`End`;if(!IO.has(e.key)||!l&&o||GO(e,f)||!g.current)return;let s=a===`rtl`,c=s?PO:FO,p=s?FO:PO,m=n===`vertical`?NO:c,_=n===`vertical`?MO:p,y=Wy(e.nativeEvent);if(y!=null&&zO(y)&&!jO(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=x,C=Vx(v,d),T=Hx(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:x,loopFocus:t,maxIndex:T,minIndex:C,onLoop:w,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=C:e.key===`End`&&(b=T)),b===x&&(E||D)&&(t&&b===T&&E?(b=C,i&&(b=i(e,x,b,v))):t&&b===C&&D?(b=T,i&&(b=i(e,x,b,v))):b=Wx(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==x&&!Bx(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Wy(e.nativeEvent);t&&n!=null&&zO(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function WO(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Gx(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function GO(e,t){for(let n of LO)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function KO(e){let{render:t,className:n,style:r,refs:i=qv,props:a=qv,state:o=Jv,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=UO({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:SE(),disabledIndices:v,modifierKeys:y}),k=Qv(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=q.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,J.jsx)(kv.Provider,{value:A,children:(0,J.jsx)(aO,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var qO=q.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=pO(),[d,f]=q.useState(0),[p,m]=q.useState(null),h=q.useRef(new Set),g=q.useRef(new Set),_=q.useRef(null);Q(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=Z(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=Z(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),b={orientation:c,tabActivationDirection:u},x={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},S=q.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:y,tabsListElement:p}),[n,v,y,p]);return(0,J.jsx)(SO.Provider,{value:S,children:(0,J.jsx)(KO,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:hO,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:qv})})});function JO({className:e,orientation:t=`horizontal`,...n}){return(0,J.jsx)(gO,{"data-slot":`tabs`,"data-orientation":t,className:X(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var YO=cy(`group/tabs-list inline-flex w-fit items-center justify-center rounded-md p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=underline]:rounded-none`,{variants:{variant:{default:`bg-muted`,underline:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function XO({className:e,variant:t=`default`,...n}){return(0,J.jsx)(qO,{"data-slot":`tabs-list`,"data-variant":t,className:X(YO({variant:t}),e),...n})}function ZO({className:e,...t}){return(0,J.jsx)(wO,{"data-slot":`tabs-trigger`,className:X(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-ui font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=underline]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=underline]/tabs-list:bg-transparent group-data-[variant=underline]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground group-data-[variant=default]/tabs-list:data-active:ring-1 group-data-[variant=default]/tabs-list:data-active:ring-muted-foreground`,`after:absolute after:bg-primary after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=underline]/tabs-list:data-active:after:opacity-100`,e),...t})}function QO({className:e,...t}){return(0,J.jsx)(AO,{"data-slot":`tabs-content`,className:X(`flex-1 text-ui -outline-offset-2`,e),...t})}function $O({className:e,onSubmitShortcut:t,onKeyDown:n,...r}){return(0,J.jsx)(`textarea`,{"data-slot":`textarea`,onKeyDown:e=>{n?.(e),t!==void 0&&!e.defaultPrevented&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t())},className:X(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-ui transition-colors placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20`,e),...r})}var ek=[{id:`nextFile`,chords:[{key:`n`}],action:`Next file`,scope:`diff`},{id:`previousFile`,chords:[{key:`p`}],action:`Previous file`,scope:`diff`},{id:`lineDown`,chords:[{key:`ArrowDown`}],action:`Focus the next line`,scope:`diff`},{id:`lineUp`,chords:[{key:`ArrowUp`}],action:`Focus the previous line`,scope:`diff`},{id:`extendDown`,chords:[{key:`ArrowDown`,shift:!0}],action:`Extend the selection down`,scope:`diff`},{id:`extendUp`,chords:[{key:`ArrowUp`,shift:!0}],action:`Extend the selection up`,scope:`diff`},{id:`comment`,chords:[{key:`c`}],action:`Comment on the selected decision, or on the focused change`,scope:`diff`},{id:`openCall`,chords:[{key:`o`}],action:`Show the code a call on the focused line runs; again for the next call`,scope:`diff`},{id:`toggleSplit`,chords:[{key:`u`}],action:`Unified or split diff`,scope:`diff`},{id:`toggleLayout`,chords:[{key:`v`}],action:`Map or overview`,scope:`global`},{id:`moveFile`,chords:[{key:`ArrowLeft`},{key:`ArrowRight`},{key:`ArrowUp`},{key:`ArrowDown`}],action:`Move between files`,scope:`overview`},{id:`openFile`,chords:[{key:`Enter`}],action:`Open the file's code in the map, or a group of files in place`,scope:`overview`},{id:`filterTree`,chords:[{key:`/`}],action:`Filter the files`,scope:`tree`},{id:`openReview`,chords:[{key:`R`,shift:!0}],action:`Open the review to publish`,scope:`global`},{id:`submit`,chords:[{key:`Enter`,mod:!0}],action:`Send the comment or review`,scope:`composer`},{id:`close`,chords:[{key:`Escape`}],action:`Close, clear the highlight, or go back to the overview`,scope:`global`},{id:`help`,chords:[{key:`?`,shift:!0}],action:`Show all shortcuts`,scope:`global`},{id:`focusLink`,chords:[{key:`/`}],action:`Paste a pull request link`,scope:`picker`},{id:`moveRow`,chords:[{key:`ArrowUp`},{key:`ArrowDown`},{key:`ArrowLeft`},{key:`ArrowRight`},{key:`Home`},{key:`End`}],action:`Move between a list's pull requests, or the activity calendar's days`,scope:`picker`},{id:`openRow`,chords:[{key:`Enter`}],action:`Open the pull request`,scope:`picker`},{id:`openInNewTab`,chords:[{key:`Enter`,mod:!0}],action:`Open the pull request or the link in a new tab`,scope:`picker`},{id:`cancelOpening`,chords:[{key:`Escape`}],action:`Stop waiting for a review to open`,scope:`picker`}],tk=new Map(ek.map(e=>[e.id,e])),nk=e=>{let t=tk.get(e);if(t===void 0)throw Error(`No shortcut ${e}`);return t},rk=new Set([`Escape`]),ik=e=>e.mod!==!0&&!rk.has(e.key),ak=e=>e.mod!==!0&&e.key.length===1,ok={ArrowDown:`↓`,ArrowUp:`↑`,ArrowLeft:`←`,ArrowRight:`→`,Enter:`↵`,Escape:`Esc`,Home:`Home`,End:`End`},sk=(e,t)=>{let n=[];return e.mod===!0&&n.push(t?`⌘`:`Ctrl`),e.shift===!0&&e.key!==`?`&&n.push(`⇧`),n.push(ok[e.key]??e.key),n},ck=(e,t,n)=>{let r=n?e.metaKey:e.ctrlKey,i=n?e.ctrlKey:e.metaKey;return e.altKey||i||r!==(t.mod===!0)||t.key.length>1&&e.shiftKey!==(t.shift===!0)?!1:e.key===t.key},lk=e=>e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement&&![`checkbox`,`radio`,`button`,`submit`,`reset`,`range`,`color`,`file`].includes(e.type):!1,uk=(e,t,n)=>{let r=lk(e.target);for(let i of t)for(let t of nk(i).chords)if(ck(e,t,n.mac)&&!(ik(t)&&r)&&(!ak(t)||n.singleKeys))return i;return null},dk=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),fk=`megareviewer:singleKeyShortcuts`,pk=new Set,mk=()=>{try{return window.localStorage.getItem(fk)!==`false`}catch{return!0}},hk=e=>(pk.add(e),window.addEventListener(`storage`,e),()=>{pk.delete(e),window.removeEventListener(`storage`,e)}),gk=()=>[(0,q.useSyncExternalStore)(hk,mk),(0,q.useCallback)(e=>{try{window.localStorage.setItem(fk,String(e))}catch{}for(let e of pk)e()},[])],_k=(e,t=!0)=>{let[n]=gk(),r=(0,q.useRef)(e);r.current=e,(0,q.useEffect)(()=>{if(!t)return;let e=dk(),i=t=>{if(t.defaultPrevented)return;let i=uk(t,ek.filter(e=>r.current[e.id]!==void 0).map(e=>e.id),{mac:e,singleKeys:n});i!==null&&(t.preventDefault(),r.current[i]?.(t))};return window.addEventListener(`keydown`,i),()=>window.removeEventListener(`keydown`,i)},[t,n])};function vk({className:e,...t}){return(0,J.jsx)(`kbd`,{"data-slot":`kbd`,className:X(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm border-b-2 border-border bg-muted px-1 font-mono text-kbd font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background [&_svg:not([class*='size-'])]:size-3`,e),...t})}function yk({className:e,...t}){return(0,J.jsx)(`kbd`,{"data-slot":`kbd-group`,className:X(`inline-flex items-center gap-1`,e),...t})}var bk=({id:e,className:t})=>{let[n]=gk(),r=(0,q.useMemo)(dk,[]),[i]=nk(e).chords;return i===void 0||!n&&ak(i)?null:(0,J.jsx)(yk,{"aria-hidden":`true`,className:X(`shrink-0`,t),children:sk(i,r).map(e=>(0,J.jsx)(vk,{children:e},e))})},xk=({hints:e,className:t})=>(0,J.jsx)(`p`,{"aria-hidden":`true`,"data-slot":`key-hint-line`,className:X(`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,t),children:e.map(({id:e,action:t},n)=>(0,J.jsxs)(q.Fragment,{children:[n>0&&(0,J.jsx)(`span`,{children:`·`}),(0,J.jsx)(bk,{id:e}),(0,J.jsx)(`span`,{children:t})]},e))}),Sk={draft:`bg-review-pending`,open:`bg-thread-marker`,resolved:`bg-review-approved`,outdated:`bg-muted-foreground`},Ck=({as:e=`div`,state:t,className:n,children:r,...i})=>(0,J.jsxs)(e,{"data-slot":`comment-card`,"data-state":t,className:X(`relative rounded-lg border bg-thread-bg py-2.5 pr-4 pl-5 font-sans`,`[&_:is(textarea,input):focus-visible]:-outline-offset-1`,n),...i,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`comment-bar`,className:X(`absolute top-2 bottom-2 left-1.5 w-[3px] rounded-full`,Sk[t])}),r]}),wk=e=>{let t=e.trim().split(/[\s._-]+/).filter(Boolean),n=(t.length===1?[...t[0]??``].slice(0,2):t.slice(0,2).map(e=>[...e][0]??``)).join(``).toUpperCase();return n===``?`?`:n},Tk=6e4,Ek=60*Tk,Dk=24*Ek,Ok=(e,t)=>{let n=Math.max(0,t-Date.parse(e));if(n<Tk)return`just now`;if(n<Ek)return`${Math.floor(n/Tk)}m ago`;if(n<Dk)return`${Math.floor(n/Ek)}h ago`;let r=Math.floor(n/Dk);return r<30?r===1?`yesterday`:`${r} days ago`:new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})},kk=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}),Ak=(e,t,n)=>`${e===`old`?`L`:`R`}${t===null||t===n?n:`${t}–${n}`}`,jk=({children:e})=>(0,J.jsx)(`code`,{className:`rounded-sm bg-diff-hunk-bg px-1 font-mono text-code-compact text-diff-hunk-fg`,children:e}),Mk=e=>{let t=e.map(e=>e.text.endsWith(`\r`)),n=t.includes(!0)&&t.includes(!1);return e.map((e,r)=>({line:e,text:t[r]?e.text.slice(0,-1):e.text,carriageReturn:n&&t[r]===!0}))},Nk=e=>({added:e.lines.filter(e=>e.kind===`add`).length,deleted:e.lines.filter(e=>e.kind===`del`).length}),Pk=(e,t)=>t<=1?`${e}`:`${e}–${e+t-1}`,Fk=e=>e.newLines>0?`lines ${Pk(e.newStart,e.newLines)}`:`deleted lines ${Pk(e.oldStart,e.oldLines)}`,Ik={"token-keyword":`keyword`,"token-string":`string`,"token-string-expression":`string`,"token-function":`function`,"token-comment":`comment`,"token-constant":`number`},Lk=e=>{let t=/^var\(--shiki-([\w-]+)/.exec(e??``)?.[1];return t===void 0?null:Ik[t]??null},Rk=e=>{let t=[];for(let{content:n,color:r}of e){let e=Lk(r),i=t.at(-1);i!==void 0&&i.type===e?t[t.length-1]={text:i.text+n,type:e}:t.push({text:n,type:e})}return t},zk=(e,t,n)=>{let r=0,i=0;return Mk(e.lines).map(({line:e,text:a})=>{let o=e.kind===`del`?t?.[r]:n?.[i];return e.kind!==`add`&&r++,e.kind!==`del`&&i++,o!==void 0&&o.map(e=>e.text).join(``)===a?o:null})},Bk=e=>`var(--shiki-${e})`,Vk=[{scope:[`storage.type.annotation.java`,`punctuation.definition.annotation.java`,`variable.language.java`],color:Bk(`token-constant`)},{scope:[`storage.type.primitive.java`,`storage.type.primitive.array.java`,`keyword.operator.instanceof.java`],color:Bk(`token-keyword`)},{scope:[`storage.type.java`,`storage.type.generic.java`,`storage.type.object.array.java`,`storage.type.generic.wildcard.java`,`entity.other.inherited-class.java`,`meta.function-call.java`,`storage.modifier.package.java`,`storage.modifier.import.java`,`variable.other.object.java`,`variable.other.object.property.java`,`source.java keyword.operator`,`keyword.control.ternary.java`],color:Bk(`foreground`)}],Hk=1e3,Uk=(0,q.createContext)((()=>{let e=null,t=new Map,n=new Map,r=(e,t,r)=>{let i=`${r}\0${t}`,a=n.get(i)??e.getLastGrammarState(t,{lang:r,theme:`hunk`});return n.set(i,a),a},i=async()=>{let[{createHighlighterCore:e,createCssVariablesTheme:t},{createJavaScriptRegexEngine:n}]=await Promise.all([yD(()=>import(`./core-Ba9Dg9_3.js`),[]),yD(()=>import(`./engine-javascript-D-6se_EF.js`),[])]),r=t({name:`hunk`,variablePrefix:`--shiki-`});return e({themes:[{...r,tokenColors:[...r.tokenColors??[],...Vk.map(({scope:e,color:t})=>({scope:[...e],settings:{foreground:t}}))]}],langs:[],engine:n()})},a=(e,n)=>{let r=t.get(n)??(async()=>{let t=xD[n];return t!==void 0&&(await e.loadLanguage(...(await t()).default),!0)})();return t.set(n,r),r};return{async highlight(t,n){if(xD[n]===void 0)return null;e??=i();let o=await e;if(!await a(o,n))return null;let s=ND(t,n);return o.codeToTokensBase(t,{lang:n,theme:`hunk`,tokenizeMaxLineLength:Hk,...s===``?{}:{grammarState:r(o,s,n)}}).map(e=>Rk(e))}}})()),Wk=new WeakMap,Gk=(e,t,n)=>{let r=Wk.get(e)??new Map;Wk.set(e,r);let i=`${n}\0${t.id}\0${t.oldStart},${t.newStart},${t.lines.length}`,a=r.get(i);if(a!==void 0)return a;let o=Mk(t.lines),s=ED(o),c=(t,r)=>r?e.highlight(t,n):Promise.resolve(null),l={promise:Promise.all([c(s.old,o.some(({line:e})=>e.kind!==`add`)),c(s.new,o.some(({line:e})=>e.kind!==`del`))]).then(([e,n])=>{let r=zk(t,e,n);return l.value=r,r}),value:null};return r.set(i,l),l},Kk=`1200px 0px`,qk=null,Jk=new Map,Yk=(e,t)=>(qk??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(Jk.get(t.target)?.(),Jk.delete(t.target),qk?.unobserve(t.target))},{rootMargin:Kk}),Jk.set(e,t),qk.observe(e),()=>{Jk.delete(e),qk?.unobserve(e)}),Xk=e=>{let[t,n]=(0,q.useState)(()=>typeof IntersectionObserver>`u`);return(0,q.useEffect)(()=>{let r=e.current;if(!(t||r===null))return Yk(r,()=>n(!0))},[e,t]),t},Zk=(e,t,n=!0)=>{let r=(0,q.useContext)(Uk),i=TD(t),a=i===null||!n?null:Gk(r,e,i),[o,s]=(0,q.useState)();return(0,q.useEffect)(()=>{if(a===null)return;let e=!0;return a.promise.then(t=>{e&&s(e=>e?.entry===a?e:{entry:a,tokens:t})}),()=>{e=!1}},[a]),a?.value??(o?.entry===a?o.tokens:null)},Qk=(e,t)=>{let n=(0,q.useContext)(Uk),r=TD(t),[i,a]=(0,q.useState)(null);return(0,q.useEffect)(()=>{if(r===null||e===null)return;let t=!0;return n.highlight(e.join(`
80
80
  `),r).then(n=>{t&&n!==null&&a({lines:e,tokens:e.map((e,t)=>{let r=n[t];return r!==void 0&&r.map(e=>e.text).join(``)===e?r:null})})}),()=>{t=!1}},[n,r,e]),i?.lines===e?i.tokens:null},$k={keyword:`text-syntax-keyword`,string:`text-syntax-string`,function:`text-syntax-function`,comment:`text-syntax-comment`,number:`text-syntax-number`},eA=(e,t)=>{let n=(0,q.useContext)(Uk),[r,i]=(0,q.useState)(null),a=`${t??``}\0${e}`;return(0,q.useEffect)(()=>{if(t===null)return;let r=!0;return n.highlight(e,t).then(e=>{r&&i({key:a,lines:e})}),()=>{r=!1}},[n,e,t,a]),r?.key===a?r.lines:null},tA=({text:e,tokens:t})=>t!=null&&t.map(e=>e.text).join(``)===e?t.map((e,t)=>(0,J.jsx)(`span`,{className:X(e.type!==null&&$k[e.type]),children:e.text},t)):e,nA=({kind:e,text:t,tokens:n})=>(0,J.jsxs)(`div`,{"data-kind":e,className:X(`flex min-h-5 whitespace-pre`,e===`add`?`bg-diff-add-bg`:`bg-diff-del-bg`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-5 shrink-0 select-none text-center`,e===`add`?`bg-diff-add-gutter text-diff-add-fg`:`bg-diff-del-gutter text-diff-del-fg`),children:e===`add`?`+`:`−`}),(0,J.jsx)(`span`,{className:`sr-only`,children:e===`add`?`added line `:`removed line `}),(0,J.jsx)(`span`,{className:`px-2`,children:(0,J.jsx)(tA,{text:t,tokens:n})})]}),rA=({removed:e,added:t,language:n,title:r})=>{let i=eA((e??[]).join(`
81
81
  `),e===null?null:n),a=eA(t.join(`
82
82
  `),n);return(0,J.jsxs)(`div`,{"data-slot":`suggestion-diff`,className:`overflow-x-auto rounded-md border font-mono text-code-compact`,children:[r!==void 0&&(0,J.jsx)(`p`,{className:`border-b px-2 py-1 font-sans text-caption font-medium text-primary`,children:r}),(e??[]).map((e,t)=>(0,J.jsx)(nA,{kind:`del`,text:e,tokens:i?.[t]},`del:${t}`)),t.map((e,t)=>(0,J.jsx)(nA,{kind:`add`,text:e,tokens:a?.[t]},`add:${t}`)),t.length===0&&(0,J.jsxs)(`p`,{className:`px-2 py-1 font-sans text-caption text-muted-foreground`,children:[`Deletes`,` `,e===null?`the lines`:e.length===1?`the line`:`the ${e.length} lines`,`.`]})]})},iA=q.createContext(void 0);function aA(e){let t=q.useContext(iA);if(!e&&t===void 0)throw Error(Ov(27));return t}var oA=q.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=aA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Qv(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:hb,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),sA=q.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=aA(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Pv({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Ab(Rb,e.nativeEvent))}return Qv(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),cA=q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=aA(),c=gE(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Qv(`p`,e,{ref:t,props:[{id:c},o]})}),lA=q.createContext(void 0);function uA(){let e=q.useContext(lA);if(e===void 0)throw Error(Ov(26));return e}var dA=`--nested-dialogs`,fA=`data-nested-dialog-open`,pA={...mb,...tb,nestedDialogOpen(e){return e?{[fA]:``}:null}},mA=q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=aA(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);uA(),zC({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?HC(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Qv(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...VC,hidden:!m,onKeyDown(e){IO.has(e.key)&&e.stopPropagation()},style:{[dA]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:pA});return(0,J.jsx)(pC,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),hA=q.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,J.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),gA=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=aA(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,J.jsx)(lA.Provider,{value:n,children:(0,J.jsxs)(JS,{ref:t,...r,children:[a&&o===!0&&(0,J.jsx)(hA,{ref:i.context.internalBackdropRef,inert:UE(!s)}),e.children]})}):null}),_A={},vA={},yA=``;function bA(e,t){return H_(e)?e:t}function xA(e,t,n){return/hidden|clip/.test(e.getComputedStyle(bA(t,n)).overflowY)}function SA(e){if(typeof document>`u`)return!1;let t=Mv(e);return I_(t).innerWidth-t.documentElement.clientWidth>0}function CA(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Mv(e),n=t.documentElement,r=t.body,i=bA(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function wA(e){let t=Mv(e),n=t.documentElement,r=t.body,i=bA(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function TA(e){let t=Mv(e),n=t.documentElement,r=t.body,i=I_(n),a=0,o=0,s=!1,c=sx.create();if(My&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,_A={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},yA=n.style.scrollBehavior,vA={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=bA(n,r);s=CA(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,_A),Object.assign(r.style,vA),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=yA)}function d(){u(),c.request(l)}l();let f=tx(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var EA=new class{lockCount=0;restore=null;timeoutLock=yy.create();timeoutUnlock=yy.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Mv(e),n=t.documentElement,r=t.body,i=I_(n);if(xA(i,n,r)){let t=new i.MutationObserver(()=>{xA(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Dy||!SA(e);this.restore=a?wA(e):TA(e)}};function DA(e=!0,t=null){Q(()=>{if(e)return EA.acquire(t)},[e,t])}function OA({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=q.useState(0),[d,f]=q.useState(0),p=l===0,m=bC(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Wy(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Hy(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return DA(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),Q(()=>{!r&&!i&&(u(0),f(0))},[r,i]),Q(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),$C(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var kA={...Cw,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},AA=class extends mw{constructor(e,t,n){let r=new tw,i=jA(e,r,t,n);super(i,MA(r),kA)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(qC(this.state,e,t.trigger)))}};function jA(e,t,n,r=!1){return{..._w(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function MA(e){return{popupRef:q.createRef(),backdropRef:q.createRef(),internalBackdropRef:q.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function NA(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=aA(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=UC((e,t)=>new AA({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);ew(b,x),ZC(b);let{forceUnmount:w}=QC(x,b);q.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Ab(Yb))}),[w,b]);let T=x||S||u!=null;return(0,J.jsxs)(iA.Provider,{value:b,children:[u&&(0,J.jsx)(WC,{handle:u,store:b}),T&&(0,J.jsx)(OA,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var PA=my(function(e){return NA(`dialog`,e)}),FA=q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=aA(),c=gE(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Qv(`h2`,e,{ref:t,props:[{id:c},o]})});function IA(e){let t=q.useRef(``),n=q.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:q.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function LA(e,t){let n=q.useRef(e),r=Z(t);Q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function RA(e,t){let{onClick:n,onPointerDown:r}=IA(Z((n,r)=>{(typeof e==`function`?e():e)||t(r||(Dy?`touch`:``))}));return q.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function zA(e){let[t,n]=q.useState(null),r=RA(e,n);return LA(e,t=>{t&&!e&&n(null)}),q.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function BA({...e}){return(0,J.jsx)(PA,{"data-slot":`dialog`,...e})}function VA({...e}){return(0,J.jsx)(gA,{"data-slot":`dialog-portal`,...e})}function HA({className:e,...t}){return(0,J.jsx)(oA,{"data-slot":`dialog-overlay`,className:X(`fixed inset-0 isolate z-50 bg-background/70 duration-(--duration-fast) supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function UA({className:e,children:t,showCloseButton:n=!0,...r}){return(0,J.jsxs)(VA,{children:[(0,J.jsx)(HA,{}),(0,J.jsxs)(mA,{"data-slot":`dialog-content`,className:X(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-ui text-popover-foreground ring-1 ring-foreground/10 duration-(--duration-fast) outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,J.jsxs)(sA,{"data-slot":`dialog-close`,render:(0,J.jsx)($,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,J.jsx)(b_,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function WA({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`dialog-header`,className:X(`flex flex-col gap-2`,e),...t})}function GA({className:e,...t}){return(0,J.jsx)(FA,{"data-slot":`dialog-title`,className:X(`text-heading font-semibold`,e),...t})}function KA({className:e,...t}){return(0,J.jsx)(cA,{"data-slot":`dialog-description`,className:X(`text-ui text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var qA=({src:e,alt:t,onClose:n})=>(0,J.jsx)(BA,{open:!0,onOpenChange:e=>{e||n()},children:(0,J.jsxs)(UA,{"data-slot":`image-viewer`,className:`top-0 left-0 flex h-dvh w-screen max-w-none translate-x-0 translate-y-0 items-center justify-center rounded-none bg-background/95 p-4 pt-12 ring-0 sm:max-w-none`,onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,J.jsx)(GA,{className:`sr-only`,children:t}),(0,J.jsx)(`img`,{src:e,alt:t,className:`max-h-full max-w-full object-contain`})]})}),JA=e=>e===null?null:TD({path:`code.${e}`,language:e}),YA=({text:e,language:t})=>{let n=eA(e,JA(t)),r=e.split(`
83
- `);return(0,J.jsx)(`pre`,{"data-slot":`thread-code`,className:`overflow-x-auto rounded-md border bg-surface-subtle px-2.5 py-1.5 font-mono text-code-compact`,children:(0,J.jsx)(`code`,{children:r.map((e,t)=>(0,J.jsx)(`span`,{className:`block min-h-[1lh] whitespace-pre`,children:(0,J.jsx)(tA,{text:e,tokens:n?.[t]})},t))})})},XA=({kind:e,alt:t,src:n,size:r})=>{let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);if(i)return(0,J.jsxs)(`span`,{"data-slot":`thread-image`,className:`inline-flex items-center gap-1 rounded-sm border bg-muted px-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(Ag,{"aria-hidden":`true`,className:`size-3`}),e===`image`?`Image`:`Video`,t===``?``:`: ${t}`,` couldn't be loaded`]});let c=`block max-h-[28rem] max-w-full rounded-md border bg-muted`,l=t===``?`Image from the comment`:t;return e===`image`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":`Open ${l} full screen`,onClick:()=>s(!0),className:`block max-w-full cursor-zoom-in rounded-md`,children:(0,J.jsx)(`img`,{"data-slot":`thread-media`,src:n,alt:l,...r===void 0?{}:{width:r.width,height:r.height},loading:`lazy`,onError:()=>a(!0),className:X(c,`h-auto w-auto`)})}),o&&(0,J.jsx)(qA,{src:n,alt:l,onClose:()=>s(!1)})]}):(0,J.jsx)(`video`,{"data-slot":`thread-media`,src:n,controls:!0,preload:`metadata`,onError:()=>a(!0),className:c})},ZA=({span:e,mediaUrl:t})=>{switch(e.kind){case`text`:return(0,J.jsx)(J.Fragment,{children:e.text});case`code`:return(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:e.text});case`strong`:return(0,J.jsx)(`strong`,{className:`font-semibold`,children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`emphasis`:return(0,J.jsx)(`em`,{children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`strike`:return(0,J.jsx)(`del`,{children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`link`:return e.url===null?(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t}):(0,J.jsx)(`a`,{href:e.url,title:e.url,target:`_blank`,rel:`noreferrer noopener nofollow`,className:`underline`,children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`image`:case`video`:{if(e.url!==null&&t)return(0,J.jsx)(XA,{kind:e.kind,alt:e.text,src:t(e.url),size:e.size});let n=e.kind===`image`?`Image`:`Video`;return(0,J.jsxs)(`span`,{"data-slot":`thread-image`,className:`inline-flex items-center gap-1 rounded-sm border bg-muted px-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(Ag,{"aria-hidden":`true`,className:`size-3`}),e.text===``?n:`${n}: ${e.text}`,(0,J.jsx)(`span`,{className:`sr-only`,children:`, not loaded: it isn't in the host's own attachments`})]})}}},QA=({spans:e,mediaUrl:t})=>e.map((e,n)=>(0,J.jsx)(ZA,{span:e,mediaUrl:t},`${e.kind}:${n}`)),$A={1:`text-heading font-semibold`,2:`text-heading font-semibold`,3:`text-body font-semibold`},ej={left:`text-left`,center:`text-center`,right:`text-right`},tj=({blocks:e,...t})=>e.map((e,n)=>(0,J.jsx)(nj,{block:e,...t},`${e.kind}:${n}`)),nj=({block:e,suggestion:t,mediaUrl:n})=>{switch(e.kind){case`suggestion`:return(0,J.jsx)(`div`,{children:t(e.lines)});case`code`:return(0,J.jsx)(YA,{text:e.text,language:e.language});case`paragraph`:return(0,J.jsx)(`p`,{className:`whitespace-pre-wrap`,children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:n})});case`heading`:return(0,J.jsx)(`p`,{"data-slot":`thread-heading`,className:X(`whitespace-pre-wrap`,$A[e.level]??`font-semibold`),children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:n})});case`quote`:return(0,J.jsx)(`blockquote`,{className:`flex flex-col gap-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,J.jsx)(tj,{blocks:e.blocks,suggestion:t,mediaUrl:n})});case`list`:{let r=e.items.map((e,r)=>(0,J.jsx)(`li`,{className:X(`pl-1`,e.checked!==null&&`list-none -ml-5 pl-0`),children:(0,J.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[e.checked!==null&&(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center`,children:e.checked?`☑`:`☐`}),e.checked!==null&&(0,J.jsx)(`span`,{className:`sr-only`,children:e.checked?`Done: `:`Not done: `}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:(0,J.jsx)(tj,{blocks:e.blocks,suggestion:t,mediaUrl:n})})]})},r));return e.ordered?(0,J.jsx)(`ol`,{start:e.start,className:`flex list-decimal flex-col gap-1 pl-5`,children:r}):(0,J.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5`,children:r})}case`table`:return(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`border-collapse text-ui`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsx)(`tr`,{children:e.head.map((t,r)=>(0,J.jsx)(`th`,{className:X(`border bg-muted px-2 py-1 font-semibold`,ej[e.align[r]??`left`]),children:(0,J.jsx)(QA,{spans:t,mediaUrl:n})},r))})}),(0,J.jsx)(`tbody`,{children:e.rows.map((t,r)=>(0,J.jsx)(`tr`,{children:t.map((t,r)=>(0,J.jsx)(`td`,{className:X(`border px-2 py-1`,ej[e.align[r]??`left`]),children:(0,J.jsx)(QA,{spans:t,mediaUrl:n})},r))},r))})]})});case`rule`:return(0,J.jsx)(`hr`,{className:`border-border`})}},rj=({blocks:e,suggestion:t,mediaUrl:n})=>(0,J.jsx)(`div`,{"data-slot":`thread-body`,className:`flex flex-col gap-2 text-body break-words`,children:(0,J.jsx)(tj,{blocks:e,suggestion:t,mediaUrl:n})}),ij=`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,aj=`shadow-[inset_0_0_0_2px_var(--ring)]`,oj=({name:e})=>(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-caption font-medium text-muted-foreground`,children:wk(e)}),sj=e=>{let t=e.line??e.originalLine;if(t===null)return e.path;let n=e.side===`old`?`old `:``;return e.startLine!==null&&e.line!==null?`${n}lines ${e.startLine}–${t}`:`${n}line ${t}`},cj=e=>{let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&e[0]?.author.id===n.author.id?e.push(n):t.push([n])}return t},lj=({thread:e,authorId:t,now:n,language:r,covered:i,onReply:a,onResolve:o,replying:s=!1,mediaUrl:c,initialReply:l,current:u=!1,anchorId:d,linesAbove:f=0,className:p})=>{let[m,h]=(0,q.useState)(!e.resolved||u),[g,_]=(0,q.useState)(u);u!==g&&(_(u),u&&h(!0));let[v,y]=(0,q.useState)(l!==void 0),[b,x]=(0,q.useState)(0),[S,C]=(0,q.useState)(l?.text??``),[w,T]=(0,q.useState)(l?.status===`posting`),[E,D]=(0,q.useState)(l?.status===`failed`?l.error??``:null),[O,k]=(0,q.useState)(!1),[A,j]=(0,q.useState)(null),M=(0,q.useRef)(null),N=(0,q.useId)(),P=e.resolved?`resolved`:e.outdated?`outdated`:`open`,F=!e.outdated&&e.line!==null&&e.side===`new`,I=a!==void 0&&e.can.reply,L=o!==void 0&&e.can.resolve,R=I&&(v||S!==``||w||E!==null),ee=()=>{h(!0),y(!0),x(e=>e+1)};(0,q.useEffect)(()=>{b>0&&M.current?.focus()},[b]),(0,q.useEffect)(()=>{s&&ee()},[s]);let z=()=>M.current?.closest(`[data-slot=review-thread]`)?.focus(),te=()=>{w||(z(),C(``),D(null),y(!1))},B=async()=>{let e=S.trim();if(e===``||w||a===void 0)return;let t=M.current?.closest(`[data-slot=review-thread]`);T(!0),D(null);let n=await a(e);T(!1),n===null?(C(``),y(!1),t?.focus()):D(n)},ne=async()=>{if(o===void 0||O)return;k(!0),j(null);let t=await o(!e.resolved);k(!1),t===null?h(e.resolved):j(t)},V=e=>(0,J.jsx)(rA,{title:`Suggested change`,removed:F?i:null,added:e,language:r}),H=e=>(0,J.jsx)(`time`,{dateTime:e.createdAt,title:kk(e.createdAt),className:`ml-auto shrink-0 pl-3 text-caption text-muted-foreground`,children:Ok(e.createdAt,n)}),re=e=>{let[n]=e;return n===void 0?null:(0,J.jsxs)(`section`,{"data-slot":`thread-group`,className:`grid grid-cols-[1.5rem_minmax(0,1fr)] gap-x-2.5 gap-y-0.5`,children:[(0,J.jsx)(oj,{name:n.author.name}),(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:n.author.name}),t!==null&&n.author.id===t&&(0,J.jsx)(`span`,{className:X(`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,`border-border bg-muted text-muted-foreground`),children:`Author`}),H(n)]}),e.length>1?(0,J.jsx)(`span`,{"data-slot":`thread-run`,"aria-hidden":`true`,className:`flex justify-center pt-1.5 pb-1`,children:(0,J.jsx)(`span`,{className:`w-px bg-thread-run`})}):(0,J.jsx)(`span`,{"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:e.map((e,t)=>{let{blocks:n}=Vd(e.body);return(0,J.jsxs)(`div`,{"data-slot":`thread-comment`,className:`flex items-baseline`,children:[(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:(0,J.jsx)(`div`,{className:`w-full`,children:(0,J.jsx)(rj,{blocks:n,suggestion:V,...c===void 0?{}:{mediaUrl:c}})})}),t>0&&H(e)]},e.id)})})]})},[ie]=e.comments,ae=e.line??e.originalLine,oe=e.resolvedBy?.name,se=I||L;return(0,J.jsx)(Ck,{as:`article`,state:P,"data-slot":`review-thread`,id:d,"data-current":u||void 0,"aria-label":`Thread on ${sj(e)}${e.resolved?`, resolved`:``}`,tabIndex:-1,style:vh({"--lines-above":Math.min(f,5)}),className:X(`flex scroll-mt-[calc(6rem+var(--lines-above)*var(--text-code--line-height))] flex-col gap-3 -outline-offset-2`,!m&&`py-1.5`,u&&aj,p),children:m?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`thread-header`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,children:[ae!==null&&(0,J.jsxs)(J.Fragment,{children:[e.startLine!==null&&e.line!==null?`Lines`:`Line`,` `,(0,J.jsx)(jk,{children:Ak(e.side,e.line===null?null:e.startLine,ae)}),(0,J.jsx)(`span`,{children:`·`})]}),(0,J.jsxs)(`span`,{children:[e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.outdated&&(0,J.jsx)(`span`,{className:X(`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,`border-border bg-muted text-muted-foreground`),children:`Outdated`}),e.resolved&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,oe===void 0?``:` by ${oe}`]}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),"aria-expanded":!0,children:`Hide`})]})]}),cj(e.comments).map((e,t)=>(0,J.jsxs)(q.Fragment,{children:[t>0&&(0,J.jsx)(`hr`,{"data-slot":`thread-divider`}),re(e)]},e[0]?.id??t)),A!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ `,e.resolved?`Not reopened`:`Not resolved`,`: `,A]}),R?(0,J.jsxs)(`div`,{"data-slot":`thread-reply`,className:`flex flex-col gap-1.5 border-t pt-3 pl-8.5`,children:[(0,J.jsxs)(`label`,{htmlFor:N,className:`sr-only`,children:[`Reply to the thread on `,sj(e)]}),(0,J.jsx)($O,{id:N,ref:M,rows:2,value:S,placeholder:`Reply…`,disabled:w,"aria-invalid":E!==null||void 0,onChange:e=>C(e.target.value),onSubmitShortcut:()=>void B(),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),te())},className:`min-h-14 bg-background`}),E!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ Not sent: `,E,` Your reply is still here; send it again when you're ready.`]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(xk,{hints:[{id:`submit`,action:`reply`},{id:`close`,action:`cancel`}]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,J.jsx)($,{variant:`ghost`,size:`sm`,disabled:w,onClick:te,children:`Cancel`}),(0,J.jsx)($,{size:`sm`,disabled:S.trim()===``||w,onClick:()=>void B(),children:w?`Sending…`:`Reply`})]})]})]}):se&&(0,J.jsxs)(`div`,{"data-slot":`thread-actions`,className:`flex items-center gap-2 pl-8.5`,children:[I&&(0,J.jsx)(`button`,{type:`button`,onClick:ee,className:`h-8 min-w-0 flex-1 cursor-text truncate rounded-md border border-input bg-background px-2.5 text-left text-ui text-muted-foreground hover:border-foreground/40`,children:`Reply…`}),L&&(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:O,onClick:()=>void ne(),className:X(!I&&`ml-auto`),children:e.resolved?`Reopen`:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Rh,{"aria-hidden":`true`}),`Resolve`]})})]})]}):(0,J.jsxs)(`div`,{className:`flex min-h-7 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,oe===void 0?``:` by ${oe}`]}),ie!==void 0&&(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-caption text-muted-foreground`,children:[ie.author.name,`: `,Td(ie.body)]}),(0,J.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!0),"aria-expanded":!1,children:[`Show `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]})]})})},uj=/[\p{L}\p{N}_]+|\s+|[^\p{L}\p{N}_\s]/gu,dj=e=>e.match(uj)??[],fj=e=>{let t=new Map,n=0;for(;n<e.length;){if(e[n]?.kind!==`del`){n++;continue}let r=n;for(;e[n]?.kind===`del`;)n++;let i=n;for(;e[n]?.kind===`add`;)n++;let a=Math.min(i-r,n-i);for(let n=0;n<a;n++){let a=pj(e[r+n]?.text??``,e[i+n]?.text??``);a!==null&&(t.set(r+n,a.old),t.set(i+n,a.new))}}return t},pj=(e,t)=>{if(e.length>500||t.length>500)return null;let n=dj(e),r=dj(t),{inOld:i,inNew:a}=hj(n,r),o=n.reduce((e,t,n)=>e+(i[n]?t.length:0),0),s=e.length+t.length;return s>0&&2*o/s<.3?null:{old:mj(n,i),new:mj(r,a)}},mj=(e,t)=>{let n=[],r=0;return e.forEach((e,i)=>{let a=r+e.length;if(!t[i]){let e=n.at(-1);e?.end===r?n[n.length-1]={start:e.start,end:a}:n.push({start:r,end:a})}r=a}),n},hj=(e,t)=>{let n=e.map(()=>!1),r=t.map(()=>!1),i=new Map([[1,0]]),a=[],o=(e,t)=>a[e]?.[t+e+1]??0,s=0;search:for(let n=0;n<=e.length+t.length;n++){let r=new Int32Array(2*n+3);for(let e=-n-1;e<=n+1;e++)r[e+n+1]=i.get(e)??0;a.push(r);for(let r=-n;r<=n;r+=2){let a=r===-n||r!==n&&(i.get(r-1)??0)<(i.get(r+1)??0)?i.get(r+1)??0:(i.get(r-1)??0)+1,o=a-r;for(;a<e.length&&o<t.length&&e[a]===t[o];)a++,o++;if(i.set(r,a),a>=e.length&&o>=t.length){s=n;break search}}}let c=e.length,l=t.length;for(let e=s;e>=0;e--){let t=c-l,i=t===-e||t!==e&&o(e,t-1)<o(e,t+1)?t+1:t-1,a=o(e,i),s=a-i;for(;c>a&&l>s;)c--,l--,n[c]=!0,r[l]=!0;c=a,l=s}return{inOld:n,inNew:r}},gj=(e,t=null)=>{let n=fj(e.lines);return Mk(e.lines).map(({line:r,text:i,carriageReturn:a},o)=>({key:`${e.id}:${o}`,hunkId:e.id,kind:r.kind,oldNo:r.oldLine,newNo:r.newLine,text:i,tokens:t?.[o]??null,wordRanges:n.get(o)??[],notes:[...a?[`CRLF`]:[],...r.noNewlineAtEnd?[`No newline at end of file`]:[]]}))},_j=e=>e.kind===`del`?e.oldLine===null?null:{side:`old`,line:e.oldLine}:e.newLine===null?null:{side:`new`,line:e.newLine},vj=`sticky left-0 w-[100cqw]`,yj=`pr-3 pl-29`,bj=({inset:e,children:t})=>(0,J.jsx)(`div`,{role:`row`,"data-slot":`line-row`,className:X(e&&X(yj,`py-2`),`font-sans`,vj),children:(0,J.jsx)(`div`,{role:`cell`,children:t})}),xj=(e,t)=>e.side===t.side&&e.line===t.line,Sj=e=>e.startLine===void 0?`Comment on ${e.side===`old`?`old `:``}line ${e.line}`:`Comment on ${e.side===`old`?`old `:``}lines ${e.startLine}–${e.line}`,Cj=(e,t,n)=>{let r=new Map(e.lines.flatMap(e=>e.kind!==`del`&&e.newLine!==null?[[e.newLine,e.text]]:[])),i=[];for(let e=t;e<=n;e+=1){let t=r.get(e);if(t===void 0)return null;i.push(t)}return i},wj=[],Tj=(0,q.memo)(function({id:e,hunk:t,file:n,risk:r,proofs:i=[],highlighted:a=!1,focused:o=!1,onFocus:s,lineLimit:c,unchanged:l=[],comments:u=[],openComment:d=null,onOpenComment:f,onCancelComment:p,onComment:m,onCommentNow:h,afterHeader:g,threadsAt:_,rangeNote:v,inFile:y=!1,marks:b,pointLines:x,pointsAt:S,pointsAtEnd:C,flagged:w}){let T=e??t.id,E=(0,q.useRef)(null),[D,O]=(0,q.useState)(!1),k=Zk(t,n,Xk(E)),A=(0,q.useMemo)(()=>gj(t,k),[t,k]),j=c===void 0||D||A.length<=c?A:A.slice(0,c);(0,q.useEffect)(()=>{let e=E.current;o&&e!==null&&!e.contains(document.activeElement)&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[o]);let M=Nk(t),N=!y||i.length>0,P=f!==void 0&&m!==void 0,F=(e,t)=>{let n=d;if(n!==null&&n.side===e.side&&n.line===e.line)f?.(T,null);else if(t&&n!==null&&n.side===e.side){let t=Math.min(n.startLine??n.line,e.line),r=Math.max(n.line,e.line);f?.(T,{side:e.side,line:r,startLine:t})}else f?.(T,e)};return(0,J.jsxs)(`section`,{ref:E,"data-slot":`hunk-card`,"data-risk":r?.riskClass,"data-highlighted":a||void 0,className:X(`relative scroll-mt-24 bg-card -outline-offset-2`,!y&&`overflow-hidden rounded-lg border`,a&&`bg-primary/5 shadow-[inset_0_0_0_2px_var(--ring)]`),"aria-label":`${n.path}, ${Fk(t)}`,tabIndex:0,onFocus:()=>s?.(T),children:[N&&(0,J.jsxs)(`header`,{"data-slot":`hunk-header`,className:X(`flex flex-wrap items-center gap-x-3 gap-y-1 border-b bg-surface-subtle px-3 py-1.5`,y&&`sticky left-0 w-[100cqw]`),children:[!y&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(JD,{file:n,status:n.status}),(0,J.jsx)(YD,{status:n.status}),t.sectionHeading!==null&&(0,J.jsx)(`code`,{className:`font-mono text-code-compact text-diff-hunk-fg`,children:t.sectionHeading}),(0,J.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,M.added]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,M.deleted]})]})]}),i.map(e=>(0,J.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),e.detail]},e.kind)),!y&&r!==null&&(0,J.jsxs)(`span`,{className:`ml-auto`,title:r.reason===``?void 0:r.reason,children:[(0,J.jsx)(tO,{status:cD[r.riskClass]}),r.reason!==``&&(0,J.jsxs)(`span`,{className:`sr-only`,children:[`: `,r.reason]})]})]}),(l.length>0||g!=null)&&(0,J.jsxs)(`div`,{className:X(y&&`sticky left-0 w-[100cqw]`),children:[l.map(e=>(0,J.jsx)(ZD,{callers:e,named:l.length>1},e.symbol)),g]}),(0,J.jsx)(`div`,{role:`table`,"aria-label":`Lines`,className:X(`[content-visibility:auto]`,!y&&`overflow-x-auto`),style:{containIntrinsicSize:`auto ${j.length*20}px`},children:(0,J.jsx)(`div`,{className:`w-max min-w-full`,children:j.map(e=>{let r=_j({kind:e.kind,oldLine:e.oldNo,newLine:e.newNo}),i=r===null?void 0:u.find(e=>xj(e,r)),a=r!==null&&d!==null&&xj(d,r),o=a?d:i,s=r===null?null:_?.(r)??null,c=r===null?null:S?.(r)??null,l=r===null?null:C?.(r)??null,g=r===null?null:`${r.side}:${r.line}`,E=g===null?void 0:x?.get(g);return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(nD,{line:e,cellRole:`cell`,pointKind:E?.kind??null,flagged:g!==null&&w?.has(g)===!0,...l===null?{}:{end:l},...E?.landing===void 0?{}:{pointLanding:E.landing},marks:(e.kind===`del`||e.newNo===null?void 0:b?.get(e.newNo))??wj,marked:r!==null&&m!==void 0&&d!==null&&d.side===r.side&&r.line>=(d.startLine??d.line)&&r.line<=d.line,numberButton:r===null||!P?void 0:{side:r.side,label:Sj(r),onClick:e=>F(r,e.shiftKey)},...r===null||!P?{}:{onRowClick:e=>{window.getSelection()?.isCollapsed!==!1&&(e.target instanceof Element&&e.target.closest(`button`)||F(r,e.shiftKey))}}}),c,r!==null&&o!=null&&(i!==void 0||a&&m!==void 0)&&(0,J.jsx)(Ej,{place:o,comment:i,editing:a&&m!==void 0,shown:(e,n)=>Cj(t,e,n),language:TD(n),rangeNote:v,fileName:n.path.split(`/`).at(-1)??n.path,onChange:m===void 0?void 0:e=>m(T,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e}),onEdit:()=>f?.(T,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine}}),onDone:()=>f?.(T,null),onCancel:()=>p?.(T,o),...h===void 0?{}:{onPostNow:e=>h(T,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e})},pinned:y}),s!==null&&(0,J.jsx)(`div`,{role:`row`,"data-slot":`line-threads`,className:X(yj,`py-2 font-sans`,y&&`sticky left-0 w-[100cqw]`),children:(0,J.jsx)(`div`,{role:`cell`,className:`flex max-w-3xl flex-col gap-2`,children:s})})]},e.key)})})}),j.length<A.length&&(0,J.jsx)(`div`,{className:X(`border-t p-2`,y&&`sticky left-0 w-[100cqw]`),children:(0,J.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>O(!0),children:[`Show all `,A.length,` lines`]})})]})}),Ej=({place:e,comment:t,editing:n,shown:r,language:i,rangeNote:a,fileName:o,onChange:s,onEdit:c,onDone:l,onCancel:u,onPostNow:d,pinned:f})=>{let p=(0,q.useRef)(null),m=(0,q.useRef)(null),[h,g]=(0,q.useState)(`write`),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(null);(0,q.useEffect)(()=>{n?m.current?.focus():(g(`write`),b(null))},[n]);let x=Sj(e),S=t?.body??``,C=t?.suggestion,w={body:S,...C===void 0?{}:{suggestion:C}},T=(0,q.useRef)(null);n?T.current===null&&(T.current=w):T.current=null;let E=e.side===`new`?r(e.startLine??e.line,e.line):null,D=e.startLine===void 0?null:`Lines ${e.startLine}–${e.line}`,O=()=>p.current?.closest(`[data-slot=hunk-card]`)?.focus({preventScroll:!0}),k=()=>s?.({body:``}),A=()=>{O(),S.trim()===``&&C===void 0&&s?.({body:``}),l()},j=async()=>{if(d===void 0||_||S.trim()===``)return;v(!0),b(null);let e=await d(w);v(!1),e===null?(O(),s?.({body:``}),l()):b(e)},M=()=>{O();let e=T.current;s?.(e===null||e.body.trim()===``&&e.suggestion===void 0?{body:``}:e),u?.(),l()},N=e=>(0,J.jsx)(rA,{title:`Suggested change`,removed:E,added:e,language:i});return(0,J.jsx)(`div`,{ref:p,role:`row`,"data-slot":`line-comment`,"data-editing":n||void 0,className:X(yj,`py-2 font-sans`,f&&`sticky left-0 w-[100cqw]`),children:(0,J.jsx)(Ck,{role:`cell`,state:`draft`,className:`flex max-w-3xl flex-col gap-2`,onKeyDown:n?e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(e.defaultPrevented)return;e.preventDefault(),A()}else e.key===`Escape`&&(e.stopPropagation(),M())}:void 0,children:n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,children:[`Commenting on `,(0,J.jsx)(jk,{children:o}),e.startLine===void 0?`line`:`lines`,` `,(0,J.jsx)(jk,{children:Ak(e.side,e.startLine??null,e.line)}),a!==void 0&&e.startLine!==void 0&&(0,J.jsx)(`span`,{children:a})]}),(0,J.jsxs)(JO,{value:h,onValueChange:e=>g(e===`preview`?`preview`:`write`),children:[(0,J.jsxs)(XO,{children:[(0,J.jsx)(ZO,{value:`write`,children:`Write`}),(0,J.jsx)(ZO,{value:`preview`,children:`Preview`})]}),(0,J.jsx)(QO,{value:`write`,children:(0,J.jsx)($O,{ref:m,rows:2,"aria-label":x,placeholder:`Leave a comment`,value:S,onChange:e=>s?.({...w,body:e.target.value}),onSubmitShortcut:A,className:`min-h-14 bg-background`})}),(0,J.jsx)(QO,{value:`preview`,"data-slot":`comment-preview`,className:`min-h-14 rounded-md border px-2.5 py-2`,children:S.trim()===``?(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`Nothing to preview`}):(0,J.jsx)(rj,{blocks:Vd(S).blocks,suggestion:N})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(xk,{hints:[{id:`submit`,action:`add to review`},{id:`close`,action:`cancel`}]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,J.jsx)($,{variant:`ghost`,size:`sm`,disabled:_,onClick:M,children:`Cancel`}),d!==void 0&&(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:_||S.trim()===``,onClick:()=>void j(),children:_?`Posting…`:`Comment now`}),(0,J.jsx)($,{size:`sm`,disabled:_,onClick:A,children:`Add to review`})]})]}),y!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ Not posted: `,y,` Your comment is still here.`]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[x,`: `]}),(0,J.jsx)(`span`,{className:X(ij,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:s===void 0?`Posted with your review`:`Draft · posts with your review`}),D!==null&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:D})]}),S.trim()!==``&&(0,J.jsx)(rj,{blocks:Vd(S).blocks,suggestion:N}),C!==void 0&&N(C),s!==void 0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Edit`}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,onClick:k,children:`Discard`})]})]})})})},Dj=()=>YE(),Oj=({handle:e,payload:t,id:n,render:r=(0,J.jsx)(`span`,{}),children:i})=>(0,J.jsx)(JE,{handle:e,payload:t,id:n,delay:300,closeDelay:150,render:r,"data-slot":`call`,className:`underline decoration-current decoration-dotted underline-offset-3 hover:decoration-primary hover:decoration-solid data-popup-open:decoration-primary data-popup-open:decoration-solid`,children:i}),kj=({handle:e,onGoTo:t})=>(0,J.jsx)(qE,{handle:e,children:({payload:n})=>n===void 0?null:(0,J.jsx)(XE,{side:`bottom`,align:`start`,"aria-label":n.label??`Code ${n.symbol} runs`,className:`flex max-h-[min(26rem,60vh)] w-[min(44rem,calc(100vw-2rem))] flex-col overflow-hidden p-0`,children:(0,J.jsx)(Aj,{payload:n,onGoTo:n=>{e.close(),t(n)}})})}),Aj=({payload:e,onGoTo:t})=>{let n=(0,q.useRef)(null),r=e.targets[0],i=r===void 0?null:`${r.hunk.id}:${Mj(r.hunk,e.symbol)}`;return(0,q.useEffect)(()=>{let e=n.current,t=i===null?null:e?.querySelector(`[data-line="${i}"]`),r=e?.querySelector(`header`);e!=null&&t!=null&&(e.scrollTop=t.offsetTop-(r?.offsetHeight??0))},[i]),(0,J.jsx)(`div`,{ref:n,"data-slot":`peek-scroller`,className:`@container relative min-h-0 overflow-auto`,children:(0,J.jsx)(`div`,{className:`w-max min-w-full`,children:e.targets.map((n,r)=>(0,J.jsx)(jj,{target:n,symbol:e.symbol,onGoTo:t,divided:r>0,last:r===e.targets.length-1},n.id))})})},jj=({target:e,symbol:t,onGoTo:n,divided:r,last:i})=>{let{hunk:a,file:o}=e,s=Zk(a,o,!0),c=(0,q.useMemo)(()=>gj(a,s),[a,s]),l=Nk(a),u=Fk(a);return(0,J.jsxs)(`section`,{"aria-label":`${o.path}, ${u}`,className:r?`border-t`:void 0,children:[(0,J.jsxs)(`header`,{className:X(vj,`top-0 z-[2] flex flex-wrap items-center gap-x-3 gap-y-1 border-b bg-surface-subtle px-3 py-1 text-caption`),children:[(0,J.jsx)(JD,{file:o,status:o.status}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:u}),(0,J.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,l.added]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,l.deleted]})]}),(0,J.jsx)($,{variant:`link`,size:`xs`,className:`ml-auto px-0`,onClick:()=>n(e.id),children:`Go to file`})]}),(0,J.jsx)(`div`,{role:`table`,"aria-label":`Lines of ${t}`,className:`w-max min-w-full`,children:c.map(e=>(0,J.jsx)(nD,{line:e,layout:`split-new`,cellRole:`cell`,density:`compact`},e.key))}),i&&(0,J.jsx)(aD,{kind:c.at(-1)?.kind??`context`,className:`h-3`})]})},Mj=(e,t)=>{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=RegExp(`(?<![\\w$])${n}(?![\\w$])`),i=RegExp(`\\b(def|class|function|func|fn|const|let|var|type|interface|enum|struct|trait|impl)\\b[^=(]*?(?<![\\w$])${n}(?![\\w$])`),a=e.lines.map((e,t)=>({line:e,at:t})).filter(({line:e})=>e.kind!==`del`);return a.find(({line:e})=>i.test(e.text))?.at??a.find(({line:e})=>r.test(e.text))?.at??0},Nj=q.createContext(void 0);function Pj(){return q.useContext(Nj)}function Fj(e){let{render:t,className:n,style:r,state:i=Jv,props:a=qv,refs:o=qv,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=xO({metadata:s});return Qv(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var Ij=q.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=gE(u||void 0),h=Pj(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=nO({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=Pv({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=Ab(Mb,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=Qv(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=q.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,J.jsx)(Fj,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),Lj=q.createContext(void 0);function Rj(e){let t=q.useContext(Lj);if(t===void 0&&!e)throw Error(Ov(69));return t}var zj=cy(`group/toggle inline-flex items-center justify-center gap-1 rounded-md text-ui font-medium whitespace-nowrap transition-all hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-background aria-pressed:text-foreground aria-pressed:shadow-sm aria-pressed:ring-1 aria-pressed:ring-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-md px-2.5 text-ui has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}});function Bj({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,J.jsx)(Ij,{"data-slot":`toggle`,className:X(zj({variant:t,size:n,className:e})),...r})}q.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});var Vj=(e,t)=>{let n=new Set,r=e=>{let r=t.filter(t=>!n.has(t)&&e(t));for(let e of r)n.add(e);return r},i=e.flatMap(e=>{let t=r(t=>t.path===e.path&&t.hunkId===null).map(t=>({key:`${e.path}\0${t.kind}`,path:e.path,file:e,hunk:null,proofs:[t],summary:Hj(t,e)})),n=e.hunks.flatMap(t=>{let n=r(e=>e.hunkId===t.id);if(n.length===0)return[];let{added:i,deleted:a}=Nk(t),o=n.map(e=>e.detail).join(`; `);return[{key:t.id,path:e.path,file:e,hunk:t,proofs:n,summary:`${e.path} — ${o} (+${i} −${a})`}]});return[...t,...n]}),a=t.filter(e=>!n.has(e)).map((e,t)=>({key:`orphan-${t}`,path:e.path,file:null,hunk:null,proofs:[e],summary:`${e.path} — ${e.detail}`}));return[...i,...a]},Hj=(e,t)=>e.kind===`rename`&&t.oldPath!==null?`${t.oldPath} → ${t.path} — renamed, content unchanged`:`${t.path} — ${e.detail}`,Uj=`flex min-h-8 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-muted-foreground`,Wj=({open:e,children:t,...n})=>(0,J.jsxs)(`button`,{type:`button`,"data-slot":`mechanical-toggle`,"aria-expanded":e,className:X(Uj,`hover:bg-accent hover:text-accent-foreground`),...n,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 transition-transform duration-(--duration-fast) ease-standard`,!e&&`-rotate-90`),children:`▾`}),(0,J.jsx)(`span`,{className:`min-w-0`,children:t})]}),Gj=(0,q.memo)(function({hunk:e,file:t,risk:n,proofs:r,focused:i=!1,onFocus:a}){let o=(0,q.useRef)(null),[s,c]=(0,q.useState)(!1),{added:l,deleted:u}=Nk(e);return(0,q.useEffect)(()=>{let e=o.current;i&&e!==null&&e!==document.activeElement&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[i]),(0,J.jsxs)(`div`,{"data-slot":`mechanical-hunk`,className:`bg-surface-subtle`,children:[(0,J.jsxs)(Wj,{ref:o,open:s,onClick:()=>c(e=>!e),onFocus:()=>a?.(e.id),children:[t.path,`, `,Fk(e),` — `,r.map(e=>e.detail).join(`; `),` (+`,l,` −`,u,`)`]}),s&&(0,J.jsx)(Tj,{hunk:e,file:t,risk:n,proofs:r,lineLimit:500})]})}),Kj=({files:e,proofs:t,risk:n})=>{let r=(0,q.useId)(),i=(0,q.useMemo)(()=>Vj(e,t),[e,t]),[a,o]=(0,q.useState)(new Set),s=i.filter(e=>e.hunk!==null).map(e=>e.key),c=s.length>0&&s.every(e=>a.has(e));if(i.length===0)return null;let l=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,J.jsxs)(`section`,{"aria-labelledby":r,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`h2`,{id:r,className:`flex items-center gap-2 text-heading font-semibold`,children:[`Mechanical changes`,` `,(0,J.jsx)(`span`,{className:`tabular rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground`,children:i.length})]}),s.length>0&&(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>o(new Set(c?[]:s)),children:c?`Collapse all`:`Expand all`})]}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>{let t=a.has(e.key);return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[e.hunk===null||e.file===null?(0,J.jsxs)(`span`,{className:Uj,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0`}),e.summary]}):(0,J.jsx)(Wj,{open:t,onClick:()=>l(e.key),children:e.summary}),t&&e.hunk!==null&&e.file!==null&&(0,J.jsx)(Tj,{hunk:e.hunk,file:e.file,risk:n.find(t=>t.hunkId===e.hunk?.id)??null,proofs:e.proofs,lineLimit:500})]},e.key)})})]})},qj={added:`added`,deleted:`deleted`,modified:`changed`,renamed:`changed`},Jj=e=>e.flatMap(e=>{let t=e.oldMode!==null||e.newMode!==null,n=!e.binary&&!t&&e.hunks.length===0&&e.status!==`renamed`;return[...e.binary?[{key:`${e.path}\0binary`,file:e,text:`binary file ${qj[e.status]}`}]:[],...t?[{key:`${e.path}\0mode`,file:e,text:`mode ${e.oldMode??`unknown`} → ${e.newMode??`unknown`}`}]:[],...n?[{key:`${e.path}\0empty`,file:e,text:e.status===`modified`?`changed, no lines to show`:`empty file ${e.status}`}]:[]]}),Yj=({files:e})=>{let t=(0,q.useId)(),n=Jj(e);return n.length===0?null:(0,J.jsxs)(`section`,{"aria-labelledby":t,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,J.jsx)(`h2`,{id:t,className:`text-heading font-semibold`,children:`Changes without lines to show`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(({key:e,file:t,text:n})=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(JD,{file:t,status:t.status}),(0,J.jsx)(YD,{status:t.status}),(0,J.jsx)(`span`,{children:n})]},e))})]})},Xj=({hunkId:e,lines:t})=>t.length===0?null:(0,J.jsx)(`div`,{role:`table`,"aria-label":`Unchanged lines`,children:(0,J.jsx)(`div`,{className:`w-max min-w-full`,children:t.map(({oldNo:t,newNo:n,text:r,tokens:i})=>{let a={key:`${e}:unchanged:${n}`,hunkId:e,kind:`context`,oldNo:t,newNo:n,text:r,tokens:i,wordRanges:[],notes:[]};return(0,J.jsx)(nD,{line:a,cellRole:`cell`},n)})})}),Zj=q.createContext(void 0);function Qj(e){let t=q.useContext(Zj);if(t===void 0&&!e)throw Error(Ov(47));return t}var $j={...Cw,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Cw.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Cw.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Cw.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},eM=class extends mw{constructor(e,t,n){let r=new tw;super(tM(e,r,t,n),nM(r),$j)}setOpen=(e,t)=>{let n=t.reason===Pb,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=JC(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=qC(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),US.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function tM(e,t,n,r=!1){let i={..._w(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function nM(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new yy,stickIfOpen:!0,triggerElements:e}}var rM=my(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=aM(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),ew(u,d),ZC(u);let{forceUnmount:m}=QC(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ab(Yb))}),[m,u]);let h=d||f||s!=null;return(0,J.jsxs)(Zj.Provider,{value:u,children:[s&&(0,J.jsx)(WC,{handle:s,store:u}),h&&(0,J.jsx)(oM,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function iM(e){return Qj(!0)?(0,J.jsx)(rM,{props:e}):(0,J.jsx)(rC,{children:(0,J.jsx)(rM,{props:e})})}function aM(e,t){let n=UC((e,n)=>new eM(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function oM({store:e,modal:t}){let n=bC(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return $C(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}function sM(e,t){function n(n,r,i){let a=n.currentTarget;US.flushSync(()=>{e.setOpen(!1,Ab(zb,n.nativeEvent,a))}),pS(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&mS(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var cM=hy(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=Qj(!0),h=ww(s)??m;if(!h)throw Error(Ov(74));let g=gE(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=q.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=XC(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=Fw(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:Zw(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=mC(v,{stickIfOpen:Z(()=>h.context.stickIfOpen)}),k=RA(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=Pv({disabled:a,native:o}),N={open(e){return w?pb.open(e):fb.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=sM(h,x),I=Qv(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[zS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,J.jsx)(q.Fragment,{children:I},g);return E?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(fx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,J.jsx)(fx,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),lM=q.createContext(void 0);function uM(){let e=q.useContext(lM);if(e===void 0)throw Error(Ov(45));return e}var dM=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Qj().useState(`mounted`)||n?(0,J.jsx)(lM.Provider,{value:n,children:(0,J.jsx)(JS,{ref:t,...r})}):null}),fM=q.createContext(void 0);function pM(){let e=q.useContext(fM);if(!e)throw Error(Ov(46));return e}function mM(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=q.useRef(null),o=q.useRef(null),s=RC(r);Q(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Q(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var hM=20;function gM(e,t,n,r){let[i,a]=q.useState(!1);Q(()=>{if(!e||!t||n==null){a(!1);return}let r=Mv(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-hM)},[e,t,n]),DA(e&&(!t||i),r)}var _M=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=VS,..._}=e,v=Qj(),y=uM(),b=tC(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=IE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});mM({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;gM(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=BE(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,J.jsxs)(fM.Provider,{value:j,children:[S&&M&&(0,J.jsx)(hA,{inert:UE(!C),cutout:T}),(0,J.jsx)(nC,{id:b,children:P})]})}),vM=q.createContext(void 0);function yM(){let[e,t]=q.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var bM=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Qj(),l=pM(),u=Rj(!0)!=null,{context:d,hasClosePart:f}=yM(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);zC({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Nw(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?HC(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Qv(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...VC,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&IO.has(e.key)&&e.stopPropagation()}},zE(g),s],stateAttributesMapping:hb});return(0,J.jsx)(pC,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:B_(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,J.jsx)(vM.Provider,{value:d,children:M})})}),xM=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Qj(),s=gE(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),Qv(`h2`,e,{ref:t,props:[{id:s},a]})});function SM({...e}){return(0,J.jsx)(iM,{"data-slot":`popover`,...e})}function CM({...e}){return(0,J.jsx)(cM,{"data-slot":`popover-trigger`,...e})}function wM({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,J.jsx)(dM,{children:(0,J.jsx)(_M,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,J.jsx)(bM,{"data-slot":`popover-content`,className:X(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-xl bg-popover p-2.5 text-ui text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-(--duration-fast) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function TM({className:e,...t}){return(0,J.jsx)(xM,{"data-slot":`popover-title`,className:X(`font-medium`,e),...t})}var EM={open:Sg,draft:Eg,merged:bg,closed:wg},DM=({state:e})=>{let{label:t,className:n}=uD[e],r=EM[e];return(0,J.jsxs)(eO,{"data-slot":`pr-state`,variant:`outline`,className:n,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),t]})},OM=({status:e})=>e===null?null:(0,J.jsx)(`span`,{"data-slot":`review-status`,children:(0,J.jsx)(tO,{status:dD[e]})}),kM=e=>{switch(e.state){case`failed`:return`CI ${e.failed} of ${e.total} failed`;case`running`:return`CI ${e.running} of ${e.total} running`;case`skipped`:return`CI ${e.skipped} skipped`;default:return`CI ${e.passed}/${e.total} passed`}},AM=e=>{let t=e=>`${e} ${e===1?`check`:`checks`}`;switch(e.state){case`failed`:return`CI: ${e.failed} of ${t(e.total)} failed`;case`running`:return`CI: ${e.running} of ${t(e.total)} running`;case`skipped`:return`CI: ${t(e.skipped)} skipped`;default:return`CI: ${e.passed} of ${t(e.total)} passed`}},jM=`h-6 gap-1.5 px-1.5 font-normal text-muted-foreground`,MM=({check:e})=>{let t=fD[e.state];return(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 text-center`,t.tone),children:t.glyph}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),(0,J.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:t.label}),e.url!==null&&(0,J.jsx)(`a`,{className:`shrink-0 text-caption`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`Details of ${e.name}`,children:`Details`})]})},NM=({checks:e,unreadable:t,head:n})=>{let r=e===null?null:cf(e),i=r===null||r.state===null?null:AM(r),a=PM(i);if(e===null)return(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:jM,"data-slot":`ci-summary`,children:`CI not readable`})}),(0,J.jsxs)(wM,{align:`end`,children:[(0,J.jsx)(TM,{children:`CI not readable`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:t})]})]});if(r===null||r.state===null)return null;let o=fD[r.state];return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsxs)($,{variant:`ghost`,size:`xs`,className:jM,"data-slot":`ci-summary`,"data-state":r.state,"aria-label":`${i}, show checks`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:o.tone,children:o.glyph}),(0,J.jsx)(`span`,{className:`tabular`,children:kM(r)})]})}),(0,J.jsxs)(wM,{align:`end`,className:`w-96`,children:[(0,J.jsxs)(TM,{children:[`Checks on `,(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:n.slice(0,7)})]}),(0,J.jsx)(`ul`,{className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,"aria-label":`Checks`,children:sf(e).map(e=>(0,J.jsx)(MM,{check:e},`${e.name}:${e.url??``}`))})]})]}),(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:a})]})},PM=e=>{let t=(0,q.useRef)(void 0),[n,r]=(0,q.useState)(``);return(0,q.useEffect)(()=>{t.current===void 0?t.current=e:e!==null&&e!==t.current&&(t.current=e,r(e))},[e]),n},FM={"changes-requested":b_,approved:Rh,commented:Kg},IM=3,LM=({reviewer:e})=>{let t=e.verdict===null?null:FM[e.verdict];return(0,J.jsxs)(`span`,{className:`relative flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-caption font-medium text-muted-foreground ring-2 ring-background`,children:[wk(e.name),t!==null&&e.verdict!==null&&(0,J.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 flex size-3 items-center justify-center rounded-full bg-background`,children:(0,J.jsx)(t,{className:X(`size-2.5`,pD[e.verdict].tone),strokeWidth:3.5})})]})},RM=e=>{let t=new Map;for(let n of e){let e=pD[n.verdict??`waiting`].label.toLowerCase();t.set(e,(t.get(e)??0)+1)}let n=[...t].map(([e,t])=>`${t} ${e}`);return`${`${e.length} ${e.length===1?`reviewer`:`reviewers`}`}: ${n.join(`, `)}`},zM=({reviewers:e})=>{if(e.length===0)return null;let t=af(e),n=t.length>IM?t.slice(0,2):t,r=t.length-n.length;return(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:`h-7 px-1`,"data-slot":`reviewers`,"aria-label":`${RM(t)}, show reviewers`,children:(0,J.jsxs)(`span`,{"aria-hidden":`true`,className:`flex items-center -space-x-1`,children:[n.map(e=>(0,J.jsx)(LM,{reviewer:e},e.id)),r>0&&(0,J.jsxs)(`span`,{className:`flex size-6 items-center justify-center rounded-full bg-muted text-caption font-medium text-muted-foreground ring-2 ring-background`,children:[`+`,r]})]})})}),(0,J.jsxs)(wM,{align:`end`,children:[(0,J.jsx)(TM,{children:`Reviewers`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Reviewers`,children:t.map(e=>{let t=pD[e.verdict??`waiting`];return(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:(0,J.jsx)(LM,{reviewer:e})}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,e.team&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` (team)`})]}),(0,J.jsx)(`span`,{className:X(`shrink-0 text-caption`,t.tone),children:t.label})]},e.id)})})]})]})};function BM(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var VM=e=>{switch(e){case`success`:return WM;case`info`:return KM;case`warning`:return GM;case`error`:return qM;default:return null}},HM=Array(12).fill(0),UM=({visible:e,className:t})=>q.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},q.createElement(`div`,{className:`sonner-spinner`},HM.map((e,t)=>q.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),WM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),GM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),KM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),qM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),JM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},q.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),q.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),YM=()=>{let[e,t]=q.useState(document.hidden);return q.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},XM=1,ZM=100,QM=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:XM++,$M=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-ZM;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=QM(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],q.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(tN(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=QM(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},eN=(e,t)=>$M.message(e,t),tN=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`;Object.assign(eN,{success:$M.success,info:$M.info,warning:$M.warning,error:$M.error,custom:$M.custom,message:$M.message,promise:$M.promise,dismiss:$M.dismiss,loading:$M.loading},{getHistory:()=>$M.toasts,getToasts:()=>$M.getActiveToasts()}),BM(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function nN(e){return e.label!==void 0}var rN=3,iN=`24px`,aN=`16px`,oN=4e3,sN=356,cN=14,lN=45,uN=200;function dN(...e){return e.filter(Boolean).join(` `)}function fN(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var pN=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=q.useState(null),[O,k]=q.useState(null),[A,j]=q.useState(!1),[M,N]=q.useState(!1),[P,F]=q.useState(!1),[I,L]=q.useState(!1),[R,ee]=q.useState(!1),[z,te]=q.useState(0),[B,ne]=q.useState(0),V=q.useRef(n.duration||y||oN),H=q.useRef(null),re=q.useRef(null),ie=c===0,ae=c+1<=o,oe=n.type,se=oe??`default`,U=n.dismissible!==!1,ce=n.className||``,le=n.descriptionClassName||``,ue=q.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),de=q.useMemo(()=>n.closeButton??p,[n.closeButton,p]),fe=q.useMemo(()=>n.duration||y||oN,[n.duration,y]),pe=q.useRef(0),me=q.useRef(0),he=q.useRef(0),ge=q.useRef(null),[_e,ve]=b.split(`-`),ye=q.useMemo(()=>s.reduce((e,t,n)=>n>=ue?e:e+t.height,0),[s,ue]),be=YM(),xe=q.useMemo(()=>e.swipeDirections??fN(b),[e.swipeDirections,b]),Se=n.invert||t,Ce=oe===`loading`;me.current=q.useMemo(()=>ue*x+ye,[ue,ye]),q.useEffect(()=>{V.current=fe},[fe]),q.useEffect(()=>{j(!0)},[]),q.useEffect(()=>{let e=re.current;if(e){let t=e.getBoundingClientRect().height;return ne(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),q.useLayoutEffect(()=>{if(!A)return;let e=re.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ne(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let we=q.useCallback(()=>{N(!0),te(me.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},uN)},[n,d,a,me]);q.useEffect(()=>{if(n.promise&&oe===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||be?(()=>{if(he.current<pe.current){let e=new Date().getTime()-pe.current;V.current-=e}he.current=new Date().getTime()})():V.current!==1/0&&(pe.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),we()},V.current)),()=>clearTimeout(e)},[u,i,n,oe,be,we]),q.useEffect(()=>{n.delete&&(we(),n.onDismiss==null||n.onDismiss.call(n,n))},[we,n.delete]);function Te(){return w?.loading?q.createElement(`div`,{className:dN(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":oe===`loading`},w.loading):q.createElement(UM,{className:dN(C?.loader,n?.classNames?.loader),visible:oe===`loading`})}let Ee=n.icon||w?.[oe]||VM(oe);return q.createElement(`li`,{tabIndex:0,ref:re,className:dN(_,ce,C?.toast,n?.classNames?.toast,C?.[se],n?.classNames?.[se]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":ae,"data-y-position":_e,"data-x-position":ve,"data-index":c,"data-front":ie,"data-swiping":P,"data-dismissible":U,"data-type":oe,"data-invert":Se,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?z:me.current}px`,"--initial-height":S?`auto`:`${B}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),ge.current=null},onPointerDown:e=>{e.button!==2&&!Ce&&U&&(H.current=new Date,te(me.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),ge.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{if(I||!U)return;ge.current=null;let e=Number(re.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(re.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-H.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if((E===`x`?xe.includes(e>0?`right`:`left`):xe.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=lN||a>.11))te(me.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),we(),L(!0);else{var o,s;(o=re.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=re.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),ee(!1),F(!1),D(null)}},onPointerMove:e=>{var t,n;if(!ge.current||!U||window.getSelection()?.toString().length>0)return;let r=e.clientY-ge.current.y,i=e.clientX-ge.current.x;!E&&(Math.abs(i)>1||Math.abs(r)>1)&&D(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(xe.includes(`top`)||xe.includes(`bottom`)){if(xe.includes(`top`)&&r<0||xe.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(E===`x`&&(xe.includes(`left`)||xe.includes(`right`))){if(xe.includes(`left`)&&i<0||xe.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&ee(!0),(t=re.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=re.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},de&&!n.jsx&&oe!==`loading`?q.createElement(`button`,{"aria-label":T,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!U?()=>{}:()=>{we(),n.onDismiss==null||n.onDismiss.call(n,n)},className:dN(C?.closeButton,n?.classNames?.closeButton)},w?.close??JM):null,(oe||n.icon||n.promise)&&n.icon!==null&&(w?.[oe]!==null||n.icon)?q.createElement(`div`,{"data-icon":``,className:dN(C?.icon,n?.classNames?.icon)},oe===`loading`?n.icon||Te():n.promise?Te():null,oe===`loading`?null:Ee):null,q.createElement(`div`,{"data-content":``,className:dN(C?.content,n?.classNames?.content)},q.createElement(`div`,{"data-title":``,className:dN(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?q.createElement(`div`,{"data-description":``,className:dN(v,le,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),q.isValidElement(n.cancel)?n.cancel:n.cancel&&nN(n.cancel)?q.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{nN(n.cancel)&&U&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),we())},className:dN(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,q.isValidElement(n.action)?n.action:n.action&&nN(n.action)?q.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{nN(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&we())},className:dN(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function mN(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function hN(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?aN:iN;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var gN=q.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=rN,toastOptions:g,dir:_=mN(),gap:v=cN,icons:y,customAriaLabel:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=q.useState([]),w=q.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=q.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=q.useState([]),[O,k]=q.useState(!1),[A,j]=q.useState(!1),[M,N]=q.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=q.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=q.useRef(null),L=q.useRef(!1),R=q.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||$M.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return q.useEffect(()=>$M.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{US.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),q.useEffect(()=>{if(d!==`system`){N(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?N(`dark`):N(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{N(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{N(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),q.useEffect(()=>{S.length<=1&&k(!1)},[S]),q.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=P.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===P.current||P.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),q.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),q.createElement(`section`,{ref:t,"aria-label":b??`${x} ${F}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?q.createElement(`ol`,{key:t,dir:_===`auto`?mN():_,tabIndex:-1,ref:P,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${sN}px`,"--gap":`${v}px`,...m,...hN(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>q.createElement(pN,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:R,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:v,expanded:O,swipeDirections:e.swipeDirections}))):null}))});function _N({className:e,...t}){return(0,J.jsx)(`label`,{"data-slot":`label`,className:X(`flex items-center gap-2 text-ui leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var vN=`data-valid`,yN=`data-invalid`,bN={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},xN={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},SN={valid(e){return e===null?null:e?{[vN]:``}:{[yN]:``}}},CN={invalid:void 0,name:void 0,validityData:{state:bN,errors:[],error:``,value:``,initialValue:null},setValidityData:Kv,disabled:void 0,setTouched:Kv,setDirty:Kv,setFilled:Kv,setFocused:Kv,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:xN,registerFieldControl:Kv,validation:{getValidationProps:(e,t=Jv)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Kv,getInputControl:()=>null,commit:async()=>{},change:Kv}},wN=q.createContext(CN);function TN(e=!0){let t=q.useContext(wN);if(t.setValidityData===Kv&&!e)throw Error(Ov(28));return t}function EN(e,t,n){let{setFocused:r,focusOwnerRef:i}=TN(),a=Z(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return Q(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var DN=q.createContext({controlId:void 0,registerControlId:Kv,resetControlId:Kv,labelId:void 0,setLabelId:Kv,messageIds:[],setMessageIds:Kv,getDescriptionProps:e=>e});function ON(){return q.useContext(DN)}function kN(e,t,n,r=!0,i,a){let[o,s]=q.useState(),c=gE(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return Q(()=>{let i=e||t||l||!r?void 0:AN(n.current,c);o!==i&&s(i)}),u}function AN(e,t){let n=jN(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function jN(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function MN(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=ON(),o=gE(),s=sv(()=>Symbol()),c=q.useRef(!1),l=q.useRef(!1),u=Z(()=>{c.current&&i!==Kv&&(c.current=!1,i(s.current,void 0))});return Q(()=>{if(!n||i===Kv){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),Q(()=>u,[u]),(n?r:void 0)??t??o}function NN(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function PN(e,t,n,r,i=!0,a){let{registerFieldControl:o}=TN(),s=sv(()=>Symbol());Q(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),Q(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var FN=q.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Kv,validationMode:`onSubmit`,submitCountRef:{current:0}});function IN(){return q.useContext(FN)}var LN=`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,RN=`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`;function zN({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`skeleton`,className:X(`animate-pulse rounded-md bg-muted`,e),...t})}var BN={muted:`bg-muted text-muted-foreground`,done:`bg-review-approved-bg text-review-approved`,info:`bg-diff-hunk-bg text-diff-hunk-fg`},VN=({glyph:e,title:t,body:n,actions:r=[],tone:i=`muted`,inline:a=!1})=>(0,J.jsxs)(`div`,{className:X(`flex flex-col gap-2`,a?`items-start p-3`:`mx-auto max-w-sm items-center px-6 py-12 text-center`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex items-center justify-center rounded-full font-semibold`,a?`size-7 text-ui`:`size-10 text-heading`,BN[i]),children:e}),(0,J.jsx)(`p`,{className:X(`font-semibold`,a?`text-ui`:`text-heading`),children:t}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:n}),r.length>0&&(0,J.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:r.map((e,t)=>(0,J.jsxs)($,{variant:t===0?`outline`:`ghost`,size:`sm`,onClick:e.onClick,children:[e.label,e.shortcut!==void 0&&(0,J.jsx)(bk,{id:e.shortcut})]},e.label))})]}),HN=({lines:e=7})=>(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Loading the diff`,className:`overflow-hidden rounded-lg border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex h-10 items-center gap-3 border-b px-3`,children:[(0,J.jsx)(zN,{className:`h-3 w-3`}),(0,J.jsx)(zN,{className:`h-3 w-56`}),(0,J.jsx)(zN,{className:`ml-auto h-3 w-12`})]}),(0,J.jsx)(`div`,{className:`flex flex-col py-1`,children:Array.from({length:e},(e,t)=>(0,J.jsxs)(`div`,{className:`flex h-5 items-center gap-3 px-3`,children:[(0,J.jsx)(zN,{className:`h-2.5 w-8`}),(0,J.jsx)(zN,{className:`h-2.5`,style:{width:`${30+t*37%55}%`}})]},t))})]}),UN=({rows:e=8})=>(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Loading the files`,className:`flex flex-col gap-2 px-1`,children:[(0,J.jsx)(zN,{className:`h-7 w-full`}),Array.from({length:e},(e,t)=>(0,J.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,style:{paddingLeft:`${t%3*12}px`},children:[(0,J.jsx)(zN,{className:`h-2.5 flex-1`}),(0,J.jsx)(zN,{className:`h-2.5 w-10`})]},t))]}),WN=q.createContext(void 0);function GN(){let e=q.useContext(WN);if(e===void 0)throw Error(Ov(63));return e}var KN=`data-checked`,qN=`data-unchecked`,JN={...SN,checked(e){return e?{[KN]:``}:{[qN]:``}}},YN=q.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=IN(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,validationMode:E,disabled:D,name:O,validation:k}=TN(),{labelId:A}=ON(),j=D||m,M=O??l,N=q.useRef(null),P=Lv(N,c,k.inputRef),F=q.useRef(null),I=EN(j,F),L=gE(),R=MN({id:s}),ee=u?void 0:R,[z,te]=nO({controlled:n,default:!!i,name:`Switch`,state:`checked`});PN(F,L,z,void 0,!j,l),Q(()=>{T(z)},[z,T]),LA(z,()=>{b(M),C(z!==w.initialValue),k.change(z)});let{getButtonProps:B,buttonRef:ne}=Pv({disabled:j,native:u}),V=kN(a,A,N,!u,ee,y[`aria-label`]),H={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":V,onFocus(){I(!0)},onBlur(){let e=N.current;e&&!j&&(S(!0),I(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){if(f||j)return;e.preventDefault();let t=N.current;t&&Nv(t,e)}},re={...k.getValidationProps(j),checked:z,disabled:j,form:o,id:ee,name:M,required:p,style:M?dx:ux,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:P,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Ab(Mb,e.nativeEvent);d?.(t,n),!n.isCanceled&&te(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?Jv:{value:_}},ie=q.useMemo(()=>({...x,checked:z,disabled:j,readOnly:f,required:p}),[x,z,j,f,p]),ae=Qv(`span`,e,{state:ie,ref:[t,F,ne],props:[H,y,B,e=>k.getValidationProps(j,e)],stateAttributesMapping:JN});return(0,J.jsxs)(WN.Provider,{value:ie,children:[ae,!z&&M&&g!==void 0&&(0,J.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,J.jsx)(`input`,{...re,suppressHydrationWarning:!0})]})}),XN=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Qv(`span`,e,{state:GN(),ref:t,stateAttributesMapping:JN,props:a})});function ZN({className:e,size:t=`default`,...n}){return(0,J.jsx)(YN,{"data-slot":`switch`,"data-size":t,className:X(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] data-checked:bg-primary data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,J.jsx)(XN,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}var QN=[{scope:`global`,title:`Anywhere`},{scope:`diff`,title:`In the code`},{scope:`overview`,title:`In the overview`},{scope:`tree`,title:`In the file tree`},{scope:`composer`,title:`Writing a comment or review`},{scope:`picker`,title:`On the pull requests page`}],$N=({open:e,onOpenChange:t,ids:n})=>{let r=ek.filter(e=>n===void 0||n.includes(e.id)),[i,a]=gk(),o=(0,q.useMemo)(dk,[]),s=(0,q.useId)();return(0,J.jsx)(BA,{open:e,onOpenChange:t,children:(0,J.jsxs)(UA,{className:`max-h-[85vh] overflow-y-auto sm:max-w-lg`,children:[(0,J.jsxs)(WA,{children:[(0,J.jsx)(GA,{children:`Keyboard shortcuts`}),(0,J.jsx)(KA,{children:`Keys don't fire while you type in a field.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,J.jsxs)(_N,{htmlFor:s,className:`leading-snug`,children:[`Single-key shortcuts`,(0,J.jsx)(`span`,{className:`block text-caption font-normal text-muted-foreground`,children:`Letter keys like n and c. Off if they get in the way of speech input or another tool.`})]}),(0,J.jsx)(ZN,{id:s,checked:i,onCheckedChange:a})]}),QN.filter(({scope:e})=>r.some(t=>t.scope===e)).map(({scope:e,title:t})=>(0,J.jsxs)(`section`,{"aria-label":t,className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:t}),(0,J.jsx)(`dl`,{className:`flex flex-col`,children:r.filter(t=>t.scope===e).map(e=>{let t=!i&&e.chords.every(ak);return(0,J.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-4 border-b py-1 last:border-0`,children:[(0,J.jsxs)(`dt`,{className:t?`text-muted-foreground line-through`:void 0,children:[e.action,t&&(0,J.jsx)(`span`,{className:`sr-only`,children:` (off)`})]}),(0,J.jsx)(`dd`,{className:`flex gap-2`,children:e.chords.map(e=>(0,J.jsx)(yk,{children:sk(e,o).map(e=>(0,J.jsx)(vk,{children:e},e))},sk(e,o).join(` `)))})]},e.id)})})]},e))]})})},eP=q.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:y,validationMode:b,validation:x}=TN(),{clearErrors:S,elementRef:C,submitCountRef:w}=IN(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=ON(),k=MN({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=Z(()=>x.inputRef.current?.value);PN(x.inputRef,k,j,M,!T,a),Q(()=>{let e=j??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[j,l,x.inputRef,y]),LA(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=q.useRef(null),P=EN(T,N),F=by();return Qv(`input`,e,{ref:[t,N],state:D,props:[{id:k,disabled:T,name:E,ref:x.inputRef,"aria-labelledby":O,autoFocus:u,...A?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Ab(Mb,e.nativeEvent);c?.(t,n),!A&&(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(S(E),x.change(t)))},onFocus(){P(!0)},onBlur(e){if(g(!0),P(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),A&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===C.current&&!e.defaultPrevented){let t=e.currentTarget,n=w.current;F.start(0,()=>{w.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(T,e)],stateAttributesMapping:SN})}),tP=q.forwardRef(function(e,t){return(0,J.jsx)(eP,{ref:t,...e})});function nP({className:e,type:t,...n}){return(0,J.jsx)(tP,{type:t,"data-slot":`input`,className:X(`h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-ui transition-colors file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-ui file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20`,e),...n})}var rP=q.createContext(void 0);function iP(){let e=q.useContext(rP);if(e===void 0)throw Error(Ov(53));return e}function aP(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var oP=`base-ui-disable-scrollbar`,sP={className:oP,getElement(e){return(0,J.jsx)(`style`,{nonce:e,href:oP,precedence:`base-ui:low`,children:`.${oP}{scrollbar-width:none}.${oP}::-webkit-scrollbar{display:none}`})}},cP=`data-has-overflow-x`,lP=`data-has-overflow-y`,uP=`data-overflow-x-start`,dP=`data-overflow-x-end`,fP=`data-overflow-y-start`,pP=`data-overflow-y-end`,mP=e=>t=>t?{[e]:``}:null,hP={hasOverflowX:mP(cP),hasOverflowY:mP(lP),overflowXStart:mP(uP),overflowXEnd:mP(dP),overflowYStart:mP(fP),overflowYEnd:mP(pP),cornerHidden:()=>null},gP=`--scroll-area-corner-height`,_P=`--scroll-area-corner-width`,vP=`data-orientation`,yP={x:0,y:0},bP={width:0,height:0},xP={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},SP={x:!0,y:!0,corner:!0},CP=q.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=wP(i),d=gE(),f=by(),p=by(),{nonce:m,disableStyleElements:h}=DO(),[g,_]=q.useState(!1),[v,y]=q.useState(!1),[b,x]=q.useState(!1),[S,C]=q.useState(!1),[w,T]=q.useState(!1),[E,D]=q.useState(bP),[O,k]=q.useState(bP),[A,j]=q.useState(xP),[M,N]=q.useState(SP),P=q.useRef(null),F=q.useRef(null),I=q.useRef(null),L=q.useRef(null),R=q.useRef(null),ee=q.useRef(null),z=q.useRef(null),te=q.useRef(null),B=q.useRef(0),ne=q.useRef(0),V=q.useRef(0),H=q.useRef(0),re=q.useRef(`vertical`),ie=q.useRef(yP),ae=q.useRef(null);function oe(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let se=Z(e=>{let t=e.x-ie.current.x,n=e.y-ie.current.y;ie.current=e,n!==0&&oe(!0),t!==0&&oe(!1)}),U=Z(()=>{let e=F.current;e&&ae.current===null&&(ae.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),ce=Z(e=>{if(e.button!==0||te.current!==null&&(re.current===`vertical`?R.current:ee.current)?.hasPointerCapture(te.current))return;te.current=e.pointerId,B.current=e.clientY,ne.current=e.clientX,re.current=e.currentTarget.getAttribute(vP);let t=F.current;t&&(V.current=t.scrollTop,H.current=t.scrollLeft,U()),(re.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),le=Z(e=>{if(e.pointerId!==te.current)return;te.current=null,(re.current===`vertical`?x:y)(!1),ae.current!==null&&(F.current&&(F.current.style.scrollSnapType=ae.current),ae.current=null);let t=re.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),ue=Z(e=>{if(e.pointerId!==te.current)return;if(e.buttons%2==0){le(e);return}let t=F.current;if(!t)return;let n=re.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=aP(i,`padding`,a),s=aP(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-B.current:e.clientX-ne.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?V.current:H.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),oe(n)});function de(e){C(e.pointerType===`touch`)}function fe(e){if(de(e),e.pointerType!==`touch`){let t=Hy(P.current,e.target);_(t)}}let pe=q.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),me={role:`presentation`,onPointerEnter:fe,onPointerMove:fe,onPointerDown:de,onPointerLeave(){_(!1)},style:{position:`relative`,[gP]:`${E.height}px`,[_P]:`${E.width}px`}},he=Qv(`div`,e,{state:pe,ref:[t,P],props:[me,o],stateAttributesMapping:hP}),ge=q.useMemo(()=>({handlePointerDown:ce,handlePointerMove:ue,handlePointerUp:le,handleScroll:se,disableViewportSnap:U,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:pe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[ce,ue,le,se,U,E,O,w,S,v,b,g,d,M,A,pe,s,c,l,u]);return(0,J.jsxs)(rP.Provider,{value:ge,children:[!h&&sP.getElement(m),he]})});function wP(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}function TP(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var EP=q.createContext(void 0);function DP(e,t){return Math.max(0,e-t)}function OP(e,t){if(t<=0)return 0;let n=TP(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var kP=`--scroll-area-overflow-x-start`,AP=`--scroll-area-overflow-x-end`,jP=`--scroll-area-overflow-y-start`,MP=`--scroll-area-overflow-y-end`,NP=`--scroll-area-thumb-height`,PP=`--scroll-area-thumb-width`,FP=[kP,AP,jP,MP],IP=!1;function LP(){IP||My||(typeof CSS<`u`&&`registerProperty`in CSS&&FP.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),IP=!0)}var RP=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=iP(),T=SE(),E=q.useRef(!0),D=q.useRef([NaN,NaN,NaN,NaN]),O=by(),k=by(),A=Z(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=zP(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=OP(T===`rtl`?-w:w,P),L=P-I);let R=A?0:OP(x,F),ee=A?0:F-R,z=j?0:b,te=A?0:y,B=0,ne=0;!j&&!A&&(B=t?.offsetWidth||0,ne=n?.offsetHeight||0);let V=f.width===0&&f.height===0,H=V?B:0,re=V?ne:0,ie=aP(n,`padding`,`x`),ae=aP(t,`padding`,`y`),oe=aP(i,`margin`,`x`),se=aP(r,`margin`,`y`),U=z-ie-oe,ce=te-ae-se,le=n?Math.min(n.offsetWidth-H,U):U,ue=t?Math.min(t.offsetHeight-re,ce):ce,de=Math.max(16,le*M),fe=Math.max(16,ue*N);if(m(e=>BP(e,{width:de,height:fe})),t&&r){let e=VP(r,NP,x,F,h,fe,t.offsetHeight-fe-ae-se);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-de-ie-oe,t=VP(i,PP,T===`rtl`?-w:w,P,_,de,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let pe=[I,L,R,ee];FP.forEach((t,n)=>{e.style.setProperty(t,`${pe[n]}px`)}),a&&p(e=>BP(e,{width:B,height:ne})),g(e=>BP(e,k));let me={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>BP(e,me))});Q(()=>{LP()},[]),Q(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),Q(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),Q(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=FC(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(Kv))).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:sP.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=Qv(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:hP}),P=q.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,J.jsx)(EP.Provider,{value:P,children:N})});function zP(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function BP(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function VP(e,t,n,r,i,a,o){let s=TP(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var HP=q.createContext(void 0);function UP(){let e=q.useContext(HP);if(e===void 0)throw Error(Ov(54));return e}var WP=q.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=iP(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=SE(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;q.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return tx(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Wy(e.nativeEvent),n=T?h.current:g.current;if(n&&Hy(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=aP(n,`margin`,a),s=aP(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${gP})`,insetInlineEnd:0,[NP]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${_P})`,bottom:0,[PP]:`${S.width}px`}}},M=Qv(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:hP});return A?(0,J.jsx)(HP.Provider,{value:i,children:M}):null}),GP=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=iP(),m=UP(),h=m===`vertical`;return Qv(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),KP=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=iP(),l=Qv(`div`,e,{ref:[t,o],props:[{"aria-hidden":!0,style:{position:`absolute`,bottom:0,insetInlineEnd:0,width:s.width,height:s.height}},a]});return c.corner?null:l});function qP({className:e,children:t,...n}){return(0,J.jsxs)(CP,{"data-slot":`scroll-area`,className:X(`relative`,e),...n,children:[(0,J.jsx)(RP,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] -outline-offset-2`,children:t}),(0,J.jsx)(JP,{}),(0,J.jsx)(KP,{})]})}function JP({className:e,orientation:t=`vertical`,...n}){return(0,J.jsx)(WP,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:X(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,J.jsx)(GP,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}var YP=(e,t)=>{let n=e.split(`/`),r=t.split(`/`);for(let e=0;e<Math.min(n.length,r.length);e++){let t=n[e]??``,i=r[e]??``;if(t===i)continue;let a=e<n.length-1;if(a!==e<r.length-1)return a?-1:1;let o=t.toLowerCase().localeCompare(i.toLowerCase(),`en`);return o===0?t<i?-1:1:o}return n.length-r.length},XP=e=>e.slice(0,Math.max(e.lastIndexOf(`/`),0)),ZP=e=>e.slice(e.lastIndexOf(`/`)+1),QP=e=>{let t={directories:new Map,files:[]};for(let n of e){let e=t;for(let t of n.split(`/`).slice(0,-1)){let n=e.directories.get(t)??{directories:new Map,files:[]};e.directories.set(t,n),e=n}e.files.push(n)}let n=(e,t)=>{let r=[...e.directories].map(([e,r])=>{let i=e,a=r,o=t===``?e:`${t}/${e}`;for(let[e]=a.directories;a.files.length===0&&a.directories.size===1&&e!==void 0;[e]=a.directories)i=`${i}/${e[0]}`,o=`${o}/${e[0]}`,a=e[1];let[s]=a.files;return s!==void 0&&a.files.length===1&&a.directories.size===0?{kind:`file`,path:s,name:ZP(s),directory:`${i}/`}:{kind:`directory`,path:o,label:`${i}/`,children:n(a,o)}}),i=e.files.map(e=>({kind:`file`,path:e,name:ZP(e)})),a=e=>e.kind===`file`?e.path:`${e.path}/x`;return[...r.sort((e,t)=>YP(a(e),a(t))),...i.sort((e,t)=>YP(e.path,t.path))]};return n(t,``)},$P=e=>{let[t]=e;return e.length===1&&t?.kind===`directory`?{root:t.label,entries:t.children}:{root:null,entries:e}},eF=e=>e.flatMap(e=>e.kind===`file`?[e.path]:eF(e.children)),tF=(e,t)=>{let n=t.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{let t=e.path.toLowerCase();return n.every(e=>t.includes(e))})},nF=(e,t)=>[...e].sort((e,n)=>t===`size`&&n.additions+n.deletions-(e.additions+e.deletions)||YP(e.path,n.path)),rF=12,iF=24,aF=({label:e})=>{let t=e.slice(0,-1).lastIndexOf(`/`)+1;return t===0?(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}):(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`min-w-[1.5em] shrink-[999] truncate`,children:e.slice(0,t)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.slice(t)})]})},oF=({files:e,activePath:t,onSelect:n,mode:r=`tree`,order:i=`path`,navigate:a=!1,className:o})=>{let s=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=s.current?.querySelector(`[data-slot=scroll-area-viewport]`),t=s.current?.querySelector(`[aria-current]`);if(e==null||t==null)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,r=Number(t.dataset.depth??0)*iF;(n<e.scrollTop+r||n>e.scrollTop+e.clientHeight-40)&&(e.scrollTop=Math.max(0,n-e.clientHeight/3))},[t]);let[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(new Set),[f,p]=(0,q.useState)(t);if(f!==t){p(t);let e=[...u].filter(e=>t?.startsWith(`${e}/`));e.length>0&&d(new Set([...u].filter(t=>!e.includes(t))))}let m=(0,q.useRef)(null);_k({filterTree:()=>m.current?.focus()});let h=(0,q.useMemo)(()=>tF(e,c),[e,c]),g=(0,q.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]),{root:_,entries:v}=(0,q.useMemo)(()=>$P(QP(h.map(e=>e.path))),[h]),y=(0,q.useMemo)(()=>r===`tree`?eF(v):nF(h,i).map(e=>e.path),[r,v,h,i]),b=(0,q.useMemo)(()=>{let e=y.filter(e=>g.get(e)?.points!==void 0);return new Map(e.map((e,t)=>[e,t]))},[y,g]),x=e=>{let r=t===null?-1:y.indexOf(t),i=y[Math.min(y.length-1,Math.max(0,r+e))];i!==void 0&&n(i)};_k({nextFile:()=>x(1),previousFile:()=>x(-1)},a);let S=e=>{let t=new Set(u);t.has(e)?t.delete(e):t.add(e),d(t)},C=(e,r,i,a)=>(0,J.jsx)(`li`,{children:(0,J.jsx)(dF,{entry:e,label:r,depth:i,...a===void 0?{}:{directory:a},active:e.path===t,onSelect:n,...b.has(e.path)?{landing:{at:b.get(e.path)??0,of:b.size}}:{}})},e.path),w=(e,t)=>e.map(e=>{if(e.kind===`file`){let n=g.get(e.path);return n===void 0?null:C(n,e.name,t,e.directory)}let n=c.trim()!==``||!u.has(e.path),r=n?gg:vg,i=t*rF+4;return(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(`button`,{type:`button`,title:`${e.path}/`,"aria-expanded":n,onClick:()=>S(e.path),className:`sticky flex h-6 w-full items-center gap-1.5 rounded-md bg-background pr-2 text-left font-medium hover:bg-accent`,style:{paddingLeft:`${i}px`,top:`${t*iF}px`,zIndex:Math.max(1,30-t)},children:[(0,J.jsx)(Bh,{"aria-hidden":`true`,className:X(`size-3 shrink-0 text-muted-foreground transition-transform duration-(--duration-fast) ease-standard`,!n&&`-rotate-90`)}),(0,J.jsx)(r,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(aF,{label:e.label})]}),n&&(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-y-0 w-px bg-border`,style:{left:`${i+6}px`}}),(0,J.jsx)(`ul`,{children:w(e.children,t+1)})]})]},e.path)});return(0,J.jsxs)(`nav`,{ref:s,"aria-label":`Changed files`,className:X(`flex min-h-0 flex-col gap-2`,o),children:[(0,J.jsxs)(`div`,{className:`relative px-1`,children:[(0,J.jsx)(nP,{ref:m,type:`search`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c!==``&&(e.preventDefault(),l(``))},placeholder:`Filter files`,"aria-label":`Filter files`,className:`h-7 pr-8`}),(0,J.jsx)(bk,{id:`filterTree`,className:`absolute top-1/2 right-3 -translate-y-1/2`})]}),(0,J.jsxs)(`p`,{className:`flex gap-1 px-2 text-caption text-muted-foreground`,"aria-live":`polite`,..._===null||r!==`tree`?{}:{title:_},children:[(0,J.jsxs)(`span`,{className:`shrink-0`,children:[c.trim()===``?`${e.length} files`:`${h.length} of ${e.length} files`,_!==null&&r===`tree`&&` in`]}),` `,_!==null&&r===`tree`&&(0,J.jsx)(`span`,{className:`flex min-w-0 flex-1 font-mono text-code-compact`,children:(0,J.jsx)(aF,{label:_})})]}),h.length===0?(0,J.jsx)(VN,{inline:!0,tone:`muted`,glyph:`∅`,title:`No files match`,body:`Nothing in this PR has “${c.trim()}” in its path.`,actions:[{label:`Clear filter`,onClick:()=>l(``)}]}):(0,J.jsx)(qP,{className:`min-h-0 flex-1`,children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-px px-1 pb-2`,children:r===`tree`?w(v,0):nF(h,i).map(e=>C(e,e.path,0))})})]})},sF=({count:e})=>(0,J.jsxs)(`span`,{"data-slot":`thread-count`,className:`tabular inline-flex items-center gap-0.5 text-caption`,children:[(0,J.jsx)(Kg,{"aria-hidden":`true`,className:`size-3`}),e,(0,J.jsxs)(`span`,{className:`sr-only`,children:[` open `,e===1?`thread`:`threads`]})]}),cF=[`finding`,`risk`,`decision`],lF={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},uF=({points:e,landing:t})=>(0,J.jsx)(`span`,{"data-land":`drop`,style:vh({"--landing-i":t?.at??0,"--landing-n":t?.of??1}),className:`inline-flex items-center gap-1.5`,children:cF.map(t=>{let n=e[t]??0;if(n===0)return null;let{label:r}=oD[t],i=sD[t];return(0,J.jsxs)(`span`,{"data-slot":`point-count`,"data-kind":t,className:X(`tabular inline-flex items-center gap-0.5 text-caption font-medium`,lF[t]),children:[(0,J.jsx)(i,{"aria-hidden":`true`,className:`size-3`}),n,(0,J.jsxs)(`span`,{className:`sr-only`,children:[` `,r.toLowerCase(),n===1?``:`s`]})]},t)})}),dF=({entry:e,label:t,depth:n=0,active:r=!1,directory:i,landing:a,onSelect:o})=>{let s=e.status===void 0?null:lD[e.status],c=s?.kind===`mark`?s:null;return(0,J.jsxs)(`button`,{type:`button`,"aria-current":r?`location`:void 0,"data-depth":n,title:e.path,onClick:()=>o(e.path),className:X(`flex min-h-6 w-full flex-wrap items-center gap-x-1.5 rounded-md pr-2 text-left hover:bg-surface-row`,r&&`bg-surface-row font-medium shadow-[inset_3px_0_0_var(--primary)]`),style:{paddingLeft:`${n*rF+4}px`},children:[(0,J.jsxs)(`span`,{className:X(`flex items-center gap-1.5`,i===void 0?`min-w-[min(7rem,100%)] flex-1 basis-0`:`max-w-full flex-[1_0_auto]`),children:[(0,J.jsx)(KD,{path:e.path,status:e.status}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1`,children:[i!==void 0&&(0,J.jsx)(`span`,{className:`min-w-[1.5em] shrink-[999] truncate text-muted-foreground [direction:rtl]`,children:(0,J.jsx)(`bdi`,{dir:`ltr`,children:i})}),(0,J.jsxs)(`span`,{className:`relative min-w-0 truncate`,children:[(0,J.jsx)(`span`,{"data-slot":`file-name`,className:c?.name,children:t===e.path?t:ZP(e.path)}),c!==null&&(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, `,c.label]})]})]})]}),(0,J.jsxs)(`span`,{"data-slot":`file-row-counts`,className:`ml-auto flex flex-wrap items-center justify-end gap-x-1.5 whitespace-nowrap`,children:[e.status!==void 0&&(0,J.jsx)(YD,{status:e.status}),e.points!==void 0&&(0,J.jsx)(uF,{points:e.points,...a===void 0?{}:{landing:a}}),e.threads!==void 0&&e.threads>0&&(0,J.jsx)(sF,{count:e.threads}),e.additions!==void 0&&e.deletions!==void 0&&(0,J.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,e.additions]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,e.deletions]})]})]})]})},fF=60,pF=3600,mF=24*pF,hF=(e,t)=>{let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<fF)return`just now`;if(n<pF)return`${Math.floor(n/fF)} min ago`;if(n<mF)return`${Math.floor(n/pF)} h ago`;let r=Math.floor(n/mF);if(r===1)return`yesterday`;if(r<7)return`${r} days ago`;let i=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`;return r<30?i(Math.floor(r/7),`week`):r<365?i(Math.floor(r/30),`month`):i(Math.floor(r/365),`year`)},gF=e=>new Date(e).toLocaleString(`en`,{dateStyle:`full`,timeStyle:`short`}),_F={github:`GitHub`,bitbucket:`Bitbucket`},vF=({repo:e,number:t})=>`${e.owner}/${e.repo} #${t}`,yF=[`bg-avatar-1-bg text-avatar-1-fg`,`bg-avatar-2-bg text-avatar-2-fg`,`bg-avatar-3-bg text-avatar-3-fg`,`bg-avatar-4-bg text-avatar-4-fg`,`bg-avatar-5-bg text-avatar-5-fg`,`bg-avatar-6-bg text-avatar-6-fg`,`bg-avatar-7-bg text-avatar-7-fg`,`bg-avatar-8-bg text-avatar-8-fg`],bF=e=>{let t=0;for(let n of e)t=t*31+(n.codePointAt(0)??0)>>>0;return yF[t%yF.length]??yF[0]},xF=`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,SF=(e,t)=>{let n=e.role===`author`?`you`:e.author.name;return`${e.title}. ${vF(e.ref)} by ${n}, updated ${hF(e.updatedAt,t)}, ${_F[e.ref.repo.host]}`},CF=({item:e,nowMs:t,starting:n,tabbable:r,onOpen:i,onFocus:a})=>{let o=_F[e.ref.repo.host],s=e.role===`author`?`you`:e.author.name;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`a`,{href:E_(e.ref),"data-pr-row":``,tabIndex:r?0:-1,"aria-label":SF(e,t),"aria-busy":n,onClick:e=>{M_(e)&&(e.preventDefault(),n||i())},onFocus:a,className:`group flex min-h-[58px] w-full flex-col items-stretch gap-x-3 gap-y-1 px-4 py-2 text-left text-foreground hover:bg-accent hover:no-underline focus-visible:bg-accent focus-visible:-outline-offset-2 aria-busy:bg-diff-hunk-bg max-sm:items-start sm:flex-row sm:items-center`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1 self-stretch`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-x-1.5 text-caption text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 gap-[1ch] font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.ref.repo.owner,`/`,e.ref.repo.repo]}),(0,J.jsxs)(`span`,{className:`shrink-0`,children:[`#`,e.ref.number]})]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-medium`,bF(e.author.id)),children:wk(e.author.name)}),(0,J.jsx)(`span`,{className:`max-w-32 shrink-0 truncate`,children:s}),(0,J.jsx)(`time`,{dateTime:e.updatedAt,title:gF(e.updatedAt),className:`shrink-0 whitespace-nowrap`,children:hF(e.updatedAt,t)}),(0,J.jsx)(eO,{variant:`outline`,className:`ml-auto shrink-0 text-muted-foreground @min-[480px]:hidden`,children:o})]})]}),n?(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-caption`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-4 text-diff-hunk-fg`,xF)}),(0,J.jsx)(`span`,{className:`font-medium text-diff-hunk-fg`,children:`Opening review…`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Esc to cancel`})]}):(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 @max-[479px]:hidden`,children:[(0,J.jsx)(eO,{variant:`outline`,className:`text-muted-foreground @max-[479px]:hidden`,children:o}),(0,J.jsx)(bk,{id:`openRow`,className:`hidden group-focus-visible:inline-flex`}),(0,J.jsx)(Wh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 max-sm:hidden`})]})]})})},wF={ArrowDown:(e,t)=>Math.min(t,e+1),ArrowUp:e=>Math.max(0,e-1),Home:()=>0,End:(e,t)=>t},TF=({title:e,word:t,items:n,count:r,loading:i,skeletonRows:a,notes:o,blocked:s,empty:c,nowMs:l,startingUrl:u,onOpen:d})=>{let f=(0,q.useId)(),p=(0,q.useRef)(null),[m,h]=(0,q.useState)(0),g=n??[],_=Math.min(m,Math.max(0,g.length-1)),v=e=>{let t=wF[e.key],n=[...p.current?.querySelectorAll(`[data-pr-row]`)??[]],r=e.target instanceof HTMLElement?n.indexOf(e.target):-1;if(t===void 0||r===-1)return;e.preventDefault();let i=t(r,n.length-1);h(i),n[i]?.focus()},y=c.icon;return(0,J.jsxs)(`section`,{"aria-labelledby":f,className:`@container flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2`,children:[(0,J.jsx)(`h2`,{id:f,className:`text-heading font-semibold`,children:e}),r!==null&&(0,J.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,J.jsx)(`span`,{className:`sr-only`,children:r===`…`?`Loading`:`${r} pull request${r===1?``:`s`}`})]}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),(0,J.jsx)(`div`,{className:`flex flex-col gap-2 p-3 empty:hidden`,children:o}),s??(n===null?(0,J.jsxs)(`div`,{"aria-busy":`true`,className:`flex flex-col`,children:[(0,J.jsxs)(`p`,{className:`flex items-center gap-2 px-4 pt-3 text-caption text-muted-foreground`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-4`,`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`)}),i]}),(0,J.jsx)(`ul`,{"aria-hidden":`true`,className:`flex flex-col gap-3 px-4 py-3`,children:Array.from({length:a},(e,t)=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(zN,{className:`h-4 w-3/4 motion-reduce:animate-none`}),(0,J.jsx)(zN,{className:`h-3 w-1/2 motion-reduce:animate-none`})]},t))})]}):g.length===0?(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-1 px-6 py-8 text-center`,children:[(0,J.jsx)(y,{"aria-hidden":`true`,className:`mb-1 size-6 text-muted-foreground`}),(0,J.jsx)(`p`,{className:`font-medium`,children:c.title}),(0,J.jsx)(`p`,{className:`max-w-sm text-caption text-muted-foreground`,children:c.text})]}):(0,J.jsx)(`ul`,{ref:p,className:`divide-y`,onKeyDown:v,children:g.map((e,t)=>(0,J.jsx)(CF,{item:e,nowMs:l,starting:u===e.url,tabbable:t===_,onOpen:()=>d(e),onFocus:()=>h(t)},e.url))}))]})},EF=Tc.options,DF=`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-caption`,OF=`h-6 min-w-6 px-1 text-caption`,kF=e=>e.map(e=>_F[e]).join(` and `),AF=(e,t)=>{let n=e===null?[]:EF.filter(t=>e.hosts[t].configured),r=n.filter(t=>e?.hosts[t].error!=null),i=(t?.errors??[]).filter(e=>!r.includes(e.host));return{configured:n,failing:r,listFailed:i,shown:n.filter(e=>!r.includes(e)&&!i.some(t=>t.host===e))}},jF=(e,t)=>(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-8 text-center text-caption text-muted-foreground`,children:[(0,J.jsx)(`p`,{children:e}),t]}),MF=({status:e,list:t,error:n,rowFailure:r,startingUrl:i,nowMs:a,onOpen:o,onRetry:s,onOpenConnections:c,onFix:l})=>{let u=AF(e,t),d=e!==null&&u.configured.length===0,f=t!==null&&u.configured.length>0&&u.shown.length===0,p=u.configured.length>1&&u.shown.length===1&&u.shown[0]!==void 0?`${_F[u.shown[0]]} only`:null,m=e=>n===null?null:(0,J.jsxs)(`p`,{className:X(LN,DF),role:`alert`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Couldn't list pull requests.`}),(0,J.jsx)(`span`,{children:Ap(n)}),e&&(0,J.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:s,children:`Retry`})]}),h=e=>r?.role===e?(0,J.jsxs)(`p`,{className:X(LN,DF),role:`alert`,children:[(0,J.jsx)(`span`,{children:r.message}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:r.onRetry,children:`Try again`})]}):null,g=u.failing.map(e=>(0,J.jsxs)(`p`,{className:X(RN,DF),role:`status`,children:[(0,J.jsxs)(`span`,{children:[_F[e],` pull requests are hidden until `,_F[e],` works again.`]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:l,children:`Fix…`})]},e)),_=u.listFailed.map(e=>(0,J.jsxs)(`p`,{className:X(LN,DF),role:`alert`,children:[(0,J.jsxs)(`span`,{className:`font-medium`,children:[`Couldn't load `,_F[e.host],` pull requests.`]}),(0,J.jsx)(`span`,{children:e.message}),u.shown.length>0&&(0,J.jsxs)(`span`,{children:[kF(u.shown),` pull requests are shown.`]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:s,children:`Retry`})]},e.host)),v=u.configured.length===0?`Loading`:`Loading from ${kF(u.configured)}`,y=t?.items.filter(e=>e.role===`reviewer`)??null,b=t?.items.filter(e=>e.role===`author`)??null,x=e=>e===null?n===null?`…`:null:f?null:e.length;return(0,J.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.55fr_1fr]`,children:[(0,J.jsx)(TF,{title:`To review`,word:p??`Waiting for your review`,items:y,count:x(y),loading:v,skeletonRows:5,notes:(0,J.jsxs)(J.Fragment,{children:[t!==null&&m(!0),g,_,h(`reviewer`)]}),blocked:d?jF(`Connect GitHub or Bitbucket to list pull requests.`,(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Open Connections`})):t===null&&n!==null?m(!0):!f&&void 0,empty:{icon:Mg,title:`Nothing is waiting for you`,text:`When someone asks for your review on GitHub or Bitbucket, it appears here. To review something else, paste its link above.`},nowMs:a,startingUrl:i,onOpen:o}),(0,J.jsx)(TF,{title:`Your pull requests`,word:p??`Open`,items:b,count:x(b),loading:`Loading`,skeletonRows:3,notes:(0,J.jsxs)(J.Fragment,{children:[t!==null&&m(!1),h(`author`)]}),blocked:d?jF(`Connect GitHub or Bitbucket to list pull requests.`):t===null&&n!==null?m(!1):f?jF(`Couldn't load pull requests.`):void 0,empty:{icon:Og,title:`No open pull requests`,text:`Pull requests you open on GitHub or Bitbucket appear here.`},nowMs:a,startingUrl:i,onOpen:o})]})},NF=(0,q.createContext)(null),PF=()=>{let e=(0,q.useContext)(NF);if(e===null)throw Error(`useConnections needs a ConnectionsProvider`);return e},FF=({children:e,now:t=Date.now})=>{let{status:n,error:r,loading:i,refresh:a}=Sp(),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(0),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);(0,q.useEffect)(()=>{!i&&n!==null&&s(t())},[i,n,t]);let g=(0,q.useCallback)(()=>{a(),d(e=>e+1)},[a]),_=(0,q.useCallback)((e,t)=>{h(e&&t?.focusCheckAgain===!0),p(e)},[]),v=(0,q.useMemo)(()=>({status:n,error:r,checking:i,checkedAtMs:o,listed:c,reportListed:l,checkAgain:g,checks:u,open:f,setOpen:_,focusCheckAgain:m}),[n,r,i,o,c,g,u,f,_,m]);return(0,J.jsx)(NF.Provider,{value:v,children:e})},IF=({pullRequest:e,error:t})=>{let{setOpen:n}=PF(),r=`Couldn't open ${vF(e)}: `;return t.code===`host-not-configured`?(0,J.jsxs)(J.Fragment,{children:[r,_F[e.repo.host],` isn't configured.`,` `,(0,J.jsx)($,{variant:`link`,className:OF,onClick:()=>n(!0),children:`Open Connections`})]}):(0,J.jsx)(J.Fragment,{children:`${r}${Ap(t)}`})},LF=({pullRequest:e})=>{let{client:t}=yp(),[n,r]=(0,q.useState)(0),[i,a]=(0,q.useState)(null),o=vF(e),s=(0,q.useRef)(0);return(0,q.useEffect)(()=>(s.current=n,t.startAnalysis({url:hf(e)}).then(e=>{s.current===n&&(e.ok?j_(D_(e.value.analysisId)):a(e.error))}),()=>{s.current=-1}),[t,e,n]),(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:o}),(0,J.jsx)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-body`,children:i===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-4`,xF)}),`Fetching `,o,` from `,_F[e.repo.host],`…`]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:()=>{s.current=-1,j_(`/`)},children:`Cancel`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-4 align-[-3px]`}),(0,J.jsx)(IF,{pullRequest:e,error:i})]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:()=>{a(null),r(e=>e+1)},children:`Try again`})]})}),i!==null&&(0,J.jsx)(`p`,{className:`text-body`,children:(0,J.jsx)(N_,{to:`/`,children:`Go to your pull requests`})})]})},RF=q.createContext(void 0);function zF(e){let t=q.useContext(RF);if(t===void 0&&!e)throw Error(Ov(72));return t}var BF={...Cw,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},VF=class extends mw{constructor(e,t,n){let r=new tw;super(UF(e,r,t,n),WF(r),BF)}setOpen=(e,t)=>{YC(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Ab(Nb,e))}};function HF(){let e=new tw,t=new rE(Object.freeze(UF(void 0,e)),Object.freeze(WF(e)),BF);return Object.assign(t,{setOpen:Kv,cancelPendingOpen:Kv})}function UF(e,t,n,r=!1){return{..._w(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function WF(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var GF=my(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=UC((e,t)=>new VF({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),ZC(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=QC(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=q.useRef(null);Q(()=>{m&&t&&p.setOpen(!1,Ab(Kb))},[m,t,p]),Q(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),Q(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),q.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,Ab(Yb))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,J.jsxs)(RF.Provider,{value:p,children:[l&&(0,J.jsx)(WC,{handle:l,store:p}),T&&(0,J.jsx)(KF,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function KF({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=bC(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=_C(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=q.useMemo(()=>mv(a.reference,i.reference),[a.reference,i.reference]);return $C(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??Jv}),null}var qF=q.createContext(void 0);function JF(){return q.useContext(qF)}var YF=`data-base-ui-tooltip-trigger`;function XF(e){let t=Wy(e);return z_(t)?t:null}var ZF=hy(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=zF(!0),m=ww(a)??p;if(!m)throw Error(Ov(82));let h=gE(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=q.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=XC(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=JF(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=ex(v,{open:_}),O=Mw(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=rx(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=q.useRef(!1),F=by(),I=q.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=Uy(e,`[${YF}]`);return n!==null&&n!==t&&Hy(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let z=Fw(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?Zw():null,restMs:L,delay(){return u==null&&D?{close:Eb(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),te=Dw(v,{enabled:!A}).reference,B=e=>{let t=P.current,n=XF(e),r=ee(n),i=y.current,a=i&&n&&Hy(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,Ab(Pb,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&zy(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,Ab(Pb,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},ne=m.useState(`appliedTriggerProps`,S||M!==`none`);return Qv(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,te,ne,{onMouseOver(e){B(e.nativeEvent)},onFocus(e){R(XF(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[gb]:A?``:void 0,[YF]:A?void 0:``},f],stateAttributesMapping:fb})}),QF=q.createContext(void 0);function $F(){let e=q.useContext(QF);if(e===void 0)throw Error(Ov(70));return e}var eI=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return zF().useState(`mounted`)||n?(0,J.jsx)(QF.Provider,{value:n,children:(0,J.jsx)(mE,{ref:t,...r})}):null}),tI=q.createContext(void 0);function nI(){let e=q.useContext(tI);if(e===void 0)throw Error(Ov(71));return e}var rI=q.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=VS,style:g,..._}=e,v=zF(),y=$F(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=IE({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=BE(e,q.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,J.jsx)(tI.Provider,{value:D,children:O})}),iI=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=zF(),{side:s,align:c}=nI(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);zC({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Nw(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Qv(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[VC,f,zE(d),a],stateAttributesMapping:hb})}),aI=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=zF(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=nI();return Qv(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:mb})}),oI=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=q.useMemo(()=>({open:t,close:n}),[t,n]);return(0,J.jsx)(qF.Provider,{value:t,children:(0,J.jsx)($b,{delay:i,timeoutMs:r,children:e.children})})},sI=class extends MC{constructor(){super(HF(),`Tooltip`)}open(e){this.openByTrigger(e)}close(){this.closePopup()}get isOpen(){return this.attachedStore?.select(`open`)??!1}};function cI(){return new sI}function lI({delay:e=0,...t}){return(0,J.jsx)(oI,{"data-slot":`tooltip-provider`,delay:e,...t})}function uI({...e}){return(0,J.jsx)(GF,{"data-slot":`tooltip`,...e})}function dI({...e}){return(0,J.jsx)(ZF,{"data-slot":`tooltip-trigger`,...e})}function fI({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,collisionBoundary:a,children:o,shortcut:s,...c}){return(0,J.jsx)(eI,{children:(0,J.jsx)(rI,{collisionBoundary:a,align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,J.jsxs)(iI,{"data-slot":`tooltip-content`,className:X(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-caption text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...c,children:[o,s!==void 0&&(0,J.jsx)(vk,{children:s}),(0,J.jsx)(aI,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var pI=e=>{if(e===null)return 26;let t=e>=900?e-260-32:e,n=Math.floor((t-32)/24);return Math.min(26,Math.max(8,n))},mI=e=>String(e).padStart(2,`0`),hI=e=>{let t=new Date(e);return`${t.getFullYear()}-${mI(t.getMonth()+1)}-${mI(t.getDate())}`},gI=e=>new Date(`${e}T00:00:00Z`),_I=e=>gI(e).toLocaleDateString(`en`,{month:`short`,day:`numeric`,timeZone:`UTC`}),vI=e=>gI(e).toLocaleDateString(`en`,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}),yI=e=>gI(e).toLocaleDateString(`en`,{month:`short`,timeZone:`UTC`}),bI=e=>Number(e.slice(8,10)),xI=e=>{let t=Math.ceil(e.length/7);return Array.from({length:t},(t,n)=>{let r=e.slice(n*7,n*7+7),i=r.find(e=>bI(e.date)===1);if(i!==void 0)return yI(i.date);let a=r[0];return n===0&&a!==void 0&&bI(a.date)<=7?yI(a.date):null})},SI=e=>e===1?`1 PR`:`${e} PRs`,CI=e=>e===1?`1 comment`:`${e} comments`,wI=e=>`${e.pullRequests===0?`No PRs`:SI(e.pullRequests)} reviewed · ${CI(e.comments)}`,TI=(e,t)=>`${_I(e.date)}: ${e.pullRequests===0?`No PRs`:SI(e.pullRequests)} reviewed, ${CI(e.comments)}${e.date===t?` (today)`:``}`,EI=e=>`Busiest day: ${_I(e.date)}, ${SI(e.pullRequests)} and ${CI(e.comments)}.`,DI=(e,t,n)=>{let r={ArrowLeft:t-7,ArrowRight:t+7,ArrowUp:t-1,ArrowDown:t+1,Home:0,End:n}[e];return r===void 0||r<0||r>n?null:r},OI=e=>Ic(e),kI={0:`border-input bg-card`,1:`border-primary bg-activity-1`,2:`border-primary bg-activity-2`,3:`border-primary bg-activity-3`,4:`border-primary bg-primary`},AI=[{level:0,label:`0`},{level:1,label:`1`},{level:2,label:`2`},{level:3,label:`3–4`},{level:4,label:`5+`}],jI=[``,`Mon`,``,`Wed`,``,`Fri`,``],MI=({level:e,className:t})=>(0,J.jsx)(`span`,{className:X(`flex items-center justify-center rounded-[4px] border`,kI[e],t),children:e===4&&(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),NI=e=>{let[t,n]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{let t=e.current;if(t===null)return;let r=t.getBoundingClientRect().width;if(r>0&&n(r),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(([e])=>{e!==void 0&&n(e.contentRect.width)});return i.observe(t),()=>i.disconnect()},[e]),t},PI=cI(),FI=({days:e,today:t,weeks:n})=>{let[r,i]=(0,q.useState)(t),a=(0,q.useRef)(new Map),o=(0,q.useRef)(null),s=e.some(e=>e.date===r)?r:e[0]?.date??t,c=xI(e),l=Math.ceil(e.length/7);return(0,J.jsxs)(`div`,{ref:o,className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`grid pl-8 text-caption text-muted-foreground`,style:{gridTemplateColumns:`repeat(${l}, 24px)`},children:c.map((e,t)=>(0,J.jsx)(`span`,{className:`h-4 overflow-visible whitespace-nowrap`,children:e},t))}),(0,J.jsx)(`div`,{role:`grid`,"aria-label":`Review activity for the last ${n} weeks, one square per day. Use arrow keys to move between days.`,className:`flex flex-col`,onKeyDown:t=>{let n=e.findIndex(e=>e.date===s),r=DI(t.key,n,e.length-1);if(r===null)return;t.preventDefault();let o=e[r];o!==void 0&&(i(o.date),a.current.get(o.date)?.focus())},children:jI.map((n,r)=>(0,J.jsxs)(`div`,{role:`row`,className:`flex items-center`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`w-8 shrink-0 text-caption text-muted-foreground`,children:n}),Array.from({length:l},(n,o)=>{let c=e[o*7+r];if(c===void 0||OI(c.date)!==r)return(0,J.jsx)(`span`,{className:`size-6 shrink-0`},o);let l=Bc(c.pullRequests);return(0,J.jsx)(dI,{handle:PI,payload:c,delay:150,render:(0,J.jsx)(`div`,{ref:e=>{e===null?a.current.delete(c.date):a.current.set(c.date,e)},role:`gridcell`,tabIndex:c.date===s?0:-1,"aria-label":TI(c,t),onFocus:()=>i(c.date),className:`group flex size-6 shrink-0 items-center justify-center rounded-md`}),children:(0,J.jsx)(MI,{level:l,className:X(`size-5 group-hover:ring-2 group-hover:ring-foreground`,c.date===t&&`outline-2 outline-offset-1 outline-foreground`)})},c.date)})]},r))}),(0,J.jsx)(GF,{handle:PI,children:({payload:e})=>e===void 0?null:(0,J.jsx)(fI,{collisionBoundary:o.current??void 0,children:(0,J.jsxs)(`span`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`font-semibold`,children:vI(e.date)}),(0,J.jsx)(`span`,{children:wI(e)})]})})}),(0,J.jsxs)(`div`,{"aria-hidden":`true`,className:`flex items-start gap-2 pl-8 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`leading-4`,children:`PRs a day`}),AI.map(({level:e,label:t})=>(0,J.jsxs)(`span`,{className:`flex w-6 flex-col items-center gap-0.5`,children:[(0,J.jsx)(MI,{level:e,className:`size-4`}),(0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:t})]},e))]})]})},II=({value:e,label:t})=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-title font-semibold tabular-nums`,children:e}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),LI=({activity:e,error:t,onRetry:n,now:r})=>{let i=(0,q.useId)(),a=(0,q.useRef)(null),o=NI(a),s=pI(o),c=o===null||o>=900,l=hI(r()),u=(0,q.useMemo)(()=>e===null?null:zc(e,{today:l,weeks:s,dayOf:hI}),[e,l,s]),d=(0,q.useMemo)(()=>e===null?null:zc(e,{today:l,weeks:26,dayOf:hI}),[e,l]),f=u===null?null:Vc(u),p=d?.every(e=>e.pullRequests===0&&e.comments===0)===!0;return(0,J.jsxs)(`section`,{"aria-labelledby":i,className:`flex flex-col rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2.5`,children:[(0,J.jsx)(`h2`,{id:i,className:`text-heading font-semibold`,children:`Review activity`}),(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`Last `,s,` weeks`]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground max-sm:basis-full sm:ml-auto`,children:[(0,J.jsx)(Ig,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Reviews and comments posted from megareviewer on this machine`]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden px-4 py-4`,children:(0,J.jsx)(`div`,{ref:a,children:u===null||f===null?t===null?(0,J.jsx)(zN,{"aria-label":`Loading review activity`,className:`h-[244px] w-full motion-reduce:animate-none`}):(0,J.jsxs)(`p`,{className:X(LN,`flex flex-wrap items-baseline gap-x-2 text-caption`),children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Couldn't read your review activity.`}),(0,J.jsx)(`span`,{children:Ap(t)}),(0,J.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:n,children:`Try again`})]}):(0,J.jsxs)(`div`,{className:X(`flex gap-8`,c?`flex-row`:`flex-col`),children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsx)(FI,{days:u,today:l,weeks:s}),p&&(0,J.jsxs)(`p`,{className:`rounded-md bg-muted px-3 py-2 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:`No reviews yet.`}),` Open a pull request above and post your review. Each day you review fills a square here.`]})]}),(0,J.jsxs)(`div`,{className:X(`flex flex-col gap-3`,c&&`w-[260px] shrink-0`),children:[(0,J.jsxs)(`div`,{className:X(`grid gap-x-6 gap-y-3`,c||o!==null&&o<520?`grid-cols-2`:`grid-cols-4`),children:[(0,J.jsx)(II,{value:f.pullRequests,label:`PRs reviewed`}),(0,J.jsx)(II,{value:f.comments,label:`comments posted`}),(0,J.jsx)(II,{value:f.daysWithReviews,label:`days with reviews`}),(0,J.jsx)(II,{value:f.thisWeek,label:`PRs this week`})]}),f.busiest!==null&&(0,J.jsx)(`p`,{className:`border-t pt-3 text-caption text-muted-foreground`,children:EI(f.busiest)})]})]})})})]})},RI=`Paste a pull request link first.`,zI=`That isn't a pull request link. Use github.com/owner/repo/pull/123 or bitbucket.org/workspace/repo/pull-requests/45.`,BI=`h-6 min-w-6 px-1 text-caption`,VI=nk(`openInNewTab`).chords[0]??{key:`Enter`,mod:!0},HI=({inputRef:e,start:t,onSubmit:n,onSubmitInNewTab:r,onEdit:i,initial:a})=>{let[o,s]=(0,q.useState)(a?.url??``),[c,l]=(0,q.useState)(a?.invalid??null),u=(0,q.useId)(),d=t?.state===`starting`,f=()=>{let e=o.trim();if(e===``)return l(RI),null;let t=mf(e);return t.ok||l(zI),t.ok?t.value:null},p=e=>{if(e.preventDefault(),d)return;let t=f();t!==null&&n(o.trim(),t)},m=e=>{e.preventDefault();let t=f();t!==null&&r(t)},h=dk();return(0,J.jsx)(`search`,{children:(0,J.jsxs)(`form`,{"aria-label":`Open a pull request by link`,className:`flex flex-col gap-1.5`,onSubmit:p,noValidate:!0,children:[(0,J.jsxs)(`div`,{className:`flex gap-2 max-sm:flex-col`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(Bg,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,J.jsx)(`input`,{ref:e,id:`${u}-url`,"aria-label":`Pull request link`,className:X(`h-9 w-full min-w-0 rounded-md border border-input bg-card pr-10 pl-8 placeholder:text-muted-foreground`,c!==null&&`border-destructive`),type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:`Paste a GitHub or Bitbucket pull request link`,value:o,readOnly:d,onKeyDown:e=>{ck(e,VI,h)&&m(e)},onChange:e=>{s(e.target.value),l(null),i()},"aria-invalid":c!==null,"aria-describedby":`${u}-message`}),(0,J.jsx)(bk,{id:`focusLink`,className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2`})]}),(0,J.jsx)($,{type:`submit`,size:`lg`,className:`sm:w-28`,"aria-busy":d,onClick:e=>{(e.metaKey||e.ctrlKey||e.shiftKey)&&m(e)},onAuxClick:e=>{e.button===1&&m(e)},children:d?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:xF}),`Opening…`]}):`Review`})]}),(0,J.jsx)(`div`,{id:`${u}-message`,role:`status`,className:`flex min-h-0 flex-wrap items-center gap-x-2 text-caption`,children:c===null?t?.state===`starting`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-3.5`,xF)}),t.message]}),(0,J.jsx)($,{type:`button`,variant:`link`,className:BI,onClick:t.onCancel,children:`Cancel`})]}):t?.state===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),t.message]}),(0,J.jsx)($,{type:`button`,variant:`link`,className:BI,onClick:t.onRetry,children:`Try again`})]}):null:(0,J.jsxs)(`span`,{className:`text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),c]})})]})})},UI=Tc.options,WI=({now:e=Date.now})=>{let{client:t}=yp(),{status:n,checks:r,reportListed:i,setOpen:a}=PF(),o=Cp(),s=wp(),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),f=(0,q.useRef)(0),p=(0,q.useRef)(null),m=(0,q.useRef)(null),{refresh:h}=o,{refresh:g}=s,_=(0,q.useCallback)(()=>{h(),g()},[h,g]),v=(0,q.useRef)(r);(0,q.useEffect)(()=>{r!==v.current&&(v.current=r,_())},[r,_]),(0,q.useEffect)(()=>{if(o.loading||(m.current=e(),o.pullRequests===null))return;let t=new Set(o.pullRequests.errors.map(e=>e.host)),r={};for(let e of UI)t.has(e)||n?.hosts[e].configured!==!0||(r[e]=o.pullRequests.items.filter(t=>t.ref.repo.host===e).length);i({counts:r,atMs:e()})},[o.loading,o.pullRequests,n,e,i]),(0,q.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&m.current!==null&&e()-m.current>12e4&&_()};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,_]),(0,q.useEffect)(()=>{let e=e=>{e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey||lk(e.target)||(e.preventDefault(),p.current?.focus(),p.current?.select())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let y=async(e,n,r,i)=>{f.current+=1;let a=f.current;l({from:r,url:e,ref:n,role:i,state:`starting`}),r===`row`&&d(`Opening ${vF(n)}`);let o=await t.startAnalysis({url:e});f.current===a&&(o.ok?A_(D_(o.value.analysisId)):l({from:r,url:e,ref:n,role:i,state:`failed`,error:o.error}))},b=(0,q.useCallback)(e=>{f.current+=1,l(null),e===`form`?p.current?.focus():d(`Cancelled`)},[]),x=c?.state===`starting`&&c.from===`row`;(0,q.useEffect)(()=>{if(!x)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||e.target instanceof Element&&e.target.closest(`[data-slot=popover-content]`)||b(`row`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[x,b]);let S=e=>(0,J.jsx)(IF,{pullRequest:e.ref,error:e.error}),C=c?.from===`form`?c.state===`starting`?{state:`starting`,message:`Fetching ${vF(c.ref)} from ${_F[c.ref.repo.host]}…`,onCancel:()=>b(`form`)}:{state:`failed`,message:S(c),onRetry:()=>void y(c.url,c.ref,`form`,null)}:null,w=e(),T=c?.state===`starting`&&c.from===`row`?c.url:null,E=c?.state===`failed`&&c.from===`row`&&c.role!==null?{role:c.role,message:S(c),onRetry:()=>void y(c.url,c.ref,`row`,c.role)}:null;return(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1240px] flex-col gap-4`,children:[(0,J.jsx)(`h1`,{className:`sr-only`,children:`Pull requests`}),(0,J.jsx)(HI,{inputRef:p,start:C,onSubmit:(e,t)=>void y(e,t,`form`,null),onSubmitInNewTab:e=>window.open(E_(e),`_blank`,`noopener`),onEdit:()=>{c?.from===`form`&&c.state===`failed`&&l(null)}}),(0,J.jsx)(MF,{status:n,list:o.pullRequests,error:o.error,rowFailure:E,startingUrl:T,nowMs:w,onOpen:e=>void y(e.url,e.ref,`row`,e.role),onRetry:_,onOpenConnections:()=>a(!0),onFix:()=>a(!0,{focusCheckAgain:!0})}),(0,J.jsx)(LI,{activity:s.activity,error:s.error,onRetry:g,now:e}),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})},GI=`megareviewer:`,KI=e=>{try{let t=window.localStorage.getItem(GI+e);return t===null?void 0:JSON.parse(t)}catch{return}},qI=(e,t)=>{try{window.localStorage.setItem(GI+e,JSON.stringify(t))}catch{}},JI=(e,t,n)=>{let[r,i]=(0,q.useState)(()=>({key:e,value:n(KI(e))??t}));return[r.key===e?r.value:n(KI(e))??t,(0,q.useCallback)(r=>i(i=>{let a=r(i.key===e?i.value:n(KI(e))??t);return qI(e,a),{key:e,value:a}}),[e,t,n])]},YI=e=>typeof e==`boolean`?e:void 0,XI=e=>typeof e==`string`?e:void 0,ZI=e=>{let t=new Map;for(let n of e){let e=n.available?`${n.provider} ${n.via}`:n.provider,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.values()].flatMap(e=>{let[t]=e;return t===void 0?[]:[[t,e]]})},QI=(e,t,n)=>{if(e.length<=6)return e;let r=e.filter(e=>e.id===t?.id||e.id===n);return r.length>0?r:e.slice(0,1)},$I=(e,t,n)=>{let r=n.toLowerCase().split(/\s+/).filter(e=>e!==``);return r.length===0?[]:e.filter(e=>!t.includes(e)&&r.every(t=>`${e.modelName} ${e.model}`.toLowerCase().includes(t)))},eL=e=>e.length===0?`No model is known to megareviewer`:e.some(e=>e.available)?null:ZI(e).map(([e])=>e.reason??`${e.providerName} can't run`).join(`; or `),tL=e=>{let[t,n]=JI(`model-option`,null,XI),r=e?.options??[],i=r.find(e=>e.id===t&&e.available)??r.find(t=>t.id===e?.defaultId)??null,a=(0,q.useCallback)(e=>n(()=>e),[n]);return{options:r,chosen:i,defaultId:e?.defaultId??null,locked:e===null?null:eL(r),choose:a}},nL=(e,t)=>({...e,preferences:e.preferences.some(e=>e.id===t.id)?e.preferences.map(e=>e.id===t.id?t:e):[...e.preferences,t]}),rL=(e,t)=>({...e,preferences:e.preferences.filter(e=>e.id!==t)}),iL=(e,t)=>({...e,proposals:[...e.proposals,...t.filter(t=>!e.proposals.some(e=>e.id===t.id))]}),aL=(e,t)=>({...e,proposals:e.proposals.filter(e=>e.id!==t)}),oL=(e,t,n,r)=>({...e,repositories:e.repositories.map(e=>ru(e.repo,t)&&e.guidelineFiles!==null?{...e,guidelineFiles:e.guidelineFiles.map(e=>e.path===n?{...e,enabled:r}:e)}:e)}),sL=(e,t)=>e.preferences.filter(e=>iu(e.scope,t)),cL=e=>{let t=[...e.repositories];for(let{scope:n}of[...e.preferences,...e.proposals])n.kind!==`repo`||t.some(e=>ru(e.repo,n.repo))||t.push({repo:n.repo,guidelineFiles:null,guidelineNote:`No pull request of this repository has been analyzed yet`});return t},lL=e=>{if(e<1024)return`${e} B`;let t=e/1024;return`${t<10?t.toFixed(1):Math.round(t)} KB`},uL=e=>{let t=e.trim();return t===``||/[.!?]$/.test(t)?t:`${t}.`},dL=e=>e.code===`bad-request`?uL(e.message):Ap(e),fL=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,pL=new Intl.ListFormat(`en`,{type:`disjunction`}).format(Jl),mL=({file:e,repository:t,onSwitch:n})=>{let[r,i]=(0,q.useState)(null);return(0,J.jsxs)(`li`,{"data-slot":`guideline-file`,className:`flex min-h-8 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 font-mono text-code-compact break-all`,children:e.path}),(0,J.jsx)(`span`,{className:`tabular shrink-0 text-caption text-muted-foreground`,children:lL(e.bytes)}),e.tooLarge?(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`too large to send: a guideline file can be `,lL(Xl)]}):(0,J.jsx)(ZN,{checked:e.enabled,"aria-label":`Read ${e.path} in AI reviews of ${t}`,onCheckedChange:async t=>{i(null),i(await n(e.path,t))}}),r!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),r]})]})},hL=({files:e,note:t,repository:n,onSwitch:r})=>(0,J.jsxs)(`div`,{"data-slot":`guideline-files`,className:`flex flex-col gap-1 border-t px-4 py-3`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Guideline files, read at the base commit of the pull request`}),e===null?(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:uL(t??`Couldn't look for them`)}):e.length===0?(0,J.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[`None at the repository's root, where megareviewer looks for `,pL,`.`]}):(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,J.jsx)(mL,{file:e,repository:n,onSwitch:r},e.path))})]}),gL=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`,_L=(e,t)=>{let[n,r]=(0,q.useState)(t);return(0,q.useEffect)(()=>{if(e===null)return;r(t());let n=setInterval(()=>r(t()),1e3);return()=>clearInterval(n)},[e,t]),e===null?0:Math.max(0,Math.round((n-e)/1e3))},vL=({label:e,running:t,icon:n,variant:r=`outline`,choice:i,what:a=`Runs`,blocked:o=null,idle:s=null,run:c,now:l=Date.now,initial:u})=>{let d=(0,q.useId)(),[f,p]=(0,q.useState)(()=>u===void 0?{is:`idle`}:`runningSince`in u?{is:`running`,since:u.runningSince}:u.ok?{is:`done`,said:u.said}:{is:`failed`,...u}),m=_L(f.is===`running`?f.since:null,l),{chosen:h,locked:g}=i,_=f.is===`running`,v=o??g,y=v??(h===null?null:`${a} ${h.modelName} through ${h.via}`),b=async()=>{p({is:`running`,since:l()});let e=await c(h?.id);p(e.ok?{is:`done`,said:e.said}:{is:`failed`,...e})};return(0,J.jsxs)(`div`,{"data-slot":`model-action`,className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,J.jsxs)(uI,{disabled:y===null,children:[(0,J.jsxs)(dI,{render:(0,J.jsx)($,{variant:r,size:`sm`,disabled:_||v!==null||h===null,focusableWhenDisabled:!0,"aria-busy":_,"aria-describedby":y===null?void 0:`${d}-note`,onClick:()=>void b()}),children:[_?(0,J.jsx)(Hg,{"aria-hidden":`true`,className:xF}):g!==null&&o===null?(0,J.jsx)(Wg,{"aria-hidden":`true`}):n,e]}),(0,J.jsxs)(fI,{side:`bottom`,align:`start`,children:[v!==null&&(0,J.jsx)(Pg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),y]})]}),y!==null&&(0,J.jsx)(`span`,{id:`${d}-note`,hidden:!0,children:y}),(0,J.jsx)(`span`,{role:f.is===`failed`?`alert`:`status`,className:X(`flex min-w-0 flex-1 basis-56 flex-wrap items-center gap-x-2 text-caption`,f.is===`failed`?`text-destructive`:`text-muted-foreground`),children:f.is===`running`?(0,J.jsxs)(J.Fragment,{children:[t,` `,(0,J.jsx)(`span`,{className:`tabular`,children:gL(m)})]}):f.is===`done`?f.said:f.is===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),f.message]}),(0,J.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:()=>void b(),children:`Try again`})]}):s})]})};function yL(e){let t=q.useRef(!0);t.current&&(t.current=!1,e())}var bL=q.createContext(void 0),xL=q.createContext(void 0);function SL(){let e=q.useContext(bL);if(e===void 0)throw Error(Ov(60));return e}function CL(){let e=q.useContext(xL);if(e===void 0)throw Error(Ov(61));return e}function wL(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var TL=(e,t)=>Object.is(e,t);function EL(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function DL(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!wL(e,t,(e,t)=>EL(e,t,n)):e!==t}function OL(e,t,n){return e?e.some(e=>e!==void 0&&EL(t,e,n)):!1}function kL(e,t,n){return e?e.findIndex(e=>e!==void 0&&EL(e,t,n)):-1}function AL(e,t){if(t!==TL)return n=>OL(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function jL(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(AL(t,n)):kL(e,t,n);return i===-1?null:i}function ML(e,t,n,r,i,a){return OL(r,t,i)?a!=null&&e>a&&OL(r,n[a],i)?a:e:e===a?jL(n,r,i,!0):a}function NL(e,t,n){return e.filter(e=>!EL(t,e,n))}function PL(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function FL(e){return PL(e?.[0])}function IL(e){return FL(e)?e.flatMap(e=>e.items):e}function LL(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(FL(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function RL(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return NN(e)}function zL(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?NN(e.value):NN(e)}function BL(e,t,n){function r(){return RL(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=IL(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function VL(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,J.jsx)(q.Fragment,{children:BL(r,t,n)},i)),e),[])}var HL={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:zL(t,r)!==``},hasNullItemLabel:(e,t)=>t?LL(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>EL(t,e,n)):EL(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function UL(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=TL,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=IN(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=TN(),F=MN({id:t}),I=M||d,L=j??c,[R,ee]=nO({controlled:n,default:y?r??qv:r,name:`Select`,state:`value`}),[z,te]=nO({controlled:a,default:o,name:`Select`,state:`open`}),B=q.useRef([]),ne=q.useRef([]),V=q.useRef(null),H=q.useRef(null),re=q.useRef(0),ie=q.useRef(null),ae=q.useRef([]),oe=q.useRef(!1),se=q.useRef(null),U=q.useRef(null),ce=q.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),le=q.useRef(!1),ue=q.useRef(R),{openMethod:de,triggerProps:fe}=zA(z),pe=sv(()=>new mw({id:F,labelId:void 0,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:z,transitionStatus:void 0,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Jv,triggerProps:Jv,itemRoot:{props:Jv,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Kv,setOpen:Kv,handleScrollArrowVisibility:Kv,onOpenChangeComplete:Kv,listRef:B,popupRef:V,scrollHandlerRef:H,scrollArrowsMountedCountRef:re,valueRef:ie,valuesRef:ae,labelsRef:ne,typingRef:oe,selectionRef:ce,firstItemTextRef:se,selectedItemTextRef:U,alignItemWithTriggerActiveRef:le,initialValueRef:ue},HL)).current,[me,he]=q.useState(!1),{mounted:ge,transitionStatus:_e,forceUnmount:ve}=BC({open:z,ref:V,preventUnmountOnClose:me,setPreventUnmountOnClose:he,onUnmount(){pe.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),ye=pe.useState(`activeIndex`),be=pe.useState(`selectedIndex`),xe=pe.useState(`triggerElement`),Se=pe.useState(`positionerElement`),Ce=WE(de),we=de??Ce,Te=q.useMemo(()=>y?``:zL(R,x),[y,R,x]),Ee=q.useMemo(()=>y&&Array.isArray(R)?R.map(e=>zL(e,x)):zL(R,x),[y,R,x]);PN(rx(xe),F,R,Z(()=>Ee),!I,c);let De=y?Array.isArray(R)&&R.length>0:R!=null&&Te!==``;Q(()=>{A(De)},[De,A]),Q(function(){let e=jL(ae.current,R,S,y);e===null&&(U.current=null),!z&&pe.set(`selectedIndex`,e)},[y,z,R,S,pe]),LA(R,()=>{T(L),E(DL(R,k.initialValue,S)),N.change(R)});let Oe=Z((e,t)=>{let n=t,r=JC(n);s?.(e,n),!t.isCanceled&&(e||he(r()),te(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))});q.useImperativeHandle(h,()=>({unmount:ve,close:()=>{pe.state.open&&Oe(!1,Ab(Yb))}}),[ve,Oe,pe]);let ke=Z((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),Ae=Z(e=>{let t=DP(e.scrollHeight,e.clientHeight),n=OP(e.scrollTop,t),r=n>0,i=n<t;pe.set(`scrollUpArrowVisible`,r),pe.set(`scrollDownArrowVisible`,i)}),je=Tw({open:z,onOpenChange:Oe,elements:{reference:xe,floating:Se}}),Me=mC(je,{enabled:!I,event:`mousedown`}),Ne=bC(je),Pe=Hw(je,{enabled:!I,listRef:B,activeIndex:ye,selectedIndex:be,disabledIndices:qv,onNavigate(e){(e!==null||z)&&pe.set(`activeIndex`,e)},focusItemOnHover:C}),Fe=Uw(je,{enabled:!I&&(z||!f&&!y),listRef:ne,activeIndex:ye,selectedIndex:be,disabledIndices:e=>jO(B.current[e]),onMatch(e){z?pe.set(`activeIndex`,e):ke(ae.current[e],Ab(Mb))},onTyping(e){oe.current=e}}),Ie=q.useMemo(()=>mv(Fe.reference,Pe.reference,Ne.reference,Me.reference,fe),[Me.reference,Fe.reference,Pe.reference,Ne.reference,fe]),Le=q.useMemo(()=>mv(VC,Fe.floating,Pe.floating,Ne.floating),[Fe.floating,Pe.floating,Ne.floating]),Re=Pe.item??Jv,ze=q.useMemo(()=>({props:Re,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S}),[Re,y,I,f,S]);pe.useContextCallback(`setValue`,ke),pe.useContextCallback(`setOpen`,Oe),pe.useContextCallback(`handleScrollArrowVisibility`,Ae),pe.useContextCallback(`onOpenChangeComplete`,_),yL(()=>{pe.update({popupProps:Le,triggerProps:Ie,itemRoot:ze})}),pe.useSyncedValues({id:F,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,value:R,open:z,mounted:ge,transitionStatus:_e,popupProps:Le,triggerProps:Ie,itemRoot:ze,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:we});let Be=Lv(g,N.inputRef),Ve=y?void 0:L,He=q.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=zL(e,x);return(0,J.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,J.jsxs)(bL.Provider,{value:pe,children:[(0,J.jsx)(xL.Provider,{value:je,children:w}),(0,J.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){pe.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Ab(Mb,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ae.current.findIndex(t=>zL(t,x).toLowerCase()===e||RL(t,b).toLowerCase()===e);r===-1&&(r=ae.current.findIndex((t,n)=>{let r=ne.current[n];return r!=null&&r.toLowerCase()===e}));let i=ae.current[r];i!=null&&ke(i,n)}pe.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Ve==null?`${F}-hidden-input`:void 0,form:l,name:Ve,autoComplete:u,value:Te,disabled:I,required:p&&!(y&&De),readOnly:f,ref:Be,style:L?dx:ux,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),He]})}function WL(e,t){return e??t}var GL=5;function KL(e,t){let n=qL(t);return e.clientX>=n.left-GL&&e.clientX<=n.right+GL&&e.clientY>=n.top-GL&&e.clientY<=n.bottom+GL}function qL(e){let t=e.getBoundingClientRect(),n=I_(e);if(Py)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var JL=`data-popup-side`,YL=400,XL={...pb,...SN,popupSide:e=>e?{[JL]:e}:null,value:()=>null},ZL=q.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=TN(),{labelId:m}=ON(),h=SL(),g=h.useState(`readOnly`),_=h.useState(`required`),v=h.useState(`disabled`),y=p||v||a,b=h.useState(`open`),x=h.useState(`mounted`),S=h.useState(`value`),C=h.useState(`triggerProps`),w=h.useState(`positionerElement`),T=h.useState(`listElement`),E=h.useState(`popupSide`),D=h.useState(`id`),O=h.useState(`labelId`),k=h.useState(`hasSelectedValue`),A=x&&w?E:null,j=i??D,M=WL(m,O);MN({id:i});let N=rx(w),P=q.useRef(null),F=EN(y,P),{getButtonProps:I,buttonRef:L}=Pv({disabled:y,native:o}),R=h.useStateSetter(`triggerElement`),ee=by(),z=by(),te=by();q.useEffect(()=>{if(b)return te.start(YL,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[b,h,z,te]);let B=mv(C,{id:j,role:`combobox`,"aria-expanded":b,"aria-haspopup":`listbox`,"aria-controls":b?T?.id??wb(w)?.id:void 0,"aria-labelledby":M,"aria-readonly":g||void 0,"aria-required":_||void 0,tabIndex:y?-1:0,onFocus(e){F(!0),b&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,Ab(Mb,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){Hy(w,e.relatedTarget)||(l(!0),F(!1),u===`onBlur`&&d.commit(S))},onMouseDown(e){if(b)return;let t=Mv(e.currentTarget);function n(e){if(!P.current)return;let t=e.target;Hy(P.current,t)||Hy(N.current,t)||KL(e,P.current)||h.context.setOpen(!1,Ab(Wb,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),ne=d.getValidationProps(y,B);ne.role=`combobox`;let V={...f,open:b,disabled:y,value:S,readOnly:g,popupSide:A,placeholder:!k};return Qv(`button`,e,{ref:[t,P,L,R],state:V,stateAttributesMapping:XL,props:ne})}),QL={value:()=>null},$L=q.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=SL(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?VL(l,u,d):BL(l,u,d)),Qv(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:QL})}),eR=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Qv(`span`,e,{state:{open:SL().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:fb})}),tR=q.forwardRef(function(e,t){let n=SL(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,J.jsx)(JS,{ref:t,...e}):null}),nR=q.createContext(void 0);function rR(){let e=q.useContext(nR);if(!e)throw Error(Ov(59));return e}function iR(e,t){e&&Object.assign(e.style,t)}var aR={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},oR={position:`fixed`},sR=q.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=BS,style:_,...v}=e,y=SL(),b=CL(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=q.useRef(null),j=q.useRef(null),[M,N]=q.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),q.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),gM((P||C)&&x,T===`touch`,E,D);let F=IE({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?oR:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};Q(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=BE(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=q.useRef(0),te=Z(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=Ab(Mb);if(t!==0&&!y.state.multiple&&w!==null&&kL(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&kL(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>kL(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};iR(E,e),iR(y.context.popupRef.current,e)}}),B=q.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,J.jsx)(aO,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:te,children:(0,J.jsxs)(nR.Provider,{value:B,children:[S&&C&&(0,J.jsx)(hA,{inert:UE(!x),cutout:D}),ee]})})}),cR=`--transform-origin`,lR={...mb,...tb},uR=q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=SL(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=CL(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=rR(),_=Rj(!0)!=null,v=SE(),{nonce:y,disableStyleElements:b}=DO(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),k=s.useState(`listElement`),A=q.useRef(!1),j=q.useRef(!1),M=q.useRef({}),N=cx(),P=Z(e=>{if(!O||!s.context.popupRef.current||!j.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(A.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=pR(O),i=mR(O.getBoundingClientRect().height,`y`,r),a=Mv(O),o=I_(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=dR(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=fR(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=TP(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(A.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=TP(g,0,fR(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});q.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),zC({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let F={open:S,transitionStatus:E,side:f,align:p};Q(()=>{O&&s.context.popupRef.current&&!Object.keys(M.current).length&&(M.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),Q(()=>{S||m||(j.current=!1,A.current=!1,iR(O,M.current))},[S,m,O]),Q(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(j.current=!0,e.style.removeProperty(cR),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=_R(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=I_(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=Mv(D),c=pR(D),l=hR(D.getBoundingClientRect(),c),d=hR(O.getBoundingClientRect(),c),f=l.height,p=k||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=dR(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,j=0;if(t&&n){let e=hR(n.getBoundingClientRect(),c);T=hR(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;j=T.top-d.top+T.height/2-r}let N=w+j+y+h,P=Math.min(S,N),F=S-_-y,I=N-P,L=C-5;O.style.left=`${TP(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=fR(p),ee=I>=R-1;ee&&(P=Math.min(S,d.height)-(I-R));let z=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),te=(r.visualViewport?.scale??1)!==1&&My;if(z||te){iR(O,M.current),g(!1);return}let B=Math.max(b,P);if(ee){let e=Math.max(0,S-N);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=fR(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=TP(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(cR,`50% ${i}%`)}(B===S||P>=x)&&(A.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,N,k,u,v,h]),q.useEffect(()=>{if(!m||!O||!S)return;let e=I_(O);function t(e){s.context.setOpen(!1,Ab(Xb,e))}return tx(e,`resize`,t)},[s,m,O,S]);let I={...k?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&IO.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:aR},className:!k&&m?sP.className:void 0},L=Qv(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:lR,props:[T,I,zE(E),o]});return(0,J.jsxs)(q.Fragment,{children:[!b&&sP.getElement(y),(0,J.jsx)(pC,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function dR(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function fR(e){return DP(e.scrollHeight,e.clientHeight)}function pR(e){return PT.getScale(e)}function mR(e,t,n){return e/n[t]}function hR(e,t){return zx({x:mR(e.x,`x`,t),y:mR(e.y,`y`,t),width:mR(e.width,`x`,t),height:mR(e.height,`y`,t)})}var gR=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function _R(e){let{style:t}=e,n={};for(let[e,r]of gR)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of gR){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var vR=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=SL(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=rR(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:aR},className:u&&d!==`touch`?sP.className:void 0};return Qv(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),yR=q.createContext(void 0);function bR(){let e=q.useContext(yR);if(!e)throw Error(Ov(57));return e}var xR=q.memo(q.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=q.useRef(null),d=bO({guess:!0,label:o,textRef:u}),f=SL(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:_}=f.useState(`itemRoot`),v=h||s,y=f.useState(`isActive`,d.index),b=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=d.index,w=q.useRef(null);Q(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),Q(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=ML(C,a,f.context.valuesRef.current,e,_,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&EL(a,e,_),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,_,f,a]);let T=q.useRef(`mouse`),E=q.useRef(!1),{getButtonProps:D,buttonRef:O}=Pv({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:v,selected:x,highlighted:y};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?NL(n,a,_):[...n,a];f.context.setValue(r,Ab(Lb,e))}else f.context.setValue(a,Ab(Lb,e)),f.context.setOpen(!1,Ab(Lb,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":x,tabIndex:b&&y?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Ly(e.nativeEvent)&&(n!==void 0||y),i=t&&!r&&!E.current;E.current=!1,!(v||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),v||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=Qv(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=q.useMemo(()=>({selected:x,index:C,textRef:u,selectedByFocus:S}),[x,C,u,S]);return(0,J.jsx)(yR.Provider,{value:P,children:N})})),SR=q.memo(q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=q.useRef(null),{transitionStatus:l,setMounted:u}=PC(o),d=Qv(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:tb});return zC({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),CR=q.forwardRef(function(e,t){let{selected:n}=bR();return e.keepMounted||n?(0,J.jsx)(SR,{...e,selected:n,ref:t}):null}),wR=q.memo(q.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=bR(),a=SL(),{render:o,className:s,style:c,...l}=e;return Qv(`div`,e,{ref:[q.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),TR=q.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=SL(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=rR(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=by(),v=c?f:d,{mounted:y,transitionStatus:b,setMounted:x}=PC(g);Q(()=>(l.context.scrollArrowsMountedCountRef.current+=1,l.set(`hasScrollArrows`,!0),()=>{l.context.scrollArrowsMountedCountRef.current=Math.max(0,l.context.scrollArrowsMountedCountRef.current-1),l.context.scrollArrowsMountedCountRef.current===0&&l.set(`hasScrollArrows`,!1)}),[l]),zC({open:g,ref:v,onComplete(){g||x(!1)}});let S=Qv(`div`,e,{ref:[t,v],state:{direction:a,visible:g,side:u,transitionStatus:b},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||_.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??l.context.popupRef.current;if(!e)return;l.set(`activeIndex`,null),l.context.handleScrollArrowVisibility(e);let n=DP(e.scrollHeight,e.clientHeight),r=OP(e.scrollTop,n),i=r===(c?0:n),a=l.context.listRef.current;if(r!==e.scrollTop&&(e.scrollTop=r),i)_.clear();else{if(a.length>0){let t=v.current?.offsetHeight||0;e.scrollTop=ER(a,c,r,e.clientHeight,t,n)}_.start(40,t)}}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:tb});return y||o?S:null});function ER(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?OP(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?OP(l.offsetTop+l.offsetHeight-r+i,a):a}var DR=q.forwardRef(function(e,t){return(0,J.jsx)(TR,{...e,ref:t,direction:`down`})}),OR=q.forwardRef(function(e,t){return(0,J.jsx)(TR,{...e,ref:t,direction:`up`})}),kR=UL;function AR({className:e,...t}){return(0,J.jsx)($L,{"data-slot":`select-value`,className:X(`flex flex-1 text-left`,e),...t})}function jR({className:e,size:t=`default`,children:n,...r}){return(0,J.jsxs)(ZL,{"data-slot":`select-trigger`,"data-size":t,className:X(`flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-ui whitespace-nowrap transition-colors select-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,J.jsx)(eR,{render:(0,J.jsx)(Bh,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function MR({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,J.jsx)(tR,{children:(0,J.jsx)(sR,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,J.jsxs)(uR,{"data-slot":`select-content`,"data-align-trigger":o,className:X(`relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-(--duration-fast) data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...s,children:[(0,J.jsx)(PR,{}),(0,J.jsx)(vR,{children:t}),(0,J.jsx)(FR,{})]})})})}function NR({className:e,children:t,...n}){return(0,J.jsxs)(xR,{"data-slot":`select-item`,className:X(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,J.jsx)(wR,{className:`flex flex-1 shrink-0 gap-2 whitespace-nowrap`,children:t}),(0,J.jsx)(CR,{render:(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,J.jsx)(Rh,{className:`pointer-events-none`})})]})}function PR({className:e,...t}){return(0,J.jsx)(OR,{"data-slot":`select-scroll-up-button`,className:X(`top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,J.jsx)(Kh,{})})}function FR({className:e,...t}){return(0,J.jsx)(DR,{"data-slot":`select-scroll-down-button`,className:X(`bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,J.jsx)(Bh,{})})}var IR={"look-for":{label:`Look for`,icon:o_,className:`border-diff-hunk-fg/25 bg-diff-hunk-bg text-diff-hunk-fg`},"dont-flag":{label:`Don't flag`,icon:fg,className:`border-border bg-muted text-muted-foreground`}},LR=({kind:e,className:t})=>{let{label:n,icon:r,className:i}=IR[e];return(0,J.jsxs)(`span`,{"data-slot":`preference-kind`,"data-kind":e,className:X(`inline-flex h-5 shrink-0 items-center gap-1 rounded-full border px-2 text-caption font-medium whitespace-nowrap`,i,t),children:[(0,J.jsx)(r,{"aria-hidden":`true`,className:`size-3`}),n]})},RR={written:`written`,learned:`learned`,imported:`imported`},zR={kind:`global`},BR=({owner:e,repo:t})=>`${e}/${t}`,VR=({host:e,owner:t,repo:n})=>`${e}/${t}/${n}`,HR=e=>e.kind===`global`?`global`:VR(e.repo),UR=e=>[{key:HR(zR),label:`Everywhere`,scope:zR},...e.map(t=>{let n=e.some(e=>e!==t&&BR(e)===BR(t));return{key:VR(t),label:n?`${BR(t)} on ${_F[t.host]}`:BR(t),scope:{kind:`repo`,repo:t}}})],WR=e=>{let t=(0,q.useRef)(null),n=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{e?n.current=!0:n.current&&(n.current=!1,t.current?.focus())},[e]),t},GR=`Write the rule first.`,KR=e=>`A preference is one sentence of at most 300 characters: this is ${e} too many.`,qR=[`look-for`,`dont-flag`],JR={"look-for":{label:`What an AI review should look for`,example:`Tenant isolation: every query filters by tenant ID`},"dont-flag":{label:`What an AI review should leave out`,example:`Naming`}},YR=({legend:e,initial:t,scopes:n,kindFixed:r=!1,submit:i,submitting:a,note:o=null,focus:s=!1,onSubmit:c,onCancel:l})=>{let u=(0,q.useId)(),[d,f]=(0,q.useState)(t.kind),[p,m]=(0,q.useState)(t.text),[h,g]=(0,q.useState)(HR(t.scope)),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(o),x=(0,q.useRef)(null);(0,q.useEffect)(()=>{s&&x.current!==null&&(x.current.focus(),x.current.setSelectionRange(x.current.value.length,x.current.value.length))},[]);let S=n.find(e=>e.key===h)??n[0],C=p.trim().length,w=C-300,T=async e=>{if(e.preventDefault(),_||S===void 0)return;if(C===0)return b(GR);if(w>0)return b(KR(w));v(!0),b(null);let t=await c({kind:d,text:p.trim(),scope:S.scope});v(!1),b(t)};return(0,J.jsxs)(`form`,{"aria-label":e,"data-slot":`preference-form`,className:`flex flex-col gap-2.5`,onSubmit:e=>void T(e),noValidate:!0,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[r?(0,J.jsx)(LR,{kind:d}):(0,J.jsxs)(`fieldset`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`legend`,{className:`sr-only`,children:`Kind`}),qR.map(e=>{let{label:t,icon:n}=IR[e];return(0,J.jsxs)(Bj,{variant:`outline`,size:`sm`,pressed:d===e,onPressedChange:t=>{t&&f(e)},children:[(0,J.jsx)(n,{"aria-hidden":`true`}),t]},e)})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{id:`${u}-scope`,className:`shrink-0 text-caption text-muted-foreground`,children:`Applies to`}),n.length>1&&S!==void 0?(0,J.jsxs)(kR,{value:S.key,items:n.map(e=>({value:e.key,label:e.label})),onValueChange:e=>{typeof e==`string`&&g(e)},children:[(0,J.jsx)(jR,{size:`sm`,className:`max-w-64 min-w-0`,"aria-labelledby":`${u}-scope`,children:(0,J.jsx)(AR,{})}),(0,J.jsx)(MR,{alignItemWithTrigger:!1,align:`start`,children:n.map(e=>(0,J.jsx)(NR,{value:e.key,children:e.label},e.key))})]}):(0,J.jsx)(`span`,{className:`truncate`,children:S?.label.toLowerCase()})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`label`,{htmlFor:`${u}-text`,className:`text-caption font-medium`,children:JR[d].label}),(0,J.jsx)($O,{ref:x,id:`${u}-text`,rows:2,className:`min-h-14 bg-card`,placeholder:JR[d].example,value:p,onChange:e=>{m(e.target.value.replace(/\s*\n\s*/g,` `)),b(null)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"aria-invalid":y!==null||w>0,"aria-describedby":`${u}-count ${u}-problem`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-3 text-caption`,children:[(0,J.jsx)(`span`,{id:`${u}-problem`,role:`status`,className:`min-w-0 flex-1 text-destructive`,children:y!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),y]})}),(0,J.jsxs)(`span`,{id:`${u}-count`,"data-slot":`character-count`,className:X(`tabular shrink-0`,w>0?`text-destructive`:`text-muted-foreground`),children:[C,`/`,300,(0,J.jsx)(`span`,{className:`sr-only`,children:` characters`}),w>0&&`, ${w} too many`]})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[l!==void 0&&(0,J.jsx)($,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,J.jsx)($,{type:`submit`,size:`sm`,disabled:_,focusableWhenDisabled:!0,"aria-busy":_,children:_?a:i})]})]})},XR=q.createContext(void 0);function ZR(e){let t=q.useContext(XR);if(t===void 0&&!e)throw Error(Ov(33));return t}var QR=q.createContext(void 0);function $R(e){let t=q.useContext(QR);if(t===void 0&&!e)throw Error(Ov(36));return t}var ez=q.createContext(void 0);function tz(e=!0){let t=q.useContext(ez);if(t===void 0&&!e)throw Error(Ov(25));return t}var nz=q.createContext(null);function rz(e=`root`){let t=q.useContext(nz),n=q.useContext(QR);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var iz={visible:!0,ref:null};function az(){return iz}function oz(e,t,n=`root`){let r=rz(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??az)({label:e.label,children:e.children,render:e.render}),a=Lv(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var sz=q.createContext(void 0);function cz(){let e=q.useContext(sz);if(e===void 0)throw Error(Ov(30));return e}function lz(e){e.preventDefault()}function uz(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=$R(),u=tz(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return q.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?lz:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:Lb})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Ay&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Nv(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var dz={type:`regular-item`};function fz(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=q.useRef(null),{getButtonProps:d,buttonRef:f}=Pv({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=uz({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=q.useCallback(e=>mv(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Lv(u,f);return q.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var pz=`data-checked`,mz=`data-unchecked`,hz={checked(e){return e?{[pz]:``}:{[mz]:``}},...tb},gz=q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=$R(),m=bO({guess:!0,label:a}),h=gE(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=fz({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:dz}),C=q.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=Ab(Lb,e.nativeEvent,void 0,{preventUnmountOnClose:Kv});u?.(!l,t)}let T=Qv(`div`,e,{state:C,stateAttributesMapping:hz,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,J.jsx)(sz.Provider,{value:C,children:T})}),_z=q.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=nO({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=oz(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,J.jsx)(gz,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),vz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=cz(),c=q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=PC(s.checked);return zC({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Qv(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:hz,props:{"aria-hidden":!0,...o},enabled:a||u})}),yz=q.createContext(void 0);function bz(){let e=q.useContext(yz);if(e===void 0)throw Error(Ov(31));return e}var xz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=q.useState(void 0),c=Qv(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,J.jsx)(yz.Provider,{value:s,children:c})}),Sz=q.forwardRef(function(e,t){let n=rz()?.Group??xz;return(0,J.jsx)(n,{...e,ref:t})}),Cz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=gE(a),c=bz();return Q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Qv(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),wz=q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=$R(),f=bO({guess:!0,label:a}),p=gE(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=fz({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:dz});return Qv(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),Tz=q.forwardRef(function(e,t){let n=oz(e,t);return n.visible?(0,J.jsx)(wz,{...e,ref:n.ref}):null}),Ez=q.createContext(void 0);function Dz(){return q.useContext(Ez)}function Oz(e,t){let n=ny(e.render);if(q.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function kz(e,t,n){let r=Oz(e,t),i=r===t?void 0:r;return[r,q.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Az(e,t,n){let r=ny(e.render),i=q.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var jz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=$R(),m=Dz(),{side:h,align:g}=ZR(),_=Rj(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=kz(e,u,d),L=Az(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,z=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(z=()=>l.state.activeIndex===null&&P),zC({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),q.useEffect(()=>{function e(e){l.setOpen(!1,Ab(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Nw(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let te=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:B,handleFocus:ne}=(q.useContext(nz)?.useParentHandoff??Nz)(l,w,v,f),V=Qv(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,te,I],stateAttributesMapping:hb,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&IO.has(e.key)&&e.stopPropagation()},onFocus:ne},zE(y),c,{"data-rootownerid":E}]}),H=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(H=!0);let re=R?.getReturnElement??B;return(0,J.jsx)(pC,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??re??H,explicitReturnFocus:a===void 0&&re?!1:void 0,initialFocus:z,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:V})}),Mz={parentVirtualFocusRef:void 0,handleFocus:void 0};function Nz(){return Mz}var Pz=q.forwardRef(function(e,t){let n=rz()?.Popup??jz;return(0,J.jsx)(n,{...e,ref:t})}),Fz=q.createContext(void 0);function Iz(){let e=q.useContext(Fz);if(e===void 0)throw Error(Ov(32));return e}var Lz=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=$R();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,J.jsx)(Fz.Provider,{value:n,children:(0,J.jsx)(JS,{ref:t,...r,portalOwnerRole:o})})}),Rz=q.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=BS,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=$R(),x=Iz(),S=tz(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=n,z=c,te=l,B=s,ne=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,B??=`start`,!o&&B!==`center`&&(te=e.alignOffset??2,z=e.sideOffset??-5));let V=o,H=B;C.type===`menu`?(V??=`inline-end`,H??=`start`,ne=e.collisionAvoidance??VS):C.type===`menubar`&&(V??=C.context.orientation===`vertical`?`inline-end`:`bottom`,H??=`start`);let re=C.type===`context-menu`,ie=IE({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:V,sideOffset:z,align:H,alignOffset:te,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ne,shift:re?{crossAxis:!(`side`in ne&&ne.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});q.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Ab(Gb)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),q.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Ab(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ae=by();q.useEffect(()=>{D||ae.clear()},[D,ae]),q.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?ae.isStarted()||ae.start(e,()=>{v.setOpen(!1,Ab(Gb))}):v.setOpen(!1,Ab(Gb))}else ae.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ae]),q.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),mM({store:v,domReference:R,positionerElement:M,open:D});let oe={open:D,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:C.type===`menu`,instant:N},se=C.type===`menubar`&&C.context.modal;gM(D&&(se||O&&F!==`trigger-hover`),k===`touch`,M,A);let U=BE(e,oe,{styles:ie.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),ce=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),le=null;return C.type===`menubar`?le=C.context.contentElement:C.type===void 0&&(le=A),(0,J.jsxs)(XR.Provider,{value:ie,children:[ce&&(0,J.jsx)(hA,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:UE(!D),cutout:le}),(0,J.jsx)(nC,{id:I,children:(0,J.jsx)(aO,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:U})})]})}),zz=q.createContext(void 0);function Bz(){let e=q.useContext(zz);if(e===void 0)throw Error(Ov(34));return e}var Vz=q.forwardRef(function(e,t){let{render:n,className:r,value:i,defaultValue:a,onValueChange:o,disabled:s=!1,style:c,"aria-labelledby":l,...u}=e,[d,f]=q.useState(void 0),[p,m]=nO({controlled:i,default:a,name:`MenuRadioGroup`}),h=Z((e,t)=>{o?.(e,t),!t.isCanceled&&m(e)}),g=Qv(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=q.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return(0,J.jsx)(yz.Provider,{value:f,children:(0,J.jsx)(zz.Provider,{value:_,children:g})})}),Hz=q.memo(q.forwardRef(function(e,t){let n=rz()?.RadioGroup??Vz;return(0,J.jsx)(n,{...e,ref:t})})),Uz=q.createContext(void 0);function Wz(){let e=q.useContext(Uz);if(e===void 0)throw Error(Ov(35));return e}var Gz=q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,value:l,style:u,...d}=e,{store:f}=$R(),{value:p,setValue:m,disabled:h}=Bz(),g=bO({guess:!0,label:a}),_=gE(i),v=f.useState(`isActive`,g.index),y=f.useState(`floatingNodeId`),b=f.useState(`itemProps`),x=f.useState(`disabled`),S=s||h||x,C=p===l,{getItemProps:w,itemRef:T}=fz({closeOnClick:c,disabled:S,highlighted:v,id:_,store:f,nativeButton:o,nodeId:y,itemMetadata:dz}),E=q.useMemo(()=>({disabled:S,highlighted:v,checked:C}),[S,v,C]);function D(e){let t=Ab(Lb,e.nativeEvent,void 0,{preventUnmountOnClose:Kv});m(l,t)}let O=Qv(`div`,e,{state:E,stateAttributesMapping:hz,props:[b,{role:`menuitemradio`,"aria-checked":C,onClick:D},d,w],ref:[T,t,g.ref]});return(0,J.jsx)(Uz.Provider,{value:E,children:O})}),Kz=q.forwardRef(function(e,t){let n=oz(e,t);return n.visible?(0,J.jsx)(Gz,{...e,ref:n.ref}):null}),qz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Wz(),c=q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=PC(s.checked);return zC({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Qv(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:hz,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),Jz=q.createContext(null);function Yz(e){let t=q.useContext(Jz);if(t===null&&!e)throw Error(Ov(5));return t}function Xz(e){return e==null?Mb:e.type.startsWith(`key`)?Hb:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Ub:Mb}var Zz={...Cw,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Cw.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>My&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Cw.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Qz=class extends mw{constructor(e,t,n=!1){let r=new tw,i=eB(r,t,n,e);super(i,$z(r),Zz),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function $z(e){return{positionerRef:q.createRef(),popupRef:q.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function eB(e,t,n=!1,r){return{..._w(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:Jv,inputProps:Jv,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new XS,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Jv,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var tB=q.createContext(null);function nB(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function rB(e,t){return e===`list-navigation`||nB(e,t)}var iB=my(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=tz(!0),C=$R(!0),w=Yz(!0),T=C?.store,E=C?.virtualFocus??!1,D=q.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=gE(),k=gE(),[A,j]=q.useState(void 0),M=(A??k)||void 0,N=$S(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=sv(()=>F?P?.state.instantType:void 0).current,L=sv(()=>{let e=new Qz({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),ee=tC(R),z=L.useState(`open`),te=L.useState(`activeTriggerElement`),B=L.useState(`positionerElement`),ne=L.useState(`hoverEnabled`),V=L.useState(`disabled`),H=L.useState(`lastOpenChangeReason`),re=L.useState(`parent`),ie=L.useState(`activeIndex`),ae=L.useState(`keyboardOpen`),oe=L.useState(`payload`),se=L.useState(`floatingParentNodeId`),U=q.useRef(null),ce=q.useRef(re.type!==`context-menu`),le=by(),ue=q.useRef(!0),de=by(),fe=se!=null,{openMethod:pe,triggerProps:me}=zA(z);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:re.type===void 0?c:void 0,openMethod:pe,rootId:O}),ZC(L);let{forceUnmount:he,transitionStatus:ge}=QC(z,L,()=>{L.set(`allowMouseEnter`,!1)},F),_e=RC(L.context.popupRef);q.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!z){e();return}if(ge!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return _e(e,t.signal),()=>{t.abort()}},[I,z,ge,_e,L]),Q(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ee,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ee,floatingParentNodeId:N})},[S,C,ee,N,te,L]),q.useEffect(()=>{z||(U.current=null),re.type===`context-menu`&&(z?le.start(500,()=>{ce.current=!0}):(le.clear(),ce.current=!1))},[le,z,re.type]),Q(()=>{!z&&!ne&&L.set(`hoverEnabled`,!0)},[z,ne,L]);let ve=Z((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||z===e&&t.trigger===te&&H===n)return;let i=JC(t);if(!e&&t.trigger==null&&(t.trigger=te??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ue.current)return;e&&n===`trigger-focus`?(ue.current=!1,de.start(300,()=>{ue.current=!0})):(ue.current=!0,de.clear());let o=!e&&(n===`escape-key`||n==null);U.current=t.event;let s=qC(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&rB(n,a),s.instantType=re.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:nB(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),ye=NC({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:ve}),be=ye.context.events;Q(()=>{let e=({open:e,eventDetails:t})=>ve(e,t);return be.on(`setOpen`,e),()=>{be?.off(`setOpen`,e)}},[be,ve]),Q(()=>L.subscribeToParentMenu(),[L]);let xe=q.useCallback(()=>{L.setOpen(!1,Ab(Yb))},[L]);q.useImperativeHandle(d,()=>({unmount:he,close:xe}),[he,xe]);let Se;re.type===`context-menu`&&(Se=re.context),q.useImperativeHandle(Se?.positionerRef,()=>B,[B]),q.useImperativeHandle(Se?.actionsRef,()=>({setOpen:ve}),[ve]);let Ce=bC(ye,{enabled:!V,bubbles:{escapeKey:f&&re.type===`menu`},outsidePress(){return re.type!==`context-menu`||U.current?.type===`contextmenu`||ce.current},externalTree:fe?R:void 0}),we=SE(),Te=Hw(ye,{enabled:!V,listRef:L.context.itemDomElements,activeIndex:ie,virtual:v,nested:re.type===`menubar`||!v&&re.type!==void 0,parentOrientation:re.type===`menubar`?re.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?ae:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:we===`rtl`,disabledIndices:qv,onNavigate(e,t){L.setActiveIndex(e,Xz(t),t?.nativeEvent)},openOnArrowKeyDown:re.type!==`context-menu`&&!(v&&_),externalTree:!v&&fe?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Ee=q.useCallback(e=>{L.context.typingRef.current=e},[L]),De=Uw(ye,{enabled:!V&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:ie,resetMs:500,onMatch:(e,t)=>{z&&e!==ie&&L.setActiveIndex(e,Hb,t.nativeEvent)},onTyping:Ee}),Oe=Z(a),ke=q.useRef(-1),Ae=Z(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(ke.current===n&&L.context.reportedItem===t)return;ke.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Mb,L.context.highlightEvent=void 0,a&&Oe(t,jb(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});Q(()=>{Ae()},[ie,Ae]);let je=q.useMemo(()=>{if(!v)return Te.reference;if(!Te.trigger)return Jv;let{onFocus:e,...t}=Te.trigger;return t},[v,Te.reference,Te.trigger]);L.useSyncedValue(`inputProps`,v?Te.reference??Jv:Jv);let Me=q.useMemo(()=>{let e=mv(De.reference,je,Ce.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},me);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=z,e},[L,De.reference,je,Ce.reference,me,z]),Ne=q.useMemo(()=>{let e=mv(Te.trigger,Ce.trigger,me);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Te.trigger,Ce.trigger,me]);sv(()=>(L.update({inactiveTriggerProps:Ne}),null)),$C(L,{floatingRootContext:ye,activeTriggerProps:Me,inactiveTriggerProps:Ne,popupProps:q.useMemo(()=>mv(VC,{onMouseMove(){L.set(`allowMouseEnter`,!0),re.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},De.floating,Te.floating,Ce.floating),[re.type,L,De.floating,Te.floating,Ce.floating]),itemProps:Te.item??Jv});let Pe=q.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Ae}),[L,D,u,l,b,k,v,E,Ae]),Fe=typeof t==`function`?t({payload:oe}):t,Ie=(0,J.jsxs)(QR.Provider,{value:Pe,children:[p&&(0,J.jsx)(WC,{handle:p,store:L}),Fe]});return(re.type===void 0||re.type===`context-menu`)&&(Ie=(0,J.jsx)(rC,{externalTree:R,children:Ie})),Ie});function aB(e){let t=q.useContext(tB);if(t===null)return(0,J.jsx)(iB,{...e});let n=t.Root;return(0,J.jsx)(tB.Provider,{value:null,children:(0,J.jsx)(n,{...t.options,...e})})}function oB(e){if(B_(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Q_(e))return oB(tv(e))}function sB(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=q.useRef(!1);return q.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Mv(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Jv,[t,n,r])}var cB=hy(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=$R(!0),h=ww(d)??m?.store;if(!h)throw Error(Ov(85));let g=gE(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=q.useRef(null),S=uB(),C=Av(!0),w=eC(),T=q.useMemo(()=>w??new XS,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=XC(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:tC(T),floatingParentNodeId:$S(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Pv({disabled:A,native:o});q.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=q.useRef(null),P=by(),F=Z(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Hy(N.current,t)||Hy(h.select(`positionerElement`),t)||t===N.current||(t==null||oB(t)!==h.select(`rootId`))&&(KL(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Wb}))});q.useEffect(()=>{let e=Mv(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=Fw(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:Zw({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=lB(y,h.select(`lastOpenChangeReason`)),ee=mC(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Dw(v,{enabled:!A&&I}),te=sB({open:y,enabled:O,mouseDownAction:`open`}),B=q.useMemo(()=>mv(z.reference,ee.reference),[z.reference,ee.reference]),ne=h.useState(`triggerProps`,D),V=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:H,handleFocusTargetFocus:re}=sM(h,x),ie={disabled:A,open:y},ae=[N,t,M,E,x],oe=[B,L??Jv,ne,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Mv(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},V,O?{role:`menuitem`}:{},te,p,j],se=Qv(`button`,e,{enabled:!O,stateAttributesMapping:pb,state:ie,ref:ae,props:oe});return O?(0,J.jsx)(Fj,{tag:`button`,render:n,className:r,style:i,state:ie,refs:ae,props:oe,stateAttributesMapping:pb}):y?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(fx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:H},`${g}-pre-focus-guard`),(0,J.jsx)(q.Fragment,{children:se},g),(0,J.jsx)(fx,{ref:h.context.triggerFocusTargetRef,onFocus:re},`${g}-post-focus-guard`)]}):(0,J.jsx)(q.Fragment,{children:se},g)});function lB(e,t){let n=by(),[r,i]=q.useState(!1);return Q(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function uB(){let e=Yz(!0);return q.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var dB=q.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Qv(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function fB({...e}){return(0,J.jsx)(aB,{"data-slot":`dropdown-menu`,...e})}function pB({...e}){return(0,J.jsx)(cB,{"data-slot":`dropdown-menu-trigger`,...e})}function mB({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,J.jsx)(Lz,{children:(0,J.jsx)(Rz,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,J.jsx)(Pz,{"data-slot":`dropdown-menu-content`,className:X(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-(--duration-fast) outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function hB({...e}){return(0,J.jsx)(Sz,{"data-slot":`dropdown-menu-group`,...e})}function gB({className:e,inset:t,...n}){return(0,J.jsx)(Cz,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:X(`px-1.5 py-1 text-caption font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function _B({className:e,inset:t,variant:n=`default`,...r}){return(0,J.jsx)(Tz,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:X(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function vB({className:e,children:t,checked:n,inset:r,...i}){return(0,J.jsxs)(_z,{"data-slot":`dropdown-menu-checkbox-item`,"data-inset":r,className:X(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-checkbox-item-indicator`,children:(0,J.jsx)(vz,{children:(0,J.jsx)(Rh,{})})}),t]})}function yB({...e}){return(0,J.jsx)(Hz,{"data-slot":`dropdown-menu-radio-group`,...e})}function bB({className:e,children:t,inset:n,...r}){return(0,J.jsxs)(Kz,{"data-slot":`dropdown-menu-radio-item`,"data-inset":n,className:X(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,J.jsx)(qz,{children:(0,J.jsx)(Rh,{})})}),t]})}function xB({className:e,...t}){return(0,J.jsx)(dB,{"data-slot":`dropdown-menu-separator`,className:X(`-mx-1 my-1 h-px bg-border`,e),...t})}var SB=({title:e,onClose:t,children:n,className:r,returnFocus:i=()=>!0})=>{let a=(0,q.useRef)(null);return(0,J.jsx)(BA,{open:!0,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(UA,{ref:a,className:X(`max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg`,r),initialFocus:()=>a.current?.querySelector(`[data-autofocus]`)??!0,finalFocus:()=>i(),children:[(0,J.jsx)(WA,{className:`shrink-0 pr-8`,children:(0,J.jsx)(GA,{children:e})}),n]})})},CB=({preference:e,onDelete:t,onClose:n})=>{let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null);return(0,J.jsxs)(SB,{title:`Delete preference`,onClose:n,children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(LR,{kind:e.kind}),(0,J.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}),(0,J.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`AI reviews stop using it. A review already made keeps what it says of it.`}),a!==null&&(0,J.jsxs)(`p`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[`Couldn't delete it. `,a]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:n,children:`Cancel`}),(0,J.jsx)($,{variant:`destructive`,disabled:r,onClick:async()=>{i(!0);let e=await t();i(!1),o(e),e===null&&n()},children:r?`Deleting…`:`Delete`})]})]})},wB=({preference:e,scopes:t,actions:n})=>{let[r,i]=(0,q.useState)(`shown`),[a,o]=(0,q.useState)(null),s=WR(r===`editing`),{id:c,kind:l,text:u,source:d,enabled:f}=e;return r===`editing`?(0,J.jsx)(`li`,{className:`bg-surface-subtle px-4 py-3`,children:(0,J.jsx)(YR,{legend:`Edit: ${u}`,initial:e,scopes:t,submit:`Save`,submitting:`Saving…`,onCancel:()=>i(`shown`),onSubmit:async e=>{let t=await n.onEdit(c,e);return t===null&&i(`shown`),t}})}):(0,J.jsxs)(`li`,{"data-slot":`preference`,"data-enabled":f,className:`flex min-h-11 flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2`,children:[(0,J.jsx)(LR,{kind:l}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-56 break-words`,!f&&`text-muted-foreground`),children:u}),(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[RR[d],!f&&` · off`]}),(0,J.jsx)(ZN,{checked:f,"aria-label":`Use in AI reviews: ${u}`,onCheckedChange:async e=>{o(null),o(await n.onSwitch(c,e))}}),(0,J.jsxs)(fB,{children:[(0,J.jsx)(pB,{render:(0,J.jsx)($,{ref:s,variant:`ghost`,size:`icon-xs`,"aria-label":`More for: ${u}`}),children:(0,J.jsx)(Qh,{"aria-hidden":`true`})}),(0,J.jsxs)(mB,{align:`end`,className:`w-36`,children:[(0,J.jsxs)(_B,{onClick:()=>i(`editing`),children:[(0,J.jsx)(Qg,{"aria-hidden":`true`}),`Edit`]}),(0,J.jsxs)(_B,{variant:`destructive`,onClick:()=>i(`deleting`),children:[(0,J.jsx)(g_,{"aria-hidden":`true`}),`Delete…`]})]})]})]}),a!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),a]}),r===`deleting`&&(0,J.jsx)(CB,{preference:e,onDelete:()=>n.onDelete(c),onClose:()=>i(`shown`)})]})},TB=({preferences:e,scopes:t,actions:n,label:r})=>(0,J.jsx)(`ul`,{"aria-label":r,className:`divide-y`,children:e.map(e=>(0,J.jsx)(wB,{preference:e,scopes:t,actions:n},e.id))}),EB=({option:e,title:t,word:n,preferences:r,scopes:i,actions:a,addable:o=!0,adding:s,onAdding:c,onAdd:l,empty:u,children:d})=>{let f=(0,q.useId)(),p=(0,q.useRef)(null),m=()=>{c(!1),p.current?.focus()};return(0,J.jsxs)(`section`,{"aria-labelledby":f,"data-slot":`preference-scope`,className:`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2`,children:[(0,J.jsx)(`h2`,{id:f,className:`flex min-w-0 items-center gap-2 text-heading font-semibold`,children:t}),(0,J.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:r.length}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[r.length,` `,r.length===1?`preference`:`preferences`]})]}),(0,J.jsx)(`span`,{className:`min-w-0 text-caption text-muted-foreground max-sm:order-last max-sm:basis-full`,children:n}),o&&(0,J.jsxs)($,{ref:p,variant:`outline`,size:`sm`,className:`ml-auto`,"aria-expanded":s,"aria-label":e.scope.kind===`repo`?`Add preference for ${e.label}`:void 0,onClick:()=>c(!s),children:[(0,J.jsx)(e_,{"aria-hidden":`true`}),`Add preference`]})]}),s&&(0,J.jsx)(`div`,{className:`border-b bg-surface-subtle px-4 py-3`,children:(0,J.jsx)(YR,{legend:`Add a preference`,initial:{kind:`look-for`,text:``,scope:e.scope},scopes:i,submit:`Add preference`,submitting:`Adding…`,focus:!0,onCancel:m,onSubmit:async e=>{let t=await l(e);return t===null&&m(),t}})}),r.length===0?u:(0,J.jsx)(TB,{preferences:r,scopes:i,actions:a,label:`Preferences for ${e.label.toLowerCase()}`}),d]})},DB={learned:`from what you did in reviews`,imported:`from your past reviews`},OB=({proposal:e,scopes:t,actions:n})=>{let{id:r,kind:i,text:a,scope:o,evidence:s}=e,c=a.length-300,[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),h=WR(l!==null),g=t.find(e=>e.key===HR(o))?.label??`Everywhere`,_=async e=>{if(d!==null)return;if(e===`accept`&&c>0)return u({note:KR(c)});f(e),m(null);let t=await(e===`accept`?n.onAccept(r,null):n.onReject(r));f(null),m(t)};return l===null?(0,J.jsxs)(`li`,{"data-slot":`proposal`,className:`flex flex-col gap-1.5 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(LR,{kind:i}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 font-medium break-words`,children:a}),(0,J.jsxs)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:[g,`, `,DB[e.source]]})]}),s.length>0&&(0,J.jsxs)(`div`,{className:`flex gap-1.5 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`shrink-0`,children:`Based on:`}),(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col`,children:[...new Set(s)].map(e=>(0,J.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[p!==null&&(0,J.jsxs)(`span`,{role:`alert`,className:`min-w-0 flex-1 text-caption text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),p]}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,"aria-label":`Reject: ${a}`,"aria-busy":d===`reject`,onClick:()=>void _(`reject`),children:d===`reject`?`Rejecting…`:`Reject`}),(0,J.jsx)($,{ref:h,variant:`outline`,size:`sm`,"aria-label":`Edit: ${a}`,onClick:()=>u({note:null}),children:`Edit`}),(0,J.jsx)($,{size:`sm`,"aria-label":`Accept: ${a}`,"aria-busy":d===`accept`,onClick:()=>void _(`accept`),children:d===`accept`?`Accepting…`:`Accept`})]})]}):(0,J.jsx)(`li`,{className:`bg-surface-subtle px-4 py-3`,children:(0,J.jsx)(YR,{legend:`Edit the suggestion: ${a}`,initial:e,scopes:t,submit:`Accept`,submitting:`Accepting…`,note:l.note,onCancel:()=>u(null),onSubmit:e=>n.onAccept(r,e)})})},kB=({proposals:e,scopes:t,actions:n,fallbackFocus:r})=>{let i=(0,q.useId)(),a=(0,q.useRef)(null),o=()=>(e.length>1?a.current:r?.current)?.focus(),s=e=>e.then(e=>(e===null&&o(),e)),c={onAccept:(e,t)=>s(n.onAccept(e,t)),onReject:e=>s(n.onReject(e))};return e.length===0?null:(0,J.jsxs)(`section`,{ref:a,tabIndex:-1,"aria-labelledby":i,"data-slot":`suggested`,className:`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2`,children:[(0,J.jsx)(`h2`,{id:i,className:`text-heading font-semibold`,children:`Suggested`}),(0,J.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:e.length}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[e.length,` `,e.length===1?`suggestion`:`suggestions`]})]}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`None is used until you accept it. A rejected one isn't suggested again.`})]}),(0,J.jsx)(`ul`,{className:`divide-y`,children:e.map(e=>(0,J.jsx)(OB,{proposal:e,scopes:t,actions:c},e.id))})]})},AB=`Nothing new to suggest from: megareviewer records the points you dismiss and raise and the comments you post.`,jB=()=>(0,J.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading your preferences`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(zN,{className:`h-7 w-56 motion-reduce:animate-none`}),[3,2].map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsx)(`div`,{className:`flex h-11 items-center border-b px-4`,children:(0,J.jsx)(zN,{className:`h-4 w-32 motion-reduce:animate-none`})}),(0,J.jsx)(`ul`,{"aria-hidden":`true`,className:`flex flex-col gap-3 px-4 py-3`,children:Array.from({length:e},(e,t)=>(0,J.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(zN,{className:`h-5 w-20 rounded-full motion-reduce:animate-none`}),(0,J.jsx)(zN,{className:`h-4 flex-1 motion-reduce:animate-none`}),(0,J.jsx)(zN,{className:`h-4 w-12 motion-reduce:animate-none`})]},t))})]},e))]}),MB=()=>(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`A preference is one rule for AI reviews: something to look for, or something not to flag. For example `,(0,J.jsx)(LR,{kind:`look-for`,className:`align-middle`}),` “Tenant isolation: every query filters by tenant ID”, or `,(0,J.jsx)(LR,{kind:`dont-flag`,className:`align-middle`}),` “Naming”.`]}),NB=({now:e=Date.now})=>{let{client:t}=yp(),n=tL(PF().status?.model??null),r=Tp(),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null);r.preferences!==i&&(a(r.preferences),s(r.preferences));let[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),f=(0,q.useRef)(null),p=e=>s(t=>t===null?t:e(t)),m=(e,t,n)=>e.ok?(p(n=>t(n,e.value)),d(n),null):dL(e.error),h=async e=>m(await t.addPreference(e),nL,`Added: ${e.text}`),g={onSwitch:async(e,n)=>m(await t.updatePreference(e,{enabled:n}),nL,n?`Switched on`:`Switched off`),onEdit:async(e,n)=>m(await t.updatePreference(e,n),nL,`Saved: ${n.text}`),onDelete:async e=>m(await t.deletePreference(e),t=>rL(t,e),`Deleted`)},_={onAccept:async(e,n)=>m(await t.decideProposal(e,{decision:`accept`,...n}),(t,{preference:n})=>{let r=aL(t,e);return n===null?r:nL(r,n)},`Accepted`),onReject:async e=>m(await t.decideProposal(e,{decision:`reject`}),t=>aL(t,e),`Rejected`)},v=async e=>{let n=await t.suggestPreferences(e===void 0?{}:{optionId:e});if(!n.ok)return{ok:!1,message:dL(n.error)};let{proposals:r,signals:i}=n.value;return p(e=>({...iL(e,r),signalsSinceSuggestion:0})),{ok:!0,said:r.length===0?`Nothing new to suggest from ${fL(i,`action`)}.`:`${fL(r.length,`suggestion`)} from ${fL(i,`action`)}, above.`}},y=async(e,n)=>{let r=await t.importPreferences({repo:e,...n===void 0?{}:{optionId:n}});if(!r.ok)return{ok:!1,message:dL(r.error)};let{proposals:i,comments:a,pullRequests:o}=r.value;if(p(e=>iL(e,i)),a===0)return{ok:!0,said:o===0?`Found no pull request of this repository that you reviewed.`:`Found no comment of yours on its last ${fL(o,`pull request`)}.`};let s=`Read ${fL(a,`comment`)} from ${fL(o,`pull request`)}`;return{ok:!0,said:i.length===0?`${s}: nothing new to suggest.`:`${s}: ${fL(i.length,`suggestion`)}, above.`}},b=async(e,n,r)=>m(await t.setGuidelineSwitch({repo:e,path:n,enabled:r}),t=>oL(t,e,n,r),r?`${n} switched on`:`${n} switched off`);return(0,J.jsxs)(`div`,{"data-slot":`preferences-page`,className:`mx-auto flex max-w-[960px] flex-col gap-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h1`,{ref:f,tabIndex:-1,className:`text-title font-semibold tracking-[-0.01em]`,children:`Preferences`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`What you want an AI review to look for and to leave out. Used by Request AI review.`})]}),(()=>{if(o===null)return r.loading||r.error===null?(0,J.jsx)(jB,{}):(0,J.jsxs)(`div`,{className:X(LN,`flex flex-wrap items-center justify-between gap-2`),role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`Couldn't read your preferences. `,Ap(r.error)]}),(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:r.refresh,children:`Try again`})]});let t=cL(o),i=UR(t.map(e=>e.repo)),[a]=i;if(a===void 0)return null;let s=o.preferences.length===0,u=o.signalsSinceSuggestion;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kB,{proposals:o.proposals,scopes:i,actions:_,fallbackFocus:f}),(0,J.jsx)(vL,{label:`Suggest from my reviews`,running:`Reading what you did in reviews…`,icon:(0,J.jsx)(f_,{"aria-hidden":`true`}),choice:n,blocked:u===0?AB:null,idle:u===0?AB:`${fL(u,`action`)} recorded since the last suggestions`,run:v,now:e}),(0,J.jsx)(EB,{option:a,title:`Everywhere`,word:`Used on every pull request`,preferences:sL(o,zR),scopes:i,actions:g,addable:!s,adding:!s&&c===a.key,onAdding:e=>l(e?a.key:null),onAdd:h,empty:s?(0,J.jsxs)(`div`,{"data-slot":`no-preferences`,className:`flex flex-col gap-3 px-4 py-4`,children:[(0,J.jsx)(MB,{}),(0,J.jsx)(YR,{legend:`Add a preference`,initial:{kind:`look-for`,text:``,scope:zR},scopes:i,submit:`Add preference`,submitting:`Adding…`,onSubmit:h})]}):(0,J.jsx)(`p`,{className:`px-4 py-3 text-caption text-muted-foreground`,children:`No preference for every repository yet.`})}),t.map(({repo:t,guidelineFiles:r,guidelineNote:s})=>{let u=i.find(e=>e.key===VR(t))??a;return(0,J.jsxs)(EB,{option:u,title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:BR(t)}),(0,J.jsx)(eO,{variant:`outline`,className:`font-normal text-muted-foreground`,children:_F[t.host]})]}),word:`Used on its pull requests, after the ones for everywhere`,preferences:sL(o,u.scope),scopes:i,actions:g,adding:c===u.key,onAdding:e=>l(e?u.key:null),onAdd:h,empty:(0,J.jsx)(`p`,{className:`px-4 py-3 text-caption text-muted-foreground`,children:`No preference for this repository yet.`}),children:[(0,J.jsx)(hL,{files:r,note:s,repository:BR(t),onSwitch:(e,n)=>b(t,e,n)}),(0,J.jsx)(`div`,{className:`border-t px-4 py-3`,children:(0,J.jsx)(vL,{label:`Import from my past reviews`,running:`Reading your comments on ${BR(t)}…`,icon:(0,J.jsx)(n_,{"aria-hidden":`true`}),choice:n,what:`Reads your own comments on its recent pull requests on ${_F[t.host]}, then runs`,run:e=>y(t,e),now:e})})]},u.key)})]})})(),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})},PB=[`import`,`call`,`type`,`request`],FB=e=>e.slice(e.lastIndexOf(`/`)+1),IB=(e,t)=>e<t?-1:+(e>t),LB=e=>/\.(md|mdx|rst|adoc)$/i.test(e),RB=/(^|[/_.-])(fakes?|mocks?|stubs?|fixtures?|testing|test[_-]?(utils?|helpers?|support))([/_.-]|$)/i,zB=e=>XP(e).split(`/`).slice(0,3).join(`/`),BB=e=>`group:${e}`,VB=e=>{let t=new Map(e.map(e=>[e,e.split(`/`)])),n=(e,n)=>(t.get(e)??[]).slice(-n).join(`/`),r=new Map;for(let i of e){let a=t.get(i)?.length??1,o=1;for(;o<a&&e.some(e=>e!==i&&n(e,o)===n(i,o));)o+=1;r.set(i,n(i,o))}return r},HB=`\0routes`,UB=e=>`${e.method} ${e.path}`,WB=e=>{let[t]=e;return e.length===1&&t!==void 0?`${t.method} ${t.path}`:`${e.length} routes`},GB=(e,t)=>{let n=al(e.parts),r=new Map(e.files.flatMap(e=>ol(e,n).map(({id:t,hunk:n})=>[t,{file:e,hunk:n}]))),i=new Map,a=(e,t)=>{let n=i.get(e)??[];n.includes(t)||i.set(e,[...n,t])},o=new Map;for(let e of t){let t=new Map;for(let n of e.entries){let e=r.get(n)?.file.path;e!==void 0&&t.set(e,[...t.get(e)??[],n])}for(let[n,i]of t){let t=i.flatMap(e=>{let t=r.get(e),n=t===void 0?null:Ku(t.file,t.hunk,[]);return n?.kind===`route`?n.routes:[]});if(t.length>0&&(a(n,HB),o.set(n,[...o.get(n)??[],...t])),!(new Set(t.map(UB)).size===i.length&&t.length>0))for(let t of(e.codeTitle??e.title).split(`; `)){t.startsWith(`Page: `)&&a(n,t);let e=/^Command: (\S+) in (.+)$/.exec(t);e!==null&&e[2]===FB(n)&&a(n,`Command: ${e[1]}`)}}}return new Map([...i].map(([e,t])=>{let n=[...new Map((o.get(e)??[]).map(e=>[UB(e),e])).values()];return[e,t.map(e=>e===HB?WB(n):e)]}))},KB=(e,t)=>{let n=new Map,r=new Map,i=[],a=new Set,o=[],s=0,c=e=>{n.set(e,s),r.set(e,s),s+=1,i.push(e),a.add(e);for(let i of t(e))n.has(i)?a.has(i)&&r.set(e,Math.min(r.get(e)??0,n.get(i)??0)):(c(i),r.set(e,Math.min(r.get(e)??0,r.get(i)??0)));if(r.get(e)!==n.get(e))return;let l=[];for(let t=i.pop();t!==void 0&&(a.delete(t),l.push(t),t!==e);t=i.pop());l.length>1&&o.push(l)};for(let t of e)n.has(t)||c(t);return o},qB=()=>({uses:new Set,symbols:new Set,pairs:0}),JB=e=>{let t=new Set(e.proofs.flatMap(e=>e.hunkId??[])),n=e.files.filter(e=>e.hunks.some(e=>!t.has(e.id))),r=new Map(n.flatMap(e=>e.hunks.map(t=>[t.id,e.path]))),i=new Set(n.map(e=>e.path)),a=new Map,o=(e,t,n,r)=>{if(e===t||!i.has(e)||!i.has(t))return;let o=a.get(e)??new Map,s=o.get(t)??{...qB(),pairs:1};s.uses.add(n),r!==void 0&&s.symbols.add(r),o.set(t,s),a.set(e,o)};for(let{from:t,to:n}of e.fileLinks)o(t,n,`import`);for(let t of e.callGraph){let e=r.get(rl(t.fromPartId)),n=r.get(rl(t.toPartId));e!==void 0&&n!==void 0&&o(e,n,t.use,t.symbol)}return{mechanical:t,files:n,pathOfHunk:r,links:a}},YB=(e,t,n=new Set)=>{let{mechanical:r,files:i,pathOfHunk:a,links:o}=JB(e),s=[...new Set(t.flatMap(e=>e.partIds))],c=new Map(s.map((e,t)=>[e,t])),l=e=>c.get(e)??s.length,u=new Set(e.generated),d=new Map(i.map(t=>{let n=t.hunks.flatMap(e=>e.lines),i=ol(t,al(e.parts)).map(e=>e.id).filter(e=>!r.has(rl(e))).sort((e,t)=>l(e)-l(t)),a=t.hunks.every(e=>r.has(e.id))?`mechanical`:`logic`;return[t.path,{added:n.filter(e=>e.kind===`add`).length,deleted:n.filter(e=>e.kind===`del`).length,partIds:i,risk:a,rank:i.reduce((e,t)=>Math.min(e,l(t)),1/0)}]})),f=e=>d.get(e)?.rank??1/0,p=(e,t)=>f(e)-f(t)||IB(e,t),m=i.map(e=>e.path).sort(p),h=e=>[...o.get(e)?.keys()??[]],g=e=>m.filter(t=>o.get(t)?.has(e)===!0),_=new Set(m.filter(ul));for(let e=!0;e;){e=!1;for(let t of m){let n=g(t);!_.has(t)&&RB.test(t)&&n.length>0&&n.every(e=>_.has(e))&&(_.add(t),e=!0)}}let v=m.filter(e=>!_.has(e)&&LB(e)),y=m.filter(e=>!_.has(e)&&!LB(e)),b=new Set(y),x=new Map;for(let e of[..._].sort(p)){let t=[],n=new Set([e]),r=e=>{for(let i of h(e))n.has(i)||(n.add(i),b.has(i)?t.push(i):r(i))};r(e),x.set(e,t)}let S=new Map;for(let[e,t]of x)for(let n of t)S.set(n,[...S.get(n)??[],e]);let C=[..._].filter(e=>(x.get(e)??[]).length===0),w=new Map;for(let e of[...y,...v,...C].sort(YP)){let t=BB(XP(e)),r=n.has(t)?e:t;w.set(r,[...w.get(r)??[],e])}let T=new Map;for(let[e,t]of w)for(let n of t)T.set(n,e);let E=e=>Math.min(...(w.get(e)??[e]).map(f)),D=(e,t)=>E(e)-E(t)||IB(e,t),O=[...w.keys()].sort(D),k=new Map;for(let[e,t]of o)for(let[n,r]of t){let t=T.get(e),i=T.get(n);if(t===void 0||i===void 0||t===i)continue;let a=k.get(t)??new Map,o=a.get(i)??qB();for(let e of r.uses)o.uses.add(e);for(let e of r.symbols)o.symbols.add(e);o.pairs+=r.pairs,a.set(i,o),k.set(t,a)}let A=new Map;for(let{partId:t,symbol:n,uses:r}of e.unchangedCallers??[]){let e=a.get(rl(t)),i=e===void 0?void 0:T.get(e);if(i!==void 0)for(let e of r){let r=A.get(e.path)??{targets:new Map,uses:0,partIds:new Set},a=r.targets.get(i)??qB();a.uses.add(e.use),a.symbols.add(n),r.targets.set(i,a),r.uses+=1,r.partIds.add(t),A.set(e.path,r)}}let j=[...A.keys()].sort((e,t)=>Number(ul(e))-Number(ul(t))||IB(e,t)),M=new Map;for(let e of j){let t=j.length>10?`outside:${zB(e)}/`:`outside:${e}`;M.set(t,[...M.get(t)??[],e])}for(let[e,t]of[...M]){let[n]=t;e.endsWith(`/`)&&t.length===1&&n!==void 0&&(M.delete(e),M.set(`outside:${n}`,[n]))}let N=new Map;for(let[e,t]of M){let n=new Map;for(let e of t)for(let[t,r]of A.get(e)?.targets??[]){let e=n.get(t)??qB();for(let t of r.uses)e.uses.add(t);for(let t of r.symbols)e.symbols.add(t);n.set(t,e)}N.set(e,n)}let P=new Set([...[...k].flatMap(([e,t])=>t.size>0?[e,...t.keys()]:[]),...[...N.values()].flatMap(e=>[...e.keys()])]),F=O.filter(e=>P.has(e)),I=new Set,L=(e,t)=>`${e}\u0000${t}`,R=e=>[...k.get(e)?.keys()??[]].filter(t=>!I.has(L(e,t))),ee=(e,t)=>k.get(e)?.get(t)?.pairs??0;for(let e=KB(F,R);e.length>0;e=KB(F,R))for(let t of e){let[e,n,r]=t;if(e!==void 0&&n!==void 0&&r===void 0&&ee(e,n)!==ee(n,e)){I.add(ee(e,n)<ee(n,e)?L(e,n):L(n,e));continue}let[i]=[...t].sort(D);for(let e of t)i!==void 0&&R(e).includes(i)&&I.add(L(e,i))}let z=new Map(F.map(e=>[e,[]]));for(let e of F)for(let t of R(e))z.get(t)?.push(e);let te=new Map,B=e=>{let t=te.get(e);if(t!==void 0)return t;let n=Math.max(-1,...(z.get(e)??[]).map(B))+1;return te.set(e,n),n},ne=[],V=(e,t)=>{for(;ne.length<=t;)ne.push([]);ne[t]?.push(e)};for(let e of F)V(e,B(e));for(let[e,t]of N){let n=[...t.keys()];z.set(e,n),te.set(e,Math.max(...n.map(B))+1),V(e,te.get(e)??0)}let H=()=>new Map(ne.flatMap(e=>e.map((t,n)=>[t,n-(e.length-1)/2]))),re=e=>R(e),ie=(e,t)=>{for(let n of e){let e=H(),r=n=>{let r=t(n).map(t=>e.get(t)??0);return r.length===0?e.get(n)??0:r.reduce((e,t)=>e+t,0)/r.length},i=new Map(n.map(e=>[e,r(e)]));n.sort((e,t)=>(i.get(e)??0)-(i.get(t)??0)||D(e,t))}},ae=e=>z.get(e)??[];ie(ne.slice(1),ae),ie(ne.slice(0,-1).reverse(),re),ie(ne.slice(1),ae);let oe=VB(m),se=GB(e,t),U=new Map;for(let e of t)if(e.kind===`flow`)for(let t of new Set(e.partIds.flatMap(e=>a.get(rl(e))??[])))U.set(t,[...U.get(t)??[],e.title]);let ce=e=>[...new Set(e)],le=VB(j),ue=(e,t)=>{let n=M.get(e)??[],[r]=n;return{key:e,kind:`outside`,paths:n,label:e.endsWith(`/`)||r===void 0?e.slice(8):le.get(r)??r,added:0,deleted:0,risk:`logic`,generated:!1,entries:[],flows:[],partIds:[...new Set(n.flatMap(e=>[...A.get(e)?.partIds??[]]))],uses:n.reduce((e,t)=>e+(A.get(t)?.uses??0),0),badges:[],row:t}},de=(e,t)=>{if(M.has(e))return ue(e,t);let n=w.get(e)??[e],r=n.flatMap(e=>d.get(e)??[]),i=e.startsWith(`group:`);return{key:e,kind:i?`group`:`file`,paths:n,label:i?`${e.slice(6)||`.`}/`:oe.get(e)??e,added:r.reduce((e,t)=>e+t.added,0),deleted:r.reduce((e,t)=>e+t.deleted,0),risk:r.every(e=>e.risk===`mechanical`)?`mechanical`:`logic`,generated:n.every(e=>u.has(e)),entries:ce(n.flatMap(e=>se.get(e)??[])),flows:ce(n.flatMap(e=>U.get(e)??[])),partIds:r.flatMap(e=>e.partIds).sort((e,t)=>l(e)-l(t)),badges:ce(n.flatMap(e=>S.get(e)??[])).sort(p),uses:0,row:t}},fe=ne.map((e,t)=>e.map(e=>de(e,t))),pe=O.filter(e=>!P.has(e)).map(e=>de(e,-1)),me=new Map;for(let e of[...fe.flat(),...pe])if(e.kind!==`outside`)for(let t of e.paths)me.set(t,e.key);for(let[e,t]of x){let[n]=t,r=n===void 0?void 0:T.get(n);r!==void 0&&me.set(e,r)}return{rows:fe,edges:[...[...k].map(e=>[e,!1]),...[...N].map(e=>[e,!0])].flatMap(([[e,t],n])=>[...t].map(([t,r])=>({from:e,to:t,uses:PB.filter(e=>r.uses.has(e)),symbols:[...r.symbols].sort(IB),back:I.has(L(e,t)),outside:n}))),strip:pe,placeOf:me}},XB=e=>e.kind!==`outside`&&!e.generated&&e.risk!==`mechanical`,ZB=e=>e.kind===`group`?e.key.slice(6)||`.`:e.key,QB=e=>{let t=e.rows.map(e=>e.filter(XB)).filter(e=>e.length>0),n=e.strip.filter(XB),r=t.length>0,i=r?t:[n],a=i.flat();if(a.length===0)return null;let o=VB(a.map(ZB)),s=8,c=i.map(e=>e.flatMap(e=>s===0?[]:(--s,[{label:o.get(ZB(e))??ZB(e),entries:e.entries}]))).filter(e=>e.length>0);return{rows:c,linked:r,more:a.length-c.flat().length+(r?n.length:0)}},$B=(e,t)=>{let n=e.flatMap(e=>{let n=t(e.partId);if(n===void 0||ul(n))return[];let r=e.uses.filter(e=>!ul(e.path)).length,i=e.uses.length>r?0:e.more;return r+i===0?[]:[{symbol:e.symbol,uses:r+i}]});return n.length===0?null:{symbols:[...new Set(n.map(e=>e.symbol))],uses:n.reduce((e,t)=>e+t.uses,0)}},eV=e=>e.split(/`([^`\n]+)`/).map((e,t)=>({text:e,code:t%2==1})).filter(e=>e.text!==``),tV=e=>{let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?0:Math.max(0,Math.round((t-e)/1e3))},nV=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`,rV={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},iV=({kind:e,count:t,words:n,at:r,pressed:i,onPressed:a,label:o})=>{let[s,c]=n,l=e===`thread`?Kg:sD[e];return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`point-chip`,"data-kind":e,"data-land":`rise`,"aria-pressed":i,"aria-label":o,style:vh({"--landing-i":r}),onClick:()=>a(!i),className:X(`flex min-h-6 shrink-0 items-center gap-1.5 rounded-full border px-2 text-caption font-medium aria-pressed:border-current aria-pressed:ring-1 aria-pressed:ring-current`,e===`thread`?`border-border bg-background text-foreground`:oD[e].className),children:[(0,J.jsx)(l,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{"data-slot":`count-up`,"aria-hidden":`true`,className:`tabular`,style:vh({"--count":t})}),(0,J.jsx)(`span`,{className:`sr-only`,children:t}),` `,(0,J.jsx)(`span`,{className:`max-xl:sr-only`,children:t===1?s:c})]})]})},aV=({option:e,noteId:t})=>(0,J.jsxs)(bB,{value:e.id,disabled:!e.available,"aria-describedby":e.available?void 0:t,children:[e.modelName,!e.measured&&(0,J.jsx)(`span`,{className:`rounded-full border px-1.5 text-caption text-muted-foreground`,children:`unmeasured`})]}),oV=e=>{if(e.key===`Escape`||e.key===`Tab`||(e.stopPropagation(),e.key!==`ArrowDown`&&e.key!==`ArrowUp`))return;let t=[...e.currentTarget.closest(`[role="menu"]`)?.querySelectorAll(`[role="menuitemradio"]`)??[]],n=t.findIndex(t=>e.currentTarget.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING),r=e.key===`ArrowDown`?t[n]:t[(n===-1?t.length:n)-1];r!==void 0&&(e.preventDefault(),r.focus())},sV=({first:e,options:t,separated:n,noteId:r,choice:i})=>{let[a,o]=(0,q.useState)(``),s=QI(t,i.chosen,i.defaultId),c=t.length-s.length,l=$I(t,s,a);return(0,J.jsxs)(hB,{children:[n&&(0,J.jsx)(xB,{}),(0,J.jsxs)(gB,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-foreground`,children:e.available?e.via:e.providerName}),!e.available&&(0,J.jsx)(`span`,{id:r,className:`font-normal`,children:e.reason})]}),s.map(e=>(0,J.jsx)(aV,{option:e,noteId:r},e.id)),c>0&&(0,J.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,J.jsx)(nP,{value:a,onChange:e=>o(e.target.value),onKeyDown:oV,placeholder:`Filter ${c} more models`,"aria-label":`Filter ${c} more models through ${e.via}`,className:`h-7`})}),l.map(e=>(0,J.jsx)(aV,{option:e,noteId:r},e.id)),c>0&&a.trim()!==``&&l.length===0&&(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,children:`No model matches`})]})},cV=({choice:e,disabled:t,filled:n})=>{let r=(0,q.useId)();return(0,J.jsxs)(fB,{children:[(0,J.jsx)(pB,{render:(0,J.jsx)($,{variant:n?`default`:`outline`,size:`sm`,"data-slot":`model-menu`,disabled:t,"aria-label":e.chosen===null?`Choose a model`:`Model: ${e.chosen.modelName}`,className:X(`w-6 rounded-l-none px-0`,n?`border-l-primary-foreground/30`:`border-l-0`)}),children:(0,J.jsx)(Bh,{"aria-hidden":`true`})}),(0,J.jsx)(mB,{align:`end`,className:`w-80`,children:(0,J.jsx)(yB,{value:e.chosen?.id??null,onValueChange:t=>e.choose(t),children:ZI(e.options).map(([t,n],i)=>(0,J.jsx)(sV,{first:t,options:n,separated:i>0,noteId:`${r}-${i}`,choice:e},t.id))})})]})},lV=({choice:e,starting:t,failed:n,onRun:r})=>{let i=(0,q.useId)(),{chosen:a,locked:o}=e,s=o??(a===null?null:`Runs ${a.modelName} through ${a.via}`),c=(0,J.jsx)($,{variant:n?`outline`:`default`,size:`sm`,"data-slot":`request-review`,disabled:t||o!==null||a===null,focusableWhenDisabled:!0,"aria-describedby":s===null?void 0:i,onClick:r,className:`rounded-r-none`}),l=(0,J.jsxs)(J.Fragment,{children:[o===null?(0,J.jsx)(f_,{"aria-hidden":`true`,className:X(n&&`text-primary`)}):(0,J.jsx)(Wg,{"aria-hidden":`true`}),t?`Starting…`:n?`Try again`:`Request AI review`]});return(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center`,children:[(0,J.jsxs)(uI,{disabled:s===null,children:[(0,J.jsx)(dI,{render:c,children:l}),(0,J.jsxs)(fI,{side:`bottom`,align:`start`,children:[o!==null&&(0,J.jsx)(Pg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),s]})]}),s!==null&&(0,J.jsx)(`span`,{id:i,hidden:!0,children:s}),(0,J.jsx)(cV,{choice:e,disabled:t||e.options.length===0,filled:!n&&o===null})]})},uV=e=>{let t=[`intent`,`findings`,`risk`,`decisions`].filter(t=>e.stages[t]!==`done`);return t.length===0||e.modelError===null?null:`${t.join(`, `)} missing: ${e.modelError.message}`},dV=({analysis:e,choice:t,running:n,startedAt:r,starting:i,error:a,points:o,leftOut:s=0,threads:c=null,narrowed:l,onNarrow:u,onRun:d,children:f})=>{let p=tV(n?r:null),m=Rl(e.modelOption??t.chosen),h=f!=null&&f!==!1,g=e=>(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e,h&&(0,J.jsx)(`span`,{className:X(`flex min-w-0 items-center`,e!==null&&`border-l pl-1.5`),children:f})]});if(n)return g((0,J.jsxs)(`span`,{"data-slot":`claude-running`,role:`status`,className:`flex shrink-0 items-center gap-2 whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(f_,{"aria-hidden":`true`,className:`size-3.5`}),m,` is reading this PR`,(0,J.jsx)(`span`,{className:`tabular text-caption`,children:nV(p)})]}));let _=[`finding`,`risk`,`decision`].map(e=>[e,o.filter(t=>t.kind===e).length]).filter(([,e])=>e>0),v=uV(e),y=_.length+(c===null?0:1),b=e=>({"data-land":`rise`,style:vh({"--landing-i":y+e})});if(o.length>0)return(0,J.jsxs)(`span`,{"data-slot":`claude-receipt`,className:`flex min-w-0 items-center gap-1.5`,children:[_.map(([e,t],n)=>(0,J.jsx)(iV,{kind:e,count:t,words:rV[e],at:n,pressed:l===e,onPressed:t=>u(t?e:null)},e)),c!==null&&(0,J.jsx)(iV,{kind:`thread`,count:c.count,words:c.words,label:c.label,at:_.length,pressed:l===`thread`,onPressed:e=>u(e?`thread`:null)}),(0,J.jsx)(`span`,{...b(0),className:`ml-1 flex min-w-0 items-center border-l pl-1.5`,children:f}),(a??v)!==null&&(0,J.jsx)(`span`,{...b(1),role:`alert`,title:a??v??void 0,className:`min-w-0 truncate text-caption text-destructive`,children:a??v}),Vu(e)&&(0,J.jsx)(`span`,{...b(1),children:(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:i,onClick:d,children:i?`Starting…`:`Try again`})})]});if(!Vu(e))return g(e.stages.findings===`done`?(0,J.jsxs)(`span`,{"data-slot":`claude-receipt`,"data-land":`fade`,className:`shrink-0 whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),m,` found nothing to raise`,s>0&&`, and left out ${s} by your preferences`]}):null);let x=e.modelError;return g((0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(lV,{choice:t,starting:i,failed:x!==null,onRun:d}),(a??x)!==null&&(0,J.jsx)(`span`,{role:`alert`,title:a??`${m} couldn't finish: ${x?.message}`,className:`min-w-0 truncate text-caption text-destructive`,children:a??`${m} couldn't finish: ${x?.message}`})]}))},fV=e=>`call-${e.partId}-${e.line}-${e.column}`,pV=(e,t,n)=>{let r=new Map;for(let i of e){let e=t.items(i.toPartIds).map(({id:e,hunk:t,file:n})=>({id:e,hunk:t,file:n}));if(e.length===0||!t.parts.has(i.partId))continue;let a={symbol:i.symbol,targets:e},o=fV(i),s=r.get(i.partId)??new Map,c=s.get(i.line)??[];c.some(e=>e.start===i.column)||(c.push({start:i.column,end:i.column+i.length,render:e=>(0,J.jsx)(Oj,{handle:n,payload:a,id:o,children:e})}),s.set(i.line,c),r.set(i.partId,s))}return r},mV=(e,t)=>{let n=e.checkedBy;if(n===void 0)return null;let{hunkId:r,startLine:i}=n.lines,a=t.items(t.partsOf(r)),o=a.filter(({hunk:e})=>e.lines.some(e=>e.kind!==`del`&&e.newLine===i)),s=(o.length>0?o:a).map(({id:e,hunk:t,file:n})=>({id:e,hunk:t,file:n}));return s.length===0?null:{symbol:n.test,targets:s,label:`Test ${n.test}`}},hV=e=>`hunk-${e}`,gV=e=>e===void 0?{}:{marks:e},_V=({id:e,deps:t})=>{let[n]=t.index.items([e]);if(n===void 0)return null;let{hunk:r,file:i,risk:a,proofs:o=[]}=n;return o.length>0?(0,J.jsx)(`div`,{className:vj,children:(0,J.jsx)(Gj,{hunk:r,file:i,risk:a,proofs:o,onFocus:t.onFocusHunk})}):(0,J.jsx)(Tj,{id:e,hunk:r,file:i,risk:a,highlighted:t.highlighted.has(e),onFocus:t.onFocusHunk,unchanged:t.unchangedOf(e),inFile:!0,comments:t.commentsOf(e),openComment:t.openComment?.partId===e?t.openComment.place:null,onOpenComment:t.onOpenComment,...t.onCancelComment===void 0?{}:{onCancelComment:t.onCancelComment},onComment:t.onComment,...t.onCommentNow===void 0?{}:{onCommentNow:t.onCommentNow},afterHeader:t.pointsOn(e),...t.pointLinesOf(e)===void 0?{}:{pointLines:t.pointLinesOf(e)},threadsAt:n=>t.threadsAt(e,n),pointsAt:n=>t.pointsAt(e,n),pointsAtEnd:n=>t.pointsAtEnd(e,n),...t.flaggedOf(e)===void 0?{}:{flagged:t.flaggedOf(e)},...t.rangeNote===void 0?{}:{rangeNote:t.rangeNote},...gV(t.marksOf(e))})},vV=/^#{1,6}\s+/,yV=e=>e.replace(/!?(\[([^\]]+)\])\([^)]*\)/g,`$2`).replace(/(`+)(.*?)\1/g,`$2`).replace(/(\*\*|__|~~)(.*?)\1/g,`$2`).replace(/(^|\s)[*_]([^*_]+)[*_](?=\s|[.,!?]|$)/g,`$1$2`).replace(/^\s*(?:>\s*|[-*+]\s+|\d+[.)]\s+)/,``).replace(/\\([\\`*_{}[\]()#+.!>-])/g,`$1`),bV=e=>{let t=e.split(`
84
- `).map(e=>e.trim()).filter(e=>e!==``);return yV(t.find(e=>!vV.test(e))??t[0]?.replace(vV,``)??``)},xV=/^(.+?[.!?])\s+(?=[A-Z0-9"'(`[])/,SV=e=>{let t=bV(e);return xV.exec(t)?.[1]??t},CV=`font-medium text-muted-foreground`,wV=({text:e})=>(0,J.jsx)(`span`,{"data-slot":`model-text`,className:`whitespace-pre-line`,children:eV(e).map((e,t)=>e.code?(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.text},t):(0,J.jsx)(`span`,{children:yV(e.text)},t))}),TV=({through:e})=>(0,J.jsxs)(`span`,{"data-slot":`through`,children:[e.rows.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&` → `,e.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&`, `,(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.label}),e.entries.length>0&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.entries.join(`, `),`)`]})]},e.label))]},t)),e.more>0&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,e.more,` more `,e.more===1?`directory`:`directories`]})]}),EV=({reach:e})=>{let t=e.symbols.slice(0,3),n=e.symbols.length-t.length,r=t.map((e,r)=>(0,J.jsxs)(`span`,{children:[r>0&&(r===t.length-1&&n===0?` and `:`, `),(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e})]},e));return(0,J.jsxs)(`span`,{"data-slot":`reach`,children:[`Changes `,r,n>0&&` and ${n} more`,`, used in `,e.uses,` `,e.uses===1?`place`:`places`,` the PR doesn't change.`]})},DV=({lead:e,children:t})=>(0,J.jsxs)(`p`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:CV,children:e}),` `,t]}),OV=({analysis:e,through:t,running:n,onDetails:r})=>{let{intent:i,pullRequest:a}=e,o=i?.mismatches??[],s=a===null?``:SV(a.description),[c,l]=(0,q.useState)(i!==null),[u,d]=(0,q.useState)(!1);i!==null!==c&&(l(i!==null),d(i!==null&&n)),u&&!n&&d(!1);let f=(i!==null||a!==null)&&(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Details`,title:`Details`,onClick:r,className:`ml-1 rounded-full align-middle text-muted-foreground`,children:(0,J.jsx)(Pg,{"aria-hidden":`true`})}),p=new Map(e.files.flatMap(e=>e.hunks.map(t=>[t.id,e.path]))),m=$B(e.unchangedCallers,e=>p.get(rl(e))),h=t!==null&&(0,J.jsx)(DV,{lead:t.linked?`Through:`:`In:`,children:(0,J.jsx)(TV,{through:t})}),g=m!==null&&(0,J.jsx)(DV,{lead:`Watch:`,children:(0,J.jsx)(EV,{reach:m})}),_=a!==null&&(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`p`,{className:`min-w-0`,children:[s===``?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,J.jsx)(`span`,{children:s}),!u&&f]}),h,g]}),v=i!==null&&(0,J.jsxs)(`div`,{"data-arriving":u||void 0,className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`p`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:o.length===0?`font-medium text-review-approved`:`font-medium`,children:o.length>0||i.stated===null?`From the code:`:`✓ Does what was asked:`}),` `,(0,J.jsx)(wV,{text:i.inferred.summary}),f]}),i.inferred.shape===``?h:(0,J.jsx)(DV,{lead:`Through:`,children:(0,J.jsx)(wV,{text:i.inferred.shape})}),i.inferred.watch.length===0?g:(0,J.jsx)(DV,{lead:`Watch:`,children:i.inferred.watch.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&` · `,(0,J.jsx)(wV,{text:e})]},t))})]});return(0,J.jsx)(`div`,{"data-slot":`intent-brief`,className:`flex min-w-0 flex-col gap-1 text-body`,children:v===!1?_:u?(0,J.jsxs)(`div`,{"data-slot":`intent-swap`,className:`min-w-0`,children:[(0,J.jsx)(`div`,{"data-leaving":!0,"aria-hidden":`true`,children:_}),v]}):v})},kV=`rounded-full border bg-muted px-2 py-0.5 text-caption`,AV=({pullRequest:e,tickets:t,missingTicketKeys:n})=>{let r=e.description.trim();return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r===``?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,J.jsx)(`p`,{className:`text-body whitespace-pre-line`,children:r}),(t.length>0||n.length>0)&&(0,J.jsxs)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets`,children:[t.map(e=>(0,J.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:(0,J.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.key,` · `,e.summary]})},e.key)),n.map(e=>(0,J.jsxs)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,title:`Jira didn't return this ticket, or Jira isn't configured`,children:[e,` · not fetched`]},e))]}),e.commits.length>0&&(0,J.jsxs)(`details`,{className:`group`,children:[(0,J.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Commits (`,e.commits.length,`)`]}),(0,J.jsx)(`ol`,{className:`mt-1 flex flex-col gap-1`,children:e.commits.map(e=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`code`,{className:`font-mono text-code-compact text-muted-foreground`,children:e.sha.slice(0,7)}),` `,e.message.split(`
83
+ `);return(0,J.jsx)(`pre`,{"data-slot":`thread-code`,className:`overflow-x-auto rounded-md border bg-surface-subtle px-2.5 py-1.5 font-mono text-code-compact`,children:(0,J.jsx)(`code`,{children:r.map((e,t)=>(0,J.jsx)(`span`,{className:`block min-h-[1lh] whitespace-pre`,children:(0,J.jsx)(tA,{text:e,tokens:n?.[t]})},t))})})},XA=({kind:e,alt:t,src:n,size:r})=>{let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);if(i)return(0,J.jsxs)(`span`,{"data-slot":`thread-image`,className:`inline-flex items-center gap-1 rounded-sm border bg-muted px-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(Ag,{"aria-hidden":`true`,className:`size-3`}),e===`image`?`Image`:`Video`,t===``?``:`: ${t}`,` couldn't be loaded`]});let c=`block max-h-[28rem] max-w-full rounded-md border bg-muted`,l=t===``?`Image from the comment`:t;return e===`image`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":`Open ${l} full screen`,onClick:()=>s(!0),className:`block max-w-full cursor-zoom-in rounded-md`,children:(0,J.jsx)(`img`,{"data-slot":`thread-media`,src:n,alt:l,...r===void 0?{}:{width:r.width,height:r.height},loading:`lazy`,onError:()=>a(!0),className:X(c,`h-auto w-auto`)})}),o&&(0,J.jsx)(qA,{src:n,alt:l,onClose:()=>s(!1)})]}):(0,J.jsx)(`video`,{"data-slot":`thread-media`,src:n,controls:!0,preload:`metadata`,onError:()=>a(!0),className:c})},ZA=({span:e,mediaUrl:t})=>{switch(e.kind){case`text`:return(0,J.jsx)(J.Fragment,{children:e.text});case`code`:return(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:e.text});case`strong`:return(0,J.jsx)(`strong`,{className:`font-semibold`,children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`emphasis`:return(0,J.jsx)(`em`,{children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`strike`:return(0,J.jsx)(`del`,{children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`link`:return e.url===null?(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t}):(0,J.jsx)(`a`,{href:e.url,title:e.url,target:`_blank`,rel:`noreferrer noopener nofollow`,className:`underline`,children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:t})});case`image`:case`video`:{if(e.url!==null&&t)return(0,J.jsx)(XA,{kind:e.kind,alt:e.text,src:t(e.url),size:e.size});let n=e.kind===`image`?`Image`:`Video`;return(0,J.jsxs)(`span`,{"data-slot":`thread-image`,className:`inline-flex items-center gap-1 rounded-sm border bg-muted px-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(Ag,{"aria-hidden":`true`,className:`size-3`}),e.text===``?n:`${n}: ${e.text}`,(0,J.jsx)(`span`,{className:`sr-only`,children:`, not loaded: it isn't in the host's own attachments`})]})}}},QA=({spans:e,mediaUrl:t})=>e.map((e,n)=>(0,J.jsx)(ZA,{span:e,mediaUrl:t},`${e.kind}:${n}`)),$A={1:`text-heading font-semibold`,2:`text-heading font-semibold`,3:`text-body font-semibold`},ej={left:`text-left`,center:`text-center`,right:`text-right`},tj=({blocks:e,...t})=>e.map((e,n)=>(0,J.jsx)(nj,{block:e,...t},`${e.kind}:${n}`)),nj=({block:e,suggestion:t,mediaUrl:n})=>{switch(e.kind){case`suggestion`:return(0,J.jsx)(`div`,{children:t(e.lines)});case`code`:return(0,J.jsx)(YA,{text:e.text,language:e.language});case`paragraph`:return(0,J.jsx)(`p`,{className:`whitespace-pre-wrap`,children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:n})});case`heading`:return(0,J.jsx)(`p`,{"data-slot":`thread-heading`,className:X(`whitespace-pre-wrap`,$A[e.level]??`font-semibold`),children:(0,J.jsx)(QA,{spans:e.spans,mediaUrl:n})});case`quote`:return(0,J.jsx)(`blockquote`,{className:`flex flex-col gap-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,J.jsx)(tj,{blocks:e.blocks,suggestion:t,mediaUrl:n})});case`list`:{let r=e.items.map((e,r)=>(0,J.jsx)(`li`,{className:X(`pl-1`,e.checked!==null&&`list-none -ml-5 pl-0`),children:(0,J.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[e.checked!==null&&(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center`,children:e.checked?`☑`:`☐`}),e.checked!==null&&(0,J.jsx)(`span`,{className:`sr-only`,children:e.checked?`Done: `:`Not done: `}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:(0,J.jsx)(tj,{blocks:e.blocks,suggestion:t,mediaUrl:n})})]})},r));return e.ordered?(0,J.jsx)(`ol`,{start:e.start,className:`flex list-decimal flex-col gap-1 pl-5`,children:r}):(0,J.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5`,children:r})}case`table`:return(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`border-collapse text-ui`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsx)(`tr`,{children:e.head.map((t,r)=>(0,J.jsx)(`th`,{className:X(`border bg-muted px-2 py-1 font-semibold`,ej[e.align[r]??`left`]),children:(0,J.jsx)(QA,{spans:t,mediaUrl:n})},r))})}),(0,J.jsx)(`tbody`,{children:e.rows.map((t,r)=>(0,J.jsx)(`tr`,{children:t.map((t,r)=>(0,J.jsx)(`td`,{className:X(`border px-2 py-1`,ej[e.align[r]??`left`]),children:(0,J.jsx)(QA,{spans:t,mediaUrl:n})},r))},r))})]})});case`rule`:return(0,J.jsx)(`hr`,{className:`border-border`})}},rj=({blocks:e,suggestion:t,mediaUrl:n})=>(0,J.jsx)(`div`,{"data-slot":`thread-body`,className:`flex flex-col gap-2 text-body break-words`,children:(0,J.jsx)(tj,{blocks:e,suggestion:t,mediaUrl:n})}),ij=`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,aj=`shadow-[inset_0_0_0_2px_var(--ring)]`,oj=({name:e})=>(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-caption font-medium text-muted-foreground`,children:wk(e)}),sj=e=>{let t=e.line??e.originalLine;if(t===null)return e.path;let n=e.side===`old`?`old `:``;return e.startLine!==null&&e.line!==null?`${n}lines ${e.startLine}–${t}`:`${n}line ${t}`},cj=e=>{let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&e[0]?.author.id===n.author.id?e.push(n):t.push([n])}return t},lj=({thread:e,authorId:t,now:n,language:r,covered:i,onReply:a,onResolve:o,replying:s=!1,mediaUrl:c,initialReply:l,current:u=!1,anchorId:d,linesAbove:f=0,className:p})=>{let[m,h]=(0,q.useState)(!e.resolved||u),[g,_]=(0,q.useState)(u);u!==g&&(_(u),u&&h(!0));let[v,y]=(0,q.useState)(l!==void 0),[b,x]=(0,q.useState)(0),[S,C]=(0,q.useState)(l?.text??``),[w,T]=(0,q.useState)(l?.status===`posting`),[E,D]=(0,q.useState)(l?.status===`failed`?l.error??``:null),[O,k]=(0,q.useState)(!1),[A,j]=(0,q.useState)(null),M=(0,q.useRef)(null),N=(0,q.useId)(),P=e.resolved?`resolved`:e.outdated?`outdated`:`open`,F=!e.outdated&&e.line!==null&&e.side===`new`,I=a!==void 0&&e.can.reply,L=o!==void 0&&e.can.resolve,R=I&&(v||S!==``||w||E!==null),ee=()=>{h(!0),y(!0),x(e=>e+1)};(0,q.useEffect)(()=>{b>0&&M.current?.focus()},[b]),(0,q.useEffect)(()=>{s&&ee()},[s]);let z=()=>M.current?.closest(`[data-slot=review-thread]`)?.focus(),te=()=>{w||(z(),C(``),D(null),y(!1))},B=async()=>{let e=S.trim();if(e===``||w||a===void 0)return;let t=M.current?.closest(`[data-slot=review-thread]`);T(!0),D(null);let n=await a(e);T(!1),n===null?(C(``),y(!1),t?.focus()):D(n)},ne=async()=>{if(o===void 0||O)return;k(!0),j(null);let t=await o(!e.resolved);k(!1),t===null?h(e.resolved):j(t)},V=e=>(0,J.jsx)(rA,{title:`Suggested change`,removed:F?i:null,added:e,language:r}),H=e=>(0,J.jsx)(`time`,{dateTime:e.createdAt,title:kk(e.createdAt),className:`ml-auto shrink-0 pl-3 text-caption text-muted-foreground`,children:Ok(e.createdAt,n)}),re=e=>{let[n]=e;return n===void 0?null:(0,J.jsxs)(`section`,{"data-slot":`thread-group`,className:`grid grid-cols-[1.5rem_minmax(0,1fr)] gap-x-2.5 gap-y-0.5`,children:[(0,J.jsx)(oj,{name:n.author.name}),(0,J.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:n.author.name}),t!==null&&n.author.id===t&&(0,J.jsx)(`span`,{className:X(`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,`border-border bg-muted text-muted-foreground`),children:`Author`}),H(n)]}),e.length>1?(0,J.jsx)(`span`,{"data-slot":`thread-run`,"aria-hidden":`true`,className:`flex justify-center pt-1.5 pb-1`,children:(0,J.jsx)(`span`,{className:`w-px bg-thread-run`})}):(0,J.jsx)(`span`,{"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:e.map((e,t)=>{let{blocks:n}=Vd(e.body);return(0,J.jsxs)(`div`,{"data-slot":`thread-comment`,className:`flex items-baseline`,children:[(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:(0,J.jsx)(`div`,{className:`w-full`,children:(0,J.jsx)(rj,{blocks:n,suggestion:V,...c===void 0?{}:{mediaUrl:c}})})}),t>0&&H(e)]},e.id)})})]})},[ie]=e.comments,ae=e.line??e.originalLine,oe=e.resolvedBy?.name,se=I||L;return(0,J.jsx)(Ck,{as:`article`,state:P,"data-slot":`review-thread`,id:d,"data-current":u||void 0,"aria-label":`Thread on ${sj(e)}${e.resolved?`, resolved`:``}`,tabIndex:-1,style:vh({"--lines-above":Math.min(f,5)}),className:X(`flex scroll-mt-[calc(6rem+var(--lines-above)*var(--text-code--line-height))] flex-col gap-3 -outline-offset-2`,!m&&`py-1.5`,u&&aj,p),children:m?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`thread-header`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,children:[ae!==null&&(0,J.jsxs)(J.Fragment,{children:[e.startLine!==null&&e.line!==null?`Lines`:`Line`,` `,(0,J.jsx)(jk,{children:Ak(e.side,e.line===null?null:e.startLine,ae)}),(0,J.jsx)(`span`,{children:`·`})]}),(0,J.jsxs)(`span`,{children:[e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.outdated&&(0,J.jsx)(`span`,{className:X(`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,`border-border bg-muted text-muted-foreground`),children:`Outdated`}),e.resolved&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,oe===void 0?``:` by ${oe}`]}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),"aria-expanded":!0,children:`Hide`})]})]}),cj(e.comments).map((e,t)=>(0,J.jsxs)(q.Fragment,{children:[t>0&&(0,J.jsx)(`hr`,{"data-slot":`thread-divider`}),re(e)]},e[0]?.id??t)),A!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ `,e.resolved?`Not reopened`:`Not resolved`,`: `,A]}),R?(0,J.jsxs)(`div`,{"data-slot":`thread-reply`,className:`flex flex-col gap-1.5 border-t pt-3 pl-8.5`,children:[(0,J.jsxs)(`label`,{htmlFor:N,className:`sr-only`,children:[`Reply to the thread on `,sj(e)]}),(0,J.jsx)($O,{id:N,ref:M,rows:2,value:S,placeholder:`Reply…`,disabled:w,"aria-invalid":E!==null||void 0,onChange:e=>C(e.target.value),onSubmitShortcut:()=>void B(),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),te())},className:`min-h-14 bg-background`}),E!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ Not sent: `,E,` Your reply is still here; send it again when you're ready.`]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(xk,{hints:[{id:`submit`,action:`reply`},{id:`close`,action:`cancel`}]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,J.jsx)($,{variant:`ghost`,size:`sm`,disabled:w,onClick:te,children:`Cancel`}),(0,J.jsx)($,{size:`sm`,disabled:S.trim()===``||w,onClick:()=>void B(),children:w?`Sending…`:`Reply`})]})]})]}):se&&(0,J.jsxs)(`div`,{"data-slot":`thread-actions`,className:`flex items-center gap-2 pl-8.5`,children:[I&&(0,J.jsx)(`button`,{type:`button`,onClick:ee,className:`h-8 min-w-0 flex-1 cursor-text truncate rounded-md border border-input bg-background px-2.5 text-left text-ui text-muted-foreground hover:border-foreground/40`,children:`Reply…`}),L&&(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:O,onClick:()=>void ne(),className:X(!I&&`ml-auto`),children:e.resolved?`Reopen`:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Rh,{"aria-hidden":`true`}),`Resolve`]})})]})]}):(0,J.jsxs)(`div`,{className:`flex min-h-7 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,oe===void 0?``:` by ${oe}`]}),ie!==void 0&&(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-caption text-muted-foreground`,children:[ie.author.name,`: `,Td(ie.body)]}),(0,J.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!0),"aria-expanded":!1,children:[`Show `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]})]})})},uj=/[\p{L}\p{N}_]+|\s+|[^\p{L}\p{N}_\s]/gu,dj=e=>e.match(uj)??[],fj=e=>{let t=new Map,n=0;for(;n<e.length;){if(e[n]?.kind!==`del`){n++;continue}let r=n;for(;e[n]?.kind===`del`;)n++;let i=n;for(;e[n]?.kind===`add`;)n++;let a=Math.min(i-r,n-i);for(let n=0;n<a;n++){let a=pj(e[r+n]?.text??``,e[i+n]?.text??``);a!==null&&(t.set(r+n,a.old),t.set(i+n,a.new))}}return t},pj=(e,t)=>{if(e.length>500||t.length>500)return null;let n=dj(e),r=dj(t),{inOld:i,inNew:a}=hj(n,r),o=n.reduce((e,t,n)=>e+(i[n]?t.length:0),0),s=e.length+t.length;return s>0&&2*o/s<.3?null:{old:mj(n,i),new:mj(r,a)}},mj=(e,t)=>{let n=[],r=0;return e.forEach((e,i)=>{let a=r+e.length;if(!t[i]){let e=n.at(-1);e?.end===r?n[n.length-1]={start:e.start,end:a}:n.push({start:r,end:a})}r=a}),n},hj=(e,t)=>{let n=e.map(()=>!1),r=t.map(()=>!1),i=new Map([[1,0]]),a=[],o=(e,t)=>a[e]?.[t+e+1]??0,s=0;search:for(let n=0;n<=e.length+t.length;n++){let r=new Int32Array(2*n+3);for(let e=-n-1;e<=n+1;e++)r[e+n+1]=i.get(e)??0;a.push(r);for(let r=-n;r<=n;r+=2){let a=r===-n||r!==n&&(i.get(r-1)??0)<(i.get(r+1)??0)?i.get(r+1)??0:(i.get(r-1)??0)+1,o=a-r;for(;a<e.length&&o<t.length&&e[a]===t[o];)a++,o++;if(i.set(r,a),a>=e.length&&o>=t.length){s=n;break search}}}let c=e.length,l=t.length;for(let e=s;e>=0;e--){let t=c-l,i=t===-e||t!==e&&o(e,t-1)<o(e,t+1)?t+1:t-1,a=o(e,i),s=a-i;for(;c>a&&l>s;)c--,l--,n[c]=!0,r[l]=!0;c=a,l=s}return{inOld:n,inNew:r}},gj=(e,t=null)=>{let n=fj(e.lines);return Mk(e.lines).map(({line:r,text:i,carriageReturn:a},o)=>({key:`${e.id}:${o}`,hunkId:e.id,kind:r.kind,oldNo:r.oldLine,newNo:r.newLine,text:i,tokens:t?.[o]??null,wordRanges:n.get(o)??[],notes:[...a?[`CRLF`]:[],...r.noNewlineAtEnd?[`No newline at end of file`]:[]]}))},_j=e=>e.kind===`del`?e.oldLine===null?null:{side:`old`,line:e.oldLine}:e.newLine===null?null:{side:`new`,line:e.newLine},vj=`sticky left-0 w-[100cqw]`,yj=`pr-3 pl-29`,bj=({inset:e,children:t})=>(0,J.jsx)(`div`,{role:`row`,"data-slot":`line-row`,className:X(e&&X(yj,`py-2`),`font-sans`,vj),children:(0,J.jsx)(`div`,{role:`cell`,children:t})}),xj=(e,t)=>e.side===t.side&&e.line===t.line,Sj=e=>e.startLine===void 0?`Comment on ${e.side===`old`?`old `:``}line ${e.line}`:`Comment on ${e.side===`old`?`old `:``}lines ${e.startLine}–${e.line}`,Cj=(e,t,n)=>{let r=new Map(e.lines.flatMap(e=>e.kind!==`del`&&e.newLine!==null?[[e.newLine,e.text]]:[])),i=[];for(let e=t;e<=n;e+=1){let t=r.get(e);if(t===void 0)return null;i.push(t)}return i},wj=[],Tj=(0,q.memo)(function({id:e,hunk:t,file:n,risk:r,proofs:i=[],highlighted:a=!1,focused:o=!1,onFocus:s,lineLimit:c,unchanged:l=[],comments:u=[],openComment:d=null,onOpenComment:f,onCancelComment:p,onComment:m,onCommentNow:h,afterHeader:g,threadsAt:_,rangeNote:v,inFile:y=!1,marks:b,pointLines:x,pointsAt:S,pointsAtEnd:C,flagged:w}){let T=e??t.id,E=(0,q.useRef)(null),[D,O]=(0,q.useState)(!1),k=Zk(t,n,Xk(E)),A=(0,q.useMemo)(()=>gj(t,k),[t,k]),j=c===void 0||D||A.length<=c?A:A.slice(0,c);(0,q.useEffect)(()=>{let e=E.current;o&&e!==null&&!e.contains(document.activeElement)&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[o]);let M=Nk(t),N=!y||i.length>0,P=f!==void 0&&m!==void 0,F=(e,t)=>{let n=d;if(n!==null&&n.side===e.side&&n.line===e.line)f?.(T,null);else if(t&&n!==null&&n.side===e.side){let t=Math.min(n.startLine??n.line,e.line),r=Math.max(n.line,e.line);f?.(T,{side:e.side,line:r,startLine:t})}else f?.(T,e)};return(0,J.jsxs)(`section`,{ref:E,"data-slot":`hunk-card`,"data-risk":r?.riskClass,"data-highlighted":a||void 0,className:X(`relative scroll-mt-24 bg-card -outline-offset-2`,!y&&`overflow-hidden rounded-lg border`,a&&`bg-primary/5 shadow-[inset_0_0_0_2px_var(--ring)]`),"aria-label":`${n.path}, ${Fk(t)}`,tabIndex:0,onFocus:()=>s?.(T),children:[N&&(0,J.jsxs)(`header`,{"data-slot":`hunk-header`,className:X(`flex flex-wrap items-center gap-x-3 gap-y-1 border-b bg-surface-subtle px-3 py-1.5`,y&&`sticky left-0 w-[100cqw]`),children:[!y&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(JD,{file:n,status:n.status}),(0,J.jsx)(YD,{status:n.status}),t.sectionHeading!==null&&(0,J.jsx)(`code`,{className:`font-mono text-code-compact text-diff-hunk-fg`,children:t.sectionHeading}),(0,J.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,M.added]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,M.deleted]})]})]}),i.map(e=>(0,J.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),e.detail]},e.kind)),!y&&r!==null&&(0,J.jsxs)(`span`,{className:`ml-auto`,title:r.reason===``?void 0:r.reason,children:[(0,J.jsx)(tO,{status:cD[r.riskClass]}),r.reason!==``&&(0,J.jsxs)(`span`,{className:`sr-only`,children:[`: `,r.reason]})]})]}),(l.length>0||g!=null)&&(0,J.jsxs)(`div`,{className:X(y&&`sticky left-0 w-[100cqw]`),children:[l.map(e=>(0,J.jsx)(ZD,{callers:e,named:l.length>1},e.symbol)),g]}),(0,J.jsx)(`div`,{role:`table`,"aria-label":`Lines`,className:X(`[content-visibility:auto]`,!y&&`overflow-x-auto`),style:{containIntrinsicSize:`auto ${j.length*20}px`},children:(0,J.jsx)(`div`,{className:`w-max min-w-full`,children:j.map(e=>{let r=_j({kind:e.kind,oldLine:e.oldNo,newLine:e.newNo}),i=r===null?void 0:u.find(e=>xj(e,r)),a=r!==null&&d!==null&&xj(d,r),o=a?d:i,s=r===null?null:_?.(r)??null,c=r===null?null:S?.(r)??null,l=r===null?null:C?.(r)??null,g=r===null?null:`${r.side}:${r.line}`,E=g===null?void 0:x?.get(g);return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(nD,{line:e,cellRole:`cell`,pointKind:E?.kind??null,flagged:g!==null&&w?.has(g)===!0,...l===null?{}:{end:l},...E?.landing===void 0?{}:{pointLanding:E.landing},marks:(e.kind===`del`||e.newNo===null?void 0:b?.get(e.newNo))??wj,marked:r!==null&&m!==void 0&&d!==null&&d.side===r.side&&r.line>=(d.startLine??d.line)&&r.line<=d.line,numberButton:r===null||!P?void 0:{side:r.side,label:Sj(r),onClick:e=>F(r,e.shiftKey)},...r===null||!P?{}:{onRowClick:e=>{window.getSelection()?.isCollapsed!==!1&&(e.target instanceof Element&&e.target.closest(`button`)||F(r,e.shiftKey))}}}),c,r!==null&&o!=null&&(i!==void 0||a&&m!==void 0)&&(0,J.jsx)(Ej,{place:o,comment:i,editing:a&&m!==void 0,shown:(e,n)=>Cj(t,e,n),language:TD(n),rangeNote:v,fileName:n.path.split(`/`).at(-1)??n.path,onChange:m===void 0?void 0:e=>m(T,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e}),onEdit:()=>f?.(T,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine}}),onDone:()=>f?.(T,null),onCancel:()=>p?.(T,o),...h===void 0?{}:{onPostNow:e=>h(T,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e})},pinned:y}),s!==null&&(0,J.jsx)(`div`,{role:`row`,"data-slot":`line-threads`,className:X(yj,`py-2 font-sans`,y&&`sticky left-0 w-[100cqw]`),children:(0,J.jsx)(`div`,{role:`cell`,className:`flex max-w-3xl flex-col gap-2`,children:s})})]},e.key)})})}),j.length<A.length&&(0,J.jsx)(`div`,{className:X(`border-t p-2`,y&&`sticky left-0 w-[100cqw]`),children:(0,J.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>O(!0),children:[`Show all `,A.length,` lines`]})})]})}),Ej=({place:e,comment:t,editing:n,shown:r,language:i,rangeNote:a,fileName:o,onChange:s,onEdit:c,onDone:l,onCancel:u,onPostNow:d,pinned:f})=>{let p=(0,q.useRef)(null),m=(0,q.useRef)(null),[h,g]=(0,q.useState)(`write`),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(null);(0,q.useEffect)(()=>{n?m.current?.focus():(g(`write`),b(null))},[n]);let x=Sj(e),S=t?.body??``,C=t?.suggestion,w={body:S,...C===void 0?{}:{suggestion:C}},T=(0,q.useRef)(null);n?T.current===null&&(T.current=w):T.current=null;let E=e.side===`new`?r(e.startLine??e.line,e.line):null,D=e.startLine===void 0?null:`Lines ${e.startLine}–${e.line}`,O=()=>p.current?.closest(`[data-slot=hunk-card]`)?.focus({preventScroll:!0}),k=()=>s?.({body:``}),A=()=>{O(),S.trim()===``&&C===void 0&&s?.({body:``}),l()},j=async()=>{if(d===void 0||_||S.trim()===``)return;v(!0),b(null);let e=await d(w);v(!1),e===null?(O(),s?.({body:``}),l()):b(e)},M=()=>{O();let e=T.current;s?.(e===null||e.body.trim()===``&&e.suggestion===void 0?{body:``}:e),u?.(),l()},N=e=>(0,J.jsx)(rA,{title:`Suggested change`,removed:E,added:e,language:i});return(0,J.jsx)(`div`,{ref:p,role:`row`,"data-slot":`line-comment`,"data-editing":n||void 0,className:X(yj,`py-2 font-sans`,f&&`sticky left-0 w-[100cqw]`),children:(0,J.jsx)(Ck,{role:`cell`,state:`draft`,className:`flex max-w-3xl flex-col gap-2`,onKeyDown:n?e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(e.defaultPrevented)return;e.preventDefault(),A()}else e.key===`Escape`&&(e.stopPropagation(),M())}:void 0,children:n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,children:[`Commenting on `,(0,J.jsx)(jk,{children:o}),e.startLine===void 0?`line`:`lines`,` `,(0,J.jsx)(jk,{children:Ak(e.side,e.startLine??null,e.line)}),a!==void 0&&e.startLine!==void 0&&(0,J.jsx)(`span`,{children:a})]}),(0,J.jsxs)(JO,{value:h,onValueChange:e=>g(e===`preview`?`preview`:`write`),children:[(0,J.jsxs)(XO,{children:[(0,J.jsx)(ZO,{value:`write`,children:`Write`}),(0,J.jsx)(ZO,{value:`preview`,children:`Preview`})]}),(0,J.jsx)(QO,{value:`write`,children:(0,J.jsx)($O,{ref:m,rows:2,"aria-label":x,placeholder:`Leave a comment`,value:S,onChange:e=>s?.({...w,body:e.target.value}),onSubmitShortcut:A,className:`min-h-14 bg-background`})}),(0,J.jsx)(QO,{value:`preview`,"data-slot":`comment-preview`,className:`min-h-14 rounded-md border px-2.5 py-2`,children:S.trim()===``?(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`Nothing to preview`}):(0,J.jsx)(rj,{blocks:Vd(S).blocks,suggestion:N})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(xk,{hints:[{id:`submit`,action:`add to review`},{id:`close`,action:`cancel`}]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,J.jsx)($,{variant:`ghost`,size:`sm`,disabled:_,onClick:M,children:`Cancel`}),d!==void 0&&(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:_||S.trim()===``,onClick:()=>void j(),children:_?`Posting…`:`Comment now`}),(0,J.jsx)($,{size:`sm`,disabled:_,onClick:A,children:`Add to review`})]})]}),y!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ Not posted: `,y,` Your comment is still here.`]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[x,`: `]}),(0,J.jsx)(`span`,{className:X(ij,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:s===void 0?`Posted with your review`:`Draft · posts with your review`}),D!==null&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:D})]}),S.trim()!==``&&(0,J.jsx)(rj,{blocks:Vd(S).blocks,suggestion:N}),C!==void 0&&N(C),s!==void 0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Edit`}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,onClick:k,children:`Discard`})]})]})})})},Dj=()=>YE(),Oj=({handle:e,payload:t,id:n,render:r=(0,J.jsx)(`span`,{}),children:i})=>(0,J.jsx)(JE,{handle:e,payload:t,id:n,delay:300,closeDelay:150,render:r,"data-slot":`call`,className:`underline decoration-current decoration-dotted underline-offset-3 hover:decoration-primary hover:decoration-solid data-popup-open:decoration-primary data-popup-open:decoration-solid`,children:i}),kj=({handle:e,onGoTo:t})=>(0,J.jsx)(qE,{handle:e,children:({payload:n})=>n===void 0?null:(0,J.jsx)(XE,{side:`bottom`,align:`start`,"aria-label":n.label??`Code ${n.symbol} runs`,className:`flex max-h-[min(26rem,60vh)] w-[min(44rem,calc(100vw-2rem))] flex-col overflow-hidden p-0`,children:(0,J.jsx)(Aj,{payload:n,onGoTo:n=>{e.close(),t(n)}})})}),Aj=({payload:e,onGoTo:t})=>{let n=(0,q.useRef)(null),r=e.targets[0],i=r===void 0?null:`${r.hunk.id}:${Mj(r.hunk,e.symbol)}`;return(0,q.useEffect)(()=>{let e=n.current,t=i===null?null:e?.querySelector(`[data-line="${i}"]`),r=e?.querySelector(`header`);e!=null&&t!=null&&(e.scrollTop=t.offsetTop-(r?.offsetHeight??0))},[i]),(0,J.jsx)(`div`,{ref:n,"data-slot":`peek-scroller`,className:`@container relative min-h-0 overflow-auto`,children:(0,J.jsx)(`div`,{className:`w-max min-w-full`,children:e.targets.map((n,r)=>(0,J.jsx)(jj,{target:n,symbol:e.symbol,onGoTo:t,divided:r>0,last:r===e.targets.length-1},n.id))})})},jj=({target:e,symbol:t,onGoTo:n,divided:r,last:i})=>{let{hunk:a,file:o}=e,s=Zk(a,o,!0),c=(0,q.useMemo)(()=>gj(a,s),[a,s]),l=Nk(a),u=Fk(a);return(0,J.jsxs)(`section`,{"aria-label":`${o.path}, ${u}`,className:r?`border-t`:void 0,children:[(0,J.jsxs)(`header`,{className:X(vj,`top-0 z-[2] flex flex-wrap items-center gap-x-3 gap-y-1 border-b bg-surface-subtle px-3 py-1 text-caption`),children:[(0,J.jsx)(JD,{file:o,status:o.status}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:u}),(0,J.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,l.added]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,l.deleted]})]}),(0,J.jsx)($,{variant:`link`,size:`xs`,className:`ml-auto px-0`,onClick:()=>n(e.id),children:`Go to file`})]}),(0,J.jsx)(`div`,{role:`table`,"aria-label":`Lines of ${t}`,className:`w-max min-w-full`,children:c.map(e=>(0,J.jsx)(nD,{line:e,layout:`split-new`,cellRole:`cell`,density:`compact`},e.key))}),i&&(0,J.jsx)(aD,{kind:c.at(-1)?.kind??`context`,className:`h-3`})]})},Mj=(e,t)=>{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=RegExp(`(?<![\\w$])${n}(?![\\w$])`),i=RegExp(`\\b(def|class|function|func|fn|const|let|var|type|interface|enum|struct|trait|impl)\\b[^=(]*?(?<![\\w$])${n}(?![\\w$])`),a=e.lines.map((e,t)=>({line:e,at:t})).filter(({line:e})=>e.kind!==`del`);return a.find(({line:e})=>i.test(e.text))?.at??a.find(({line:e})=>r.test(e.text))?.at??0},Nj=q.createContext(void 0);function Pj(){return q.useContext(Nj)}function Fj(e){let{render:t,className:n,style:r,state:i=Jv,props:a=qv,refs:o=qv,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=xO({metadata:s});return Qv(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var Ij=q.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=gE(u||void 0),h=Pj(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=nO({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=Pv({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=Ab(Mb,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=Qv(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=q.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,J.jsx)(Fj,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),Lj=q.createContext(void 0);function Rj(e){let t=q.useContext(Lj);if(t===void 0&&!e)throw Error(Ov(69));return t}var zj=cy(`group/toggle inline-flex items-center justify-center gap-1 rounded-md text-ui font-medium whitespace-nowrap transition-all hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-background aria-pressed:text-foreground aria-pressed:shadow-sm aria-pressed:ring-1 aria-pressed:ring-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-md px-2.5 text-ui has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}});function Bj({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,J.jsx)(Ij,{"data-slot":`toggle`,className:X(zj({variant:t,size:n,className:e})),...r})}q.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});var Vj=(e,t)=>{let n=new Set,r=e=>{let r=t.filter(t=>!n.has(t)&&e(t));for(let e of r)n.add(e);return r},i=e.flatMap(e=>{let t=r(t=>t.path===e.path&&t.hunkId===null).map(t=>({key:`${e.path}\0${t.kind}`,path:e.path,file:e,hunk:null,proofs:[t],summary:Hj(t,e)})),n=e.hunks.flatMap(t=>{let n=r(e=>e.hunkId===t.id);if(n.length===0)return[];let{added:i,deleted:a}=Nk(t),o=n.map(e=>e.detail).join(`; `);return[{key:t.id,path:e.path,file:e,hunk:t,proofs:n,summary:`${e.path} — ${o} (+${i} −${a})`}]});return[...t,...n]}),a=t.filter(e=>!n.has(e)).map((e,t)=>({key:`orphan-${t}`,path:e.path,file:null,hunk:null,proofs:[e],summary:`${e.path} — ${e.detail}`}));return[...i,...a]},Hj=(e,t)=>e.kind===`rename`&&t.oldPath!==null?`${t.oldPath} → ${t.path} — renamed, content unchanged`:`${t.path} — ${e.detail}`,Uj=`flex min-h-8 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-muted-foreground`,Wj=({open:e,children:t,...n})=>(0,J.jsxs)(`button`,{type:`button`,"data-slot":`mechanical-toggle`,"aria-expanded":e,className:X(Uj,`hover:bg-accent hover:text-accent-foreground`),...n,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 transition-transform duration-(--duration-fast) ease-standard`,!e&&`-rotate-90`),children:`▾`}),(0,J.jsx)(`span`,{className:`min-w-0`,children:t})]}),Gj=(0,q.memo)(function({hunk:e,file:t,risk:n,proofs:r,focused:i=!1,onFocus:a}){let o=(0,q.useRef)(null),[s,c]=(0,q.useState)(!1),{added:l,deleted:u}=Nk(e);return(0,q.useEffect)(()=>{let e=o.current;i&&e!==null&&e!==document.activeElement&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[i]),(0,J.jsxs)(`div`,{"data-slot":`mechanical-hunk`,className:`bg-surface-subtle`,children:[(0,J.jsxs)(Wj,{ref:o,open:s,onClick:()=>c(e=>!e),onFocus:()=>a?.(e.id),children:[t.path,`, `,Fk(e),` — `,r.map(e=>e.detail).join(`; `),` (+`,l,` −`,u,`)`]}),s&&(0,J.jsx)(Tj,{hunk:e,file:t,risk:n,proofs:r,lineLimit:500})]})}),Kj=({files:e,proofs:t,risk:n})=>{let r=(0,q.useId)(),i=(0,q.useMemo)(()=>Vj(e,t),[e,t]),[a,o]=(0,q.useState)(new Set),s=i.filter(e=>e.hunk!==null).map(e=>e.key),c=s.length>0&&s.every(e=>a.has(e));if(i.length===0)return null;let l=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,J.jsxs)(`section`,{"aria-labelledby":r,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`h2`,{id:r,className:`flex items-center gap-2 text-heading font-semibold`,children:[`Mechanical changes`,` `,(0,J.jsx)(`span`,{className:`tabular rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground`,children:i.length})]}),s.length>0&&(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>o(new Set(c?[]:s)),children:c?`Collapse all`:`Expand all`})]}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>{let t=a.has(e.key);return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[e.hunk===null||e.file===null?(0,J.jsxs)(`span`,{className:Uj,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0`}),e.summary]}):(0,J.jsx)(Wj,{open:t,onClick:()=>l(e.key),children:e.summary}),t&&e.hunk!==null&&e.file!==null&&(0,J.jsx)(Tj,{hunk:e.hunk,file:e.file,risk:n.find(t=>t.hunkId===e.hunk?.id)??null,proofs:e.proofs,lineLimit:500})]},e.key)})})]})},qj={added:`added`,deleted:`deleted`,modified:`changed`,renamed:`changed`},Jj=e=>e.flatMap(e=>{let t=e.oldMode!==null||e.newMode!==null,n=!e.binary&&!t&&e.hunks.length===0&&e.status!==`renamed`;return[...e.binary?[{key:`${e.path}\0binary`,file:e,text:`binary file ${qj[e.status]}`}]:[],...t?[{key:`${e.path}\0mode`,file:e,text:`mode ${e.oldMode??`unknown`} → ${e.newMode??`unknown`}`}]:[],...n?[{key:`${e.path}\0empty`,file:e,text:e.status===`modified`?`changed, no lines to show`:`empty file ${e.status}`}]:[]]}),Yj=({files:e})=>{let t=(0,q.useId)(),n=Jj(e);return n.length===0?null:(0,J.jsxs)(`section`,{"aria-labelledby":t,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,J.jsx)(`h2`,{id:t,className:`text-heading font-semibold`,children:`Changes without lines to show`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(({key:e,file:t,text:n})=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(JD,{file:t,status:t.status}),(0,J.jsx)(YD,{status:t.status}),(0,J.jsx)(`span`,{children:n})]},e))})]})},Xj=({hunkId:e,lines:t})=>t.length===0?null:(0,J.jsx)(`div`,{role:`table`,"aria-label":`Unchanged lines`,children:(0,J.jsx)(`div`,{className:`w-max min-w-full`,children:t.map(({oldNo:t,newNo:n,text:r,tokens:i})=>{let a={key:`${e}:unchanged:${n}`,hunkId:e,kind:`context`,oldNo:t,newNo:n,text:r,tokens:i,wordRanges:[],notes:[]};return(0,J.jsx)(nD,{line:a,cellRole:`cell`},n)})})}),Zj=q.createContext(void 0);function Qj(e){let t=q.useContext(Zj);if(t===void 0&&!e)throw Error(Ov(47));return t}var $j={...Cw,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Cw.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Cw.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Cw.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},eM=class extends mw{constructor(e,t,n){let r=new tw;super(tM(e,r,t,n),nM(r),$j)}setOpen=(e,t)=>{let n=t.reason===Pb,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=JC(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=qC(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),US.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function tM(e,t,n,r=!1){let i={..._w(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function nM(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new yy,stickIfOpen:!0,triggerElements:e}}var rM=my(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=aM(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),ew(u,d),ZC(u);let{forceUnmount:m}=QC(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ab(Yb))}),[m,u]);let h=d||f||s!=null;return(0,J.jsxs)(Zj.Provider,{value:u,children:[s&&(0,J.jsx)(WC,{handle:s,store:u}),h&&(0,J.jsx)(oM,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function iM(e){return Qj(!0)?(0,J.jsx)(rM,{props:e}):(0,J.jsx)(rC,{children:(0,J.jsx)(rM,{props:e})})}function aM(e,t){let n=UC((e,n)=>new eM(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function oM({store:e,modal:t}){let n=bC(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return $C(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}function sM(e,t){function n(n,r,i){let a=n.currentTarget;US.flushSync(()=>{e.setOpen(!1,Ab(zb,n.nativeEvent,a))}),pS(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&mS(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var cM=hy(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=Qj(!0),h=ww(s)??m;if(!h)throw Error(Ov(74));let g=gE(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=q.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=XC(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=Fw(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:Zw(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=mC(v,{stickIfOpen:Z(()=>h.context.stickIfOpen)}),k=RA(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=Pv({disabled:a,native:o}),N={open(e){return w?pb.open(e):fb.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=sM(h,x),I=Qv(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[zS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,J.jsx)(q.Fragment,{children:I},g);return E?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(fx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,J.jsx)(fx,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),lM=q.createContext(void 0);function uM(){let e=q.useContext(lM);if(e===void 0)throw Error(Ov(45));return e}var dM=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Qj().useState(`mounted`)||n?(0,J.jsx)(lM.Provider,{value:n,children:(0,J.jsx)(JS,{ref:t,...r})}):null}),fM=q.createContext(void 0);function pM(){let e=q.useContext(fM);if(!e)throw Error(Ov(46));return e}function mM(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=q.useRef(null),o=q.useRef(null),s=RC(r);Q(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Q(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var hM=20;function gM(e,t,n,r){let[i,a]=q.useState(!1);Q(()=>{if(!e||!t||n==null){a(!1);return}let r=Mv(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-hM)},[e,t,n]),DA(e&&(!t||i),r)}var _M=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=VS,..._}=e,v=Qj(),y=uM(),b=tC(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=IE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});mM({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;gM(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=BE(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,J.jsxs)(fM.Provider,{value:j,children:[S&&M&&(0,J.jsx)(hA,{inert:UE(!C),cutout:T}),(0,J.jsx)(nC,{id:b,children:P})]})}),vM=q.createContext(void 0);function yM(){let[e,t]=q.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var bM=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Qj(),l=pM(),u=Rj(!0)!=null,{context:d,hasClosePart:f}=yM(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);zC({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Nw(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?HC(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Qv(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...VC,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&IO.has(e.key)&&e.stopPropagation()}},zE(g),s],stateAttributesMapping:hb});return(0,J.jsx)(pC,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:B_(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,J.jsx)(vM.Provider,{value:d,children:M})})}),xM=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Qj(),s=gE(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),Qv(`h2`,e,{ref:t,props:[{id:s},a]})});function SM({...e}){return(0,J.jsx)(iM,{"data-slot":`popover`,...e})}function CM({...e}){return(0,J.jsx)(cM,{"data-slot":`popover-trigger`,...e})}function wM({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,J.jsx)(dM,{children:(0,J.jsx)(_M,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,J.jsx)(bM,{"data-slot":`popover-content`,className:X(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-xl bg-popover p-2.5 text-ui text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-(--duration-fast) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function TM({className:e,...t}){return(0,J.jsx)(xM,{"data-slot":`popover-title`,className:X(`font-medium`,e),...t})}var EM={open:Sg,draft:Eg,merged:bg,closed:wg},DM=({state:e})=>{let{label:t,className:n}=uD[e],r=EM[e];return(0,J.jsxs)(eO,{"data-slot":`pr-state`,variant:`outline`,className:n,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),t]})},OM=({status:e})=>e===null?null:(0,J.jsx)(`span`,{"data-slot":`review-status`,children:(0,J.jsx)(tO,{status:dD[e]})}),kM=e=>{switch(e.state){case`failed`:return`CI ${e.failed} of ${e.total} failed`;case`running`:return`CI ${e.running} of ${e.total} running`;case`skipped`:return`CI ${e.skipped} skipped`;default:return`CI ${e.passed}/${e.total} passed`}},AM=e=>{let t=e=>`${e} ${e===1?`check`:`checks`}`;switch(e.state){case`failed`:return`CI: ${e.failed} of ${t(e.total)} failed`;case`running`:return`CI: ${e.running} of ${t(e.total)} running`;case`skipped`:return`CI: ${t(e.skipped)} skipped`;default:return`CI: ${e.passed} of ${t(e.total)} passed`}},jM=`h-6 gap-1.5 px-1.5 font-normal text-muted-foreground`,MM=({check:e})=>{let t=fD[e.state];return(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 text-center`,t.tone),children:t.glyph}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),(0,J.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:t.label}),e.url!==null&&(0,J.jsx)(`a`,{className:`shrink-0 text-caption`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`Details of ${e.name}`,children:`Details`})]})},NM=({checks:e,unreadable:t,head:n})=>{let r=e===null?null:cf(e),i=r===null||r.state===null?null:AM(r),a=PM(i);if(e===null)return(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:jM,"data-slot":`ci-summary`,children:`CI not readable`})}),(0,J.jsxs)(wM,{align:`end`,children:[(0,J.jsx)(TM,{children:`CI not readable`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:t})]})]});if(r===null||r.state===null)return null;let o=fD[r.state];return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsxs)($,{variant:`ghost`,size:`xs`,className:jM,"data-slot":`ci-summary`,"data-state":r.state,"aria-label":`${i}, show checks`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:o.tone,children:o.glyph}),(0,J.jsx)(`span`,{className:`tabular`,children:kM(r)})]})}),(0,J.jsxs)(wM,{align:`end`,className:`w-96`,children:[(0,J.jsxs)(TM,{children:[`Checks on `,(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:n.slice(0,7)})]}),(0,J.jsx)(`ul`,{className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,"aria-label":`Checks`,children:sf(e).map(e=>(0,J.jsx)(MM,{check:e},`${e.name}:${e.url??``}`))})]})]}),(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:a})]})},PM=e=>{let t=(0,q.useRef)(void 0),[n,r]=(0,q.useState)(``);return(0,q.useEffect)(()=>{t.current===void 0?t.current=e:e!==null&&e!==t.current&&(t.current=e,r(e))},[e]),n},FM={"changes-requested":b_,approved:Rh,commented:Kg},IM=3,LM=({reviewer:e})=>{let t=e.verdict===null?null:FM[e.verdict];return(0,J.jsxs)(`span`,{className:`relative flex size-6 shrink-0 items-center justify-center rounded-full bg-muted text-caption font-medium text-muted-foreground ring-2 ring-background`,children:[wk(e.name),t!==null&&e.verdict!==null&&(0,J.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 flex size-3 items-center justify-center rounded-full bg-background`,children:(0,J.jsx)(t,{className:X(`size-2.5`,pD[e.verdict].tone),strokeWidth:3.5})})]})},RM=e=>{let t=new Map;for(let n of e){let e=pD[n.verdict??`waiting`].label.toLowerCase();t.set(e,(t.get(e)??0)+1)}let n=[...t].map(([e,t])=>`${t} ${e}`);return`${`${e.length} ${e.length===1?`reviewer`:`reviewers`}`}: ${n.join(`, `)}`},zM=({reviewers:e})=>{if(e.length===0)return null;let t=af(e),n=t.length>IM?t.slice(0,2):t,r=t.length-n.length;return(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:`h-7 px-1`,"data-slot":`reviewers`,"aria-label":`${RM(t)}, show reviewers`,children:(0,J.jsxs)(`span`,{"aria-hidden":`true`,className:`flex items-center -space-x-1`,children:[n.map(e=>(0,J.jsx)(LM,{reviewer:e},e.id)),r>0&&(0,J.jsxs)(`span`,{className:`flex size-6 items-center justify-center rounded-full bg-muted text-caption font-medium text-muted-foreground ring-2 ring-background`,children:[`+`,r]})]})})}),(0,J.jsxs)(wM,{align:`end`,children:[(0,J.jsx)(TM,{children:`Reviewers`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Reviewers`,children:t.map(e=>{let t=pD[e.verdict??`waiting`];return(0,J.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:(0,J.jsx)(LM,{reviewer:e})}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,e.team&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` (team)`})]}),(0,J.jsx)(`span`,{className:X(`shrink-0 text-caption`,t.tone),children:t.label})]},e.id)})})]})]})};function BM(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var VM=e=>{switch(e){case`success`:return WM;case`info`:return KM;case`warning`:return GM;case`error`:return qM;default:return null}},HM=Array(12).fill(0),UM=({visible:e,className:t})=>q.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},q.createElement(`div`,{className:`sonner-spinner`},HM.map((e,t)=>q.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),WM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),GM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),KM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),qM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),JM=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},q.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),q.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),YM=()=>{let[e,t]=q.useState(document.hidden);return q.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},XM=1,ZM=100,QM=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:XM++,$M=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-ZM;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=QM(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],q.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(tN(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=QM(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},eN=(e,t)=>$M.message(e,t),tN=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`;Object.assign(eN,{success:$M.success,info:$M.info,warning:$M.warning,error:$M.error,custom:$M.custom,message:$M.message,promise:$M.promise,dismiss:$M.dismiss,loading:$M.loading},{getHistory:()=>$M.toasts,getToasts:()=>$M.getActiveToasts()}),BM(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function nN(e){return e.label!==void 0}var rN=3,iN=`24px`,aN=`16px`,oN=4e3,sN=356,cN=14,lN=45,uN=200;function dN(...e){return e.filter(Boolean).join(` `)}function fN(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var pN=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=q.useState(null),[O,k]=q.useState(null),[A,j]=q.useState(!1),[M,N]=q.useState(!1),[P,F]=q.useState(!1),[I,L]=q.useState(!1),[R,ee]=q.useState(!1),[z,te]=q.useState(0),[B,ne]=q.useState(0),V=q.useRef(n.duration||y||oN),H=q.useRef(null),re=q.useRef(null),ie=c===0,ae=c+1<=o,oe=n.type,se=oe??`default`,U=n.dismissible!==!1,ce=n.className||``,le=n.descriptionClassName||``,ue=q.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),de=q.useMemo(()=>n.closeButton??p,[n.closeButton,p]),fe=q.useMemo(()=>n.duration||y||oN,[n.duration,y]),pe=q.useRef(0),me=q.useRef(0),he=q.useRef(0),ge=q.useRef(null),[_e,ve]=b.split(`-`),ye=q.useMemo(()=>s.reduce((e,t,n)=>n>=ue?e:e+t.height,0),[s,ue]),be=YM(),xe=q.useMemo(()=>e.swipeDirections??fN(b),[e.swipeDirections,b]),Se=n.invert||t,Ce=oe===`loading`;me.current=q.useMemo(()=>ue*x+ye,[ue,ye]),q.useEffect(()=>{V.current=fe},[fe]),q.useEffect(()=>{j(!0)},[]),q.useEffect(()=>{let e=re.current;if(e){let t=e.getBoundingClientRect().height;return ne(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),q.useLayoutEffect(()=>{if(!A)return;let e=re.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ne(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let we=q.useCallback(()=>{N(!0),te(me.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},uN)},[n,d,a,me]);q.useEffect(()=>{if(n.promise&&oe===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||be?(()=>{if(he.current<pe.current){let e=new Date().getTime()-pe.current;V.current-=e}he.current=new Date().getTime()})():V.current!==1/0&&(pe.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),we()},V.current)),()=>clearTimeout(e)},[u,i,n,oe,be,we]),q.useEffect(()=>{n.delete&&(we(),n.onDismiss==null||n.onDismiss.call(n,n))},[we,n.delete]);function Te(){return w?.loading?q.createElement(`div`,{className:dN(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":oe===`loading`},w.loading):q.createElement(UM,{className:dN(C?.loader,n?.classNames?.loader),visible:oe===`loading`})}let Ee=n.icon||w?.[oe]||VM(oe);return q.createElement(`li`,{tabIndex:0,ref:re,className:dN(_,ce,C?.toast,n?.classNames?.toast,C?.[se],n?.classNames?.[se]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":ae,"data-y-position":_e,"data-x-position":ve,"data-index":c,"data-front":ie,"data-swiping":P,"data-dismissible":U,"data-type":oe,"data-invert":Se,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?z:me.current}px`,"--initial-height":S?`auto`:`${B}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),ge.current=null},onPointerDown:e=>{e.button!==2&&!Ce&&U&&(H.current=new Date,te(me.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),ge.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{if(I||!U)return;ge.current=null;let e=Number(re.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(re.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-H.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if((E===`x`?xe.includes(e>0?`right`:`left`):xe.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=lN||a>.11))te(me.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),we(),L(!0);else{var o,s;(o=re.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=re.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),ee(!1),F(!1),D(null)}},onPointerMove:e=>{var t,n;if(!ge.current||!U||window.getSelection()?.toString().length>0)return;let r=e.clientY-ge.current.y,i=e.clientX-ge.current.x;!E&&(Math.abs(i)>1||Math.abs(r)>1)&&D(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(xe.includes(`top`)||xe.includes(`bottom`)){if(xe.includes(`top`)&&r<0||xe.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(E===`x`&&(xe.includes(`left`)||xe.includes(`right`))){if(xe.includes(`left`)&&i<0||xe.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&ee(!0),(t=re.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=re.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},de&&!n.jsx&&oe!==`loading`?q.createElement(`button`,{"aria-label":T,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!U?()=>{}:()=>{we(),n.onDismiss==null||n.onDismiss.call(n,n)},className:dN(C?.closeButton,n?.classNames?.closeButton)},w?.close??JM):null,(oe||n.icon||n.promise)&&n.icon!==null&&(w?.[oe]!==null||n.icon)?q.createElement(`div`,{"data-icon":``,className:dN(C?.icon,n?.classNames?.icon)},oe===`loading`?n.icon||Te():n.promise?Te():null,oe===`loading`?null:Ee):null,q.createElement(`div`,{"data-content":``,className:dN(C?.content,n?.classNames?.content)},q.createElement(`div`,{"data-title":``,className:dN(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?q.createElement(`div`,{"data-description":``,className:dN(v,le,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),q.isValidElement(n.cancel)?n.cancel:n.cancel&&nN(n.cancel)?q.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{nN(n.cancel)&&U&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),we())},className:dN(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,q.isValidElement(n.action)?n.action:n.action&&nN(n.action)?q.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{nN(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&we())},className:dN(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function mN(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function hN(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?aN:iN;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var gN=q.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=rN,toastOptions:g,dir:_=mN(),gap:v=cN,icons:y,customAriaLabel:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=q.useState([]),w=q.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=q.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=q.useState([]),[O,k]=q.useState(!1),[A,j]=q.useState(!1),[M,N]=q.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=q.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=q.useRef(null),L=q.useRef(!1),R=q.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||$M.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return q.useEffect(()=>$M.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{US.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),q.useEffect(()=>{if(d!==`system`){N(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?N(`dark`):N(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{N(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{N(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),q.useEffect(()=>{S.length<=1&&k(!1)},[S]),q.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=P.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===P.current||P.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),q.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),q.createElement(`section`,{ref:t,"aria-label":b??`${x} ${F}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?q.createElement(`ol`,{key:t,dir:_===`auto`?mN():_,tabIndex:-1,ref:P,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${sN}px`,"--gap":`${v}px`,...m,...hN(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>q.createElement(pN,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:R,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:v,expanded:O,swipeDirections:e.swipeDirections}))):null}))});function _N({className:e,...t}){return(0,J.jsx)(`label`,{"data-slot":`label`,className:X(`flex items-center gap-2 text-ui leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var vN=`data-valid`,yN=`data-invalid`,bN={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},xN={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},SN={valid(e){return e===null?null:e?{[vN]:``}:{[yN]:``}}},CN={invalid:void 0,name:void 0,validityData:{state:bN,errors:[],error:``,value:``,initialValue:null},setValidityData:Kv,disabled:void 0,setTouched:Kv,setDirty:Kv,setFilled:Kv,setFocused:Kv,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:xN,registerFieldControl:Kv,validation:{getValidationProps:(e,t=Jv)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Kv,getInputControl:()=>null,commit:async()=>{},change:Kv}},wN=q.createContext(CN);function TN(e=!0){let t=q.useContext(wN);if(t.setValidityData===Kv&&!e)throw Error(Ov(28));return t}function EN(e,t,n){let{setFocused:r,focusOwnerRef:i}=TN(),a=Z(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return Q(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var DN=q.createContext({controlId:void 0,registerControlId:Kv,resetControlId:Kv,labelId:void 0,setLabelId:Kv,messageIds:[],setMessageIds:Kv,getDescriptionProps:e=>e});function ON(){return q.useContext(DN)}function kN(e,t,n,r=!0,i,a){let[o,s]=q.useState(),c=gE(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return Q(()=>{let i=e||t||l||!r?void 0:AN(n.current,c);o!==i&&s(i)}),u}function AN(e,t){let n=jN(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function jN(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function MN(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=ON(),o=gE(),s=sv(()=>Symbol()),c=q.useRef(!1),l=q.useRef(!1),u=Z(()=>{c.current&&i!==Kv&&(c.current=!1,i(s.current,void 0))});return Q(()=>{if(!n||i===Kv){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),Q(()=>u,[u]),(n?r:void 0)??t??o}function NN(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function PN(e,t,n,r,i=!0,a){let{registerFieldControl:o}=TN(),s=sv(()=>Symbol());Q(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),Q(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var FN=q.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Kv,validationMode:`onSubmit`,submitCountRef:{current:0}});function IN(){return q.useContext(FN)}var LN=`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,RN=`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`;function zN({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`skeleton`,className:X(`animate-pulse rounded-md bg-muted`,e),...t})}var BN={muted:`bg-muted text-muted-foreground`,done:`bg-review-approved-bg text-review-approved`,info:`bg-diff-hunk-bg text-diff-hunk-fg`},VN=({glyph:e,title:t,body:n,actions:r=[],tone:i=`muted`,inline:a=!1})=>(0,J.jsxs)(`div`,{className:X(`flex flex-col gap-2`,a?`items-start p-3`:`mx-auto max-w-sm items-center px-6 py-12 text-center`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex items-center justify-center rounded-full font-semibold`,a?`size-7 text-ui`:`size-10 text-heading`,BN[i]),children:e}),(0,J.jsx)(`p`,{className:X(`font-semibold`,a?`text-ui`:`text-heading`),children:t}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:n}),r.length>0&&(0,J.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:r.map((e,t)=>(0,J.jsxs)($,{variant:t===0?`outline`:`ghost`,size:`sm`,onClick:e.onClick,children:[e.label,e.shortcut!==void 0&&(0,J.jsx)(bk,{id:e.shortcut})]},e.label))})]}),HN=({lines:e=7})=>(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Loading the diff`,className:`overflow-hidden rounded-lg border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex h-10 items-center gap-3 border-b px-3`,children:[(0,J.jsx)(zN,{className:`h-3 w-3`}),(0,J.jsx)(zN,{className:`h-3 w-56`}),(0,J.jsx)(zN,{className:`ml-auto h-3 w-12`})]}),(0,J.jsx)(`div`,{className:`flex flex-col py-1`,children:Array.from({length:e},(e,t)=>(0,J.jsxs)(`div`,{className:`flex h-5 items-center gap-3 px-3`,children:[(0,J.jsx)(zN,{className:`h-2.5 w-8`}),(0,J.jsx)(zN,{className:`h-2.5`,style:{width:`${30+t*37%55}%`}})]},t))})]}),UN=({rows:e=8})=>(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Loading the files`,className:`flex flex-col gap-2 px-1`,children:[(0,J.jsx)(zN,{className:`h-7 w-full`}),Array.from({length:e},(e,t)=>(0,J.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,style:{paddingLeft:`${t%3*12}px`},children:[(0,J.jsx)(zN,{className:`h-2.5 flex-1`}),(0,J.jsx)(zN,{className:`h-2.5 w-10`})]},t))]}),WN=q.createContext(void 0);function GN(){let e=q.useContext(WN);if(e===void 0)throw Error(Ov(63));return e}var KN=`data-checked`,qN=`data-unchecked`,JN={...SN,checked(e){return e?{[KN]:``}:{[qN]:``}}},YN=q.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=IN(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,validationMode:E,disabled:D,name:O,validation:k}=TN(),{labelId:A}=ON(),j=D||m,M=O??l,N=q.useRef(null),P=Lv(N,c,k.inputRef),F=q.useRef(null),I=EN(j,F),L=gE(),R=MN({id:s}),ee=u?void 0:R,[z,te]=nO({controlled:n,default:!!i,name:`Switch`,state:`checked`});PN(F,L,z,void 0,!j,l),Q(()=>{T(z)},[z,T]),LA(z,()=>{b(M),C(z!==w.initialValue),k.change(z)});let{getButtonProps:B,buttonRef:ne}=Pv({disabled:j,native:u}),V=kN(a,A,N,!u,ee,y[`aria-label`]),H={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":V,onFocus(){I(!0)},onBlur(){let e=N.current;e&&!j&&(S(!0),I(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){if(f||j)return;e.preventDefault();let t=N.current;t&&Nv(t,e)}},re={...k.getValidationProps(j),checked:z,disabled:j,form:o,id:ee,name:M,required:p,style:M?dx:ux,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:P,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Ab(Mb,e.nativeEvent);d?.(t,n),!n.isCanceled&&te(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?Jv:{value:_}},ie=q.useMemo(()=>({...x,checked:z,disabled:j,readOnly:f,required:p}),[x,z,j,f,p]),ae=Qv(`span`,e,{state:ie,ref:[t,F,ne],props:[H,y,B,e=>k.getValidationProps(j,e)],stateAttributesMapping:JN});return(0,J.jsxs)(WN.Provider,{value:ie,children:[ae,!z&&M&&g!==void 0&&(0,J.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,J.jsx)(`input`,{...re,suppressHydrationWarning:!0})]})}),XN=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Qv(`span`,e,{state:GN(),ref:t,stateAttributesMapping:JN,props:a})});function ZN({className:e,size:t=`default`,...n}){return(0,J.jsx)(YN,{"data-slot":`switch`,"data-size":t,className:X(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] data-checked:bg-primary data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,J.jsx)(XN,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}var QN=[{scope:`global`,title:`Anywhere`},{scope:`diff`,title:`In the code`},{scope:`overview`,title:`In the overview`},{scope:`tree`,title:`In the file tree`},{scope:`composer`,title:`Writing a comment or review`},{scope:`picker`,title:`On the pull requests page`}],$N=({open:e,onOpenChange:t,ids:n})=>{let r=ek.filter(e=>n===void 0||n.includes(e.id)),[i,a]=gk(),o=(0,q.useMemo)(dk,[]),s=(0,q.useId)();return(0,J.jsx)(BA,{open:e,onOpenChange:t,children:(0,J.jsxs)(UA,{className:`max-h-[85vh] overflow-y-auto sm:max-w-lg`,children:[(0,J.jsxs)(WA,{children:[(0,J.jsx)(GA,{children:`Keyboard shortcuts`}),(0,J.jsx)(KA,{children:`Keys don't fire while you type in a field.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,J.jsxs)(_N,{htmlFor:s,className:`leading-snug`,children:[`Single-key shortcuts`,(0,J.jsx)(`span`,{className:`block text-caption font-normal text-muted-foreground`,children:`Letter keys like n and c. Off if they get in the way of speech input or another tool.`})]}),(0,J.jsx)(ZN,{id:s,checked:i,onCheckedChange:a})]}),QN.filter(({scope:e})=>r.some(t=>t.scope===e)).map(({scope:e,title:t})=>(0,J.jsxs)(`section`,{"aria-label":t,className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:t}),(0,J.jsx)(`dl`,{className:`flex flex-col`,children:r.filter(t=>t.scope===e).map(e=>{let t=!i&&e.chords.every(ak);return(0,J.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-4 border-b py-1 last:border-0`,children:[(0,J.jsxs)(`dt`,{className:t?`text-muted-foreground line-through`:void 0,children:[e.action,t&&(0,J.jsx)(`span`,{className:`sr-only`,children:` (off)`})]}),(0,J.jsx)(`dd`,{className:`flex gap-2`,children:e.chords.map(e=>(0,J.jsx)(yk,{children:sk(e,o).map(e=>(0,J.jsx)(vk,{children:e},e))},sk(e,o).join(` `)))})]},e.id)})})]},e))]})})},eP=q.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:y,validationMode:b,validation:x}=TN(),{clearErrors:S,elementRef:C,submitCountRef:w}=IN(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=ON(),k=MN({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=Z(()=>x.inputRef.current?.value);PN(x.inputRef,k,j,M,!T,a),Q(()=>{let e=j??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[j,l,x.inputRef,y]),LA(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=q.useRef(null),P=EN(T,N),F=by();return Qv(`input`,e,{ref:[t,N],state:D,props:[{id:k,disabled:T,name:E,ref:x.inputRef,"aria-labelledby":O,autoFocus:u,...A?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Ab(Mb,e.nativeEvent);c?.(t,n),!A&&(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(S(E),x.change(t)))},onFocus(){P(!0)},onBlur(e){if(g(!0),P(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),A&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===C.current&&!e.defaultPrevented){let t=e.currentTarget,n=w.current;F.start(0,()=>{w.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(T,e)],stateAttributesMapping:SN})}),tP=q.forwardRef(function(e,t){return(0,J.jsx)(eP,{ref:t,...e})});function nP({className:e,type:t,...n}){return(0,J.jsx)(tP,{type:t,"data-slot":`input`,className:X(`h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-ui transition-colors file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-ui file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20`,e),...n})}var rP=q.createContext(void 0);function iP(){let e=q.useContext(rP);if(e===void 0)throw Error(Ov(53));return e}function aP(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var oP=`base-ui-disable-scrollbar`,sP={className:oP,getElement(e){return(0,J.jsx)(`style`,{nonce:e,href:oP,precedence:`base-ui:low`,children:`.${oP}{scrollbar-width:none}.${oP}::-webkit-scrollbar{display:none}`})}},cP=`data-has-overflow-x`,lP=`data-has-overflow-y`,uP=`data-overflow-x-start`,dP=`data-overflow-x-end`,fP=`data-overflow-y-start`,pP=`data-overflow-y-end`,mP=e=>t=>t?{[e]:``}:null,hP={hasOverflowX:mP(cP),hasOverflowY:mP(lP),overflowXStart:mP(uP),overflowXEnd:mP(dP),overflowYStart:mP(fP),overflowYEnd:mP(pP),cornerHidden:()=>null},gP=`--scroll-area-corner-height`,_P=`--scroll-area-corner-width`,vP=`data-orientation`,yP={x:0,y:0},bP={width:0,height:0},xP={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},SP={x:!0,y:!0,corner:!0},CP=q.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=wP(i),d=gE(),f=by(),p=by(),{nonce:m,disableStyleElements:h}=DO(),[g,_]=q.useState(!1),[v,y]=q.useState(!1),[b,x]=q.useState(!1),[S,C]=q.useState(!1),[w,T]=q.useState(!1),[E,D]=q.useState(bP),[O,k]=q.useState(bP),[A,j]=q.useState(xP),[M,N]=q.useState(SP),P=q.useRef(null),F=q.useRef(null),I=q.useRef(null),L=q.useRef(null),R=q.useRef(null),ee=q.useRef(null),z=q.useRef(null),te=q.useRef(null),B=q.useRef(0),ne=q.useRef(0),V=q.useRef(0),H=q.useRef(0),re=q.useRef(`vertical`),ie=q.useRef(yP),ae=q.useRef(null);function oe(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let se=Z(e=>{let t=e.x-ie.current.x,n=e.y-ie.current.y;ie.current=e,n!==0&&oe(!0),t!==0&&oe(!1)}),U=Z(()=>{let e=F.current;e&&ae.current===null&&(ae.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),ce=Z(e=>{if(e.button!==0||te.current!==null&&(re.current===`vertical`?R.current:ee.current)?.hasPointerCapture(te.current))return;te.current=e.pointerId,B.current=e.clientY,ne.current=e.clientX,re.current=e.currentTarget.getAttribute(vP);let t=F.current;t&&(V.current=t.scrollTop,H.current=t.scrollLeft,U()),(re.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),le=Z(e=>{if(e.pointerId!==te.current)return;te.current=null,(re.current===`vertical`?x:y)(!1),ae.current!==null&&(F.current&&(F.current.style.scrollSnapType=ae.current),ae.current=null);let t=re.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),ue=Z(e=>{if(e.pointerId!==te.current)return;if(e.buttons%2==0){le(e);return}let t=F.current;if(!t)return;let n=re.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=aP(i,`padding`,a),s=aP(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-B.current:e.clientX-ne.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?V.current:H.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),oe(n)});function de(e){C(e.pointerType===`touch`)}function fe(e){if(de(e),e.pointerType!==`touch`){let t=Hy(P.current,e.target);_(t)}}let pe=q.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),me={role:`presentation`,onPointerEnter:fe,onPointerMove:fe,onPointerDown:de,onPointerLeave(){_(!1)},style:{position:`relative`,[gP]:`${E.height}px`,[_P]:`${E.width}px`}},he=Qv(`div`,e,{state:pe,ref:[t,P],props:[me,o],stateAttributesMapping:hP}),ge=q.useMemo(()=>({handlePointerDown:ce,handlePointerMove:ue,handlePointerUp:le,handleScroll:se,disableViewportSnap:U,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:pe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[ce,ue,le,se,U,E,O,w,S,v,b,g,d,M,A,pe,s,c,l,u]);return(0,J.jsxs)(rP.Provider,{value:ge,children:[!h&&sP.getElement(m),he]})});function wP(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}function TP(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var EP=q.createContext(void 0);function DP(e,t){return Math.max(0,e-t)}function OP(e,t){if(t<=0)return 0;let n=TP(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var kP=`--scroll-area-overflow-x-start`,AP=`--scroll-area-overflow-x-end`,jP=`--scroll-area-overflow-y-start`,MP=`--scroll-area-overflow-y-end`,NP=`--scroll-area-thumb-height`,PP=`--scroll-area-thumb-width`,FP=[kP,AP,jP,MP],IP=!1;function LP(){IP||My||(typeof CSS<`u`&&`registerProperty`in CSS&&FP.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),IP=!0)}var RP=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=iP(),T=SE(),E=q.useRef(!0),D=q.useRef([NaN,NaN,NaN,NaN]),O=by(),k=by(),A=Z(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=zP(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=OP(T===`rtl`?-w:w,P),L=P-I);let R=A?0:OP(x,F),ee=A?0:F-R,z=j?0:b,te=A?0:y,B=0,ne=0;!j&&!A&&(B=t?.offsetWidth||0,ne=n?.offsetHeight||0);let V=f.width===0&&f.height===0,H=V?B:0,re=V?ne:0,ie=aP(n,`padding`,`x`),ae=aP(t,`padding`,`y`),oe=aP(i,`margin`,`x`),se=aP(r,`margin`,`y`),U=z-ie-oe,ce=te-ae-se,le=n?Math.min(n.offsetWidth-H,U):U,ue=t?Math.min(t.offsetHeight-re,ce):ce,de=Math.max(16,le*M),fe=Math.max(16,ue*N);if(m(e=>BP(e,{width:de,height:fe})),t&&r){let e=VP(r,NP,x,F,h,fe,t.offsetHeight-fe-ae-se);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-de-ie-oe,t=VP(i,PP,T===`rtl`?-w:w,P,_,de,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let pe=[I,L,R,ee];FP.forEach((t,n)=>{e.style.setProperty(t,`${pe[n]}px`)}),a&&p(e=>BP(e,{width:B,height:ne})),g(e=>BP(e,k));let me={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>BP(e,me))});Q(()=>{LP()},[]),Q(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),Q(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),Q(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=FC(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(Kv))).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:sP.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=Qv(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:hP}),P=q.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,J.jsx)(EP.Provider,{value:P,children:N})});function zP(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function BP(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function VP(e,t,n,r,i,a,o){let s=TP(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var HP=q.createContext(void 0);function UP(){let e=q.useContext(HP);if(e===void 0)throw Error(Ov(54));return e}var WP=q.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=iP(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=SE(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;q.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return tx(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Wy(e.nativeEvent),n=T?h.current:g.current;if(n&&Hy(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=aP(n,`margin`,a),s=aP(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${gP})`,insetInlineEnd:0,[NP]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${_P})`,bottom:0,[PP]:`${S.width}px`}}},M=Qv(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:hP});return A?(0,J.jsx)(HP.Provider,{value:i,children:M}):null}),GP=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=iP(),m=UP(),h=m===`vertical`;return Qv(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),KP=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=iP(),l=Qv(`div`,e,{ref:[t,o],props:[{"aria-hidden":!0,style:{position:`absolute`,bottom:0,insetInlineEnd:0,width:s.width,height:s.height}},a]});return c.corner?null:l});function qP({className:e,children:t,...n}){return(0,J.jsxs)(CP,{"data-slot":`scroll-area`,className:X(`relative`,e),...n,children:[(0,J.jsx)(RP,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] -outline-offset-2`,children:t}),(0,J.jsx)(JP,{}),(0,J.jsx)(KP,{})]})}function JP({className:e,orientation:t=`vertical`,...n}){return(0,J.jsx)(WP,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:X(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,J.jsx)(GP,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}var YP=(e,t)=>{let n=e.split(`/`),r=t.split(`/`);for(let e=0;e<Math.min(n.length,r.length);e++){let t=n[e]??``,i=r[e]??``;if(t===i)continue;let a=e<n.length-1;if(a!==e<r.length-1)return a?-1:1;let o=t.toLowerCase().localeCompare(i.toLowerCase(),`en`);return o===0?t<i?-1:1:o}return n.length-r.length},XP=e=>e.slice(0,Math.max(e.lastIndexOf(`/`),0)),ZP=e=>e.slice(e.lastIndexOf(`/`)+1),QP=e=>{let t={directories:new Map,files:[]};for(let n of e){let e=t;for(let t of n.split(`/`).slice(0,-1)){let n=e.directories.get(t)??{directories:new Map,files:[]};e.directories.set(t,n),e=n}e.files.push(n)}let n=(e,t)=>{let r=[...e.directories].map(([e,r])=>{let i=e,a=r,o=t===``?e:`${t}/${e}`;for(let[e]=a.directories;a.files.length===0&&a.directories.size===1&&e!==void 0;[e]=a.directories)i=`${i}/${e[0]}`,o=`${o}/${e[0]}`,a=e[1];let[s]=a.files;return s!==void 0&&a.files.length===1&&a.directories.size===0?{kind:`file`,path:s,name:ZP(s),directory:`${i}/`}:{kind:`directory`,path:o,label:`${i}/`,children:n(a,o)}}),i=e.files.map(e=>({kind:`file`,path:e,name:ZP(e)})),a=e=>e.kind===`file`?e.path:`${e.path}/x`;return[...r.sort((e,t)=>YP(a(e),a(t))),...i.sort((e,t)=>YP(e.path,t.path))]};return n(t,``)},$P=e=>{let[t]=e;return e.length===1&&t?.kind===`directory`?{root:t.label,entries:t.children}:{root:null,entries:e}},eF=e=>e.flatMap(e=>e.kind===`file`?[e.path]:eF(e.children)),tF=(e,t)=>{let n=t.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{let t=e.path.toLowerCase();return n.every(e=>t.includes(e))})},nF=(e,t)=>[...e].sort((e,n)=>t===`size`&&n.additions+n.deletions-(e.additions+e.deletions)||YP(e.path,n.path)),rF=12,iF=24,aF=({label:e})=>{let t=e.slice(0,-1).lastIndexOf(`/`)+1;return t===0?(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}):(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`min-w-[1.5em] shrink-[999] truncate`,children:e.slice(0,t)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.slice(t)})]})},oF=({files:e,activePath:t,onSelect:n,mode:r=`tree`,order:i=`path`,navigate:a=!1,className:o})=>{let s=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=s.current?.querySelector(`[data-slot=scroll-area-viewport]`),t=s.current?.querySelector(`[aria-current]`);if(e==null||t==null)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,r=Number(t.dataset.depth??0)*iF;(n<e.scrollTop+r||n>e.scrollTop+e.clientHeight-40)&&(e.scrollTop=Math.max(0,n-e.clientHeight/3))},[t]);let[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(new Set),[f,p]=(0,q.useState)(t);if(f!==t){p(t);let e=[...u].filter(e=>t?.startsWith(`${e}/`));e.length>0&&d(new Set([...u].filter(t=>!e.includes(t))))}let m=(0,q.useRef)(null);_k({filterTree:()=>m.current?.focus()});let h=(0,q.useMemo)(()=>tF(e,c),[e,c]),g=(0,q.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]),{root:_,entries:v}=(0,q.useMemo)(()=>$P(QP(h.map(e=>e.path))),[h]),y=(0,q.useMemo)(()=>r===`tree`?eF(v):nF(h,i).map(e=>e.path),[r,v,h,i]),b=(0,q.useMemo)(()=>{let e=y.filter(e=>g.get(e)?.points!==void 0);return new Map(e.map((e,t)=>[e,t]))},[y,g]),x=e=>{let r=t===null?-1:y.indexOf(t),i=y[Math.min(y.length-1,Math.max(0,r+e))];i!==void 0&&n(i)};_k({nextFile:()=>x(1),previousFile:()=>x(-1)},a);let S=e=>{let t=new Set(u);t.has(e)?t.delete(e):t.add(e),d(t)},C=(e,r,i,a)=>(0,J.jsx)(`li`,{children:(0,J.jsx)(dF,{entry:e,label:r,depth:i,...a===void 0?{}:{directory:a},active:e.path===t,onSelect:n,...b.has(e.path)?{landing:{at:b.get(e.path)??0,of:b.size}}:{}})},e.path),w=(e,t)=>e.map(e=>{if(e.kind===`file`){let n=g.get(e.path);return n===void 0?null:C(n,e.name,t,e.directory)}let n=c.trim()!==``||!u.has(e.path),r=n?gg:vg,i=t*rF+4;return(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(`button`,{type:`button`,title:`${e.path}/`,"aria-expanded":n,onClick:()=>S(e.path),className:`sticky flex h-6 w-full items-center gap-1.5 rounded-md bg-background pr-2 text-left font-medium hover:bg-accent`,style:{paddingLeft:`${i}px`,top:`${t*iF}px`,zIndex:Math.max(1,30-t)},children:[(0,J.jsx)(Bh,{"aria-hidden":`true`,className:X(`size-3 shrink-0 text-muted-foreground transition-transform duration-(--duration-fast) ease-standard`,!n&&`-rotate-90`)}),(0,J.jsx)(r,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(aF,{label:e.label})]}),n&&(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-y-0 w-px bg-border`,style:{left:`${i+6}px`}}),(0,J.jsx)(`ul`,{children:w(e.children,t+1)})]})]},e.path)});return(0,J.jsxs)(`nav`,{ref:s,"aria-label":`Changed files`,className:X(`flex min-h-0 flex-col gap-2`,o),children:[(0,J.jsxs)(`div`,{className:`relative px-1`,children:[(0,J.jsx)(nP,{ref:m,type:`search`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c!==``&&(e.preventDefault(),l(``))},placeholder:`Filter files`,"aria-label":`Filter files`,className:`h-7 pr-8`}),(0,J.jsx)(bk,{id:`filterTree`,className:`absolute top-1/2 right-3 -translate-y-1/2`})]}),(0,J.jsxs)(`p`,{className:`flex gap-1 px-2 text-caption text-muted-foreground`,"aria-live":`polite`,..._===null||r!==`tree`?{}:{title:_},children:[(0,J.jsxs)(`span`,{className:`shrink-0`,children:[c.trim()===``?`${e.length} files`:`${h.length} of ${e.length} files`,_!==null&&r===`tree`&&` in`]}),` `,_!==null&&r===`tree`&&(0,J.jsx)(`span`,{className:`flex min-w-0 flex-1 font-mono text-code-compact`,children:(0,J.jsx)(aF,{label:_})})]}),h.length===0?(0,J.jsx)(VN,{inline:!0,tone:`muted`,glyph:`∅`,title:`No files match`,body:`Nothing in this PR has “${c.trim()}” in its path.`,actions:[{label:`Clear filter`,onClick:()=>l(``)}]}):(0,J.jsx)(qP,{className:`min-h-0 flex-1`,children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-px px-1 pb-2`,children:r===`tree`?w(v,0):nF(h,i).map(e=>C(e,e.path,0))})})]})},sF=({count:e})=>(0,J.jsxs)(`span`,{"data-slot":`thread-count`,className:`tabular inline-flex items-center gap-0.5 text-caption`,children:[(0,J.jsx)(Kg,{"aria-hidden":`true`,className:`size-3`}),e,(0,J.jsxs)(`span`,{className:`sr-only`,children:[` open `,e===1?`thread`:`threads`]})]}),cF=[`finding`,`risk`,`decision`],lF={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},uF=({points:e,landing:t})=>(0,J.jsx)(`span`,{"data-land":`drop`,style:vh({"--landing-i":t?.at??0,"--landing-n":t?.of??1}),className:`inline-flex items-center gap-1.5`,children:cF.map(t=>{let n=e[t]??0;if(n===0)return null;let{label:r}=oD[t],i=sD[t];return(0,J.jsxs)(`span`,{"data-slot":`point-count`,"data-kind":t,className:X(`tabular inline-flex items-center gap-0.5 text-caption font-medium`,lF[t]),children:[(0,J.jsx)(i,{"aria-hidden":`true`,className:`size-3`}),n,(0,J.jsxs)(`span`,{className:`sr-only`,children:[` `,r.toLowerCase(),n===1?``:`s`]})]},t)})}),dF=({entry:e,label:t,depth:n=0,active:r=!1,directory:i,landing:a,onSelect:o})=>{let s=e.status===void 0?null:lD[e.status],c=s?.kind===`mark`?s:null;return(0,J.jsxs)(`button`,{type:`button`,"aria-current":r?`location`:void 0,"data-depth":n,title:e.path,onClick:()=>o(e.path),className:X(`flex min-h-6 w-full flex-wrap items-center gap-x-1.5 rounded-md pr-2 text-left hover:bg-surface-row`,r&&`bg-surface-row font-medium shadow-[inset_3px_0_0_var(--primary)]`),style:{paddingLeft:`${n*rF+4}px`},children:[(0,J.jsxs)(`span`,{className:X(`flex items-center gap-1.5`,i===void 0?`min-w-[min(7rem,100%)] flex-1 basis-0`:`max-w-full flex-[1_0_auto]`),children:[(0,J.jsx)(KD,{path:e.path,status:e.status}),(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1`,children:[i!==void 0&&(0,J.jsx)(`span`,{className:`min-w-[1.5em] shrink-[999] truncate text-muted-foreground [direction:rtl]`,children:(0,J.jsx)(`bdi`,{dir:`ltr`,children:i})}),(0,J.jsxs)(`span`,{className:`relative min-w-0 truncate`,children:[(0,J.jsx)(`span`,{"data-slot":`file-name`,className:c?.name,children:t===e.path?t:ZP(e.path)}),c!==null&&(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, `,c.label]})]})]})]}),(0,J.jsxs)(`span`,{"data-slot":`file-row-counts`,className:`ml-auto flex flex-wrap items-center justify-end gap-x-1.5 whitespace-nowrap`,children:[e.status!==void 0&&(0,J.jsx)(YD,{status:e.status}),e.points!==void 0&&(0,J.jsx)(uF,{points:e.points,...a===void 0?{}:{landing:a}}),e.threads!==void 0&&e.threads>0&&(0,J.jsx)(sF,{count:e.threads}),e.additions!==void 0&&e.deletions!==void 0&&(0,J.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,e.additions]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,e.deletions]})]})]})]})},fF=60,pF=3600,mF=24*pF,hF=(e,t)=>{let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<fF)return`just now`;if(n<pF)return`${Math.floor(n/fF)} min ago`;if(n<mF)return`${Math.floor(n/pF)} h ago`;let r=Math.floor(n/mF);if(r===1)return`yesterday`;if(r<7)return`${r} days ago`;let i=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`;return r<30?i(Math.floor(r/7),`week`):r<365?i(Math.floor(r/30),`month`):i(Math.floor(r/365),`year`)},gF=e=>new Date(e).toLocaleString(`en`,{dateStyle:`full`,timeStyle:`short`}),_F={github:`GitHub`,bitbucket:`Bitbucket`},vF=({repo:e,number:t})=>`${e.owner}/${e.repo} #${t}`,yF=[`bg-avatar-1-bg text-avatar-1-fg`,`bg-avatar-2-bg text-avatar-2-fg`,`bg-avatar-3-bg text-avatar-3-fg`,`bg-avatar-4-bg text-avatar-4-fg`,`bg-avatar-5-bg text-avatar-5-fg`,`bg-avatar-6-bg text-avatar-6-fg`,`bg-avatar-7-bg text-avatar-7-fg`,`bg-avatar-8-bg text-avatar-8-fg`],bF=e=>{let t=0;for(let n of e)t=t*31+(n.codePointAt(0)??0)>>>0;return yF[t%yF.length]??yF[0]},xF=`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,SF=(e,t)=>{let n=e.role===`author`?`you`:e.author.name;return`${e.title}. ${vF(e.ref)} by ${n}, updated ${hF(e.updatedAt,t)}, ${_F[e.ref.repo.host]}`},CF=({item:e,nowMs:t,starting:n,tabbable:r,onOpen:i,onFocus:a})=>{let o=_F[e.ref.repo.host],s=e.role===`author`?`you`:e.author.name;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`a`,{href:E_(e.ref),"data-pr-row":``,tabIndex:r?0:-1,"aria-label":SF(e,t),"aria-busy":n,onClick:e=>{M_(e)&&(e.preventDefault(),n||i())},onFocus:a,className:`group flex min-h-[58px] w-full flex-col items-stretch gap-x-3 gap-y-1 px-4 py-2 text-left text-foreground hover:bg-accent hover:no-underline focus-visible:bg-accent focus-visible:-outline-offset-2 aria-busy:bg-diff-hunk-bg max-sm:items-start sm:flex-row sm:items-center`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1 self-stretch`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-x-1.5 text-caption text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 gap-[1ch] font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.ref.repo.owner,`/`,e.ref.repo.repo]}),(0,J.jsxs)(`span`,{className:`shrink-0`,children:[`#`,e.ref.number]})]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-medium`,bF(e.author.id)),children:wk(e.author.name)}),(0,J.jsx)(`span`,{className:`max-w-32 shrink-0 truncate`,children:s}),(0,J.jsx)(`time`,{dateTime:e.updatedAt,title:gF(e.updatedAt),className:`shrink-0 whitespace-nowrap`,children:hF(e.updatedAt,t)}),(0,J.jsx)(eO,{variant:`outline`,className:`ml-auto shrink-0 text-muted-foreground @min-[480px]:hidden`,children:o})]})]}),n?(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-caption`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-4 text-diff-hunk-fg`,xF)}),(0,J.jsx)(`span`,{className:`font-medium text-diff-hunk-fg`,children:`Opening review…`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Esc to cancel`})]}):(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 @max-[479px]:hidden`,children:[(0,J.jsx)(eO,{variant:`outline`,className:`text-muted-foreground @max-[479px]:hidden`,children:o}),(0,J.jsx)(bk,{id:`openRow`,className:`hidden group-focus-visible:inline-flex`}),(0,J.jsx)(Wh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 max-sm:hidden`})]})]})})},wF={ArrowDown:(e,t)=>Math.min(t,e+1),ArrowUp:e=>Math.max(0,e-1),Home:()=>0,End:(e,t)=>t},TF=({title:e,word:t,items:n,count:r,loading:i,skeletonRows:a,notes:o,blocked:s,empty:c,nowMs:l,startingUrl:u,onOpen:d})=>{let f=(0,q.useId)(),p=(0,q.useRef)(null),[m,h]=(0,q.useState)(0),g=n??[],_=Math.min(m,Math.max(0,g.length-1)),v=e=>{let t=wF[e.key],n=[...p.current?.querySelectorAll(`[data-pr-row]`)??[]],r=e.target instanceof HTMLElement?n.indexOf(e.target):-1;if(t===void 0||r===-1)return;e.preventDefault();let i=t(r,n.length-1);h(i),n[i]?.focus()},y=c.icon;return(0,J.jsxs)(`section`,{"aria-labelledby":f,className:`@container flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2`,children:[(0,J.jsx)(`h2`,{id:f,className:`text-heading font-semibold`,children:e}),r!==null&&(0,J.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,J.jsx)(`span`,{className:`sr-only`,children:r===`…`?`Loading`:`${r} pull request${r===1?``:`s`}`})]}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),(0,J.jsx)(`div`,{className:`flex flex-col gap-2 p-3 empty:hidden`,children:o}),s??(n===null?(0,J.jsxs)(`div`,{"aria-busy":`true`,className:`flex flex-col`,children:[(0,J.jsxs)(`p`,{className:`flex items-center gap-2 px-4 pt-3 text-caption text-muted-foreground`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-4`,`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`)}),i]}),(0,J.jsx)(`ul`,{"aria-hidden":`true`,className:`flex flex-col gap-3 px-4 py-3`,children:Array.from({length:a},(e,t)=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(zN,{className:`h-4 w-3/4 motion-reduce:animate-none`}),(0,J.jsx)(zN,{className:`h-3 w-1/2 motion-reduce:animate-none`})]},t))})]}):g.length===0?(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-1 px-6 py-8 text-center`,children:[(0,J.jsx)(y,{"aria-hidden":`true`,className:`mb-1 size-6 text-muted-foreground`}),(0,J.jsx)(`p`,{className:`font-medium`,children:c.title}),(0,J.jsx)(`p`,{className:`max-w-sm text-caption text-muted-foreground`,children:c.text})]}):(0,J.jsx)(`ul`,{ref:p,className:`divide-y`,onKeyDown:v,children:g.map((e,t)=>(0,J.jsx)(CF,{item:e,nowMs:l,starting:u===e.url,tabbable:t===_,onOpen:()=>d(e),onFocus:()=>h(t)},e.url))}))]})},EF=Tc.options,DF=`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-caption`,OF=`h-6 min-w-6 px-1 text-caption`,kF=e=>e.map(e=>_F[e]).join(` and `),AF=(e,t)=>{let n=e===null?[]:EF.filter(t=>e.hosts[t].configured),r=n.filter(t=>e?.hosts[t].error!=null),i=(t?.errors??[]).filter(e=>!r.includes(e.host));return{configured:n,failing:r,listFailed:i,shown:n.filter(e=>!r.includes(e)&&!i.some(t=>t.host===e))}},jF=(e,t)=>(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-8 text-center text-caption text-muted-foreground`,children:[(0,J.jsx)(`p`,{children:e}),t]}),MF=({status:e,list:t,error:n,rowFailure:r,startingUrl:i,nowMs:a,onOpen:o,onRetry:s,onOpenConnections:c,onFix:l})=>{let u=AF(e,t),d=e!==null&&u.configured.length===0,f=t!==null&&u.configured.length>0&&u.shown.length===0,p=u.configured.length>1&&u.shown.length===1&&u.shown[0]!==void 0?`${_F[u.shown[0]]} only`:null,m=e=>n===null?null:(0,J.jsxs)(`p`,{className:X(LN,DF),role:`alert`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Couldn't list pull requests.`}),(0,J.jsx)(`span`,{children:Ap(n)}),e&&(0,J.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:s,children:`Retry`})]}),h=e=>r?.role===e?(0,J.jsxs)(`p`,{className:X(LN,DF),role:`alert`,children:[(0,J.jsx)(`span`,{children:r.message}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:r.onRetry,children:`Try again`})]}):null,g=u.failing.map(e=>(0,J.jsxs)(`p`,{className:X(RN,DF),role:`status`,children:[(0,J.jsxs)(`span`,{children:[_F[e],` pull requests are hidden until `,_F[e],` works again.`]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:l,children:`Fix…`})]},e)),_=u.listFailed.map(e=>(0,J.jsxs)(`p`,{className:X(LN,DF),role:`alert`,children:[(0,J.jsxs)(`span`,{className:`font-medium`,children:[`Couldn't load `,_F[e.host],` pull requests.`]}),(0,J.jsx)(`span`,{children:e.message}),u.shown.length>0&&(0,J.jsxs)(`span`,{children:[kF(u.shown),` pull requests are shown.`]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:s,children:`Retry`})]},e.host)),v=u.configured.length===0?`Loading`:`Loading from ${kF(u.configured)}`,y=t?.items.filter(e=>e.role===`reviewer`)??null,b=t?.items.filter(e=>e.role===`author`)??null,x=e=>e===null?n===null?`…`:null:f?null:e.length;return(0,J.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.55fr_1fr]`,children:[(0,J.jsx)(TF,{title:`To review`,word:p??`Waiting for your review`,items:y,count:x(y),loading:v,skeletonRows:5,notes:(0,J.jsxs)(J.Fragment,{children:[t!==null&&m(!0),g,_,h(`reviewer`)]}),blocked:d?jF(`Connect GitHub or Bitbucket to list pull requests.`,(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Open Connections`})):t===null&&n!==null?m(!0):!f&&void 0,empty:{icon:Mg,title:`Nothing is waiting for you`,text:`When someone asks for your review on GitHub or Bitbucket, it appears here. To review something else, paste its link above.`},nowMs:a,startingUrl:i,onOpen:o}),(0,J.jsx)(TF,{title:`Your pull requests`,word:p??`Open`,items:b,count:x(b),loading:`Loading`,skeletonRows:3,notes:(0,J.jsxs)(J.Fragment,{children:[t!==null&&m(!1),h(`author`)]}),blocked:d?jF(`Connect GitHub or Bitbucket to list pull requests.`):t===null&&n!==null?m(!1):f?jF(`Couldn't load pull requests.`):void 0,empty:{icon:Og,title:`No open pull requests`,text:`Pull requests you open on GitHub or Bitbucket appear here.`},nowMs:a,startingUrl:i,onOpen:o})]})},NF=(0,q.createContext)(null),PF=()=>{let e=(0,q.useContext)(NF);if(e===null)throw Error(`useConnections needs a ConnectionsProvider`);return e},FF=({children:e,now:t=Date.now})=>{let{status:n,error:r,loading:i,refresh:a}=Sp(),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(0),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);(0,q.useEffect)(()=>{!i&&n!==null&&s(t())},[i,n,t]);let g=(0,q.useCallback)(()=>{a(),d(e=>e+1)},[a]),_=(0,q.useCallback)((e,t)=>{h(e&&t?.focusCheckAgain===!0),p(e)},[]),v=(0,q.useMemo)(()=>({status:n,error:r,checking:i,checkedAtMs:o,listed:c,reportListed:l,checkAgain:g,checks:u,open:f,setOpen:_,focusCheckAgain:m}),[n,r,i,o,c,g,u,f,_,m]);return(0,J.jsx)(NF.Provider,{value:v,children:e})},IF=({pullRequest:e,error:t})=>{let{setOpen:n}=PF(),r=`Couldn't open ${vF(e)}: `;return t.code===`host-not-configured`?(0,J.jsxs)(J.Fragment,{children:[r,_F[e.repo.host],` isn't configured.`,` `,(0,J.jsx)($,{variant:`link`,className:OF,onClick:()=>n(!0),children:`Open Connections`})]}):(0,J.jsx)(J.Fragment,{children:`${r}${Ap(t)}`})},LF=({pullRequest:e})=>{let{client:t}=yp(),[n,r]=(0,q.useState)(0),[i,a]=(0,q.useState)(null),o=vF(e),s=(0,q.useRef)(0);return(0,q.useEffect)(()=>(s.current=n,t.startAnalysis({url:hf(e)}).then(e=>{s.current===n&&(e.ok?j_(D_(e.value.analysisId)):a(e.error))}),()=>{s.current=-1}),[t,e,n]),(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:o}),(0,J.jsx)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-body`,children:i===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-4`,xF)}),`Fetching `,o,` from `,_F[e.repo.host],`…`]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:()=>{s.current=-1,j_(`/`)},children:`Cancel`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-4 align-[-3px]`}),(0,J.jsx)(IF,{pullRequest:e,error:i})]}),(0,J.jsx)($,{variant:`link`,className:OF,onClick:()=>{a(null),r(e=>e+1)},children:`Try again`})]})}),i!==null&&(0,J.jsx)(`p`,{className:`text-body`,children:(0,J.jsx)(N_,{to:`/`,children:`Go to your pull requests`})})]})},RF=q.createContext(void 0);function zF(e){let t=q.useContext(RF);if(t===void 0&&!e)throw Error(Ov(72));return t}var BF={...Cw,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},VF=class extends mw{constructor(e,t,n){let r=new tw;super(UF(e,r,t,n),WF(r),BF)}setOpen=(e,t)=>{YC(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Ab(Nb,e))}};function HF(){let e=new tw,t=new rE(Object.freeze(UF(void 0,e)),Object.freeze(WF(e)),BF);return Object.assign(t,{setOpen:Kv,cancelPendingOpen:Kv})}function UF(e,t,n,r=!1){return{..._w(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function WF(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var GF=my(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=UC((e,t)=>new VF({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),ZC(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=QC(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=q.useRef(null);Q(()=>{m&&t&&p.setOpen(!1,Ab(Kb))},[m,t,p]),Q(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),Q(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),q.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,Ab(Yb))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,J.jsxs)(RF.Provider,{value:p,children:[l&&(0,J.jsx)(WC,{handle:l,store:p}),T&&(0,J.jsx)(KF,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function KF({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=bC(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=_C(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=q.useMemo(()=>mv(a.reference,i.reference),[a.reference,i.reference]);return $C(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??Jv}),null}var qF=q.createContext(void 0);function JF(){return q.useContext(qF)}var YF=`data-base-ui-tooltip-trigger`;function XF(e){let t=Wy(e);return z_(t)?t:null}var ZF=hy(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=zF(!0),m=ww(a)??p;if(!m)throw Error(Ov(82));let h=gE(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=q.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=XC(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=JF(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=ex(v,{open:_}),O=Mw(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=rx(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=q.useRef(!1),F=by(),I=q.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=Uy(e,`[${YF}]`);return n!==null&&n!==t&&Hy(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let z=Fw(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?Zw():null,restMs:L,delay(){return u==null&&D?{close:Eb(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),te=Dw(v,{enabled:!A}).reference,B=e=>{let t=P.current,n=XF(e),r=ee(n),i=y.current,a=i&&n&&Hy(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,Ab(Pb,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&zy(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,Ab(Pb,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},ne=m.useState(`appliedTriggerProps`,S||M!==`none`);return Qv(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,te,ne,{onMouseOver(e){B(e.nativeEvent)},onFocus(e){R(XF(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[gb]:A?``:void 0,[YF]:A?void 0:``},f],stateAttributesMapping:fb})}),QF=q.createContext(void 0);function $F(){let e=q.useContext(QF);if(e===void 0)throw Error(Ov(70));return e}var eI=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return zF().useState(`mounted`)||n?(0,J.jsx)(QF.Provider,{value:n,children:(0,J.jsx)(mE,{ref:t,...r})}):null}),tI=q.createContext(void 0);function nI(){let e=q.useContext(tI);if(e===void 0)throw Error(Ov(71));return e}var rI=q.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=VS,style:g,..._}=e,v=zF(),y=$F(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=IE({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=BE(e,q.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,J.jsx)(tI.Provider,{value:D,children:O})}),iI=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=zF(),{side:s,align:c}=nI(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);zC({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Nw(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Qv(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[VC,f,zE(d),a],stateAttributesMapping:hb})}),aI=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=zF(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=nI();return Qv(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:mb})}),oI=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=q.useMemo(()=>({open:t,close:n}),[t,n]);return(0,J.jsx)(qF.Provider,{value:t,children:(0,J.jsx)($b,{delay:i,timeoutMs:r,children:e.children})})},sI=class extends MC{constructor(){super(HF(),`Tooltip`)}open(e){this.openByTrigger(e)}close(){this.closePopup()}get isOpen(){return this.attachedStore?.select(`open`)??!1}};function cI(){return new sI}function lI({delay:e=0,...t}){return(0,J.jsx)(oI,{"data-slot":`tooltip-provider`,delay:e,...t})}function uI({...e}){return(0,J.jsx)(GF,{"data-slot":`tooltip`,...e})}function dI({...e}){return(0,J.jsx)(ZF,{"data-slot":`tooltip-trigger`,...e})}function fI({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,collisionBoundary:a,children:o,shortcut:s,...c}){return(0,J.jsx)(eI,{children:(0,J.jsx)(rI,{collisionBoundary:a,align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,J.jsxs)(iI,{"data-slot":`tooltip-content`,className:X(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-caption text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...c,children:[o,s!==void 0&&(0,J.jsx)(vk,{children:s}),(0,J.jsx)(aI,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var pI=e=>{if(e===null)return 26;let t=e>=900?e-260-32:e,n=Math.floor((t-32)/24);return Math.min(26,Math.max(8,n))},mI=e=>String(e).padStart(2,`0`),hI=e=>{let t=new Date(e);return`${t.getFullYear()}-${mI(t.getMonth()+1)}-${mI(t.getDate())}`},gI=e=>new Date(`${e}T00:00:00Z`),_I=e=>gI(e).toLocaleDateString(`en`,{month:`short`,day:`numeric`,timeZone:`UTC`}),vI=e=>gI(e).toLocaleDateString(`en`,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}),yI=e=>gI(e).toLocaleDateString(`en`,{month:`short`,timeZone:`UTC`}),bI=e=>Number(e.slice(8,10)),xI=e=>{let t=Math.ceil(e.length/7);return Array.from({length:t},(t,n)=>{let r=e.slice(n*7,n*7+7),i=r.find(e=>bI(e.date)===1);if(i!==void 0)return yI(i.date);let a=r[0];return n===0&&a!==void 0&&bI(a.date)<=7?yI(a.date):null})},SI=e=>e===1?`1 PR`:`${e} PRs`,CI=e=>e===1?`1 comment`:`${e} comments`,wI=e=>`${e.pullRequests===0?`No PRs`:SI(e.pullRequests)} reviewed · ${CI(e.comments)}`,TI=(e,t)=>`${_I(e.date)}: ${e.pullRequests===0?`No PRs`:SI(e.pullRequests)} reviewed, ${CI(e.comments)}${e.date===t?` (today)`:``}`,EI=e=>`Busiest day: ${_I(e.date)}, ${SI(e.pullRequests)} and ${CI(e.comments)}.`,DI=(e,t,n)=>{let r={ArrowLeft:t-7,ArrowRight:t+7,ArrowUp:t-1,ArrowDown:t+1,Home:0,End:n}[e];return r===void 0||r<0||r>n?null:r},OI=e=>Ic(e),kI={0:`border-input bg-card`,1:`border-primary bg-activity-1`,2:`border-primary bg-activity-2`,3:`border-primary bg-activity-3`,4:`border-primary bg-primary`},AI=[{level:0,label:`0`},{level:1,label:`1`},{level:2,label:`2`},{level:3,label:`3–4`},{level:4,label:`5+`}],jI=[``,`Mon`,``,`Wed`,``,`Fri`,``],MI=({level:e,className:t})=>(0,J.jsx)(`span`,{className:X(`flex items-center justify-center rounded-[4px] border`,kI[e],t),children:e===4&&(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),NI=e=>{let[t,n]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{let t=e.current;if(t===null)return;let r=t.getBoundingClientRect().width;if(r>0&&n(r),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(([e])=>{e!==void 0&&n(e.contentRect.width)});return i.observe(t),()=>i.disconnect()},[e]),t},PI=cI(),FI=({days:e,today:t,weeks:n})=>{let[r,i]=(0,q.useState)(t),a=(0,q.useRef)(new Map),o=(0,q.useRef)(null),s=e.some(e=>e.date===r)?r:e[0]?.date??t,c=xI(e),l=Math.ceil(e.length/7);return(0,J.jsxs)(`div`,{ref:o,className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`grid pl-8 text-caption text-muted-foreground`,style:{gridTemplateColumns:`repeat(${l}, 24px)`},children:c.map((e,t)=>(0,J.jsx)(`span`,{className:`h-4 overflow-visible whitespace-nowrap`,children:e},t))}),(0,J.jsx)(`div`,{role:`grid`,"aria-label":`Review activity for the last ${n} weeks, one square per day. Use arrow keys to move between days.`,className:`flex flex-col`,onKeyDown:t=>{let n=e.findIndex(e=>e.date===s),r=DI(t.key,n,e.length-1);if(r===null)return;t.preventDefault();let o=e[r];o!==void 0&&(i(o.date),a.current.get(o.date)?.focus())},children:jI.map((n,r)=>(0,J.jsxs)(`div`,{role:`row`,className:`flex items-center`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`w-8 shrink-0 text-caption text-muted-foreground`,children:n}),Array.from({length:l},(n,o)=>{let c=e[o*7+r];if(c===void 0||OI(c.date)!==r)return(0,J.jsx)(`span`,{className:`size-6 shrink-0`},o);let l=Bc(c.pullRequests);return(0,J.jsx)(dI,{handle:PI,payload:c,delay:150,render:(0,J.jsx)(`div`,{ref:e=>{e===null?a.current.delete(c.date):a.current.set(c.date,e)},role:`gridcell`,tabIndex:c.date===s?0:-1,"aria-label":TI(c,t),onFocus:()=>i(c.date),className:`group flex size-6 shrink-0 items-center justify-center rounded-md`}),children:(0,J.jsx)(MI,{level:l,className:X(`size-5 group-hover:ring-2 group-hover:ring-foreground`,c.date===t&&`outline-2 outline-offset-1 outline-foreground`)})},c.date)})]},r))}),(0,J.jsx)(GF,{handle:PI,children:({payload:e})=>e===void 0?null:(0,J.jsx)(fI,{collisionBoundary:o.current??void 0,children:(0,J.jsxs)(`span`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`font-semibold`,children:vI(e.date)}),(0,J.jsx)(`span`,{children:wI(e)})]})})}),(0,J.jsxs)(`div`,{"aria-hidden":`true`,className:`flex items-start gap-2 pl-8 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`leading-4`,children:`PRs a day`}),AI.map(({level:e,label:t})=>(0,J.jsxs)(`span`,{className:`flex w-6 flex-col items-center gap-0.5`,children:[(0,J.jsx)(MI,{level:e,className:`size-4`}),(0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:t})]},e))]})]})},II=({value:e,label:t})=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-title font-semibold tabular-nums`,children:e}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),LI=({activity:e,error:t,onRetry:n,now:r})=>{let i=(0,q.useId)(),a=(0,q.useRef)(null),o=NI(a),s=pI(o),c=o===null||o>=900,l=hI(r()),u=(0,q.useMemo)(()=>e===null?null:zc(e,{today:l,weeks:s,dayOf:hI}),[e,l,s]),d=(0,q.useMemo)(()=>e===null?null:zc(e,{today:l,weeks:26,dayOf:hI}),[e,l]),f=u===null?null:Vc(u),p=d?.every(e=>e.pullRequests===0&&e.comments===0)===!0;return(0,J.jsxs)(`section`,{"aria-labelledby":i,className:`flex flex-col rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2.5`,children:[(0,J.jsx)(`h2`,{id:i,className:`text-heading font-semibold`,children:`Review activity`}),(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`Last `,s,` weeks`]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground max-sm:basis-full sm:ml-auto`,children:[(0,J.jsx)(Ig,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Reviews and comments posted from megareviewer on this machine`]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden px-4 py-4`,children:(0,J.jsx)(`div`,{ref:a,children:u===null||f===null?t===null?(0,J.jsx)(zN,{"aria-label":`Loading review activity`,className:`h-[244px] w-full motion-reduce:animate-none`}):(0,J.jsxs)(`p`,{className:X(LN,`flex flex-wrap items-baseline gap-x-2 text-caption`),children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Couldn't read your review activity.`}),(0,J.jsx)(`span`,{children:Ap(t)}),(0,J.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:n,children:`Try again`})]}):(0,J.jsxs)(`div`,{className:X(`flex gap-8`,c?`flex-row`:`flex-col`),children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,J.jsx)(FI,{days:u,today:l,weeks:s}),p&&(0,J.jsxs)(`p`,{className:`rounded-md bg-muted px-3 py-2 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:`No reviews yet.`}),` Open a pull request above and post your review. Each day you review fills a square here.`]})]}),(0,J.jsxs)(`div`,{className:X(`flex flex-col gap-3`,c&&`w-[260px] shrink-0`),children:[(0,J.jsxs)(`div`,{className:X(`grid gap-x-6 gap-y-3`,c||o!==null&&o<520?`grid-cols-2`:`grid-cols-4`),children:[(0,J.jsx)(II,{value:f.pullRequests,label:`PRs reviewed`}),(0,J.jsx)(II,{value:f.comments,label:`comments posted`}),(0,J.jsx)(II,{value:f.daysWithReviews,label:`days with reviews`}),(0,J.jsx)(II,{value:f.thisWeek,label:`PRs this week`})]}),f.busiest!==null&&(0,J.jsx)(`p`,{className:`border-t pt-3 text-caption text-muted-foreground`,children:EI(f.busiest)})]})]})})})]})},RI=`Paste a pull request link first.`,zI=`That isn't a pull request link. Use github.com/owner/repo/pull/123 or bitbucket.org/workspace/repo/pull-requests/45.`,BI=`h-6 min-w-6 px-1 text-caption`,VI=nk(`openInNewTab`).chords[0]??{key:`Enter`,mod:!0},HI=({inputRef:e,start:t,onSubmit:n,onSubmitInNewTab:r,onEdit:i,initial:a})=>{let[o,s]=(0,q.useState)(a?.url??``),[c,l]=(0,q.useState)(a?.invalid??null),u=(0,q.useId)(),d=t?.state===`starting`,f=()=>{let e=o.trim();if(e===``)return l(RI),null;let t=mf(e);return t.ok||l(zI),t.ok?t.value:null},p=e=>{if(e.preventDefault(),d)return;let t=f();t!==null&&n(o.trim(),t)},m=e=>{e.preventDefault();let t=f();t!==null&&r(t)},h=dk();return(0,J.jsx)(`search`,{children:(0,J.jsxs)(`form`,{"aria-label":`Open a pull request by link`,className:`flex flex-col gap-1.5`,onSubmit:p,noValidate:!0,children:[(0,J.jsxs)(`div`,{className:`flex gap-2 max-sm:flex-col`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(Bg,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,J.jsx)(`input`,{ref:e,id:`${u}-url`,"aria-label":`Pull request link`,className:X(`h-9 w-full min-w-0 rounded-md border border-input bg-card pr-10 pl-8 placeholder:text-muted-foreground`,c!==null&&`border-destructive`),type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:`Paste a GitHub or Bitbucket pull request link`,value:o,readOnly:d,onKeyDown:e=>{ck(e,VI,h)&&m(e)},onChange:e=>{s(e.target.value),l(null),i()},"aria-invalid":c!==null,"aria-describedby":`${u}-message`}),(0,J.jsx)(bk,{id:`focusLink`,className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2`})]}),(0,J.jsx)($,{type:`submit`,size:`lg`,className:`sm:w-28`,"aria-busy":d,onClick:e=>{(e.metaKey||e.ctrlKey||e.shiftKey)&&m(e)},onAuxClick:e=>{e.button===1&&m(e)},children:d?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:xF}),`Opening…`]}):`Review`})]}),(0,J.jsx)(`div`,{id:`${u}-message`,role:`status`,className:`flex min-h-0 flex-wrap items-center gap-x-2 text-caption`,children:c===null?t?.state===`starting`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`size-3.5`,xF)}),t.message]}),(0,J.jsx)($,{type:`button`,variant:`link`,className:BI,onClick:t.onCancel,children:`Cancel`})]}):t?.state===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),t.message]}),(0,J.jsx)($,{type:`button`,variant:`link`,className:BI,onClick:t.onRetry,children:`Try again`})]}):null:(0,J.jsxs)(`span`,{className:`text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),c]})})]})})},UI=Tc.options,WI=({now:e=Date.now})=>{let{client:t}=yp(),{status:n,checks:r,reportListed:i,setOpen:a}=PF(),o=Cp(),s=wp(),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),f=(0,q.useRef)(0),p=(0,q.useRef)(null),m=(0,q.useRef)(null),{refresh:h}=o,{refresh:g}=s,_=(0,q.useCallback)(()=>{h(),g()},[h,g]),v=(0,q.useRef)(r);(0,q.useEffect)(()=>{r!==v.current&&(v.current=r,_())},[r,_]),(0,q.useEffect)(()=>{if(o.loading||(m.current=e(),o.pullRequests===null))return;let t=new Set(o.pullRequests.errors.map(e=>e.host)),r={};for(let e of UI)t.has(e)||n?.hosts[e].configured!==!0||(r[e]=o.pullRequests.items.filter(t=>t.ref.repo.host===e).length);i({counts:r,atMs:e()})},[o.loading,o.pullRequests,n,e,i]),(0,q.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&m.current!==null&&e()-m.current>12e4&&_()};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,_]),(0,q.useEffect)(()=>{let e=e=>{e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey||lk(e.target)||(e.preventDefault(),p.current?.focus(),p.current?.select())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let y=async(e,n,r,i)=>{f.current+=1;let a=f.current;l({from:r,url:e,ref:n,role:i,state:`starting`}),r===`row`&&d(`Opening ${vF(n)}`);let o=await t.startAnalysis({url:e});f.current===a&&(o.ok?A_(D_(o.value.analysisId)):l({from:r,url:e,ref:n,role:i,state:`failed`,error:o.error}))},b=(0,q.useCallback)(e=>{f.current+=1,l(null),e===`form`?p.current?.focus():d(`Cancelled`)},[]),x=c?.state===`starting`&&c.from===`row`;(0,q.useEffect)(()=>{if(!x)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||e.target instanceof Element&&e.target.closest(`[data-slot=popover-content]`)||b(`row`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[x,b]);let S=e=>(0,J.jsx)(IF,{pullRequest:e.ref,error:e.error}),C=c?.from===`form`?c.state===`starting`?{state:`starting`,message:`Fetching ${vF(c.ref)} from ${_F[c.ref.repo.host]}…`,onCancel:()=>b(`form`)}:{state:`failed`,message:S(c),onRetry:()=>void y(c.url,c.ref,`form`,null)}:null,w=e(),T=c?.state===`starting`&&c.from===`row`?c.url:null,E=c?.state===`failed`&&c.from===`row`&&c.role!==null?{role:c.role,message:S(c),onRetry:()=>void y(c.url,c.ref,`row`,c.role)}:null;return(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1240px] flex-col gap-4`,children:[(0,J.jsx)(`h1`,{className:`sr-only`,children:`Pull requests`}),(0,J.jsx)(HI,{inputRef:p,start:C,onSubmit:(e,t)=>void y(e,t,`form`,null),onSubmitInNewTab:e=>window.open(E_(e),`_blank`,`noopener`),onEdit:()=>{c?.from===`form`&&c.state===`failed`&&l(null)}}),(0,J.jsx)(MF,{status:n,list:o.pullRequests,error:o.error,rowFailure:E,startingUrl:T,nowMs:w,onOpen:e=>void y(e.url,e.ref,`row`,e.role),onRetry:_,onOpenConnections:()=>a(!0),onFix:()=>a(!0,{focusCheckAgain:!0})}),(0,J.jsx)(LI,{activity:s.activity,error:s.error,onRetry:g,now:e}),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})},GI=`megareviewer:`,KI=e=>{try{let t=window.localStorage.getItem(GI+e);return t===null?void 0:JSON.parse(t)}catch{return}},qI=(e,t)=>{try{window.localStorage.setItem(GI+e,JSON.stringify(t))}catch{}},JI=(e,t,n)=>{let[r,i]=(0,q.useState)(()=>({key:e,value:n(KI(e))??t}));return[r.key===e?r.value:n(KI(e))??t,(0,q.useCallback)(r=>i(i=>{let a=r(i.key===e?i.value:n(KI(e))??t);return qI(e,a),{key:e,value:a}}),[e,t,n])]},YI=e=>typeof e==`boolean`?e:void 0,XI=e=>typeof e==`string`?e:void 0,ZI=e=>{let t=new Map;for(let n of e){let e=n.available?`${n.provider} ${n.via}`:n.provider,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.values()].flatMap(e=>{let[t]=e;return t===void 0?[]:[[t,e]]})},QI=(e,t,n)=>{if(e.length<=6)return e;let r=e.filter(e=>e.id===t?.id||e.id===n);return r.length>0?r:e.slice(0,1)},$I=(e,t,n)=>{let r=n.toLowerCase().split(/\s+/).filter(e=>e!==``);return r.length===0?[]:e.filter(e=>!t.includes(e)&&r.every(t=>`${e.modelName} ${e.model}`.toLowerCase().includes(t)))},eL=e=>e.length===0?`No model is known to megareviewer`:e.some(e=>e.available)?null:ZI(e).map(([e])=>e.reason??`${e.providerName} can't run`).join(`; or `),tL=e=>{let[t,n]=JI(`model-option`,null,XI),r=e?.options??[],i=r.find(e=>e.id===t&&e.available)??r.find(t=>t.id===e?.defaultId)??null,a=(0,q.useCallback)(e=>n(()=>e),[n]);return{options:r,chosen:i,defaultId:e?.defaultId??null,locked:e===null?null:eL(r),choose:a}},nL=(e,t)=>({...e,preferences:e.preferences.some(e=>e.id===t.id)?e.preferences.map(e=>e.id===t.id?t:e):[...e.preferences,t]}),rL=(e,t)=>({...e,preferences:e.preferences.filter(e=>e.id!==t)}),iL=(e,t)=>({...e,proposals:[...e.proposals,...t.filter(t=>!e.proposals.some(e=>e.id===t.id))]}),aL=(e,t)=>({...e,proposals:e.proposals.filter(e=>e.id!==t)}),oL=(e,t,n,r)=>({...e,repositories:e.repositories.map(e=>ru(e.repo,t)&&e.guidelineFiles!==null?{...e,guidelineFiles:e.guidelineFiles.map(e=>e.path===n?{...e,enabled:r}:e)}:e)}),sL=(e,t)=>e.preferences.filter(e=>iu(e.scope,t)),cL=e=>{let t=[...e.repositories];for(let{scope:n}of[...e.preferences,...e.proposals])n.kind!==`repo`||t.some(e=>ru(e.repo,n.repo))||t.push({repo:n.repo,guidelineFiles:null,guidelineNote:`No pull request of this repository has been analyzed yet`});return t},lL=e=>{if(e<1024)return`${e} B`;let t=e/1024;return`${t<10?t.toFixed(1):Math.round(t)} KB`},uL=e=>{let t=e.trim();return t===``||/[.!?]$/.test(t)?t:`${t}.`},dL=e=>e.code===`bad-request`?uL(e.message):Ap(e),fL=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,pL=new Intl.ListFormat(`en`,{type:`disjunction`}).format(Jl),mL=({file:e,repository:t,onSwitch:n})=>{let[r,i]=(0,q.useState)(null);return(0,J.jsxs)(`li`,{"data-slot":`guideline-file`,className:`flex min-h-8 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 font-mono text-code-compact break-all`,children:e.path}),(0,J.jsx)(`span`,{className:`tabular shrink-0 text-caption text-muted-foreground`,children:lL(e.bytes)}),e.tooLarge?(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`too large to send: a guideline file can be `,lL(Xl)]}):(0,J.jsx)(ZN,{checked:e.enabled,"aria-label":`Read ${e.path} in AI reviews of ${t}`,onCheckedChange:async t=>{i(null),i(await n(e.path,t))}}),r!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),r]})]})},hL=({files:e,note:t,repository:n,onSwitch:r})=>(0,J.jsxs)(`div`,{"data-slot":`guideline-files`,className:`flex flex-col gap-1 border-t px-4 py-3`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Guideline files, read at the base commit of the pull request`}),e===null?(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:uL(t??`Couldn't look for them`)}):e.length===0?(0,J.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[`None at the repository's root, where megareviewer looks for `,pL,`.`]}):(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,J.jsx)(mL,{file:e,repository:n,onSwitch:r},e.path))})]}),gL=q.createContext(void 0);function _L(e){let t=q.useContext(gL);if(t===void 0&&!e)throw Error(Ov(33));return t}var vL=q.createContext(void 0);function yL(e){let t=q.useContext(vL);if(t===void 0&&!e)throw Error(Ov(36));return t}var bL=q.createContext(void 0);function xL(e=!0){let t=q.useContext(bL);if(t===void 0&&!e)throw Error(Ov(25));return t}var SL=q.createContext(null);function CL(e=`root`){let t=q.useContext(SL),n=q.useContext(vL);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var wL={visible:!0,ref:null};function TL(){return wL}function EL(e,t,n=`root`){let r=CL(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??TL)({label:e.label,children:e.children,render:e.render}),a=Lv(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var DL=q.createContext(void 0);function OL(){let e=q.useContext(DL);if(e===void 0)throw Error(Ov(30));return e}function kL(e){e.preventDefault()}function AL(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=yL(),u=xL(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return q.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?kL:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:Lb})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Ay&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Nv(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var jL={type:`regular-item`};function ML(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=q.useRef(null),{getButtonProps:d,buttonRef:f}=Pv({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=AL({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=q.useCallback(e=>mv(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Lv(u,f);return q.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var NL=`data-checked`,PL=`data-unchecked`,FL={checked(e){return e?{[NL]:``}:{[PL]:``}},...tb},IL=q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=yL(),m=bO({guess:!0,label:a}),h=gE(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=ML({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:jL}),C=q.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=Ab(Lb,e.nativeEvent,void 0,{preventUnmountOnClose:Kv});u?.(!l,t)}let T=Qv(`div`,e,{state:C,stateAttributesMapping:FL,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,J.jsx)(DL.Provider,{value:C,children:T})}),LL=q.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=nO({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=EL(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,J.jsx)(IL,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),RL=q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=OL(),c=q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=PC(s.checked);return zC({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Qv(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:FL,props:{"aria-hidden":!0,...o},enabled:a||u})}),zL=q.createContext(void 0);function BL(){let e=q.useContext(zL);if(e===void 0)throw Error(Ov(31));return e}var VL=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=q.useState(void 0),c=Qv(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,J.jsx)(zL.Provider,{value:s,children:c})}),HL=q.forwardRef(function(e,t){let n=CL()?.Group??VL;return(0,J.jsx)(n,{...e,ref:t})}),UL=q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=gE(a),c=BL();return Q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Qv(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),WL=q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=yL(),f=bO({guess:!0,label:a}),p=gE(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=ML({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:jL});return Qv(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),GL=q.forwardRef(function(e,t){let n=EL(e,t);return n.visible?(0,J.jsx)(WL,{...e,ref:n.ref}):null}),KL=q.createContext(void 0);function qL(){return q.useContext(KL)}function JL(e,t){let n=ny(e.render);if(q.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function YL(e,t,n){let r=JL(e,t),i=r===t?void 0:r;return[r,q.useCallback(e=>n?.(e?i:void 0),[i,n])]}function XL(e,t,n){let r=ny(e.render),i=q.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var ZL=q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=yL(),m=qL(),{side:h,align:g}=_L(),_=Rj(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=YL(e,u,d),L=XL(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,z=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(z=()=>l.state.activeIndex===null&&P),zC({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),q.useEffect(()=>{function e(e){l.setOpen(!1,Ab(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Nw(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let te=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:B,handleFocus:ne}=(q.useContext(SL)?.useParentHandoff??$L)(l,w,v,f),V=Qv(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,te,I],stateAttributesMapping:hb,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&IO.has(e.key)&&e.stopPropagation()},onFocus:ne},zE(y),c,{"data-rootownerid":E}]}),H=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(H=!0);let re=R?.getReturnElement??B;return(0,J.jsx)(pC,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??re??H,explicitReturnFocus:a===void 0&&re?!1:void 0,initialFocus:z,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:V})}),QL={parentVirtualFocusRef:void 0,handleFocus:void 0};function $L(){return QL}var eR=q.forwardRef(function(e,t){let n=CL()?.Popup??ZL;return(0,J.jsx)(n,{...e,ref:t})}),tR=q.createContext(void 0);function nR(){let e=q.useContext(tR);if(e===void 0)throw Error(Ov(32));return e}var rR=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=yL();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,J.jsx)(tR.Provider,{value:n,children:(0,J.jsx)(JS,{ref:t,...r,portalOwnerRole:o})})}),iR=q.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=BS,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=yL(),x=nR(),S=xL(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=n,z=c,te=l,B=s,ne=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,B??=`start`,!o&&B!==`center`&&(te=e.alignOffset??2,z=e.sideOffset??-5));let V=o,H=B;C.type===`menu`?(V??=`inline-end`,H??=`start`,ne=e.collisionAvoidance??VS):C.type===`menubar`&&(V??=C.context.orientation===`vertical`?`inline-end`:`bottom`,H??=`start`);let re=C.type===`context-menu`,ie=IE({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:V,sideOffset:z,align:H,alignOffset:te,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ne,shift:re?{crossAxis:!(`side`in ne&&ne.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});q.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Ab(Gb)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),q.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Ab(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ae=by();q.useEffect(()=>{D||ae.clear()},[D,ae]),q.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?ae.isStarted()||ae.start(e,()=>{v.setOpen(!1,Ab(Gb))}):v.setOpen(!1,Ab(Gb))}else ae.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ae]),q.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),mM({store:v,domReference:R,positionerElement:M,open:D});let oe={open:D,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:C.type===`menu`,instant:N},se=C.type===`menubar`&&C.context.modal;gM(D&&(se||O&&F!==`trigger-hover`),k===`touch`,M,A);let U=BE(e,oe,{styles:ie.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),ce=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),le=null;return C.type===`menubar`?le=C.context.contentElement:C.type===void 0&&(le=A),(0,J.jsxs)(gL.Provider,{value:ie,children:[ce&&(0,J.jsx)(hA,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:UE(!D),cutout:le}),(0,J.jsx)(nC,{id:I,children:(0,J.jsx)(aO,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:U})})]})}),aR=q.createContext(void 0);function oR(){let e=q.useContext(aR);if(e===void 0)throw Error(Ov(34));return e}var sR=q.forwardRef(function(e,t){let{render:n,className:r,value:i,defaultValue:a,onValueChange:o,disabled:s=!1,style:c,"aria-labelledby":l,...u}=e,[d,f]=q.useState(void 0),[p,m]=nO({controlled:i,default:a,name:`MenuRadioGroup`}),h=Z((e,t)=>{o?.(e,t),!t.isCanceled&&m(e)}),g=Qv(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=q.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return(0,J.jsx)(zL.Provider,{value:f,children:(0,J.jsx)(aR.Provider,{value:_,children:g})})}),cR=q.memo(q.forwardRef(function(e,t){let n=CL()?.RadioGroup??sR;return(0,J.jsx)(n,{...e,ref:t})})),lR=q.createContext(void 0);function uR(){let e=q.useContext(lR);if(e===void 0)throw Error(Ov(35));return e}var dR=q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,value:l,style:u,...d}=e,{store:f}=yL(),{value:p,setValue:m,disabled:h}=oR(),g=bO({guess:!0,label:a}),_=gE(i),v=f.useState(`isActive`,g.index),y=f.useState(`floatingNodeId`),b=f.useState(`itemProps`),x=f.useState(`disabled`),S=s||h||x,C=p===l,{getItemProps:w,itemRef:T}=ML({closeOnClick:c,disabled:S,highlighted:v,id:_,store:f,nativeButton:o,nodeId:y,itemMetadata:jL}),E=q.useMemo(()=>({disabled:S,highlighted:v,checked:C}),[S,v,C]);function D(e){let t=Ab(Lb,e.nativeEvent,void 0,{preventUnmountOnClose:Kv});m(l,t)}let O=Qv(`div`,e,{state:E,stateAttributesMapping:FL,props:[b,{role:`menuitemradio`,"aria-checked":C,onClick:D},d,w],ref:[T,t,g.ref]});return(0,J.jsx)(lR.Provider,{value:E,children:O})}),fR=q.forwardRef(function(e,t){let n=EL(e,t);return n.visible?(0,J.jsx)(dR,{...e,ref:n.ref}):null}),pR=q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=uR(),c=q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=PC(s.checked);return zC({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Qv(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:FL,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),mR=q.createContext(null);function hR(e){let t=q.useContext(mR);if(t===null&&!e)throw Error(Ov(5));return t}function gR(e){return e==null?Mb:e.type.startsWith(`key`)?Hb:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Ub:Mb}var _R={...Cw,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Cw.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>My&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Cw.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},vR=class extends mw{constructor(e,t,n=!1){let r=new tw,i=bR(r,t,n,e);super(i,yR(r),_R),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function yR(e){return{positionerRef:q.createRef(),popupRef:q.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function bR(e,t,n=!1,r){return{..._w(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:Jv,inputProps:Jv,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new XS,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Jv,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var xR=q.createContext(null);function SR(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function CR(e,t){return e===`list-navigation`||SR(e,t)}var wR=my(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=xL(!0),C=yL(!0),w=hR(!0),T=C?.store,E=C?.virtualFocus??!1,D=q.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=gE(),k=gE(),[A,j]=q.useState(void 0),M=(A??k)||void 0,N=$S(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=sv(()=>F?P?.state.instantType:void 0).current,L=sv(()=>{let e=new vR({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),ee=tC(R),z=L.useState(`open`),te=L.useState(`activeTriggerElement`),B=L.useState(`positionerElement`),ne=L.useState(`hoverEnabled`),V=L.useState(`disabled`),H=L.useState(`lastOpenChangeReason`),re=L.useState(`parent`),ie=L.useState(`activeIndex`),ae=L.useState(`keyboardOpen`),oe=L.useState(`payload`),se=L.useState(`floatingParentNodeId`),U=q.useRef(null),ce=q.useRef(re.type!==`context-menu`),le=by(),ue=q.useRef(!0),de=by(),fe=se!=null,{openMethod:pe,triggerProps:me}=zA(z);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:re.type===void 0?c:void 0,openMethod:pe,rootId:O}),ZC(L);let{forceUnmount:he,transitionStatus:ge}=QC(z,L,()=>{L.set(`allowMouseEnter`,!1)},F),_e=RC(L.context.popupRef);q.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!z){e();return}if(ge!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return _e(e,t.signal),()=>{t.abort()}},[I,z,ge,_e,L]),Q(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ee,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ee,floatingParentNodeId:N})},[S,C,ee,N,te,L]),q.useEffect(()=>{z||(U.current=null),re.type===`context-menu`&&(z?le.start(500,()=>{ce.current=!0}):(le.clear(),ce.current=!1))},[le,z,re.type]),Q(()=>{!z&&!ne&&L.set(`hoverEnabled`,!0)},[z,ne,L]);let ve=Z((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||z===e&&t.trigger===te&&H===n)return;let i=JC(t);if(!e&&t.trigger==null&&(t.trigger=te??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ue.current)return;e&&n===`trigger-focus`?(ue.current=!1,de.start(300,()=>{ue.current=!0})):(ue.current=!0,de.clear());let o=!e&&(n===`escape-key`||n==null);U.current=t.event;let s=qC(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&CR(n,a),s.instantType=re.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:SR(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),ye=NC({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:ve}),be=ye.context.events;Q(()=>{let e=({open:e,eventDetails:t})=>ve(e,t);return be.on(`setOpen`,e),()=>{be?.off(`setOpen`,e)}},[be,ve]),Q(()=>L.subscribeToParentMenu(),[L]);let xe=q.useCallback(()=>{L.setOpen(!1,Ab(Yb))},[L]);q.useImperativeHandle(d,()=>({unmount:he,close:xe}),[he,xe]);let Se;re.type===`context-menu`&&(Se=re.context),q.useImperativeHandle(Se?.positionerRef,()=>B,[B]),q.useImperativeHandle(Se?.actionsRef,()=>({setOpen:ve}),[ve]);let Ce=bC(ye,{enabled:!V,bubbles:{escapeKey:f&&re.type===`menu`},outsidePress(){return re.type!==`context-menu`||U.current?.type===`contextmenu`||ce.current},externalTree:fe?R:void 0}),we=SE(),Te=Hw(ye,{enabled:!V,listRef:L.context.itemDomElements,activeIndex:ie,virtual:v,nested:re.type===`menubar`||!v&&re.type!==void 0,parentOrientation:re.type===`menubar`?re.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?ae:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:we===`rtl`,disabledIndices:qv,onNavigate(e,t){L.setActiveIndex(e,gR(t),t?.nativeEvent)},openOnArrowKeyDown:re.type!==`context-menu`&&!(v&&_),externalTree:!v&&fe?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Ee=q.useCallback(e=>{L.context.typingRef.current=e},[L]),De=Uw(ye,{enabled:!V&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:ie,resetMs:500,onMatch:(e,t)=>{z&&e!==ie&&L.setActiveIndex(e,Hb,t.nativeEvent)},onTyping:Ee}),Oe=Z(a),ke=q.useRef(-1),Ae=Z(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(ke.current===n&&L.context.reportedItem===t)return;ke.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Mb,L.context.highlightEvent=void 0,a&&Oe(t,jb(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});Q(()=>{Ae()},[ie,Ae]);let je=q.useMemo(()=>{if(!v)return Te.reference;if(!Te.trigger)return Jv;let{onFocus:e,...t}=Te.trigger;return t},[v,Te.reference,Te.trigger]);L.useSyncedValue(`inputProps`,v?Te.reference??Jv:Jv);let Me=q.useMemo(()=>{let e=mv(De.reference,je,Ce.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},me);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=z,e},[L,De.reference,je,Ce.reference,me,z]),Ne=q.useMemo(()=>{let e=mv(Te.trigger,Ce.trigger,me);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Te.trigger,Ce.trigger,me]);sv(()=>(L.update({inactiveTriggerProps:Ne}),null)),$C(L,{floatingRootContext:ye,activeTriggerProps:Me,inactiveTriggerProps:Ne,popupProps:q.useMemo(()=>mv(VC,{onMouseMove(){L.set(`allowMouseEnter`,!0),re.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},De.floating,Te.floating,Ce.floating),[re.type,L,De.floating,Te.floating,Ce.floating]),itemProps:Te.item??Jv});let Pe=q.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Ae}),[L,D,u,l,b,k,v,E,Ae]),Fe=typeof t==`function`?t({payload:oe}):t,Ie=(0,J.jsxs)(vL.Provider,{value:Pe,children:[p&&(0,J.jsx)(WC,{handle:p,store:L}),Fe]});return(re.type===void 0||re.type===`context-menu`)&&(Ie=(0,J.jsx)(rC,{externalTree:R,children:Ie})),Ie});function TR(e){let t=q.useContext(xR);if(t===null)return(0,J.jsx)(wR,{...e});let n=t.Root;return(0,J.jsx)(xR.Provider,{value:null,children:(0,J.jsx)(n,{...t.options,...e})})}var ER=5;function DR(e,t){let n=OR(t);return e.clientX>=n.left-ER&&e.clientX<=n.right+ER&&e.clientY>=n.top-ER&&e.clientY<=n.bottom+ER}function OR(e){let t=e.getBoundingClientRect(),n=I_(e);if(Py)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function kR(e){if(B_(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Q_(e))return kR(tv(e))}function AR(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=q.useRef(!1);return q.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Mv(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Jv,[t,n,r])}var jR=hy(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=yL(!0),h=ww(d)??m?.store;if(!h)throw Error(Ov(85));let g=gE(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=q.useRef(null),S=NR(),C=Av(!0),w=eC(),T=q.useMemo(()=>w??new XS,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=XC(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:tC(T),floatingParentNodeId:$S(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Pv({disabled:A,native:o});q.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=q.useRef(null),P=by(),F=Z(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Hy(N.current,t)||Hy(h.select(`positionerElement`),t)||t===N.current||(t==null||kR(t)!==h.select(`rootId`))&&(DR(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Wb}))});q.useEffect(()=>{let e=Mv(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=Fw(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:Zw({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=MR(y,h.select(`lastOpenChangeReason`)),ee=mC(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Dw(v,{enabled:!A&&I}),te=AR({open:y,enabled:O,mouseDownAction:`open`}),B=q.useMemo(()=>mv(z.reference,ee.reference),[z.reference,ee.reference]),ne=h.useState(`triggerProps`,D),V=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:H,handleFocusTargetFocus:re}=sM(h,x),ie={disabled:A,open:y},ae=[N,t,M,E,x],oe=[B,L??Jv,ne,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Mv(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},V,O?{role:`menuitem`}:{},te,p,j],se=Qv(`button`,e,{enabled:!O,stateAttributesMapping:pb,state:ie,ref:ae,props:oe});return O?(0,J.jsx)(Fj,{tag:`button`,render:n,className:r,style:i,state:ie,refs:ae,props:oe,stateAttributesMapping:pb}):y?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(fx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:H},`${g}-pre-focus-guard`),(0,J.jsx)(q.Fragment,{children:se},g),(0,J.jsx)(fx,{ref:h.context.triggerFocusTargetRef,onFocus:re},`${g}-post-focus-guard`)]}):(0,J.jsx)(q.Fragment,{children:se},g)});function MR(e,t){let n=by(),[r,i]=q.useState(!1);return Q(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function NR(){let e=hR(!0);return q.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var PR=q.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Qv(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function FR(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function IR(e){return FR(e?.[0])}function LR(e){return IR(e)?e.flatMap(e=>e.items):e}function RR(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(IR(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function zR(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return NN(e)}function BR(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?NN(e.value):NN(e)}function VR(e,t,n){function r(){return zR(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=LR(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function HR(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,J.jsx)(q.Fragment,{children:VR(r,t,n)},i)),e),[])}function UR({...e}){return(0,J.jsx)(TR,{"data-slot":`dropdown-menu`,...e})}function WR({...e}){return(0,J.jsx)(jR,{"data-slot":`dropdown-menu-trigger`,...e})}function GR({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,J.jsx)(rR,{children:(0,J.jsx)(iR,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,J.jsx)(eR,{"data-slot":`dropdown-menu-content`,className:X(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-(--duration-fast) outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function KR({...e}){return(0,J.jsx)(HL,{"data-slot":`dropdown-menu-group`,...e})}function qR({className:e,inset:t,...n}){return(0,J.jsx)(UL,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:X(`px-1.5 py-1 text-caption font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function JR({className:e,inset:t,variant:n=`default`,...r}){return(0,J.jsx)(GL,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:X(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function YR({className:e,children:t,checked:n,inset:r,...i}){return(0,J.jsxs)(LL,{"data-slot":`dropdown-menu-checkbox-item`,"data-inset":r,className:X(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-checkbox-item-indicator`,children:(0,J.jsx)(RL,{children:(0,J.jsx)(Rh,{})})}),t]})}function XR({...e}){return(0,J.jsx)(cR,{"data-slot":`dropdown-menu-radio-group`,...e})}function ZR({className:e,children:t,inset:n,...r}){return(0,J.jsxs)(fR,{"data-slot":`dropdown-menu-radio-item`,"data-inset":n,className:X(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,J.jsx)(pR,{children:(0,J.jsx)(Rh,{})})}),t]})}function QR({className:e,...t}){return(0,J.jsx)(PR,{"data-slot":`dropdown-menu-separator`,className:X(`-mx-1 my-1 h-px bg-border`,e),...t})}var $R=({option:e,noteId:t})=>(0,J.jsxs)(ZR,{value:e.id,disabled:!e.available,"aria-describedby":e.available?void 0:t,children:[e.modelName,!e.measured&&(0,J.jsx)(`span`,{className:`rounded-full border px-1.5 text-caption text-muted-foreground`,children:`unmeasured`})]}),ez=e=>{if(e.key===`Escape`||e.key===`Tab`||(e.stopPropagation(),e.key!==`ArrowDown`&&e.key!==`ArrowUp`))return;let t=[...e.currentTarget.closest(`[role="menu"]`)?.querySelectorAll(`[role="menuitemradio"]`)??[]],n=t.findIndex(t=>e.currentTarget.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING),r=e.key===`ArrowDown`?t[n]:t[(n===-1?t.length:n)-1];r!==void 0&&(e.preventDefault(),r.focus())},tz=({first:e,options:t,separated:n,noteId:r,choice:i})=>{let[a,o]=(0,q.useState)(``),s=QI(t,i.chosen,i.defaultId),c=t.length-s.length,l=$I(t,s,a);return(0,J.jsxs)(KR,{children:[n&&(0,J.jsx)(QR,{}),(0,J.jsxs)(qR,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-foreground`,children:e.available?e.via:e.providerName}),!e.available&&(0,J.jsx)(`span`,{id:r,className:`font-normal`,children:e.reason})]}),s.map(e=>(0,J.jsx)($R,{option:e,noteId:r},e.id)),c>0&&(0,J.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,J.jsx)(nP,{value:a,onChange:e=>o(e.target.value),onKeyDown:ez,placeholder:`Filter ${c} more models`,"aria-label":`Filter ${c} more models through ${e.via}`,className:`h-7`})}),l.map(e=>(0,J.jsx)($R,{option:e,noteId:r},e.id)),c>0&&a.trim()!==``&&l.length===0&&(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,children:`No model matches`})]})},nz=({choice:e,disabled:t,filled:n})=>{let r=(0,q.useId)();return(0,J.jsxs)(UR,{children:[(0,J.jsx)(WR,{render:(0,J.jsx)($,{variant:n?`default`:`outline`,size:`sm`,"data-slot":`model-menu`,disabled:t,"aria-label":e.chosen===null?`Choose a model`:`Model: ${e.chosen.modelName}`,className:X(`w-6 rounded-l-none px-0`,n?`border-l-primary-foreground/30`:`border-l-0`)}),children:(0,J.jsx)(Bh,{"aria-hidden":`true`})}),(0,J.jsx)(GR,{align:`end`,className:`w-80`,children:(0,J.jsx)(XR,{value:e.chosen?.id??null,onValueChange:t=>e.choose(t),children:ZI(e.options).map(([t,n],i)=>(0,J.jsx)(tz,{first:t,options:n,separated:i>0,noteId:`${r}-${i}`,choice:e},t.id))})})]})},rz=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`,iz=(e,t)=>{let[n,r]=(0,q.useState)(t);return(0,q.useEffect)(()=>{if(e===null)return;r(t());let n=setInterval(()=>r(t()),1e3);return()=>clearInterval(n)},[e,t]),e===null?0:Math.max(0,Math.round((n-e)/1e3))},az=({label:e,running:t,icon:n,variant:r=`outline`,choice:i,what:a=`Runs`,blocked:o=null,idle:s=null,run:c,now:l=Date.now,initial:u})=>{let d=(0,q.useId)(),[f,p]=(0,q.useState)(()=>u===void 0?{is:`idle`}:`runningSince`in u?{is:`running`,since:u.runningSince}:u.ok?{is:`done`,said:u.said}:{is:`failed`,...u}),m=iz(f.is===`running`?f.since:null,l),{chosen:h,locked:g}=i,_=f.is===`running`,v=o??g,y=v??(h===null?null:`${a} ${h.modelName} through ${h.via}`),b=async()=>{p({is:`running`,since:l()});let e=await c(h?.id);p(e.ok?{is:`done`,said:e.said}:{is:`failed`,...e})};return(0,J.jsxs)(`div`,{"data-slot":`model-action`,className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center`,children:[(0,J.jsxs)(uI,{disabled:y===null,children:[(0,J.jsxs)(dI,{render:(0,J.jsx)($,{variant:r,size:`sm`,disabled:_||v!==null||h===null,focusableWhenDisabled:!0,"aria-busy":_,"aria-describedby":y===null?void 0:`${d}-note`,onClick:()=>void b(),className:`rounded-r-none`}),children:[_?(0,J.jsx)(Hg,{"aria-hidden":`true`,className:xF}):g!==null&&o===null?(0,J.jsx)(Wg,{"aria-hidden":`true`}):n,e]}),(0,J.jsxs)(fI,{side:`bottom`,align:`start`,children:[v!==null&&(0,J.jsx)(Pg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),y]})]}),(0,J.jsx)(nz,{choice:i,disabled:_||i.options.length===0,filled:r==="default"&&v===null})]}),y!==null&&(0,J.jsx)(`span`,{id:`${d}-note`,hidden:!0,children:y}),(0,J.jsx)(`span`,{role:f.is===`failed`?`alert`:`status`,className:X(`flex min-w-0 flex-1 basis-56 flex-wrap items-center gap-x-2 text-caption`,f.is===`failed`?`text-destructive`:`text-muted-foreground`),children:f.is===`running`?(0,J.jsxs)(J.Fragment,{children:[t,` `,(0,J.jsx)(`span`,{className:`tabular`,children:rz(m)})]}):f.is===`done`?f.said:f.is===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),f.message]}),(0,J.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:()=>void b(),children:`Try again`})]}):s})]})};function oz(e){let t=q.useRef(!0);t.current&&(t.current=!1,e())}var sz=q.createContext(void 0),cz=q.createContext(void 0);function lz(){let e=q.useContext(sz);if(e===void 0)throw Error(Ov(60));return e}function uz(){let e=q.useContext(cz);if(e===void 0)throw Error(Ov(61));return e}function dz(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var fz=(e,t)=>Object.is(e,t);function pz(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function mz(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!dz(e,t,(e,t)=>pz(e,t,n)):e!==t}function hz(e,t,n){return e?e.some(e=>e!==void 0&&pz(t,e,n)):!1}function gz(e,t,n){return e?e.findIndex(e=>e!==void 0&&pz(e,t,n)):-1}function _z(e,t){if(t!==fz)return n=>hz(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function vz(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(_z(t,n)):gz(e,t,n);return i===-1?null:i}function yz(e,t,n,r,i,a){return hz(r,t,i)?a!=null&&e>a&&hz(r,n[a],i)?a:e:e===a?vz(n,r,i,!0):a}function bz(e,t,n){return e.filter(e=>!pz(t,e,n))}var xz={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:BR(t,r)!==``},hasNullItemLabel:(e,t)=>t?RR(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>pz(t,e,n)):pz(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function Sz(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=fz,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=IN(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=TN(),F=MN({id:t}),I=M||d,L=j??c,[R,ee]=nO({controlled:n,default:y?r??qv:r,name:`Select`,state:`value`}),[z,te]=nO({controlled:a,default:o,name:`Select`,state:`open`}),B=q.useRef([]),ne=q.useRef([]),V=q.useRef(null),H=q.useRef(null),re=q.useRef(0),ie=q.useRef(null),ae=q.useRef([]),oe=q.useRef(!1),se=q.useRef(null),U=q.useRef(null),ce=q.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),le=q.useRef(!1),ue=q.useRef(R),{openMethod:de,triggerProps:fe}=zA(z),pe=sv(()=>new mw({id:F,labelId:void 0,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:z,transitionStatus:void 0,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Jv,triggerProps:Jv,itemRoot:{props:Jv,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Kv,setOpen:Kv,handleScrollArrowVisibility:Kv,onOpenChangeComplete:Kv,listRef:B,popupRef:V,scrollHandlerRef:H,scrollArrowsMountedCountRef:re,valueRef:ie,valuesRef:ae,labelsRef:ne,typingRef:oe,selectionRef:ce,firstItemTextRef:se,selectedItemTextRef:U,alignItemWithTriggerActiveRef:le,initialValueRef:ue},xz)).current,[me,he]=q.useState(!1),{mounted:ge,transitionStatus:_e,forceUnmount:ve}=BC({open:z,ref:V,preventUnmountOnClose:me,setPreventUnmountOnClose:he,onUnmount(){pe.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),ye=pe.useState(`activeIndex`),be=pe.useState(`selectedIndex`),xe=pe.useState(`triggerElement`),Se=pe.useState(`positionerElement`),Ce=WE(de),we=de??Ce,Te=q.useMemo(()=>y?``:BR(R,x),[y,R,x]),Ee=q.useMemo(()=>y&&Array.isArray(R)?R.map(e=>BR(e,x)):BR(R,x),[y,R,x]);PN(rx(xe),F,R,Z(()=>Ee),!I,c);let De=y?Array.isArray(R)&&R.length>0:R!=null&&Te!==``;Q(()=>{A(De)},[De,A]),Q(function(){let e=vz(ae.current,R,S,y);e===null&&(U.current=null),!z&&pe.set(`selectedIndex`,e)},[y,z,R,S,pe]),LA(R,()=>{T(L),E(mz(R,k.initialValue,S)),N.change(R)});let Oe=Z((e,t)=>{let n=t,r=JC(n);s?.(e,n),!t.isCanceled&&(e||he(r()),te(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))});q.useImperativeHandle(h,()=>({unmount:ve,close:()=>{pe.state.open&&Oe(!1,Ab(Yb))}}),[ve,Oe,pe]);let ke=Z((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),Ae=Z(e=>{let t=DP(e.scrollHeight,e.clientHeight),n=OP(e.scrollTop,t),r=n>0,i=n<t;pe.set(`scrollUpArrowVisible`,r),pe.set(`scrollDownArrowVisible`,i)}),je=Tw({open:z,onOpenChange:Oe,elements:{reference:xe,floating:Se}}),Me=mC(je,{enabled:!I,event:`mousedown`}),Ne=bC(je),Pe=Hw(je,{enabled:!I,listRef:B,activeIndex:ye,selectedIndex:be,disabledIndices:qv,onNavigate(e){(e!==null||z)&&pe.set(`activeIndex`,e)},focusItemOnHover:C}),Fe=Uw(je,{enabled:!I&&(z||!f&&!y),listRef:ne,activeIndex:ye,selectedIndex:be,disabledIndices:e=>jO(B.current[e]),onMatch(e){z?pe.set(`activeIndex`,e):ke(ae.current[e],Ab(Mb))},onTyping(e){oe.current=e}}),Ie=q.useMemo(()=>mv(Fe.reference,Pe.reference,Ne.reference,Me.reference,fe),[Me.reference,Fe.reference,Pe.reference,Ne.reference,fe]),Le=q.useMemo(()=>mv(VC,Fe.floating,Pe.floating,Ne.floating),[Fe.floating,Pe.floating,Ne.floating]),Re=Pe.item??Jv,ze=q.useMemo(()=>({props:Re,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S}),[Re,y,I,f,S]);pe.useContextCallback(`setValue`,ke),pe.useContextCallback(`setOpen`,Oe),pe.useContextCallback(`handleScrollArrowVisibility`,Ae),pe.useContextCallback(`onOpenChangeComplete`,_),oz(()=>{pe.update({popupProps:Le,triggerProps:Ie,itemRoot:ze})}),pe.useSyncedValues({id:F,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,value:R,open:z,mounted:ge,transitionStatus:_e,popupProps:Le,triggerProps:Ie,itemRoot:ze,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:we});let Be=Lv(g,N.inputRef),Ve=y?void 0:L,He=q.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=BR(e,x);return(0,J.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,J.jsxs)(sz.Provider,{value:pe,children:[(0,J.jsx)(cz.Provider,{value:je,children:w}),(0,J.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){pe.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Ab(Mb,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ae.current.findIndex(t=>BR(t,x).toLowerCase()===e||zR(t,b).toLowerCase()===e);r===-1&&(r=ae.current.findIndex((t,n)=>{let r=ne.current[n];return r!=null&&r.toLowerCase()===e}));let i=ae.current[r];i!=null&&ke(i,n)}pe.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Ve==null?`${F}-hidden-input`:void 0,form:l,name:Ve,autoComplete:u,value:Te,disabled:I,required:p&&!(y&&De),readOnly:f,ref:Be,style:L?dx:ux,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),He]})}function Cz(e,t){return e??t}var wz=`data-popup-side`,Tz=400,Ez={...pb,...SN,popupSide:e=>e?{[wz]:e}:null,value:()=>null},Dz=q.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=TN(),{labelId:m}=ON(),h=lz(),g=h.useState(`readOnly`),_=h.useState(`required`),v=h.useState(`disabled`),y=p||v||a,b=h.useState(`open`),x=h.useState(`mounted`),S=h.useState(`value`),C=h.useState(`triggerProps`),w=h.useState(`positionerElement`),T=h.useState(`listElement`),E=h.useState(`popupSide`),D=h.useState(`id`),O=h.useState(`labelId`),k=h.useState(`hasSelectedValue`),A=x&&w?E:null,j=i??D,M=Cz(m,O);MN({id:i});let N=rx(w),P=q.useRef(null),F=EN(y,P),{getButtonProps:I,buttonRef:L}=Pv({disabled:y,native:o}),R=h.useStateSetter(`triggerElement`),ee=by(),z=by(),te=by();q.useEffect(()=>{if(b)return te.start(Tz,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[b,h,z,te]);let B=mv(C,{id:j,role:`combobox`,"aria-expanded":b,"aria-haspopup":`listbox`,"aria-controls":b?T?.id??wb(w)?.id:void 0,"aria-labelledby":M,"aria-readonly":g||void 0,"aria-required":_||void 0,tabIndex:y?-1:0,onFocus(e){F(!0),b&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,Ab(Mb,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){Hy(w,e.relatedTarget)||(l(!0),F(!1),u===`onBlur`&&d.commit(S))},onMouseDown(e){if(b)return;let t=Mv(e.currentTarget);function n(e){if(!P.current)return;let t=e.target;Hy(P.current,t)||Hy(N.current,t)||DR(e,P.current)||h.context.setOpen(!1,Ab(Wb,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),ne=d.getValidationProps(y,B);ne.role=`combobox`;let V={...f,open:b,disabled:y,value:S,readOnly:g,popupSide:A,placeholder:!k};return Qv(`button`,e,{ref:[t,P,L,R],state:V,stateAttributesMapping:Ez,props:ne})}),Oz={value:()=>null},kz=q.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=lz(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?HR(l,u,d):VR(l,u,d)),Qv(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:Oz})}),Az=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Qv(`span`,e,{state:{open:lz().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:fb})}),jz=q.forwardRef(function(e,t){let n=lz(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,J.jsx)(JS,{ref:t,...e}):null}),Mz=q.createContext(void 0);function Nz(){let e=q.useContext(Mz);if(!e)throw Error(Ov(59));return e}function Pz(e,t){e&&Object.assign(e.style,t)}var Fz={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},Iz={position:`fixed`},Lz=q.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=BS,style:_,...v}=e,y=lz(),b=uz(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=q.useRef(null),j=q.useRef(null),[M,N]=q.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),q.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),gM((P||C)&&x,T===`touch`,E,D);let F=IE({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?Iz:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};Q(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=BE(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=q.useRef(0),te=Z(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=Ab(Mb);if(t!==0&&!y.state.multiple&&w!==null&&gz(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&gz(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>gz(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};Pz(E,e),Pz(y.context.popupRef.current,e)}}),B=q.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,J.jsx)(aO,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:te,children:(0,J.jsxs)(Mz.Provider,{value:B,children:[S&&C&&(0,J.jsx)(hA,{inert:UE(!x),cutout:D}),ee]})})}),Rz=`--transform-origin`,zz={...mb,...tb},Bz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=lz(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=uz(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=Nz(),_=Rj(!0)!=null,v=SE(),{nonce:y,disableStyleElements:b}=DO(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),k=s.useState(`listElement`),A=q.useRef(!1),j=q.useRef(!1),M=q.useRef({}),N=cx(),P=Z(e=>{if(!O||!s.context.popupRef.current||!j.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(A.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=Uz(O),i=Wz(O.getBoundingClientRect().height,`y`,r),a=Mv(O),o=I_(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=Vz(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=Hz(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=TP(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(A.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=TP(g,0,Hz(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});q.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),zC({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let F={open:S,transitionStatus:E,side:f,align:p};Q(()=>{O&&s.context.popupRef.current&&!Object.keys(M.current).length&&(M.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),Q(()=>{S||m||(j.current=!1,A.current=!1,Pz(O,M.current))},[S,m,O]),Q(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(j.current=!0,e.style.removeProperty(Rz),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=qz(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=I_(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=Mv(D),c=Uz(D),l=Gz(D.getBoundingClientRect(),c),d=Gz(O.getBoundingClientRect(),c),f=l.height,p=k||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=Vz(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,j=0;if(t&&n){let e=Gz(n.getBoundingClientRect(),c);T=Gz(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;j=T.top-d.top+T.height/2-r}let N=w+j+y+h,P=Math.min(S,N),F=S-_-y,I=N-P,L=C-5;O.style.left=`${TP(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=Hz(p),ee=I>=R-1;ee&&(P=Math.min(S,d.height)-(I-R));let z=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),te=(r.visualViewport?.scale??1)!==1&&My;if(z||te){Pz(O,M.current),g(!1);return}let B=Math.max(b,P);if(ee){let e=Math.max(0,S-N);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=Hz(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=TP(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(Rz,`50% ${i}%`)}(B===S||P>=x)&&(A.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,N,k,u,v,h]),q.useEffect(()=>{if(!m||!O||!S)return;let e=I_(O);function t(e){s.context.setOpen(!1,Ab(Xb,e))}return tx(e,`resize`,t)},[s,m,O,S]);let I={...k?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&IO.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:Fz},className:!k&&m?sP.className:void 0},L=Qv(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:zz,props:[T,I,zE(E),o]});return(0,J.jsxs)(q.Fragment,{children:[!b&&sP.getElement(y),(0,J.jsx)(pC,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function Vz(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function Hz(e){return DP(e.scrollHeight,e.clientHeight)}function Uz(e){return PT.getScale(e)}function Wz(e,t,n){return e/n[t]}function Gz(e,t){return zx({x:Wz(e.x,`x`,t),y:Wz(e.y,`y`,t),width:Wz(e.width,`x`,t),height:Wz(e.height,`y`,t)})}var Kz=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function qz(e){let{style:t}=e,n={};for(let[e,r]of Kz)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of Kz){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var Jz=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=lz(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=Nz(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:Fz},className:u&&d!==`touch`?sP.className:void 0};return Qv(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),Yz=q.createContext(void 0);function Xz(){let e=q.useContext(Yz);if(!e)throw Error(Ov(57));return e}var Zz=q.memo(q.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=q.useRef(null),d=bO({guess:!0,label:o,textRef:u}),f=lz(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:_}=f.useState(`itemRoot`),v=h||s,y=f.useState(`isActive`,d.index),b=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=d.index,w=q.useRef(null);Q(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),Q(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=yz(C,a,f.context.valuesRef.current,e,_,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&pz(a,e,_),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,_,f,a]);let T=q.useRef(`mouse`),E=q.useRef(!1),{getButtonProps:D,buttonRef:O}=Pv({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:v,selected:x,highlighted:y};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?bz(n,a,_):[...n,a];f.context.setValue(r,Ab(Lb,e))}else f.context.setValue(a,Ab(Lb,e)),f.context.setOpen(!1,Ab(Lb,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":x,tabIndex:b&&y?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Ly(e.nativeEvent)&&(n!==void 0||y),i=t&&!r&&!E.current;E.current=!1,!(v||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),v||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=Qv(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=q.useMemo(()=>({selected:x,index:C,textRef:u,selectedByFocus:S}),[x,C,u,S]);return(0,J.jsx)(Yz.Provider,{value:P,children:N})})),Qz=q.memo(q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=q.useRef(null),{transitionStatus:l,setMounted:u}=PC(o),d=Qv(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:tb});return zC({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),$z=q.forwardRef(function(e,t){let{selected:n}=Xz();return e.keepMounted||n?(0,J.jsx)(Qz,{...e,selected:n,ref:t}):null}),eB=q.memo(q.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Xz(),a=lz(),{render:o,className:s,style:c,...l}=e;return Qv(`div`,e,{ref:[q.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),tB=q.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=lz(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=Nz(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=by(),v=c?f:d,{mounted:y,transitionStatus:b,setMounted:x}=PC(g);Q(()=>(l.context.scrollArrowsMountedCountRef.current+=1,l.set(`hasScrollArrows`,!0),()=>{l.context.scrollArrowsMountedCountRef.current=Math.max(0,l.context.scrollArrowsMountedCountRef.current-1),l.context.scrollArrowsMountedCountRef.current===0&&l.set(`hasScrollArrows`,!1)}),[l]),zC({open:g,ref:v,onComplete(){g||x(!1)}});let S=Qv(`div`,e,{ref:[t,v],state:{direction:a,visible:g,side:u,transitionStatus:b},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||_.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??l.context.popupRef.current;if(!e)return;l.set(`activeIndex`,null),l.context.handleScrollArrowVisibility(e);let n=DP(e.scrollHeight,e.clientHeight),r=OP(e.scrollTop,n),i=r===(c?0:n),a=l.context.listRef.current;if(r!==e.scrollTop&&(e.scrollTop=r),i)_.clear();else{if(a.length>0){let t=v.current?.offsetHeight||0;e.scrollTop=nB(a,c,r,e.clientHeight,t,n)}_.start(40,t)}}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:tb});return y||o?S:null});function nB(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?OP(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?OP(l.offsetTop+l.offsetHeight-r+i,a):a}var rB=q.forwardRef(function(e,t){return(0,J.jsx)(tB,{...e,ref:t,direction:`down`})}),iB=q.forwardRef(function(e,t){return(0,J.jsx)(tB,{...e,ref:t,direction:`up`})}),aB=Sz;function oB({className:e,...t}){return(0,J.jsx)(kz,{"data-slot":`select-value`,className:X(`flex flex-1 text-left`,e),...t})}function sB({className:e,size:t=`default`,children:n,...r}){return(0,J.jsxs)(Dz,{"data-slot":`select-trigger`,"data-size":t,className:X(`flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-ui whitespace-nowrap transition-colors select-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,J.jsx)(Az,{render:(0,J.jsx)(Bh,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function cB({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,J.jsx)(jz,{children:(0,J.jsx)(Lz,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,J.jsxs)(Bz,{"data-slot":`select-content`,"data-align-trigger":o,className:X(`relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-(--duration-fast) data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...s,children:[(0,J.jsx)(uB,{}),(0,J.jsx)(Jz,{children:t}),(0,J.jsx)(dB,{})]})})})}function lB({className:e,children:t,...n}){return(0,J.jsxs)(Zz,{"data-slot":`select-item`,className:X(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-ui -outline-offset-2 select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,J.jsx)(eB,{className:`flex flex-1 shrink-0 gap-2 whitespace-nowrap`,children:t}),(0,J.jsx)($z,{render:(0,J.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,J.jsx)(Rh,{className:`pointer-events-none`})})]})}function uB({className:e,...t}){return(0,J.jsx)(iB,{"data-slot":`select-scroll-up-button`,className:X(`top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,J.jsx)(Kh,{})})}function dB({className:e,...t}){return(0,J.jsx)(rB,{"data-slot":`select-scroll-down-button`,className:X(`bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,J.jsx)(Bh,{})})}var fB={"look-for":{label:`Look for`,icon:o_,className:`border-diff-hunk-fg/25 bg-diff-hunk-bg text-diff-hunk-fg`},"dont-flag":{label:`Don't flag`,icon:fg,className:`border-border bg-muted text-muted-foreground`}},pB=({kind:e,className:t})=>{let{label:n,icon:r,className:i}=fB[e];return(0,J.jsxs)(`span`,{"data-slot":`preference-kind`,"data-kind":e,className:X(`inline-flex h-5 shrink-0 items-center gap-1 rounded-full border px-2 text-caption font-medium whitespace-nowrap`,i,t),children:[(0,J.jsx)(r,{"aria-hidden":`true`,className:`size-3`}),n]})},mB={written:`written`,learned:`learned`,imported:`imported`},hB={kind:`global`},gB=({owner:e,repo:t})=>`${e}/${t}`,_B=({host:e,owner:t,repo:n})=>`${e}/${t}/${n}`,vB=e=>e.kind===`global`?`global`:_B(e.repo),yB=e=>[{key:vB(hB),label:`Everywhere`,scope:hB},...e.map(t=>{let n=e.some(e=>e!==t&&gB(e)===gB(t));return{key:_B(t),label:n?`${gB(t)} on ${_F[t.host]}`:gB(t),scope:{kind:`repo`,repo:t}}})],bB=e=>{let t=(0,q.useRef)(null),n=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{e?n.current=!0:n.current&&(n.current=!1,t.current?.focus())},[e]),t},xB=`Write the rule first.`,SB=e=>`A preference is one sentence of at most 300 characters: this is ${e} too many.`,CB=[`look-for`,`dont-flag`],wB={"look-for":{label:`What an AI review should look for`,example:`Tenant isolation: every query filters by tenant ID`},"dont-flag":{label:`What an AI review should leave out`,example:`Naming`}},TB=({legend:e,initial:t,scopes:n,kindFixed:r=!1,submit:i,submitting:a,note:o=null,focus:s=!1,onSubmit:c,onCancel:l})=>{let u=(0,q.useId)(),[d,f]=(0,q.useState)(t.kind),[p,m]=(0,q.useState)(t.text),[h,g]=(0,q.useState)(vB(t.scope)),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(o),x=(0,q.useRef)(null);(0,q.useEffect)(()=>{s&&x.current!==null&&(x.current.focus(),x.current.setSelectionRange(x.current.value.length,x.current.value.length))},[]);let S=n.find(e=>e.key===h)??n[0],C=p.trim().length,w=C-300,T=async e=>{if(e.preventDefault(),_||S===void 0)return;if(C===0)return b(xB);if(w>0)return b(SB(w));v(!0),b(null);let t=await c({kind:d,text:p.trim(),scope:S.scope});v(!1),b(t)};return(0,J.jsxs)(`form`,{"aria-label":e,"data-slot":`preference-form`,className:`flex flex-col gap-2.5`,onSubmit:e=>void T(e),noValidate:!0,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[r?(0,J.jsx)(pB,{kind:d}):(0,J.jsxs)(`fieldset`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`legend`,{className:`sr-only`,children:`Kind`}),CB.map(e=>{let{label:t,icon:n}=fB[e];return(0,J.jsxs)(Bj,{variant:`outline`,size:`sm`,pressed:d===e,onPressedChange:t=>{t&&f(e)},children:[(0,J.jsx)(n,{"aria-hidden":`true`}),t]},e)})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{id:`${u}-scope`,className:`shrink-0 text-caption text-muted-foreground`,children:`Applies to`}),n.length>1&&S!==void 0?(0,J.jsxs)(aB,{value:S.key,items:n.map(e=>({value:e.key,label:e.label})),onValueChange:e=>{typeof e==`string`&&g(e)},children:[(0,J.jsx)(sB,{size:`sm`,className:`max-w-64 min-w-0`,"aria-labelledby":`${u}-scope`,children:(0,J.jsx)(oB,{})}),(0,J.jsx)(cB,{alignItemWithTrigger:!1,align:`start`,children:n.map(e=>(0,J.jsx)(lB,{value:e.key,children:e.label},e.key))})]}):(0,J.jsx)(`span`,{className:`truncate`,children:S?.label.toLowerCase()})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`label`,{htmlFor:`${u}-text`,className:`text-caption font-medium`,children:wB[d].label}),(0,J.jsx)($O,{ref:x,id:`${u}-text`,rows:2,className:`min-h-14 bg-card`,placeholder:wB[d].example,value:p,onChange:e=>{m(e.target.value.replace(/\s*\n\s*/g,` `)),b(null)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"aria-invalid":y!==null||w>0,"aria-describedby":`${u}-count ${u}-problem`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-3 text-caption`,children:[(0,J.jsx)(`span`,{id:`${u}-problem`,role:`status`,className:`min-w-0 flex-1 text-destructive`,children:y!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),y]})}),(0,J.jsxs)(`span`,{id:`${u}-count`,"data-slot":`character-count`,className:X(`tabular shrink-0`,w>0?`text-destructive`:`text-muted-foreground`),children:[C,`/`,300,(0,J.jsx)(`span`,{className:`sr-only`,children:` characters`}),w>0&&`, ${w} too many`]})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[l!==void 0&&(0,J.jsx)($,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,J.jsx)($,{type:`submit`,size:`sm`,disabled:_,focusableWhenDisabled:!0,"aria-busy":_,children:_?a:i})]})]})},EB=({title:e,onClose:t,children:n,className:r,returnFocus:i=()=>!0})=>{let a=(0,q.useRef)(null);return(0,J.jsx)(BA,{open:!0,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(UA,{ref:a,className:X(`max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg`,r),initialFocus:()=>a.current?.querySelector(`[data-autofocus]`)??!0,finalFocus:()=>i(),children:[(0,J.jsx)(WA,{className:`shrink-0 pr-8`,children:(0,J.jsx)(GA,{children:e})}),n]})})},DB=({preference:e,onDelete:t,onClose:n})=>{let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null);return(0,J.jsxs)(EB,{title:`Delete preference`,onClose:n,children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(pB,{kind:e.kind}),(0,J.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}),(0,J.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:`AI reviews stop using it. A review already made keeps what it says of it.`}),a!==null&&(0,J.jsxs)(`p`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[`Couldn't delete it. `,a]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:n,children:`Cancel`}),(0,J.jsx)($,{variant:`destructive`,disabled:r,onClick:async()=>{i(!0);let e=await t();i(!1),o(e),e===null&&n()},children:r?`Deleting…`:`Delete`})]})]})},OB=({preference:e,scopes:t,actions:n})=>{let[r,i]=(0,q.useState)(`shown`),[a,o]=(0,q.useState)(null),s=bB(r===`editing`),{id:c,kind:l,text:u,source:d,enabled:f}=e;return r===`editing`?(0,J.jsx)(`li`,{className:`bg-surface-subtle px-4 py-3`,children:(0,J.jsx)(TB,{legend:`Edit: ${u}`,initial:e,scopes:t,submit:`Save`,submitting:`Saving…`,onCancel:()=>i(`shown`),onSubmit:async e=>{let t=await n.onEdit(c,e);return t===null&&i(`shown`),t}})}):(0,J.jsxs)(`li`,{"data-slot":`preference`,"data-enabled":f,className:`flex min-h-11 flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2`,children:[(0,J.jsx)(pB,{kind:l}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-56 break-words`,!f&&`text-muted-foreground`),children:u}),(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[mB[d],!f&&` · off`]}),(0,J.jsx)(ZN,{checked:f,"aria-label":`Use in AI reviews: ${u}`,onCheckedChange:async e=>{o(null),o(await n.onSwitch(c,e))}}),(0,J.jsxs)(UR,{children:[(0,J.jsx)(WR,{render:(0,J.jsx)($,{ref:s,variant:`ghost`,size:`icon-xs`,"aria-label":`More for: ${u}`}),children:(0,J.jsx)(Qh,{"aria-hidden":`true`})}),(0,J.jsxs)(GR,{align:`end`,className:`w-36`,children:[(0,J.jsxs)(JR,{onClick:()=>i(`editing`),children:[(0,J.jsx)(Qg,{"aria-hidden":`true`}),`Edit`]}),(0,J.jsxs)(JR,{variant:`destructive`,onClick:()=>i(`deleting`),children:[(0,J.jsx)(g_,{"aria-hidden":`true`}),`Delete…`]})]})]})]}),a!==null&&(0,J.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),a]}),r===`deleting`&&(0,J.jsx)(DB,{preference:e,onDelete:()=>n.onDelete(c),onClose:()=>i(`shown`)})]})},kB=({preferences:e,scopes:t,actions:n,label:r})=>(0,J.jsx)(`ul`,{"aria-label":r,className:`divide-y`,children:e.map(e=>(0,J.jsx)(OB,{preference:e,scopes:t,actions:n},e.id))}),AB=({option:e,title:t,word:n,preferences:r,scopes:i,actions:a,addable:o=!0,adding:s,onAdding:c,onAdd:l,empty:u,children:d})=>{let f=(0,q.useId)(),p=(0,q.useRef)(null),m=()=>{c(!1),p.current?.focus()};return(0,J.jsxs)(`section`,{"aria-labelledby":f,"data-slot":`preference-scope`,className:`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2`,children:[(0,J.jsx)(`h2`,{id:f,className:`flex min-w-0 items-center gap-2 text-heading font-semibold`,children:t}),(0,J.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:r.length}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[r.length,` `,r.length===1?`preference`:`preferences`]})]}),(0,J.jsx)(`span`,{className:`min-w-0 text-caption text-muted-foreground max-sm:order-last max-sm:basis-full`,children:n}),o&&(0,J.jsxs)($,{ref:p,variant:`outline`,size:`sm`,className:`ml-auto`,"aria-expanded":s,"aria-label":e.scope.kind===`repo`?`Add preference for ${e.label}`:void 0,onClick:()=>c(!s),children:[(0,J.jsx)(e_,{"aria-hidden":`true`}),`Add preference`]})]}),s&&(0,J.jsx)(`div`,{className:`border-b bg-surface-subtle px-4 py-3`,children:(0,J.jsx)(TB,{legend:`Add a preference`,initial:{kind:`look-for`,text:``,scope:e.scope},scopes:i,submit:`Add preference`,submitting:`Adding…`,focus:!0,onCancel:m,onSubmit:async e=>{let t=await l(e);return t===null&&m(),t}})}),r.length===0?u:(0,J.jsx)(kB,{preferences:r,scopes:i,actions:a,label:`Preferences for ${e.label.toLowerCase()}`}),d]})},jB={learned:`from what you did in reviews`,imported:`from your past reviews`},MB=({proposal:e,scopes:t,actions:n})=>{let{id:r,kind:i,text:a,scope:o,evidence:s}=e,c=a.length-300,[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),h=bB(l!==null),g=t.find(e=>e.key===vB(o))?.label??`Everywhere`,_=async e=>{if(d!==null)return;if(e===`accept`&&c>0)return u({note:SB(c)});f(e),m(null);let t=await(e===`accept`?n.onAccept(r,null):n.onReject(r));f(null),m(t)};return l===null?(0,J.jsxs)(`li`,{"data-slot":`proposal`,className:`flex flex-col gap-1.5 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(pB,{kind:i}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 font-medium break-words`,children:a}),(0,J.jsxs)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:[g,`, `,jB[e.source]]})]}),s.length>0&&(0,J.jsxs)(`div`,{className:`flex gap-1.5 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`shrink-0`,children:`Based on:`}),(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col`,children:[...new Set(s)].map(e=>(0,J.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[p!==null&&(0,J.jsxs)(`span`,{role:`alert`,className:`min-w-0 flex-1 text-caption text-destructive`,children:[(0,J.jsx)(v_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),p]}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,"aria-label":`Reject: ${a}`,"aria-busy":d===`reject`,onClick:()=>void _(`reject`),children:d===`reject`?`Rejecting…`:`Reject`}),(0,J.jsx)($,{ref:h,variant:`outline`,size:`sm`,"aria-label":`Edit: ${a}`,onClick:()=>u({note:null}),children:`Edit`}),(0,J.jsx)($,{size:`sm`,"aria-label":`Accept: ${a}`,"aria-busy":d===`accept`,onClick:()=>void _(`accept`),children:d===`accept`?`Accepting…`:`Accept`})]})]}):(0,J.jsx)(`li`,{className:`bg-surface-subtle px-4 py-3`,children:(0,J.jsx)(TB,{legend:`Edit the suggestion: ${a}`,initial:e,scopes:t,submit:`Accept`,submitting:`Accepting…`,note:l.note,onCancel:()=>u(null),onSubmit:e=>n.onAccept(r,e)})})},NB=({proposals:e,scopes:t,actions:n,fallbackFocus:r})=>{let i=(0,q.useId)(),a=(0,q.useRef)(null),o=()=>(e.length>1?a.current:r?.current)?.focus(),s=e=>e.then(e=>(e===null&&o(),e)),c={onAccept:(e,t)=>s(n.onAccept(e,t)),onReject:e=>s(n.onReject(e))};return e.length===0?null:(0,J.jsxs)(`section`,{ref:a,tabIndex:-1,"aria-labelledby":i,"data-slot":`suggested`,className:`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2`,children:[(0,J.jsx)(`h2`,{id:i,className:`text-heading font-semibold`,children:`Suggested`}),(0,J.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:e.length}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[e.length,` `,e.length===1?`suggestion`:`suggestions`]})]}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`None is used until you accept it. A rejected one isn't suggested again.`})]}),(0,J.jsx)(`ul`,{className:`divide-y`,children:e.map(e=>(0,J.jsx)(MB,{proposal:e,scopes:t,actions:c},e.id))})]})},PB=`Nothing new to suggest from: megareviewer records the points you dismiss and raise and the comments you post.`,FB=()=>(0,J.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading your preferences`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(zN,{className:`h-7 w-56 motion-reduce:animate-none`}),[3,2].map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,J.jsx)(`div`,{className:`flex h-11 items-center border-b px-4`,children:(0,J.jsx)(zN,{className:`h-4 w-32 motion-reduce:animate-none`})}),(0,J.jsx)(`ul`,{"aria-hidden":`true`,className:`flex flex-col gap-3 px-4 py-3`,children:Array.from({length:e},(e,t)=>(0,J.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(zN,{className:`h-5 w-20 rounded-full motion-reduce:animate-none`}),(0,J.jsx)(zN,{className:`h-4 flex-1 motion-reduce:animate-none`}),(0,J.jsx)(zN,{className:`h-4 w-12 motion-reduce:animate-none`})]},t))})]},e))]}),IB=()=>(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`A preference is one rule for AI reviews: something to look for, or something not to flag. For example `,(0,J.jsx)(pB,{kind:`look-for`,className:`align-middle`}),` “Tenant isolation: every query filters by tenant ID”, or `,(0,J.jsx)(pB,{kind:`dont-flag`,className:`align-middle`}),` “Naming”.`]}),LB=({now:e=Date.now})=>{let{client:t}=yp(),n=tL(PF().status?.model??null),r=Tp(),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null);r.preferences!==i&&(a(r.preferences),s(r.preferences));let[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),f=(0,q.useRef)(null),p=e=>s(t=>t===null?t:e(t)),m=(e,t,n)=>e.ok?(p(n=>t(n,e.value)),d(n),null):dL(e.error),h=async e=>m(await t.addPreference(e),nL,`Added: ${e.text}`),g={onSwitch:async(e,n)=>m(await t.updatePreference(e,{enabled:n}),nL,n?`Switched on`:`Switched off`),onEdit:async(e,n)=>m(await t.updatePreference(e,n),nL,`Saved: ${n.text}`),onDelete:async e=>m(await t.deletePreference(e),t=>rL(t,e),`Deleted`)},_={onAccept:async(e,n)=>m(await t.decideProposal(e,{decision:`accept`,...n}),(t,{preference:n})=>{let r=aL(t,e);return n===null?r:nL(r,n)},`Accepted`),onReject:async e=>m(await t.decideProposal(e,{decision:`reject`}),t=>aL(t,e),`Rejected`)},v=async e=>{let n=await t.suggestPreferences(e===void 0?{}:{optionId:e});if(!n.ok)return{ok:!1,message:dL(n.error)};let{proposals:r,signals:i}=n.value;return p(e=>({...iL(e,r),signalsSinceSuggestion:0})),{ok:!0,said:r.length===0?`Nothing new to suggest from ${fL(i,`action`)}.`:`${fL(r.length,`suggestion`)} from ${fL(i,`action`)}, above.`}},y=async(e,n)=>{let r=await t.importPreferences({repo:e,...n===void 0?{}:{optionId:n}});if(!r.ok)return{ok:!1,message:dL(r.error)};let{proposals:i,comments:a,pullRequests:o}=r.value;if(p(e=>iL(e,i)),a===0)return{ok:!0,said:o===0?`Found no pull request of this repository that you reviewed.`:`Found no comment of yours on its last ${fL(o,`pull request`)}.`};let s=`Read ${fL(a,`comment`)} from ${fL(o,`pull request`)}`;return{ok:!0,said:i.length===0?`${s}: nothing new to suggest.`:`${s}: ${fL(i.length,`suggestion`)}, above.`}},b=async(e,n,r)=>m(await t.setGuidelineSwitch({repo:e,path:n,enabled:r}),t=>oL(t,e,n,r),r?`${n} switched on`:`${n} switched off`);return(0,J.jsxs)(`div`,{"data-slot":`preferences-page`,className:`mx-auto flex max-w-[960px] flex-col gap-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h1`,{ref:f,tabIndex:-1,className:`text-title font-semibold tracking-[-0.01em]`,children:`Preferences`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`What you want an AI review to look for and to leave out. Used by Request AI review.`})]}),(()=>{if(o===null)return r.loading||r.error===null?(0,J.jsx)(FB,{}):(0,J.jsxs)(`div`,{className:X(LN,`flex flex-wrap items-center justify-between gap-2`),role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`Couldn't read your preferences. `,Ap(r.error)]}),(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:r.refresh,children:`Try again`})]});let t=cL(o),i=yB(t.map(e=>e.repo)),[a]=i;if(a===void 0)return null;let s=o.preferences.length===0,u=o.signalsSinceSuggestion;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(NB,{proposals:o.proposals,scopes:i,actions:_,fallbackFocus:f}),(0,J.jsx)(az,{label:`Suggest from my reviews`,running:`Reading what you did in reviews…`,icon:(0,J.jsx)(f_,{"aria-hidden":`true`}),choice:n,blocked:u===0?PB:null,idle:u===0?PB:`${fL(u,`action`)} recorded since the last suggestions`,run:v,now:e}),(0,J.jsx)(AB,{option:a,title:`Everywhere`,word:`Used on every pull request`,preferences:sL(o,hB),scopes:i,actions:g,addable:!s,adding:!s&&c===a.key,onAdding:e=>l(e?a.key:null),onAdd:h,empty:s?(0,J.jsxs)(`div`,{"data-slot":`no-preferences`,className:`flex flex-col gap-3 px-4 py-4`,children:[(0,J.jsx)(IB,{}),(0,J.jsx)(TB,{legend:`Add a preference`,initial:{kind:`look-for`,text:``,scope:hB},scopes:i,submit:`Add preference`,submitting:`Adding…`,onSubmit:h})]}):(0,J.jsx)(`p`,{className:`px-4 py-3 text-caption text-muted-foreground`,children:`No preference for every repository yet.`})}),t.map(({repo:t,guidelineFiles:r,guidelineNote:s})=>{let u=i.find(e=>e.key===_B(t))??a;return(0,J.jsxs)(AB,{option:u,title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:gB(t)}),(0,J.jsx)(eO,{variant:`outline`,className:`font-normal text-muted-foreground`,children:_F[t.host]})]}),word:`Used on its pull requests, after the ones for everywhere`,preferences:sL(o,u.scope),scopes:i,actions:g,adding:c===u.key,onAdding:e=>l(e?u.key:null),onAdd:h,empty:(0,J.jsx)(`p`,{className:`px-4 py-3 text-caption text-muted-foreground`,children:`No preference for this repository yet.`}),children:[(0,J.jsx)(hL,{files:r,note:s,repository:gB(t),onSwitch:(e,n)=>b(t,e,n)}),(0,J.jsx)(`div`,{className:`border-t px-4 py-3`,children:(0,J.jsx)(az,{label:`Import from my past reviews`,running:`Reading your comments on ${gB(t)}…`,icon:(0,J.jsx)(n_,{"aria-hidden":`true`}),choice:n,what:`Reads your own comments on its recent pull requests on ${_F[t.host]}, then runs`,run:e=>y(t,e),now:e})})]},u.key)})]})})(),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})},RB=[`import`,`call`,`type`,`request`],zB=e=>e.slice(e.lastIndexOf(`/`)+1),BB=(e,t)=>e<t?-1:+(e>t),VB=e=>/\.(md|mdx|rst|adoc)$/i.test(e),HB=/(^|[/_.-])(fakes?|mocks?|stubs?|fixtures?|testing|test[_-]?(utils?|helpers?|support))([/_.-]|$)/i,UB=e=>XP(e).split(`/`).slice(0,3).join(`/`),WB=e=>`group:${e}`,GB=e=>{let t=new Map(e.map(e=>[e,e.split(`/`)])),n=(e,n)=>(t.get(e)??[]).slice(-n).join(`/`),r=new Map;for(let i of e){let a=t.get(i)?.length??1,o=1;for(;o<a&&e.some(e=>e!==i&&n(e,o)===n(i,o));)o+=1;r.set(i,n(i,o))}return r},KB=`\0routes`,qB=e=>`${e.method} ${e.path}`,JB=e=>{let[t]=e;return e.length===1&&t!==void 0?`${t.method} ${t.path}`:`${e.length} routes`},YB=(e,t)=>{let n=al(e.parts),r=new Map(e.files.flatMap(e=>ol(e,n).map(({id:t,hunk:n})=>[t,{file:e,hunk:n}]))),i=new Map,a=(e,t)=>{let n=i.get(e)??[];n.includes(t)||i.set(e,[...n,t])},o=new Map;for(let e of t){let t=new Map;for(let n of e.entries){let e=r.get(n)?.file.path;e!==void 0&&t.set(e,[...t.get(e)??[],n])}for(let[n,i]of t){let t=i.flatMap(e=>{let t=r.get(e),n=t===void 0?null:Ku(t.file,t.hunk,[]);return n?.kind===`route`?n.routes:[]});if(t.length>0&&(a(n,KB),o.set(n,[...o.get(n)??[],...t])),!(new Set(t.map(qB)).size===i.length&&t.length>0))for(let t of(e.codeTitle??e.title).split(`; `)){t.startsWith(`Page: `)&&a(n,t);let e=/^Command: (\S+) in (.+)$/.exec(t);e!==null&&e[2]===zB(n)&&a(n,`Command: ${e[1]}`)}}}return new Map([...i].map(([e,t])=>{let n=[...new Map((o.get(e)??[]).map(e=>[qB(e),e])).values()];return[e,t.map(e=>e===KB?JB(n):e)]}))},XB=(e,t)=>{let n=new Map,r=new Map,i=[],a=new Set,o=[],s=0,c=e=>{n.set(e,s),r.set(e,s),s+=1,i.push(e),a.add(e);for(let i of t(e))n.has(i)?a.has(i)&&r.set(e,Math.min(r.get(e)??0,n.get(i)??0)):(c(i),r.set(e,Math.min(r.get(e)??0,r.get(i)??0)));if(r.get(e)!==n.get(e))return;let l=[];for(let t=i.pop();t!==void 0&&(a.delete(t),l.push(t),t!==e);t=i.pop());l.length>1&&o.push(l)};for(let t of e)n.has(t)||c(t);return o},ZB=()=>({uses:new Set,symbols:new Set,pairs:0}),QB=e=>{let t=new Set(e.proofs.flatMap(e=>e.hunkId??[])),n=e.files.filter(e=>e.hunks.some(e=>!t.has(e.id))),r=new Map(n.flatMap(e=>e.hunks.map(t=>[t.id,e.path]))),i=new Set(n.map(e=>e.path)),a=new Map,o=(e,t,n,r)=>{if(e===t||!i.has(e)||!i.has(t))return;let o=a.get(e)??new Map,s=o.get(t)??{...ZB(),pairs:1};s.uses.add(n),r!==void 0&&s.symbols.add(r),o.set(t,s),a.set(e,o)};for(let{from:t,to:n}of e.fileLinks)o(t,n,`import`);for(let t of e.callGraph){let e=r.get(rl(t.fromPartId)),n=r.get(rl(t.toPartId));e!==void 0&&n!==void 0&&o(e,n,t.use,t.symbol)}return{mechanical:t,files:n,pathOfHunk:r,links:a}},$B=(e,t,n=new Set)=>{let{mechanical:r,files:i,pathOfHunk:a,links:o}=QB(e),s=[...new Set(t.flatMap(e=>e.partIds))],c=new Map(s.map((e,t)=>[e,t])),l=e=>c.get(e)??s.length,u=new Set(e.generated),d=new Map(i.map(t=>{let n=t.hunks.flatMap(e=>e.lines),i=ol(t,al(e.parts)).map(e=>e.id).filter(e=>!r.has(rl(e))).sort((e,t)=>l(e)-l(t)),a=t.hunks.every(e=>r.has(e.id))?`mechanical`:`logic`;return[t.path,{added:n.filter(e=>e.kind===`add`).length,deleted:n.filter(e=>e.kind===`del`).length,partIds:i,risk:a,rank:i.reduce((e,t)=>Math.min(e,l(t)),1/0)}]})),f=e=>d.get(e)?.rank??1/0,p=(e,t)=>f(e)-f(t)||BB(e,t),m=i.map(e=>e.path).sort(p),h=e=>[...o.get(e)?.keys()??[]],g=e=>m.filter(t=>o.get(t)?.has(e)===!0),_=new Set(m.filter(ul));for(let e=!0;e;){e=!1;for(let t of m){let n=g(t);!_.has(t)&&HB.test(t)&&n.length>0&&n.every(e=>_.has(e))&&(_.add(t),e=!0)}}let v=m.filter(e=>!_.has(e)&&VB(e)),y=m.filter(e=>!_.has(e)&&!VB(e)),b=new Set(y),x=new Map;for(let e of[..._].sort(p)){let t=[],n=new Set([e]),r=e=>{for(let i of h(e))n.has(i)||(n.add(i),b.has(i)?t.push(i):r(i))};r(e),x.set(e,t)}let S=new Map;for(let[e,t]of x)for(let n of t)S.set(n,[...S.get(n)??[],e]);let C=[..._].filter(e=>(x.get(e)??[]).length===0),w=new Map;for(let e of[...y,...v,...C].sort(YP)){let t=WB(XP(e)),r=n.has(t)?e:t;w.set(r,[...w.get(r)??[],e])}let T=new Map;for(let[e,t]of w)for(let n of t)T.set(n,e);let E=e=>Math.min(...(w.get(e)??[e]).map(f)),D=(e,t)=>E(e)-E(t)||BB(e,t),O=[...w.keys()].sort(D),k=new Map;for(let[e,t]of o)for(let[n,r]of t){let t=T.get(e),i=T.get(n);if(t===void 0||i===void 0||t===i)continue;let a=k.get(t)??new Map,o=a.get(i)??ZB();for(let e of r.uses)o.uses.add(e);for(let e of r.symbols)o.symbols.add(e);o.pairs+=r.pairs,a.set(i,o),k.set(t,a)}let A=new Map;for(let{partId:t,symbol:n,uses:r}of e.unchangedCallers??[]){let e=a.get(rl(t)),i=e===void 0?void 0:T.get(e);if(i!==void 0)for(let e of r){let r=A.get(e.path)??{targets:new Map,uses:0,partIds:new Set},a=r.targets.get(i)??ZB();a.uses.add(e.use),a.symbols.add(n),r.targets.set(i,a),r.uses+=1,r.partIds.add(t),A.set(e.path,r)}}let j=[...A.keys()].sort((e,t)=>Number(ul(e))-Number(ul(t))||BB(e,t)),M=new Map;for(let e of j){let t=j.length>10?`outside:${UB(e)}/`:`outside:${e}`;M.set(t,[...M.get(t)??[],e])}for(let[e,t]of[...M]){let[n]=t;e.endsWith(`/`)&&t.length===1&&n!==void 0&&(M.delete(e),M.set(`outside:${n}`,[n]))}let N=new Map;for(let[e,t]of M){let n=new Map;for(let e of t)for(let[t,r]of A.get(e)?.targets??[]){let e=n.get(t)??ZB();for(let t of r.uses)e.uses.add(t);for(let t of r.symbols)e.symbols.add(t);n.set(t,e)}N.set(e,n)}let P=new Set([...[...k].flatMap(([e,t])=>t.size>0?[e,...t.keys()]:[]),...[...N.values()].flatMap(e=>[...e.keys()])]),F=O.filter(e=>P.has(e)),I=new Set,L=(e,t)=>`${e}\u0000${t}`,R=e=>[...k.get(e)?.keys()??[]].filter(t=>!I.has(L(e,t))),ee=(e,t)=>k.get(e)?.get(t)?.pairs??0;for(let e=XB(F,R);e.length>0;e=XB(F,R))for(let t of e){let[e,n,r]=t;if(e!==void 0&&n!==void 0&&r===void 0&&ee(e,n)!==ee(n,e)){I.add(ee(e,n)<ee(n,e)?L(e,n):L(n,e));continue}let[i]=[...t].sort(D);for(let e of t)i!==void 0&&R(e).includes(i)&&I.add(L(e,i))}let z=new Map(F.map(e=>[e,[]]));for(let e of F)for(let t of R(e))z.get(t)?.push(e);let te=new Map,B=e=>{let t=te.get(e);if(t!==void 0)return t;let n=Math.max(-1,...(z.get(e)??[]).map(B))+1;return te.set(e,n),n},ne=[],V=(e,t)=>{for(;ne.length<=t;)ne.push([]);ne[t]?.push(e)};for(let e of F)V(e,B(e));for(let[e,t]of N){let n=[...t.keys()];z.set(e,n),te.set(e,Math.max(...n.map(B))+1),V(e,te.get(e)??0)}let H=()=>new Map(ne.flatMap(e=>e.map((t,n)=>[t,n-(e.length-1)/2]))),re=e=>R(e),ie=(e,t)=>{for(let n of e){let e=H(),r=n=>{let r=t(n).map(t=>e.get(t)??0);return r.length===0?e.get(n)??0:r.reduce((e,t)=>e+t,0)/r.length},i=new Map(n.map(e=>[e,r(e)]));n.sort((e,t)=>(i.get(e)??0)-(i.get(t)??0)||D(e,t))}},ae=e=>z.get(e)??[];ie(ne.slice(1),ae),ie(ne.slice(0,-1).reverse(),re),ie(ne.slice(1),ae);let oe=GB(m),se=YB(e,t),U=new Map;for(let e of t)if(e.kind===`flow`)for(let t of new Set(e.partIds.flatMap(e=>a.get(rl(e))??[])))U.set(t,[...U.get(t)??[],e.title]);let ce=e=>[...new Set(e)],le=GB(j),ue=(e,t)=>{let n=M.get(e)??[],[r]=n;return{key:e,kind:`outside`,paths:n,label:e.endsWith(`/`)||r===void 0?e.slice(8):le.get(r)??r,added:0,deleted:0,risk:`logic`,generated:!1,entries:[],flows:[],partIds:[...new Set(n.flatMap(e=>[...A.get(e)?.partIds??[]]))],uses:n.reduce((e,t)=>e+(A.get(t)?.uses??0),0),badges:[],row:t}},de=(e,t)=>{if(M.has(e))return ue(e,t);let n=w.get(e)??[e],r=n.flatMap(e=>d.get(e)??[]),i=e.startsWith(`group:`);return{key:e,kind:i?`group`:`file`,paths:n,label:i?`${e.slice(6)||`.`}/`:oe.get(e)??e,added:r.reduce((e,t)=>e+t.added,0),deleted:r.reduce((e,t)=>e+t.deleted,0),risk:r.every(e=>e.risk===`mechanical`)?`mechanical`:`logic`,generated:n.every(e=>u.has(e)),entries:ce(n.flatMap(e=>se.get(e)??[])),flows:ce(n.flatMap(e=>U.get(e)??[])),partIds:r.flatMap(e=>e.partIds).sort((e,t)=>l(e)-l(t)),badges:ce(n.flatMap(e=>S.get(e)??[])).sort(p),uses:0,row:t}},fe=ne.map((e,t)=>e.map(e=>de(e,t))),pe=O.filter(e=>!P.has(e)).map(e=>de(e,-1)),me=new Map;for(let e of[...fe.flat(),...pe])if(e.kind!==`outside`)for(let t of e.paths)me.set(t,e.key);for(let[e,t]of x){let[n]=t,r=n===void 0?void 0:T.get(n);r!==void 0&&me.set(e,r)}return{rows:fe,edges:[...[...k].map(e=>[e,!1]),...[...N].map(e=>[e,!0])].flatMap(([[e,t],n])=>[...t].map(([t,r])=>({from:e,to:t,uses:RB.filter(e=>r.uses.has(e)),symbols:[...r.symbols].sort(BB),back:I.has(L(e,t)),outside:n}))),strip:pe,placeOf:me}},eV=e=>e.kind!==`outside`&&!e.generated&&e.risk!==`mechanical`,tV=e=>e.kind===`group`?e.key.slice(6)||`.`:e.key,nV=e=>{let t=e.rows.map(e=>e.filter(eV)).filter(e=>e.length>0),n=e.strip.filter(eV),r=t.length>0,i=r?t:[n],a=i.flat();if(a.length===0)return null;let o=GB(a.map(tV)),s=8,c=i.map(e=>e.flatMap(e=>s===0?[]:(--s,[{label:o.get(tV(e))??tV(e),entries:e.entries}]))).filter(e=>e.length>0);return{rows:c,linked:r,more:a.length-c.flat().length+(r?n.length:0)}},rV=(e,t)=>{let n=e.flatMap(e=>{let n=t(e.partId);if(n===void 0||ul(n))return[];let r=e.uses.filter(e=>!ul(e.path)).length,i=e.uses.length>r?0:e.more;return r+i===0?[]:[{symbol:e.symbol,uses:r+i}]});return n.length===0?null:{symbols:[...new Set(n.map(e=>e.symbol))],uses:n.reduce((e,t)=>e+t.uses,0)}},iV=e=>e.split(/`([^`\n]+)`/).map((e,t)=>({text:e,code:t%2==1})).filter(e=>e.text!==``),aV=e=>{let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?0:Math.max(0,Math.round((t-e)/1e3))},oV=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`,sV={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},cV=({kind:e,count:t,words:n,at:r,pressed:i,onPressed:a,label:o})=>{let[s,c]=n,l=e===`thread`?Kg:sD[e];return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`point-chip`,"data-kind":e,"data-land":`rise`,"aria-pressed":i,"aria-label":o,style:vh({"--landing-i":r}),onClick:()=>a(!i),className:X(`flex min-h-6 shrink-0 items-center gap-1.5 rounded-full border px-2 text-caption font-medium aria-pressed:border-current aria-pressed:ring-1 aria-pressed:ring-current`,e===`thread`?`border-border bg-background text-foreground`:oD[e].className),children:[(0,J.jsx)(l,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{"data-slot":`count-up`,"aria-hidden":`true`,className:`tabular`,style:vh({"--count":t})}),(0,J.jsx)(`span`,{className:`sr-only`,children:t}),` `,(0,J.jsx)(`span`,{className:`max-xl:sr-only`,children:t===1?s:c})]})]})},lV=({choice:e,starting:t,failed:n,onRun:r})=>{let i=(0,q.useId)(),{chosen:a,locked:o}=e,s=o??(a===null?null:`Runs ${a.modelName} through ${a.via}`),c=(0,J.jsx)($,{variant:n?`outline`:`default`,size:`sm`,"data-slot":`request-review`,disabled:t||o!==null||a===null,focusableWhenDisabled:!0,"aria-describedby":s===null?void 0:i,onClick:r,className:`rounded-r-none`}),l=(0,J.jsxs)(J.Fragment,{children:[o===null?(0,J.jsx)(f_,{"aria-hidden":`true`,className:X(n&&`text-primary`)}):(0,J.jsx)(Wg,{"aria-hidden":`true`}),t?`Starting…`:n?`Try again`:`Request AI review`]});return(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center`,children:[(0,J.jsxs)(uI,{disabled:s===null,children:[(0,J.jsx)(dI,{render:c,children:l}),(0,J.jsxs)(fI,{side:`bottom`,align:`start`,children:[o!==null&&(0,J.jsx)(Pg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),s]})]}),s!==null&&(0,J.jsx)(`span`,{id:i,hidden:!0,children:s}),(0,J.jsx)(nz,{choice:e,disabled:t||e.options.length===0,filled:!n&&o===null})]})},uV=e=>{let t=[`intent`,`findings`,`risk`,`decisions`].filter(t=>e.stages[t]!==`done`);return t.length===0||e.modelError===null?null:`${t.join(`, `)} missing: ${e.modelError.message}`},dV=({analysis:e,choice:t,running:n,startedAt:r,starting:i,error:a,points:o,leftOut:s=0,threads:c=null,narrowed:l,onNarrow:u,onRun:d,children:f})=>{let p=aV(n?r:null),m=Rl(e.modelOption??t.chosen),h=f!=null&&f!==!1,g=e=>(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e,h&&(0,J.jsx)(`span`,{className:X(`flex min-w-0 items-center`,e!==null&&`border-l pl-1.5`),children:f})]});if(n)return g((0,J.jsxs)(`span`,{"data-slot":`claude-running`,role:`status`,className:`flex shrink-0 items-center gap-2 whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(f_,{"aria-hidden":`true`,className:`size-3.5`}),m,` is reading this PR`,(0,J.jsx)(`span`,{className:`tabular text-caption`,children:oV(p)})]}));let _=[`finding`,`risk`,`decision`].map(e=>[e,o.filter(t=>t.kind===e).length]).filter(([,e])=>e>0),v=uV(e),y=_.length+(c===null?0:1),b=e=>({"data-land":`rise`,style:vh({"--landing-i":y+e})});if(o.length>0)return(0,J.jsxs)(`span`,{"data-slot":`claude-receipt`,className:`flex min-w-0 items-center gap-1.5`,children:[_.map(([e,t],n)=>(0,J.jsx)(cV,{kind:e,count:t,words:sV[e],at:n,pressed:l===e,onPressed:t=>u(t?e:null)},e)),c!==null&&(0,J.jsx)(cV,{kind:`thread`,count:c.count,words:c.words,label:c.label,at:_.length,pressed:l===`thread`,onPressed:e=>u(e?`thread`:null)}),(0,J.jsx)(`span`,{...b(0),className:`ml-1 flex min-w-0 items-center border-l pl-1.5`,children:f}),(a??v)!==null&&(0,J.jsx)(`span`,{...b(1),role:`alert`,title:a??v??void 0,className:`min-w-0 truncate text-caption text-destructive`,children:a??v}),Vu(e)&&(0,J.jsx)(`span`,{...b(1),children:(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:i,onClick:d,children:i?`Starting…`:`Try again`})})]});if(!Vu(e))return g(e.stages.findings===`done`?(0,J.jsxs)(`span`,{"data-slot":`claude-receipt`,"data-land":`fade`,className:`shrink-0 whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),m,` found nothing to raise`,s>0&&`, and left out ${s} by your preferences`]}):null);let x=e.modelError;return g((0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(lV,{choice:t,starting:i,failed:x!==null,onRun:d}),(a??x)!==null&&(0,J.jsx)(`span`,{role:`alert`,title:a??`${m} couldn't finish: ${x?.message}`,className:`min-w-0 truncate text-caption text-destructive`,children:a??`${m} couldn't finish: ${x?.message}`})]}))},fV=e=>`call-${e.partId}-${e.line}-${e.column}`,pV=(e,t,n)=>{let r=new Map;for(let i of e){let e=t.items(i.toPartIds).map(({id:e,hunk:t,file:n})=>({id:e,hunk:t,file:n}));if(e.length===0||!t.parts.has(i.partId))continue;let a={symbol:i.symbol,targets:e},o=fV(i),s=r.get(i.partId)??new Map,c=s.get(i.line)??[];c.some(e=>e.start===i.column)||(c.push({start:i.column,end:i.column+i.length,render:e=>(0,J.jsx)(Oj,{handle:n,payload:a,id:o,children:e})}),s.set(i.line,c),r.set(i.partId,s))}return r},mV=(e,t)=>{let n=e.checkedBy;if(n===void 0)return null;let{hunkId:r,startLine:i}=n.lines,a=t.items(t.partsOf(r)),o=a.filter(({hunk:e})=>e.lines.some(e=>e.kind!==`del`&&e.newLine===i)),s=(o.length>0?o:a).map(({id:e,hunk:t,file:n})=>({id:e,hunk:t,file:n}));return s.length===0?null:{symbol:n.test,targets:s,label:`Test ${n.test}`}},hV=e=>`hunk-${e}`,gV=e=>e===void 0?{}:{marks:e},_V=({id:e,deps:t})=>{let[n]=t.index.items([e]);if(n===void 0)return null;let{hunk:r,file:i,risk:a,proofs:o=[]}=n;return o.length>0?(0,J.jsx)(`div`,{className:vj,children:(0,J.jsx)(Gj,{hunk:r,file:i,risk:a,proofs:o,onFocus:t.onFocusHunk})}):(0,J.jsx)(Tj,{id:e,hunk:r,file:i,risk:a,highlighted:t.highlighted.has(e),onFocus:t.onFocusHunk,unchanged:t.unchangedOf(e),inFile:!0,comments:t.commentsOf(e),openComment:t.openComment?.partId===e?t.openComment.place:null,onOpenComment:t.onOpenComment,...t.onCancelComment===void 0?{}:{onCancelComment:t.onCancelComment},onComment:t.onComment,...t.onCommentNow===void 0?{}:{onCommentNow:t.onCommentNow},afterHeader:t.pointsOn(e),...t.pointLinesOf(e)===void 0?{}:{pointLines:t.pointLinesOf(e)},threadsAt:n=>t.threadsAt(e,n),pointsAt:n=>t.pointsAt(e,n),pointsAtEnd:n=>t.pointsAtEnd(e,n),...t.flaggedOf(e)===void 0?{}:{flagged:t.flaggedOf(e)},...t.rangeNote===void 0?{}:{rangeNote:t.rangeNote},...gV(t.marksOf(e))})},vV=/^#{1,6}\s+/,yV=e=>e.replace(/!?(\[([^\]]+)\])\([^)]*\)/g,`$2`).replace(/(`+)(.*?)\1/g,`$2`).replace(/(\*\*|__|~~)(.*?)\1/g,`$2`).replace(/(^|\s)[*_]([^*_]+)[*_](?=\s|[.,!?]|$)/g,`$1$2`).replace(/^\s*(?:>\s*|[-*+]\s+|\d+[.)]\s+)/,``).replace(/\\([\\`*_{}[\]()#+.!>-])/g,`$1`),bV=e=>{let t=e.split(`
84
+ `).map(e=>e.trim()).filter(e=>e!==``);return yV(t.find(e=>!vV.test(e))??t[0]?.replace(vV,``)??``)},xV=/^(.+?[.!?])\s+(?=[A-Z0-9"'(`[])/,SV=e=>{let t=bV(e);return xV.exec(t)?.[1]??t},CV=`font-medium text-muted-foreground`,wV=({text:e})=>(0,J.jsx)(`span`,{"data-slot":`model-text`,className:`whitespace-pre-line`,children:iV(e).map((e,t)=>e.code?(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.text},t):(0,J.jsx)(`span`,{children:yV(e.text)},t))}),TV=({through:e})=>(0,J.jsxs)(`span`,{"data-slot":`through`,children:[e.rows.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&` → `,e.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&`, `,(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.label}),e.entries.length>0&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.entries.join(`, `),`)`]})]},e.label))]},t)),e.more>0&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,e.more,` more `,e.more===1?`directory`:`directories`]})]}),EV=({reach:e})=>{let t=e.symbols.slice(0,3),n=e.symbols.length-t.length,r=t.map((e,r)=>(0,J.jsxs)(`span`,{children:[r>0&&(r===t.length-1&&n===0?` and `:`, `),(0,J.jsx)(`code`,{className:`font-mono text-code-compact`,children:e})]},e));return(0,J.jsxs)(`span`,{"data-slot":`reach`,children:[`Changes `,r,n>0&&` and ${n} more`,`, used in `,e.uses,` `,e.uses===1?`place`:`places`,` the PR doesn't change.`]})},DV=({lead:e,children:t})=>(0,J.jsxs)(`p`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:CV,children:e}),` `,t]}),OV=({analysis:e,through:t,running:n,onDetails:r})=>{let{intent:i,pullRequest:a}=e,o=i?.mismatches??[],s=a===null?``:SV(a.description),[c,l]=(0,q.useState)(i!==null),[u,d]=(0,q.useState)(!1);i!==null!==c&&(l(i!==null),d(i!==null&&n)),u&&!n&&d(!1);let f=(i!==null||a!==null)&&(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Details`,title:`Details`,onClick:r,className:`ml-1 rounded-full align-middle text-muted-foreground`,children:(0,J.jsx)(Pg,{"aria-hidden":`true`})}),p=new Map(e.files.flatMap(e=>e.hunks.map(t=>[t.id,e.path]))),m=rV(e.unchangedCallers,e=>p.get(rl(e))),h=t!==null&&(0,J.jsx)(DV,{lead:t.linked?`Through:`:`In:`,children:(0,J.jsx)(TV,{through:t})}),g=m!==null&&(0,J.jsx)(DV,{lead:`Watch:`,children:(0,J.jsx)(EV,{reach:m})}),_=a!==null&&(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`p`,{className:`min-w-0`,children:[s===``?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,J.jsx)(`span`,{children:s}),!u&&f]}),h,g]}),v=i!==null&&(0,J.jsxs)(`div`,{"data-arriving":u||void 0,className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`p`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:o.length===0?`font-medium text-review-approved`:`font-medium`,children:o.length>0||i.stated===null?`From the code:`:`✓ Does what was asked:`}),` `,(0,J.jsx)(wV,{text:i.inferred.summary}),f]}),i.inferred.shape===``?h:(0,J.jsx)(DV,{lead:`Through:`,children:(0,J.jsx)(wV,{text:i.inferred.shape})}),i.inferred.watch.length===0?g:(0,J.jsx)(DV,{lead:`Watch:`,children:i.inferred.watch.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&` · `,(0,J.jsx)(wV,{text:e})]},t))})]});return(0,J.jsx)(`div`,{"data-slot":`intent-brief`,className:`flex min-w-0 flex-col gap-1 text-body`,children:v===!1?_:u?(0,J.jsxs)(`div`,{"data-slot":`intent-swap`,className:`min-w-0`,children:[(0,J.jsx)(`div`,{"data-leaving":!0,"aria-hidden":`true`,children:_}),v]}):v})},kV=`rounded-full border bg-muted px-2 py-0.5 text-caption`,AV=({pullRequest:e,tickets:t,missingTicketKeys:n})=>{let r=e.description.trim();return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r===``?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,J.jsx)(`p`,{className:`text-body whitespace-pre-line`,children:r}),(t.length>0||n.length>0)&&(0,J.jsxs)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets`,children:[t.map(e=>(0,J.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:(0,J.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.key,` · `,e.summary]})},e.key)),n.map(e=>(0,J.jsxs)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,title:`Jira didn't return this ticket, or Jira isn't configured`,children:[e,` · not fetched`]},e))]}),e.commits.length>0&&(0,J.jsxs)(`details`,{className:`group`,children:[(0,J.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Commits (`,e.commits.length,`)`]}),(0,J.jsx)(`ol`,{className:`mt-1 flex flex-col gap-1`,children:e.commits.map(e=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`code`,{className:`font-mono text-code-compact text-muted-foreground`,children:e.sha.slice(0,7)}),` `,e.message.split(`
85
85
  `)[0]]},e.sha))})]})]})},jV={description:`Description`,commits:`Commits`,branch:`Branch name`},MV={unrequested:`Unrequested`,missing:`Missing`,contradicts:`Contradicts`},NV={contradicts:`text-review-changes bg-review-changes-bg border-review-changes/25`,missing:`text-review-pending bg-review-pending-bg border-review-pending/25`,unrequested:`text-review-pending bg-review-pending-bg border-review-pending/25`},PV=`whitespace-pre-line`,FV=`text-caption font-medium text-muted-foreground`,IV=({ticketKey:e,ticket:t})=>t===void 0?(0,J.jsxs)(`li`,{className:kV,title:`Jira didn't return this ticket, or Jira isn't configured`,children:[e,` · not fetched`]}):(0,J.jsx)(`li`,{className:kV,children:(0,J.jsxs)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,title:t.summary,children:[t.key,` · `,t.status]})}),LV=({stated:e,ticketOf:t,unfetched:n})=>(0,J.jsxs)(J.Fragment,{children:[e!==null&&(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Sources`,children:e.sources.map(e=>e.kind===`ticket`&&e.ref!==null?(0,J.jsx)(IV,{ticketKey:e.ref,ticket:t.get(e.ref)},`ticket:${e.ref}`):e.kind===`ticket`?null:(0,J.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:jV[e.kind]},e.kind))}),n.length>0&&(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets mentioned but not fetched`,children:n.map(e=>(0,J.jsx)(IV,{ticketKey:e,ticket:void 0},e))})]}),RV=`No stated intent: the PR has no description or linked tickets.`,zV=({intent:e,tickets:t,missingTicketKeys:n,onSelectMismatch:r})=>{let{stated:i,inferred:a,mismatches:o}=e,s=new Map(t.map(e=>[e.key,e])),c=new Set(i?.sources.flatMap(e=>e.ref??[])??[]),l=n.filter(e=>!c.has(e)),u=(0,J.jsx)(LV,{stated:i,ticketOf:s,unfetched:l}),d=o.length===0?i:null,{behaviorChanges:f}=a;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 text-body`,children:[o.length===0?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`p`,{children:[i===null?(0,J.jsx)(`span`,{className:`font-medium`,children:`From the code:`}):(0,J.jsx)(`span`,{className:`font-medium text-review-approved`,children:`✓ Does what was asked:`}),` `,(0,J.jsx)(`span`,{className:PV,children:a.summary})]}),i===null&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:RV}),u]}):(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`h3`,{className:FV,children:`Stated`}),i===null?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:RV}):(0,J.jsx)(`p`,{className:PV,children:i.summary}),u]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`h3`,{className:FV,children:`Inferred from the code`}),(0,J.jsx)(`p`,{className:PV,children:a.summary})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`h3`,{className:FV,children:`Mismatches`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map((e,t)=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full flex-col items-start gap-1 rounded-md border p-2 text-left hover:bg-accent`,onClick:()=>r(t),children:[(0,J.jsxs)(`span`,{className:X(`rounded-full border px-2 text-caption font-medium`,NV[e.kind]),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),MV[e.kind]]}),(0,J.jsx)(`span`,{className:PV,children:e.description})]})},t))})]})]}),(d!==null||f.length>0)&&(0,J.jsxs)(`details`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Details`,f.length>0&&` (${f.length})`]}),d!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:X(FV,`mt-2`),children:`Asked`}),(0,J.jsx)(`p`,{className:PV,children:d.summary})]}),f.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:X(FV,`mt-2`),children:`Behavior changes`}),(0,J.jsx)(`ul`,{className:`list-disc pl-5`,children:f.map((e,t)=>(0,J.jsx)(`li`,{className:PV,children:e},t))})]})]})]})},BV=3,VV=(e,t)=>{let n=e.end??t;return n===null?null:Math.max(0,n-e.start+1)},HV=e=>({head:e.newLines===0?e.newStart+1:e.newStart+e.newLines,base:e.oldLines===0?e.oldStart+1:e.oldStart+e.oldLines}),UV=e=>e.newLines===0?e.newStart+1:e.newStart,WV=e=>{let t=e.lines.at(-1);if(t===void 0||t.noNewlineAtEnd)return!0;let n=0;for(let t=e.lines.length-1;t>=0&&e.lines[t]?.kind===`context`;t--)n++;return n<BV},GV=e=>!e.binary&&e.status!==`added`&&e.status!==`deleted`,KV=(e,t)=>{let n=e.flatMap(e=>{let n=t.parts.get(e);return n===void 0?[]:[{id:e,hunk:n.hunk}]}),r=[],i=n[0];if(i===void 0)return r;let a=UV(i.hunk)-1;a>0&&r.push({before:i.id,after:null,start:1,end:a,offset:0});for(let[e,{id:t,hunk:i}]of n.entries()){let a=HV(i),o=n[e+1],s=a.base-a.head;if(o===void 0){WV(i)||r.push({before:null,after:t,start:a.head,end:null,offset:s});continue}let c=UV(o.hunk)-1;c>=a.head&&r.push({before:o.id,after:t,start:a.head,end:c,offset:s})}return r},qV=(e,t)=>Array.from({length:VV(e,t)??0},(t,n)=>e.start+n),JV=e=>{let t=e.split(`
86
- `);return t.at(-1)===``&&t.pop(),t.map(e=>e.endsWith(`\r`)?e.slice(0,-1):e)},YV=(e,t)=>{let{client:n}=yp(),[r,i]=(0,q.useState)({status:`idle`}),a=(0,q.useRef)(`idle`);return{text:r,load:(0,q.useCallback)(()=>{if(a.current===`loading`||a.current===`ready`)return;let r=e=>{a.current=e.status,i(e)};r({status:`loading`}),n.getFileContent(e,`head`,t).then(e=>r(e.ok?e.value.content===null?{status:`error`,message:`The file isn't at the pull request's head commit.`}:{status:`ready`,lines:JV(e.value.content)}:{status:`error`,message:Ap(e.error)}))},[n,e,t])}},XV=()=>(0,J.jsx)(`svg`,{"data-slot":`unfold-icon`,className:`shrink-0`,viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M8 1.5v4M5.5 3.5 8 1l2.5 2.5M8 14.5v-4M5.5 12.5 8 15l2.5-2.5M2 8h12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}),ZV=e=>`${e} ${e===1?`line`:`lines`}`,QV=(e,t,n,r)=>e.map(e=>({oldNo:e+t.offset,newNo:e,text:n[e-1]??``,tokens:r?.[e-1]??null})),$V=({fold:e,file:t,hunkId:n,opened:r,text:i,onOpen:a,above:o,below:s})=>{let c=i.status===`ready`?i.lines:null,l=Qk(c,t),u=VV(e,c?.length??null);if(u===0)return null;if(r&&c!==null)return(0,J.jsx)(`div`,{"data-slot":`file-fold`,children:(0,J.jsx)(Xj,{hunkId:n,lines:QV(qV(e,c.length),e,c,l)})});let d=r&&i.status===`loading`,f=u===null?`Unchanged lines below`:`${ZV(u)} unchanged`;return(0,J.jsxs)(`div`,{"data-slot":`file-gap`,className:X(`flex flex-wrap items-center bg-surface-subtle text-muted-foreground`,vj,o&&`border-t`,s?`border-b`:`rounded-b-lg`),children:[(0,J.jsxs)(`button`,{type:`button`,"data-slot":`fold-open`,"aria-busy":d||void 0,disabled:d,onClick:a,className:X(`flex min-h-8 flex-1 items-center gap-2 px-3 cursor-pointer text-left -outline-offset-2 hover:bg-accent hover:text-foreground disabled:cursor-wait disabled:hover:bg-transparent`,!s&&`rounded-b-lg`),children:[(0,J.jsx)(XV,{}),d?(0,J.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),`Opening `,u===null?`unchanged lines below`:f]}):(0,J.jsx)(`span`,{children:f})]}),r&&i.status===`error`&&(0,J.jsx)(`span`,{role:`alert`,className:`px-3 text-destructive`,children:i.message})]})},eH=e=>e===`map`?`map`:e===`overview`||e===`tree`?`overview`:void 0,tH=(e,t)=>YP(e.path,t.path),nH=`Not classified yet.`,rH=e=>{let t=al(e.parts),n=new Map,r=new Map;for(let i of e.files){for(let e of i.hunks){let n=t.get(e.id)??[],i=n.map(e=>e.id);r.set(e.id,n.length>0?i:[e.id])}for(let e of ol(i,t)){let r=t.get(e.hunk.id)??[],a=r.findIndex(t=>t.id===e.id),o=r[a];n.set(e.id,{hunk:e.hunk,file:i,place:o===void 0?null:{n:a+1,of:r.length,definitions:o.definitions,siblings:r.map(e=>e.id)}})}}let i=new Map(e.risk.map(e=>[e.hunkId,e])),a=new Map;for(let t of e.proofs)t.hunkId!==null&&a.set(t.hunkId,[...a.get(t.hunkId)??[],t]);let o=new Set(a.keys()),s=e=>{let t=rl(e);return i.get(t)??{hunkId:t,riskClass:`logic`,reason:nH,source:`fallback`,lines:null,guidance:null}},c=e=>e.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[{...t,id:e,hunkId:rl(e),risk:s(e),proofs:a.get(e)??[]}]}),l=e=>r.get(e)??[];return{parts:n,mechanical:o,items:c,partsOf:l,partsInFile:e=>e.hunks.flatMap(e=>l(e.id))}},iH=(e,t)=>[...e.files].sort(tH).flatMap(e=>e.hunks.flatMap(e=>t.partsOf(e.id))).filter(e=>!t.mechanical.has(e)),aH=(e,t)=>{let n=e.tour?.steps??[],r=new Set(n.flatMap(e=>e.partIds)),i=iH(e,t).filter(e=>!r.has(e));return i.length===0?n:[...n,{id:yu.parse(`s${n.length+1}`),title:`Changes the tour left out`,explanation:`The tour didn't include these changes, so they're shown here in file order.`,partIds:i,kind:`supporting`,via:[],entries:[],codeTitle:null,merged:[]}]},oH=(e,t)=>[...e.files].sort((e,t)=>YP(e.path,t.path)).flatMap(e=>{let n=t.partsInFile(e);return n.every(e=>t.mechanical.has(e))?[]:[{file:e,partIds:n}]}),sH=(e,t,n)=>{let r=n.parts.get(e),i=n.parts.get(t);if(r===void 0||i===void 0||r.file!==i.file)return null;let a=r.file.status===`deleted`?`old`:`new`,o=e=>a===`old`?{start:e.oldStart,count:e.oldLines}:{start:e.newStart,count:e.newLines},s=o(r.hunk),c=o(i.hunk),l=s.count===0?s.start:s.start+s.count-1,u=c.count===0?c.start+1:c.start;return Math.max(u-l-1,0)},cH=(e,t,n)=>{let r=new Map(t.map((e,t)=>[e,t])),i=new Map,a=new Map,o=new Map,s=[],c=(e,t,n)=>e.set(t,[...e.get(t)??[],n]);for(let t of e){let e=[...new Set(t.hunkIds)].flatMap(n.partsOf).filter(e=>r.has(e)&&!n.mechanical.has(e)).sort((e,t)=>(r.get(e)??0)-(r.get(t)??0)),l=t.lines===null?void 0:lH(t.lines,e,n),[u=l,...d]=l===void 0?e:[l,...e.filter(e=>e!==l)];if(u===void 0){s.push(t);continue}c(i,u,t),o.set(t.id,u);let f=l===void 0?null:rl(u);for(let e of d)rl(e)!==f&&c(a,e,t)}return{cards:i,mentions:a,cardPart:o,unplaced:s}},lH=(e,t,n)=>t.find(t=>n.parts.get(t)?.hunk.lines.some(t=>{let n=_j(t);return n!==null&&n.side===e.side&&n.line===e.startLine})),uH=e=>{let t=new Set,n=0;for(let r of e)r.hunkId===null?n+=1:t.add(r.hunkId);return t.size+n},dH=(e,t)=>{let n=new Set([...t.parts].flatMap(([e,{file:n}])=>t.mechanical.has(e)?[]:[n.path]));return e.proofs.filter(e=>e.hunkId===null||!n.has(e.path))},fH=(e,t)=>{let n=new Map;for(let r of e){let e=t.partsOf(r.hunkId).find(e=>t.parts.get(e)?.hunk.lines.some(e=>{let t=_j(e);return t!==null&&t.side===r.side&&t.line===r.line}));e!==void 0&&n.set(e,[...n.get(e)??[],r])}return n},pH=e=>({files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}),mH=e=>({threads:e.length,unresolved:e.filter(e=>!e.resolved).length}),hH=`mechanical-changes`,gH=e=>`file-${e}`,_H=(0,q.memo)(function({render:e}){return e()},(e,t)=>e.signature===t.signature),vH=({id:e,joined:t,deps:n,signatureOf:r})=>(0,J.jsx)(`div`,{id:hV(e),className:X(`scroll-mt-24`,!t&&`border-t first:border-t-0`),"data-hunk-id":e,children:(0,J.jsx)(_H,{signature:r(e),render:()=>(0,J.jsx)(_V,{id:e,deps:n})})}),yH=({lines:e})=>e===0?null:(0,J.jsx)(`div`,{"data-slot":`file-gap`,className:X(`flex h-8 items-center gap-2 border-t bg-surface-subtle px-3 text-muted-foreground`,vj),children:(0,J.jsxs)(`span`,{children:[e,` `,e===1?`line`:`lines`,` unchanged`]})}),bH=({analysisId:e,group:t,deps:n,signatureOf:r})=>{let i=n.index.items(t.partIds),a=i.reduce((e,t)=>e+Nk(t.hunk).added,0),o=i.reduce((e,t)=>e+Nk(t.hunk).deleted,0),s=n.openThreads(t.file.path),c=n.earlierThreads(t.file.path),{text:l,load:u}=YV(e,t.file.path),[d,f]=(0,q.useState)(new Set),p=(0,q.useMemo)(()=>GV(t.file)?KV(t.partIds,n.index):[],[t,n.index]),m=e=>`${e.after??``}>${e.before??``}`,h=e=>{let r=m(e),i=e.before??e.after,a=i===null?void 0:n.index.parts.get(i);return a===void 0?null:(0,J.jsx)($V,{fold:e,file:t.file,hunkId:a.hunk.id,opened:d.has(r),text:l,above:e.after!==null,below:e.before!==null,onOpen:()=>{u(),f(e=>new Set(e).add(r))}},r)};return(0,J.jsxs)(`section`,{id:gH(t.file.path),"data-slot":`file-card`,className:`scroll-mt-2 rounded-lg border bg-card -outline-offset-2`,"aria-label":t.file.path,"data-path":t.file.path,tabIndex:-1,children:[(0,J.jsxs)(`header`,{"data-slot":`file-card-header`,className:`sticky top-[var(--review-bar-h,0px)] z-10 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-t-lg border-b bg-card px-3 py-2`,children:[(0,J.jsx)(JD,{file:t.file,status:t.file.status,className:`min-w-0 flex-1`}),(0,J.jsx)(YD,{status:t.file.status}),(0,J.jsxs)(`span`,{className:`tabular flex flex-wrap items-center gap-x-1.5 text-caption`,children:[s>0&&(0,J.jsxs)(`span`,{"data-slot":`count-threads`,className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,J.jsx)(sF,{count:s}),(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}),(0,J.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,a]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,o]})]})]})]}),(0,J.jsx)(`div`,{"data-slot":`file-lines`,className:`@container overflow-x-auto rounded-b-lg`,children:(0,J.jsxs)(`div`,{className:`w-max min-w-full`,children:[t.partIds.map((e,i)=>{let a=t.partIds[i-1],o=a===void 0?null:sH(a,e,n.index),s=p.find(t=>t.before===e);return(0,J.jsxs)(q.Fragment,{children:[s===void 0?o!==null&&(0,J.jsx)(yH,{lines:o}):h(s),(0,J.jsx)(vH,{id:e,joined:o===0||s!==void 0,deps:n,signatureOf:r})]},e)}),p.filter(e=>e.before===null).map(h)]})}),c!==null&&(0,J.jsxs)(`section`,{"data-slot":`earlier-comments`,"aria-label":`Earlier comments on ${t.file.path}`,className:`flex flex-col gap-2 border-t bg-surface-subtle px-3 py-2`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Earlier comments`}),c]})]})},xH=({analysis:e,files:t,deps:n,before:r,after:i,trailingProofs:a,mechanicalCount:o,scrollRequest:s,signatureOf:c})=>((0,q.useEffect)(()=>{if(s===null)return;let e=document.getElementById(s.id);if(e===null)return;let t=(e.dataset.hunkId===void 0?null:e.querySelector(`[data-slot=hunk-card], [data-slot=mechanical-toggle]`))??e,n=e.dataset.slot===`decision`;e.scrollIntoView({block:n?`center`:`start`}),t.focus({preventScroll:!0})},[s]),(0,J.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":`Changes`,children:[r,t.map(t=>(0,J.jsx)(bH,{analysisId:e.id,group:t,deps:n,signatureOf:c},t.file.path)),i,(0,J.jsxs)(`div`,{id:hH,className:`flex scroll-mt-2 flex-col gap-4 -outline-offset-2`,tabIndex:-1,children:[o===0&&e.stages.prep===`done`&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No mechanical changes in this pull request.`}),(0,J.jsx)(Kj,{files:e.files,proofs:a,risk:e.risk}),(0,J.jsx)(Yj,{files:e.files})]})]})),SH={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`},CH=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`,wH=e=>`$${e.toFixed(2)}`,TH=e=>e===void 0?`—`:`${(e/1e3).toFixed(1)} s`,EH=e=>e===null?null:`${e.modelName} through ${e.providerName}`,DH=new Intl.ListFormat(`en`,{type:`conjunction`}),OH=e=>{if(e===null)return null;let t=e.preferences.length,n=[...t===0?[]:[`${t} ${t===1?`preference`:`preferences`}`],...e.guidelines.map(e=>e.path)];return n.length===0?null:DH.format(n)},kH=(e,t)=>{let n=EH(e),r=OH(t);return r===null?n:n===null?`With ${r}`:`${n} with ${r}`},AH=e=>e===null?`—`:wH(e),jH=(e,t,n=`Claude`)=>{let r=e.filter(e=>e!==null),i=e.length-r.length,a=t?`on your ${n} plan`:null;if(r.length===0)return a??`cost unknown`;let o=wH(r.reduce((e,t)=>e+t,0)),s=i===0?``:`, cost unknown for ${i} ${i===1?`call`:`calls`}`;return a===null?`${o}${s}`:`≈ ${o} at API prices${s}, ${a}`},MH=e=>e.inputTokens+e.cacheWriteTokens,NH=({usage:e,option:t=null,guidance:n=null})=>{let r=(0,q.useId)();if(e.length===0)return null;let i=t=>e.reduce((e,n)=>e+t(n),0),a=e.some(e=>e.billing===`plan`),o=e.some(e=>e.durationMs!==void 0);return(0,J.jsxs)(`div`,{className:`group relative flex justify-end`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`peer tabular min-h-6 rounded-sm text-caption text-muted-foreground hover:text-foreground`,"aria-describedby":`${r}-breakdown`,children:[kH(t,n)===null?``:`${kH(t,n)} · `,`Usage: `,CH(i(MH)),` tokens in ·`,` `,CH(i(e=>e.cacheReadTokens)),` cache read ·`,` `,CH(i(e=>e.outputTokens)),` out ·`,` `,jH(e.map(e=>e.costUsd),a,Pl(t))]}),(0,J.jsxs)(`table`,{id:`${r}-breakdown`,role:`tooltip`,className:`tabular absolute right-0 bottom-full mb-2 hidden rounded-xl bg-popover p-3 text-caption text-popover-foreground shadow-md ring-1 ring-foreground/10 group-hover:table peer-focus-visible:table [&_td]:px-2 [&_td]:text-right [&_th]:px-2 [&_th]:text-left [&_thead_th]:font-medium [&_thead_th]:text-muted-foreground`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,J.jsx)(`th`,{scope:`col`,children:`In`}),(0,J.jsx)(`th`,{scope:`col`,children:`Cache read`}),(0,J.jsx)(`th`,{scope:`col`,children:`Out`}),(0,J.jsx)(`th`,{scope:`col`,children:a?`At API prices`:`Cost`}),o&&(0,J.jsx)(`th`,{scope:`col`,children:`Time`})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`row`,children:SH[e.pass]}),(0,J.jsx)(`td`,{children:CH(MH(e))}),(0,J.jsx)(`td`,{children:CH(e.cacheReadTokens)}),(0,J.jsx)(`td`,{children:CH(e.outputTokens)}),(0,J.jsx)(`td`,{children:AH(e.costUsd)}),o&&(0,J.jsx)(`td`,{children:TH(e.durationMs)})]},e.pass))})]})]})},PH={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`},FH=e=>{let t=Math.round(e/1e3);return`+${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},IH=e=>{if(e.outcome===`ok`)return`✓ Answered`;if(e.outcome===`failed`)return`✕ Failed: ${e.error?.kind??`unknown`}`;let t=e.problems.length;return`⚠ ${t} ${t===1?`problem`:`problems`}`},LH=e=>[...e].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)||e.attempt-t.attempt),RH=({guidance:e,leftOut:t})=>{let n=OH(e);return n===null?null:(0,J.jsxs)(`section`,{"aria-label":`What the run read beside the code`,className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`h3`,{className:`font-medium`,children:`Read beside the code`}),(0,J.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[n,`, as they were when the run started.`,` `,t===0?`No point was left out by them.`:`${t} ${t===1?`point was`:`points were`} left out by them, folded where ${t===1?`its card`:`their cards`} would be.`,` `,(0,J.jsx)(N_,{to:S_,className:`underline`,children:`Preferences`})]}),(0,J.jsxs)(`ul`,{className:`flex flex-col gap-1 text-ui`,children:[e.preferences.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,J.jsx)(LR,{kind:e.kind}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 break-words`,children:e.text}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.scope.kind===`global`?`Everywhere`:BR(e.scope.repo)})]},e.ref)),e.guidelines.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`font-mono text-code-compact break-all`,children:e.path}),(0,J.jsx)(`span`,{className:`tabular text-caption text-muted-foreground`,children:lL(e.bytes)})]},e.ref))]})]})},zH=({calls:e,option:t,guidance:n=null,leftOut:r=0})=>{let[i,a]=(0,q.useState)(!1),o=LH(e),s=o[0];if(s===void 0)return null;let c=Date.parse(s.startedAt),l=Math.max(...o.map(e=>Date.parse(e.startedAt)+e.durationMs));return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>a(!0),children:`Run details…`}),i&&(0,J.jsxs)(SB,{title:`${Rl(t)}'s calls`,onClose:()=>a(!1),className:`sm:max-w-3xl`,children:[(0,J.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[EH(t)===null?``:`On ${EH(t)}. `,TH(l-c),` from the first call to the end of the last. A call whose answer has problems runs once more, told what they are.`]}),(0,J.jsxs)(`table`,{className:`tabular w-full text-ui [&_td]:px-2 [&_td]:py-1 [&_td]:align-top [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:align-top [&_th]:font-normal [&_thead_th]:font-medium [&_thead_th]:text-muted-foreground`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,J.jsx)(`th`,{scope:`col`,children:`Started`}),(0,J.jsx)(`th`,{scope:`col`,children:`Time`}),(0,J.jsx)(`th`,{scope:`col`,children:`Outcome`})]})}),(0,J.jsx)(`tbody`,{children:o.map(e=>{let t=e.error===null?e.problems:[e.error.message];return(0,J.jsxs)(`tr`,{children:[(0,J.jsxs)(`th`,{scope:`row`,children:[PH[e.pass],e.attempt>1&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` · again`})]}),(0,J.jsx)(`td`,{children:FH(Date.parse(e.startedAt)-c)}),(0,J.jsx)(`td`,{children:TH(e.durationMs)}),(0,J.jsxs)(`td`,{children:[(0,J.jsx)(`span`,{className:e.outcome===`failed`?`text-destructive`:void 0,children:IH(e)}),t.length>0&&(0,J.jsx)(`ul`,{className:`mt-1 list-disc pl-4 text-muted-foreground`,children:t.map(e=>(0,J.jsx)(`li`,{children:e},e))})]})]},`${e.pass}/${e.attempt}/${e.startedAt}`)})})]}),n!==null&&(0,J.jsx)(RH,{guidance:n,leftOut:r})]})]})},BH={logic:`border-risk-logic-solid bg-risk-logic-bg text-risk-logic`,mechanical:`border-risk-mechanical-solid bg-risk-mechanical-bg text-risk-mechanical`},VH=`border-dashed border-input bg-surface-subtle text-muted-foreground`,HH={call:``,import:`[stroke-dasharray:6_4]`,request:`stroke-muted-foreground [stroke-dasharray:12_4_3_4] [stroke-width:2.5]`,type:`[stroke-dasharray:1.5_3] [stroke-linecap:round]`,outside:`[stroke-dasharray:4_4] opacity-60`},UH=56,WH=24,GH=16,KH=120,qH=300,JH=8.6,YH=6.6,XH=6.7,ZH=32,QH=24,$H=20,eU=380,tU=e=>e.slice(e.lastIndexOf(`/`)+1),nU=e=>e===1?`1 use`:`${e} uses`,rU=e=>e===1?`1 file`:`${e} files`,iU=e=>e.kind===`outside`?`${e.paths.length>1?`${rU(e.paths.length)} · `:``}outside the PR · ${nU(e.uses)}`:[e.kind===`group`?rU(e.paths.length):`+${e.added} −${e.deleted}`,...e.entries].join(` · `),aU=e=>{let t=e.badges.reduce((e,t)=>e+tU(t).length*XH+14,0),n=Math.min(Math.max(e.label.length*JH+ZH+(e.kind===`group`&&e.paths.length>1?QH:0),iU(e).length*YH+$H,t+$H),eU),r=KH+Math.sqrt(e.added+e.deleted)*9;return Math.round(Math.max(n,Math.min(r,qH)))},oU=72,sU=(e,t)=>{let n=e.map(e=>e.reduce((e,t,n)=>e+aU(t)+(n>0?WH:0),0)),r=Math.max(0,...n)+32,i=r+(t?oU:0),a=new Map;return e.forEach((e,t)=>{let i=(r-(n[t]??0))/2;for(let n of e){let e=aU(n);a.set(n.key,{x:i,y:GH+t*120,width:e}),i+=e+WH}}),{boxes:a,width:i,height:e.length===0?0:32+e.length*64+(e.length-1)*UH}},cU=e=>e.outside?`outside`:e.uses.includes(`request`)?`request`:e.uses.includes(`call`)?`call`:e.uses.every(e=>e===`import`)?`import`:`type`,lU=(e,t)=>{let n=e=>{let n=t.get(e);return n===void 0?0:n.x+n.width/2},r=(e,r,i)=>{let a=t.get(r),o=[...e].sort((e,t)=>n(i(e))-n(i(t)));return new Map(o.map((e,t)=>[e,a===void 0?0:a.x+a.width*(.5+(o.length===1?0:(t/(o.length-1)-.5)*.5))]))},i=e.filter(e=>!e.back&&!e.outside),a=new Map,o=new Map;for(let e of t.keys()){for(let[t,n]of r(i.filter(t=>t.from===e),e,e=>e.to))a.set(t,n);for(let[t,n]of r(i.filter(t=>t.to===e),e,e=>e.from))o.set(t,n)}return{out:a,into:o}},uU=(e,t,n,r,i=e.x+e.width/2,a=t.x+t.width/2)=>{if(n){let n=e.x+e.width,i=t.x+t.width,a=e.y+32,o=t.y+32,s=r-oU/2;return`M ${n} ${a} C ${s} ${a} ${s} ${o} ${i} ${o}`}if(e.y>t.y){let n=e.y,r=t.y+64,o=Math.max(UH/2,(n-r)/2);return`M ${i} ${n} C ${i} ${n-o} ${a} ${r+o} ${a} ${r}`}let o=e.y+64,s=t.y,c=Math.max(UH/2,(s-o)/2);return`M ${i} ${o} C ${i} ${o+c} ${a} ${s-c} ${a} ${s}`},dU={import:`imports`,call:`calls`,type:`uses types from`,request:`sends requests to`},fU=(e,t)=>{let n=e.uses.map(e=>dU[e]).join(`, `),r=e.symbols.length>0?`: ${e.symbols.join(`, `)}`:``;return`${t(e.from)} ${n} ${t(e.to)}${r}`},pU=({node:e,box:t,active:n,current:r,onOpen:i,onExpand:a,onFocus:o})=>{let s=e.kind===`group`,c=e.kind===`outside`,l=(c?[e.label,iU(e)]:[e.label,s?rU(e.paths.length):null,...e.entries,e.risk,e.generated?`generated`:null,r?`in view in the code`:null]).filter(e=>e!==null).join(`, `);return(0,J.jsxs)(`div`,{"data-slot":`overview-node-box`,className:X(`grid`,t===void 0?`relative`:`absolute`),style:t===void 0?{width:aU(e)}:{left:t.x,top:t.y,width:t.width,height:64},children:[(0,J.jsxs)(`button`,{type:`button`,"data-slot":`overview-node`,"data-risk":c?`outside`:e.risk,"data-generated":e.generated||void 0,"data-active":n||void 0,"data-current":r||void 0,className:X(`grid h-full w-full content-start gap-0.5 overflow-hidden rounded-md border px-2 py-1 text-left text-caption`,c?VH:BH[e.risk],e.generated&&`border-dashed`,n&&`border-primary`,r&&`shadow-[0_0_0_2px_var(--background),0_0_0_4px_var(--primary)]`),"data-key":e.key,"aria-label":l,"aria-current":r?`location`:void 0,title:s?e.label:e.paths.length===1?e.paths[0]:void 0,onClick:()=>i(e),onFocus:()=>o(e),onMouseEnter:()=>o(e),onMouseLeave:()=>o(null),children:[(0,J.jsx)(`span`,{className:X(`flex min-w-0 items-baseline gap-2`,s&&`pr-6`),children:(0,J.jsx)(`span`,{"data-slot":`overview-label`,className:`min-w-0 truncate font-mono text-code-compact font-semibold`,children:e.label})}),(0,J.jsx)(`span`,{className:`truncate`,children:iU(e)}),e.badges.length>0&&(0,J.jsx)(`span`,{className:`flex gap-1 overflow-hidden`,children:e.badges.map(e=>(0,J.jsx)(`span`,{className:`shrink-0 rounded-sm border border-current px-1 font-mono text-kbd`,children:tU(e)},e))})]}),s&&e.paths.length>1&&(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,className:`absolute top-1 right-1 text-current`,"aria-label":`Show the files of ${e.label}`,title:`Show its files`,onClick:()=>a(e),children:(0,J.jsx)(Rg,{"aria-hidden":`true`})})]})},mU=({overview:e,focusKey:t,currentPath:n,onOpen:r,onExpand:i,onCollapse:a,expandedGroups:o,onFocusNode:s})=>{let c=(0,q.useId)(),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(null),{boxes:f,width:p,height:m}=(0,q.useMemo)(()=>sU(e.rows,e.edges.some(e=>e.back)),[e]),h=(0,q.useMemo)(()=>lU(e.edges,f),[e.edges,f]),g=(0,q.useMemo)(()=>new Map([...e.rows.flat(),...e.strip].map(e=>[e.key,e.label])),[e]),_=e=>g.get(e)??e,v=(0,q.useMemo)(()=>[...e.rows,e.strip].filter(e=>e.length>0),[e]);(0,q.useEffect)(()=>d(null),[e]);let y=(0,q.useRef)(-1);(0,q.useEffect)(()=>{if(t===null||y.current===t.n)return;let n=e.placeOf.get(t.key)??t.key,r=l.current?.querySelector(`[data-key="${CSS.escape(n)}"]`);r!=null&&(y.current=t.n,r.focus(),r.scrollIntoView?.({block:`nearest`,inline:`nearest`}))},[t,e]);let b=e=>l.current?.querySelector(`[data-key="${CSS.escape(e)}"]`)?.focus(),x=e=>{let t=e.target.dataset.key;if(t===void 0)return;let n=v.findIndex(e=>e.some(e=>e.key===t)),r=v[n]?.findIndex(e=>e.key===t)??-1,i=e=>{let t=l.current?.querySelector(`[data-key="${CSS.escape(e.key)}"]`)?.getBoundingClientRect();return t===void 0?0:t.left+t.width/2},a;if(e.key===`ArrowRight`)a=v[n]?.[r+1];else if(e.key===`ArrowLeft`)a=v[n]?.[r-1];else if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=v[n+(e.key===`ArrowDown`?1:-1)]??[],o=v[n]?.[r],s=o===void 0?0:i(o);a=[...t].sort((e,t)=>Math.abs(i(e)-s)-Math.abs(i(t)-s))[0]}else return;e.preventDefault(),a!==void 0&&b(a.key)},S=u?.kind===`node`?u.node.key:null,C=e=>e.from===S||e.to===S,w=e=>{e!==null&&s(e.key),d(e===null?null:{kind:`node`,node:e})},T=n===null?null:e.placeOf.get(n)??null,E=e=>({node:e,active:S===e.key,current:T===e.key,onOpen:r,onExpand:e=>i(e.key),onFocus:w});return(0,J.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Overview of the changed files`,ref:l,onKeyDown:x,children:[(0,J.jsxs)(`p`,{"data-slot":`overview-legend`,className:`text-muted-foreground`,children:[`Each box is a directory. Directories that nothing in the pull request calls are on top; each sits below its callers. Solid lines are calls, dash-dot ones HTTP requests to a route, dashed ones imports, dotted ones types. Tests show on the directories they call. The outlined box holds the file last in view in the code.`,e.edges.some(e=>e.outside)&&` Faded files are outside the pull request, under the code whose changes they use.`]}),o.length>0&&(0,J.jsx)(`p`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,J.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>a(e),children:[`Collapse `,e.slice(6),`/`]},e))}),e.rows.length>0?(0,J.jsx)(`div`,{"data-slot":`overview-scroll`,className:`overflow-x-auto rounded-lg border bg-surface-subtle`,children:(0,J.jsxs)(`div`,{"data-slot":`overview-diagram`,className:`relative mx-auto`,style:{width:p,height:m},children:[(0,J.jsxs)(`svg`,{className:`absolute inset-0 overflow-visible`,width:p,height:m,"aria-hidden":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:`${c}-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,className:`fill-input`})})}),e.edges.map(e=>{let t=f.get(e.from),n=f.get(e.to);if(t===void 0||n===void 0)return null;let r=uU(t,n,e.back,p,h.out.get(e),h.into.get(e)),i=C(e)||u?.kind===`edge`&&u.edge===e,a=u!==null&&!i;return(0,J.jsxs)(`g`,{"data-slot":`overview-edge`,"data-style":cU(e),"data-lit":i||void 0,"data-dim":a||void 0,className:X(a&&`opacity-30`),onMouseEnter:()=>d({kind:`edge`,edge:e}),onMouseLeave:()=>d(null),children:[(0,J.jsx)(`path`,{d:r,className:`fill-none stroke-transparent [stroke-width:10]`}),(0,J.jsx)(`path`,{d:r,className:X(`fill-none stroke-input [stroke-width:1.5]`,HH[cU(e)],i&&`stroke-primary [stroke-width:2]`),markerEnd:`url(#${c}-arrow)`}),(0,J.jsx)(`title`,{children:fU(e,_)})]},`${e.from}>${e.to}`)})]}),e.rows.flat().map(e=>(0,J.jsx)(pU,{box:f.get(e.key),...E(e)},e.key))]})}):(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No changed file calls or imports another.`}),e.strip.length>0&&(0,J.jsxs)(`section`,{"aria-label":`Not linked`,className:`flex flex-col gap-2`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Not linked`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.strip.map(e=>(0,J.jsx)(pU,{...E(e)},e.key))})]}),(0,J.jsx)(`p`,{"data-slot":`overview-detail`,className:`min-h-5 text-muted-foreground`,"aria-live":`polite`,children:u===null?`Hover or focus a directory to see its files, flows and tests.`:u.kind===`edge`?fU(u.edge,_):hU(u.node,e.edges,_)})]})},hU=(e,t,n)=>{let r=t.filter(t=>t.from===e.key).map(e=>{let t=e.symbols.length>0?` (${e.symbols.join(`, `)})`:``;return`${n(e.to)}${t}`});return e.kind===`outside`?`${e.paths.length>1?`${e.label}: ${e.paths.length} files`:e.paths[0]} · outside the pull request · uses ${r.join(`, `)}.`:`${[e.kind===`group`?`${e.label}: ${e.paths.map(tU).join(`, `)}`:e.paths[0],e.flows.length>0?`read in ${e.flows.join(`; `)}`:`in no flow`,...r.length>0?[`reaches ${r.join(`, `)}`]:[],...e.badges.length>0?[`tested in ${e.badges.map(tU).join(`, `)}`]:[]].join(` · `)}.`},gU=e=>`point-${e}`,_U={contradicts:`Contradicts what was asked`,missing:`Asked for, not done`,unrequested:`Done, not asked for`},vU={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},yU=({kind:e})=>{let t=sD[e];return(0,J.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 font-medium`,vU[e]),children:[(0,J.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),oD[e].label]})},bU=({point:e,state:t,current:n,note:r,action:i,className:a,leftOut:o=!1})=>{let s=sD[e.kind];return(0,J.jsxs)(`article`,{id:gU(e.id),"data-slot":`point`,"data-kind":e.kind,"data-state":t,"data-left-out":o||void 0,"data-current":n||void 0,"aria-label":e.title,className:X(`flex scroll-mt-24 flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground`,a,n&&MU),children:[(0,J.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[oD[e.kind].label,`: `]}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-40 truncate`,t===`dismissed`&&`line-through`),children:e.title}),(0,J.jsx)(`span`,{className:`max-w-full min-w-0 truncate text-caption`,children:r}),i]})},xU=({effect:e,preferenceId:t})=>{let n=t===null?``:` your preference:`;return e===`raised`?`From${n}`:`Left out by${n}`},SU=({guidance:e,className:t})=>{let n=e.preferenceId===null?cg:u_;return(0,J.jsxs)(`p`,{"data-slot":`point-guidance`,"data-effect":e.effect,className:X(`flex items-start gap-1.5 text-caption text-muted-foreground`,t),children:[(0,J.jsx)(n,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[xU(e),` `,(0,J.jsx)(N_,{to:S_,className:X(`underline`,e.preferenceId===null&&`font-mono text-code-compact`),children:e.label})]})]})},CU=({point:e,guidance:t,state:n,current:r,onShow:i})=>(0,J.jsx)(bU,{point:e,state:n,current:r,leftOut:!0,note:`${xU(t)} ${t.label}`,className:FU,action:(0,J.jsx)($,{variant:`ghost`,size:`xs`,"aria-label":`Show: ${e.title}`,onClick:i,children:`Show`})}),wU=(e,t,n)=>{let r=(0,q.useRef)(null),i=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{!e&&i.current&&(i.current=!1,r.current?.focus())},[e]),{card:r,show:()=>{i.current=!0,t(n)}}},TU=({point:e,size:t,disabled:n,onDismiss:r,onRule:i})=>(0,J.jsxs)(`span`,{className:`flex items-center`,children:[(0,J.jsxs)($,{variant:`ghost`,size:t,disabled:n,"aria-label":`Dismiss: ${e.title}`,className:`rounded-r-none`,onClick:r,children:[t===`sm`&&(0,J.jsx)(b_,{"aria-hidden":`true`}),`Dismiss`]}),(0,J.jsxs)(fB,{children:[(0,J.jsx)(pB,{render:(0,J.jsx)($,{variant:`ghost`,size:t,"data-slot":`dismiss-menu`,disabled:n,"aria-label":`More ways to dismiss: ${e.title}`,className:`w-6 rounded-l-none px-0`}),children:(0,J.jsx)(Bh,{"aria-hidden":`true`})}),(0,J.jsx)(mB,{align:`end`,className:`w-64`,children:(0,J.jsxs)(_B,{onClick:i,children:[(0,J.jsx)(fg,{"aria-hidden":`true`}),`Don't flag things like this…`]})})]})]}),EU=({point:e,scopes:t,onSave:n,onCancel:r})=>{let[i]=t;return i===void 0?null:(0,J.jsxs)(`div`,{"data-slot":`point-rule`,className:`flex flex-col gap-2 rounded-md border bg-card p-3`,children:[(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`Word it as a rule. It's saved to your preferences, and AI reviews leave out what it describes, folded to a line you can open.`}),(0,J.jsx)(YR,{legend:`Don't flag things like: ${e.title}`,initial:{kind:`dont-flag`,text:e.title,scope:i.scope},scopes:t,kindFixed:!0,submit:`Save and dismiss`,submitting:`Saving…`,focus:!0,onCancel:r,onSubmit:n})]})},DU=(e,t)=>{let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1);return{writing:n,setWriting:r,saved:i,save:async n=>{let i=await t(e,n);return i===null&&(a(!0),r(!1)),i}}},OU=e=>e?(0,J.jsxs)(J.Fragment,{children:[`Dismissed, and saved to your`,` `,(0,J.jsx)(N_,{to:S_,className:`underline`,children:`preferences`})]}):`Dismissed`,kU={blocking:{glyph:`■`,className:`text-severity-blocker bg-review-changes-bg border-severity-blocker/25`},major:{glyph:`▲`,className:`text-severity-major bg-severity-major-bg border-severity-major/25`},minor:{glyph:`●`,className:`text-severity-minor bg-review-pending-bg border-severity-minor/25`}},AU=({severity:e})=>(0,J.jsxs)(`span`,{"data-slot":`severity`,className:X(ij,kU[e].className),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:kU[e].glyph}),e]}),jU=`animate-in duration-(--duration-slow) fade-in-0 slide-in-from-top-1`,MU=`shadow-[inset_0_0_0_2px_var(--ring)]`,NU=`relative max-w-3xl rounded-lg border bg-thread-bg`,PU=`scroll-mt-[calc(6rem+var(--lines-above)*var(--text-code--line-height))] -outline-offset-2`,FU=X(NU,`px-3 py-1.5`),IU={finding:`bg-review-changes`,risk:`bg-risk-contract-solid`},LU=({kind:e})=>(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`absolute top-2 bottom-2 left-1.5 w-[3px] rounded-full`,IU[e])}),RU=(0,q.memo)(function({point:e,state:t,saving:n,readOnly:r,current:i,onRaise:a,onState:o,leftOut:s,onShow:c,ruleScopes:l,onRule:u,inReview:d,removed:f,language:p,linesAbove:m=0}){let h=(0,q.useId)(),{card:g,show:_}=wU(s,c,e.id),v=DU(e,u);if(t===`dismissed`)return(0,J.jsx)(bU,{point:e,state:t,current:i,note:OU(v.saved),className:FU,action:(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(t===`raised`&&d)return(0,J.jsx)(bU,{point:e,state:t,current:i,note:`In your review, below`,className:`max-w-3xl px-1`,action:(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓`})});if(s&&e.guidance!==void 0)return(0,J.jsx)(CU,{point:e,guidance:e.guidance,state:t,current:i,onShow:_});let y=r||n;return(0,J.jsxs)(`article`,{ref:g,id:gU(e.id),"data-slot":`point`,"data-kind":`finding`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${h}-title`,tabIndex:-1,style:vh({"--lines-above":m}),className:X(NU,PU,`flex flex-col gap-2 py-2.5 pr-4 pl-5`,i&&MU),children:[(0,J.jsx)(LU,{kind:`finding`}),(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(yU,{kind:`finding`}),e.severity!==null&&(0,J.jsx)(AU,{severity:e.severity}),(0,J.jsx)(`span`,{className:X(ij,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:`Draft`}),e.lines!==null&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[`on`,` `,(0,J.jsx)(jk,{children:Ak(e.lines.side,e.lines.startLine,e.lines.line)})]}),(0,J.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(eg,{"aria-hidden":`true`,className:`size-3.5`}),`Only you see this`]})]}),(0,J.jsx)(`h3`,{id:`${h}-title`,className:`font-semibold`,children:e.title}),e.explanation!==``&&(0,J.jsx)(rj,{blocks:Vd(e.explanation).blocks,suggestion:()=>null}),e.mismatch!==null&&(0,J.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`font-medium text-foreground`,children:[_U[e.mismatch.kind],`:`]}),` `,e.mismatch.description]}),e.guidance!==void 0&&(0,J.jsx)(SU,{guidance:e.guidance}),e.suggestion!==null&&(0,J.jsx)(rA,{title:`Suggested change`,removed:f,added:e.suggestion,language:p}),v.writing?(0,J.jsx)(EU,{point:e,scopes:l,onSave:v.save,onCancel:()=>{v.setWriting(!1),g.current?.focus()}}):(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,J.jsx)(TU,{point:e,size:`sm`,disabled:y,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>v.setWriting(!0)}),e.lines!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)($,{variant:`outline`,size:`sm`,disabled:y,"aria-label":`Edit: ${e.title}`,onClick:()=>a(e,!1),children:[(0,J.jsx)(Qg,{"aria-hidden":`true`}),`Edit`]}),(0,J.jsx)($,{size:`sm`,disabled:y,"aria-label":`Add to review: ${e.title}`,onClick:()=>a(e,!0),children:`Add to review`})]})]})]})}),zU=e=>e.slice(e.lastIndexOf(`/`)+1),BU=({checkedBy:e,peek:t,id:n})=>{let r=(0,J.jsx)(`span`,{className:`font-mono text-code-compact`,children:e.test});return(0,J.jsxs)(`p`,{"data-slot":`checked-by`,className:`flex items-start gap-1.5 pb-0.5 text-muted-foreground`,children:[(0,J.jsx)(mg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:`Checked by`}),` `,t===null?r:(0,J.jsx)(Oj,{handle:t.handle,payload:t.payload,id:n,render:(0,J.jsx)(`button`,{type:`button`,className:`text-left text-foreground`}),children:r}),` `,`in `,zU(e.path),`, which asserts: `,e.checks]})]})},VU=(0,q.memo)(function({point:e,state:t,saving:n,readOnly:r,current:i,onRaise:a,onState:o,leftOut:s,onShow:c,ruleScopes:l,onRule:u,linesAbove:d=0,test:f=null}){let p=(0,q.useId)(),{card:m,show:h}=wU(s,c,e.id),g=DU(e,u);if(t===`dismissed`)return(0,J.jsx)(bU,{point:e,state:t,current:i,note:OU(g.saved),className:FU,action:(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(s&&e.guidance!==void 0)return(0,J.jsx)(CU,{point:e,guidance:e.guidance,state:t,current:i,onShow:h});let _=r||n;return(0,J.jsxs)(`article`,{ref:m,id:gU(e.id),"data-slot":`point`,"data-kind":`risk`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${p}-title`,tabIndex:-1,style:vh({"--lines-above":d}),className:X(NU,PU,`flex flex-col gap-0.5 py-1.5 pr-2 pl-5`,i&&MU),children:[(0,J.jsx)(LU,{kind:`risk`}),(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(yU,{kind:`risk`}),e.lines!==null&&(0,J.jsx)(jk,{children:Ak(e.lines.side,e.lines.startLine,e.lines.line)}),t===`raised`&&(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,J.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:_||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>a(e,!1),children:`Comment`}),(0,J.jsx)(TU,{point:e,size:`xs`,disabled:_,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>g.setWriting(!0)})]})]}),(0,J.jsx)(`h3`,{id:`${p}-title`,className:`pb-0.5 font-normal`,children:e.title}),e.checkedBy!==void 0&&(0,J.jsx)(BU,{checkedBy:e.checkedBy,peek:f,id:`${gU(e.id)}-test`}),e.guidance!==void 0&&(0,J.jsx)(SU,{guidance:e.guidance,className:`pb-0.5`}),g.writing&&(0,J.jsx)(`div`,{className:`py-1.5 pr-2`,children:(0,J.jsx)(EU,{point:e,scopes:l,onSave:g.save,onCancel:()=>{g.setWriting(!1),m.current?.focus()}})})]})}),HU=({point:e,state:t,open:n,current:r,onToggle:i})=>{let a=sD.decision;return(0,J.jsxs)(`button`,{type:`button`,id:gU(e.id),"data-slot":`decision-chip`,"data-inline-target":!0,"data-state":t,"data-current":r||void 0,"aria-expanded":n,"aria-label":`Decision: ${e.title}`,className:X(`ml-3 inline-flex min-h-5 scroll-mt-24 items-center gap-1 rounded-full border bg-background px-2 align-middle font-sans text-caption text-muted-foreground hover:text-foreground`,t===`dismissed`&&`line-through`,r&&MU),onClick:t=>{t.stopPropagation(),i(e.id)},children:[(0,J.jsx)(a,{"aria-hidden":`true`,className:`size-3`}),e.title]})},UU=({point:e,state:t,saving:n,readOnly:r,onRaise:i,onState:a})=>{let o=r||n;return(0,J.jsxs)(`article`,{"data-slot":`decision-note`,"data-state":t,"aria-label":e.title,className:X(`flex max-w-3xl flex-wrap items-baseline gap-x-2 border-l pl-3 text-caption`,jU),children:[(0,J.jsxs)(`p`,{className:`min-w-0 flex-1 basis-80 text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.title,`.`]}),` `,e.explanation]}),(0,J.jsx)(`span`,{className:`flex items-center gap-1`,children:t===`dismissed`?(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>a(e.id,`open`),children:`Show again`}):(0,J.jsxs)(J.Fragment,{children:[t===`raised`&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:o||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>i(e,!1),children:`Comment`}),(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:o,"aria-label":`Hide: ${e.title}`,onClick:()=>a(e.id,`dismissed`),children:`Hide`})]})})]})},WU=({point:e,onGo:t})=>{let n=sD[e.kind];return(0,J.jsxs)(`p`,{"data-slot":`point-mention`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(n,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),oD[e.kind].label,`:`,` `,(0,J.jsx)(`button`,{type:`button`,className:`min-h-6 rounded-sm text-left whitespace-pre-line text-primary underline-offset-2 hover:underline`,onClick:()=>t(e.id),children:e.title})]})},GU=({pointId:e,fresh:t,at:n,row:r=!1,className:i,bodyClassName:a,children:o})=>(0,J.jsx)(`div`,{role:r?`row`:void 0,"data-slot":`point-fold`,"data-point-id":e,"data-fresh":t||void 0,"data-unfold":n!==void 0||void 0,style:n===void 0?void 0:vh({"--landing-i":n}),className:i,children:(0,J.jsx)(`div`,{role:r?`cell`:void 0,children:(0,J.jsx)(`div`,{className:a,children:o})})}),KU={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},qU=({points:e,kind:t,stateOf:n,onGo:r,onClose:i,family:a=`Claude`})=>{let o=t===null?e:e.filter(e=>e.kind===t),s=(0,q.useRef)(!1),[c,l]=t===null?[`point`,`points`]:KU[t];return(0,J.jsx)(SB,{title:`${o.length} ${o.length===1?c:l} from ${a}`,onClose:i,returnFocus:()=>!s.current,className:`sm:max-w-2xl`,children:(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-1`,"aria-label":`Points`,children:o.map(e=>{let{label:t}=oD[e.kind],i=sD[e.kind],a=n(e.id);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`point-row`,"data-kind":e.kind,className:`flex min-h-7 w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-accent`,onClick:()=>{s.current=!0,r(e.id)},children:[(0,J.jsx)(i,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[t,`: `]}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,a===`dismissed`&&`line-through`),children:e.title}),a!==`open`&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:a===`raised`?`Raised`:`Dismissed`}),e.path!==null&&(0,J.jsx)(`span`,{className:`truncate font-mono text-code-compact text-muted-foreground`,children:e.path})]})},e.id)})})})},JU=(e,t,n)=>{let r=t===null?e:e.filter(e=>e.kind===t),i=r.findIndex(e=>e.id===n);return{steps:r,at:i===-1?null:i}},YU=(e,t)=>{let{steps:n,at:r}=e;return n.length===0?null:n[r===null?t===1?0:n.length-1:(r+t+n.length)%n.length]?.id??null},XU=(e,t,n)=>{if(t===null)return null;let r=JU(e,t,n);return r.at===null?r.steps[0]?.id??null:null},ZU={finding:`findings`,risk:`risks`,decision:`decisions`},QU={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},$U=({kind:e})=>{let t=sD[e];return(0,J.jsx)(t,{"aria-hidden":`true`,className:X(`size-3.5 shrink-0`,QU[e])})},eW=({slot:e,noun:t,total:n,at:r,count:i,title:a,status:o,onStep:s,onOpenList:c})=>{let l=r===null?i:`${r+1} of ${n}`,u=`${t.charAt(0).toUpperCase()}${t.slice(1)}`;return(0,J.jsxs)(`span`,{"data-slot":e,className:`flex min-w-0 items-center gap-0.5`,children:[(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Previous ${t}`,disabled:n===0,onClick:()=>s(-1),children:(0,J.jsx)(Hh,{"aria-hidden":`true`})}),(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:`tabular`,"aria-label":r===null?`${i}, show all`:`${u} ${l}, show all`,onClick:c,children:l}),(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Next ${t}`,disabled:n===0,onClick:()=>s(1),children:(0,J.jsx)(Wh,{"aria-hidden":`true`})}),a,(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:o})]})},tW=({points:e,current:t,stateOf:n,kind:r,onGo:i,onOpenList:a})=>{let o=JU(e,r,t),{steps:s,at:c}=o,l=c===null?void 0:s[c],u=r===null||s.length===1?`${s.length} ${s.length===1?`point`:`points`}`:`${s.length} ${ZU[r]}`,d=l!==void 0&&n(l.id)===`dismissed`;return(0,J.jsx)(eW,{slot:`point-stepper`,noun:`point`,total:s.length,at:c,count:u,onStep:e=>{let t=YU(o,e);t!==null&&i(t)},onOpenList:a,title:l!==void 0&&(0,J.jsxs)(`button`,{type:`button`,"data-slot":`stepper-title`,"data-kind":l.kind,className:`ml-1 flex h-6 min-w-0 items-center gap-1.5 rounded-md px-1 text-left max-sm:hidden hover:bg-muted`,"aria-label":`Go to ${oD[l.kind].label.toLowerCase()}: ${l.title}`,onClick:()=>i(l.id),children:[(0,J.jsx)($U,{kind:l.kind}),(0,J.jsx)(`span`,{className:X(`min-w-0 truncate`,d&&`text-muted-foreground line-through`),children:l.title})]}),status:l===void 0||c===null?``:`${oD[l.kind].label} ${c+1} of ${s.length}: ${l.title}${d?` (dismissed)`:``}`})},nW={collect:`Collect`,prep:`Prepare`,intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`},rW={pending:`waiting`,running:`running`,done:`done`,failed:`failed`,skipped:`skipped`},iW={pending:`text-muted-foreground`,running:`text-primary font-medium`,done:`text-review-approved`,failed:`text-destructive font-medium`,skipped:`text-muted-foreground`},aW={pending:`○`,running:`◐`,done:`●`,failed:`✗`,skipped:`–`},oW=({stages:e,shown:t,filesFetched:n})=>(0,J.jsx)(`ol`,{className:`flex flex-wrap gap-x-4 gap-y-1 rounded-lg border bg-surface-subtle px-3 py-2`,"aria-label":`Analysis progress`,children:t.map(t=>{let r=e[t];return(0,J.jsxs)(`li`,{"data-status":r,className:iW[r],children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:aW[r]}),` `,nW[t],(0,J.jsxs)(`span`,{className:`sr-only`,children:[`: `,rW[r]]}),t===`collect`&&r===`running`&&n!==null&&(0,J.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[` `,`· `,n.done,` of `,n.total,` files`]})]},t)})}),sW=e=>nW[e],cW=xu.options.filter(e=>!zu.includes(e)),lW=({legend:e,options:t,value:n,onChange:r})=>(0,J.jsxs)(`fieldset`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`legend`,{className:`sr-only`,children:e}),t.map(e=>(0,J.jsx)(Bj,{variant:`outline`,size:`sm`,pressed:n===e.value,disabled:e.disabled===!0,onPressedChange:t=>{t&&r(e.value)},children:e.label},e.value))]}),uW=[{value:`comment`,label:`Comment`},{value:`approve`,label:`Approve`},{value:`request_changes`,label:`Request changes`}],dW=`whitespace-pre-wrap wrap-anywhere`,fW=(e,t)=>{let n=t===0?``:` ${t} ${t===1?`comment`:`comments`}`;return e===`comment`?n===``?`Publish the summary`:`Publish${n}`:`Publish${n} and ${e===`approve`?`approve`:`request changes`}`},pW=({analysisId:e,hunkComments:t,isAuthor:n,published:r,onClose:i,onPublished:a})=>{let{client:o}=yp(),s=(0,q.useId)(),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(`comment`),[f,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(!1),[b]=(0,q.useState)(()=>qd.parse(crypto.randomUUID())),x=Dp(o.publish);(0,q.useEffect)(()=>{let n=!0;return o.previewPublication(e,{summary:``,hunkComments:t}).then(e=>{n&&(p(e.ok?e.value:null),h(e.ok?null:e.error))}),()=>{n=!1}},[e,o,t]);let S=n?`comment`:u,C=fW(S,f?.comments.length??t.length),w=f!==null&&Jd({...f,verdict:S,summary:c}),T=async n=>{y(n),_(!1);let r=await x.run(e,{publicationId:b,summary:c,allowStale:n,hunkComments:t,verdict:S});r.ok?a(r.value):r.error.code===`stale-analysis`&&(x.reset(),_(!0))};return(0,J.jsxs)(SB,{title:`Publish review`,onClose:i,className:`flex flex-col sm:max-w-2xl`,children:[r&&(0,J.jsx)(`p`,{className:`shrink-0 text-muted-foreground`,children:`Your earlier review is on the pull request. This one posts as another, with its own verdict.`}),m===null?f===null?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Reading the comments…`}):f.comments.length>0&&(0,J.jsx)(`section`,{"data-slot":`publish-comments`,"aria-label":`Comments to post`,tabIndex:0,className:`-mx-4 min-h-12 overflow-y-auto overscroll-contain border-y px-4 py-3 -outline-offset-2`,children:(0,J.jsx)(`ul`,{"aria-label":`Comments`,className:`flex flex-col gap-1.5`,children:f.comments.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 border-l-2 border-l-review-pending py-0.5 pl-2.5`,children:[(0,J.jsxs)(`code`,{className:`font-mono text-code-compact text-muted-foreground`,children:[e.path,`:`,e.startLine===void 0?e.line:`${e.startLine}–${e.line}`,e.side===`old`?` (old side)`:``]}),(0,J.jsx)(`p`,{className:dW,children:e.body})]},e.key))})}):(0,J.jsxs)(`p`,{className:LN,role:`alert`,children:[`Couldn't read what will be posted. `,Ap(m)]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`Verdict`}),(0,J.jsx)(lW,{legend:`Verdict`,options:uW.map(e=>({...e,disabled:n&&e.value!==`comment`})),value:S,onChange:d})]}),n&&(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`You opened this pull request, and its author can't approve it or request changes, so your review comments.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`${s}-summary`,className:`sr-only`,children:`Summary`}),(0,J.jsx)($O,{id:`${s}-summary`,rows:2,"data-autofocus":!0,placeholder:`Summary (optional)`,value:c,onChange:e=>l(e.target.value)})]}),g?(0,J.jsxs)(`div`,{className:X(RN,`flex flex-col gap-2`),role:`alert`,children:[(0,J.jsx)(`p`,{children:`This PR changed since the analysis. Publish anyway?`}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)($,{variant:`outline`,onClick:()=>_(!1),children:`Cancel`}),(0,J.jsx)($,{onClick:()=>void T(!0),children:`Publish anyway`})]})]}):(0,J.jsxs)(J.Fragment,{children:[x.error!==null&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`Couldn't publish. `,Ap(x.error)]}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Retrying is safe: comments that were already posted aren't posted again.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[w&&(0,J.jsx)(`p`,{id:`${s}-nothing`,className:`mr-auto text-caption text-muted-foreground`,children:`Nothing to post yet: write a summary, or approve or request changes.`}),(0,J.jsx)($,{variant:`outline`,onClick:i,children:`Cancel`}),(0,J.jsx)($,{disabled:x.pending||f===null||w,"aria-describedby":w?`${s}-nothing`:void 0,onClick:()=>void T(v),children:x.pending?`Publishing…`:x.error===null?C:`Retry`})]})]})]})]})},mW=({children:e})=>(0,J.jsx)(`aside`,{id:`review-tree-rail`,"aria-label":`Files`,className:`sticky top-[var(--review-bar-h,0px)] -ml-1 flex h-[calc(100vh-var(--review-bar-h,0px))] min-h-0 flex-col gap-2 self-start overflow-hidden p-1`,children:e}),hW=({analysisId:e,family:t,onRemoved:n})=>{let{client:r}=yp(),i=Dp(r.removeModelRun),[a,o]=(0,q.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>o(!0),children:`Remove AI review…`}),a&&(0,J.jsxs)(SB,{title:`Remove AI review`,onClose:()=>{o(!1),i.reset()},children:[(0,J.jsxs)(`p`,{className:`text-ui`,children:[t,`'s intent, findings, risks and decisions go, with what you did with them, and the code's analysis is back as it was. Your comments stay. Request AI review runs a model again, the same or another.`]}),i.error!==null&&(0,J.jsxs)(`p`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[`Couldn't remove it. `,Ap(i.error)]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:()=>o(!1),children:`Cancel`}),(0,J.jsx)($,{variant:`destructive`,disabled:i.pending,onClick:async()=>{let t=await i.run(e);t.ok&&(o(!1),n(t.value))},children:i.pending?`Removing…`:`Remove`})]})]})]})},gW=()=>{let e=(0,q.useRef)(null),[t,n]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{let t=e.current;if(t===null||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>{e!==void 0&&n(e.intersectionRatio<1&&e.boundingClientRect.top<=0)},{rootMargin:`-1px 0px 0px 0px`,threshold:1});return r.observe(t),()=>r.disconnect()},[]),{bar:e,stuck:t}},_W=({title:e,claude:t,tools:n,publish:r,publication:i,hairline:a,stuck:o})=>{let s=gW(),c=o??s.stuck;return(0,J.jsxs)(`div`,{ref:s.bar,"data-slot":`review-bar`,"data-stuck":c||void 0,className:`sticky top-0 z-20 flex h-(--review-bar-h) min-w-0 items-center gap-3 border-b bg-background`,children:[a!==null&&(0,J.jsx)(`span`,{"data-slot":`model-hairline`,"data-state":a,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{})}),c&&e!==null&&(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`max-w-72 shrink truncate font-semibold max-xl:hidden`,title:e,children:e}),(0,J.jsx)(`div`,{"data-slot":`claude-slot`,className:`flex min-w-0 flex-1 items-center`,children:t}),(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n}),i!==null&&(0,J.jsxs)(`p`,{role:`status`,className:`flex shrink-0 items-center gap-1 font-medium text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),` `,i.url===null?`Published`:(0,J.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,className:`text-review-approved`,children:`Published`})]}),r]})},vW=2,yW=(e,t,n)=>`${e} ${e===1?t:n}`,bW=()=>(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-border`}),xW=({error:e,onRetry:t})=>(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:`h-6 px-1.5 font-normal text-muted-foreground`,"data-slot":`status-unavailable`,children:`Status unavailable`})}),(0,J.jsxs)(wM,{align:`end`,children:[(0,J.jsx)(TM,{children:`The PR's status couldn't be read`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Ap(e)}),(0,J.jsx)($,{variant:`outline`,size:`sm`,className:`self-start`,onClick:t,children:`Try again`})]})]}),SW=({name:e})=>(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact text-foreground`,children:e}),CW=({view:e,intent:t,totals:n,threads:r,status:i,statusError:a,onRetryStatus:o,now:s,reanalyzing:c,reanalyzeError:l,onReanalyze:u})=>{let{analysis:d,stale:f}=e,{pullRequest:p,warnings:m}=d,{ref:h}=d.key;return(0,J.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[(0,J.jsxs)(`a`,{className:`font-mono text-code-compact`,href:p?.url??hf(h),target:`_blank`,rel:`noreferrer`,children:[h.repo.repo,` #`,h.number]}),(0,J.jsx)(`div`,{"data-slot":`pr-standing`,className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[r!==null&&r.threads>0&&(0,J.jsxs)(`span`,{"data-slot":`thread-totals`,className:`tabular text-caption text-muted-foreground`,children:[yW(r.threads,`thread`,`threads`),r.unresolved>0&&` · ${r.unresolved} unresolved`]},`threads`),i===null&&a!==null&&(0,J.jsx)(xW,{error:a,onRetry:o},`unavailable`),i!==null&&(i.checks===null||i.checks.length>0)&&(0,J.jsx)(NM,{checks:i.checks,unreadable:i.checksUnreadable,head:d.key.headSha},`ci`),i!==null&&i.reviewers.length>0&&(0,J.jsx)(zM,{reviewers:i.reviewers},`reviewers`)].filter(e=>e!==!1).flatMap((e,t)=>t===0?[e]:[(0,J.jsx)(bW,{},`before-${e.key}`),e])})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(`h1`,{className:`min-w-0 text-title font-semibold tracking-[-0.01em] whitespace-pre-line`,children:p?.title??`Collecting the pull request…`}),i!==null&&(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(DM,{state:i.state}),(0,J.jsx)(OM,{status:i.reviewStatus})]})]}),p!==null&&(0,J.jsxs)(`p`,{"data-slot":`pr-byline`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-muted-foreground`,children:[(0,J.jsxs)(`span`,{children:[p.author.name,` wants to merge `,(0,J.jsx)(SW,{name:p.sourceBranch}),` `,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:`into`}),` `,(0,J.jsx)(SW,{name:p.targetBranch})]}),` `,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,J.jsxs)(`span`,{children:[`updated `,Ok(p.updatedAt,s)]}),` `,d.stages.prep===`done`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,J.jsxs)(`span`,{className:`tabular`,children:[yW(n.files,`file`,`files`),` `,(0,J.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{"aria-hidden":`true`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,n.additions]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,n.deletions]})]}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, `,n.additions,` lines added, `,n.deletions,` removed`]})]})]})]})]}),(0,J.jsx)(`div`,{className:`mt-1.5`,children:t}),f&&(0,J.jsxs)(`div`,{role:`status`,className:X(`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,`flex flex-wrap items-center gap-3`),children:[(0,J.jsx)(`span`,{children:`This PR has new commits since the analysis.`}),(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:c,onClick:u,children:c?`Starting…`:`Re-analyze`}),l!==null&&(0,J.jsx)(`span`,{className:`text-destructive`,role:`alert`,children:Ap(l)})]}),m.length>0&&m.length<=vW&&(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Warnings`,children:m.map(e=>(0,J.jsxs)(`li`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),e]},e))}),m.length>vW&&(0,J.jsxs)(`details`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,J.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),m.length,` warnings`]}),(0,J.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:m.map(e=>(0,J.jsx)(`li`,{children:e},e))})]})]})},wW=e=>`thread-${e}`,TW=e=>`${e.side}:${e.line}`,EW={onLine:new Map,earlier:new Map,elsewhere:[],open:new Map},DW=(e,t,n)=>e.set(t,[...e.get(t)??[],n]),OW=(e,t,n)=>{if(e===null||e.length===0)return EW;let r=new Map(t.map(e=>[e.file.path,e])),i=new Map,a=new Map,o=[],s=new Map;for(let t of e){t.resolved||s.set(t.path,(s.get(t.path)??0)+1);let e=r.get(t.path);if(e===void 0){o.push(t);continue}let{line:c}=t,l=t.outdated||c===null?void 0:e.partIds.find(e=>n.parts.get(e)?.hunk.lines.some(e=>{let n=_j(e);return n!==null&&n.side===t.side&&n.line===c}));if(l===void 0||c===null){DW(a,t.path,t);continue}let u=i.get(l)??new Map;DW(u,TW({side:t.side,line:c}),t),i.set(l,u)}return{onLine:i,earlier:a,elsewhere:o,open:s}},kW=(e,t,n)=>{let r=new Map(e.lines.flatMap(e=>e.kind!==`del`&&e.newLine!==null?[[e.newLine,e.text]]:[])),i=[];for(let e=t;e<=n;e+=1){let t=r.get(e);if(t===void 0)return null;i.push(t)}return i},AW=(e,t,n)=>{let r=[];for(let i of t){for(let t of i.partIds){let i=e.onLine.get(t),a=n.parts.get(t)?.hunk;if(i===void 0||a===void 0)continue;let o=new Set;for(let e of a.lines){let t=_j(e);if(t===null)continue;let n=TW(t);o.has(n)||(o.add(n),r.push(...i.get(n)??[]))}}r.push(...e.earlier.get(i.file.path)??[])}return r.push(...e.elsewhere),r},jW=(e,t,n)=>t===`all`?e:e.filter(e=>!e.resolved||n.has(e.id)),MW=(e,t,n)=>e===null?jW(t,`unresolved`,n).length>0?`unresolved`:`all`:e,NW=(e,t,n,r)=>{if(t.length===0)return null;let i=new Set(t.map(e=>e.id)),a=n===null?-1:e.findIndex(e=>e.id===n);if(a===-1)return(r===1?t[0]:t.at(-1))?.id??null;for(let t=1;t<=e.length;t+=1){let n=e[(a+r*t+e.length*t)%e.length];if(n!==void 0&&i.has(n.id))return n.id}return null},PW=(e,t,n)=>`${e} ${e===1?t:n}`,FW=e=>(e.line??e.originalLine)===null?`the file`:sj(e.outdated?{...e,line:null}:e),IW=e=>{let[t]=e.comments;if(t===void 0)return FW(e);let n=Td(t.body);return`${t.author.name}: ${n===``?`Suggested change`:n}`},LW=(e,t)=>e===`unresolved`?`${t} unresolved`:PW(t,`thread`,`threads`),RW=(e,t,n)=>{if(e.length===0)return null;let r=jW(e,t,n).length;return t===`unresolved`?{count:r,words:[`unresolved`,`unresolved`],label:PW(r,`unresolved thread`,`unresolved threads`)}:{count:r,words:[`thread`,`threads`],label:PW(r,`thread`,`threads`)}},zW=({resolved:e})=>e?(0,J.jsx)(Rh,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-review-approved`}):(0,J.jsx)(Kg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),BW=({ordered:e,scope:t,resolvedHere:n,current:r,onGo:i,onOpenList:a})=>{let o=jW(e,t,n),s=o.findIndex(e=>e.id===r),c=s===-1?null:s,l=c===null?void 0:o[c],u=l===void 0?``:IW(l);return(0,J.jsx)(eW,{slot:`thread-stepper`,noun:`thread`,total:o.length,at:c,count:LW(t,o.length),onStep:t=>{let n=NW(e,o,r,t);n!==null&&i(n)},onOpenList:a,title:l!==void 0&&(0,J.jsxs)(`button`,{type:`button`,"data-slot":`stepper-title`,"data-kind":`thread`,className:`ml-1 flex h-6 min-w-0 items-center gap-1.5 rounded-md px-1 text-left max-sm:hidden hover:bg-muted`,title:`${l.path}, ${FW(l)}`,"aria-label":`Go to thread: ${u}`,onClick:()=>i(l.id),children:[(0,J.jsx)(zW,{resolved:l.resolved}),(0,J.jsx)(`span`,{className:X(`min-w-0 truncate`,l.resolved&&`text-muted-foreground`),children:u})]}),status:l===void 0||c===null?``:`Thread ${c+1} of ${o.length}, ${l.path} ${FW(l)}${l.resolved?`, resolved`:l.outdated?`, outdated`:``}: ${u}`})},VW=({ordered:e,scope:t,onScope:n,onGo:r,onClose:i})=>{let a=e.filter(e=>!e.resolved).length,o=(0,q.useRef)(!1),s=[];for(let t of e){let e=s.at(-1);e?.path===t.path?e.threads.push(t):s.push({path:t.path,threads:[t]})}return(0,J.jsxs)(SB,{title:`${PW(e.length,`thread`,`threads`)}, ${a} unresolved`,onClose:i,returnFocus:()=>!o.current,className:`sm:max-w-2xl`,children:[a>0&&a<e.length&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`Previous and Next go round`}),(0,J.jsx)(lW,{legend:`Previous and Next go round`,options:[{value:`unresolved`,label:`Unresolved (${a})`},{value:`all`,label:`All (${e.length})`}],value:t,onChange:n})]}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:s.map(({path:e,threads:t})=>(0,J.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`truncate px-2 font-mono text-code-compact text-muted-foreground`,children:e}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`thread-row`,"data-resolved":e.resolved||void 0,className:`flex min-h-7 w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-accent`,onClick:()=>{o.current=!0,r(e.id)},children:[(0,J.jsx)(zW,{resolved:e.resolved}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,e.resolved&&`text-muted-foreground`),children:IW(e)}),(e.resolved||e.outdated)&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.resolved?`Resolved`:`Outdated`}),(0,J.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:FW(e)})]})},e.id))})]},t[0]?.id??e))})]})},HW=.25,UW=(e,t,n)=>{let r=n?t-1:t*HW;return(e.findLast(e=>e.top<=r)??e[0])?.path??null},WW=()=>{let e=[...document.querySelectorAll(`[aria-label=Changes] [data-slot=file-card][data-path]`)],t=e.map(e=>e.getBoundingClientRect());return t.every(e=>e.height===0)?null:e.map((e,n)=>({path:e.dataset.path??``,top:t[n]?.top??0}))},GW=(e,t)=>{let[n,r]=(0,q.useState)(null),i=e.join(`\0`);return(0,q.useEffect)(()=>{if(!t)return;let e=0,n=()=>{e=0;let t=document.documentElement,n=window.scrollY+window.innerHeight>=t.scrollHeight-2,i=WW();if(i===null)return;let a=UW(i,window.innerHeight,n&&window.scrollY>0);a!==null&&r(a)},i=()=>{e===0&&(e=requestAnimationFrame(n))};return n(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i),e!==0&&cancelAnimationFrame(e)}},[i,t]),n},KW=1,qW=240,JW=6,YW=()=>{},XW=e=>{let t=e.left+e.width/2;for(let e=KW;e<Math.min(window.innerHeight,qW);e+=JW){let n=document.elementFromPoint(t,e);if(n===null||n.closest(`[data-slot=file-card-header]`)!==null)continue;let r=n.closest(`[role=row]`);if(r!==null)return r}return null},ZW=e=>{let t=document.querySelector(e)?.getBoundingClientRect();if(window.scrollY<=KW||t===void 0||t.top>=0||typeof document.elementFromPoint!=`function`)return YW;let n=XW(t);if(n===null)return YW;let r=n.getBoundingClientRect().top;return()=>{if(!n.isConnected)return;let e=n.getBoundingClientRect().top-r;e!==0&&window.scrollBy({top:e,behavior:`instant`})}},QW=`[aria-label=Changes]`,$W=e=>{let t=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),n=Number.parseFloat(t);return Number.isFinite(n)?t.endsWith(`ms`)?n:t.endsWith(`s`)?n*1e3:n:0},eG=e=>`✓ ${e} is done`,tG=new Set,nG=new Map,rG=(e,t,n=`Claude`)=>{let[r,i]=(0,q.useState)({running:e,before:tG}),[a,o]=(0,q.useState)(`done`),[s,c]=(0,q.useState)(nG),[l,u]=(0,q.useState)(0);e!==r.running&&(i({running:e,before:e?new Set(t):r.before}),o(e?`done`:`measure`),c(nG),e||u(l+1)),(0,q.useEffect)(()=>{if(l===0||!document.hidden)return;let e=document.title;document.title=`${eG(n)} · ${e}`;let t=()=>{document.hidden||(document.title=e)};return document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t),document.title=e}},[l,n]);let d=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{if(a!==`measure`)return;if(d.current=ZW(QW),$W(`--landing-total`)===0){o(`done`);return}let e=new Map;for(let t of document.querySelectorAll(`[data-slot=point-fold][data-fresh]`)){let{top:n}=t.getBoundingClientRect(),r=uu.safeParse(t.dataset.pointId);r.success&&n>=0&&n<window.innerHeight&&e.set(r.data,e.size)}c(e),o(`landing`)},[a]),(0,q.useLayoutEffect)(()=>{a!==`measure`&&d.current!==null&&(d.current(),d.current=null)},[a]),(0,q.useEffect)(()=>{if(a!==`landing`)return;let e=Math.max(0,s.size-1)*$W(`--landing-step-code`),t=setTimeout(()=>o(`done`),$W(`--landing-total`)+e);return()=>clearTimeout(t)},[a,s]);let{before:f}=r,p=(0,q.useCallback)(e=>a!==`done`&&!f.has(e),[a,f]);return{phase:a,running:e||a===`measure`,fresh:p,inView:a===`landing`?s:nG}},iG=(e,t)=>{let{client:n}=yp(),[r,i]=(0,q.useState)(new Map),[a,o]=(0,q.useState)(new Set),[s,c]=(0,q.useState)(null),l=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>{let e=new Map(t.map(e=>[e.pointId,e.state]));for(let[t,n]of r)e.set(t,n);return e},[t,r]);return{stateOf:(0,q.useCallback)(e=>u.get(e)??`open`,[u]),setState:(0,q.useCallback)(async(t,r)=>{i(e=>new Map(e).set(t,r)),o(e=>new Set(e).add(t));let a=(l.current.get(t)??0)+1;l.current.set(t,a);let s=await n.putPointState(e,t,{state:r});l.current.get(t)===a&&(o(e=>{let n=new Set(e);return n.delete(t),n}),s.ok?c(e=>e?.pointId===t?null:e):(i(e=>{let n=new Map(e);return n.delete(t),n}),c({pointId:t,message:Ap(s.error)})))},[e,n]),isSaving:e=>a.has(e),failure:s,dismissFailure:()=>c(null)}},aG=6e4,oG=e=>{let{client:t}=yp(),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null),o=(0,q.useRef)(0),s=(0,q.useCallback)(()=>{o.current+=1;let n=o.current;t.getPullRequestStatus(e).then(e=>{n===o.current&&(e.ok?(r(e.value),a(null)):a(e.error))})},[t,e]);(0,q.useEffect)(()=>(s(),window.addEventListener(`focus`,s),()=>window.removeEventListener(`focus`,s)),[s]);let c=n?.checks?.some(e=>e.state===`running`)===!0;return(0,q.useEffect)(()=>{if(!c)return;let e=setInterval(()=>{document.visibilityState===`visible`&&s()},aG);return()=>clearInterval(e)},[c,s]),{status:n,error:i,reload:s}},sG=(e,t)=>{let{client:n}=yp(),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),s=(0,q.useRef)(0),c=(0,q.useCallback)(()=>{s.current+=1;let t=s.current;n.getThreads(e).then(e=>{t===s.current&&(e.ok?(i(e.value),o(null)):o(e.error))})},[n,e]);return(0,q.useEffect)(()=>{t&&c()},[t,c]),{list:r,error:a,reload:c,reply:(0,q.useCallback)(async(t,r)=>{let i=await n.replyToThread(e,t,{body:r});return i.ok?(c(),null):Ap(i.error)},[n,e,c]),resolve:(0,q.useCallback)(async(t,r)=>{let i=await n.resolveThread(e,t,{resolved:r});return i.ok?(c(),null):Ap(i.error)},[n,e,c]),post:(0,q.useCallback)(async t=>{let r=await n.postComment(e,t);return r.ok?(c(),null):Ap(r.error)},[n,e,c])}},cG=[],lG=e=>Wd.array().safeParse(e).data,uG=({analysisId:e})=>{let[t,n]=(0,q.useState)({count:0,seed:null}),r=(0,q.useCallback)((e=null)=>n(({count:t})=>({count:t+1,seed:e})),[]);return(0,J.jsx)(dG,{analysisId:e,seed:t.seed,restart:r},`${e}/${t.count}`)},dG=({analysisId:e,seed:t,restart:n})=>{let{view:r,error:i,refetch:a,follow:o}=Ep(e,t);return r===null?i?.code===`not-found`?(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Analysis not found`}),(0,J.jsx)(`p`,{className:`text-body`,children:Ap(i)}),(0,J.jsx)(`p`,{children:(0,J.jsx)(N_,{to:`/`,children:`Pick a pull request to review`})})]}):i===null?(0,J.jsx)(fG,{}):(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 py-12`,children:[(0,J.jsxs)(`p`,{className:LN,role:`alert`,children:[`Couldn't load the analysis. `,Ap(i)]}),(0,J.jsx)($,{variant:`outline`,onClick:()=>void a(),children:`Try again`})]}):(0,J.jsx)(TG,{view:r,refetch:a,follow:o,restart:n})},fG=()=>(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1600px] flex-col gap-4`,role:`status`,"aria-busy":`true`,"aria-label":`Loading the analysis`,children:[(0,J.jsx)(zN,{className:`h-7 w-2/3`}),(0,J.jsx)(zN,{className:`h-4 w-1/2`}),(0,J.jsxs)(`div`,{className:pG,children:[(0,J.jsx)(UN,{}),(0,J.jsx)(HN,{})]})]}),pG=`grid items-start gap-5 lg:grid-cols-[17rem_minmax(0,1fr)]`,mG=[],hG=[{value:`map`,label:`Map`},{value:`overview`,label:`Overview`}],gG=[`nextFile`,`previousFile`,`comment`,`openCall`,`moveFile`,`openFile`,`toggleLayout`,`openReview`,`close`,`help`],_G=({analysis:e})=>{let{checkout:t,pullRequest:n}=e;if(t===`read`||n===null)return null;let{ref:r,headSha:i}=n;return(0,J.jsxs)(`p`,{"data-slot":`checkout-note`,className:`text-muted-foreground`,children:[`Code outside the pull request that calls what it changes isn't shown:`,` `,t===`missing-commit`?(0,J.jsxs)(J.Fragment,{children:[`the local checkout doesn't have the head commit`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:i.slice(0,7)}),`. Run`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`git fetch`}),` in it`,r.repo.host===`github`&&(0,J.jsxs)(J.Fragment,{children:[`, or`,` `,(0,J.jsxs)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:[`git fetch origin pull/`,r.number,`/head`]}),` `,`for a pull request from a fork`]}),`, then open the pull request again.`]}):(0,J.jsxs)(J.Fragment,{children:[`megareviewer didn't run in a checkout of `,r.repo.owner,`/`,r.repo.repo,`. Start it in one, or pass`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`--checkout <dir>`}),`, then open the pull request again.`]})]})},vG=[],yG=(e,t)=>{let[n,r]=(0,q.useState)(e);return!t&&n!==e&&r(e),t?n:e},bG=(e,t)=>{let{lines:n}=e;if(n===null)return null;let r=null,i=null;for(let[e,a]of t.lines.entries()){let t=_j(a);t!==null&&t.side===n.side&&(t.line<n.startLine||t.line>n.line||(r??=e,(i===null||t.line>i.line)&&(i={line:t.line,at:e})))}return r===null||i===null?null:{key:`${n.side}:${i.line}`,rows:i.at-r+1}},xG={github:void 0,bitbucket:`Bitbucket can't anchor a range, so the comment goes on the last line and names them.`},SG=new WeakMap,CG=0,wG=e=>{let t=SG.get(e);return t===void 0?(CG+=1,SG.set(e,CG),CG):t},TG=({view:e,refetch:t,follow:n,restart:r})=>{let{client:i}=yp(),a=tL(Sp().status?.model??null),{analysis:o,publication:s}=e,c=o.id,l=o.status===`complete`,u=l&&Bu(o),d=yG(o,u),f=Dp(i.runModel),p=s!==null||!l,m=(0,q.useMemo)(()=>rH(d),[d]),h=(0,q.useMemo)(()=>aH(d,m),[d,m]),g=(0,q.useMemo)(()=>oH(d,m),[d,m]),_=(0,q.useMemo)(()=>g.flatMap(e=>e.partIds),[g]),v=(0,q.useMemo)(()=>dH(d,m),[d,m]),y=uH(v),[b,x]=JI(`decisions`,!1,YI),S=(0,q.useMemo)(()=>hu(d).filter(e=>b||e.kind!==`decision`),[d,b]),C=(0,q.useMemo)(()=>S.map(e=>e.id),[S]),w=iG(c,e.pointReviews),[T,E]=(0,q.useState)(new Set),{stateOf:D}=w,O=(0,q.useMemo)(()=>new Set(S.filter(e=>e.guidance?.effect===`left-out`&&D(e.id)===`open`&&!T.has(e.id)).map(e=>e.id)),[S,D,T]),k=(0,q.useMemo)(()=>S.filter(e=>!O.has(e.id)),[S,O]),A=(0,q.useCallback)(e=>E(t=>new Set(t).add(e)),[]),j=Rl(o.modelOption??a.chosen),M=rG(u,C,j),N=(0,q.useMemo)(()=>cH(S,_,m),[S,_,m]),P=(0,q.useMemo)(()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=(e,t,n,r)=>{let i=e.get(t)??new Map;i.set(n,[...i.get(n)??[],r]),e.set(t,i)};for(let[a,o]of N.cards){let s=m.parts.get(a);for(let c of o){let o=s===void 0?null:bG(c,s.hunk);o===null?n.set(a,[...n.get(a)??[],c]):c.kind===`decision`?i(t,a,o.key,c):(i(e,a,o.key,c),r.set(c.id,o.rows))}}for(let t of e.values())for(let[e,n]of t)t.set(e,[...n.filter(e=>e.kind===`finding`),...n.filter(e=>e.kind!==`finding`)]);return{underLine:e,atLineEnd:t,underHeader:n,rowsAbove:r}},[N,m]),F=(0,q.useMemo)(()=>{let e=new Map,t=t=>{let[n]=t;for(let r of t)n!==void 0&&e.set(r.id,n.id)};for(let e of P.underLine.values())for(let n of e.values())t(n);for(let[e,n]of P.underHeader)t([...n,...N.mentions.get(e)??mG]);for(let[e,n]of N.mentions)P.underHeader.has(e)||t(n);return t(N.unplaced),e},[P,N]),{inView:I}=M,L=(0,q.useCallback)(e=>I.get(F.get(e)??e),[I,F]),R=(0,q.useMemo)(()=>{let e=new Map;for(let[t,n]of N.cards){let r=m.parts.get(t)?.file.path;if(r===void 0)continue;let i=n.filter(e=>!O.has(e.id));if(i.length===0)continue;let a=e.get(r)??{};for(let e of i)a[e.kind]=(a[e.kind]??0)+1;e.set(r,a)}return e},[N,m,O]),ee=(0,q.useMemo)(()=>g.map(({file:e})=>({path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,...R.has(e.path)?{points:R.get(e.path)}:{}})),[g,R]),[z,te]=(0,q.useState)([]),B=(0,q.useMemo)(()=>YB(d,h,new Set(z)),[d,h,z]),ne=(0,q.useMemo)(()=>d.stages.prep===`done`?QB(YB(d,h)):null,[d,h]),[V,H]=JI(`review-layout`,`map`,eH),re=GW((0,q.useMemo)(()=>g.map(e=>e.file.path),[g]),V===`map`&&d.stages.prep===`done`),[ie,ae]=(0,q.useState)(!1),oe=(0,q.useMemo)(()=>{let e=new Map;for(let t of d.unchangedCallers)e.set(t.partId,[...e.get(t.partId)??[],t]);return e},[d.unchangedCallers]),se=(0,q.useCallback)(e=>oe.get(e)??vG,[oe]),[U]=(0,q.useState)(Dj),ce=(0,q.useMemo)(()=>pV(d.callSites,m,U),[d.callSites,m,U]),le=(0,q.useCallback)(e=>ce.get(e),[ce]),ue=(0,q.useMemo)(()=>new Map(S.flatMap(e=>{let t=mV(e,m);return t===null?[]:[[e.id,{handle:U,payload:t}]]})),[S,m,U]),[de,fe]=(0,q.useState)(null),[pe,me]=(0,q.useState)(null),he=(0,q.useRef)(null),[ge,_e]=(0,q.useState)(null),[ve,ye]=(0,q.useState)(null),[be,xe]=(0,q.useState)(null),[Se,Ce]=(0,q.useState)(null),[we,Te]=(0,q.useState)(null),[Ee,De]=(0,q.useState)(new Set),[Oe,ke]=(0,q.useState)(!1),Ae=be===`thread`||k.length===0,je=Ae?null:ve,[Me,Ne]=(0,q.useState)(!1),[Pe,Fe]=(0,q.useState)(new Set),Ie=(0,q.useCallback)(e=>Fe(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),[Le,Re]=(0,q.useState)(null),[ze,Be]=(0,q.useState)(new Set),[Ve,He]=(0,q.useState)(null),[W,Ue]=(0,q.useState)(!1),[We,Ge]=(0,q.useState)(!1),Ke=(0,q.useRef)(!0),[qe,Je]=(0,q.useState)(!1),[Ye,Xe]=JI(`hunk-comments:${c}`,cG,lG),[Ze,Qe]=(0,q.useState)(null),$e=(0,q.useRef)(null),et=(0,q.useMemo)(()=>fH(Ye,m),[Ye,m]),tt=(0,q.useCallback)(e=>et.get(e)??cG,[et]),nt=(0,q.useCallback)((e,t)=>Xe(n=>{let r=rl(e),i=e=>e.hunkId===r&&e.side===t.side&&e.line===t.line,a={hunkId:r,...t},o=t.body===``&&t.suggestion===void 0;return n.some(i)?o?n.filter(e=>!i(e)):n.map(e=>i(e)?a:e):o?n:[...n,a]}),[Xe]),rt=(0,q.useCallback)((e,t)=>{$e.current=null,Qe(n=>{if(t?.startLine!==void 0&&n!==null&&n.partId===e){let r=rl(e),i=n.place;Xe(e=>e.map(e=>e.hunkId===r&&e.side===i.side&&e.line===i.line?{...e,line:t.line,startLine:t.startLine}:e))}return t===null?null:{partId:e,place:t}})},[Xe]),{setState:it}=w,at=(0,q.useCallback)((e,t)=>{let n=$e.current;$e.current=null,n!==null&&n.partId===e&&n.place.side===t.side&&n.place.line===t.line&&(nt(e,n.before??{...n.place,body:``}),n.state!==`raised`&&it(n.pointId,n.state))},[nt,it]),ot=sG(c,d.stages.prep===`done`),st=oG(c),{post:ct}=ot,lt=(0,q.useCallback)((e,t)=>ct({hunkId:rl(e),...t}),[ct]),ut=(0,q.useMemo)(()=>OW(ot.list?.threads??null,g,m),[ot.list,g,m]),dt=(0,q.useMemo)(()=>AW(ut,g,m),[ut,g,m]),ft=MW(we,dt,Ee),pt=Ae?Se:null,{resolve:mt}=ot,ht=(0,q.useCallback)(async(e,t)=>{let n=await mt(e,t);return n===null&&t&&De(t=>new Set(t).add(e)),n},[mt]),gt=d.pullRequest?.author.id??null,_t=(e,t)=>(0,J.jsx)(lj,{thread:e,authorId:gt,now:Date.now(),language:TD({path:e.path,language:null}),covered:t,mediaUrl:e=>i.attachmentUrl(c,e),onReply:t=>ot.reply(e.id,t),onResolve:t=>ht(e.id,t),current:pt===e.id,anchorId:wW(e.id),linesAbove:t?.length??0},e.id),vt=(e,t)=>{let n=ut.onLine.get(e)?.get(TW(t));if(n===void 0)return null;let r=m.parts.get(e)?.hunk;return n.map(e=>{let n=e.startLine??t.line;return _t(e,r===void 0?null:kW(r,Math.min(n,t.line),t.line))})},yt=e=>{let t=ut.earlier.get(e);return t===void 0?null:t.map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.outdated?`Was on ${e.side===`old`?`old `:``}line ${e.originalLine??`?`}; the code has changed since`:`On ${sj(e)}, which the diff doesn't show`}),_t(e,null)]},e.id))},bt=e=>ut.open.get(e)??0,xt=(0,q.useMemo)(()=>ee.map(e=>({...e,threads:ut.open.get(e.path)??0})),[ee,ut]),St=e=>He(t=>({id:e,n:(t?.n??0)+1})),Ct=()=>V===`overview`?null:de,wt=(0,q.useCallback)(e=>fe(e),[]),Tt=e=>{B.placeOf.has(e)&&me(t=>({key:e,n:(t?.n??0)+1}))},Et=(e,t=V)=>{if(t===`overview`){let t=m.parts.get(e)?.file.path;t!==void 0&&Tt(t)}else St(_.includes(e)?hV(e):hH)},Dt=e=>{let t=S.find(t=>t.id===e),n=N.cardPart.get(e);t?.kind===`decision`&&Fe(t=>new Set([...t,e])),O.has(e)&&A(e),be===`thread`&&xe(null),Be(new Set((t?.hunkIds??[]).flatMap(m.partsOf))),V===`overview`?n!==void 0&&Et(n):St(gU(e)),ye(e)},Ot=e=>{xe(`thread`),Ce(e),Be(new Set),V===`overview`&&H(()=>`map`),St(wW(e))},kt=e=>{if(xe(e),e===`thread`){let e=jW(dt,ft,Ee),[t]=e;t!==void 0&&!e.some(e=>e.id===Se)&&Ot(t.id);return}let t=XU(k,e,ve);t!==null&&Dt(t)},At=e=>{let t=uu.parse(`m${e+1}`),n=d.findings.find(t=>t.mismatch===`m${e+1}`);Dt(S.some(e=>e.id===t)||n===void 0?t:uu.parse(n.id))},jt=()=>{let e=(document.activeElement?.closest(`[aria-label=Changes] [data-slot=file-card]`))?.dataset.path??re;H(()=>`overview`),_e(null),e!==null&&Tt(e)},Mt=e=>{let[t]=e.kind===`outside`?[]:e.paths,n=t===void 0?e.partIds[0]:g.find(e=>e.file.path===t)?.partIds[0];n!==void 0&&(H(()=>`map`),_e(e.key),fe(n),t===void 0?Et(n,`map`):St(gH(t)))},Nt=()=>{if(V===`map`)return jt();let e=[...B.rows.flat(),...B.strip].find(e=>e.key===he.current);if(e!==void 0&&e.kind!==`outside`)return Mt(e);H(()=>`map`)};Ip({label:`Layout`,options:hG,value:V,onChange:e=>{e!==V&&Nt()},toggle:{label:`Decisions`,checked:b,onChange:e=>x(()=>e)}});let Pt=e=>{let t=[...document.querySelectorAll(`[aria-label=Changes] [data-slot=file-card]`)],n=t.findIndex(e=>e.contains(document.activeElement)),r=n===-1?e===1?t.find(e=>e.getBoundingClientRect().top>1):t.findLast(e=>e.getBoundingClientRect().top<-1):t[n+e];r!==void 0&&St(r.id)},Ft=(e,t=!1)=>{let n=N.cardPart.get(e.id),r=n===void 0?void 0:m.parts.get(n);if(p||n===void 0||r===void 0)return;let i=e.lines===null?null:{side:e.lines.side,line:e.lines.line,...e.lines.startLine===e.lines.line?{}:{startLine:e.lines.startLine}},a=r.hunk.lines.find(e=>e.kind!==`context`),o=i??(a===void 0?null:_j(a));if(o===null)return;let s=e.explanation===``?e.title:`${e.title}\n\n${e.explanation}`,c=rl(n),l=Ye.find(e=>e.hunkId===c&&e.side===o.side&&e.line===o.line),u={...e.suggestion===null?{}:{suggestion:e.suggestion}};l===void 0?nt(n,{...o,body:s,...u}):w.stateOf(e.id)!==`raised`&&!l.body.includes(s)&&nt(n,{...u,...l,body:l.body===``?s:`${l.body}\n\n${s}`}),ye(e.id);let d=w.stateOf(e.id);if(w.setState(e.id,`raised`),t)return;let{startLine:f}=l??o,h={side:o.side,line:o.line,...f===void 0?{}:{startLine:f}};Qe({partId:n,place:h}),$e.current={partId:n,place:h,before:l,pointId:e.id,state:d},St(hV(n))},It=()=>{let e=Ct(),t=e===null?void 0:m.parts.get(e),n=t?.hunk.lines.find(e=>e.kind!==`context`);if(!l||t===void 0||n===void 0)return;let r=_j(n);r!==null&&e!==null&&($e.current=null,Qe({partId:e,place:r}))},Lt=()=>{let e=document.activeElement;if(!(e instanceof HTMLElement))return;let t=[...(e.closest(`[role=row]`)??e.closest(`[data-slot=hunk-card]`)??e.closest(`[data-slot=file-card]`))?.querySelectorAll(`[data-slot=call]`)??[]],n=t[(t.findIndex(e=>e.hasAttribute(`data-popup-open`))+1)%t.length];n!==void 0&&U.open(n.id)},Rt=()=>{if(ze.size>0)return Be(new Set);V===`map`&&ge!==null&&(H(()=>`overview`),me(e=>({key:ge,n:(e?.n??0)+1})),_e(null))},zt=l;_k({...V===`map`?{nextFile:()=>Pt(1),previousFile:()=>Pt(-1),comment:It,openCall:Lt,close:Rt}:{},toggleLayout:()=>Nt(),openReview:()=>{zt&&Wt()},help:()=>Ge(!0)},!W&&!We&&!qe);let Bt=d.pullRequest?.url??hf(d.key.ref),Vt=Dp(i.startAnalysis),Ht=Dp(i.retryAnalysis),Ut=e=>{e===c?r():A_(D_(e))},Wt=()=>Ue(!0),Gt=Ye.length,Kt=(0,q.useMemo)(()=>pH(d.files),[d.files]),qt=w.failure===null?``:S.find(e=>e.id===w.failure?.pointId)?.title??``,Jt=async(e,t)=>{let n=await i.addPreference({...t,source:`learned`});return n.ok?(w.setState(e.id,`dismissed`),null):dL(n.error)},Yt=e=>({state:w.stateOf(e.id),saving:w.isSaving(e.id),readOnly:p,current:je===e.id,onRaise:ln.raisePoint,onState:ln.setPointState,leftOut:O.has(e.id),onShow:A,ruleScopes:dn,onRule:ln.saveRule}),Xt=(e,t)=>{let n=t===null?void 0:m.parts.get(t),r=e.lines,i=t!==null&&r!==null&&tt(t).some(e=>e.side===r.side&&e.line===r.line);return(0,J.jsx)(RU,{point:e,...Yt(e),linesAbove:P.rowsAbove.get(e.id)??0,inReview:i,removed:n===void 0||r===null||r.side===`old`?null:kW(n.hunk,r.startLine,r.line),language:n===void 0?null:TD(n.file)},e.id)},Zt=e=>(0,J.jsx)(VU,{point:e,...Yt(e),linesAbove:P.rowsAbove.get(e.id)??0,test:ue.get(e.id)??null},e.id),Qt=e=>(0,J.jsx)(UU,{point:e,...Yt(e)},e.id),$t=(e,t=null)=>e.kind===`finding`?Xt(e,t):e.kind===`risk`?Zt(e):Qt(e),en=(0,q.useMemo)(()=>{let e={finding:0,risk:1,decision:2},t=new Map;for(let[n,r]of N.cards){let i=new Map;for(let t of r){if(t.lines===null||t.kind===`decision`||O.has(t.id))continue;let{side:n,startLine:r,line:a}=t.lines,o=L(t.id);for(let s=r;s<=a;s+=1){let c=`${n}:${s}`,l=i.get(c);l!==void 0&&e[t.kind]>=e[l.kind]||i.set(c,{kind:t.kind,...o===void 0?{}:{landing:{at:o,line:s-r,lines:a-r+1}}})}}i.size>0&&t.set(n,i)}return t},[N,L,O]),tn=(0,q.useCallback)(e=>en.get(e),[en]),nn=(e,t,n)=>{let[r]=e;return r===void 0?null:(0,J.jsx)(GU,{pointId:r.id,fresh:e.some(e=>M.fresh(e.id)),at:L(r.id),...t,children:n},r.id)},rn=e=>{let t=P.underHeader.get(e)??mG,n=N.mentions.get(e)??mG;return nn([...t,...n],{bodyClassName:`flex flex-col gap-2 border-b bg-surface-subtle p-3`},(0,J.jsxs)(J.Fragment,{children:[t.map(t=>$t(t,e)),n.map(e=>(0,J.jsx)(WU,{point:e,onGo:ln.goToPoint},e.id))]}))},an=(e,t)=>{let n=TW(t),r=P.underLine.get(e)?.get(n)??mG,i=(P.atLineEnd.get(e)?.get(n)??mG).filter(e=>Pe.has(e.id));return(0,J.jsxs)(J.Fragment,{children:[nn(r,{row:!0,className:vj,bodyClassName:`flex max-w-3xl flex-col gap-2 py-2 pr-3 pl-29 font-sans`},r.map(t=>$t(t,e))),i.length>0&&(0,J.jsx)(bj,{inset:!0,children:(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(Qt)})})]})},on=(e,t)=>{let n=P.atLineEnd.get(e)?.get(TW(t));return n===void 0?null:n.map(e=>(0,J.jsx)(HU,{point:e,state:w.stateOf(e.id),open:Pe.has(e.id),current:je===e.id,onToggle:Ie},e.id))},sn=(0,q.useCallback)(e=>{let t=P.underLine.get(e);if(t===void 0)return;let n=[...t].filter(([,e])=>e.some(e=>e.kind===`finding`&&!O.has(e.id)));return new Set(n.map(([e])=>e))},[P,O]),cn=(0,q.useRef)({goToPoint:Dt,raisePoint:Ft,saveRule:Jt});cn.current={goToPoint:Dt,raisePoint:Ft,saveRule:Jt};let ln=(0,q.useMemo)(()=>({goToPoint:e=>cn.current.goToPoint(e),raisePoint:(e,t)=>cn.current.raisePoint(e,t),saveRule:(e,t)=>cn.current.saveRule(e,t),setPointState:w.setState}),[w.setState]),un=d.key.ref.repo,dn=(0,q.useMemo)(()=>UR([un]).reverse(),[un]),fn=e=>{let t=[wG(d),p,ze.has(e),Ze?.partId===e?`${Ze.place.side}${Ze.place.line}`:``,...tt(e).map(e=>JSON.stringify(e))];ut.onLine.has(e)&&t.push(wG(ut),pt??``);let n=N.cards.get(e)??mG,r=N.mentions.get(e)??mG;for(let e of n)t.push(e.id,w.stateOf(e.id),w.isSaving(e.id)),t.push(je===e.id,O.has(e.id)),e.kind===`decision`&&t.push(Pe.has(e.id));for(let e of r)t.push(e.id);for(let e of[...n,...r])t.push(M.fresh(e.id),L(e.id)??``);return t.join(`\0`)},pn={index:m,unchangedOf:se,highlighted:ze,commentsOf:tt,openComment:Ze,onOpenComment:rt,onCancelComment:at,onComment:l?nt:void 0,...l?{onCommentNow:lt}:{},onFocusHunk:wt,marksOf:le,pointsOn:rn,pointsAt:an,pointsAtEnd:on,flaggedOf:sn,pointLinesOf:tn,threadsAt:vt,earlierThreads:yt,openThreads:bt,...xG[d.key.ref.repo.host]===void 0?{}:{rangeNote:xG[d.key.ref.repo.host]}},mn=(0,J.jsx)(J.Fragment,{children:N.unplaced.length>0&&(0,J.jsx)(`section`,{"aria-label":`Points on no change shown here`,children:nn(N.unplaced,{bodyClassName:`flex flex-col gap-2`},N.unplaced.map(e=>$t(e)))})});return(0,J.jsxs)(`div`,{"data-slot":`review-page`,"data-layout":V,"data-landing":M.phase,className:`mx-auto flex max-w-[1600px] flex-col gap-4`,children:[(0,J.jsx)(CW,{view:e,intent:(0,J.jsx)(OV,{analysis:o,through:ne,running:M.running,onDetails:()=>{Ke.current=!0,Je(!0)}}),totals:Kt,threads:ot.list===null?null:mH(ot.list.threads),status:st.status,statusError:st.error,onRetryStatus:st.reload,now:Date.now(),reanalyzing:Vt.pending,reanalyzeError:Vt.error,onReanalyze:async()=>{let e=await Vt.run({url:Bt});e.ok&&Ut(e.value.analysisId)}}),(0,J.jsx)(_W,{title:o.pullRequest?.title??null,claude:(0,J.jsx)(dV,{analysis:o,choice:a,running:M.running,startedAt:Le,starting:f.pending,error:f.error===null?null:Ap(f.error),points:k,leftOut:O.size,threads:RW(dt,ft,Ee),narrowed:be,onNarrow:kt,onRun:async()=>{let e=a.chosen?.id;(await f.run(c,e===void 0?{}:{optionId:e})).ok&&(Re(Date.now()),n())},children:Ae?dt.length>0&&(0,J.jsx)(BW,{ordered:dt,scope:ft,resolvedHere:Ee,current:Se,onGo:Ot,onOpenList:()=>ke(!0)}):(0,J.jsx)(tW,{points:k,current:ve,stateOf:w.stateOf,kind:be,onGo:Dt,onOpenList:()=>Ne(!0)})}),tools:V===`map`&&(0,J.jsx)($,{variant:`outline`,size:`sm`,className:`lg:hidden`,"aria-expanded":ie,"aria-controls":`review-tree-rail`,onClick:()=>ae(!ie),children:ie?`Hide files`:`Show files`}),publish:zt&&(0,J.jsxs)($,{size:`sm`,"data-slot":`publish-button`,className:`shrink-0`,onClick:()=>void Wt(),children:[`Publish review…`,Gt>0&&(0,J.jsxs)(`span`,{className:`tabular rounded-full bg-primary-foreground px-1.5 text-caption text-primary`,children:[Gt,(0,J.jsx)(`span`,{className:`sr-only`,children:` to post`})]})]}),publication:s,hairline:M.running?`running`:M.phase===`landing`?`finishing`:null}),!l&&(0,J.jsx)(oW,{stages:o.stages,shown:cW,filesFetched:o.filesFetched}),o.error!==null&&(0,J.jsxs)(`div`,{className:X(`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,`flex flex-col items-start gap-2`),role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`The analysis failed at the `,sW(o.error.stage).toLowerCase(),` stage:`,` `,o.error.message]}),Ht.error!==null&&(0,J.jsxs)(`p`,{children:[`Couldn't retry. `,Ap(Ht.error)]}),(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:Ht.pending,onClick:async()=>{let e=await Ht.run(c);e.ok&&Ut(e.value.analysisId)},children:Ht.pending?`Retrying…`:`Retry`})]}),w.failure!==null&&(0,J.jsxs)(`div`,{className:X(`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,`flex flex-wrap items-center justify-between gap-2`),role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`Couldn't save what you did with “`,qt,`”. `,w.failure.message]}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,onClick:w.dismissFailure,children:`Dismiss`})]}),ot.error!==null&&(0,J.jsxs)(`div`,{role:`status`,className:X(`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,`flex flex-wrap items-center gap-3`),children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),`Couldn't read the comments on the pull request. `,Ap(ot.error)]}),(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:ot.reload,children:`Try again`})]}),d.stages.prep===`done`?V===`map`?(0,J.jsxs)(`div`,{className:X(pG,`[&>aside]:hidden lg:[&>aside]:flex`,ie&&`[&>aside]:flex`),children:[(0,J.jsx)(mW,{children:(0,J.jsx)(oF,{files:xt,activePath:re,onSelect:e=>St(gH(e)),className:`min-h-0 flex-1`})}),(0,J.jsx)(xH,{analysis:d,files:g,deps:pn,before:mn,after:ut.elsewhere.length>0&&(0,J.jsxs)(`section`,{"aria-label":`Comments on other files`,className:`flex flex-col gap-2 rounded-lg border bg-surface-subtle p-3`,children:[(0,J.jsx)(`h2`,{className:`text-caption font-medium text-muted-foreground`,children:`Comments on files without a card here`}),ut.elsewhere.map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`font-mono text-code-compact`,children:e.path}),_t(e,null)]},e.id))]}),trailingProofs:v,mechanicalCount:y,scrollRequest:Ve,signatureOf:fn})]}):(0,J.jsx)(`div`,{children:(0,J.jsx)(mU,{overview:B,focusKey:pe,currentPath:re,onOpen:Mt,onExpand:e=>te(t=>[...t,e]),expandedGroups:z,onCollapse:e=>te(t=>t.filter(t=>t!==e)),onFocusNode:e=>{he.current=e}})}):(0,J.jsx)(`section`,{"aria-busy":d.status===`running`,children:(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:d.status===`running`?`Reading the diff…`:`The diff couldn't be read, so there are no changes to show.`})}),(0,J.jsxs)(`footer`,{className:`flex items-center justify-end gap-3`,children:[(0,J.jsx)(zH,{calls:o.modelCalls,option:o.modelOption,guidance:o.guidance,leftOut:S.filter(e=>e.guidance?.effect===`left-out`).length}),l&&!u&&Hu(o)&&(0,J.jsx)(hW,{analysisId:c,family:j,onRemoved:t=>r({...e,...t})}),(0,J.jsx)(NH,{usage:o.usage,option:o.modelOption,guidance:o.guidance})]}),W&&(0,J.jsx)(pW,{analysisId:c,hunkComments:Ye,isAuthor:e.isAuthor,published:s!==null,onClose:()=>Ue(!1),onPublished:()=>{Ue(!1),Xe(()=>[]),ot.reload(),st.reload(),t()}}),Oe&&(0,J.jsx)(VW,{ordered:dt,scope:ft,onScope:Te,onGo:e=>{ke(!1),Ot(e)},onClose:()=>ke(!1)}),Me&&(0,J.jsx)(qU,{points:k,family:j,kind:be===`thread`?null:be,stateOf:w.stateOf,onGo:e=>{Ne(!1),Dt(e)},onClose:()=>Ne(!1)}),(0,J.jsx)($N,{open:We,onOpenChange:Ge,ids:gG}),(0,J.jsx)(kj,{handle:U,onGoTo:e=>St(hV(e))}),qe&&(0,J.jsxs)(SB,{title:d.intent===null?`What was asked`:`Intent`,onClose:()=>Je(!1),className:`sm:max-w-4xl`,returnFocus:()=>Ke.current,children:[d.intent===null?d.pullRequest!==null&&(0,J.jsx)(AV,{pullRequest:d.pullRequest,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys}):(0,J.jsx)(zV,{intent:d.intent,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys,onSelectMismatch:e=>{Ke.current=!1,Je(!1),At(e)}}),(0,J.jsx)(_G,{analysis:d})]}),(0,J.jsxs)(`p`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground`,children:[`Press `,(0,J.jsx)(bk,{id:`help`}),` for keyboard shortcuts.`]})]})},EG={theme:`megareviewer:theme`,diffPalette:`megareviewer:diffPalette`},DG=`(prefers-color-scheme: dark)`,OG=e=>e===`light`||e===`dark`?e:`system`,kG=e=>e===`cb`?`cb`:`default`,AG=(e,t)=>e===`system`?t?`dark`:`light`:e,jG=(e,t,n)=>{e.classList.toggle(`dark`,t===`dark`),n===`cb`?e.dataset.diffPalette=`cb`:delete e.dataset.diffPalette},MG=e=>{try{let t=window.localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}},NG=(e,t)=>{try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}},PG=new Set,FG=()=>{for(let e of PG)e()},IG=e=>{PG.add(e);let t=window.matchMedia(DG);return t.addEventListener(`change`,e),window.addEventListener(`storage`,e),()=>{PG.delete(e),t.removeEventListener(`change`,e),window.removeEventListener(`storage`,e)}},LG=()=>`${OG(MG(EG.theme))} ${kG(MG(EG.diffPalette))} ${window.matchMedia(DG).matches}`,RG=()=>{let[e=`system`,t=`default`,n]=(0,q.useSyncExternalStore)(IG,LG).split(` `),r=OG(e),i=kG(t),a=AG(r,n===`true`);return(0,q.useEffect)(()=>{jG(document.documentElement,a,i)},[a,i]),{theme:r,resolvedTheme:a,diffPalette:i,setTheme:(0,q.useCallback)(e=>{NG(EG.theme,e),FG()},[]),setDiffPalette:(0,q.useCallback)(e=>{NG(EG.diffPalette,e),FG()},[])}},zG={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius-xl)`},BG=({...e})=>{let{resolvedTheme:t}=RG();return(0,J.jsx)(gN,{theme:t,className:`toaster group`,icons:{success:(0,J.jsx)(Jh,{className:`size-4`}),info:(0,J.jsx)(Pg,{className:`size-4`}),warning:(0,J.jsx)(v_,{className:`size-4`}),error:(0,J.jsx)(Jg,{className:`size-4`}),loading:(0,J.jsx)(Hg,{className:`size-4 animate-spin`})},style:zG,toastOptions:{classNames:{toast:`cn-toast`}},...e})},VG={github:`GitHub`,bitbucket:`Bitbucket`},HG=`then restart megareviewer.`,UG={github:{connect:`Set GITHUB_TOKEN or run \`gh auth login\`, ${HG}`,adds:`Lists and opens GitHub pull requests.`},bitbucket:{connect:`Set BITBUCKET_EMAIL and BITBUCKET_API_TOKEN, and BITBUCKET_WORKSPACE to list its pull requests, ${HG}`,adds:`Lists and opens Bitbucket pull requests.`}},WG=e=>e===1?`1 pull request`:`${e} pull requests`,GG=(e,t,n,r,i)=>{let a=VG[e],{connect:o,adds:s}=UG[e];if(!t.configured)return n.configured?{kind:e,name:a,state:`optional`,detail:s,fix:o}:{kind:e,name:a,state:`not-connected`,detail:`${a} isn't configured.`,fix:o};if(t.user===null)return{kind:e,name:a,state:`failing`,detail:t.error??`Couldn't read the signed-in ${a} user.`,fix:`Check the token, ${HG} A network failure needs only Check again.`};let c=r?.counts[e];return{kind:e,name:a,state:`working`,detail:c===void 0||r===null?t.user.name:`${t.user.name} · ${WG(c)} listed ${hF(new Date(r.atMs).toISOString(),i)}`,fix:null}},KG={claude:{name:`Claude`,providers:[`claude-code`,`anthropic-api`],adds:`Adds intent, findings, risks and decisions with Request AI review.`,connect:"Run `claude` and sign in, or set ANTHROPIC_API_KEY."},codex:{name:`Codex`,providers:[`codex`],adds:`Adds OpenAI's GPT models to Request AI review, on your ChatGPT plan.`,connect:"Install the Codex CLI and run `codex login`."},opencode:{name:`opencode`,providers:[`opencode`],adds:`Adds the models of the providers you connected in opencode to Request AI review.`,connect:"Install opencode (https://opencode.ai) and connect a provider with `opencode auth login`."}},qG=e=>e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`,JG=(e,t,n)=>{if(e===`claude`){let e=t.find(e=>e.id===n)??t[0];return e===void 0?``:`${e.modelName} through ${e.via}`}if(e===`codex`)return`${qG(t.map(e=>e.modelName))} through ${t[0]?.via??`Codex`}`;let r=[...new Set(t.map(e=>e.via.replace(/^opencode, on /,``)))];return`${t.length===1?`1 model`:`${t.length} models`} through ${qG(r)}`},YG=(e,{options:t,defaultId:n})=>{let{name:r,providers:i,adds:a,connect:o}=KG[e],s=t.filter(e=>i.includes(e.provider)),c=s.filter(e=>e.available);if(c.length>0)return{kind:e,name:r,state:`working`,detail:JG(e,c,n),fix:null};let l=[...new Set(s.flatMap(e=>e.reason??[]))];return{kind:e,name:r,state:`optional`,detail:a,fix:l.length>0?l.join(`; or `):`${o.slice(0,-1)}, ${HG}`}},XG=e=>e?{kind:`jira`,name:`Jira`,state:`working`,detail:`Links tickets`,fix:null}:{kind:`jira`,name:`Jira`,state:`optional`,detail:`Reads the tickets a pull request names.`,fix:`Set JIRA_BASE_URL, JIRA_EMAIL and JIRA_API_TOKEN, ${HG}`},ZG={failing:0,"not-connected":1,working:2,optional:2,checking:2},QG=(e,t)=>e===1?`1 ${t}`:`${e} ${t}s`,$G=[[`github`,`GitHub`],[`bitbucket`,`Bitbucket`],[`claude`,`Claude`],[`codex`,`Codex`],[`opencode`,`opencode`],[`jira`,`Jira`]],eK=e=>{let{status:t,error:n,checking:r,checkedAtMs:i,listed:a,nowMs:o}=e;if(n!==null&&!r)return{rows:[],button:{label:`Disconnected`,tone:`danger`,name:`Connections: megareviewer's server isn't answering. Open for details.`},summary:`megareviewer's server isn't answering`,disconnected:Ap(n)};if(t===null)return{rows:$G.map(([e,t])=>({kind:e,name:t,state:`checking`,detail:``,fix:null})),button:{label:`Checking…`,tone:`checking`,name:`Connections: checking. Open for details.`},summary:`Checking ${$G.length} connections…`,disconnected:null};let{github:s,bitbucket:c}=t.hosts,l=[GG(`github`,s,c,a,o),GG(`bitbucket`,c,s,a,o),YG(`claude`,t.model),YG(`codex`,t.model),YG(`opencode`,t.model),XG(t.jira.configured)].sort((e,t)=>ZG[e.state]-ZG[t.state]),u=e=>l.filter(t=>t.state===e).length,d=u(`failing`),f=u(`not-connected`),p=u(`working`),m=u(`optional`),h=d+f,g=[...d>0?[`${d} failing`]:[],...f>0?[`${f} not connected`]:[],...p>0?[`${p} working`]:[],...m>0&&h===0?[`${m} optional`]:[]],_=i===null?``:` · checked ${hF(new Date(i).toISOString(),o)}`,v=h>0?g.join(` · `):p===l.length?`All ${p} working${_}`:`${g.join(` · `)}${_}`,y=`Connections: ${g.join(` · `)}. ${h>0?`Open to fix.`:`Open for details.`}`;return r?{rows:l.map(e=>({...e,state:`checking`})),button:{label:`Checking…`,tone:`checking`,name:`Connections: checking. Open for details.`},summary:`Checking ${l.length} connections…`,disconnected:null}:{rows:l,button:{...h>0?{label:QG(h,`issue`),tone:d>0?`danger`:`warning`}:p===l.length?{label:`All connected`,tone:`ok`}:{label:`${p} of ${l.length} connected`,tone:`ok`},name:y},summary:v,disconnected:null}},tK={checking:`text-muted-foreground`,ok:``,warning:`border-review-pending bg-review-pending-bg text-review-pending hover:bg-review-pending-bg hover:text-review-pending aria-expanded:bg-review-pending-bg aria-expanded:text-review-pending`,danger:`border-destructive bg-review-changes-bg text-destructive hover:bg-review-changes-bg hover:text-destructive aria-expanded:bg-review-changes-bg aria-expanded:text-destructive`},nK={github:Og,bitbucket:Og,claude:f_,codex:f_,opencode:f_,jira:m_},rK={working:{label:`Connected`,icon:Rh,tone:`text-ci-success`,row:``},failing:{label:`Failing`,icon:v_,tone:`text-destructive`,row:`border-l-3 border-l-destructive bg-review-changes-bg`},"not-connected":{label:`Not connected`,icon:Xh,tone:`text-review-pending`,row:`border-l-3 border-l-review-pending bg-review-pending-bg`},optional:{label:`Not connected · Optional`,icon:Xh,tone:`text-muted-foreground`,row:``},checking:{label:`Checking…`,icon:Hg,tone:`text-muted-foreground`,row:``}},iK=new Set([`claude`,`codex`,`opencode`]),aK=({className:e})=>(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,e)}),oK=({tone:e})=>e===`checking`?(0,J.jsx)(aK,{}):e===`ok`?(0,J.jsx)(Rh,{"aria-hidden":`true`,className:`text-ci-success`}):(0,J.jsx)(v_,{"aria-hidden":`true`}),sK=({row:e})=>{let t=rK[e.state],n=e.state===`optional`&&iK.has(e.kind)?`Not connected`:t.label,r=nK[e.kind],i=t.icon;return(0,J.jsxs)(`li`,{"data-state":e.state,className:X(`flex flex-col gap-0.5 rounded-md px-2.5 py-2`,t.row,e.state===`optional`&&`text-muted-foreground`),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,J.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,J.jsxs)(`span`,{className:X(`ml-auto flex items-center gap-1 text-caption`,t.tone),children:[(0,J.jsx)(i,{"aria-hidden":`true`,className:X(`size-3.5`,e.state===`checking`&&`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`)}),n]})]}),e.detail!==``&&(0,J.jsx)(`p`,{className:`text-caption`,children:e.detail}),e.fix!==null&&(0,J.jsx)(`p`,{className:`text-caption`,children:e.fix})]})},cK=({connections:e,version:t,checking:n,onCheckAgain:r,checkAgainRef:i})=>(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1`,children:[(0,J.jsx)(TM,{className:`text-heading font-semibold`,children:`Connections`}),(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:e.summary})]}),e.disconnected===null?(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.rows.map(e=>(0,J.jsx)(sK,{row:e},e.kind))}):(0,J.jsx)(`p`,{className:`rounded-md border-l-3 border-l-destructive bg-review-changes-bg px-2.5 py-2 text-caption`,children:e.disconnected}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-1 pt-2`,children:[(0,J.jsxs)($,{ref:i,variant:`outline`,size:`sm`,onClick:r,"aria-busy":n,"aria-disabled":n,children:[n&&(0,J.jsx)(aK,{}),`Check again`]}),t!==null&&(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`megareviewer `,t]})]})]}),lK=({connections:e,version:t,checking:n,open:r,onOpenChange:i,onCheckAgain:a,focusCheckAgain:o=!1})=>{let s=(0,q.useCallback)(e=>{e!==null&&o&&e.focus()},[o]),{label:c,tone:l,name:u}=e.button;return(0,J.jsxs)(SM,{...r===void 0?{}:{open:r},...i===void 0?{}:{onOpenChange:e=>i(e)},children:[(0,J.jsxs)(CM,{render:(0,J.jsx)($,{variant:`outline`,size:`sm`,className:tK[l],"data-tone":l,"aria-label":u}),children:[(0,J.jsx)(oK,{tone:l}),c]}),(0,J.jsx)(wM,{align:`end`,className:`w-[min(340px,calc(100vw-24px))] p-2`,initialFocus:!1,children:(0,J.jsx)(cK,{connections:e,version:t,checking:n,onCheckAgain:()=>{n||a()},checkAgainRef:s})})]})},uK=({now:e=Date.now})=>{let t=PF(),{status:n,error:r,checking:i,checkedAtMs:a,listed:o,open:s,setOpen:c,focusCheckAgain:l}=t,u=eK({status:n,error:r,checking:i,checkedAtMs:a,listed:o,nowMs:e()}),{label:d,tone:f}=u.button,[p,m]=(0,q.useState)(``),h=(0,q.useRef)(!0);return(0,q.useEffect)(()=>{f!==`checking`&&(h.current?h.current=!1:m(`Connections: ${d}`))},[d,f]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lK,{connections:u,version:n?.version??null,checking:i,open:s,onOpenChange:e=>c(e),onCheckAgain:t.checkAgain,focusCheckAgain:l}),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:p})]})},dK=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}],fK=()=>{let{theme:e,diffPalette:t,setTheme:n,setDiffPalette:r}=RG(),i=Fp(),a=(0,q.useRef)(!1);return(0,J.jsxs)(fB,{children:[(0,J.jsx)(pB,{render:(0,J.jsx)($,{variant:`ghost`,size:`sm`,className:`max-sm:px-1.5`}),children:`Display`}),(0,J.jsxs)(mB,{align:`end`,className:`w-56`,finalFocus:()=>{let e=a.current;return a.current=!1,!e},children:[i!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(hB,{children:[(0,J.jsx)(gB,{children:i.label}),(0,J.jsx)(yB,{value:i.value,onValueChange:e=>{a.current=!0,i.onChange(e)},children:i.options.map(e=>(0,J.jsx)(bB,{value:e.value,closeOnClick:!0,children:e.label},e.value))})]}),(0,J.jsx)(xB,{}),i.toggle!==void 0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(vB,{checked:i.toggle.checked,onCheckedChange:i.toggle.onChange,children:i.toggle.label}),(0,J.jsx)(xB,{})]})]}),(0,J.jsxs)(hB,{children:[(0,J.jsx)(gB,{children:`Theme`}),(0,J.jsx)(yB,{value:e,onValueChange:e=>{let t=dK.find(t=>t.value===e);t!==void 0&&n(t.value)},children:dK.map(e=>(0,J.jsx)(bB,{value:e.value,children:e.label},e.value))})]}),(0,J.jsx)(xB,{}),(0,J.jsx)(vB,{checked:t===`cb`,onCheckedChange:e=>r(e?`cb`:`default`),children:`Color-blind safe diff`})]})]})},pK=({current:e})=>(0,J.jsxs)(N_,{to:S_,"aria-current":e?`page`:void 0,className:X(ly({variant:`ghost`,size:`sm`}),`min-w-7 text-foreground hover:no-underline aria-[current=page]:bg-muted max-sm:px-0`),children:[(0,J.jsx)(u_,{"aria-hidden":`true`,className:`sm:hidden`}),(0,J.jsx)(`span`,{className:`max-sm:sr-only`,children:`Preferences`})]}),mK=()=>{let e=T_(k_());return(0,J.jsxs)(`header`,{className:`flex h-12 items-center justify-between gap-4 border-b bg-background px-4 max-sm:gap-2 sm:px-6`,children:[(0,J.jsx)(N_,{to:`/`,className:`text-heading font-semibold text-foreground hover:no-underline`,children:`megareviewer`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 max-sm:gap-1`,children:[(0,J.jsx)(uK,{}),(0,J.jsx)(pK,{current:e.page===`preferences`}),(0,J.jsx)(fK,{})]})]})},hK=()=>(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Page not found`}),(0,J.jsxs)(`p`,{className:`text-body`,children:[`There's nothing at this address. `,(0,J.jsx)(N_,{to:`/`,children:`Go to your pull requests`}),`.`]})]}),gK=({reason:e})=>(0,J.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col gap-3 px-4 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Open megareviewer from your terminal`}),e===`missing`?(0,J.jsxs)(`p`,{className:`text-body`,children:[`This page needs the link megareviewer printed when it started. It looks like`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`http://127.0.0.1:4823/?token=…`}),`. Copy it from your terminal and open it once; other tabs in this browser then work without it.`]}):(0,J.jsx)(`p`,{className:`text-body`,children:`This page's session has ended, usually because megareviewer was restarted. Open the new link printed in your terminal.`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Not running? Start it with`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`npx megareviewer`}),`.`]})]}),_K=({token:e,fetch:t,openEventStream:n})=>{let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(e.value),s=(0,q.useMemo)(()=>a===null?null:{client:hp({fetch:t,token:a,onUnauthorized:()=>{let t=e.reject(a);t===null?i(!0):o(t)}}),subscribe:(e,t)=>_p(e,a,t,n)},[t,n,e,a]);return r?(0,J.jsx)(gK,{reason:`ended`}):s===null?(0,J.jsx)(gK,{reason:`missing`}):(0,J.jsx)(vp.Provider,{value:s,children:(0,J.jsx)(vK,{},a)})},vK=()=>{let e=T_(k_());return(0,J.jsx)(lI,{children:(0,J.jsx)(Pp,{children:(0,J.jsxs)(FF,{children:[(0,J.jsx)(mK,{}),(0,J.jsx)(`main`,{className:X(`px-4 py-5 sm:px-6`,(e.page===`picker`||e.page===`preferences`)&&`min-h-[calc(100dvh-3rem)] bg-surface-subtle`),children:e.page===`picker`?(0,J.jsx)(WI,{}):e.page===`preferences`?(0,J.jsx)(NB,{}):e.page===`review`?(0,J.jsx)(uG,{analysisId:e.analysisId}):e.page===`open`?(0,J.jsx)(LF,{pullRequest:e.ref},E_(e.ref)):(0,J.jsx)(hK,{})}),(0,J.jsx)(BG,{})]})})})},yK=class extends q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}render(){let{error:e}=this.state;if(e===null)return this.props.children;let t=this.props.onReload??(()=>window.location.reload());return(0,J.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 px-4 py-12`,role:`alert`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Something went wrong`}),(0,J.jsx)(`p`,{className:`text-body`,children:`megareviewer hit a bug while showing this page.`}),(0,J.jsx)(`pre`,{className:`w-full overflow-x-auto rounded-md border bg-muted p-3 font-mono text-code-compact whitespace-pre-wrap`,children:String(e)}),(0,J.jsx)($,{onClick:t,children:`Reload`})]})}},bK=`token`,xK=`megareviewer.token`,SK=e=>{let t=(()=>{try{return e.localStorage}catch{return null}})(),n=e=>{try{return t===null?null:e(t)}catch{return null}},r=new URL(e.location.href),i=r.searchParams.get(bK),a;return i!==null&&i!==``?(a=i,n(e=>e.setItem(xK,i))):a=n(e=>e.getItem(xK)),r.searchParams.has(bK)&&(r.searchParams.delete(bK),e.history.replaceState(e.history.state,``,`${r.pathname}${r.search}${r.hash}`)),{get value(){return a},reject(e){let t=n(e=>e.getItem(xK));return t===e&&n(e=>e.removeItem(xK)),a=t!==null&&t!==e?t:null,a}}},CK=document.getElementById(`root`);if(CK===null)throw Error(`index.html has no #root`);(0,xc.createRoot)(CK).render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(yK,{children:(0,J.jsx)(_K,{token:SK(window),fetch:window.fetch.bind(window)})})}));export{s as t};
86
+ `);return t.at(-1)===``&&t.pop(),t.map(e=>e.endsWith(`\r`)?e.slice(0,-1):e)},YV=(e,t)=>{let{client:n}=yp(),[r,i]=(0,q.useState)({status:`idle`}),a=(0,q.useRef)(`idle`);return{text:r,load:(0,q.useCallback)(()=>{if(a.current===`loading`||a.current===`ready`)return;let r=e=>{a.current=e.status,i(e)};r({status:`loading`}),n.getFileContent(e,`head`,t).then(e=>r(e.ok?e.value.content===null?{status:`error`,message:`The file isn't at the pull request's head commit.`}:{status:`ready`,lines:JV(e.value.content)}:{status:`error`,message:Ap(e.error)}))},[n,e,t])}},XV=()=>(0,J.jsx)(`svg`,{"data-slot":`unfold-icon`,className:`shrink-0`,viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M8 1.5v4M5.5 3.5 8 1l2.5 2.5M8 14.5v-4M5.5 12.5 8 15l2.5-2.5M2 8h12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}),ZV=e=>`${e} ${e===1?`line`:`lines`}`,QV=(e,t,n,r)=>e.map(e=>({oldNo:e+t.offset,newNo:e,text:n[e-1]??``,tokens:r?.[e-1]??null})),$V=({fold:e,file:t,hunkId:n,opened:r,text:i,onOpen:a,above:o,below:s})=>{let c=i.status===`ready`?i.lines:null,l=Qk(c,t),u=VV(e,c?.length??null);if(u===0)return null;if(r&&c!==null)return(0,J.jsx)(`div`,{"data-slot":`file-fold`,children:(0,J.jsx)(Xj,{hunkId:n,lines:QV(qV(e,c.length),e,c,l)})});let d=r&&i.status===`loading`,f=u===null?`Unchanged lines below`:`${ZV(u)} unchanged`;return(0,J.jsxs)(`div`,{"data-slot":`file-gap`,className:X(`flex flex-wrap items-center bg-surface-subtle text-muted-foreground`,vj,o&&`border-t`,s?`border-b`:`rounded-b-lg`),children:[(0,J.jsxs)(`button`,{type:`button`,"data-slot":`fold-open`,"aria-busy":d||void 0,disabled:d,onClick:a,className:X(`flex min-h-8 flex-1 items-center gap-2 px-3 cursor-pointer text-left -outline-offset-2 hover:bg-accent hover:text-foreground disabled:cursor-wait disabled:hover:bg-transparent`,!s&&`rounded-b-lg`),children:[(0,J.jsx)(XV,{}),d?(0,J.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),`Opening `,u===null?`unchanged lines below`:f]}):(0,J.jsx)(`span`,{children:f})]}),r&&i.status===`error`&&(0,J.jsx)(`span`,{role:`alert`,className:`px-3 text-destructive`,children:i.message})]})},eH=e=>e===`map`?`map`:e===`overview`||e===`tree`?`overview`:void 0,tH=(e,t)=>YP(e.path,t.path),nH=`Not classified yet.`,rH=e=>{let t=al(e.parts),n=new Map,r=new Map;for(let i of e.files){for(let e of i.hunks){let n=t.get(e.id)??[],i=n.map(e=>e.id);r.set(e.id,n.length>0?i:[e.id])}for(let e of ol(i,t)){let r=t.get(e.hunk.id)??[],a=r.findIndex(t=>t.id===e.id),o=r[a];n.set(e.id,{hunk:e.hunk,file:i,place:o===void 0?null:{n:a+1,of:r.length,definitions:o.definitions,siblings:r.map(e=>e.id)}})}}let i=new Map(e.risk.map(e=>[e.hunkId,e])),a=new Map;for(let t of e.proofs)t.hunkId!==null&&a.set(t.hunkId,[...a.get(t.hunkId)??[],t]);let o=new Set(a.keys()),s=e=>{let t=rl(e);return i.get(t)??{hunkId:t,riskClass:`logic`,reason:nH,source:`fallback`,lines:null,guidance:null}},c=e=>e.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[{...t,id:e,hunkId:rl(e),risk:s(e),proofs:a.get(e)??[]}]}),l=e=>r.get(e)??[];return{parts:n,mechanical:o,items:c,partsOf:l,partsInFile:e=>e.hunks.flatMap(e=>l(e.id))}},iH=(e,t)=>[...e.files].sort(tH).flatMap(e=>e.hunks.flatMap(e=>t.partsOf(e.id))).filter(e=>!t.mechanical.has(e)),aH=(e,t)=>{let n=e.tour?.steps??[],r=new Set(n.flatMap(e=>e.partIds)),i=iH(e,t).filter(e=>!r.has(e));return i.length===0?n:[...n,{id:yu.parse(`s${n.length+1}`),title:`Changes the tour left out`,explanation:`The tour didn't include these changes, so they're shown here in file order.`,partIds:i,kind:`supporting`,via:[],entries:[],codeTitle:null,merged:[]}]},oH=(e,t)=>[...e.files].sort((e,t)=>YP(e.path,t.path)).flatMap(e=>{let n=t.partsInFile(e);return n.every(e=>t.mechanical.has(e))?[]:[{file:e,partIds:n}]}),sH=(e,t,n)=>{let r=n.parts.get(e),i=n.parts.get(t);if(r===void 0||i===void 0||r.file!==i.file)return null;let a=r.file.status===`deleted`?`old`:`new`,o=e=>a===`old`?{start:e.oldStart,count:e.oldLines}:{start:e.newStart,count:e.newLines},s=o(r.hunk),c=o(i.hunk),l=s.count===0?s.start:s.start+s.count-1,u=c.count===0?c.start+1:c.start;return Math.max(u-l-1,0)},cH=(e,t,n)=>{let r=new Map(t.map((e,t)=>[e,t])),i=new Map,a=new Map,o=new Map,s=[],c=(e,t,n)=>e.set(t,[...e.get(t)??[],n]);for(let t of e){let e=[...new Set(t.hunkIds)].flatMap(n.partsOf).filter(e=>r.has(e)&&!n.mechanical.has(e)).sort((e,t)=>(r.get(e)??0)-(r.get(t)??0)),l=t.lines===null?void 0:lH(t.lines,e,n),[u=l,...d]=l===void 0?e:[l,...e.filter(e=>e!==l)];if(u===void 0){s.push(t);continue}c(i,u,t),o.set(t.id,u);let f=l===void 0?null:rl(u);for(let e of d)rl(e)!==f&&c(a,e,t)}return{cards:i,mentions:a,cardPart:o,unplaced:s}},lH=(e,t,n)=>t.find(t=>n.parts.get(t)?.hunk.lines.some(t=>{let n=_j(t);return n!==null&&n.side===e.side&&n.line===e.startLine})),uH=e=>{let t=new Set,n=0;for(let r of e)r.hunkId===null?n+=1:t.add(r.hunkId);return t.size+n},dH=(e,t)=>{let n=new Set([...t.parts].flatMap(([e,{file:n}])=>t.mechanical.has(e)?[]:[n.path]));return e.proofs.filter(e=>e.hunkId===null||!n.has(e.path))},fH=(e,t)=>{let n=new Map;for(let r of e){let e=t.partsOf(r.hunkId).find(e=>t.parts.get(e)?.hunk.lines.some(e=>{let t=_j(e);return t!==null&&t.side===r.side&&t.line===r.line}));e!==void 0&&n.set(e,[...n.get(e)??[],r])}return n},pH=e=>({files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}),mH=e=>({threads:e.length,unresolved:e.filter(e=>!e.resolved).length}),hH=`mechanical-changes`,gH=e=>`file-${e}`,_H=(0,q.memo)(function({render:e}){return e()},(e,t)=>e.signature===t.signature),vH=({id:e,joined:t,deps:n,signatureOf:r})=>(0,J.jsx)(`div`,{id:hV(e),className:X(`scroll-mt-24`,!t&&`border-t first:border-t-0`),"data-hunk-id":e,children:(0,J.jsx)(_H,{signature:r(e),render:()=>(0,J.jsx)(_V,{id:e,deps:n})})}),yH=({lines:e})=>e===0?null:(0,J.jsx)(`div`,{"data-slot":`file-gap`,className:X(`flex h-8 items-center gap-2 border-t bg-surface-subtle px-3 text-muted-foreground`,vj),children:(0,J.jsxs)(`span`,{children:[e,` `,e===1?`line`:`lines`,` unchanged`]})}),bH=({analysisId:e,group:t,deps:n,signatureOf:r})=>{let i=n.index.items(t.partIds),a=i.reduce((e,t)=>e+Nk(t.hunk).added,0),o=i.reduce((e,t)=>e+Nk(t.hunk).deleted,0),s=n.openThreads(t.file.path),c=n.earlierThreads(t.file.path),{text:l,load:u}=YV(e,t.file.path),[d,f]=(0,q.useState)(new Set),p=(0,q.useMemo)(()=>GV(t.file)?KV(t.partIds,n.index):[],[t,n.index]),m=e=>`${e.after??``}>${e.before??``}`,h=e=>{let r=m(e),i=e.before??e.after,a=i===null?void 0:n.index.parts.get(i);return a===void 0?null:(0,J.jsx)($V,{fold:e,file:t.file,hunkId:a.hunk.id,opened:d.has(r),text:l,above:e.after!==null,below:e.before!==null,onOpen:()=>{u(),f(e=>new Set(e).add(r))}},r)};return(0,J.jsxs)(`section`,{id:gH(t.file.path),"data-slot":`file-card`,className:`scroll-mt-2 rounded-lg border bg-card -outline-offset-2`,"aria-label":t.file.path,"data-path":t.file.path,tabIndex:-1,children:[(0,J.jsxs)(`header`,{"data-slot":`file-card-header`,className:`sticky top-[var(--review-bar-h,0px)] z-10 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-t-lg border-b bg-card px-3 py-2`,children:[(0,J.jsx)(JD,{file:t.file,status:t.file.status,className:`min-w-0 flex-1`}),(0,J.jsx)(YD,{status:t.file.status}),(0,J.jsxs)(`span`,{className:`tabular flex flex-wrap items-center gap-x-1.5 text-caption`,children:[s>0&&(0,J.jsxs)(`span`,{"data-slot":`count-threads`,className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,J.jsx)(sF,{count:s}),(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}),(0,J.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,a]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,o]})]})]})]}),(0,J.jsx)(`div`,{"data-slot":`file-lines`,className:`@container overflow-x-auto rounded-b-lg`,children:(0,J.jsxs)(`div`,{className:`w-max min-w-full`,children:[t.partIds.map((e,i)=>{let a=t.partIds[i-1],o=a===void 0?null:sH(a,e,n.index),s=p.find(t=>t.before===e);return(0,J.jsxs)(q.Fragment,{children:[s===void 0?o!==null&&(0,J.jsx)(yH,{lines:o}):h(s),(0,J.jsx)(vH,{id:e,joined:o===0||s!==void 0,deps:n,signatureOf:r})]},e)}),p.filter(e=>e.before===null).map(h)]})}),c!==null&&(0,J.jsxs)(`section`,{"data-slot":`earlier-comments`,"aria-label":`Earlier comments on ${t.file.path}`,className:`flex flex-col gap-2 border-t bg-surface-subtle px-3 py-2`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Earlier comments`}),c]})]})},xH=({analysis:e,files:t,deps:n,before:r,after:i,trailingProofs:a,mechanicalCount:o,scrollRequest:s,signatureOf:c})=>((0,q.useEffect)(()=>{if(s===null)return;let e=document.getElementById(s.id);if(e===null)return;let t=(e.dataset.hunkId===void 0?null:e.querySelector(`[data-slot=hunk-card], [data-slot=mechanical-toggle]`))??e,n=e.dataset.slot===`decision`;e.scrollIntoView({block:n?`center`:`start`}),t.focus({preventScroll:!0})},[s]),(0,J.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":`Changes`,children:[r,t.map(t=>(0,J.jsx)(bH,{analysisId:e.id,group:t,deps:n,signatureOf:c},t.file.path)),i,(0,J.jsxs)(`div`,{id:hH,className:`flex scroll-mt-2 flex-col gap-4 -outline-offset-2`,tabIndex:-1,children:[o===0&&e.stages.prep===`done`&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No mechanical changes in this pull request.`}),(0,J.jsx)(Kj,{files:e.files,proofs:a,risk:e.risk}),(0,J.jsx)(Yj,{files:e.files})]})]})),SH={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`},CH=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`,wH=e=>`$${e.toFixed(2)}`,TH=e=>e===void 0?`—`:`${(e/1e3).toFixed(1)} s`,EH=e=>e===null?null:`${e.modelName} through ${e.providerName}`,DH=new Intl.ListFormat(`en`,{type:`conjunction`}),OH=e=>{if(e===null)return null;let t=e.preferences.length,n=[...t===0?[]:[`${t} ${t===1?`preference`:`preferences`}`],...e.guidelines.map(e=>e.path)];return n.length===0?null:DH.format(n)},kH=(e,t)=>{let n=EH(e),r=OH(t);return r===null?n:n===null?`With ${r}`:`${n} with ${r}`},AH=e=>e===null?`—`:wH(e),jH=(e,t,n=`Claude`)=>{let r=e.filter(e=>e!==null),i=e.length-r.length,a=t?`on your ${n} plan`:null;if(r.length===0)return a??`cost unknown`;let o=wH(r.reduce((e,t)=>e+t,0)),s=i===0?``:`, cost unknown for ${i} ${i===1?`call`:`calls`}`;return a===null?`${o}${s}`:`≈ ${o} at API prices${s}, ${a}`},MH=e=>e.inputTokens+e.cacheWriteTokens,NH=({usage:e,option:t=null,guidance:n=null})=>{let r=(0,q.useId)();if(e.length===0)return null;let i=t=>e.reduce((e,n)=>e+t(n),0),a=e.some(e=>e.billing===`plan`),o=e.some(e=>e.durationMs!==void 0);return(0,J.jsxs)(`div`,{className:`group relative flex justify-end`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`peer tabular min-h-6 rounded-sm text-caption text-muted-foreground hover:text-foreground`,"aria-describedby":`${r}-breakdown`,children:[kH(t,n)===null?``:`${kH(t,n)} · `,`Usage: `,CH(i(MH)),` tokens in ·`,` `,CH(i(e=>e.cacheReadTokens)),` cache read ·`,` `,CH(i(e=>e.outputTokens)),` out ·`,` `,jH(e.map(e=>e.costUsd),a,Pl(t))]}),(0,J.jsxs)(`table`,{id:`${r}-breakdown`,role:`tooltip`,className:`tabular absolute right-0 bottom-full mb-2 hidden rounded-xl bg-popover p-3 text-caption text-popover-foreground shadow-md ring-1 ring-foreground/10 group-hover:table peer-focus-visible:table [&_td]:px-2 [&_td]:text-right [&_th]:px-2 [&_th]:text-left [&_thead_th]:font-medium [&_thead_th]:text-muted-foreground`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,J.jsx)(`th`,{scope:`col`,children:`In`}),(0,J.jsx)(`th`,{scope:`col`,children:`Cache read`}),(0,J.jsx)(`th`,{scope:`col`,children:`Out`}),(0,J.jsx)(`th`,{scope:`col`,children:a?`At API prices`:`Cost`}),o&&(0,J.jsx)(`th`,{scope:`col`,children:`Time`})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`row`,children:SH[e.pass]}),(0,J.jsx)(`td`,{children:CH(MH(e))}),(0,J.jsx)(`td`,{children:CH(e.cacheReadTokens)}),(0,J.jsx)(`td`,{children:CH(e.outputTokens)}),(0,J.jsx)(`td`,{children:AH(e.costUsd)}),o&&(0,J.jsx)(`td`,{children:TH(e.durationMs)})]},e.pass))})]})]})},PH={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`},FH=e=>{let t=Math.round(e/1e3);return`+${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},IH=e=>{if(e.outcome===`ok`)return`✓ Answered`;if(e.outcome===`failed`)return`✕ Failed: ${e.error?.kind??`unknown`}`;let t=e.problems.length;return`⚠ ${t} ${t===1?`problem`:`problems`}`},LH=e=>[...e].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)||e.attempt-t.attempt),RH=({guidance:e,leftOut:t})=>{let n=OH(e);return n===null?null:(0,J.jsxs)(`section`,{"aria-label":`What the run read beside the code`,className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`h3`,{className:`font-medium`,children:`Read beside the code`}),(0,J.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[n,`, as they were when the run started.`,` `,t===0?`No point was left out by them.`:`${t} ${t===1?`point was`:`points were`} left out by them, folded where ${t===1?`its card`:`their cards`} would be.`,` `,(0,J.jsx)(N_,{to:S_,className:`underline`,children:`Preferences`})]}),(0,J.jsxs)(`ul`,{className:`flex flex-col gap-1 text-ui`,children:[e.preferences.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,J.jsx)(pB,{kind:e.kind}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 break-words`,children:e.text}),(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.scope.kind===`global`?`Everywhere`:gB(e.scope.repo)})]},e.ref)),e.guidelines.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(cg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`font-mono text-code-compact break-all`,children:e.path}),(0,J.jsx)(`span`,{className:`tabular text-caption text-muted-foreground`,children:lL(e.bytes)})]},e.ref))]})]})},zH=({calls:e,option:t,guidance:n=null,leftOut:r=0})=>{let[i,a]=(0,q.useState)(!1),o=LH(e),s=o[0];if(s===void 0)return null;let c=Date.parse(s.startedAt),l=Math.max(...o.map(e=>Date.parse(e.startedAt)+e.durationMs));return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>a(!0),children:`Run details…`}),i&&(0,J.jsxs)(EB,{title:`${Rl(t)}'s calls`,onClose:()=>a(!1),className:`sm:max-w-3xl`,children:[(0,J.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[EH(t)===null?``:`On ${EH(t)}. `,TH(l-c),` from the first call to the end of the last. A call whose answer has problems runs once more, told what they are.`]}),(0,J.jsxs)(`table`,{className:`tabular w-full text-ui [&_td]:px-2 [&_td]:py-1 [&_td]:align-top [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:align-top [&_th]:font-normal [&_thead_th]:font-medium [&_thead_th]:text-muted-foreground`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,J.jsx)(`th`,{scope:`col`,children:`Started`}),(0,J.jsx)(`th`,{scope:`col`,children:`Time`}),(0,J.jsx)(`th`,{scope:`col`,children:`Outcome`})]})}),(0,J.jsx)(`tbody`,{children:o.map(e=>{let t=e.error===null?e.problems:[e.error.message];return(0,J.jsxs)(`tr`,{children:[(0,J.jsxs)(`th`,{scope:`row`,children:[PH[e.pass],e.attempt>1&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` · again`})]}),(0,J.jsx)(`td`,{children:FH(Date.parse(e.startedAt)-c)}),(0,J.jsx)(`td`,{children:TH(e.durationMs)}),(0,J.jsxs)(`td`,{children:[(0,J.jsx)(`span`,{className:e.outcome===`failed`?`text-destructive`:void 0,children:IH(e)}),t.length>0&&(0,J.jsx)(`ul`,{className:`mt-1 list-disc pl-4 text-muted-foreground`,children:t.map(e=>(0,J.jsx)(`li`,{children:e},e))})]})]},`${e.pass}/${e.attempt}/${e.startedAt}`)})})]}),n!==null&&(0,J.jsx)(RH,{guidance:n,leftOut:r})]})]})},BH={logic:`border-risk-logic-solid bg-risk-logic-bg text-risk-logic`,mechanical:`border-risk-mechanical-solid bg-risk-mechanical-bg text-risk-mechanical`},VH=`border-dashed border-input bg-surface-subtle text-muted-foreground`,HH={call:``,import:`[stroke-dasharray:6_4]`,request:`stroke-muted-foreground [stroke-dasharray:12_4_3_4] [stroke-width:2.5]`,type:`[stroke-dasharray:1.5_3] [stroke-linecap:round]`,outside:`[stroke-dasharray:4_4] opacity-60`},UH=56,WH=24,GH=16,KH=120,qH=300,JH=8.6,YH=6.6,XH=6.7,ZH=32,QH=24,$H=20,eU=380,tU=e=>e.slice(e.lastIndexOf(`/`)+1),nU=e=>e===1?`1 use`:`${e} uses`,rU=e=>e===1?`1 file`:`${e} files`,iU=e=>e.kind===`outside`?`${e.paths.length>1?`${rU(e.paths.length)} · `:``}outside the PR · ${nU(e.uses)}`:[e.kind===`group`?rU(e.paths.length):`+${e.added} −${e.deleted}`,...e.entries].join(` · `),aU=e=>{let t=e.badges.reduce((e,t)=>e+tU(t).length*XH+14,0),n=Math.min(Math.max(e.label.length*JH+ZH+(e.kind===`group`&&e.paths.length>1?QH:0),iU(e).length*YH+$H,t+$H),eU),r=KH+Math.sqrt(e.added+e.deleted)*9;return Math.round(Math.max(n,Math.min(r,qH)))},oU=72,sU=(e,t)=>{let n=e.map(e=>e.reduce((e,t,n)=>e+aU(t)+(n>0?WH:0),0)),r=Math.max(0,...n)+32,i=r+(t?oU:0),a=new Map;return e.forEach((e,t)=>{let i=(r-(n[t]??0))/2;for(let n of e){let e=aU(n);a.set(n.key,{x:i,y:GH+t*120,width:e}),i+=e+WH}}),{boxes:a,width:i,height:e.length===0?0:32+e.length*64+(e.length-1)*UH}},cU=e=>e.outside?`outside`:e.uses.includes(`request`)?`request`:e.uses.includes(`call`)?`call`:e.uses.every(e=>e===`import`)?`import`:`type`,lU=(e,t)=>{let n=e=>{let n=t.get(e);return n===void 0?0:n.x+n.width/2},r=(e,r,i)=>{let a=t.get(r),o=[...e].sort((e,t)=>n(i(e))-n(i(t)));return new Map(o.map((e,t)=>[e,a===void 0?0:a.x+a.width*(.5+(o.length===1?0:(t/(o.length-1)-.5)*.5))]))},i=e.filter(e=>!e.back&&!e.outside),a=new Map,o=new Map;for(let e of t.keys()){for(let[t,n]of r(i.filter(t=>t.from===e),e,e=>e.to))a.set(t,n);for(let[t,n]of r(i.filter(t=>t.to===e),e,e=>e.from))o.set(t,n)}return{out:a,into:o}},uU=(e,t,n,r,i=e.x+e.width/2,a=t.x+t.width/2)=>{if(n){let n=e.x+e.width,i=t.x+t.width,a=e.y+32,o=t.y+32,s=r-oU/2;return`M ${n} ${a} C ${s} ${a} ${s} ${o} ${i} ${o}`}if(e.y>t.y){let n=e.y,r=t.y+64,o=Math.max(UH/2,(n-r)/2);return`M ${i} ${n} C ${i} ${n-o} ${a} ${r+o} ${a} ${r}`}let o=e.y+64,s=t.y,c=Math.max(UH/2,(s-o)/2);return`M ${i} ${o} C ${i} ${o+c} ${a} ${s-c} ${a} ${s}`},dU={import:`imports`,call:`calls`,type:`uses types from`,request:`sends requests to`},fU=(e,t)=>{let n=e.uses.map(e=>dU[e]).join(`, `),r=e.symbols.length>0?`: ${e.symbols.join(`, `)}`:``;return`${t(e.from)} ${n} ${t(e.to)}${r}`},pU=({node:e,box:t,active:n,current:r,onOpen:i,onExpand:a,onFocus:o})=>{let s=e.kind===`group`,c=e.kind===`outside`,l=(c?[e.label,iU(e)]:[e.label,s?rU(e.paths.length):null,...e.entries,e.risk,e.generated?`generated`:null,r?`in view in the code`:null]).filter(e=>e!==null).join(`, `);return(0,J.jsxs)(`div`,{"data-slot":`overview-node-box`,className:X(`grid`,t===void 0?`relative`:`absolute`),style:t===void 0?{width:aU(e)}:{left:t.x,top:t.y,width:t.width,height:64},children:[(0,J.jsxs)(`button`,{type:`button`,"data-slot":`overview-node`,"data-risk":c?`outside`:e.risk,"data-generated":e.generated||void 0,"data-active":n||void 0,"data-current":r||void 0,className:X(`grid h-full w-full content-start gap-0.5 overflow-hidden rounded-md border px-2 py-1 text-left text-caption`,c?VH:BH[e.risk],e.generated&&`border-dashed`,n&&`border-primary`,r&&`shadow-[0_0_0_2px_var(--background),0_0_0_4px_var(--primary)]`),"data-key":e.key,"aria-label":l,"aria-current":r?`location`:void 0,title:s?e.label:e.paths.length===1?e.paths[0]:void 0,onClick:()=>i(e),onFocus:()=>o(e),onMouseEnter:()=>o(e),onMouseLeave:()=>o(null),children:[(0,J.jsx)(`span`,{className:X(`flex min-w-0 items-baseline gap-2`,s&&`pr-6`),children:(0,J.jsx)(`span`,{"data-slot":`overview-label`,className:`min-w-0 truncate font-mono text-code-compact font-semibold`,children:e.label})}),(0,J.jsx)(`span`,{className:`truncate`,children:iU(e)}),e.badges.length>0&&(0,J.jsx)(`span`,{className:`flex gap-1 overflow-hidden`,children:e.badges.map(e=>(0,J.jsx)(`span`,{className:`shrink-0 rounded-sm border border-current px-1 font-mono text-kbd`,children:tU(e)},e))})]}),s&&e.paths.length>1&&(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,className:`absolute top-1 right-1 text-current`,"aria-label":`Show the files of ${e.label}`,title:`Show its files`,onClick:()=>a(e),children:(0,J.jsx)(Rg,{"aria-hidden":`true`})})]})},mU=({overview:e,focusKey:t,currentPath:n,onOpen:r,onExpand:i,onCollapse:a,expandedGroups:o,onFocusNode:s})=>{let c=(0,q.useId)(),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(null),{boxes:f,width:p,height:m}=(0,q.useMemo)(()=>sU(e.rows,e.edges.some(e=>e.back)),[e]),h=(0,q.useMemo)(()=>lU(e.edges,f),[e.edges,f]),g=(0,q.useMemo)(()=>new Map([...e.rows.flat(),...e.strip].map(e=>[e.key,e.label])),[e]),_=e=>g.get(e)??e,v=(0,q.useMemo)(()=>[...e.rows,e.strip].filter(e=>e.length>0),[e]);(0,q.useEffect)(()=>d(null),[e]);let y=(0,q.useRef)(-1);(0,q.useEffect)(()=>{if(t===null||y.current===t.n)return;let n=e.placeOf.get(t.key)??t.key,r=l.current?.querySelector(`[data-key="${CSS.escape(n)}"]`);r!=null&&(y.current=t.n,r.focus(),r.scrollIntoView?.({block:`nearest`,inline:`nearest`}))},[t,e]);let b=e=>l.current?.querySelector(`[data-key="${CSS.escape(e)}"]`)?.focus(),x=e=>{let t=e.target.dataset.key;if(t===void 0)return;let n=v.findIndex(e=>e.some(e=>e.key===t)),r=v[n]?.findIndex(e=>e.key===t)??-1,i=e=>{let t=l.current?.querySelector(`[data-key="${CSS.escape(e.key)}"]`)?.getBoundingClientRect();return t===void 0?0:t.left+t.width/2},a;if(e.key===`ArrowRight`)a=v[n]?.[r+1];else if(e.key===`ArrowLeft`)a=v[n]?.[r-1];else if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=v[n+(e.key===`ArrowDown`?1:-1)]??[],o=v[n]?.[r],s=o===void 0?0:i(o);a=[...t].sort((e,t)=>Math.abs(i(e)-s)-Math.abs(i(t)-s))[0]}else return;e.preventDefault(),a!==void 0&&b(a.key)},S=u?.kind===`node`?u.node.key:null,C=e=>e.from===S||e.to===S,w=e=>{e!==null&&s(e.key),d(e===null?null:{kind:`node`,node:e})},T=n===null?null:e.placeOf.get(n)??null,E=e=>({node:e,active:S===e.key,current:T===e.key,onOpen:r,onExpand:e=>i(e.key),onFocus:w});return(0,J.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Overview of the changed files`,ref:l,onKeyDown:x,children:[(0,J.jsxs)(`p`,{"data-slot":`overview-legend`,className:`text-muted-foreground`,children:[`Each box is a directory. Directories that nothing in the pull request calls are on top; each sits below its callers. Solid lines are calls, dash-dot ones HTTP requests to a route, dashed ones imports, dotted ones types. Tests show on the directories they call. The outlined box holds the file last in view in the code.`,e.edges.some(e=>e.outside)&&` Faded files are outside the pull request, under the code whose changes they use.`]}),o.length>0&&(0,J.jsx)(`p`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,J.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>a(e),children:[`Collapse `,e.slice(6),`/`]},e))}),e.rows.length>0?(0,J.jsx)(`div`,{"data-slot":`overview-scroll`,className:`overflow-x-auto rounded-lg border bg-surface-subtle`,children:(0,J.jsxs)(`div`,{"data-slot":`overview-diagram`,className:`relative mx-auto`,style:{width:p,height:m},children:[(0,J.jsxs)(`svg`,{className:`absolute inset-0 overflow-visible`,width:p,height:m,"aria-hidden":`true`,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:`${c}-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,J.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,className:`fill-input`})})}),e.edges.map(e=>{let t=f.get(e.from),n=f.get(e.to);if(t===void 0||n===void 0)return null;let r=uU(t,n,e.back,p,h.out.get(e),h.into.get(e)),i=C(e)||u?.kind===`edge`&&u.edge===e,a=u!==null&&!i;return(0,J.jsxs)(`g`,{"data-slot":`overview-edge`,"data-style":cU(e),"data-lit":i||void 0,"data-dim":a||void 0,className:X(a&&`opacity-30`),onMouseEnter:()=>d({kind:`edge`,edge:e}),onMouseLeave:()=>d(null),children:[(0,J.jsx)(`path`,{d:r,className:`fill-none stroke-transparent [stroke-width:10]`}),(0,J.jsx)(`path`,{d:r,className:X(`fill-none stroke-input [stroke-width:1.5]`,HH[cU(e)],i&&`stroke-primary [stroke-width:2]`),markerEnd:`url(#${c}-arrow)`}),(0,J.jsx)(`title`,{children:fU(e,_)})]},`${e.from}>${e.to}`)})]}),e.rows.flat().map(e=>(0,J.jsx)(pU,{box:f.get(e.key),...E(e)},e.key))]})}):(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`No changed file calls or imports another.`}),e.strip.length>0&&(0,J.jsxs)(`section`,{"aria-label":`Not linked`,className:`flex flex-col gap-2`,children:[(0,J.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Not linked`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.strip.map(e=>(0,J.jsx)(pU,{...E(e)},e.key))})]}),(0,J.jsx)(`p`,{"data-slot":`overview-detail`,className:`min-h-5 text-muted-foreground`,"aria-live":`polite`,children:u===null?`Hover or focus a directory to see its files, flows and tests.`:u.kind===`edge`?fU(u.edge,_):hU(u.node,e.edges,_)})]})},hU=(e,t,n)=>{let r=t.filter(t=>t.from===e.key).map(e=>{let t=e.symbols.length>0?` (${e.symbols.join(`, `)})`:``;return`${n(e.to)}${t}`});return e.kind===`outside`?`${e.paths.length>1?`${e.label}: ${e.paths.length} files`:e.paths[0]} · outside the pull request · uses ${r.join(`, `)}.`:`${[e.kind===`group`?`${e.label}: ${e.paths.map(tU).join(`, `)}`:e.paths[0],e.flows.length>0?`read in ${e.flows.join(`; `)}`:`in no flow`,...r.length>0?[`reaches ${r.join(`, `)}`]:[],...e.badges.length>0?[`tested in ${e.badges.map(tU).join(`, `)}`]:[]].join(` · `)}.`},gU=e=>`point-${e}`,_U={contradicts:`Contradicts what was asked`,missing:`Asked for, not done`,unrequested:`Done, not asked for`},vU={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},yU=({kind:e})=>{let t=sD[e];return(0,J.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 font-medium`,vU[e]),children:[(0,J.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),oD[e].label]})},bU=({point:e,state:t,current:n,note:r,action:i,className:a,leftOut:o=!1})=>{let s=sD[e.kind];return(0,J.jsxs)(`article`,{id:gU(e.id),"data-slot":`point`,"data-kind":e.kind,"data-state":t,"data-left-out":o||void 0,"data-current":n||void 0,"aria-label":e.title,className:X(`flex scroll-mt-24 flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground`,a,n&&MU),children:[(0,J.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[oD[e.kind].label,`: `]}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-40 truncate`,t===`dismissed`&&`line-through`),children:e.title}),(0,J.jsx)(`span`,{className:`max-w-full min-w-0 truncate text-caption`,children:r}),i]})},xU=({effect:e,preferenceId:t})=>{let n=t===null?``:` your preference:`;return e===`raised`?`From${n}`:`Left out by${n}`},SU=({guidance:e,className:t})=>{let n=e.preferenceId===null?cg:u_;return(0,J.jsxs)(`p`,{"data-slot":`point-guidance`,"data-effect":e.effect,className:X(`flex items-start gap-1.5 text-caption text-muted-foreground`,t),children:[(0,J.jsx)(n,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[xU(e),` `,(0,J.jsx)(N_,{to:S_,className:X(`underline`,e.preferenceId===null&&`font-mono text-code-compact`),children:e.label})]})]})},CU=({point:e,guidance:t,state:n,current:r,onShow:i})=>(0,J.jsx)(bU,{point:e,state:n,current:r,leftOut:!0,note:`${xU(t)} ${t.label}`,className:FU,action:(0,J.jsx)($,{variant:`ghost`,size:`xs`,"aria-label":`Show: ${e.title}`,onClick:i,children:`Show`})}),wU=(e,t,n)=>{let r=(0,q.useRef)(null),i=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{!e&&i.current&&(i.current=!1,r.current?.focus())},[e]),{card:r,show:()=>{i.current=!0,t(n)}}},TU=({point:e,size:t,disabled:n,onDismiss:r,onRule:i})=>(0,J.jsxs)(`span`,{className:`flex items-center`,children:[(0,J.jsxs)($,{variant:`ghost`,size:t,disabled:n,"aria-label":`Dismiss: ${e.title}`,className:`rounded-r-none`,onClick:r,children:[t===`sm`&&(0,J.jsx)(b_,{"aria-hidden":`true`}),`Dismiss`]}),(0,J.jsxs)(UR,{children:[(0,J.jsx)(WR,{render:(0,J.jsx)($,{variant:`ghost`,size:t,"data-slot":`dismiss-menu`,disabled:n,"aria-label":`More ways to dismiss: ${e.title}`,className:`w-6 rounded-l-none px-0`}),children:(0,J.jsx)(Bh,{"aria-hidden":`true`})}),(0,J.jsx)(GR,{align:`end`,className:`w-64`,children:(0,J.jsxs)(JR,{onClick:i,children:[(0,J.jsx)(fg,{"aria-hidden":`true`}),`Don't flag things like this…`]})})]})]}),EU=({point:e,scopes:t,onSave:n,onCancel:r})=>{let[i]=t;return i===void 0?null:(0,J.jsxs)(`div`,{"data-slot":`point-rule`,className:`flex flex-col gap-2 rounded-md border bg-card p-3`,children:[(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`Word it as a rule. It's saved to your preferences, and AI reviews leave out what it describes, folded to a line you can open.`}),(0,J.jsx)(TB,{legend:`Don't flag things like: ${e.title}`,initial:{kind:`dont-flag`,text:e.title,scope:i.scope},scopes:t,kindFixed:!0,submit:`Save and dismiss`,submitting:`Saving…`,focus:!0,onCancel:r,onSubmit:n})]})},DU=(e,t)=>{let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1);return{writing:n,setWriting:r,saved:i,save:async n=>{let i=await t(e,n);return i===null&&(a(!0),r(!1)),i}}},OU=e=>e?(0,J.jsxs)(J.Fragment,{children:[`Dismissed, and saved to your`,` `,(0,J.jsx)(N_,{to:S_,className:`underline`,children:`preferences`})]}):`Dismissed`,kU={blocking:{glyph:`■`,className:`text-severity-blocker bg-review-changes-bg border-severity-blocker/25`},major:{glyph:`▲`,className:`text-severity-major bg-severity-major-bg border-severity-major/25`},minor:{glyph:`●`,className:`text-severity-minor bg-review-pending-bg border-severity-minor/25`}},AU=({severity:e})=>(0,J.jsxs)(`span`,{"data-slot":`severity`,className:X(ij,kU[e].className),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:kU[e].glyph}),e]}),jU=`animate-in duration-(--duration-slow) fade-in-0 slide-in-from-top-1`,MU=`shadow-[inset_0_0_0_2px_var(--ring)]`,NU=`relative max-w-3xl rounded-lg border bg-thread-bg`,PU=`scroll-mt-[calc(6rem+var(--lines-above)*var(--text-code--line-height))] -outline-offset-2`,FU=X(NU,`px-3 py-1.5`),IU={finding:`bg-review-changes`,risk:`bg-risk-contract-solid`},LU=({kind:e})=>(0,J.jsx)(`span`,{"aria-hidden":`true`,className:X(`absolute top-2 bottom-2 left-1.5 w-[3px] rounded-full`,IU[e])}),RU=(0,q.memo)(function({point:e,state:t,saving:n,readOnly:r,current:i,onRaise:a,onState:o,leftOut:s,onShow:c,ruleScopes:l,onRule:u,inReview:d,removed:f,language:p,linesAbove:m=0}){let h=(0,q.useId)(),{card:g,show:_}=wU(s,c,e.id),v=DU(e,u);if(t===`dismissed`)return(0,J.jsx)(bU,{point:e,state:t,current:i,note:OU(v.saved),className:FU,action:(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(t===`raised`&&d)return(0,J.jsx)(bU,{point:e,state:t,current:i,note:`In your review, below`,className:`max-w-3xl px-1`,action:(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓`})});if(s&&e.guidance!==void 0)return(0,J.jsx)(CU,{point:e,guidance:e.guidance,state:t,current:i,onShow:_});let y=r||n;return(0,J.jsxs)(`article`,{ref:g,id:gU(e.id),"data-slot":`point`,"data-kind":`finding`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${h}-title`,tabIndex:-1,style:vh({"--lines-above":m}),className:X(NU,PU,`flex flex-col gap-2 py-2.5 pr-4 pl-5`,i&&MU),children:[(0,J.jsx)(LU,{kind:`finding`}),(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(yU,{kind:`finding`}),e.severity!==null&&(0,J.jsx)(AU,{severity:e.severity}),(0,J.jsx)(`span`,{className:X(ij,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:`Draft`}),e.lines!==null&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[`on`,` `,(0,J.jsx)(jk,{children:Ak(e.lines.side,e.lines.startLine,e.lines.line)})]}),(0,J.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(eg,{"aria-hidden":`true`,className:`size-3.5`}),`Only you see this`]})]}),(0,J.jsx)(`h3`,{id:`${h}-title`,className:`font-semibold`,children:e.title}),e.explanation!==``&&(0,J.jsx)(rj,{blocks:Vd(e.explanation).blocks,suggestion:()=>null}),e.mismatch!==null&&(0,J.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`font-medium text-foreground`,children:[_U[e.mismatch.kind],`:`]}),` `,e.mismatch.description]}),e.guidance!==void 0&&(0,J.jsx)(SU,{guidance:e.guidance}),e.suggestion!==null&&(0,J.jsx)(rA,{title:`Suggested change`,removed:f,added:e.suggestion,language:p}),v.writing?(0,J.jsx)(EU,{point:e,scopes:l,onSave:v.save,onCancel:()=>{v.setWriting(!1),g.current?.focus()}}):(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,J.jsx)(TU,{point:e,size:`sm`,disabled:y,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>v.setWriting(!0)}),e.lines!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)($,{variant:`outline`,size:`sm`,disabled:y,"aria-label":`Edit: ${e.title}`,onClick:()=>a(e,!1),children:[(0,J.jsx)(Qg,{"aria-hidden":`true`}),`Edit`]}),(0,J.jsx)($,{size:`sm`,disabled:y,"aria-label":`Add to review: ${e.title}`,onClick:()=>a(e,!0),children:`Add to review`})]})]})]})}),zU=e=>e.slice(e.lastIndexOf(`/`)+1),BU=({checkedBy:e,peek:t,id:n})=>{let r=(0,J.jsx)(`span`,{className:`font-mono text-code-compact`,children:e.test});return(0,J.jsxs)(`p`,{"data-slot":`checked-by`,className:`flex items-start gap-1.5 pb-0.5 text-muted-foreground`,children:[(0,J.jsx)(mg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:`Checked by`}),` `,t===null?r:(0,J.jsx)(Oj,{handle:t.handle,payload:t.payload,id:n,render:(0,J.jsx)(`button`,{type:`button`,className:`text-left text-foreground`}),children:r}),` `,`in `,zU(e.path),`, which asserts: `,e.checks]})]})},VU=(0,q.memo)(function({point:e,state:t,saving:n,readOnly:r,current:i,onRaise:a,onState:o,leftOut:s,onShow:c,ruleScopes:l,onRule:u,linesAbove:d=0,test:f=null}){let p=(0,q.useId)(),{card:m,show:h}=wU(s,c,e.id),g=DU(e,u);if(t===`dismissed`)return(0,J.jsx)(bU,{point:e,state:t,current:i,note:OU(g.saved),className:FU,action:(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(s&&e.guidance!==void 0)return(0,J.jsx)(CU,{point:e,guidance:e.guidance,state:t,current:i,onShow:h});let _=r||n;return(0,J.jsxs)(`article`,{ref:m,id:gU(e.id),"data-slot":`point`,"data-kind":`risk`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${p}-title`,tabIndex:-1,style:vh({"--lines-above":d}),className:X(NU,PU,`flex flex-col gap-0.5 py-1.5 pr-2 pl-5`,i&&MU),children:[(0,J.jsx)(LU,{kind:`risk`}),(0,J.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(yU,{kind:`risk`}),e.lines!==null&&(0,J.jsx)(jk,{children:Ak(e.lines.side,e.lines.startLine,e.lines.line)}),t===`raised`&&(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,J.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:_||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>a(e,!1),children:`Comment`}),(0,J.jsx)(TU,{point:e,size:`xs`,disabled:_,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>g.setWriting(!0)})]})]}),(0,J.jsx)(`h3`,{id:`${p}-title`,className:`pb-0.5 font-normal`,children:e.title}),e.checkedBy!==void 0&&(0,J.jsx)(BU,{checkedBy:e.checkedBy,peek:f,id:`${gU(e.id)}-test`}),e.guidance!==void 0&&(0,J.jsx)(SU,{guidance:e.guidance,className:`pb-0.5`}),g.writing&&(0,J.jsx)(`div`,{className:`py-1.5 pr-2`,children:(0,J.jsx)(EU,{point:e,scopes:l,onSave:g.save,onCancel:()=>{g.setWriting(!1),m.current?.focus()}})})]})}),HU=({point:e,state:t,open:n,current:r,onToggle:i})=>{let a=sD.decision;return(0,J.jsxs)(`button`,{type:`button`,id:gU(e.id),"data-slot":`decision-chip`,"data-inline-target":!0,"data-state":t,"data-current":r||void 0,"aria-expanded":n,"aria-label":`Decision: ${e.title}`,className:X(`ml-3 inline-flex min-h-5 scroll-mt-24 items-center gap-1 rounded-full border bg-background px-2 align-middle font-sans text-caption text-muted-foreground hover:text-foreground`,t===`dismissed`&&`line-through`,r&&MU),onClick:t=>{t.stopPropagation(),i(e.id)},children:[(0,J.jsx)(a,{"aria-hidden":`true`,className:`size-3`}),e.title]})},UU=({point:e,state:t,saving:n,readOnly:r,onRaise:i,onState:a})=>{let o=r||n;return(0,J.jsxs)(`article`,{"data-slot":`decision-note`,"data-state":t,"aria-label":e.title,className:X(`flex max-w-3xl flex-wrap items-baseline gap-x-2 border-l pl-3 text-caption`,jU),children:[(0,J.jsxs)(`p`,{className:`min-w-0 flex-1 basis-80 text-muted-foreground`,children:[(0,J.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.title,`.`]}),` `,e.explanation]}),(0,J.jsx)(`span`,{className:`flex items-center gap-1`,children:t===`dismissed`?(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>a(e.id,`open`),children:`Show again`}):(0,J.jsxs)(J.Fragment,{children:[t===`raised`&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:o||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>i(e,!1),children:`Comment`}),(0,J.jsx)($,{variant:`ghost`,size:`xs`,disabled:o,"aria-label":`Hide: ${e.title}`,onClick:()=>a(e.id,`dismissed`),children:`Hide`})]})})]})},WU=({point:e,onGo:t})=>{let n=sD[e.kind];return(0,J.jsxs)(`p`,{"data-slot":`point-mention`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,J.jsx)(n,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),oD[e.kind].label,`:`,` `,(0,J.jsx)(`button`,{type:`button`,className:`min-h-6 rounded-sm text-left whitespace-pre-line text-primary underline-offset-2 hover:underline`,onClick:()=>t(e.id),children:e.title})]})},GU=({pointId:e,fresh:t,at:n,row:r=!1,className:i,bodyClassName:a,children:o})=>(0,J.jsx)(`div`,{role:r?`row`:void 0,"data-slot":`point-fold`,"data-point-id":e,"data-fresh":t||void 0,"data-unfold":n!==void 0||void 0,style:n===void 0?void 0:vh({"--landing-i":n}),className:i,children:(0,J.jsx)(`div`,{role:r?`cell`:void 0,children:(0,J.jsx)(`div`,{className:a,children:o})})}),KU={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},qU=({points:e,kind:t,stateOf:n,onGo:r,onClose:i,family:a=`Claude`})=>{let o=t===null?e:e.filter(e=>e.kind===t),s=(0,q.useRef)(!1),[c,l]=t===null?[`point`,`points`]:KU[t];return(0,J.jsx)(EB,{title:`${o.length} ${o.length===1?c:l} from ${a}`,onClose:i,returnFocus:()=>!s.current,className:`sm:max-w-2xl`,children:(0,J.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-1`,"aria-label":`Points`,children:o.map(e=>{let{label:t}=oD[e.kind],i=sD[e.kind],a=n(e.id);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`point-row`,"data-kind":e.kind,className:`flex min-h-7 w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-accent`,onClick:()=>{s.current=!0,r(e.id)},children:[(0,J.jsx)(i,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[t,`: `]}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,a===`dismissed`&&`line-through`),children:e.title}),a!==`open`&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:a===`raised`?`Raised`:`Dismissed`}),e.path!==null&&(0,J.jsx)(`span`,{className:`truncate font-mono text-code-compact text-muted-foreground`,children:e.path})]})},e.id)})})})},JU=(e,t,n)=>{let r=t===null?e:e.filter(e=>e.kind===t),i=r.findIndex(e=>e.id===n);return{steps:r,at:i===-1?null:i}},YU=(e,t)=>{let{steps:n,at:r}=e;return n.length===0?null:n[r===null?t===1?0:n.length-1:(r+t+n.length)%n.length]?.id??null},XU=(e,t,n)=>{if(t===null)return null;let r=JU(e,t,n);return r.at===null?r.steps[0]?.id??null:null},ZU={finding:`findings`,risk:`risks`,decision:`decisions`},QU={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},$U=({kind:e})=>{let t=sD[e];return(0,J.jsx)(t,{"aria-hidden":`true`,className:X(`size-3.5 shrink-0`,QU[e])})},eW=({slot:e,noun:t,total:n,at:r,count:i,title:a,status:o,onStep:s,onOpenList:c})=>{let l=r===null?i:`${r+1} of ${n}`,u=`${t.charAt(0).toUpperCase()}${t.slice(1)}`;return(0,J.jsxs)(`span`,{"data-slot":e,className:`flex min-w-0 items-center gap-0.5`,children:[(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Previous ${t}`,disabled:n===0,onClick:()=>s(-1),children:(0,J.jsx)(Hh,{"aria-hidden":`true`})}),(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:`tabular`,"aria-label":r===null?`${i}, show all`:`${u} ${l}, show all`,onClick:c,children:l}),(0,J.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Next ${t}`,disabled:n===0,onClick:()=>s(1),children:(0,J.jsx)(Wh,{"aria-hidden":`true`})}),a,(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:o})]})},tW=({points:e,current:t,stateOf:n,kind:r,onGo:i,onOpenList:a})=>{let o=JU(e,r,t),{steps:s,at:c}=o,l=c===null?void 0:s[c],u=r===null||s.length===1?`${s.length} ${s.length===1?`point`:`points`}`:`${s.length} ${ZU[r]}`,d=l!==void 0&&n(l.id)===`dismissed`;return(0,J.jsx)(eW,{slot:`point-stepper`,noun:`point`,total:s.length,at:c,count:u,onStep:e=>{let t=YU(o,e);t!==null&&i(t)},onOpenList:a,title:l!==void 0&&(0,J.jsxs)(`button`,{type:`button`,"data-slot":`stepper-title`,"data-kind":l.kind,className:`ml-1 flex h-6 min-w-0 items-center gap-1.5 rounded-md px-1 text-left max-sm:hidden hover:bg-muted`,"aria-label":`Go to ${oD[l.kind].label.toLowerCase()}: ${l.title}`,onClick:()=>i(l.id),children:[(0,J.jsx)($U,{kind:l.kind}),(0,J.jsx)(`span`,{className:X(`min-w-0 truncate`,d&&`text-muted-foreground line-through`),children:l.title})]}),status:l===void 0||c===null?``:`${oD[l.kind].label} ${c+1} of ${s.length}: ${l.title}${d?` (dismissed)`:``}`})},nW={collect:`Collect`,prep:`Prepare`,intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`},rW={pending:`waiting`,running:`running`,done:`done`,failed:`failed`,skipped:`skipped`},iW={pending:`text-muted-foreground`,running:`text-primary font-medium`,done:`text-review-approved`,failed:`text-destructive font-medium`,skipped:`text-muted-foreground`},aW={pending:`○`,running:`◐`,done:`●`,failed:`✗`,skipped:`–`},oW=({stages:e,shown:t,filesFetched:n})=>(0,J.jsx)(`ol`,{className:`flex flex-wrap gap-x-4 gap-y-1 rounded-lg border bg-surface-subtle px-3 py-2`,"aria-label":`Analysis progress`,children:t.map(t=>{let r=e[t];return(0,J.jsxs)(`li`,{"data-status":r,className:iW[r],children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:aW[r]}),` `,nW[t],(0,J.jsxs)(`span`,{className:`sr-only`,children:[`: `,rW[r]]}),t===`collect`&&r===`running`&&n!==null&&(0,J.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[` `,`· `,n.done,` of `,n.total,` files`]})]},t)})}),sW=e=>nW[e],cW=xu.options.filter(e=>!zu.includes(e)),lW=({legend:e,options:t,value:n,onChange:r})=>(0,J.jsxs)(`fieldset`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`legend`,{className:`sr-only`,children:e}),t.map(e=>(0,J.jsx)(Bj,{variant:`outline`,size:`sm`,pressed:n===e.value,disabled:e.disabled===!0,onPressedChange:t=>{t&&r(e.value)},children:e.label},e.value))]}),uW=[{value:`comment`,label:`Comment`},{value:`approve`,label:`Approve`},{value:`request_changes`,label:`Request changes`}],dW=`whitespace-pre-wrap wrap-anywhere`,fW=(e,t)=>{let n=t===0?``:` ${t} ${t===1?`comment`:`comments`}`;return e===`comment`?n===``?`Publish the summary`:`Publish${n}`:`Publish${n} and ${e===`approve`?`approve`:`request changes`}`},pW=({analysisId:e,hunkComments:t,isAuthor:n,published:r,onClose:i,onPublished:a})=>{let{client:o}=yp(),s=(0,q.useId)(),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(`comment`),[f,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(!1),[b]=(0,q.useState)(()=>qd.parse(crypto.randomUUID())),x=Dp(o.publish);(0,q.useEffect)(()=>{let n=!0;return o.previewPublication(e,{summary:``,hunkComments:t}).then(e=>{n&&(p(e.ok?e.value:null),h(e.ok?null:e.error))}),()=>{n=!1}},[e,o,t]);let S=n?`comment`:u,C=fW(S,f?.comments.length??t.length),w=f!==null&&Jd({...f,verdict:S,summary:c}),T=async n=>{y(n),_(!1);let r=await x.run(e,{publicationId:b,summary:c,allowStale:n,hunkComments:t,verdict:S});r.ok?a(r.value):r.error.code===`stale-analysis`&&(x.reset(),_(!0))};return(0,J.jsxs)(EB,{title:`Publish review`,onClose:i,className:`flex flex-col sm:max-w-2xl`,children:[r&&(0,J.jsx)(`p`,{className:`shrink-0 text-muted-foreground`,children:`Your earlier review is on the pull request. This one posts as another, with its own verdict.`}),m===null?f===null?(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Reading the comments…`}):f.comments.length>0&&(0,J.jsx)(`section`,{"data-slot":`publish-comments`,"aria-label":`Comments to post`,tabIndex:0,className:`-mx-4 min-h-12 overflow-y-auto overscroll-contain border-y px-4 py-3 -outline-offset-2`,children:(0,J.jsx)(`ul`,{"aria-label":`Comments`,className:`flex flex-col gap-1.5`,children:f.comments.map(e=>(0,J.jsxs)(`li`,{className:`min-w-0 border-l-2 border-l-review-pending py-0.5 pl-2.5`,children:[(0,J.jsxs)(`code`,{className:`font-mono text-code-compact text-muted-foreground`,children:[e.path,`:`,e.startLine===void 0?e.line:`${e.startLine}–${e.line}`,e.side===`old`?` (old side)`:``]}),(0,J.jsx)(`p`,{className:dW,children:e.body})]},e.key))})}):(0,J.jsxs)(`p`,{className:LN,role:`alert`,children:[`Couldn't read what will be posted. `,Ap(m)]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`Verdict`}),(0,J.jsx)(lW,{legend:`Verdict`,options:uW.map(e=>({...e,disabled:n&&e.value!==`comment`})),value:S,onChange:d})]}),n&&(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`You opened this pull request, and its author can't approve it or request changes, so your review comments.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`${s}-summary`,className:`sr-only`,children:`Summary`}),(0,J.jsx)($O,{id:`${s}-summary`,rows:2,"data-autofocus":!0,placeholder:`Summary (optional)`,value:c,onChange:e=>l(e.target.value)})]}),g?(0,J.jsxs)(`div`,{className:X(RN,`flex flex-col gap-2`),role:`alert`,children:[(0,J.jsx)(`p`,{children:`This PR changed since the analysis. Publish anyway?`}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)($,{variant:`outline`,onClick:()=>_(!1),children:`Cancel`}),(0,J.jsx)($,{onClick:()=>void T(!0),children:`Publish anyway`})]})]}):(0,J.jsxs)(J.Fragment,{children:[x.error!==null&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`Couldn't publish. `,Ap(x.error)]}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Retrying is safe: comments that were already posted aren't posted again.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[w&&(0,J.jsx)(`p`,{id:`${s}-nothing`,className:`mr-auto text-caption text-muted-foreground`,children:`Nothing to post yet: write a summary, or approve or request changes.`}),(0,J.jsx)($,{variant:`outline`,onClick:i,children:`Cancel`}),(0,J.jsx)($,{disabled:x.pending||f===null||w,"aria-describedby":w?`${s}-nothing`:void 0,onClick:()=>void T(v),children:x.pending?`Publishing…`:x.error===null?C:`Retry`})]})]})]})]})},mW=({children:e})=>(0,J.jsx)(`aside`,{id:`review-tree-rail`,"aria-label":`Files`,className:`sticky top-[var(--review-bar-h,0px)] -ml-1 flex h-[calc(100vh-var(--review-bar-h,0px))] min-h-0 flex-col gap-2 self-start overflow-hidden p-1`,children:e}),hW=({analysisId:e,family:t,onRemoved:n})=>{let{client:r}=yp(),i=Dp(r.removeModelRun),[a,o]=(0,q.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>o(!0),children:`Remove AI review…`}),a&&(0,J.jsxs)(EB,{title:`Remove AI review`,onClose:()=>{o(!1),i.reset()},children:[(0,J.jsxs)(`p`,{className:`text-ui`,children:[t,`'s intent, findings, risks and decisions go, with what you did with them, and the code's analysis is back as it was. Your comments stay. Request AI review runs a model again, the same or another.`]}),i.error!==null&&(0,J.jsxs)(`p`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[`Couldn't remove it. `,Ap(i.error)]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:()=>o(!1),children:`Cancel`}),(0,J.jsx)($,{variant:`destructive`,disabled:i.pending,onClick:async()=>{let t=await i.run(e);t.ok&&(o(!1),n(t.value))},children:i.pending?`Removing…`:`Remove`})]})]})]})},gW=()=>{let e=(0,q.useRef)(null),[t,n]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{let t=e.current;if(t===null||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>{e!==void 0&&n(e.intersectionRatio<1&&e.boundingClientRect.top<=0)},{rootMargin:`-1px 0px 0px 0px`,threshold:1});return r.observe(t),()=>r.disconnect()},[]),{bar:e,stuck:t}},_W=({title:e,claude:t,tools:n,publish:r,publication:i,hairline:a,stuck:o})=>{let s=gW(),c=o??s.stuck;return(0,J.jsxs)(`div`,{ref:s.bar,"data-slot":`review-bar`,"data-stuck":c||void 0,className:`sticky top-0 z-20 flex h-(--review-bar-h) min-w-0 items-center gap-3 border-b bg-background`,children:[a!==null&&(0,J.jsx)(`span`,{"data-slot":`model-hairline`,"data-state":a,"aria-hidden":`true`,children:(0,J.jsx)(`span`,{})}),c&&e!==null&&(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`max-w-72 shrink truncate font-semibold max-xl:hidden`,title:e,children:e}),(0,J.jsx)(`div`,{"data-slot":`claude-slot`,className:`flex min-w-0 flex-1 items-center`,children:t}),(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n}),i!==null&&(0,J.jsxs)(`p`,{role:`status`,className:`flex shrink-0 items-center gap-1 font-medium text-review-approved`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),` `,i.url===null?`Published`:(0,J.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,className:`text-review-approved`,children:`Published`})]}),r]})},vW=2,yW=(e,t,n)=>`${e} ${e===1?t:n}`,bW=()=>(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-border`}),xW=({error:e,onRetry:t})=>(0,J.jsxs)(SM,{children:[(0,J.jsx)(CM,{render:(0,J.jsx)($,{variant:`ghost`,size:`xs`,className:`h-6 px-1.5 font-normal text-muted-foreground`,"data-slot":`status-unavailable`,children:`Status unavailable`})}),(0,J.jsxs)(wM,{align:`end`,children:[(0,J.jsx)(TM,{children:`The PR's status couldn't be read`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Ap(e)}),(0,J.jsx)($,{variant:`outline`,size:`sm`,className:`self-start`,onClick:t,children:`Try again`})]})]}),SW=({name:e})=>(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact text-foreground`,children:e}),CW=({view:e,intent:t,totals:n,threads:r,status:i,statusError:a,onRetryStatus:o,now:s,reanalyzing:c,reanalyzeError:l,onReanalyze:u})=>{let{analysis:d,stale:f}=e,{pullRequest:p,warnings:m}=d,{ref:h}=d.key;return(0,J.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[(0,J.jsxs)(`a`,{className:`font-mono text-code-compact`,href:p?.url??hf(h),target:`_blank`,rel:`noreferrer`,children:[h.repo.repo,` #`,h.number]}),(0,J.jsx)(`div`,{"data-slot":`pr-standing`,className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[r!==null&&r.threads>0&&(0,J.jsxs)(`span`,{"data-slot":`thread-totals`,className:`tabular text-caption text-muted-foreground`,children:[yW(r.threads,`thread`,`threads`),r.unresolved>0&&` · ${r.unresolved} unresolved`]},`threads`),i===null&&a!==null&&(0,J.jsx)(xW,{error:a,onRetry:o},`unavailable`),i!==null&&(i.checks===null||i.checks.length>0)&&(0,J.jsx)(NM,{checks:i.checks,unreadable:i.checksUnreadable,head:d.key.headSha},`ci`),i!==null&&i.reviewers.length>0&&(0,J.jsx)(zM,{reviewers:i.reviewers},`reviewers`)].filter(e=>e!==!1).flatMap((e,t)=>t===0?[e]:[(0,J.jsx)(bW,{},`before-${e.key}`),e])})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(`h1`,{className:`min-w-0 text-title font-semibold tracking-[-0.01em] whitespace-pre-line`,children:p?.title??`Collecting the pull request…`}),i!==null&&(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(DM,{state:i.state}),(0,J.jsx)(OM,{status:i.reviewStatus})]})]}),p!==null&&(0,J.jsxs)(`p`,{"data-slot":`pr-byline`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-muted-foreground`,children:[(0,J.jsxs)(`span`,{children:[p.author.name,` wants to merge `,(0,J.jsx)(SW,{name:p.sourceBranch}),` `,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),` `,(0,J.jsx)(`span`,{className:`sr-only`,children:`into`}),` `,(0,J.jsx)(SW,{name:p.targetBranch})]}),` `,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,J.jsxs)(`span`,{children:[`updated `,Ok(p.updatedAt,s)]}),` `,d.stages.prep===`done`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,J.jsxs)(`span`,{className:`tabular`,children:[yW(n.files,`file`,`files`),` `,(0,J.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[(0,J.jsxs)(`span`,{"aria-hidden":`true`,children:[(0,J.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,n.additions]}),` `,(0,J.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,n.deletions]})]}),(0,J.jsxs)(`span`,{className:`sr-only`,children:[`, `,n.additions,` lines added, `,n.deletions,` removed`]})]})]})]})]}),(0,J.jsx)(`div`,{className:`mt-1.5`,children:t}),f&&(0,J.jsxs)(`div`,{role:`status`,className:X(`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,`flex flex-wrap items-center gap-3`),children:[(0,J.jsx)(`span`,{children:`This PR has new commits since the analysis.`}),(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:c,onClick:u,children:c?`Starting…`:`Re-analyze`}),l!==null&&(0,J.jsx)(`span`,{className:`text-destructive`,role:`alert`,children:Ap(l)})]}),m.length>0&&m.length<=vW&&(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Warnings`,children:m.map(e=>(0,J.jsxs)(`li`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),e]},e))}),m.length>vW&&(0,J.jsxs)(`details`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,J.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),m.length,` warnings`]}),(0,J.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:m.map(e=>(0,J.jsx)(`li`,{children:e},e))})]})]})},wW=e=>`thread-${e}`,TW=e=>`${e.side}:${e.line}`,EW={onLine:new Map,earlier:new Map,elsewhere:[],open:new Map},DW=(e,t,n)=>e.set(t,[...e.get(t)??[],n]),OW=(e,t,n)=>{if(e===null||e.length===0)return EW;let r=new Map(t.map(e=>[e.file.path,e])),i=new Map,a=new Map,o=[],s=new Map;for(let t of e){t.resolved||s.set(t.path,(s.get(t.path)??0)+1);let e=r.get(t.path);if(e===void 0){o.push(t);continue}let{line:c}=t,l=t.outdated||c===null?void 0:e.partIds.find(e=>n.parts.get(e)?.hunk.lines.some(e=>{let n=_j(e);return n!==null&&n.side===t.side&&n.line===c}));if(l===void 0||c===null){DW(a,t.path,t);continue}let u=i.get(l)??new Map;DW(u,TW({side:t.side,line:c}),t),i.set(l,u)}return{onLine:i,earlier:a,elsewhere:o,open:s}},kW=(e,t,n)=>{let r=new Map(e.lines.flatMap(e=>e.kind!==`del`&&e.newLine!==null?[[e.newLine,e.text]]:[])),i=[];for(let e=t;e<=n;e+=1){let t=r.get(e);if(t===void 0)return null;i.push(t)}return i},AW=(e,t,n)=>{let r=[];for(let i of t){for(let t of i.partIds){let i=e.onLine.get(t),a=n.parts.get(t)?.hunk;if(i===void 0||a===void 0)continue;let o=new Set;for(let e of a.lines){let t=_j(e);if(t===null)continue;let n=TW(t);o.has(n)||(o.add(n),r.push(...i.get(n)??[]))}}r.push(...e.earlier.get(i.file.path)??[])}return r.push(...e.elsewhere),r},jW=(e,t,n)=>t===`all`?e:e.filter(e=>!e.resolved||n.has(e.id)),MW=(e,t,n)=>e===null?jW(t,`unresolved`,n).length>0?`unresolved`:`all`:e,NW=(e,t,n,r)=>{if(t.length===0)return null;let i=new Set(t.map(e=>e.id)),a=n===null?-1:e.findIndex(e=>e.id===n);if(a===-1)return(r===1?t[0]:t.at(-1))?.id??null;for(let t=1;t<=e.length;t+=1){let n=e[(a+r*t+e.length*t)%e.length];if(n!==void 0&&i.has(n.id))return n.id}return null},PW=(e,t,n)=>`${e} ${e===1?t:n}`,FW=e=>(e.line??e.originalLine)===null?`the file`:sj(e.outdated?{...e,line:null}:e),IW=e=>{let[t]=e.comments;if(t===void 0)return FW(e);let n=Td(t.body);return`${t.author.name}: ${n===``?`Suggested change`:n}`},LW=(e,t)=>e===`unresolved`?`${t} unresolved`:PW(t,`thread`,`threads`),RW=(e,t,n)=>{if(e.length===0)return null;let r=jW(e,t,n).length;return t===`unresolved`?{count:r,words:[`unresolved`,`unresolved`],label:PW(r,`unresolved thread`,`unresolved threads`)}:{count:r,words:[`thread`,`threads`],label:PW(r,`thread`,`threads`)}},zW=({resolved:e})=>e?(0,J.jsx)(Rh,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-review-approved`}):(0,J.jsx)(Kg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),BW=({ordered:e,scope:t,resolvedHere:n,current:r,onGo:i,onOpenList:a})=>{let o=jW(e,t,n),s=o.findIndex(e=>e.id===r),c=s===-1?null:s,l=c===null?void 0:o[c],u=l===void 0?``:IW(l);return(0,J.jsx)(eW,{slot:`thread-stepper`,noun:`thread`,total:o.length,at:c,count:LW(t,o.length),onStep:t=>{let n=NW(e,o,r,t);n!==null&&i(n)},onOpenList:a,title:l!==void 0&&(0,J.jsxs)(`button`,{type:`button`,"data-slot":`stepper-title`,"data-kind":`thread`,className:`ml-1 flex h-6 min-w-0 items-center gap-1.5 rounded-md px-1 text-left max-sm:hidden hover:bg-muted`,title:`${l.path}, ${FW(l)}`,"aria-label":`Go to thread: ${u}`,onClick:()=>i(l.id),children:[(0,J.jsx)(zW,{resolved:l.resolved}),(0,J.jsx)(`span`,{className:X(`min-w-0 truncate`,l.resolved&&`text-muted-foreground`),children:u})]}),status:l===void 0||c===null?``:`Thread ${c+1} of ${o.length}, ${l.path} ${FW(l)}${l.resolved?`, resolved`:l.outdated?`, outdated`:``}: ${u}`})},VW=({ordered:e,scope:t,onScope:n,onGo:r,onClose:i})=>{let a=e.filter(e=>!e.resolved).length,o=(0,q.useRef)(!1),s=[];for(let t of e){let e=s.at(-1);e?.path===t.path?e.threads.push(t):s.push({path:t.path,threads:[t]})}return(0,J.jsxs)(EB,{title:`${PW(e.length,`thread`,`threads`)}, ${a} unresolved`,onClose:i,returnFocus:()=>!o.current,className:`sm:max-w-2xl`,children:[a>0&&a<e.length&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-caption text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`Previous and Next go round`}),(0,J.jsx)(lW,{legend:`Previous and Next go round`,options:[{value:`unresolved`,label:`Unresolved (${a})`},{value:`all`,label:`All (${e.length})`}],value:t,onChange:n})]}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:s.map(({path:e,threads:t})=>(0,J.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`truncate px-2 font-mono text-code-compact text-muted-foreground`,children:e}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`thread-row`,"data-resolved":e.resolved||void 0,className:`flex min-h-7 w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-accent`,onClick:()=>{o.current=!0,r(e.id)},children:[(0,J.jsx)(zW,{resolved:e.resolved}),(0,J.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,e.resolved&&`text-muted-foreground`),children:IW(e)}),(e.resolved||e.outdated)&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.resolved?`Resolved`:`Outdated`}),(0,J.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:FW(e)})]})},e.id))})]},t[0]?.id??e))})]})},HW=.25,UW=(e,t,n)=>{let r=n?t-1:t*HW;return(e.findLast(e=>e.top<=r)??e[0])?.path??null},WW=()=>{let e=[...document.querySelectorAll(`[aria-label=Changes] [data-slot=file-card][data-path]`)],t=e.map(e=>e.getBoundingClientRect());return t.every(e=>e.height===0)?null:e.map((e,n)=>({path:e.dataset.path??``,top:t[n]?.top??0}))},GW=(e,t)=>{let[n,r]=(0,q.useState)(null),i=e.join(`\0`);return(0,q.useEffect)(()=>{if(!t)return;let e=0,n=()=>{e=0;let t=document.documentElement,n=window.scrollY+window.innerHeight>=t.scrollHeight-2,i=WW();if(i===null)return;let a=UW(i,window.innerHeight,n&&window.scrollY>0);a!==null&&r(a)},i=()=>{e===0&&(e=requestAnimationFrame(n))};return n(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i),e!==0&&cancelAnimationFrame(e)}},[i,t]),n},KW=1,qW=240,JW=6,YW=()=>{},XW=e=>{let t=e.left+e.width/2;for(let e=KW;e<Math.min(window.innerHeight,qW);e+=JW){let n=document.elementFromPoint(t,e);if(n===null||n.closest(`[data-slot=file-card-header]`)!==null)continue;let r=n.closest(`[role=row]`);if(r!==null)return r}return null},ZW=e=>{let t=document.querySelector(e)?.getBoundingClientRect();if(window.scrollY<=KW||t===void 0||t.top>=0||typeof document.elementFromPoint!=`function`)return YW;let n=XW(t);if(n===null)return YW;let r=n.getBoundingClientRect().top;return()=>{if(!n.isConnected)return;let e=n.getBoundingClientRect().top-r;e!==0&&window.scrollBy({top:e,behavior:`instant`})}},QW=`[aria-label=Changes]`,$W=e=>{let t=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),n=Number.parseFloat(t);return Number.isFinite(n)?t.endsWith(`ms`)?n:t.endsWith(`s`)?n*1e3:n:0},eG=e=>`✓ ${e} is done`,tG=new Set,nG=new Map,rG=(e,t,n=`Claude`)=>{let[r,i]=(0,q.useState)({running:e,before:tG}),[a,o]=(0,q.useState)(`done`),[s,c]=(0,q.useState)(nG),[l,u]=(0,q.useState)(0);e!==r.running&&(i({running:e,before:e?new Set(t):r.before}),o(e?`done`:`measure`),c(nG),e||u(l+1)),(0,q.useEffect)(()=>{if(l===0||!document.hidden)return;let e=document.title;document.title=`${eG(n)} · ${e}`;let t=()=>{document.hidden||(document.title=e)};return document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t),document.title=e}},[l,n]);let d=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{if(a!==`measure`)return;if(d.current=ZW(QW),$W(`--landing-total`)===0){o(`done`);return}let e=new Map;for(let t of document.querySelectorAll(`[data-slot=point-fold][data-fresh]`)){let{top:n}=t.getBoundingClientRect(),r=uu.safeParse(t.dataset.pointId);r.success&&n>=0&&n<window.innerHeight&&e.set(r.data,e.size)}c(e),o(`landing`)},[a]),(0,q.useLayoutEffect)(()=>{a!==`measure`&&d.current!==null&&(d.current(),d.current=null)},[a]),(0,q.useEffect)(()=>{if(a!==`landing`)return;let e=Math.max(0,s.size-1)*$W(`--landing-step-code`),t=setTimeout(()=>o(`done`),$W(`--landing-total`)+e);return()=>clearTimeout(t)},[a,s]);let{before:f}=r,p=(0,q.useCallback)(e=>a!==`done`&&!f.has(e),[a,f]);return{phase:a,running:e||a===`measure`,fresh:p,inView:a===`landing`?s:nG}},iG=(e,t)=>{let{client:n}=yp(),[r,i]=(0,q.useState)(new Map),[a,o]=(0,q.useState)(new Set),[s,c]=(0,q.useState)(null),l=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>{let e=new Map(t.map(e=>[e.pointId,e.state]));for(let[t,n]of r)e.set(t,n);return e},[t,r]);return{stateOf:(0,q.useCallback)(e=>u.get(e)??`open`,[u]),setState:(0,q.useCallback)(async(t,r)=>{i(e=>new Map(e).set(t,r)),o(e=>new Set(e).add(t));let a=(l.current.get(t)??0)+1;l.current.set(t,a);let s=await n.putPointState(e,t,{state:r});l.current.get(t)===a&&(o(e=>{let n=new Set(e);return n.delete(t),n}),s.ok?c(e=>e?.pointId===t?null:e):(i(e=>{let n=new Map(e);return n.delete(t),n}),c({pointId:t,message:Ap(s.error)})))},[e,n]),isSaving:e=>a.has(e),failure:s,dismissFailure:()=>c(null)}},aG=6e4,oG=e=>{let{client:t}=yp(),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null),o=(0,q.useRef)(0),s=(0,q.useCallback)(()=>{o.current+=1;let n=o.current;t.getPullRequestStatus(e).then(e=>{n===o.current&&(e.ok?(r(e.value),a(null)):a(e.error))})},[t,e]);(0,q.useEffect)(()=>(s(),window.addEventListener(`focus`,s),()=>window.removeEventListener(`focus`,s)),[s]);let c=n?.checks?.some(e=>e.state===`running`)===!0;return(0,q.useEffect)(()=>{if(!c)return;let e=setInterval(()=>{document.visibilityState===`visible`&&s()},aG);return()=>clearInterval(e)},[c,s]),{status:n,error:i,reload:s}},sG=(e,t)=>{let{client:n}=yp(),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),s=(0,q.useRef)(0),c=(0,q.useCallback)(()=>{s.current+=1;let t=s.current;n.getThreads(e).then(e=>{t===s.current&&(e.ok?(i(e.value),o(null)):o(e.error))})},[n,e]);return(0,q.useEffect)(()=>{t&&c()},[t,c]),{list:r,error:a,reload:c,reply:(0,q.useCallback)(async(t,r)=>{let i=await n.replyToThread(e,t,{body:r});return i.ok?(c(),null):Ap(i.error)},[n,e,c]),resolve:(0,q.useCallback)(async(t,r)=>{let i=await n.resolveThread(e,t,{resolved:r});return i.ok?(c(),null):Ap(i.error)},[n,e,c]),post:(0,q.useCallback)(async t=>{let r=await n.postComment(e,t);return r.ok?(c(),null):Ap(r.error)},[n,e,c])}},cG=[],lG=e=>Wd.array().safeParse(e).data,uG=({analysisId:e})=>{let[t,n]=(0,q.useState)({count:0,seed:null}),r=(0,q.useCallback)((e=null)=>n(({count:t})=>({count:t+1,seed:e})),[]);return(0,J.jsx)(dG,{analysisId:e,seed:t.seed,restart:r},`${e}/${t.count}`)},dG=({analysisId:e,seed:t,restart:n})=>{let{view:r,error:i,refetch:a,follow:o}=Ep(e,t);return r===null?i?.code===`not-found`?(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Analysis not found`}),(0,J.jsx)(`p`,{className:`text-body`,children:Ap(i)}),(0,J.jsx)(`p`,{children:(0,J.jsx)(N_,{to:`/`,children:`Pick a pull request to review`})})]}):i===null?(0,J.jsx)(fG,{}):(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 py-12`,children:[(0,J.jsxs)(`p`,{className:LN,role:`alert`,children:[`Couldn't load the analysis. `,Ap(i)]}),(0,J.jsx)($,{variant:`outline`,onClick:()=>void a(),children:`Try again`})]}):(0,J.jsx)(TG,{view:r,refetch:a,follow:o,restart:n})},fG=()=>(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1600px] flex-col gap-4`,role:`status`,"aria-busy":`true`,"aria-label":`Loading the analysis`,children:[(0,J.jsx)(zN,{className:`h-7 w-2/3`}),(0,J.jsx)(zN,{className:`h-4 w-1/2`}),(0,J.jsxs)(`div`,{className:pG,children:[(0,J.jsx)(UN,{}),(0,J.jsx)(HN,{})]})]}),pG=`grid items-start gap-5 lg:grid-cols-[17rem_minmax(0,1fr)]`,mG=[],hG=[{value:`map`,label:`Map`},{value:`overview`,label:`Overview`}],gG=[`nextFile`,`previousFile`,`comment`,`openCall`,`moveFile`,`openFile`,`toggleLayout`,`openReview`,`close`,`help`],_G=({analysis:e})=>{let{checkout:t,pullRequest:n}=e;if(t===`read`||n===null)return null;let{ref:r,headSha:i}=n;return(0,J.jsxs)(`p`,{"data-slot":`checkout-note`,className:`text-muted-foreground`,children:[`Code outside the pull request that calls what it changes isn't shown:`,` `,t===`missing-commit`?(0,J.jsxs)(J.Fragment,{children:[`the local checkout doesn't have the head commit`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:i.slice(0,7)}),`. Run`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`git fetch`}),` in it`,r.repo.host===`github`&&(0,J.jsxs)(J.Fragment,{children:[`, or`,` `,(0,J.jsxs)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:[`git fetch origin pull/`,r.number,`/head`]}),` `,`for a pull request from a fork`]}),`, then open the pull request again.`]}):(0,J.jsxs)(J.Fragment,{children:[`megareviewer didn't run in a checkout of `,r.repo.owner,`/`,r.repo.repo,`. Start it in one, or pass`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`--checkout <dir>`}),`, then open the pull request again.`]})]})},vG=[],yG=(e,t)=>{let[n,r]=(0,q.useState)(e);return!t&&n!==e&&r(e),t?n:e},bG=(e,t)=>{let{lines:n}=e;if(n===null)return null;let r=null,i=null;for(let[e,a]of t.lines.entries()){let t=_j(a);t!==null&&t.side===n.side&&(t.line<n.startLine||t.line>n.line||(r??=e,(i===null||t.line>i.line)&&(i={line:t.line,at:e})))}return r===null||i===null?null:{key:`${n.side}:${i.line}`,rows:i.at-r+1}},xG={github:void 0,bitbucket:`Bitbucket can't anchor a range, so the comment goes on the last line and names them.`},SG=new WeakMap,CG=0,wG=e=>{let t=SG.get(e);return t===void 0?(CG+=1,SG.set(e,CG),CG):t},TG=({view:e,refetch:t,follow:n,restart:r})=>{let{client:i}=yp(),a=tL(Sp().status?.model??null),{analysis:o,publication:s}=e,c=o.id,l=o.status===`complete`,u=l&&Bu(o),d=yG(o,u),f=Dp(i.runModel),p=s!==null||!l,m=(0,q.useMemo)(()=>rH(d),[d]),h=(0,q.useMemo)(()=>aH(d,m),[d,m]),g=(0,q.useMemo)(()=>oH(d,m),[d,m]),_=(0,q.useMemo)(()=>g.flatMap(e=>e.partIds),[g]),v=(0,q.useMemo)(()=>dH(d,m),[d,m]),y=uH(v),[b,x]=JI(`decisions`,!1,YI),S=(0,q.useMemo)(()=>hu(d).filter(e=>b||e.kind!==`decision`),[d,b]),C=(0,q.useMemo)(()=>S.map(e=>e.id),[S]),w=iG(c,e.pointReviews),[T,E]=(0,q.useState)(new Set),{stateOf:D}=w,O=(0,q.useMemo)(()=>new Set(S.filter(e=>e.guidance?.effect===`left-out`&&D(e.id)===`open`&&!T.has(e.id)).map(e=>e.id)),[S,D,T]),k=(0,q.useMemo)(()=>S.filter(e=>!O.has(e.id)),[S,O]),A=(0,q.useCallback)(e=>E(t=>new Set(t).add(e)),[]),j=Rl(o.modelOption??a.chosen),M=rG(u,C,j),N=(0,q.useMemo)(()=>cH(S,_,m),[S,_,m]),P=(0,q.useMemo)(()=>{let e=new Map,t=new Map,n=new Map,r=new Map,i=(e,t,n,r)=>{let i=e.get(t)??new Map;i.set(n,[...i.get(n)??[],r]),e.set(t,i)};for(let[a,o]of N.cards){let s=m.parts.get(a);for(let c of o){let o=s===void 0?null:bG(c,s.hunk);o===null?n.set(a,[...n.get(a)??[],c]):c.kind===`decision`?i(t,a,o.key,c):(i(e,a,o.key,c),r.set(c.id,o.rows))}}for(let t of e.values())for(let[e,n]of t)t.set(e,[...n.filter(e=>e.kind===`finding`),...n.filter(e=>e.kind!==`finding`)]);return{underLine:e,atLineEnd:t,underHeader:n,rowsAbove:r}},[N,m]),F=(0,q.useMemo)(()=>{let e=new Map,t=t=>{let[n]=t;for(let r of t)n!==void 0&&e.set(r.id,n.id)};for(let e of P.underLine.values())for(let n of e.values())t(n);for(let[e,n]of P.underHeader)t([...n,...N.mentions.get(e)??mG]);for(let[e,n]of N.mentions)P.underHeader.has(e)||t(n);return t(N.unplaced),e},[P,N]),{inView:I}=M,L=(0,q.useCallback)(e=>I.get(F.get(e)??e),[I,F]),R=(0,q.useMemo)(()=>{let e=new Map;for(let[t,n]of N.cards){let r=m.parts.get(t)?.file.path;if(r===void 0)continue;let i=n.filter(e=>!O.has(e.id));if(i.length===0)continue;let a=e.get(r)??{};for(let e of i)a[e.kind]=(a[e.kind]??0)+1;e.set(r,a)}return e},[N,m,O]),ee=(0,q.useMemo)(()=>g.map(({file:e})=>({path:e.path,status:e.status,additions:e.additions,deletions:e.deletions,...R.has(e.path)?{points:R.get(e.path)}:{}})),[g,R]),[z,te]=(0,q.useState)([]),B=(0,q.useMemo)(()=>$B(d,h,new Set(z)),[d,h,z]),ne=(0,q.useMemo)(()=>d.stages.prep===`done`?nV($B(d,h)):null,[d,h]),[V,H]=JI(`review-layout`,`map`,eH),re=GW((0,q.useMemo)(()=>g.map(e=>e.file.path),[g]),V===`map`&&d.stages.prep===`done`),[ie,ae]=(0,q.useState)(!1),oe=(0,q.useMemo)(()=>{let e=new Map;for(let t of d.unchangedCallers)e.set(t.partId,[...e.get(t.partId)??[],t]);return e},[d.unchangedCallers]),se=(0,q.useCallback)(e=>oe.get(e)??vG,[oe]),[U]=(0,q.useState)(Dj),ce=(0,q.useMemo)(()=>pV(d.callSites,m,U),[d.callSites,m,U]),le=(0,q.useCallback)(e=>ce.get(e),[ce]),ue=(0,q.useMemo)(()=>new Map(S.flatMap(e=>{let t=mV(e,m);return t===null?[]:[[e.id,{handle:U,payload:t}]]})),[S,m,U]),[de,fe]=(0,q.useState)(null),[pe,me]=(0,q.useState)(null),he=(0,q.useRef)(null),[ge,_e]=(0,q.useState)(null),[ve,ye]=(0,q.useState)(null),[be,xe]=(0,q.useState)(null),[Se,Ce]=(0,q.useState)(null),[we,Te]=(0,q.useState)(null),[Ee,De]=(0,q.useState)(new Set),[Oe,ke]=(0,q.useState)(!1),Ae=be===`thread`||k.length===0,je=Ae?null:ve,[Me,Ne]=(0,q.useState)(!1),[Pe,Fe]=(0,q.useState)(new Set),Ie=(0,q.useCallback)(e=>Fe(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),[Le,Re]=(0,q.useState)(null),[ze,Be]=(0,q.useState)(new Set),[Ve,He]=(0,q.useState)(null),[W,Ue]=(0,q.useState)(!1),[We,Ge]=(0,q.useState)(!1),Ke=(0,q.useRef)(!0),[qe,Je]=(0,q.useState)(!1),[Ye,Xe]=JI(`hunk-comments:${c}`,cG,lG),[Ze,Qe]=(0,q.useState)(null),$e=(0,q.useRef)(null),et=(0,q.useMemo)(()=>fH(Ye,m),[Ye,m]),tt=(0,q.useCallback)(e=>et.get(e)??cG,[et]),nt=(0,q.useCallback)((e,t)=>Xe(n=>{let r=rl(e),i=e=>e.hunkId===r&&e.side===t.side&&e.line===t.line,a={hunkId:r,...t},o=t.body===``&&t.suggestion===void 0;return n.some(i)?o?n.filter(e=>!i(e)):n.map(e=>i(e)?a:e):o?n:[...n,a]}),[Xe]),rt=(0,q.useCallback)((e,t)=>{$e.current=null,Qe(n=>{if(t?.startLine!==void 0&&n!==null&&n.partId===e){let r=rl(e),i=n.place;Xe(e=>e.map(e=>e.hunkId===r&&e.side===i.side&&e.line===i.line?{...e,line:t.line,startLine:t.startLine}:e))}return t===null?null:{partId:e,place:t}})},[Xe]),{setState:it}=w,at=(0,q.useCallback)((e,t)=>{let n=$e.current;$e.current=null,n!==null&&n.partId===e&&n.place.side===t.side&&n.place.line===t.line&&(nt(e,n.before??{...n.place,body:``}),n.state!==`raised`&&it(n.pointId,n.state))},[nt,it]),ot=sG(c,d.stages.prep===`done`),st=oG(c),{post:ct}=ot,lt=(0,q.useCallback)((e,t)=>ct({hunkId:rl(e),...t}),[ct]),ut=(0,q.useMemo)(()=>OW(ot.list?.threads??null,g,m),[ot.list,g,m]),dt=(0,q.useMemo)(()=>AW(ut,g,m),[ut,g,m]),ft=MW(we,dt,Ee),pt=Ae?Se:null,{resolve:mt}=ot,ht=(0,q.useCallback)(async(e,t)=>{let n=await mt(e,t);return n===null&&t&&De(t=>new Set(t).add(e)),n},[mt]),gt=d.pullRequest?.author.id??null,_t=(e,t)=>(0,J.jsx)(lj,{thread:e,authorId:gt,now:Date.now(),language:TD({path:e.path,language:null}),covered:t,mediaUrl:e=>i.attachmentUrl(c,e),onReply:t=>ot.reply(e.id,t),onResolve:t=>ht(e.id,t),current:pt===e.id,anchorId:wW(e.id),linesAbove:t?.length??0},e.id),vt=(e,t)=>{let n=ut.onLine.get(e)?.get(TW(t));if(n===void 0)return null;let r=m.parts.get(e)?.hunk;return n.map(e=>{let n=e.startLine??t.line;return _t(e,r===void 0?null:kW(r,Math.min(n,t.line),t.line))})},yt=e=>{let t=ut.earlier.get(e);return t===void 0?null:t.map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.outdated?`Was on ${e.side===`old`?`old `:``}line ${e.originalLine??`?`}; the code has changed since`:`On ${sj(e)}, which the diff doesn't show`}),_t(e,null)]},e.id))},bt=e=>ut.open.get(e)??0,xt=(0,q.useMemo)(()=>ee.map(e=>({...e,threads:ut.open.get(e.path)??0})),[ee,ut]),St=e=>He(t=>({id:e,n:(t?.n??0)+1})),Ct=()=>V===`overview`?null:de,wt=(0,q.useCallback)(e=>fe(e),[]),Tt=e=>{B.placeOf.has(e)&&me(t=>({key:e,n:(t?.n??0)+1}))},Et=(e,t=V)=>{if(t===`overview`){let t=m.parts.get(e)?.file.path;t!==void 0&&Tt(t)}else St(_.includes(e)?hV(e):hH)},Dt=e=>{let t=S.find(t=>t.id===e),n=N.cardPart.get(e);t?.kind===`decision`&&Fe(t=>new Set([...t,e])),O.has(e)&&A(e),be===`thread`&&xe(null),Be(new Set((t?.hunkIds??[]).flatMap(m.partsOf))),V===`overview`?n!==void 0&&Et(n):St(gU(e)),ye(e)},Ot=e=>{xe(`thread`),Ce(e),Be(new Set),V===`overview`&&H(()=>`map`),St(wW(e))},kt=e=>{if(xe(e),e===`thread`){let e=jW(dt,ft,Ee),[t]=e;t!==void 0&&!e.some(e=>e.id===Se)&&Ot(t.id);return}let t=XU(k,e,ve);t!==null&&Dt(t)},At=e=>{let t=uu.parse(`m${e+1}`),n=d.findings.find(t=>t.mismatch===`m${e+1}`);Dt(S.some(e=>e.id===t)||n===void 0?t:uu.parse(n.id))},jt=()=>{let e=(document.activeElement?.closest(`[aria-label=Changes] [data-slot=file-card]`))?.dataset.path??re;H(()=>`overview`),_e(null),e!==null&&Tt(e)},Mt=e=>{let[t]=e.kind===`outside`?[]:e.paths,n=t===void 0?e.partIds[0]:g.find(e=>e.file.path===t)?.partIds[0];n!==void 0&&(H(()=>`map`),_e(e.key),fe(n),t===void 0?Et(n,`map`):St(gH(t)))},Nt=()=>{if(V===`map`)return jt();let e=[...B.rows.flat(),...B.strip].find(e=>e.key===he.current);if(e!==void 0&&e.kind!==`outside`)return Mt(e);H(()=>`map`)};Ip({label:`Layout`,options:hG,value:V,onChange:e=>{e!==V&&Nt()},toggle:{label:`Decisions`,checked:b,onChange:e=>x(()=>e)}});let Pt=e=>{let t=[...document.querySelectorAll(`[aria-label=Changes] [data-slot=file-card]`)],n=t.findIndex(e=>e.contains(document.activeElement)),r=n===-1?e===1?t.find(e=>e.getBoundingClientRect().top>1):t.findLast(e=>e.getBoundingClientRect().top<-1):t[n+e];r!==void 0&&St(r.id)},Ft=(e,t=!1)=>{let n=N.cardPart.get(e.id),r=n===void 0?void 0:m.parts.get(n);if(p||n===void 0||r===void 0)return;let i=e.lines===null?null:{side:e.lines.side,line:e.lines.line,...e.lines.startLine===e.lines.line?{}:{startLine:e.lines.startLine}},a=r.hunk.lines.find(e=>e.kind!==`context`),o=i??(a===void 0?null:_j(a));if(o===null)return;let s=e.explanation===``?e.title:`${e.title}\n\n${e.explanation}`,c=rl(n),l=Ye.find(e=>e.hunkId===c&&e.side===o.side&&e.line===o.line),u={...e.suggestion===null?{}:{suggestion:e.suggestion}};l===void 0?nt(n,{...o,body:s,...u}):w.stateOf(e.id)!==`raised`&&!l.body.includes(s)&&nt(n,{...u,...l,body:l.body===``?s:`${l.body}\n\n${s}`}),ye(e.id);let d=w.stateOf(e.id);if(w.setState(e.id,`raised`),t)return;let{startLine:f}=l??o,h={side:o.side,line:o.line,...f===void 0?{}:{startLine:f}};Qe({partId:n,place:h}),$e.current={partId:n,place:h,before:l,pointId:e.id,state:d},St(hV(n))},It=()=>{let e=Ct(),t=e===null?void 0:m.parts.get(e),n=t?.hunk.lines.find(e=>e.kind!==`context`);if(!l||t===void 0||n===void 0)return;let r=_j(n);r!==null&&e!==null&&($e.current=null,Qe({partId:e,place:r}))},Lt=()=>{let e=document.activeElement;if(!(e instanceof HTMLElement))return;let t=[...(e.closest(`[role=row]`)??e.closest(`[data-slot=hunk-card]`)??e.closest(`[data-slot=file-card]`))?.querySelectorAll(`[data-slot=call]`)??[]],n=t[(t.findIndex(e=>e.hasAttribute(`data-popup-open`))+1)%t.length];n!==void 0&&U.open(n.id)},Rt=()=>{if(ze.size>0)return Be(new Set);V===`map`&&ge!==null&&(H(()=>`overview`),me(e=>({key:ge,n:(e?.n??0)+1})),_e(null))},zt=l;_k({...V===`map`?{nextFile:()=>Pt(1),previousFile:()=>Pt(-1),comment:It,openCall:Lt,close:Rt}:{},toggleLayout:()=>Nt(),openReview:()=>{zt&&Wt()},help:()=>Ge(!0)},!W&&!We&&!qe);let Bt=d.pullRequest?.url??hf(d.key.ref),Vt=Dp(i.startAnalysis),Ht=Dp(i.retryAnalysis),Ut=e=>{e===c?r():A_(D_(e))},Wt=()=>Ue(!0),Gt=Ye.length,Kt=(0,q.useMemo)(()=>pH(d.files),[d.files]),qt=w.failure===null?``:S.find(e=>e.id===w.failure?.pointId)?.title??``,Jt=async(e,t)=>{let n=await i.addPreference({...t,source:`learned`});return n.ok?(w.setState(e.id,`dismissed`),null):dL(n.error)},Yt=e=>({state:w.stateOf(e.id),saving:w.isSaving(e.id),readOnly:p,current:je===e.id,onRaise:ln.raisePoint,onState:ln.setPointState,leftOut:O.has(e.id),onShow:A,ruleScopes:dn,onRule:ln.saveRule}),Xt=(e,t)=>{let n=t===null?void 0:m.parts.get(t),r=e.lines,i=t!==null&&r!==null&&tt(t).some(e=>e.side===r.side&&e.line===r.line);return(0,J.jsx)(RU,{point:e,...Yt(e),linesAbove:P.rowsAbove.get(e.id)??0,inReview:i,removed:n===void 0||r===null||r.side===`old`?null:kW(n.hunk,r.startLine,r.line),language:n===void 0?null:TD(n.file)},e.id)},Zt=e=>(0,J.jsx)(VU,{point:e,...Yt(e),linesAbove:P.rowsAbove.get(e.id)??0,test:ue.get(e.id)??null},e.id),Qt=e=>(0,J.jsx)(UU,{point:e,...Yt(e)},e.id),$t=(e,t=null)=>e.kind===`finding`?Xt(e,t):e.kind===`risk`?Zt(e):Qt(e),en=(0,q.useMemo)(()=>{let e={finding:0,risk:1,decision:2},t=new Map;for(let[n,r]of N.cards){let i=new Map;for(let t of r){if(t.lines===null||t.kind===`decision`||O.has(t.id))continue;let{side:n,startLine:r,line:a}=t.lines,o=L(t.id);for(let s=r;s<=a;s+=1){let c=`${n}:${s}`,l=i.get(c);l!==void 0&&e[t.kind]>=e[l.kind]||i.set(c,{kind:t.kind,...o===void 0?{}:{landing:{at:o,line:s-r,lines:a-r+1}}})}}i.size>0&&t.set(n,i)}return t},[N,L,O]),tn=(0,q.useCallback)(e=>en.get(e),[en]),nn=(e,t,n)=>{let[r]=e;return r===void 0?null:(0,J.jsx)(GU,{pointId:r.id,fresh:e.some(e=>M.fresh(e.id)),at:L(r.id),...t,children:n},r.id)},rn=e=>{let t=P.underHeader.get(e)??mG,n=N.mentions.get(e)??mG;return nn([...t,...n],{bodyClassName:`flex flex-col gap-2 border-b bg-surface-subtle p-3`},(0,J.jsxs)(J.Fragment,{children:[t.map(t=>$t(t,e)),n.map(e=>(0,J.jsx)(WU,{point:e,onGo:ln.goToPoint},e.id))]}))},an=(e,t)=>{let n=TW(t),r=P.underLine.get(e)?.get(n)??mG,i=(P.atLineEnd.get(e)?.get(n)??mG).filter(e=>Pe.has(e.id));return(0,J.jsxs)(J.Fragment,{children:[nn(r,{row:!0,className:vj,bodyClassName:`flex max-w-3xl flex-col gap-2 py-2 pr-3 pl-29 font-sans`},r.map(t=>$t(t,e))),i.length>0&&(0,J.jsx)(bj,{inset:!0,children:(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(Qt)})})]})},on=(e,t)=>{let n=P.atLineEnd.get(e)?.get(TW(t));return n===void 0?null:n.map(e=>(0,J.jsx)(HU,{point:e,state:w.stateOf(e.id),open:Pe.has(e.id),current:je===e.id,onToggle:Ie},e.id))},sn=(0,q.useCallback)(e=>{let t=P.underLine.get(e);if(t===void 0)return;let n=[...t].filter(([,e])=>e.some(e=>e.kind===`finding`&&!O.has(e.id)));return new Set(n.map(([e])=>e))},[P,O]),cn=(0,q.useRef)({goToPoint:Dt,raisePoint:Ft,saveRule:Jt});cn.current={goToPoint:Dt,raisePoint:Ft,saveRule:Jt};let ln=(0,q.useMemo)(()=>({goToPoint:e=>cn.current.goToPoint(e),raisePoint:(e,t)=>cn.current.raisePoint(e,t),saveRule:(e,t)=>cn.current.saveRule(e,t),setPointState:w.setState}),[w.setState]),un=d.key.ref.repo,dn=(0,q.useMemo)(()=>yB([un]).reverse(),[un]),fn=e=>{let t=[wG(d),p,ze.has(e),Ze?.partId===e?`${Ze.place.side}${Ze.place.line}`:``,...tt(e).map(e=>JSON.stringify(e))];ut.onLine.has(e)&&t.push(wG(ut),pt??``);let n=N.cards.get(e)??mG,r=N.mentions.get(e)??mG;for(let e of n)t.push(e.id,w.stateOf(e.id),w.isSaving(e.id)),t.push(je===e.id,O.has(e.id)),e.kind===`decision`&&t.push(Pe.has(e.id));for(let e of r)t.push(e.id);for(let e of[...n,...r])t.push(M.fresh(e.id),L(e.id)??``);return t.join(`\0`)},pn={index:m,unchangedOf:se,highlighted:ze,commentsOf:tt,openComment:Ze,onOpenComment:rt,onCancelComment:at,onComment:l?nt:void 0,...l?{onCommentNow:lt}:{},onFocusHunk:wt,marksOf:le,pointsOn:rn,pointsAt:an,pointsAtEnd:on,flaggedOf:sn,pointLinesOf:tn,threadsAt:vt,earlierThreads:yt,openThreads:bt,...xG[d.key.ref.repo.host]===void 0?{}:{rangeNote:xG[d.key.ref.repo.host]}},mn=(0,J.jsx)(J.Fragment,{children:N.unplaced.length>0&&(0,J.jsx)(`section`,{"aria-label":`Points on no change shown here`,children:nn(N.unplaced,{bodyClassName:`flex flex-col gap-2`},N.unplaced.map(e=>$t(e)))})});return(0,J.jsxs)(`div`,{"data-slot":`review-page`,"data-layout":V,"data-landing":M.phase,className:`mx-auto flex max-w-[1600px] flex-col gap-4`,children:[(0,J.jsx)(CW,{view:e,intent:(0,J.jsx)(OV,{analysis:o,through:ne,running:M.running,onDetails:()=>{Ke.current=!0,Je(!0)}}),totals:Kt,threads:ot.list===null?null:mH(ot.list.threads),status:st.status,statusError:st.error,onRetryStatus:st.reload,now:Date.now(),reanalyzing:Vt.pending,reanalyzeError:Vt.error,onReanalyze:async()=>{let e=await Vt.run({url:Bt});e.ok&&Ut(e.value.analysisId)}}),(0,J.jsx)(_W,{title:o.pullRequest?.title??null,claude:(0,J.jsx)(dV,{analysis:o,choice:a,running:M.running,startedAt:Le,starting:f.pending,error:f.error===null?null:Ap(f.error),points:k,leftOut:O.size,threads:RW(dt,ft,Ee),narrowed:be,onNarrow:kt,onRun:async()=>{let e=a.chosen?.id;(await f.run(c,e===void 0?{}:{optionId:e})).ok&&(Re(Date.now()),n())},children:Ae?dt.length>0&&(0,J.jsx)(BW,{ordered:dt,scope:ft,resolvedHere:Ee,current:Se,onGo:Ot,onOpenList:()=>ke(!0)}):(0,J.jsx)(tW,{points:k,current:ve,stateOf:w.stateOf,kind:be,onGo:Dt,onOpenList:()=>Ne(!0)})}),tools:V===`map`&&(0,J.jsx)($,{variant:`outline`,size:`sm`,className:`lg:hidden`,"aria-expanded":ie,"aria-controls":`review-tree-rail`,onClick:()=>ae(!ie),children:ie?`Hide files`:`Show files`}),publish:zt&&(0,J.jsxs)($,{size:`sm`,"data-slot":`publish-button`,className:`shrink-0`,onClick:()=>void Wt(),children:[`Publish review…`,Gt>0&&(0,J.jsxs)(`span`,{className:`tabular rounded-full bg-primary-foreground px-1.5 text-caption text-primary`,children:[Gt,(0,J.jsx)(`span`,{className:`sr-only`,children:` to post`})]})]}),publication:s,hairline:M.running?`running`:M.phase===`landing`?`finishing`:null}),!l&&(0,J.jsx)(oW,{stages:o.stages,shown:cW,filesFetched:o.filesFetched}),o.error!==null&&(0,J.jsxs)(`div`,{className:X(`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,`flex flex-col items-start gap-2`),role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`The analysis failed at the `,sW(o.error.stage).toLowerCase(),` stage:`,` `,o.error.message]}),Ht.error!==null&&(0,J.jsxs)(`p`,{children:[`Couldn't retry. `,Ap(Ht.error)]}),(0,J.jsx)($,{variant:`outline`,size:`sm`,disabled:Ht.pending,onClick:async()=>{let e=await Ht.run(c);e.ok&&Ut(e.value.analysisId)},children:Ht.pending?`Retrying…`:`Retry`})]}),w.failure!==null&&(0,J.jsxs)(`div`,{className:X(`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,`flex flex-wrap items-center justify-between gap-2`),role:`alert`,children:[(0,J.jsxs)(`p`,{children:[`Couldn't save what you did with “`,qt,`”. `,w.failure.message]}),(0,J.jsx)($,{variant:`ghost`,size:`sm`,onClick:w.dismissFailure,children:`Dismiss`})]}),ot.error!==null&&(0,J.jsxs)(`div`,{role:`status`,className:X(`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,`flex flex-wrap items-center gap-3`),children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),`Couldn't read the comments on the pull request. `,Ap(ot.error)]}),(0,J.jsx)($,{variant:`outline`,size:`sm`,onClick:ot.reload,children:`Try again`})]}),d.stages.prep===`done`?V===`map`?(0,J.jsxs)(`div`,{className:X(pG,`[&>aside]:hidden lg:[&>aside]:flex`,ie&&`[&>aside]:flex`),children:[(0,J.jsx)(mW,{children:(0,J.jsx)(oF,{files:xt,activePath:re,onSelect:e=>St(gH(e)),className:`min-h-0 flex-1`})}),(0,J.jsx)(xH,{analysis:d,files:g,deps:pn,before:mn,after:ut.elsewhere.length>0&&(0,J.jsxs)(`section`,{"aria-label":`Comments on other files`,className:`flex flex-col gap-2 rounded-lg border bg-surface-subtle p-3`,children:[(0,J.jsx)(`h2`,{className:`text-caption font-medium text-muted-foreground`,children:`Comments on files without a card here`}),ut.elsewhere.map(e=>(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`font-mono text-code-compact`,children:e.path}),_t(e,null)]},e.id))]}),trailingProofs:v,mechanicalCount:y,scrollRequest:Ve,signatureOf:fn})]}):(0,J.jsx)(`div`,{children:(0,J.jsx)(mU,{overview:B,focusKey:pe,currentPath:re,onOpen:Mt,onExpand:e=>te(t=>[...t,e]),expandedGroups:z,onCollapse:e=>te(t=>t.filter(t=>t!==e)),onFocusNode:e=>{he.current=e}})}):(0,J.jsx)(`section`,{"aria-busy":d.status===`running`,children:(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:d.status===`running`?`Reading the diff…`:`The diff couldn't be read, so there are no changes to show.`})}),(0,J.jsxs)(`footer`,{className:`flex items-center justify-end gap-3`,children:[(0,J.jsx)(zH,{calls:o.modelCalls,option:o.modelOption,guidance:o.guidance,leftOut:S.filter(e=>e.guidance?.effect===`left-out`).length}),l&&!u&&Hu(o)&&(0,J.jsx)(hW,{analysisId:c,family:j,onRemoved:t=>r({...e,...t})}),(0,J.jsx)(NH,{usage:o.usage,option:o.modelOption,guidance:o.guidance})]}),W&&(0,J.jsx)(pW,{analysisId:c,hunkComments:Ye,isAuthor:e.isAuthor,published:s!==null,onClose:()=>Ue(!1),onPublished:()=>{Ue(!1),Xe(()=>[]),ot.reload(),st.reload(),t()}}),Oe&&(0,J.jsx)(VW,{ordered:dt,scope:ft,onScope:Te,onGo:e=>{ke(!1),Ot(e)},onClose:()=>ke(!1)}),Me&&(0,J.jsx)(qU,{points:k,family:j,kind:be===`thread`?null:be,stateOf:w.stateOf,onGo:e=>{Ne(!1),Dt(e)},onClose:()=>Ne(!1)}),(0,J.jsx)($N,{open:We,onOpenChange:Ge,ids:gG}),(0,J.jsx)(kj,{handle:U,onGoTo:e=>St(hV(e))}),qe&&(0,J.jsxs)(EB,{title:d.intent===null?`What was asked`:`Intent`,onClose:()=>Je(!1),className:`sm:max-w-4xl`,returnFocus:()=>Ke.current,children:[d.intent===null?d.pullRequest!==null&&(0,J.jsx)(AV,{pullRequest:d.pullRequest,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys}):(0,J.jsx)(zV,{intent:d.intent,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys,onSelectMismatch:e=>{Ke.current=!1,Je(!1),At(e)}}),(0,J.jsx)(_G,{analysis:d})]}),(0,J.jsxs)(`p`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground`,children:[`Press `,(0,J.jsx)(bk,{id:`help`}),` for keyboard shortcuts.`]})]})},EG={theme:`megareviewer:theme`,diffPalette:`megareviewer:diffPalette`},DG=`(prefers-color-scheme: dark)`,OG=e=>e===`light`||e===`dark`?e:`system`,kG=e=>e===`cb`?`cb`:`default`,AG=(e,t)=>e===`system`?t?`dark`:`light`:e,jG=(e,t,n)=>{e.classList.toggle(`dark`,t===`dark`),n===`cb`?e.dataset.diffPalette=`cb`:delete e.dataset.diffPalette},MG=e=>{try{let t=window.localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}},NG=(e,t)=>{try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}},PG=new Set,FG=()=>{for(let e of PG)e()},IG=e=>{PG.add(e);let t=window.matchMedia(DG);return t.addEventListener(`change`,e),window.addEventListener(`storage`,e),()=>{PG.delete(e),t.removeEventListener(`change`,e),window.removeEventListener(`storage`,e)}},LG=()=>`${OG(MG(EG.theme))} ${kG(MG(EG.diffPalette))} ${window.matchMedia(DG).matches}`,RG=()=>{let[e=`system`,t=`default`,n]=(0,q.useSyncExternalStore)(IG,LG).split(` `),r=OG(e),i=kG(t),a=AG(r,n===`true`);return(0,q.useEffect)(()=>{jG(document.documentElement,a,i)},[a,i]),{theme:r,resolvedTheme:a,diffPalette:i,setTheme:(0,q.useCallback)(e=>{NG(EG.theme,e),FG()},[]),setDiffPalette:(0,q.useCallback)(e=>{NG(EG.diffPalette,e),FG()},[])}},zG={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius-xl)`},BG=({...e})=>{let{resolvedTheme:t}=RG();return(0,J.jsx)(gN,{theme:t,className:`toaster group`,icons:{success:(0,J.jsx)(Jh,{className:`size-4`}),info:(0,J.jsx)(Pg,{className:`size-4`}),warning:(0,J.jsx)(v_,{className:`size-4`}),error:(0,J.jsx)(Jg,{className:`size-4`}),loading:(0,J.jsx)(Hg,{className:`size-4 animate-spin`})},style:zG,toastOptions:{classNames:{toast:`cn-toast`}},...e})},VG={github:`GitHub`,bitbucket:`Bitbucket`},HG=`then restart megareviewer.`,UG={github:{connect:`Set GITHUB_TOKEN or run \`gh auth login\`, ${HG}`,adds:`Lists and opens GitHub pull requests.`},bitbucket:{connect:`Set BITBUCKET_EMAIL and BITBUCKET_API_TOKEN, and BITBUCKET_WORKSPACE to list its pull requests, ${HG}`,adds:`Lists and opens Bitbucket pull requests.`}},WG=e=>e===1?`1 pull request`:`${e} pull requests`,GG=(e,t,n,r,i)=>{let a=VG[e],{connect:o,adds:s}=UG[e];if(!t.configured)return n.configured?{kind:e,name:a,state:`optional`,detail:s,fix:o}:{kind:e,name:a,state:`not-connected`,detail:`${a} isn't configured.`,fix:o};if(t.user===null)return{kind:e,name:a,state:`failing`,detail:t.error??`Couldn't read the signed-in ${a} user.`,fix:`Check the token, ${HG} A network failure needs only Check again.`};let c=r?.counts[e];return{kind:e,name:a,state:`working`,detail:c===void 0||r===null?t.user.name:`${t.user.name} · ${WG(c)} listed ${hF(new Date(r.atMs).toISOString(),i)}`,fix:null}},KG={claude:{name:`Claude`,providers:[`claude-code`,`anthropic-api`],adds:`Adds intent, findings, risks and decisions with Request AI review.`,connect:"Run `claude` and sign in, or set ANTHROPIC_API_KEY."},codex:{name:`Codex`,providers:[`codex`],adds:`Adds OpenAI's GPT models to Request AI review, on your ChatGPT plan.`,connect:"Install the Codex CLI and run `codex login`."},opencode:{name:`opencode`,providers:[`opencode`],adds:`Adds the models of the providers you connected in opencode to Request AI review.`,connect:"Install opencode (https://opencode.ai) and connect a provider with `opencode auth login`."}},qG=e=>e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`,JG=(e,t,n)=>{if(e===`claude`){let e=t.find(e=>e.id===n)??t[0];return e===void 0?``:`${e.modelName} through ${e.via}`}if(e===`codex`)return`${qG(t.map(e=>e.modelName))} through ${t[0]?.via??`Codex`}`;let r=[...new Set(t.map(e=>e.via.replace(/^opencode, on /,``)))];return`${t.length===1?`1 model`:`${t.length} models`} through ${qG(r)}`},YG=(e,{options:t,defaultId:n})=>{let{name:r,providers:i,adds:a,connect:o}=KG[e],s=t.filter(e=>i.includes(e.provider)),c=s.filter(e=>e.available);if(c.length>0)return{kind:e,name:r,state:`working`,detail:JG(e,c,n),fix:null};let l=[...new Set(s.flatMap(e=>e.reason??[]))];return{kind:e,name:r,state:`optional`,detail:a,fix:l.length>0?l.join(`; or `):`${o.slice(0,-1)}, ${HG}`}},XG=e=>e?{kind:`jira`,name:`Jira`,state:`working`,detail:`Links tickets`,fix:null}:{kind:`jira`,name:`Jira`,state:`optional`,detail:`Reads the tickets a pull request names.`,fix:`Set JIRA_BASE_URL, JIRA_EMAIL and JIRA_API_TOKEN, ${HG}`},ZG={failing:0,"not-connected":1,working:2,optional:2,checking:2},QG=(e,t)=>e===1?`1 ${t}`:`${e} ${t}s`,$G=[[`github`,`GitHub`],[`bitbucket`,`Bitbucket`],[`claude`,`Claude`],[`codex`,`Codex`],[`opencode`,`opencode`],[`jira`,`Jira`]],eK=e=>{let{status:t,error:n,checking:r,checkedAtMs:i,listed:a,nowMs:o}=e;if(n!==null&&!r)return{rows:[],button:{label:`Disconnected`,tone:`danger`,name:`Connections: megareviewer's server isn't answering. Open for details.`},summary:`megareviewer's server isn't answering`,disconnected:Ap(n)};if(t===null)return{rows:$G.map(([e,t])=>({kind:e,name:t,state:`checking`,detail:``,fix:null})),button:{label:`Checking…`,tone:`checking`,name:`Connections: checking. Open for details.`},summary:`Checking ${$G.length} connections…`,disconnected:null};let{github:s,bitbucket:c}=t.hosts,l=[GG(`github`,s,c,a,o),GG(`bitbucket`,c,s,a,o),YG(`claude`,t.model),YG(`codex`,t.model),YG(`opencode`,t.model),XG(t.jira.configured)].sort((e,t)=>ZG[e.state]-ZG[t.state]),u=e=>l.filter(t=>t.state===e).length,d=u(`failing`),f=u(`not-connected`),p=u(`working`),m=u(`optional`),h=d+f,g=[...d>0?[`${d} failing`]:[],...f>0?[`${f} not connected`]:[],...p>0?[`${p} working`]:[],...m>0&&h===0?[`${m} optional`]:[]],_=i===null?``:` · checked ${hF(new Date(i).toISOString(),o)}`,v=h>0?g.join(` · `):p===l.length?`All ${p} working${_}`:`${g.join(` · `)}${_}`,y=`Connections: ${g.join(` · `)}. ${h>0?`Open to fix.`:`Open for details.`}`;return r?{rows:l.map(e=>({...e,state:`checking`})),button:{label:`Checking…`,tone:`checking`,name:`Connections: checking. Open for details.`},summary:`Checking ${l.length} connections…`,disconnected:null}:{rows:l,button:{...h>0?{label:QG(h,`issue`),tone:d>0?`danger`:`warning`}:p===l.length?{label:`All connected`,tone:`ok`}:{label:`${p} of ${l.length} connected`,tone:`ok`},name:y},summary:v,disconnected:null}},tK={checking:`text-muted-foreground`,ok:``,warning:`border-review-pending bg-review-pending-bg text-review-pending hover:bg-review-pending-bg hover:text-review-pending aria-expanded:bg-review-pending-bg aria-expanded:text-review-pending`,danger:`border-destructive bg-review-changes-bg text-destructive hover:bg-review-changes-bg hover:text-destructive aria-expanded:bg-review-changes-bg aria-expanded:text-destructive`},nK={github:Og,bitbucket:Og,claude:f_,codex:f_,opencode:f_,jira:m_},rK={working:{label:`Connected`,icon:Rh,tone:`text-ci-success`,row:``},failing:{label:`Failing`,icon:v_,tone:`text-destructive`,row:`border-l-3 border-l-destructive bg-review-changes-bg`},"not-connected":{label:`Not connected`,icon:Xh,tone:`text-review-pending`,row:`border-l-3 border-l-review-pending bg-review-pending-bg`},optional:{label:`Not connected · Optional`,icon:Xh,tone:`text-muted-foreground`,row:``},checking:{label:`Checking…`,icon:Hg,tone:`text-muted-foreground`,row:``}},iK=new Set([`claude`,`codex`,`opencode`]),aK=({className:e})=>(0,J.jsx)(Hg,{"aria-hidden":`true`,className:X(`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,e)}),oK=({tone:e})=>e===`checking`?(0,J.jsx)(aK,{}):e===`ok`?(0,J.jsx)(Rh,{"aria-hidden":`true`,className:`text-ci-success`}):(0,J.jsx)(v_,{"aria-hidden":`true`}),sK=({row:e})=>{let t=rK[e.state],n=e.state===`optional`&&iK.has(e.kind)?`Not connected`:t.label,r=nK[e.kind],i=t.icon;return(0,J.jsxs)(`li`,{"data-state":e.state,className:X(`flex flex-col gap-0.5 rounded-md px-2.5 py-2`,t.row,e.state===`optional`&&`text-muted-foreground`),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,J.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,J.jsxs)(`span`,{className:X(`ml-auto flex items-center gap-1 text-caption`,t.tone),children:[(0,J.jsx)(i,{"aria-hidden":`true`,className:X(`size-3.5`,e.state===`checking`&&`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`)}),n]})]}),e.detail!==``&&(0,J.jsx)(`p`,{className:`text-caption`,children:e.detail}),e.fix!==null&&(0,J.jsx)(`p`,{className:`text-caption`,children:e.fix})]})},cK=({connections:e,version:t,checking:n,onCheckAgain:r,checkAgainRef:i})=>(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1`,children:[(0,J.jsx)(TM,{className:`text-heading font-semibold`,children:`Connections`}),(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:e.summary})]}),e.disconnected===null?(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.rows.map(e=>(0,J.jsx)(sK,{row:e},e.kind))}):(0,J.jsx)(`p`,{className:`rounded-md border-l-3 border-l-destructive bg-review-changes-bg px-2.5 py-2 text-caption`,children:e.disconnected}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-1 pt-2`,children:[(0,J.jsxs)($,{ref:i,variant:`outline`,size:`sm`,onClick:r,"aria-busy":n,"aria-disabled":n,children:[n&&(0,J.jsx)(aK,{}),`Check again`]}),t!==null&&(0,J.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`megareviewer `,t]})]})]}),lK=({connections:e,version:t,checking:n,open:r,onOpenChange:i,onCheckAgain:a,focusCheckAgain:o=!1})=>{let s=(0,q.useCallback)(e=>{e!==null&&o&&e.focus()},[o]),{label:c,tone:l,name:u}=e.button;return(0,J.jsxs)(SM,{...r===void 0?{}:{open:r},...i===void 0?{}:{onOpenChange:e=>i(e)},children:[(0,J.jsxs)(CM,{render:(0,J.jsx)($,{variant:`outline`,size:`sm`,className:tK[l],"data-tone":l,"aria-label":u}),children:[(0,J.jsx)(oK,{tone:l}),c]}),(0,J.jsx)(wM,{align:`end`,className:`w-[min(340px,calc(100vw-24px))] p-2`,initialFocus:!1,children:(0,J.jsx)(cK,{connections:e,version:t,checking:n,onCheckAgain:()=>{n||a()},checkAgainRef:s})})]})},uK=({now:e=Date.now})=>{let t=PF(),{status:n,error:r,checking:i,checkedAtMs:a,listed:o,open:s,setOpen:c,focusCheckAgain:l}=t,u=eK({status:n,error:r,checking:i,checkedAtMs:a,listed:o,nowMs:e()}),{label:d,tone:f}=u.button,[p,m]=(0,q.useState)(``),h=(0,q.useRef)(!0);return(0,q.useEffect)(()=>{f!==`checking`&&(h.current?h.current=!1:m(`Connections: ${d}`))},[d,f]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lK,{connections:u,version:n?.version??null,checking:i,open:s,onOpenChange:e=>c(e),onCheckAgain:t.checkAgain,focusCheckAgain:l}),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:p})]})},dK=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}],fK=()=>{let{theme:e,diffPalette:t,setTheme:n,setDiffPalette:r}=RG(),i=Fp(),a=(0,q.useRef)(!1);return(0,J.jsxs)(UR,{children:[(0,J.jsx)(WR,{render:(0,J.jsx)($,{variant:`ghost`,size:`sm`,className:`max-sm:px-1.5`}),children:`Display`}),(0,J.jsxs)(GR,{align:`end`,className:`w-56`,finalFocus:()=>{let e=a.current;return a.current=!1,!e},children:[i!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(KR,{children:[(0,J.jsx)(qR,{children:i.label}),(0,J.jsx)(XR,{value:i.value,onValueChange:e=>{a.current=!0,i.onChange(e)},children:i.options.map(e=>(0,J.jsx)(ZR,{value:e.value,closeOnClick:!0,children:e.label},e.value))})]}),(0,J.jsx)(QR,{}),i.toggle!==void 0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(YR,{checked:i.toggle.checked,onCheckedChange:i.toggle.onChange,children:i.toggle.label}),(0,J.jsx)(QR,{})]})]}),(0,J.jsxs)(KR,{children:[(0,J.jsx)(qR,{children:`Theme`}),(0,J.jsx)(XR,{value:e,onValueChange:e=>{let t=dK.find(t=>t.value===e);t!==void 0&&n(t.value)},children:dK.map(e=>(0,J.jsx)(ZR,{value:e.value,children:e.label},e.value))})]}),(0,J.jsx)(QR,{}),(0,J.jsx)(YR,{checked:t===`cb`,onCheckedChange:e=>r(e?`cb`:`default`),children:`Color-blind safe diff`})]})]})},pK=({current:e})=>(0,J.jsxs)(N_,{to:S_,"aria-current":e?`page`:void 0,className:X(ly({variant:`ghost`,size:`sm`}),`min-w-7 text-foreground hover:no-underline aria-[current=page]:bg-muted max-sm:px-0`),children:[(0,J.jsx)(u_,{"aria-hidden":`true`,className:`sm:hidden`}),(0,J.jsx)(`span`,{className:`max-sm:sr-only`,children:`Preferences`})]}),mK=()=>{let e=T_(k_());return(0,J.jsxs)(`header`,{className:`flex h-12 items-center justify-between gap-4 border-b bg-background px-4 max-sm:gap-2 sm:px-6`,children:[(0,J.jsx)(N_,{to:`/`,className:`text-heading font-semibold text-foreground hover:no-underline`,children:`megareviewer`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 max-sm:gap-1`,children:[(0,J.jsx)(uK,{}),(0,J.jsx)(pK,{current:e.page===`preferences`}),(0,J.jsx)(fK,{})]})]})},hK=()=>(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Page not found`}),(0,J.jsxs)(`p`,{className:`text-body`,children:[`There's nothing at this address. `,(0,J.jsx)(N_,{to:`/`,children:`Go to your pull requests`}),`.`]})]}),gK=({reason:e})=>(0,J.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col gap-3 px-4 py-12`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Open megareviewer from your terminal`}),e===`missing`?(0,J.jsxs)(`p`,{className:`text-body`,children:[`This page needs the link megareviewer printed when it started. It looks like`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`http://127.0.0.1:4823/?token=…`}),`. Copy it from your terminal and open it once; other tabs in this browser then work without it.`]}):(0,J.jsx)(`p`,{className:`text-body`,children:`This page's session has ended, usually because megareviewer was restarted. Open the new link printed in your terminal.`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Not running? Start it with`,` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`npx megareviewer`}),`.`]})]}),_K=({token:e,fetch:t,openEventStream:n})=>{let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(e.value),s=(0,q.useMemo)(()=>a===null?null:{client:hp({fetch:t,token:a,onUnauthorized:()=>{let t=e.reject(a);t===null?i(!0):o(t)}}),subscribe:(e,t)=>_p(e,a,t,n)},[t,n,e,a]);return r?(0,J.jsx)(gK,{reason:`ended`}):s===null?(0,J.jsx)(gK,{reason:`missing`}):(0,J.jsx)(vp.Provider,{value:s,children:(0,J.jsx)(vK,{},a)})},vK=()=>{let e=T_(k_());return(0,J.jsx)(lI,{children:(0,J.jsx)(Pp,{children:(0,J.jsxs)(FF,{children:[(0,J.jsx)(mK,{}),(0,J.jsx)(`main`,{className:X(`px-4 py-5 sm:px-6`,(e.page===`picker`||e.page===`preferences`)&&`min-h-[calc(100dvh-3rem)] bg-surface-subtle`),children:e.page===`picker`?(0,J.jsx)(WI,{}):e.page===`preferences`?(0,J.jsx)(LB,{}):e.page===`review`?(0,J.jsx)(uG,{analysisId:e.analysisId}):e.page===`open`?(0,J.jsx)(LF,{pullRequest:e.ref},E_(e.ref)):(0,J.jsx)(hK,{})}),(0,J.jsx)(BG,{})]})})})},yK=class extends q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}render(){let{error:e}=this.state;if(e===null)return this.props.children;let t=this.props.onReload??(()=>window.location.reload());return(0,J.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 px-4 py-12`,role:`alert`,children:[(0,J.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Something went wrong`}),(0,J.jsx)(`p`,{className:`text-body`,children:`megareviewer hit a bug while showing this page.`}),(0,J.jsx)(`pre`,{className:`w-full overflow-x-auto rounded-md border bg-muted p-3 font-mono text-code-compact whitespace-pre-wrap`,children:String(e)}),(0,J.jsx)($,{onClick:t,children:`Reload`})]})}},bK=`token`,xK=`megareviewer.token`,SK=e=>{let t=(()=>{try{return e.localStorage}catch{return null}})(),n=e=>{try{return t===null?null:e(t)}catch{return null}},r=new URL(e.location.href),i=r.searchParams.get(bK),a;return i!==null&&i!==``?(a=i,n(e=>e.setItem(xK,i))):a=n(e=>e.getItem(xK)),r.searchParams.has(bK)&&(r.searchParams.delete(bK),e.history.replaceState(e.history.state,``,`${r.pathname}${r.search}${r.hash}`)),{get value(){return a},reject(e){let t=n(e=>e.getItem(xK));return t===e&&n(e=>e.removeItem(xK)),a=t!==null&&t!==e?t:null,a}}},CK=document.getElementById(`root`);if(CK===null)throw Error(`index.html has no #root`);(0,xc.createRoot)(CK).render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(yK,{children:(0,J.jsx)(_K,{token:SK(window),fetch:window.fetch.bind(window)})})}));export{s as t};