megareviewer 0.2.17 → 0.2.18

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.
@@ -78,11 +78,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
78
78
  `.repeat(e),LA=e=>`class _ {\nvoid _() {\n${`{
79
79
  `.repeat(e-2)}`,RA=/^(?:@\w|(?:public|protected|private|abstract|static|native|transient|volatile)\b)/,zA=/^(?:[}\])]|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*(?:[-+*/%&|^]?=(?!=)|\+\+|--|\())/,BA=/^\*/,VA=(e,t)=>{if(t!==`java`)return``;let n=e.split(`
80
80
  `).filter(e=>e.trim()!==``),r=n[0];if(r===void 0)return``;let i=BA.test(r.trim()),a=n.find(e=>!/^(?:\*|\/\*|\/\/)/.test(e.trim())),o=i?`/*
81
- `:``;if(a===void 0)return o;let s=HA(a,n),c=a.trim();return(s===0?``:RA.test(c)||s===1&&!zA.test(c)?IA(s):LA(Math.max(s,2)))+o},HA=(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&&!BA.test(e.trim()));return Math.floor(n.length/(i?2:4))},UA=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}))},WA=e=>({added:e.lines.filter(e=>e.kind===`add`).length,deleted:e.lines.filter(e=>e.kind===`del`).length}),GA=(e,t)=>t<=1?`${e}`:`${e}–${e+t-1}`,KA=e=>e.newLines>0?`lines ${GA(e.newStart,e.newLines)}`:`deleted lines ${GA(e.oldStart,e.oldLines)}`,qA={"token-keyword":`keyword`,"token-string":`string`,"token-string-expression":`string`,"token-function":`function`,"token-comment":`comment`,"token-constant":`number`,"token-decorator":`decorator`,"token-attribute":`attribute`},JA=e=>{let t=/^var\(--shiki-([\w-]+)/.exec(e??``)?.[1];return t===void 0?null:qA[t]??null},YA=e=>{let t=[];for(let{content:n,color:r}of e){let e=JA(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},XA=(e,t,n)=>{let r=0,i=0;return UA(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})},ZA=e=>`var(--shiki-${e})`,QA=[{scope:[`entity.name.function.decorator`,`punctuation.definition.decorator`,`meta.function.decorator support.type`,`punctuation.decorator`,`meta.decorator entity.name.function`,`meta.decorator variable.other.readwrite`,`storage.type.annotation`,`punctuation.definition.annotation`,`entity.name.type.annotation`],color:ZA(`token-decorator`)},{scope:[`entity.other.attribute-name`,`variable.parameter.function-call`],color:ZA(`token-attribute`)},{scope:[`variable.other.object`,`variable.other.class`,`variable.other.constant`,`support.class`,`support.type`,`support.variable`],color:ZA(`foreground`)},{scope:[`support.type.primitive`],color:ZA(`token-keyword`)}],$A=[{scope:[`variable.language.java`,`variable.other.constant.java`],color:ZA(`token-constant`)},{scope:[`storage.type.primitive.java`,`storage.type.primitive.array.java`,`keyword.operator.instanceof.java`],color:ZA(`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:ZA(`foreground`)}],ej=1e3,tj=(0,J.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([DA(()=>import(`./core-bY0eVDTo.js`),[]),DA(()=>import(`./engine-javascript-D-6se_EF.js`),[])]),r=t({name:`hunk`,variablePrefix:`--shiki-`});return e({themes:[{...r,tokenColors:[...r.tokenColors??[],...[...QA,...$A].map(({scope:e,color:t})=>({scope:[...e],settings:{foreground:t}}))]}],langs:[],engine:n()})},a=(e,n)=>{let r=t.get(n)??(async()=>{let t=kA[n];return t!==void 0&&(await e.loadLanguage(...(await t()).default),!0)})();return t.set(n,r),r};return{async highlight(t,n){if(kA[n]===void 0)return null;e??=i();let o=await e;if(!await a(o,n))return null;let s=VA(t,n);return o.codeToTokensBase(t,{lang:n,theme:`hunk`,tokenizeMaxLineLength:ej,...s===``?{}:{grammarState:r(o,s,n)}}).map(e=>YA(e))}}})()),nj=new WeakMap,rj=(e,t,n)=>{let r=nj.get(e)??new Map;nj.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=UA(t.lines),s=PA(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=XA(t,e,n);return l.value=r,r}),value:null};return r.set(i,l),l},ij=`1200px 0px`,aj=null,oj=new Map,sj=(e,t)=>(aj??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(oj.get(t.target)?.(),oj.delete(t.target),aj?.unobserve(t.target))},{rootMargin:ij}),oj.set(e,t),aj.observe(e),()=>{oj.delete(e),aj?.unobserve(e)}),cj=e=>{let[t,n]=(0,J.useState)(()=>typeof IntersectionObserver>`u`);return(0,J.useEffect)(()=>{let r=e.current;if(!(t||r===null))return sj(r,()=>n(!0))},[e,t]),t},lj=(e,t,n=!0)=>{let r=(0,J.useContext)(tj),i=NA(t),a=i===null||!n?null:rj(r,e,i),[o,s]=(0,J.useState)();return(0,J.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)},uj=(e,t)=>{let n=(0,J.useContext)(tj),r=NA(t),[i,a]=(0,J.useState)(null);return(0,J.useEffect)(()=>{if(r===null||e===null)return;let t=!0;return n.highlight(e.join(`
81
+ `:``;if(a===void 0)return o;let s=HA(a,n),c=a.trim();return(s===0?``:RA.test(c)||s===1&&!zA.test(c)?IA(s):LA(Math.max(s,2)))+o},HA=(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&&!BA.test(e.trim()));return Math.floor(n.length/(i?2:4))},UA=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}))},WA=e=>({added:e.lines.filter(e=>e.kind===`add`).length,deleted:e.lines.filter(e=>e.kind===`del`).length}),GA=(e,t)=>t<=1?`${e}`:`${e}–${e+t-1}`,KA=e=>e.newLines>0?`lines ${GA(e.newStart,e.newLines)}`:`deleted lines ${GA(e.oldStart,e.oldLines)}`,qA={"token-keyword":`keyword`,"token-string":`string`,"token-string-expression":`string`,"token-function":`function`,"token-comment":`comment`,"token-constant":`number`,"token-decorator":`decorator`,"token-attribute":`attribute`},JA=e=>{let t=/^var\(--shiki-([\w-]+)/.exec(e??``)?.[1];return t===void 0?null:qA[t]??null},YA=e=>{let t=[];for(let{content:n,color:r}of e){let e=JA(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},XA=(e,t,n)=>{let r=0,i=0;return UA(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})},ZA=e=>`var(--shiki-${e})`,QA=[{scope:[`entity.name.function.decorator`,`punctuation.definition.decorator`,`meta.function.decorator support.type`,`punctuation.decorator`,`meta.decorator entity.name.function`,`meta.decorator variable.other.readwrite`,`storage.type.annotation`,`punctuation.definition.annotation`,`entity.name.type.annotation`],color:ZA(`token-decorator`)},{scope:[`entity.other.attribute-name`,`variable.parameter.function-call`],color:ZA(`token-attribute`)},{scope:[`variable.other.object`,`variable.other.class`,`variable.other.constant`,`support.class`,`support.type`,`support.variable`],color:ZA(`foreground`)},{scope:[`support.type.primitive`],color:ZA(`token-keyword`)}],$A=[{scope:[`variable.language.java`,`variable.other.constant.java`],color:ZA(`token-constant`)},{scope:[`storage.type.primitive.java`,`storage.type.primitive.array.java`,`keyword.operator.instanceof.java`],color:ZA(`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:ZA(`foreground`)}],ej=1e3,tj=(0,J.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([DA(()=>import(`./core-djNlzX8o.js`),[]),DA(()=>import(`./engine-javascript-D-6se_EF.js`),[])]),r=t({name:`hunk`,variablePrefix:`--shiki-`});return e({themes:[{...r,tokenColors:[...r.tokenColors??[],...[...QA,...$A].map(({scope:e,color:t})=>({scope:[...e],settings:{foreground:t}}))]}],langs:[],engine:n()})},a=(e,n)=>{let r=t.get(n)??(async()=>{let t=kA[n];return t!==void 0&&(await e.loadLanguage(...(await t()).default),!0)})();return t.set(n,r),r};return{async highlight(t,n){if(kA[n]===void 0)return null;e??=i();let o=await e;if(!await a(o,n))return null;let s=VA(t,n);return o.codeToTokensBase(t,{lang:n,theme:`hunk`,tokenizeMaxLineLength:ej,...s===``?{}:{grammarState:r(o,s,n)}}).map(e=>YA(e))}}})()),nj=new WeakMap,rj=(e,t,n)=>{let r=nj.get(e)??new Map;nj.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=UA(t.lines),s=PA(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=XA(t,e,n);return l.value=r,r}),value:null};return r.set(i,l),l},ij=`1200px 0px`,aj=null,oj=new Map,sj=(e,t)=>(aj??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(oj.get(t.target)?.(),oj.delete(t.target),aj?.unobserve(t.target))},{rootMargin:ij}),oj.set(e,t),aj.observe(e),()=>{oj.delete(e),aj?.unobserve(e)}),cj=e=>{let[t,n]=(0,J.useState)(()=>typeof IntersectionObserver>`u`);return(0,J.useEffect)(()=>{let r=e.current;if(!(t||r===null))return sj(r,()=>n(!0))},[e,t]),t},lj=(e,t,n=!0)=>{let r=(0,J.useContext)(tj),i=NA(t),a=i===null||!n?null:rj(r,e,i),[o,s]=(0,J.useState)();return(0,J.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)},uj=(e,t)=>{let n=(0,J.useContext)(tj),r=NA(t),[i,a]=(0,J.useState)(null);return(0,J.useEffect)(()=>{if(r===null||e===null)return;let t=!0;return n.highlight(e.join(`
82
82
  `),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},dj={keyword:`text-syntax-keyword`,string:`text-syntax-string`,function:`text-syntax-function`,comment:`text-syntax-comment`,number:`text-syntax-number`,decorator:`text-syntax-decorator`,attribute:`text-syntax-attribute`},fj=(e,t)=>{let n=(0,J.useContext)(tj),[r,i]=(0,J.useState)(null),a=`${t??``}\0${e}`;return(0,J.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},pj=({text:e,tokens:t})=>t!=null&&t.map(e=>e.text).join(``)===e?t.map((e,t)=>(0,Y.jsx)(`span`,{className:X(e.type!==null&&dj[e.type]),children:e.text},t)):e,mj=({kind:e,text:t,tokens:n})=>(0,Y.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,Y.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,Y.jsx)(`span`,{className:`sr-only`,children:e===`add`?`added line `:`removed line `}),(0,Y.jsx)(`span`,{className:`px-2`,children:(0,Y.jsx)(pj,{text:t,tokens:n})})]}),hj=({removed:e,added:t,language:n,title:r})=>{let i=fj((e??[]).join(`
83
83
  `),e===null?null:n),a=fj(t.join(`
84
84
  `),n);return(0,Y.jsxs)(`div`,{"data-slot":`suggestion-diff`,className:`overflow-x-auto rounded-md border font-code text-code-compact`,children:[r!==void 0&&(0,Y.jsx)(`p`,{className:`border-b px-2 py-1 font-sans text-caption font-medium text-primary`,children:r}),(e??[]).map((e,t)=>(0,Y.jsx)(mj,{kind:`del`,text:e,tokens:i?.[t]},`del:${t}`)),t.map((e,t)=>(0,Y.jsx)(mj,{kind:`add`,text:e,tokens:a?.[t]},`add:${t}`)),t.length===0&&(0,Y.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`,`.`]})]})},gj=J.createContext(void 0);function _j(e){let t=J.useContext(gj);if(!e&&t===void 0)throw Error(qv(27));return t}var vj=J.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=_j(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return _y(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Pb,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),yj=J.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=_j(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=$v({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Yb(rx,e.nativeEvent))}return _y(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),bj=J.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=_j(),c=FE(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),_y(`p`,e,{ref:t,props:[{id:c},o]})}),xj=J.createContext(void 0);function Sj(){let e=J.useContext(xj);if(e===void 0)throw Error(qv(26));return e}var Cj=`--nested-dialogs`,wj=`data-nested-dialog-open`,Tj={...Nb,...bb,nestedDialogOpen(e){return e?{[wj]:``}:null}},Ej=J.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=_j(),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`);Sj(),iw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?sw(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=_y(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...ow,hidden:!m,onKeyDown(e){Ck.has(e.key)&&e.stopPropagation()},style:{[Cj]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Tj});return(0,Y.jsx)(MC,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Dj=J.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,Y.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Oj=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=_j(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Y.jsx)(xj.Provider,{value:n,children:(0,Y.jsxs)(pC,{ref:t,...r,children:[a&&o===!0&&(0,Y.jsx)(Dj,{ref:i.context.internalBackdropRef,inert:cD(!s)}),e.children]})}):null}),kj={},Aj={},jj=``;function Mj(e,t){return sv(e)?e:t}function Nj(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Mj(t,n)).overflowY)}function Pj(e){if(typeof document>`u`)return!1;let t=Zv(e);return tv(t).innerWidth-t.documentElement.clientWidth>0}function Fj(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Zv(e),n=t.documentElement,r=t.body,i=Mj(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 Ij(e){let t=Zv(e),n=t.documentElement,r=t.body,i=Mj(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 Lj(e){let t=Zv(e),n=t.documentElement,r=t.body,i=tv(n),a=0,o=0,s=!1,c=Ex.create();if(Zy&&(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,kj={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},jj=n.style.scrollBehavior,Aj={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=Mj(n,r);s=Fj(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,kj),Object.assign(r.style,Aj),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=jj)}function d(){u(),c.request(l)}l();let f=bx(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var Rj=new class{lockCount=0;restore=null;timeoutLock=Ry.create();timeoutUnlock=Ry.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=Zv(e),n=t.documentElement,r=t.body,i=tv(n);if(Nj(i,n,r)){let t=new i.MutationObserver(()=>{Nj(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=Ky||!Pj(e);this.restore=a?Ij(e):Lj(e)}};function zj(e=!0,t=null){Q(()=>{if(e)return Rj.acquire(t)},[e,t])}function Bj({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]=J.useState(0),[d,f]=J.useState(0),p=l===0,m=zC(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=lb(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||sb(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return zj(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]),vw(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var Vj={...Hw,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},Hj=class extends Nw{constructor(e,t,n){let r=new bw,i=Uj(e,r,t,n);super(i,Wj(r),Vj)}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(fw(this.state,e,t.trigger)))}};function Uj(e,t,n,r=!1){return{...Iw(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 Wj(e){return{popupRef:J.createRef(),backdropRef:J.createRef(),internalBackdropRef:J.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Gj(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=_j(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=cw((e,t)=>new Hj({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`);yw(b,x),gw(b);let{forceUnmount:w}=_w(x,b);J.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Yb(mx))}),[w,b]);let T=x||S||u!=null;return(0,Y.jsxs)(gj.Provider,{value:b,children:[u&&(0,Y.jsx)(lw,{handle:u,store:b}),T&&(0,Y.jsx)(Bj,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var Kj=Ny(function(e){return Gj(`dialog`,e)}),qj=J.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=_j(),c=FE(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),_y(`h2`,e,{ref:t,props:[{id:c},o]})});function Jj(e){let t=J.useRef(``),n=J.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:J.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 Yj(e,t){let n=J.useRef(e),r=Z(t);Q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Xj(e,t){let{onClick:n,onPointerDown:r}=Jj(Z((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ky?`touch`:``))}));return J.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function Zj(e){let[t,n]=J.useState(null),r=Xj(e,n);return Yj(e,t=>{t&&!e&&n(null)}),J.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function Qj({...e}){return(0,Y.jsx)(Kj,{"data-slot":`dialog`,...e})}function $j({...e}){return(0,Y.jsx)(Oj,{"data-slot":`dialog-portal`,...e})}function eM({className:e,...t}){return(0,Y.jsx)(vj,{"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 tM({className:e,children:t,showCloseButton:n=!0,...r}){return(0,Y.jsxs)($j,{children:[(0,Y.jsx)(eM,{}),(0,Y.jsxs)(Ej,{"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,Y.jsxs)(yj,{"data-slot":`dialog-close`,render:(0,Y.jsx)($,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,Y.jsx)(I_,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function nM({className:e,...t}){return(0,Y.jsx)(`div`,{"data-slot":`dialog-header`,className:X(`flex flex-col gap-2`,e),...t})}function rM({className:e,...t}){return(0,Y.jsx)(qj,{"data-slot":`dialog-title`,className:X(`text-heading font-semibold`,e),...t})}function iM({className:e,...t}){return(0,Y.jsx)(bj,{"data-slot":`dialog-description`,className:X(`text-ui text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var aM=({src:e,alt:t,onClose:n})=>(0,Y.jsx)(Qj,{open:!0,onOpenChange:e=>{e||n()},children:(0,Y.jsxs)(tM,{"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,Y.jsx)(rM,{className:`sr-only`,children:t}),(0,Y.jsx)(`img`,{src:e,alt:t,className:`max-h-full max-w-full object-contain`})]})}),oM=e=>e===null?null:NA({path:`code.${e}`,language:e}),sM=({text:e,language:t})=>{let n=fj(e,oM(t)),r=e.split(`
85
- `);return(0,Y.jsx)(`pre`,{"data-slot":`thread-code`,className:`overflow-x-auto rounded-md border bg-surface-subtle px-2.5 py-1.5 font-code text-code-compact`,children:(0,Y.jsx)(`code`,{children:r.map((e,t)=>(0,Y.jsx)(`span`,{className:`block min-h-[1lh] whitespace-pre`,children:(0,Y.jsx)(pj,{text:e,tokens:n?.[t]})},t))})})},cM=({kind:e,alt:t,src:n,size:r})=>{let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1);if(i)return(0,Y.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,Y.jsx)(Bg,{"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,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.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,Y.jsx)(aM,{src:n,alt:l,onClose:()=>s(!1)})]}):(0,Y.jsx)(`video`,{"data-slot":`thread-media`,src:n,controls:!0,preload:`metadata`,onError:()=>a(!0),className:c})},lM=({span:e,mediaUrl:t})=>{switch(e.kind){case`text`:return(0,Y.jsx)(Y.Fragment,{children:e.text});case`code`:return(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-code text-code-compact`,children:e.text});case`strong`:return(0,Y.jsx)(`strong`,{className:`font-semibold`,children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`emphasis`:return(0,Y.jsx)(`em`,{children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`strike`:return(0,Y.jsx)(`del`,{children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`link`:return e.url===null?(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t}):(0,Y.jsx)(`a`,{href:e.url,title:e.url,target:`_blank`,rel:`noreferrer noopener nofollow`,className:`underline`,children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`image`:case`video`:{if(e.url!==null&&t)return(0,Y.jsx)(cM,{kind:e.kind,alt:e.text,src:t(e.url),size:e.size});let n=e.kind===`image`?`Image`:`Video`;return(0,Y.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,Y.jsx)(Bg,{"aria-hidden":`true`,className:`size-3`}),e.text===``?n:`${n}: ${e.text}`,(0,Y.jsx)(`span`,{className:`sr-only`,children:`, not loaded: it isn't in the host's own attachments`})]})}}},uM=({spans:e,mediaUrl:t})=>e.map((e,n)=>(0,Y.jsx)(lM,{span:e,mediaUrl:t},`${e.kind}:${n}`)),dM={1:`text-heading font-semibold`,2:`text-heading font-semibold`,3:`text-body font-semibold`},fM={left:`text-left`,center:`text-center`,right:`text-right`},pM=({blocks:e,...t})=>e.map((e,n)=>(0,Y.jsx)(mM,{block:e,...t},`${e.kind}:${n}`)),mM=({block:e,suggestion:t,mediaUrl:n})=>{switch(e.kind){case`suggestion`:return(0,Y.jsx)(`div`,{children:t(e.lines)});case`code`:return(0,Y.jsx)(sM,{text:e.text,language:e.language});case`paragraph`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:n})});case`heading`:return(0,Y.jsx)(`p`,{"data-slot":`thread-heading`,className:X(`whitespace-pre-wrap`,dM[e.level]??`font-semibold`),children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:n})});case`quote`:return(0,Y.jsx)(`blockquote`,{className:`flex flex-col gap-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,Y.jsx)(pM,{blocks:e.blocks,suggestion:t,mediaUrl:n})});case`list`:{let r=e.items.map((e,r)=>(0,Y.jsx)(`li`,{className:X(`pl-1`,e.checked!==null&&`list-none -ml-5 pl-0`),children:(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[e.checked!==null&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center`,children:e.checked?`☑`:`☐`}),e.checked!==null&&(0,Y.jsx)(`span`,{className:`sr-only`,children:e.checked?`Done: `:`Not done: `}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:(0,Y.jsx)(pM,{blocks:e.blocks,suggestion:t,mediaUrl:n})})]})},r));return e.ordered?(0,Y.jsx)(`ol`,{start:e.start,className:`flex list-decimal flex-col gap-1 pl-5`,children:r}):(0,Y.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5`,children:r})}case`table`:return(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`border-collapse text-ui`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsx)(`tr`,{children:e.head.map((t,r)=>(0,Y.jsx)(`th`,{className:X(`border bg-muted px-2 py-1 font-semibold`,fM[e.align[r]??`left`]),children:(0,Y.jsx)(uM,{spans:t,mediaUrl:n})},r))})}),(0,Y.jsx)(`tbody`,{children:e.rows.map((t,r)=>(0,Y.jsx)(`tr`,{children:t.map((t,r)=>(0,Y.jsx)(`td`,{className:X(`border px-2 py-1`,fM[e.align[r]??`left`]),children:(0,Y.jsx)(uM,{spans:t,mediaUrl:n})},r))},r))})]})});case`rule`:return(0,Y.jsx)(`hr`,{className:`border-border`})}},hM=({blocks:e,suggestion:t,mediaUrl:n})=>(0,Y.jsx)(`div`,{"data-slot":`thread-body`,className:`flex flex-col gap-2 text-body break-words`,children:(0,Y.jsx)(pM,{blocks:e,suggestion:t,mediaUrl:n})}),gM=`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,_M=`shadow-[inset_0_0_0_2px_var(--ring)]`,vM=({person:e})=>(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex size-6 shrink-0 items-center justify-center rounded-full text-caption font-medium`,mA(e.id)),children:fA(e.name)}),yM=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}`},bM=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},xM=({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,J.useState)(!e.resolved||u),[g,_]=(0,J.useState)(u);u!==g&&(_(u),u&&h(!0));let[v,y]=(0,J.useState)(l!==void 0),[b,x]=(0,J.useState)(0),[S,C]=(0,J.useState)(l?.text??``),[w,T]=(0,J.useState)(l?.status===`posting`),[E,D]=(0,J.useState)(l?.status===`failed`?l.error??``:null),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(null),M=(0,J.useRef)(null),N=(0,J.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,J.useEffect)(()=>{b>0&&M.current?.focus()},[b]),(0,J.useEffect)(()=>{s&&ee()},[s]);let z=()=>M.current?.closest(`[data-slot=review-thread]`)?.focus(),B=()=>{w||(z(),C(``),D(null),y(!1))},V=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)},te=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)},H=e=>(0,Y.jsx)(hj,{title:`Suggested change`,removed:F?i:null,added:e,language:r}),U=e=>(0,Y.jsx)(`time`,{dateTime:e.createdAt,title:yA(e.createdAt),className:`ml-auto shrink-0 pl-3 text-caption text-muted-foreground`,children:vA(e.createdAt,n)}),ne=e=>{let[n]=e;return n===void 0?null:(0,Y.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,Y.jsx)(vM,{person:n.author}),(0,Y.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:n.author.name}),t!==null&&n.author.id===t&&(0,Y.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`}),U(n)]}),e.length>1?(0,Y.jsx)(`span`,{"data-slot":`thread-run`,"aria-hidden":`true`,className:`flex justify-center pt-1.5 pb-1`,children:(0,Y.jsx)(`span`,{className:`w-px bg-thread-run`})}):(0,Y.jsx)(`span`,{"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:e.map((e,t)=>{let{blocks:n}=rf(e.body);return(0,Y.jsxs)(`div`,{"data-slot":`thread-comment`,className:`flex items-baseline`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(hM,{blocks:n,suggestion:H,...c===void 0?{}:{mediaUrl:c}})})}),t>0&&U(e)]},e.id)})})]})},[re]=e.comments,ie=e.line??e.originalLine,ae=e.resolvedBy?.name,oe=I||L;return(0,Y.jsx)(dA,{as:`article`,state:P,"data-slot":`review-thread`,id:d,"data-current":u||void 0,"aria-label":`Thread on ${yM(e)}${e.resolved?`, resolved`:``}`,tabIndex:-1,style:Ph({"--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&&_M,p),children:m?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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:[ie!==null&&(0,Y.jsxs)(Y.Fragment,{children:[e.startLine!==null&&e.line!==null?`Lines`:`Line`,` `,(0,Y.jsx)(xA,{children:bA(e.side,e.line===null?null:e.startLine,ie)}),(0,Y.jsx)(`span`,{children:`·`})]}),(0,Y.jsxs)(`span`,{children:[e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.outdated&&(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-review-approved`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,ae===void 0?``:` by ${ae}`]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),"aria-expanded":!0,children:`Hide`})]})]}),bM(e.comments).map((e,t)=>(0,Y.jsxs)(J.Fragment,{children:[t>0&&(0,Y.jsx)(`hr`,{"data-slot":`thread-divider`}),ne(e)]},e[0]?.id??t)),A!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ `,e.resolved?`Not reopened`:`Not resolved`,`: `,A]}),R?(0,Y.jsxs)(`div`,{"data-slot":`thread-reply`,className:`flex flex-col gap-1.5 border-t pt-3 pl-8.5`,children:[(0,Y.jsxs)(`label`,{htmlFor:N,className:`sr-only`,children:[`Reply to the thread on `,yM(e)]}),(0,Y.jsx)(Vk,{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 V(),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),B())},className:`min-h-14 bg-background`}),E!==null&&(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(lA,{hints:[{id:`submit`,action:`reply`},{id:`close`,action:`cancel`}]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`sm`,disabled:w,onClick:B,children:`Cancel`}),(0,Y.jsx)($,{size:`sm`,disabled:S.trim()===``||w,onClick:()=>void V(),children:w?`Sending…`:`Reply`})]})]})]}):oe&&(0,Y.jsxs)(`div`,{"data-slot":`thread-actions`,className:`flex items-center gap-2 pl-8.5`,children:[I&&(0,Y.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,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:O,onClick:()=>void te(),className:X(!I&&`ml-auto`),children:e.resolved?`Reopen`:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ng,{"aria-hidden":`true`}),`Resolve`]})})]})]}):(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,ae===void 0?``:` by ${ae}`]}),re!==void 0&&(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-caption text-muted-foreground`,children:[re.author.name,`: `,Vd(re.body)]}),(0,Y.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!0),"aria-expanded":!1,children:[`Show `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]})]})})},SM=/[\p{L}\p{N}_]+|\s+|[^\p{L}\p{N}_\s]/gu,CM=e=>e.match(SM)??[],wM=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=TM(e[r+n]?.text??``,e[i+n]?.text??``);a!==null&&(t.set(r+n,a.old),t.set(i+n,a.new))}}return t},TM=(e,t)=>{if(e.length>500||t.length>500)return null;let n=CM(e),r=CM(t),{inOld:i,inNew:a}=DM(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:EM(n,i),new:EM(r,a)}},EM=(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},DM=(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}},OM=(e,t=null)=>{let n=wM(e.lines);return UA(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`]:[]]}))},kM=e=>e.kind===`del`?e.oldLine===null?null:{side:`old`,line:e.oldLine}:e.newLine===null?null:{side:`new`,line:e.newLine},AM=`sticky left-0 w-[100cqw]`,jM=`pr-3 pl-29`,MM=({inset:e,children:t})=>(0,Y.jsx)(`div`,{role:`row`,"data-slot":`line-row`,className:X(e&&X(jM,`py-2`),`font-sans`,AM),children:(0,Y.jsx)(`div`,{role:`cell`,children:t})}),NM=(e,t)=>e.side===t.side&&e.line===t.line,PM=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}`,FM=(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},IM=[],LM=(0,J.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,draftNote:g,afterHeader:_,threadsAt:v,rangeNote:y,inFile:b=!1,marks:x,pointLines:S,pointsAt:C,pointsAtEnd:w,flagged:T}){let E=e??t.id,D=(0,J.useRef)(null),[O,k]=(0,J.useState)(!1),A=lj(t,n,cj(D)),j=(0,J.useMemo)(()=>OM(t,A),[t,A]),M=c===void 0||O||j.length<=c?j:j.slice(0,c);(0,J.useEffect)(()=>{let e=D.current;o&&e!==null&&!e.contains(document.activeElement)&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[o]);let N=WA(t),P=!b||i.length>0,F=f!==void 0&&m!==void 0,I=(e,t)=>{let n=d;if(n!==null&&n.side===e.side&&n.line===e.line)f?.(E,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?.(E,{side:e.side,line:r,startLine:t})}else f?.(E,e)};return(0,Y.jsxs)(`section`,{ref:D,"data-slot":`hunk-card`,"data-risk":r?.riskClass,"data-highlighted":a||void 0,className:X(`relative scroll-mt-24 bg-card -outline-offset-2`,!b&&`overflow-hidden rounded-lg border`,a&&`bg-primary/5 shadow-[inset_0_0_0_2px_var(--ring)]`),"aria-label":`${n.path}, ${KA(t)}`,tabIndex:0,onFocus:()=>s?.(E),children:[P&&(0,Y.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`,b&&`sticky left-0 w-[100cqw]`),children:[!b&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(FO,{file:n,status:n.status}),(0,Y.jsx)(IO,{status:n.status}),t.sectionHeading!==null&&(0,Y.jsx)(`code`,{className:`font-mono text-code-compact text-diff-hunk-fg`,children:t.sectionHeading}),(0,Y.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,N.added]}),` `,(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,N.deleted]})]})]}),i.map(e=>(0,Y.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),e.detail]},e.kind)),!b&&r!==null&&(0,Y.jsxs)(`span`,{className:`ml-auto`,title:r.reason===``?void 0:r.reason,children:[(0,Y.jsx)(HO,{status:OD[r.riskClass]}),r.reason!==``&&(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`: `,r.reason]})]})]}),(l.length>0||_!=null)&&(0,Y.jsxs)(`div`,{className:X(b&&`sticky left-0 w-[100cqw]`),children:[l.map(e=>(0,Y.jsx)(RO,{callers:e,named:l.length>1},e.symbol)),_]}),(0,Y.jsx)(`div`,{role:`table`,"aria-label":`Lines`,className:X(`[content-visibility:auto]`,!b&&`overflow-x-auto`),style:{containIntrinsicSize:`auto ${M.length*20}px`},children:(0,Y.jsx)(`div`,{className:`w-max min-w-full`,children:M.map(e=>{let r=kM({kind:e.kind,oldLine:e.oldNo,newLine:e.newNo}),i=r===null?void 0:u.find(e=>NM(e,r)),a=r!==null&&d!==null&&NM(d,r),o=a?d:i,s=r===null?null:v?.(r)??null,c=r===null?null:C?.(r)??null,l=r===null?null:w?.(r)??null,_=r===null?null:`${r.side}:${r.line}`,D=_===null?void 0:S?.get(_);return(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(SD,{line:e,cellRole:`cell`,pointKind:D?.kind??null,flagged:_!==null&&T?.has(_)===!0,...l===null?{}:{end:l},...D?.landing===void 0?{}:{pointLanding:D.landing},marks:(e.kind===`del`||e.newNo===null?void 0:x?.get(e.newNo))??IM,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||!F?void 0:{side:r.side,label:PM(r),onClick:e=>I(r,e.shiftKey)},...r===null||!F?{}:{onRowClick:e=>{window.getSelection()?.isCollapsed!==!1&&(e.target instanceof Element&&e.target.closest(`button`)||I(r,e.shiftKey))}}}),c,r!==null&&o!=null&&(i!==void 0||a&&m!==void 0)&&(0,Y.jsx)(RM,{place:o,comment:i,editing:a&&m!==void 0,shown:(e,n)=>FM(t,e,n),language:NA(n),rangeNote:y,fileName:n.path.split(`/`).at(-1)??n.path,onChange:m===void 0?void 0:e=>m(E,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e}),onEdit:()=>f?.(E,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine}}),onDone:()=>f?.(E,null),onCancel:()=>p?.(E,o),...h===void 0?{}:{onPostNow:e=>h(E,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e})},pinned:b,...g===void 0||i===void 0||m===void 0?{}:{note:g(i,e=>m(E,{...i,body:e}))}}),s!==null&&(0,Y.jsx)(`div`,{role:`row`,"data-slot":`line-threads`,className:X(jM,`py-2 font-sans`,b&&`sticky left-0 w-[100cqw]`),children:(0,Y.jsx)(`div`,{role:`cell`,className:`flex max-w-3xl flex-col gap-2`,children:s})})]},e.key)})})}),M.length<j.length&&(0,Y.jsx)(`div`,{className:X(`border-t p-2`,b&&`sticky left-0 w-[100cqw]`),children:(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>k(!0),children:[`Show all `,j.length,` lines`]})})]})}),RM=({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,note:p})=>{let m=(0,J.useRef)(null),h=(0,J.useRef)(null),[g,_]=(0,J.useState)(`write`),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(null);(0,J.useEffect)(()=>{n?h.current?.focus():(_(`write`),x(null))},[n]);let S=PM(e),C=t?.body??``,w=t?.suggestion,T={body:C,...w===void 0?{}:{suggestion:w}},E=(0,J.useRef)(null);n?E.current===null&&(E.current=T):E.current=null;let D=e.side===`new`?r(e.startLine??e.line,e.line):null,O=e.startLine===void 0?null:`Lines ${e.startLine}–${e.line}`,k=()=>m.current?.closest(`[data-slot=hunk-card]`)?.focus({preventScroll:!0}),A=()=>s?.({body:``}),j=()=>{k(),C.trim()===``&&w===void 0&&s?.({body:``}),l()},M=async()=>{if(d===void 0||v||C.trim()===``)return;y(!0),x(null);let e=await d(T);y(!1),e===null?(k(),s?.({body:``}),l()):x(e)},N=()=>{k();let e=E.current;s?.(e===null||e.body.trim()===``&&e.suggestion===void 0?{body:``}:e),u?.(),l()},P=e=>(0,Y.jsx)(hj,{title:`Suggested change`,removed:D,added:e,language:i});return(0,Y.jsx)(`div`,{ref:m,role:`row`,"data-slot":`line-comment`,"data-editing":n||void 0,className:X(jM,`py-2 font-sans`,f&&`sticky left-0 w-[100cqw]`),children:(0,Y.jsx)(dA,{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(),j()}else e.key===`Escape`&&(e.stopPropagation(),N())}:void 0,children:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,children:[`Commenting on `,(0,Y.jsx)(xA,{children:o}),e.startLine===void 0?`line`:`lines`,` `,(0,Y.jsx)(xA,{children:bA(e.side,e.startLine??null,e.line)}),a!==void 0&&e.startLine!==void 0&&(0,Y.jsx)(`span`,{children:a})]}),(0,Y.jsxs)(Ik,{value:g,onValueChange:e=>_(e===`preview`?`preview`:`write`),children:[(0,Y.jsxs)(Rk,{children:[(0,Y.jsx)(zk,{value:`write`,children:`Write`}),(0,Y.jsx)(zk,{value:`preview`,children:`Preview`})]}),(0,Y.jsx)(Bk,{value:`write`,children:(0,Y.jsx)(Vk,{ref:h,rows:2,"aria-label":S,placeholder:`Leave a comment`,value:C,onChange:e=>s?.({...T,body:e.target.value}),onSubmitShortcut:j,className:`min-h-14 bg-background`})}),(0,Y.jsx)(Bk,{value:`preview`,"data-slot":`comment-preview`,className:`min-h-14 rounded-md border px-2.5 py-2`,children:C.trim()===``?(0,Y.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`Nothing to preview`}):(0,Y.jsx)(hM,{blocks:rf(C).blocks,suggestion:P})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(lA,{hints:[{id:`submit`,action:`add to review`},{id:`close`,action:`cancel`}]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`sm`,disabled:v,onClick:N,children:`Cancel`}),d!==void 0&&(0,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:v||C.trim()===``,onClick:()=>void M(),children:v?`Posting…`:`Comment now`}),(0,Y.jsx)($,{size:`sm`,disabled:v,onClick:j,children:`Add to review`})]})]}),b!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ Not posted: `,b,` Your comment is still here.`]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[S,`: `]}),(0,Y.jsx)(`span`,{className:X(gM,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:s===void 0?`Posted with your review`:`Draft · posts with your review`}),O!==null&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:O})]}),C.trim()!==``&&(0,Y.jsx)(hM,{blocks:rf(C).blocks,suggestion:P}),w!==void 0&&P(w),s!==void 0&&p,s!==void 0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Edit`}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:A,children:`Discard`})]})]})})})},zM=()=>mD(),BM=({handle:e,payload:t,id:n,render:r=(0,Y.jsx)(`span`,{}),children:i})=>(0,Y.jsx)(pD,{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}),VM=({handle:e,onGoTo:t})=>(0,Y.jsx)(fD,{handle:e,children:({payload:n})=>n===void 0?null:(0,Y.jsx)(hD,{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,Y.jsx)(HM,{payload:n,onGoTo:n=>{e.close(),t(n)}})})}),HM=({payload:e,onGoTo:t})=>{let n=(0,J.useRef)(null),r=e.targets[0],i=r===void 0?null:`${r.hunk.id}:${WM(r.hunk,e.symbol)}`;return(0,J.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,Y.jsx)(`div`,{ref:n,"data-slot":`peek-scroller`,className:`@container relative min-h-0 overflow-auto`,children:(0,Y.jsx)(`div`,{className:`w-max min-w-full`,children:e.targets.map((n,r)=>(0,Y.jsx)(UM,{target:n,symbol:e.symbol,onGoTo:t,divided:r>0,last:r===e.targets.length-1},n.id))})})},UM=({target:e,symbol:t,onGoTo:n,divided:r,last:i})=>{let{hunk:a,file:o}=e,s=lj(a,o,!0),c=(0,J.useMemo)(()=>OM(a,s),[a,s]),l=WA(a),u=KA(a);return(0,Y.jsxs)(`section`,{"aria-label":`${o.path}, ${u}`,className:r?`border-t`:void 0,children:[(0,Y.jsxs)(`header`,{className:X(AM,`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,Y.jsx)(FO,{file:o,status:o.status}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u}),(0,Y.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,l.added]}),` `,(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,l.deleted]})]}),(0,Y.jsx)($,{variant:`link`,size:`xs`,className:`ml-auto px-0`,onClick:()=>n(e.id),children:`Go to file`})]}),(0,Y.jsx)(`div`,{role:`table`,"aria-label":`Lines of ${t}`,className:`w-max min-w-full`,children:c.map(e=>(0,Y.jsx)(SD,{line:e,layout:`split-new`,cellRole:`cell`,density:`compact`},e.key))}),i&&(0,Y.jsx)(TD,{kind:c.at(-1)?.kind??`context`,className:`h-3`})]})},WM=(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},GM=J.createContext(void 0);function KM(){return J.useContext(GM)}function qM(e){let{render:t,className:n,style:r,state:i=py,props:a=fy,refs:o=fy,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=ck({metadata:s});return _y(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var JM=J.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=FE(u||void 0),h=KM(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=UO({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=$v({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=Yb(Zb,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=_y(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=J.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,Y.jsx)(qM,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),YM=J.createContext(void 0);function XM(e){let t=J.useContext(YM);if(t===void 0&&!e)throw Error(qv(69));return t}var ZM=Dy(`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 QM({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Y.jsx)(JM,{"data-slot":`toggle`,className:X(ZM({variant:t,size:n,className:e})),...r})}J.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});var $M=(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:eN(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}=WA(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]},eN=(e,t)=>e.kind===`rename`&&t.oldPath!==null?`${t.oldPath} → ${t.path} — renamed, content unchanged`:`${t.path} — ${e.detail}`,tN=`flex min-h-8 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-muted-foreground`,nN=({open:e,children:t,...n})=>(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`mechanical-toggle`,"aria-expanded":e,className:X(tN,`hover:bg-accent hover:text-accent-foreground`),...n,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 transition-transform duration-(--duration-fast) ease-standard`,!e&&`-rotate-90`),children:`▾`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:t})]}),rN=(0,J.memo)(function({hunk:e,file:t,risk:n,proofs:r,focused:i=!1,onFocus:a}){let o=(0,J.useRef)(null),[s,c]=(0,J.useState)(!1),{added:l,deleted:u}=WA(e);return(0,J.useEffect)(()=>{let e=o.current;i&&e!==null&&e!==document.activeElement&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[i]),(0,Y.jsxs)(`div`,{"data-slot":`mechanical-hunk`,className:`bg-surface-subtle`,children:[(0,Y.jsxs)(nN,{ref:o,open:s,onClick:()=>c(e=>!e),onFocus:()=>a?.(e.id),children:[t.path,`, `,KA(e),` — `,r.map(e=>e.detail).join(`; `),` (+`,l,` −`,u,`)`]}),s&&(0,Y.jsx)(LM,{hunk:e,file:t,risk:n,proofs:r,lineLimit:500})]})}),iN=({files:e,proofs:t,risk:n})=>{let r=(0,J.useId)(),i=(0,J.useMemo)(()=>$M(e,t),[e,t]),[a,o]=(0,J.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,Y.jsxs)(`section`,{"aria-labelledby":r,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`h2`,{id:r,className:`flex items-center gap-2 text-heading font-semibold`,children:[`Mechanical changes`,` `,(0,Y.jsx)(`span`,{className:`tabular rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground`,children:i.length})]}),s.length>0&&(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>o(new Set(c?[]:s)),children:c?`Collapse all`:`Expand all`})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>{let t=a.has(e.key);return(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[e.hunk===null||e.file===null?(0,Y.jsxs)(`span`,{className:tN,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0`}),e.summary]}):(0,Y.jsx)(nN,{open:t,onClick:()=>l(e.key),children:e.summary}),t&&e.hunk!==null&&e.file!==null&&(0,Y.jsx)(LM,{hunk:e.hunk,file:e.file,risk:n.find(t=>t.hunkId===e.hunk?.id)??null,proofs:e.proofs,lineLimit:500})]},e.key)})})]})},aN={added:`added`,deleted:`deleted`,modified:`changed`,renamed:`changed`},oN=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 ${aN[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}`}]:[]]}),sN=({files:e})=>{let t=(0,J.useId)(),n=oN(e);return n.length===0?null:(0,Y.jsxs)(`section`,{"aria-labelledby":t,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,Y.jsx)(`h2`,{id:t,className:`text-heading font-semibold`,children:`Changes without lines to show`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(({key:e,file:t,text:n})=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(FO,{file:t,status:t.status}),(0,Y.jsx)(IO,{status:t.status}),(0,Y.jsx)(`span`,{children:n})]},e))})]})},cN=({hunkId:e,lines:t})=>t.length===0?null:(0,Y.jsx)(`div`,{role:`table`,"aria-label":`Unchanged lines`,children:(0,Y.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,Y.jsx)(SD,{line:a,cellRole:`cell`},n)})})}),lN=J.createContext(void 0);function uN(e){let t=J.useContext(lN);if(t===void 0&&!e)throw Error(qv(47));return t}var dN={...Hw,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Hw.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Hw.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Hw.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},fN=class extends Nw{constructor(e,t,n){let r=new bw;super(pN(e,r,t,n),mN(r),dN)}setOpen=(e,t)=>{let n=t.reason===$b,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=pw(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=fw(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}),cC.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function pN(e,t,n,r=!1){let i={...Iw(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 mN(e){return{popupRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:J.createRef(),beforeTriggerFocusGuardRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),stickIfOpenTimeout:new Ry,stickIfOpen:!0,triggerElements:e}}var hN=Ny(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=_N(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),yw(u,d),gw(u);let{forceUnmount:m}=_w(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),J.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),J.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Yb(mx))}),[m,u]);let h=d||f||s!=null;return(0,Y.jsxs)(lN.Provider,{value:u,children:[s&&(0,Y.jsx)(lw,{handle:s,store:u}),h&&(0,Y.jsx)(vN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function gN(e){return uN(!0)?(0,Y.jsx)(hN,{props:e}):(0,Y.jsx)(SC,{children:(0,Y.jsx)(hN,{props:e})})}function _N(e,t){let n=cw((e,n)=>new fN(t,e,n));return J.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function vN({store:e,modal:t}){let n=zC(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return vw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}function yN(e,t){function n(n,r,i){let a=n.currentTarget;cC.flushSync(()=>{e.setOpen(!1,Yb(ix,n.nativeEvent,a))}),MS(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&&NS(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var bN=Py(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=uN(!0),h=Uw(s)??m;if(!h)throw Error(qv(74));let g=FE(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=J.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=hw(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=eT(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:gT(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=NC(v,{stickIfOpen:Z(()=>h.context.stickIfOpen)}),k=Xj(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=$v({disabled:a,native:o}),N={open(e){return w?Mb.open(e):jb.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=yN(h,x),I=_y(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[iC]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,Y.jsx)(J.Fragment,{children:I},g);return E?(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(jx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,Y.jsx)(jx,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),xN=J.createContext(void 0);function SN(){let e=J.useContext(xN);if(e===void 0)throw Error(qv(45));return e}var CN=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return uN().useState(`mounted`)||n?(0,Y.jsx)(xN.Provider,{value:n,children:(0,Y.jsx)(pC,{ref:t,...r})}):null}),wN=J.createContext(void 0);function TN(){let e=J.useContext(wN);if(!e)throw Error(qv(46));return e}function EN(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=J.useRef(null),o=J.useRef(null),s=rw(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 DN=20;function ON(e,t,n,r){let[i,a]=J.useState(!1);Q(()=>{if(!e||!t||n==null){a(!1);return}let r=Zv(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-DN)},[e,t,n]),zj(e&&(!t||i),r)}var kN=J.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=oC,..._}=e,v=uN(),y=SN(),b=bC(),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=tD({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`)});EN({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;ON(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=aD(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,Y.jsxs)(wN.Provider,{value:j,children:[S&&M&&(0,Y.jsx)(Dj,{inert:cD(!C),cutout:T}),(0,Y.jsx)(xC,{id:b,children:P})]})}),AN=J.createContext(void 0);function jN(){let[e,t]=J.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:J.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var MN=J.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=uN(),l=TN(),u=XM(!0)!=null,{context:d,hasClosePart:f}=jN(),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`);iw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Qw(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?sw(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=_y(`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`,...ow,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Ck.has(e.key)&&e.stopPropagation()}},iD(g),s],stateAttributesMapping:Pb});return(0,Y.jsx)(MC,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:av(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Y.jsx)(AN.Provider,{value:d,children:M})})}),NN=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=uN(),s=FE(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),_y(`h2`,e,{ref:t,props:[{id:s},a]})});function PN({...e}){return(0,Y.jsx)(gN,{"data-slot":`popover`,...e})}function FN({...e}){return(0,Y.jsx)(bN,{"data-slot":`popover-trigger`,...e})}function IN({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,Y.jsx)(CN,{children:(0,Y.jsx)(kN,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,Y.jsx)(MN,{"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 LN({className:e,...t}){return(0,Y.jsx)(NN,{"data-slot":`popover-title`,className:X(`font-medium`,e),...t})}var RN={open:Ag,draft:Pg,merged:Og,closed:Mg},zN=({state:e})=>{let{label:t,className:n}=AD[e],r=RN[e];return(0,Y.jsxs)(VO,{"data-slot":`pr-state`,variant:`outline`,className:n,children:[(0,Y.jsx)(r,{"aria-hidden":`true`}),t]})},BN=({status:e})=>e===null?null:(0,Y.jsx)(`span`,{"data-slot":`review-status`,children:(0,Y.jsx)(HO,{status:jD[e]})}),VN=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`}},HN=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`}},UN=`h-6 gap-1.5 px-1.5 font-normal text-muted-foreground`,WN=({check:e})=>{let t=MD[e.state];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 text-center`,t.tone),children:t.glyph}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),(0,Y.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:t.label}),e.url!==null&&(0,Y.jsx)(`a`,{className:`shrink-0 text-caption`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`Details of ${e.name}`,children:`Details`})]})},GN=({checks:e,unreadable:t,head:n})=>{let r=e===null?null:wf(e),i=r===null||r.state===null?null:HN(r),a=KN(i);if(e===null)return(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:UN,"data-slot":`ci-summary`,children:`CI not readable`})}),(0,Y.jsxs)(IN,{align:`end`,children:[(0,Y.jsx)(LN,{children:`CI not readable`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:t})]})]});if(r===null||r.state===null)return null;let o=MD[r.state];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsxs)($,{variant:`ghost`,size:`xs`,className:UN,"data-slot":`ci-summary`,"data-state":r.state,"aria-label":`${i}, show checks`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:o.tone,children:o.glyph}),(0,Y.jsx)(`span`,{className:`tabular`,children:VN(r)})]})}),(0,Y.jsxs)(IN,{align:`end`,className:`w-96`,children:[(0,Y.jsxs)(LN,{children:[`Checks on `,(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:n.slice(0,7)})]}),(0,Y.jsx)(`ul`,{className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,"aria-label":`Checks`,children:Cf(e).map(e=>(0,Y.jsx)(WN,{check:e},`${e.name}:${e.url??``}`))})]})]}),(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:a})]})},KN=e=>{let t=(0,J.useRef)(void 0),[n,r]=(0,J.useState)(``);return(0,J.useEffect)(()=>{t.current===void 0?t.current=e:e!==null&&e!==t.current&&(t.current=e,r(e))},[e]),n},qN={"changes-requested":I_,approved:ng,commented:n_},JN=3,YN=({reviewer:e})=>{let t=e.verdict===null?null:qN[e.verdict];return(0,Y.jsxs)(`span`,{className:X(`relative flex size-6 shrink-0 items-center justify-center rounded-full text-caption font-medium ring-2 ring-background`,mA(e.id)),children:[fA(e.name),t!==null&&e.verdict!==null&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 flex size-3 items-center justify-center rounded-full bg-background`,children:(0,Y.jsx)(t,{className:X(`size-2.5`,ND[e.verdict].tone),strokeWidth:3.5})})]})},XN=e=>{let t=new Map;for(let n of e){let e=ND[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(`, `)}`},ZN=({reviewers:e})=>{if(e.length===0)return null;let t=xf(e),n=t.length>JN?t.slice(0,2):t,r=t.length-n.length;return(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:`h-7 px-1`,"data-slot":`reviewers`,"aria-label":`${XN(t)}, show reviewers`,children:(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`flex items-center -space-x-1`,children:[n.map(e=>(0,Y.jsx)(YN,{reviewer:e},e.id)),r>0&&(0,Y.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,Y.jsxs)(IN,{align:`end`,children:[(0,Y.jsx)(LN,{children:`Reviewers`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Reviewers`,children:t.map(e=>{let t=ND[e.verdict??`waiting`];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:(0,Y.jsx)(YN,{reviewer:e})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,e.team&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` (team)`})]}),(0,Y.jsx)(`span`,{className:X(`shrink-0 text-caption`,t.tone),children:t.label})]},e.id)})})]})]})};function QN(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 $N=e=>{switch(e){case`success`:return nP;case`info`:return iP;case`warning`:return rP;case`error`:return aP;default:return null}},eP=Array(12).fill(0),tP=({visible:e,className:t})=>J.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},J.createElement(`div`,{className:`sonner-spinner`},eP.map((e,t)=>J.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),nP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),rP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),iP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),aP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),oP=J.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`},J.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),J.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),sP=()=>{let[e,t]=J.useState(document.hidden);return J.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},cP=1,lP=100,uP=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:cP++,dP=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-lP;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=uP(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],J.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(pP(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`&&!J.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`&&!J.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`&&!J.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`&&!J.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=uP(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}},fP=(e,t)=>dP.message(e,t),pP=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`;Object.assign(fP,{success:dP.success,info:dP.info,warning:dP.warning,error:dP.error,custom:dP.custom,message:dP.message,promise:dP.promise,dismiss:dP.dismiss,loading:dP.loading},{getHistory:()=>dP.toasts,getToasts:()=>dP.getActiveToasts()}),QN(`[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 mP(e){return e.label!==void 0}var hP=3,gP=`24px`,_P=`16px`,vP=4e3,yP=356,bP=14,xP=45,SP=200;function CP(...e){return e.filter(Boolean).join(` `)}function wP(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var TP=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]=J.useState(null),[O,k]=J.useState(null),[A,j]=J.useState(!1),[M,N]=J.useState(!1),[P,F]=J.useState(!1),[I,L]=J.useState(!1),[R,ee]=J.useState(!1),[z,B]=J.useState(0),[V,te]=J.useState(0),H=J.useRef(n.duration||y||vP),U=J.useRef(null),ne=J.useRef(null),re=c===0,ie=c+1<=o,ae=n.type,oe=ae??`default`,W=n.dismissible!==!1,se=n.className||``,ce=n.descriptionClassName||``,le=J.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ue=J.useMemo(()=>n.closeButton??p,[n.closeButton,p]),de=J.useMemo(()=>n.duration||y||vP,[n.duration,y]),fe=J.useRef(0),pe=J.useRef(0),me=J.useRef(0),he=J.useRef(null),[ge,_e]=b.split(`-`),ve=J.useMemo(()=>s.reduce((e,t,n)=>n>=le?e:e+t.height,0),[s,le]),ye=sP(),be=J.useMemo(()=>e.swipeDirections??wP(b),[e.swipeDirections,b]),xe=n.invert||t,Se=ae===`loading`;pe.current=J.useMemo(()=>le*x+ve,[le,ve]),J.useEffect(()=>{H.current=de},[de]),J.useEffect(()=>{j(!0)},[]),J.useEffect(()=>{let e=ne.current;if(e){let t=e.getBoundingClientRect().height;return te(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),J.useLayoutEffect(()=>{if(!A)return;let e=ne.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,te(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 Ce=J.useCallback(()=>{N(!0),B(pe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},SP)},[n,d,a,pe]);J.useEffect(()=>{if(n.promise&&ae===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||ye?(()=>{if(me.current<fe.current){let e=new Date().getTime()-fe.current;H.current-=e}me.current=new Date().getTime()})():H.current!==1/0&&(fe.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Ce()},H.current)),()=>clearTimeout(e)},[u,i,n,ae,ye,Ce]),J.useEffect(()=>{n.delete&&(Ce(),n.onDismiss==null||n.onDismiss.call(n,n))},[Ce,n.delete]);function we(){return w?.loading?J.createElement(`div`,{className:CP(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ae===`loading`},w.loading):J.createElement(tP,{className:CP(C?.loader,n?.classNames?.loader),visible:ae===`loading`})}let Te=n.icon||w?.[ae]||$N(ae);return J.createElement(`li`,{tabIndex:0,ref:ne,className:CP(_,se,C?.toast,n?.classNames?.toast,C?.[oe],n?.classNames?.[oe]),"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":ie,"data-y-position":ge,"data-x-position":_e,"data-index":c,"data-front":re,"data-swiping":P,"data-dismissible":W,"data-type":ae,"data-invert":xe,"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:pe.current}px`,"--initial-height":S?`auto`:`${V}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),he.current=null},onPointerDown:e=>{e.button!==2&&!Se&&W&&(U.current=new Date,B(pe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),he.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{if(I||!W)return;he.current=null;let e=Number(ne.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ne.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-U.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if((E===`x`?be.includes(e>0?`right`:`left`):be.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=xP||a>.11))B(pe.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Ce(),L(!0);else{var o,s;(o=ne.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ne.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),ee(!1),F(!1),D(null)}},onPointerMove:e=>{var t,n;if(!he.current||!W||window.getSelection()?.toString().length>0)return;let r=e.clientY-he.current.y,i=e.clientX-he.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(be.includes(`top`)||be.includes(`bottom`)){if(be.includes(`top`)&&r<0||be.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`&&(be.includes(`left`)||be.includes(`right`))){if(be.includes(`left`)&&i<0||be.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=ne.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=ne.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},ue&&!n.jsx&&ae!==`loading`?J.createElement(`button`,{"aria-label":T,"data-disabled":Se,"data-close-button":!0,onClick:Se||!W?()=>{}:()=>{Ce(),n.onDismiss==null||n.onDismiss.call(n,n)},className:CP(C?.closeButton,n?.classNames?.closeButton)},w?.close??oP):null,(ae||n.icon||n.promise)&&n.icon!==null&&(w?.[ae]!==null||n.icon)?J.createElement(`div`,{"data-icon":``,className:CP(C?.icon,n?.classNames?.icon)},ae===`loading`?n.icon||we():n.promise?we():null,ae===`loading`?null:Te):null,J.createElement(`div`,{"data-content":``,className:CP(C?.content,n?.classNames?.content)},J.createElement(`div`,{"data-title":``,className:CP(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?J.createElement(`div`,{"data-description":``,className:CP(v,ce,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),J.isValidElement(n.cancel)?n.cancel:n.cancel&&mP(n.cancel)?J.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{mP(n.cancel)&&W&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Ce())},className:CP(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,J.isValidElement(n.action)?n.action:n.action&&mP(n.action)?J.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{mP(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Ce())},className:CP(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function EP(){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 DP(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?_P:gP;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 OP=J.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=hP,toastOptions:g,dir:_=EP(),gap:v=bP,icons:y,customAriaLabel:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=J.useState([]),w=J.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=J.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=J.useState([]),[O,k]=J.useState(!1),[A,j]=J.useState(!1),[M,N]=J.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=J.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=J.useRef(null),L=J.useRef(!1),R=J.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||dP.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return J.useEffect(()=>dP.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{cC.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)]})})})}),[]),J.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]),J.useEffect(()=>{S.length<=1&&k(!1)},[S]),J.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]),J.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),J.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?J.createElement(`ol`,{key:t,dir:_===`auto`?EP():_,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":`${yP}px`,"--gap":`${v}px`,...m,...DP(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)=>J.createElement(TP,{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 kP({className:e,...t}){return(0,Y.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 AP=`data-valid`,jP=`data-invalid`,MP={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},NP={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},PP={valid(e){return e===null?null:e?{[AP]:``}:{[jP]:``}}},FP=`data-checked`,IP=`data-unchecked`,LP={checked(e){return e?{[FP]:``}:{[IP]:``}},...bb,...PP},RP={invalid:void 0,name:void 0,validityData:{state:MP,errors:[],error:``,value:``,initialValue:null},setValidityData:dy,disabled:void 0,setTouched:dy,setDirty:dy,setFilled:dy,setFocused:dy,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:NP,registerFieldControl:dy,validation:{getValidationProps:(e,t=py)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:dy,getInputControl:()=>null,commit:async()=>{},change:dy}},zP=J.createContext(RP);function BP(e=!0){let t=J.useContext(zP);if(t.setValidityData===dy&&!e)throw Error(qv(28));return t}function VP(e,t,n){let{setFocused:r,focusOwnerRef:i}=BP(),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 HP=J.createContext({disabled:!1});function UP(){return J.useContext(HP)}var WP=J.createContext({controlId:void 0,registerControlId:dy,resetControlId:dy,labelId:void 0,setLabelId:dy,messageIds:[],setMessageIds:dy,getDescriptionProps:e=>e});function GP(){return J.useContext(WP)}function KP(e,t,n,r=!0,i,a){let[o,s]=J.useState(),c=FE(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:qP(n.current,c);o!==i&&s(i)}),u}function qP(e,t){let n=JP(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function JP(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 YP(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=GP(),o=FE(),s=Ev(()=>Symbol()),c=J.useRef(!1),l=J.useRef(!1),u=Z(()=>{c.current&&i!==dy&&(c.current=!1,i(s.current,void 0))});return Q(()=>{if(!n||i===dy){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}var XP=J.createContext(void 0);function ZP(){return J.useContext(XP)}function QP(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var $P=J.createContext(void 0),eF=J.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=ZP(),{disabled:h,readOnly:g,required:_,form:v,checkedValue:y,touched:b=!1,validation:x,name:S,setCheckedValue:C=dy,setTouched:w=dy,registerInputRef:T=dy}=m??{},{setTouched:E,setFilled:D,state:O,disabled:k}=BP(),A=UP(),{labelId:j,getDescriptionProps:M}=GP(),N=k||A.disabled||h||i,P=g||a,F=_||o,I=v,L=m?y===c:c===``,R=J.useRef(null),ee=VP(N,R),z=J.useRef(null),B=x?.registerInput,V=ny(l,z,T,J.useCallback(e=>B?.(e,{controlRef:R,value:void 0}),[B]));Q(()=>{z.current?.checked&&D(!0)},[D]),Q(()=>{z.current&&T(N&&L?null:z.current)},[L,N,T]);let te=FE(),H=YP({id:d}),U=u?void 0:H,ne={role:`radio`,"aria-checked":L,"aria-labelledby":KP(s,j,z,!u,U,p[`aria-label`]),[ok]:L?``:void 0,id:u?H:te,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||N||P)return;e.preventDefault();let t=z.current;t&&Qv(t,e)},onFocus(e){ee(!0),!(e.defaultPrevented||N||P||!b)&&(z.current?.click(),w(!1))},onBlur(){m||ee(!1)}},{getButtonProps:re,buttonRef:ie}=$v({disabled:N,native:u,composite:!1}),ae={type:`radio`,ref:V,form:I,id:U,name:S,tabIndex:-1,style:S?Ax:kx,"aria-hidden":!0,...c===void 0?py:{value:QP(c)},disabled:N,checked:L,required:F,readOnly:P,onChange(e){if(e.nativeEvent.defaultPrevented||N||P||c===void 0)return;let t=Yb(Zb,e.nativeEvent);C(c,t),!t.isCanceled&&E(!0)},onClick(e){e.stopPropagation()},onFocus(){R.current?.focus()}},oe=J.useMemo(()=>({...O,required:F,disabled:N,readOnly:P,checked:L}),[O,N,P,L,F]),W=oe,se=m!==void 0,ce=[t,R,ie],le=[ne,p,re,M,x?e=>x.getValidationProps(N,e):py],ue=_y(`span`,e,{enabled:!se,state:oe,ref:ce,props:le,stateAttributesMapping:LP});return(0,Y.jsxs)($P.Provider,{value:W,children:[se?(0,Y.jsx)(qM,{tag:`span`,render:n,className:r,style:f,state:oe,refs:ce,props:le,stateAttributesMapping:LP}):ue,(0,Y.jsx)(`input`,{...ae,suppressHydrationWarning:!0})]})});function tF(e,t,n,r,i=!0,a){let{registerFieldControl:o}=BP(),s=Ev(()=>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 nF=J.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:dy,validationMode:`onSubmit`,submitCountRef:{current:0}});function rF(){return J.useContext(nF)}Object.keys(MP);function iF(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var aF=J.createContext(void 0);function oF(e=!1){let t=J.useContext(aF);if(!t&&!e)throw Error(qv(86));return t}var sF=[wk],cF=J.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:g,setFocused:_,validationMode:v,name:y,disabled:b,state:x,validation:S,setDirty:C,setFilled:w,validityData:T}=BP(),{labelId:E}=GP(),{clearErrors:D,elementRef:O}=rF(),k=oF(!0),A=b||i,j=y??d,M=FE(p),[N,P]=UO({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[F,I]=J.useState(!1),L=Z((e,t)=>{s?.(e,t),!t.isCanceled&&P(e)}),R=S.getInputControl,ee=J.useMemo(()=>({get current(){return R()}}),[R]),z=J.useRef(null),B=J.useRef(null),V=ny(z,f),te=J.useRef(V),H=Z(e=>{(z.current!==e||te.current!==V)&&(te.current=V,V?.(e))});Q(()=>{H(z.current)},[V,H]);let U=Z(e=>{if(e){if(!e.disabled){B.current||=e;let t=z.current;(e.checked||t==null||t.disabled)&&H(e)}return()=>{B.current===e&&(B.current=null),z.current===e&&H(null)}}}),ne=Z(()=>{let e=O.current;if(!e)return N??null;for(let t of S.registeredInputs.keys())if(t.checked&&iF(t,e))return N??null;return null});tF(ee,M,N??null,ne,!A,d),Yj(N,()=>{D(j),C(N!==T.initialValue),w(N!=null),S.change(N);let e=B.current;N==null&&e&&!e.disabled&&H(e)});let re=E??k?.legendId,ie={...x,disabled:A??!1,required:o??!1,readOnly:a??!1},ae=J.useMemo(()=>({checkedValue:N,disabled:A,form:u,validation:S,name:j,readOnly:a,registerInputRef:U,required:o,setCheckedValue:L,setTouched:I,touched:F}),[N,A,u,S,j,a,U,o,L,I,F]),oe={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":A||void 0,"aria-readonly":a||void 0,"aria-labelledby":re,onBlur(e){sb(e.currentTarget,e.relatedTarget)||(I(!1),g(!0),_(!1),v===`onBlur`&&S.commit(N))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&I(!0)}};return(0,Y.jsx)(XP.Provider,{value:ae,children:(0,Y.jsx)(Pk,{render:n,className:r,style:m,state:ie,props:[oe,h,e=>S.getValidationProps(A??!1,e)],refs:[t],stateAttributesMapping:PP,enableHomeAndEndKeys:!1,modifierKeys:sF})})});function lF({className:e,...t}){return(0,Y.jsx)(cF,{"data-slot":`radio-group`,className:X(`grid w-full gap-2`,e),...t})}function uF({className:e,...t}){return(0,Y.jsx)(eF,{"data-slot":`radio-group-segment`,className:X(`inline-flex h-7 items-center gap-1.5 rounded-sm px-2.5 text-ui font-medium text-muted-foreground hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 data-checked:bg-secondary data-checked:text-foreground data-checked:inset-ring data-checked:inset-ring-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,e),...t})}var dF=`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,fF=`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`;function pF({className:e,...t}){return(0,Y.jsx)(`div`,{"data-slot":`skeleton`,className:X(`animate-pulse rounded-md bg-muted`,e),...t})}var mF=({lines:e=7})=>(0,Y.jsxs)(`div`,{role:`status`,"aria-label":`Loading the diff`,className:`overflow-hidden rounded-lg border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex h-10 items-center gap-3 border-b px-3`,children:[(0,Y.jsx)(pF,{className:`h-3 w-3`}),(0,Y.jsx)(pF,{className:`h-3 w-56`}),(0,Y.jsx)(pF,{className:`ml-auto h-3 w-12`})]}),(0,Y.jsx)(`div`,{className:`flex flex-col py-1`,children:Array.from({length:e},(e,t)=>(0,Y.jsxs)(`div`,{className:`flex h-5 items-center gap-3 px-3`,children:[(0,Y.jsx)(pF,{className:`h-2.5 w-8`}),(0,Y.jsx)(pF,{className:`h-2.5`,style:{width:`${30+t*37%55}%`}})]},t))})]}),hF=({rows:e=8})=>(0,Y.jsxs)(`div`,{role:`status`,"aria-label":`Loading the files`,className:`flex flex-col gap-2 px-1`,children:[(0,Y.jsx)(pF,{className:`h-7 w-full`}),Array.from({length:e},(e,t)=>(0,Y.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,style:{paddingLeft:`${t%3*12}px`},children:[(0,Y.jsx)(pF,{className:`h-2.5 flex-1`}),(0,Y.jsx)(pF,{className:`h-2.5 w-10`})]},t))]}),gF=J.createContext(void 0);function _F(){let e=J.useContext(gF);if(e===void 0)throw Error(qv(63));return e}var vF=`data-checked`,yF=`data-unchecked`,bF={...PP,checked(e){return e?{[vF]:``}:{[yF]:``}}},xF=J.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}=rF(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,validationMode:E,disabled:D,name:O,validation:k}=BP(),{labelId:A}=GP(),j=D||m,M=O??l,N=J.useRef(null),P=ny(N,c,k.inputRef),F=J.useRef(null),I=VP(j,F),L=FE(),R=YP({id:s}),ee=u?void 0:R,[z,B]=UO({controlled:n,default:!!i,name:`Switch`,state:`checked`});tF(F,L,z,void 0,!j,l),Q(()=>{T(z)},[z,T]),Yj(z,()=>{b(M),C(z!==w.initialValue),k.change(z)});let{getButtonProps:V,buttonRef:te}=$v({disabled:j,native:u}),H=KP(a,A,N,!u,ee,y[`aria-label`]),U={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":H,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&&Qv(t,e)}},ne={...k.getValidationProps(j),checked:z,disabled:j,form:o,id:ee,name:M,required:p,style:M?Ax:kx,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=Yb(Zb,e.nativeEvent);d?.(t,n),!n.isCanceled&&B(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?py:{value:_}},re=J.useMemo(()=>({...x,checked:z,disabled:j,readOnly:f,required:p}),[x,z,j,f,p]),ie=_y(`span`,e,{state:re,ref:[t,F,te],props:[U,y,V,e=>k.getValidationProps(j,e)],stateAttributesMapping:bF});return(0,Y.jsxs)(gF.Provider,{value:re,children:[ie,!z&&M&&g!==void 0&&(0,Y.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,Y.jsx)(`input`,{...ne,suppressHydrationWarning:!0})]})}),SF=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return _y(`span`,e,{state:_F(),ref:t,stateAttributesMapping:bF,props:a})});function CF({className:e,size:t=`default`,...n}){return(0,Y.jsx)(xF,{"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,Y.jsx)(SF,{"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 wF=[{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`}],TF=({open:e,onOpenChange:t,ids:n})=>{let r=Hk.filter(e=>n===void 0||n.includes(e.id)),[i,a]=iA(),o=(0,J.useMemo)($k,[]),s=(0,J.useId)();return(0,Y.jsx)(Qj,{open:e,onOpenChange:t,children:(0,Y.jsxs)(tM,{className:`max-h-[85vh] overflow-y-auto sm:max-w-lg`,children:[(0,Y.jsxs)(nM,{children:[(0,Y.jsx)(rM,{children:`Keyboard shortcuts`}),(0,Y.jsx)(iM,{children:`Keys don't fire while you type in a field.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,Y.jsxs)(kP,{htmlFor:s,className:`leading-snug`,children:[`Single-key shortcuts`,(0,Y.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,Y.jsx)(CF,{id:s,checked:i,onCheckedChange:a})]}),wF.filter(({scope:e})=>r.some(t=>t.scope===e)).map(({scope:e,title:t})=>(0,Y.jsxs)(`section`,{"aria-label":t,className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:t}),(0,Y.jsx)(`dl`,{className:`flex flex-col`,children:r.filter(t=>t.scope===e).map(e=>{let t=!i&&e.chords.every(qk);return(0,Y.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-4 border-b py-1 last:border-0`,children:[(0,Y.jsxs)(`dt`,{className:t?`text-muted-foreground line-through`:void 0,children:[e.action,t&&(0,Y.jsx)(`span`,{className:`sr-only`,children:` (off)`})]}),(0,Y.jsx)(`dd`,{className:`flex gap-2`,children:e.chords.map(e=>(0,Y.jsx)(sA,{children:Yk(e,o).map(e=>(0,Y.jsx)(oA,{children:e},e))},Yk(e,o).join(` `)))})]},e.id)})})]},e))]})})},EF,DF=(e,t)=>{if(EF??=document.createElement(`canvas`).getContext(`2d`),EF===null)return null;let n=getComputedStyle(e);return EF.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,EF.letterSpacing=n.letterSpacing===`normal`?`0px`:n.letterSpacing,EF.measureText(t).width},OF=(e,t)=>{if(t(),document.fonts?.ready.then(t),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},kF=J.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}=BP(),{clearErrors:S,elementRef:C,submitCountRef:w}=rF(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=GP(),k=YP({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=Z(()=>x.inputRef.current?.value);tF(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]),Yj(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=J.useRef(null),P=VP(T,N),F=zy();return _y(`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=Yb(Zb,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:PP})}),AF=J.forwardRef(function(e,t){return(0,Y.jsx)(kF,{ref:t,...e})});function jF({className:e,type:t,...n}){return(0,Y.jsx)(AF,{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 MF=J.createContext(void 0);function NF(){let e=J.useContext(MF);if(e===void 0)throw Error(qv(53));return e}function PF(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 FF=`base-ui-disable-scrollbar`,IF={className:FF,getElement(e){return(0,Y.jsx)(`style`,{nonce:e,href:FF,precedence:`base-ui:low`,children:`.${FF}{scrollbar-width:none}.${FF}::-webkit-scrollbar{display:none}`})}},LF=`data-has-overflow-x`,RF=`data-has-overflow-y`,zF=`data-overflow-x-start`,BF=`data-overflow-x-end`,VF=`data-overflow-y-start`,HF=`data-overflow-y-end`,UF=e=>t=>t?{[e]:``}:null,WF={hasOverflowX:UF(LF),hasOverflowY:UF(RF),overflowXStart:UF(zF),overflowXEnd:UF(BF),overflowYStart:UF(VF),overflowYEnd:UF(HF),cornerHidden:()=>null},GF=`--scroll-area-corner-height`,KF=`--scroll-area-corner-width`,qF=`data-orientation`,JF={x:0,y:0},YF={width:0,height:0},XF={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},ZF={x:!0,y:!0,corner:!0},QF=J.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=$F(i),d=FE(),f=zy(),p=zy(),{nonce:m,disableStyleElements:h}=mk(),[g,_]=J.useState(!1),[v,y]=J.useState(!1),[b,x]=J.useState(!1),[S,C]=J.useState(!1),[w,T]=J.useState(!1),[E,D]=J.useState(YF),[O,k]=J.useState(YF),[A,j]=J.useState(XF),[M,N]=J.useState(ZF),P=J.useRef(null),F=J.useRef(null),I=J.useRef(null),L=J.useRef(null),R=J.useRef(null),ee=J.useRef(null),z=J.useRef(null),B=J.useRef(null),V=J.useRef(0),te=J.useRef(0),H=J.useRef(0),U=J.useRef(0),ne=J.useRef(`vertical`),re=J.useRef(JF),ie=J.useRef(null);function ae(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let oe=Z(e=>{let t=e.x-re.current.x,n=e.y-re.current.y;re.current=e,n!==0&&ae(!0),t!==0&&ae(!1)}),W=Z(()=>{let e=F.current;e&&ie.current===null&&(ie.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),se=Z(e=>{if(e.button!==0||B.current!==null&&(ne.current===`vertical`?R.current:ee.current)?.hasPointerCapture(B.current))return;B.current=e.pointerId,V.current=e.clientY,te.current=e.clientX,ne.current=e.currentTarget.getAttribute(qF);let t=F.current;t&&(H.current=t.scrollTop,U.current=t.scrollLeft,W()),(ne.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),ce=Z(e=>{if(e.pointerId!==B.current)return;B.current=null,(ne.current===`vertical`?x:y)(!1),ie.current!==null&&(F.current&&(F.current.style.scrollSnapType=ie.current),ie.current=null);let t=ne.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),le=Z(e=>{if(e.pointerId!==B.current)return;if(e.buttons%2==0){ce(e);return}let t=F.current;if(!t)return;let n=ne.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=PF(i,`padding`,a),s=PF(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-V.current:e.clientX-te.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?H.current:U.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ae(n)});function ue(e){C(e.pointerType===`touch`)}function de(e){if(ue(e),e.pointerType!==`touch`){let t=sb(P.current,e.target);_(t)}}let fe=J.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]),pe={role:`presentation`,onPointerEnter:de,onPointerMove:de,onPointerDown:ue,onPointerLeave(){_(!1)},style:{position:`relative`,[GF]:`${E.height}px`,[KF]:`${E.width}px`}},me=_y(`div`,e,{state:fe,ref:[t,P],props:[pe,o],stateAttributesMapping:WF}),he=J.useMemo(()=>({handlePointerDown:se,handlePointerMove:le,handlePointerUp:ce,handleScroll:oe,disableViewportSnap:W,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:fe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[se,le,ce,oe,W,E,O,w,S,v,b,g,d,M,A,fe,s,c,l,u]);return(0,Y.jsxs)(MF.Provider,{value:he,children:[!h&&IF.getElement(m),me]})});function $F(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 eI(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var tI=J.createContext(void 0);function nI(e,t){return Math.max(0,e-t)}function rI(e,t){if(t<=0)return 0;let n=eI(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 iI=`--scroll-area-overflow-x-start`,aI=`--scroll-area-overflow-x-end`,oI=`--scroll-area-overflow-y-start`,sI=`--scroll-area-overflow-y-end`,cI=`--scroll-area-thumb-height`,lI=`--scroll-area-thumb-width`,uI=[iI,aI,oI,sI],dI=!1;function fI(){dI||Zy||(typeof CSS<`u`&&`registerProperty`in CSS&&uI.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),dI=!0)}var pI=J.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}=NF(),T=VE(),E=J.useRef(!0),D=J.useRef([NaN,NaN,NaN,NaN]),O=zy(),k=zy(),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=mI(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=rI(T===`rtl`?-w:w,P),L=P-I);let R=A?0:rI(x,F),ee=A?0:F-R,z=j?0:b,B=A?0:y,V=0,te=0;!j&&!A&&(V=t?.offsetWidth||0,te=n?.offsetHeight||0);let H=f.width===0&&f.height===0,U=H?V:0,ne=H?te:0,re=PF(n,`padding`,`x`),ie=PF(t,`padding`,`y`),ae=PF(i,`margin`,`x`),oe=PF(r,`margin`,`y`),W=z-re-ae,se=B-ie-oe,ce=n?Math.min(n.offsetWidth-U,W):W,le=t?Math.min(t.offsetHeight-ne,se):se,ue=Math.max(16,ce*M),de=Math.max(16,le*N);if(m(e=>hI(e,{width:ue,height:de})),t&&r){let e=gI(r,cI,x,F,h,de,t.offsetHeight-de-ie-oe);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-ue-re-ae,t=gI(i,lI,T===`rtl`?-w:w,P,_,ue,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let fe=[I,L,R,ee];uI.forEach((t,n)=>{e.style.setProperty(t,`${fe[n]}px`)}),a&&p(e=>hI(e,{width:V,height:te})),g(e=>hI(e,k));let pe={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>hI(e,pe))});Q(()=>{fI()},[]),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=ew(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(dy))).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:IF.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=_y(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:WF}),P=J.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Y.jsx)(tI.Provider,{value:P,children:N})});function mI(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function hI(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function gI(e,t,n,r,i,a,o){let s=eI(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 _I=J.createContext(void 0);function vI(){let e=J.useContext(_I);if(e===void 0)throw Error(qv(54));return e}var yI=J.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}=NF(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=VE(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;J.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 bx(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=lb(e.nativeEvent),n=T?h.current:g.current;if(n&&sb(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=PF(n,`margin`,a),s=PF(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(${GF})`,insetInlineEnd:0,[cI]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${KF})`,bottom:0,[lI]:`${S.width}px`}}},M=_y(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:WF});return A?(0,Y.jsx)(_I.Provider,{value:i,children:M}):null}),bI=J.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}=NF(),m=vI(),h=m===`vertical`;return _y(`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]})}),xI=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=NF(),l=_y(`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 SI({className:e,children:t,...n}){return(0,Y.jsxs)(QF,{"data-slot":`scroll-area`,className:X(`relative`,e),...n,children:[(0,Y.jsx)(pI,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] -outline-offset-2`,children:t}),(0,Y.jsx)(CI,{}),(0,Y.jsx)(xI,{})]})}function CI({className:e,orientation:t=`vertical`,...n}){return(0,Y.jsx)(yI,{"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,Y.jsx)(bI,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}var wI=(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))})},TI=`…`,EI=e=>e.match(/[A-Z]?[a-z0-9]+|[A-Z]+(?![a-z])|[^A-Za-z0-9]+/g)??[e],DI=(e,t,n)=>{for(let r=1;r<=e.length-2;r++)for(let i=Math.ceil((e.length-r)/2);i>=1;i--){if(i+r>e.length-1)continue;let a=[...e.slice(0,i),TI,...e.slice(i+r)].join(t);if(n(a))return a}return null},OI=(e,t)=>{if(t(e))return e;let n=EI(e);if(n.length>2&&n.join(``)===e){let e=DI(n,``,t);if(e!==null)return e}let r=Math.min(8,e.length>>1),i=e;for(let n=e.length-r-1;n>=3;n--)if(i=`${e.slice(0,n)}${TI}${e.slice(-r)}`,t(i))return i;return i},kI=(e,t)=>{if(t(e))return e;let n=e.split(/(?<=[-_.])(?=.)/);for(let e=1;e<=n.length-2;e++)for(let r=Math.ceil((n.length-e)/2);r>=1;r--){if(r+e>n.length-1)continue;let i=n[r+e-1]?.slice(-1)??``,a=`${n.slice(0,r).join(``)}${TI}${i}${n.slice(r+e).join(``)}`;if(t(a))return a}return OI(e,t)},AI=(e,t)=>{if(t(e))return e;let n=e.split(`/`);return n.length<2?e:DI(n,`/`,t)??`${TI}/${n.at(-1)??``}`},jI=e=>{let t=/(?<=.)\.[a-z][a-z0-9]{0,9}$/.exec(e)?.[0]??``;return[e.slice(0,e.length-t.length),t]},MI=e=>{let t=e.split(`/`);for(let e=0;e<t.length-2;e++){let n=t[e]??``;if(!n.includes(`.`)||t[e+1]!==`src`)continue;let r=n.split(`.`);if(t.slice(e+2,e+2+r.length).join(`.`)===n&&!(e+2+r.length>=t.length)){t.splice(e+1,1+r.length);break}}return t.join(`/`)},NI=(e,t)=>{let n=MI(e).split(`/`),r=MI(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},PI=e=>e.slice(0,Math.max(e.lastIndexOf(`/`),0)),FI=e=>e.slice(e.lastIndexOf(`/`)+1),II=e=>{let t={directories:new Map,files:[]};for(let n of e){let e=t;for(let t of MI(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,n,r)=>{let i=e,a=t,o=n===``?e:`${n}/${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];return{label:`${r}${i}`,path:o,inner:a}},r=(t,n,r)=>({kind:`directory`,path:n,label:t,folder:OO(n,e),children:a(r,n)}),i=e=>e.sort((e,t)=>NI(e.kind===`file`?e.path:`${e.path}/x`,t.kind===`file`?t.path:`${t.path}/x`)),a=(e,t)=>i([...[...e.directories].map(([e,i])=>{let{label:a,path:o,inner:s}=n(e,i,t,``);return r(a,o,s)}),...e.files.map(e=>({kind:`file`,path:e,name:FI(e)}))]),o=(e,t,i)=>[...e.directories].flatMap(([e,a])=>{let{label:s,path:c,inner:l}=n(e,a,t,i),u=s.slice(i.length);return l.files.length===0&&l.directories.size>1&&!u.includes(`.`)?o(l,c,`${s}/`):[{prefix:i,heading:r(s,c,l)}]}),s=o(t,``,``).sort((e,t)=>NI(`${e.heading.path}/x`,`${t.heading.path}/x`)),c=[];for(let e=0;e<s.length;){let t=s[e]?.prefix??``,n=e+1;for(;t!==``&&s[n]?.heading.path.startsWith(t);)n++;let r=s.slice(e,n).map(({heading:e})=>e);c.push(...r.length<2?r:[{kind:`group`,path:t.slice(0,-1),children:r.map(e=>({...e,label:e.path.slice(t.length)}))}]),e=n}return[...c,...i(t.files.map(e=>({kind:`file`,path:e,name:FI(e)})))]},LI=e=>e.flatMap(e=>e.kind===`file`?[e.path]:LI(e.children)),RI={added:`new file`,modified:`modified`,deleted:`deleted`,renamed:`renamed`},zI=(e,t)=>`${e} ${t}${e===1?``:`s`}`,BI=e=>e.status===`renamed`?e.oldPath??null:null,VI=e=>{let{finding:t=0,risk:n=0}=e.points??{},r=BI(e),i=r===null?``:` from ${r}`;return[FI(e.path),`${TO(e.path,e.status).label}, ${RI[e.status]}${i}`,e.additions>0?`${zI(e.additions,`line`)} added`:``,e.deletions>0?`${zI(e.deletions,`line`)} removed`:``,(e.threads??0)>0?zI(e.threads??0,`open thread`):``,t>0?zI(t,`finding`):``,n>0?zI(n,`risk`):``,PI(e.path)===``?``:`in ${PI(e.path)}`].filter(Boolean).join(`, `)},HI=e=>{let t=RI[e.status],n=BI(e),r=n===null?``:` · was ${FI(n)}`;return`${e.path}\n${t[0]?.toUpperCase()}${t.slice(1)}${r}`},UI=({files:e,activePath:t,onSelect:n,navigate:r=!1,className:i})=>{let a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(null),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(`all`),[f,p]=(0,J.useState)(new Set),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(t);if(g!==t){_(t);let e=t===null?null:MI(t),n=[...f].filter(t=>e?.startsWith(`${t}/`));n.length>0&&p(new Set([...f].filter(e=>!n.includes(e))))}aA({filterTree:()=>s.current?.focus()});let v=(0,J.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]),y=(0,J.useMemo)(()=>II(e.map(e=>e.path)),[e]),b=e.filter(e=>(e.points?.finding??0)>0).length,x=e.filter(e=>(e.points?.risk??0)>0).length,S=(0,J.useMemo)(()=>{let t=new Set(wI(e,c).map(e=>e.path));return new Set(e.filter(e=>t.has(e.path)).filter(e=>u===`all`||(e.points?.[u]??0)>0).map(e=>e.path))},[e,c,u]),C=c.trim()!==``,w=(0,J.useMemo)(()=>{let e=[],t=e=>e.kind===`file`?Number(S.has(e.path)):e.children.reduce((e,n)=>e+t(n),0),n=(r,i,a)=>{for(let o of r){if(o.kind===`group`){n(o.children,i,o.path);continue}if(o.kind===`file`){let t=v.get(o.path);t!==void 0&&S.has(t.path)&&e.push({kind:`file`,key:t.path,file:t,depth:i,group:a});continue}let r=t(o);if(r===0)continue;let s=C||!f.has(o.path);e.push({kind:`directory`,key:`${o.path}/`,label:o.label,entry:o,depth:i,group:a,open:s,count:r}),s&&n(o.children,i+1,a)}};return n(y,0,null),e},[y,v,S,f,C]),T=(0,J.useMemo)(()=>w.reduce((e,t)=>{let n=e.at(-1);return n!==void 0&&n.group===t.group?n.rows.push(t):e.push({group:t.group,rows:[t]}),e},[]),[w]),E=(0,J.useMemo)(()=>LI(y).filter(e=>S.has(e)),[y,S]),D=(0,J.useMemo)(()=>{let e=E.filter(e=>{let{finding:t=0,risk:n=0}=v.get(e)?.points??{};return t+n>0});return new Map(e.map((e,t)=>[e,t]))},[E,v]),O=e=>{let r=t===null?-1:E.indexOf(t),i=E[Math.min(E.length-1,Math.max(0,r+e))];i!==void 0&&n(i)};aA({nextFile:()=>O(1),previousFile:()=>O(-1)},r),(0,J.useEffect)(()=>{let e=a.current?.querySelector(`[data-slot=scroll-area-viewport]`),t=o.current?.querySelector(`[aria-selected=true]`);if(e==null||t==null)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;(n<e.scrollTop||n>e.scrollTop+e.clientHeight-40)&&(e.scrollTop=Math.max(0,n-e.clientHeight/3))},[t]);let k=w.find(e=>e.key===m)?.key??w.find(e=>e.kind===`file`&&e.file.path===t)?.key??w[0]?.key,A=e=>{e!==void 0&&(h(e),o.current?.querySelector(`[data-key="${CSS.escape(e)}"]`)?.focus())},j=e=>{let t=new Set(f);t.has(e)?t.delete(e):t.add(e),p(t)},M=e=>{h(e.key),e.kind===`file`?n(e.file.path):C||j(e.entry.path)};return(0,Y.jsxs)(`nav`,{ref:a,"aria-label":`Changed files`,className:X(`flex min-h-0 flex-col font-tree`,i),children:[(0,Y.jsxs)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(g_,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Y.jsx)(jF,{ref:s,type:`text`,value:c,spellCheck:!1,autoComplete:`off`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),l(``),e.currentTarget.blur()):e.key===`ArrowDown`&&(e.preventDefault(),A(k))},placeholder:`Filter files`,"aria-label":`Filter files by name or path`,className:`h-7.5 pl-7`})]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex h-7 items-center justify-between text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`tabular`,"aria-live":`polite`,children:S.size===e.length?`${e.length} files`:`${S.size} of ${e.length} files`}),(0,Y.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex gap-px`,children:[[`all`,`All`],[`finding`,`Findings ${b}`],[`risk`,`Risks ${x}`]].map(([e,t])=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:X(`tabular rounded-sm px-1.5 py-0.5 text-caption hover:text-foreground`,u===e&&`bg-secondary font-medium text-foreground`),children:t},e))})]})]}),w.length===0?(0,Y.jsxs)(`p`,{className:`border-t px-3 py-4 text-caption text-muted-foreground`,children:[`No files match.`,` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{l(``),d(`all`)},className:`text-primary underline`,children:`Clear filter`})]}):(0,Y.jsx)(SI,{className:`min-h-0 flex-1 border-t`,children:(0,Y.jsx)(`div`,{ref:o,role:`tree`,"aria-label":`Changed files`,onKeyDown:e=>{let t=w.findIndex(t=>t.key===e.target.dataset.key),n=w[t];if(n===void 0)return;let r=t=>{e.preventDefault(),A(w[Math.min(w.length-1,Math.max(0,t))]?.key)};switch(e.key){case`ArrowDown`:return r(t+1);case`ArrowUp`:if(t===0){e.preventDefault(),s.current?.focus();return}return r(t-1);case`Home`:return r(0);case`End`:return r(w.length-1);case`Enter`:case` `:return e.preventDefault(),M(n);case`ArrowRight`:n.kind===`directory`&&!n.open&&(e.preventDefault(),j(n.entry.path));return;case`ArrowLeft`:{if(n.kind===`directory`&&n.open&&!C){e.preventDefault(),j(n.entry.path);return}let i=w.slice(0,t).findLastIndex(e=>e.depth<n.depth);i>=0&&r(i);return}}},className:`pt-1 pb-4`,children:T.map(e=>{let n=e.rows.map(e=>e.kind===`directory`?(0,Y.jsx)(qI,{row:e,tabbable:e.key===k,onActivate:()=>M(e)},e.key):(0,Y.jsx)(ZI,{file:e.file,depth:e.depth,inset:e.group!==null,active:e.file.path===t,tabbable:e.key===k,onActivate:()=>M(e),...D.has(e.file.path)?{landing:{at:D.get(e.file.path)??0,of:D.size}}:{}},e.key)),r=e.rows[0]?.key??``;return e.group===null?(0,Y.jsx)(J.Fragment,{children:n},r):(0,Y.jsxs)(`div`,{role:`group`,"aria-label":`${e.group}/`,children:[(0,Y.jsx)(KI,{path:e.group}),n]},r)})})})]})},WI=`relative flex min-h-7.5 cursor-default items-center whitespace-nowrap pr-[7px] select-none hover:bg-surface-row focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`,GI=(e,t=!1)=>({paddingLeft:`${6+(e+Number(t))*14}px`}),KI=({path:e})=>(0,Y.jsx)(`div`,{"aria-hidden":`true`,title:e,className:`flex h-6 items-end pr-[7px] pb-0.5 whitespace-nowrap select-none`,style:GI(0),children:(0,Y.jsx)(YI,{path:e,caption:!0})}),qI=({row:e,tabbable:t,onActivate:n})=>(0,Y.jsxs)(`div`,{role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":e.open,"aria-label":`${e.entry.path}, folder, ${zI(e.count,`file`)}`,title:e.entry.path,"data-key":e.key,tabIndex:t?0:-1,onClick:n,className:X(WI,`gap-[5px]`),style:GI(e.depth,e.group!==null),children:[(0,Y.jsx)(cg,{"aria-hidden":`true`,className:X(`size-3 shrink-0 text-muted-foreground transition-transform duration-(--duration-fast) ease-standard`,e.open&&`rotate-90`)}),(0,Y.jsx)(`span`,{className:`mr-px`,children:(0,Y.jsx)(NO,{kind:e.entry.folder})}),(0,Y.jsx)(YI,{path:e.label}),!e.open&&(0,Y.jsx)(`span`,{className:`tabular font-code text-code-compact leading-none text-muted-foreground`,children:e.count})]}),JI={added:[`text-diff-add-fg`,`text-file-ext-add`],deleted:[`text-diff-del-fg line-through decoration-1`,`text-file-ext-del line-through decoration-1`],modified:[``,`text-muted-foreground`],renamed:[``,`text-muted-foreground`]},YI=({path:e,caption:t=!1})=>{let n=(0,J.useRef)(null),r=t?`/`:``,[i,a]=(0,J.useState)(e);(0,J.useLayoutEffect)(()=>{let t=n.current;if(t!==null)return OF(t,()=>{let n=t.clientWidth,i=t.firstElementChild,o=t.lastElementChild;n!==0&&i!==null&&o!==null&&a(AI(e,e=>{let t=e.lastIndexOf(`/`)+1,a=[DF(i,e.slice(0,t)),DF(o,e.slice(t)+r)];return(a[0]??0)+(a[1]??0)<=n+.5}))})},[e,r]);let o=i.lastIndexOf(`/`)+1;return(0,Y.jsxs)(`span`,{ref:n,className:`min-w-0 flex-1 basis-0 truncate text-tree-folder text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:i.slice(0,o)}),(0,Y.jsxs)(`span`,{className:t?void 0:`font-medium text-foreground`,children:[i.slice(o),r]})]})},XI=({file:e})=>{let t=(0,J.useRef)(null),[n,r]=jI(FI(e.path)),[i,a]=(0,J.useState)(n);(0,J.useLayoutEffect)(()=>{let e=t.current;if(e!==null)return OF(e,()=>{let t=e.clientWidth,i=e.firstElementChild,o=e.lastElementChild;if(t===0||i===null||o===null)return;let s=DF(o,r);s!==null&&a(OI(n,e=>(DF(i,e)??0)+s<=t+.5))})},[n,r]);let[o,s]=JI[e.status];return(0,Y.jsxs)(`span`,{ref:t,"data-slot":`file-name`,className:`min-w-0 flex-1 basis-0 truncate text-tree font-medium tracking-[-0.012em]`,children:[(0,Y.jsx)(`span`,{"data-slot":`file-stem`,className:o,children:i}),(0,Y.jsx)(`span`,{"data-slot":`file-extension`,className:X(`font-normal`,s),children:r})]})},ZI=({file:e,depth:t,inset:n,active:r,tabbable:i,landing:a,onActivate:o})=>{let{finding:s=0,risk:c=0}=e.points??{},l=e.threads??0;return(0,Y.jsxs)(`div`,{role:`treeitem`,"aria-level":t+1,"aria-selected":r,"aria-label":VI(e),title:HI(e),"data-key":e.path,"data-status":e.status,tabIndex:i?0:-1,onClick:o,className:X(WI,`gap-1.5`,r&&`bg-diff-hunk-bg before:absolute before:top-1 before:bottom-1 before:left-0 before:w-0.5 before:rounded-full before:bg-primary hover:bg-diff-hunk-bg`),style:GI(t,n),children:[(0,Y.jsx)(MO,{path:e.path,status:e.status}),(0,Y.jsx)(XI,{file:e}),(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`tabular flex flex-none items-center gap-1.5 font-code text-code-compact leading-none text-muted-foreground`,children:[l>0&&(0,Y.jsxs)(`span`,{"data-slot":`thread-count`,className:`inline-flex items-center gap-[2.5px]`,children:[(0,Y.jsx)(n_,{className:`size-3`,strokeWidth:1.75}),l]}),s+c>0&&(0,Y.jsxs)(`span`,{"data-land":`drop`,style:Ph({"--landing-i":a?.at??0,"--landing-n":a?.of??1}),className:`inline-flex items-center gap-1.5`,children:[s>0&&(0,Y.jsxs)(`span`,{"data-slot":`point-count`,"data-kind":`finding`,className:`inline-flex items-center gap-[2.5px]`,children:[(0,Y.jsx)(`i`,{className:`size-1.5 rounded-full bg-severity-minor`}),s>1&&s]}),c>0&&(0,Y.jsx)(`span`,{"data-slot":`point-count`,"data-kind":`risk`,className:`inline-flex items-center`,children:(0,Y.jsx)(`i`,{className:`size-[7px] rounded-full ring-[1.5px] ring-risk-contract-solid ring-inset`})})]}),(e.additions>0||e.deletions>0)&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-[5px]`,children:[e.additions>0&&(0,Y.jsxs)(`span`,{className:`text-stat-add`,children:[`+`,e.additions]}),e.deletions>0&&(0,Y.jsxs)(`span`,{className:`text-stat-del`,children:[`−`,e.deletions]})]})]})]})},QI=({count:e})=>(0,Y.jsxs)(`span`,{"data-slot":`thread-count`,className:`tabular inline-flex items-center gap-0.5 text-caption`,children:[(0,Y.jsx)(n_,{"aria-hidden":`true`,className:`size-3`}),e,(0,Y.jsxs)(`span`,{className:`sr-only`,children:[` open `,e===1?`thread`:`threads`]})]}),$I=60,eL=3600,tL=24*eL,nL=(e,t)=>{let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<$I)return`just now`;if(n<eL)return`${Math.floor(n/$I)} min ago`;if(n<tL)return`${Math.floor(n/eL)} h ago`;let r=Math.floor(n/tL);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`)},rL=e=>new Date(e).toLocaleString(`en`,{dateStyle:`full`,timeStyle:`short`}),iL={github:`GitHub`,bitbucket:`Bitbucket`},aL=({repo:e,number:t})=>`${e.owner}/${e.repo} #${t}`,oL=`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,sL=(e,t)=>{let n=e.role===`author`?`you`:e.author.name;return`${e.title}. ${aL(e.ref)} by ${n}, updated ${nL(e.updatedAt,t)}, ${iL[e.ref.repo.host]}`},cL=({item:e,nowMs:t,starting:n,tabbable:r,onOpen:i,onFocus:a})=>{let o=iL[e.ref.repo.host],s=e.role===`author`?`you`:e.author.name;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:W_(e.ref),"data-pr-row":``,tabIndex:r?0:-1,"aria-label":sL(e,t),"aria-busy":n,onClick:e=>{Z_(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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1 self-stretch`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-x-1.5 text-caption text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 gap-[1ch] font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.ref.repo.owner,`/`,e.ref.repo.repo]}),(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`#`,e.ref.number]})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-medium`,mA(e.author.id)),children:fA(e.author.name)}),(0,Y.jsx)(`span`,{className:`max-w-32 shrink-0 truncate`,children:s}),(0,Y.jsx)(`time`,{dateTime:e.updatedAt,title:rL(e.updatedAt),className:`shrink-0 whitespace-nowrap`,children:nL(e.updatedAt,t)}),(0,Y.jsx)(VO,{variant:`outline`,className:`ml-auto shrink-0 text-muted-foreground @min-[480px]:hidden`,children:o})]})]}),n?(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-caption`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-4 text-diff-hunk-fg`,oL)}),(0,Y.jsx)(`span`,{className:`font-medium text-diff-hunk-fg`,children:`Opening review…`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Esc to cancel`})]}):(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 @max-[479px]:hidden`,children:[(0,Y.jsx)(VO,{variant:`outline`,className:`text-muted-foreground @max-[479px]:hidden`,children:o}),(0,Y.jsx)(cA,{id:`openRow`,className:`hidden group-focus-visible:inline-flex`}),(0,Y.jsx)(cg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 max-sm:hidden`})]})]})})},lL={ArrowDown:(e,t)=>Math.min(t,e+1),ArrowUp:e=>Math.max(0,e-1),Home:()=>0,End:(e,t)=>t},uL=({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,J.useId)(),p=(0,J.useRef)(null),[m,h]=(0,J.useState)(0),g=n??[],_=Math.min(m,Math.max(0,g.length-1)),v=e=>{let t=lL[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,Y.jsxs)(`section`,{"aria-labelledby":f,className:`@container flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,Y.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,Y.jsx)(`h2`,{id:f,className:`text-heading font-semibold`,children:e}),r!==null&&(0,Y.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,Y.jsx)(`span`,{className:`sr-only`,children:r===`…`?`Loading`:`${r} pull request${r===1?``:`s`}`})]}),(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 p-3 empty:hidden`,children:o}),s??(n===null?(0,Y.jsxs)(`div`,{"aria-busy":`true`,className:`flex flex-col`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 px-4 pt-3 text-caption text-muted-foreground`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-4`,`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`)}),i]}),(0,Y.jsx)(`ul`,{"aria-hidden":`true`,className:`flex flex-col gap-3 px-4 py-3`,children:Array.from({length:a},(e,t)=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(pF,{className:`h-4 w-3/4 motion-reduce:animate-none`}),(0,Y.jsx)(pF,{className:`h-3 w-1/2 motion-reduce:animate-none`})]},t))})]}):g.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-1 px-6 py-8 text-center`,children:[(0,Y.jsx)(y,{"aria-hidden":`true`,className:`mb-1 size-6 text-muted-foreground`}),(0,Y.jsx)(`p`,{className:`font-medium`,children:c.title}),(0,Y.jsx)(`p`,{className:`max-w-sm text-caption text-muted-foreground`,children:c.text})]}):(0,Y.jsx)(`ul`,{ref:p,className:`divide-y`,onKeyDown:v,children:g.map((e,t)=>(0,Y.jsx)(cL,{item:e,nowMs:l,starting:u===e.url,tabbable:t===_,onOpen:()=>d(e),onFocus:()=>h(t)},e.url))}))]})},dL=wc.options,fL=`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-caption`,pL=`h-6 min-w-6 px-1 text-caption`,mL=e=>e.map(e=>iL[e]).join(` and `),hL=(e,t)=>{let n=e===null?[]:dL.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))}},gL=(e,t)=>(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-8 text-center text-caption text-muted-foreground`,children:[(0,Y.jsx)(`p`,{children:e}),t]}),_L=({status:e,list:t,error:n,rowFailure:r,startingUrl:i,nowMs:a,onOpen:o,onRetry:s,onOpenConnections:c,onFix:l})=>{let u=hL(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?`${iL[u.shown[0]]} only`:null,m=e=>n===null?null:(0,Y.jsxs)(`p`,{className:X(dF,fL),role:`alert`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Couldn't list pull requests.`}),(0,Y.jsx)(`span`,{children:Gp(n)}),e&&(0,Y.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:s,children:`Retry`})]}),h=e=>r?.role===e?(0,Y.jsxs)(`p`,{className:X(dF,fL),role:`alert`,children:[(0,Y.jsx)(`span`,{children:r.message}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:r.onRetry,children:`Try again`})]}):null,g=u.failing.map(e=>(0,Y.jsxs)(`p`,{className:X(fF,fL),role:`status`,children:[(0,Y.jsxs)(`span`,{children:[iL[e],` pull requests are hidden until `,iL[e],` works again.`]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:l,children:`Fix…`})]},e)),_=u.listFailed.map(e=>(0,Y.jsxs)(`p`,{className:X(dF,fL),role:`alert`,children:[(0,Y.jsxs)(`span`,{className:`font-medium`,children:[`Couldn't load `,iL[e.host],` pull requests.`]}),(0,Y.jsx)(`span`,{children:e.message}),u.shown.length>0&&(0,Y.jsxs)(`span`,{children:[mL(u.shown),` pull requests are shown.`]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:s,children:`Retry`})]},e.host)),v=u.configured.length===0?`Loading`:`Loading from ${mL(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,Y.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.55fr_1fr]`,children:[(0,Y.jsx)(uL,{title:`To review`,word:p??`Waiting for your review`,items:y,count:x(y),loading:v,skeletonRows:5,notes:(0,Y.jsxs)(Y.Fragment,{children:[t!==null&&m(!0),g,_,h(`reviewer`)]}),blocked:d?gL(`Connect GitHub or Bitbucket to list pull requests.`,(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Open Connections`})):t===null&&n!==null?m(!0):!f&&void 0,empty:{icon:Hg,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,Y.jsx)(uL,{title:`Your pull requests`,word:p??`Open`,items:b,count:x(b),loading:`Loading`,skeletonRows:3,notes:(0,Y.jsxs)(Y.Fragment,{children:[t!==null&&m(!1),h(`author`)]}),blocked:d?gL(`Connect GitHub or Bitbucket to list pull requests.`):t===null&&n!==null?m(!1):f?gL(`Couldn't load pull requests.`):void 0,empty:{icon:Ig,title:`No open pull requests`,text:`Pull requests you open on GitHub or Bitbucket appear here.`},nowMs:a,startingUrl:i,onOpen:o})]})},vL=(0,J.createContext)(null),yL=()=>{let e=(0,J.useContext)(vL);if(e===null)throw Error(`useConnections needs a ConnectionsProvider`);return e},bL=({children:e,now:t=Date.now})=>{let{status:n,error:r,loading:i,refresh:a}=Lp(),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1);(0,J.useEffect)(()=>{!i&&n!==null&&s(t())},[i,n,t]);let g=(0,J.useCallback)(()=>{a(),d(e=>e+1)},[a]),_=(0,J.useCallback)((e,t)=>{h(e&&t?.focusCheckAgain===!0),p(e)},[]),v=(0,J.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,Y.jsx)(vL.Provider,{value:v,children:e})},xL=({pullRequest:e,error:t})=>{let{setOpen:n}=yL(),r=`Couldn't open ${aL(e)}: `;return t.code===`host-not-configured`?(0,Y.jsxs)(Y.Fragment,{children:[r,iL[e.repo.host],` isn't configured.`,` `,(0,Y.jsx)($,{variant:`link`,className:pL,onClick:()=>n(!0),children:`Open Connections`})]}):(0,Y.jsx)(Y.Fragment,{children:`${r}${Gp(t)}`})},SL=({pullRequest:e})=>{let{client:t}=Pp(),[n,r]=(0,J.useState)(0),[i,a]=(0,J.useState)(null),o=aL(e),s=(0,J.useRef)(0);return(0,J.useEffect)(()=>(s.current=n,t.startAnalysis({url:jf(e)}).then(e=>{s.current===n&&(e.ok?X_(G_(e.value.analysisId)):a(e.error))}),()=>{s.current=-1}),[t,e,n]),(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:o}),(0,Y.jsx)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-body`,children:i===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-4`,oL)}),`Fetching `,o,` from `,iL[e.repo.host],`…`]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:()=>{s.current=-1,X_(`/`)},children:`Cancel`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-4 align-[-3px]`}),(0,Y.jsx)(xL,{pullRequest:e,error:i})]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:()=>{a(null),r(e=>e+1)},children:`Try again`})]})}),i!==null&&(0,Y.jsx)(`p`,{className:`text-body`,children:(0,Y.jsx)(Q_,{to:`/`,children:`Go to your pull requests`})})]})},CL=J.createContext(void 0);function wL(e){let t=J.useContext(CL);if(t===void 0&&!e)throw Error(qv(72));return t}var TL={...Hw,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},EL=class extends Nw{constructor(e,t,n){let r=new bw;super(OL(e,r,t,n),kL(r),TL)}setOpen=(e,t)=>{mw(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Yb(Qb,e))}};function DL(){let e=new bw,t=new SE(Object.freeze(OL(void 0,e)),Object.freeze(kL(e)),TL);return Object.assign(t,{setOpen:dy,cancelPendingOpen:dy})}function OL(e,t,n,r=!1){return{...Iw(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 kL(e){return{popupRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var AL=Ny(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=cw((e,t)=>new EL({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}),gw(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=_w(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=J.useRef(null);Q(()=>{m&&t&&p.setOpen(!1,Yb(dx))},[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]),J.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,Yb(mx))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Y.jsxs)(CL.Provider,{value:p,children:[l&&(0,Y.jsx)(lw,{handle:l,store:p}),T&&(0,Y.jsx)(jL,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function jL({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=zC(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=IC(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=J.useMemo(()=>Nv(a.reference,i.reference),[a.reference,i.reference]);return vw(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??py}),null}var ML=J.createContext(void 0);function NL(){return J.useContext(ML)}var PL=`data-base-ui-tooltip-trigger`;function FL(e){let t=lb(e);return iv(t)?t:null}var IL=Py(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=wL(!0),m=Uw(a)??p;if(!m)throw Error(qv(82));let h=FE(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=J.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=hw(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=NL(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=yx(v,{open:_}),O=Zw(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Sx(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=J.useRef(!1),F=zy(),I=J.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=cb(e,`[${PL}]`);return n!==null&&n!==t&&sb(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=eT(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?gT():null,restMs:L,delay(){return u==null&&D?{close:Gb(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),B=Kw(v,{enabled:!A}).reference,V=e=>{let t=P.current,n=FL(e),r=ee(n),i=y.current,a=i&&n&&sb(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,Yb($b,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&ib(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,Yb($b,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},te=m.useState(`appliedTriggerProps`,S||M!==`none`);return _y(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,B,te,{onMouseOver(e){V(e.nativeEvent)},onFocus(e){R(FL(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,[Fb]:A?``:void 0,[PL]:A?void 0:``},f],stateAttributesMapping:jb})}),LL=J.createContext(void 0);function RL(){let e=J.useContext(LL);if(e===void 0)throw Error(qv(70));return e}var zL=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return wL().useState(`mounted`)||n?(0,Y.jsx)(LL.Provider,{value:n,children:(0,Y.jsx)(NE,{ref:t,...r})}):null}),BL=J.createContext(void 0);function VL(){let e=J.useContext(BL);if(e===void 0)throw Error(qv(71));return e}var HL=J.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=oC,style:g,..._}=e,v=wL(),y=RL(),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=tD({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=aD(e,J.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,Y.jsx)(BL.Provider,{value:D,children:O})}),UL=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=wL(),{side:s,align:c}=VL(),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`);iw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Qw(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return _y(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[ow,f,iD(d),a],stateAttributesMapping:Pb})}),WL=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=wL(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=VL();return _y(`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:Nb})}),GL=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=J.useMemo(()=>({open:t,close:n}),[t,n]);return(0,Y.jsx)(ML.Provider,{value:t,children:(0,Y.jsx)(vx,{delay:i,timeoutMs:r,children:e.children})})},KL=class extends ZC{constructor(){super(DL(),`Tooltip`)}open(e){this.openByTrigger(e)}close(){this.closePopup()}get isOpen(){return this.attachedStore?.select(`open`)??!1}};function qL(){return new KL}function JL({delay:e=0,...t}){return(0,Y.jsx)(GL,{"data-slot":`tooltip-provider`,delay:e,...t})}function YL({...e}){return(0,Y.jsx)(AL,{"data-slot":`tooltip`,...e})}function XL({...e}){return(0,Y.jsx)(IL,{"data-slot":`tooltip-trigger`,...e})}function ZL({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,collisionBoundary:a,children:o,shortcut:s,...c}){return(0,Y.jsx)(zL,{children:(0,Y.jsx)(HL,{collisionBoundary:a,align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,Y.jsxs)(UL,{"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,Y.jsx)(oA,{children:s}),(0,Y.jsx)(WL,{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 QL=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))},$L=e=>String(e).padStart(2,`0`),eR=e=>{let t=new Date(e);return`${t.getFullYear()}-${$L(t.getMonth()+1)}-${$L(t.getDate())}`},tR=e=>new Date(`${e}T00:00:00Z`),nR=e=>tR(e).toLocaleDateString(`en`,{month:`short`,day:`numeric`,timeZone:`UTC`}),rR=e=>tR(e).toLocaleDateString(`en`,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}),iR=e=>tR(e).toLocaleDateString(`en`,{month:`short`,timeZone:`UTC`}),aR=e=>Number(e.slice(8,10)),oR=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=>aR(e.date)===1);if(i!==void 0)return iR(i.date);let a=r[0];return n===0&&a!==void 0&&aR(a.date)<=7?iR(a.date):null})},sR=e=>e===1?`1 PR`:`${e} PRs`,cR=e=>e===1?`1 comment`:`${e} comments`,lR=e=>`${e.pullRequests===0?`No PRs`:sR(e.pullRequests)} reviewed · ${cR(e.comments)}`,uR=(e,t)=>`${nR(e.date)}: ${e.pullRequests===0?`No PRs`:sR(e.pullRequests)} reviewed, ${cR(e.comments)}${e.date===t?` (today)`:``}`,dR=e=>`Busiest day: ${nR(e.date)}, ${sR(e.pullRequests)} and ${cR(e.comments)}.`,fR=(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},pR=e=>Fc(e),mR={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`},hR=[{level:0,label:`0`},{level:1,label:`1`},{level:2,label:`2`},{level:3,label:`3–4`},{level:4,label:`5+`}],gR=[``,`Mon`,``,`Wed`,``,`Fri`,``],_R=({level:e,className:t})=>(0,Y.jsx)(`span`,{className:X(`flex items-center justify-center rounded-[4px] border`,mR[e],t),children:e===4&&(0,Y.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),vR=e=>{let[t,n]=(0,J.useState)(null);return(0,J.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},yR=qL(),bR=({days:e,today:t,weeks:n})=>{let[r,i]=(0,J.useState)(t),a=(0,J.useRef)(new Map),o=(0,J.useRef)(null),s=e.some(e=>e.date===r)?r:e[0]?.date??t,c=oR(e),l=Math.ceil(e.length/7);return(0,Y.jsxs)(`div`,{ref:o,className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.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,Y.jsx)(`span`,{className:`h-4 overflow-visible whitespace-nowrap`,children:e},t))}),(0,Y.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=fR(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:gR.map((n,r)=>(0,Y.jsxs)(`div`,{role:`row`,className:`flex items-center`,children:[(0,Y.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||pR(c.date)!==r)return(0,Y.jsx)(`span`,{className:`size-6 shrink-0`},o);let l=zc(c.pullRequests);return(0,Y.jsx)(XL,{handle:yR,payload:c,delay:150,render:(0,Y.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":uR(c,t),onFocus:()=>i(c.date),className:`group flex size-6 shrink-0 items-center justify-center rounded-md`}),children:(0,Y.jsx)(_R,{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,Y.jsx)(AL,{handle:yR,children:({payload:e})=>e===void 0?null:(0,Y.jsx)(ZL,{collisionBoundary:o.current??void 0,children:(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`font-semibold`,children:rR(e.date)}),(0,Y.jsx)(`span`,{children:lR(e)})]})})}),(0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`flex items-start gap-2 pl-8 text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`leading-4`,children:`PRs a day`}),hR.map(({level:e,label:t})=>(0,Y.jsxs)(`span`,{className:`flex w-6 flex-col items-center gap-0.5`,children:[(0,Y.jsx)(_R,{level:e,className:`size-4`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:t})]},e))]})]})},xR=({value:e,label:t})=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-title font-semibold tabular-nums`,children:e}),(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),SR=({activity:e,error:t,onRetry:n,now:r})=>{let i=(0,J.useId)(),a=(0,J.useRef)(null),o=vR(a),s=QL(o),c=o===null||o>=900,l=eR(r()),u=(0,J.useMemo)(()=>e===null?null:Rc(e,{today:l,weeks:s,dayOf:eR}),[e,l,s]),d=(0,J.useMemo)(()=>e===null?null:Rc(e,{today:l,weeks:26,dayOf:eR}),[e,l]),f=u===null?null:Bc(u),p=d?.every(e=>e.pullRequests===0&&e.comments===0)===!0;return(0,Y.jsxs)(`section`,{"aria-labelledby":i,className:`flex flex-col rounded-xl border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2.5`,children:[(0,Y.jsx)(`h2`,{id:i,className:`text-heading font-semibold`,children:`Review activity`}),(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`Last `,s,` weeks`]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground max-sm:basis-full sm:ml-auto`,children:[(0,Y.jsx)(Kg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Reviews and comments posted from megareviewer on this machine`]})]}),(0,Y.jsx)(`div`,{className:`overflow-hidden px-4 py-4`,children:(0,Y.jsx)(`div`,{ref:a,children:u===null||f===null?t===null?(0,Y.jsx)(pF,{"aria-label":`Loading review activity`,className:`h-[244px] w-full motion-reduce:animate-none`}):(0,Y.jsxs)(`p`,{className:X(dF,`flex flex-wrap items-baseline gap-x-2 text-caption`),children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Couldn't read your review activity.`}),(0,Y.jsx)(`span`,{children:Gp(t)}),(0,Y.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:n,children:`Try again`})]}):(0,Y.jsxs)(`div`,{className:X(`flex gap-8`,c?`flex-row`:`flex-col`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(bR,{days:u,today:l,weeks:s}),p&&(0,Y.jsxs)(`p`,{className:`rounded-md bg-muted px-3 py-2 text-caption text-muted-foreground`,children:[(0,Y.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,Y.jsxs)(`div`,{className:X(`flex flex-col gap-3`,c&&`w-[260px] shrink-0`),children:[(0,Y.jsxs)(`div`,{className:X(`grid gap-x-6 gap-y-3`,c||o!==null&&o<520?`grid-cols-2`:`grid-cols-4`),children:[(0,Y.jsx)(xR,{value:f.pullRequests,label:`PRs reviewed`}),(0,Y.jsx)(xR,{value:f.comments,label:`comments posted`}),(0,Y.jsx)(xR,{value:f.daysWithReviews,label:`days with reviews`}),(0,Y.jsx)(xR,{value:f.thisWeek,label:`PRs this week`})]}),f.busiest!==null&&(0,Y.jsx)(`p`,{className:`border-t pt-3 text-caption text-muted-foreground`,children:dR(f.busiest)})]})]})})})]})},CR=`Paste a pull request link first.`,wR=`That isn't a pull request link. Use github.com/owner/repo/pull/123 or bitbucket.org/workspace/repo/pull-requests/45.`,TR=`h-6 min-w-6 px-1 text-caption`,ER=Wk(`openInNewTab`).chords[0]??{key:`Enter`,mod:!0},DR=({inputRef:e,start:t,onSubmit:n,onSubmitInNewTab:r,onEdit:i,initial:a})=>{let[o,s]=(0,J.useState)(a?.url??``),[c,l]=(0,J.useState)(a?.invalid??null),u=(0,J.useId)(),d=t?.state===`starting`,f=()=>{let e=o.trim();if(e===``)return l(CR),null;let t=Af(e);return t.ok||l(wR),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=$k();return(0,Y.jsx)(`search`,{children:(0,Y.jsxs)(`form`,{"aria-label":`Open a pull request by link`,className:`flex flex-col gap-1.5`,onSubmit:p,noValidate:!0,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2 max-sm:flex-col`,children:[(0,Y.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Y.jsx)(Xg,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Y.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=>{Xk(e,ER,h)&&m(e)},onChange:e=>{s(e.target.value),l(null),i()},"aria-invalid":c!==null,"aria-describedby":`${u}-message`}),(0,Y.jsx)(cA,{id:`focusLink`,className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2`})]}),(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:oL}),`Opening…`]}):`Review`})]}),(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-3.5`,oL)}),t.message]}),(0,Y.jsx)($,{type:`button`,variant:`link`,className:TR,onClick:t.onCancel,children:`Cancel`})]}):t?.state===`failed`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),t.message]}),(0,Y.jsx)($,{type:`button`,variant:`link`,className:TR,onClick:t.onRetry,children:`Try again`})]}):null:(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),c]})})]})})},OR=wc.options,kR=({now:e=Date.now})=>{let{client:t}=Pp(),{status:n,checks:r,reportListed:i,setOpen:a}=yL(),o=Rp(),s=zp(),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),f=(0,J.useRef)(0),p=(0,J.useRef)(null),m=(0,J.useRef)(null),{refresh:h}=o,{refresh:g}=s,_=(0,J.useCallback)(()=>{h(),g()},[h,g]),v=(0,J.useRef)(r);(0,J.useEffect)(()=>{r!==v.current&&(v.current=r,_())},[r,_]),(0,J.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 OR)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,J.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&m.current!==null&&e()-m.current>12e4&&_()};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,_]),(0,J.useEffect)(()=>{let e=e=>{e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey||Zk(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 ${aL(n)}`);let o=await t.startAnalysis({url:e});f.current===a&&(o.ok?Y_(G_(o.value.analysisId)):l({from:r,url:e,ref:n,role:i,state:`failed`,error:o.error}))},b=(0,J.useCallback)(e=>{f.current+=1,l(null),e===`form`?p.current?.focus():d(`Cancelled`)},[]),x=c?.state===`starting`&&c.from===`row`;(0,J.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,Y.jsx)(xL,{pullRequest:e.ref,error:e.error}),C=c?.from===`form`?c.state===`starting`?{state:`starting`,message:`Fetching ${aL(c.ref)} from ${iL[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,Y.jsxs)(`div`,{className:`mx-auto flex max-w-[1240px] flex-col gap-4`,children:[(0,Y.jsx)(`h1`,{className:`sr-only`,children:`Pull requests`}),(0,Y.jsx)(DR,{inputRef:p,start:C,onSubmit:(e,t)=>void y(e,t,`form`,null),onSubmitInNewTab:e=>window.open(W_(e),`_blank`,`noopener`),onEdit:()=>{c?.from===`form`&&c.state===`failed`&&l(null)}}),(0,Y.jsx)(_L,{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,Y.jsx)(SR,{activity:s.activity,error:s.error,onRetry:g,now:e}),(0,Y.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})},AR=`megareviewer:`,jR=e=>{try{let t=window.localStorage.getItem(AR+e);return t===null?void 0:JSON.parse(t)}catch{return}},MR=(e,t)=>{try{window.localStorage.setItem(AR+e,JSON.stringify(t))}catch{}},NR=(e,t,n)=>{let[r,i]=(0,J.useState)(()=>({key:e,value:n(jR(e))??t}));return[r.key===e?r.value:n(jR(e))??t,(0,J.useCallback)(r=>i(i=>{let a=r(i.key===e?i.value:n(jR(e))??t);return MR(e,a),{key:e,value:a}}),[e,t,n])]},PR=e=>typeof e==`boolean`?e:void 0,FR=e=>{try{let t=window.sessionStorage.getItem(AR+e);return t===null?void 0:JSON.parse(t)}catch{return}},IR=(e,t)=>{try{window.sessionStorage.setItem(AR+e,JSON.stringify(t))}catch{}},LR=e=>typeof e==`string`?e:void 0,RR=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]]})},zR=(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)},BR=(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)))},VR=e=>e.length===0?`No model is known to megareviewer`:e.some(e=>e.available)?null:RR(e).map(([e])=>e.reason??`${e.providerName} can't run`).join(`; or `),HR=e=>{let[t,n]=NR(`model-option`,null,LR),r=e?.options??[],i=r.find(e=>e.id===t&&e.available)??r.find(t=>t.id===e?.defaultId)??null,a=(0,J.useCallback)(e=>n(()=>e),[n]);return{options:r,chosen:i,defaultId:e?.defaultId??null,locked:e===null?null:VR(r),choose:a}},UR={github:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`,bitbucket:`M.778 1.213a.768.768 0 00-.768.892l3.263 19.81c.084.5.515.868 1.022.873H19.95a.772.772 0 00.77-.646l3.27-20.03a.768.768 0 00-.768-.891zM14.52 15.53H9.522L8.17 8.466h7.561z`},WR=({host:e,className:t})=>(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,"data-host":e,className:X(`size-[15px] shrink-0`,t),children:(0,Y.jsx)(`path`,{d:UR[e]})}),GR=J.createContext(void 0);function KR(e){let t=J.useContext(GR);if(t===void 0&&!e)throw Error(qv(33));return t}var qR=J.createContext(void 0);function JR(e){let t=J.useContext(qR);if(t===void 0&&!e)throw Error(qv(36));return t}var YR=J.createContext(void 0);function XR(e=!0){let t=J.useContext(YR);if(t===void 0&&!e)throw Error(qv(25));return t}var ZR=J.createContext(null);function QR(e=`root`){let t=J.useContext(ZR),n=J.useContext(qR);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var $R={visible:!0,ref:null};function ez(){return $R}function tz(e,t,n=`root`){let r=QR(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??ez)({label:e.label,children:e.children,render:e.render}),a=ny(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var nz=J.createContext(void 0);function rz(){let e=J.useContext(nz);if(e===void 0)throw Error(qv(30));return e}function iz(e){e.preventDefault()}function az(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=JR(),u=XR(!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 J.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?iz: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:nx})},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&&!Yy&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Qv(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var oz={type:`regular-item`};function sz(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=J.useRef(null),{getButtonProps:d,buttonRef:f}=$v({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=az({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=J.useCallback(e=>Nv(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=ny(u,f);return J.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var cz=`data-checked`,lz=`data-unchecked`,uz={checked(e){return e?{[cz]:``}:{[lz]:``}},...bb},dz=J.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}=JR(),m=sk({guess:!0,label:a}),h=FE(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}=sz({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:oz}),C=J.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=Yb(nx,e.nativeEvent,void 0,{preventUnmountOnClose:dy});u?.(!l,t)}let T=_y(`div`,e,{state:C,stateAttributesMapping:uz,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,Y.jsx)(nz.Provider,{value:C,children:T})}),fz=J.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=UO({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=tz(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,Y.jsx)(dz,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),pz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=rz(),c=J.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=$C(s.checked);return iw({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),_y(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:uz,props:{"aria-hidden":!0,...o},enabled:a||u})}),mz=J.createContext(void 0);function hz(){let e=J.useContext(mz);if(e===void 0)throw Error(qv(31));return e}var gz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=J.useState(void 0),c=_y(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Y.jsx)(mz.Provider,{value:s,children:c})}),_z=J.forwardRef(function(e,t){let n=QR()?.Group??gz;return(0,Y.jsx)(n,{...e,ref:t})}),vz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=FE(a),c=hz();return Q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),_y(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),yz=J.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}=JR(),f=sk({guess:!0,label:a}),p=FE(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}=sz({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:oz});return _y(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),bz=J.forwardRef(function(e,t){let n=tz(e,t);return n.visible?(0,Y.jsx)(yz,{...e,ref:n.ref}):null}),xz=J.createContext(void 0);function Sz(){return J.useContext(xz)}function Cz(e,t){let n=xy(e.render);if(J.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function wz(e,t,n){let r=Cz(e,t),i=r===t?void 0:r;return[r,J.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Tz(e,t,n){let r=xy(e.render),i=J.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 Ez=J.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}=JR(),m=Sz(),{side:h,align:g}=KR(),_=XM(!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]=wz(e,u,d),L=Tz(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),iw({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),J.useEffect(()=>{function e(e){l.setOpen(!1,Yb(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Qw(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let B=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:V,handleFocus:te}=(J.useContext(ZR)?.useParentHandoff??Oz)(l,w,v,f),H=_y(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,B,I],stateAttributesMapping:Pb,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&Ck.has(e.key)&&e.stopPropagation()},onFocus:te},iD(y),c,{"data-rootownerid":E}]}),U=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(U=!0);let ne=R?.getReturnElement??V;return(0,Y.jsx)(MC,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??ne??U,explicitReturnFocus:a===void 0&&ne?!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:H})}),Dz={parentVirtualFocusRef:void 0,handleFocus:void 0};function Oz(){return Dz}var kz=J.forwardRef(function(e,t){let n=QR()?.Popup??Ez;return(0,Y.jsx)(n,{...e,ref:t})}),Az=J.createContext(void 0);function jz(){let e=J.useContext(Az);if(e===void 0)throw Error(qv(32));return e}var Mz=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=JR();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Y.jsx)(Az.Provider,{value:n,children:(0,Y.jsx)(pC,{ref:t,...r,portalOwnerRole:o})})}),Nz=J.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=aC,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=JR(),x=jz(),S=XR(!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,B=l,V=s,te=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,V??=`start`,!o&&V!==`center`&&(B=e.alignOffset??2,z=e.sideOffset??-5));let H=o,U=V;C.type===`menu`?(H??=`inline-end`,U??=`start`,te=e.collisionAvoidance??oC):C.type===`menubar`&&(H??=C.context.orientation===`vertical`?`inline-end`:`bottom`,U??=`start`);let ne=C.type===`context-menu`,re=tD({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:H,sideOffset:z,align:U,alignOffset:B,arrowPadding:ne?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:te,shift:ne?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});J.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Yb(ux)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),J.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,Yb(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ie=zy();J.useEffect(()=>{D||ie.clear()},[D,ie]),J.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?ie.isStarted()||ie.start(e,()=>{v.setOpen(!1,Yb(ux))}):v.setOpen(!1,Yb(ux))}else ie.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ie]),J.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),EN({store:v,domReference:R,positionerElement:M,open:D});let ae={open:D,side:re.side,align:re.align,anchorHidden:re.anchorHidden,nested:C.type===`menu`,instant:N},oe=C.type===`menubar`&&C.context.modal;ON(D&&(oe||O&&F!==`trigger-hover`),k===`touch`,M,A);let W=aD(e,ae,{styles:re.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),se=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),ce=null;return C.type===`menubar`?ce=C.context.contentElement:C.type===void 0&&(ce=A),(0,Y.jsxs)(GR.Provider,{value:re,children:[se&&(0,Y.jsx)(Dj,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:cD(!D),cutout:ce}),(0,Y.jsx)(xC,{id:I,children:(0,Y.jsx)(KO,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:W})})]})}),Pz=J.createContext(void 0);function Fz(){let e=J.useContext(Pz);if(e===void 0)throw Error(qv(34));return e}var Iz=J.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]=J.useState(void 0),[p,m]=UO({controlled:i,default:a,name:`MenuRadioGroup`}),h=Z((e,t)=>{o?.(e,t),!t.isCanceled&&m(e)}),g=_y(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=J.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return(0,Y.jsx)(mz.Provider,{value:f,children:(0,Y.jsx)(Pz.Provider,{value:_,children:g})})}),Lz=J.memo(J.forwardRef(function(e,t){let n=QR()?.RadioGroup??Iz;return(0,Y.jsx)(n,{...e,ref:t})})),Rz=J.createContext(void 0);function zz(){let e=J.useContext(Rz);if(e===void 0)throw Error(qv(35));return e}var Bz=J.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}=JR(),{value:p,setValue:m,disabled:h}=Fz(),g=sk({guess:!0,label:a}),_=FE(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}=sz({closeOnClick:c,disabled:S,highlighted:v,id:_,store:f,nativeButton:o,nodeId:y,itemMetadata:oz}),E=J.useMemo(()=>({disabled:S,highlighted:v,checked:C}),[S,v,C]);function D(e){let t=Yb(nx,e.nativeEvent,void 0,{preventUnmountOnClose:dy});m(l,t)}let O=_y(`div`,e,{state:E,stateAttributesMapping:uz,props:[b,{role:`menuitemradio`,"aria-checked":C,onClick:D},d,w],ref:[T,t,g.ref]});return(0,Y.jsx)(Rz.Provider,{value:E,children:O})}),Vz=J.forwardRef(function(e,t){let n=tz(e,t);return n.visible?(0,Y.jsx)(Bz,{...e,ref:n.ref}):null}),Hz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=zz(),c=J.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=$C(s.checked);return iw({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),_y(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:uz,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),Uz=J.createContext(null);function Wz(e){let t=J.useContext(Uz);if(t===null&&!e)throw Error(qv(5));return t}function Gz(e){return e==null?Zb:e.type.startsWith(`key`)?sx:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?cx:Zb}var Kz={...Hw,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=Hw.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Zy&&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`&&!Hw.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 Nw{constructor(e,t,n=!1){let r=new bw,i=Yz(r,t,n,e);super(i,Jz(r),Kz),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 Jz(e){return{positionerRef:J.createRef(),popupRef:J.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:J.createRef(),beforeTriggerFocusGuardRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Yz(e,t,n=!1,r){return{...Iw(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:py,inputProps:py,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new hC,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:py,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Xz=J.createContext(null);function Zz(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Qz(e,t){return e===`list-navigation`||Zz(e,t)}var $z=Ny(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=XR(!0),C=JR(!0),w=Wz(!0),T=C?.store,E=C?.virtualFocus??!1,D=J.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=FE(),k=FE(),[A,j]=J.useState(void 0),M=(A??k)||void 0,N=vC(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=Ev(()=>F?P?.state.instantType:void 0).current,L=Ev(()=>{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=bC(R),z=L.useState(`open`),B=L.useState(`activeTriggerElement`),V=L.useState(`positionerElement`),te=L.useState(`hoverEnabled`),H=L.useState(`disabled`),U=L.useState(`lastOpenChangeReason`),ne=L.useState(`parent`),re=L.useState(`activeIndex`),ie=L.useState(`keyboardOpen`),ae=L.useState(`payload`),oe=L.useState(`floatingParentNodeId`),W=J.useRef(null),se=J.useRef(ne.type!==`context-menu`),ce=zy(),le=J.useRef(!0),ue=zy(),de=oe!=null,{openMethod:fe,triggerProps:pe}=Zj(z);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:ne.type===void 0?c:void 0,openMethod:fe,rootId:O}),gw(L);let{forceUnmount:me,transitionStatus:he}=_w(z,L,()=>{L.set(`allowMouseEnter`,!1)},F),ge=rw(L.context.popupRef);J.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!z){e();return}if(he!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return ge(e,t.signal),()=>{t.abort()}},[I,z,he,ge,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,B,L]),J.useEffect(()=>{z||(W.current=null),ne.type===`context-menu`&&(z?ce.start(500,()=>{se.current=!0}):(ce.clear(),se.current=!1))},[ce,z,ne.type]),Q(()=>{!z&&!te&&L.set(`hoverEnabled`,!0)},[z,te,L]);let _e=Z((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||z===e&&t.trigger===B&&U===n)return;let i=pw(t);if(!e&&t.trigger==null&&(t.trigger=B??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`&&!le.current)return;e&&n===`trigger-focus`?(le.current=!1,ue.start(300,()=>{le.current=!0})):(le.current=!0,ue.clear());let o=!e&&(n===`escape-key`||n==null);W.current=t.event;let s=fw(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Qz(n,a),s.instantType=ne.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:Zz(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),ve=QC({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:_e}),ye=ve.context.events;Q(()=>{let e=({open:e,eventDetails:t})=>_e(e,t);return ye.on(`setOpen`,e),()=>{ye?.off(`setOpen`,e)}},[ye,_e]),Q(()=>L.subscribeToParentMenu(),[L]);let be=J.useCallback(()=>{L.setOpen(!1,Yb(mx))},[L]);J.useImperativeHandle(d,()=>({unmount:me,close:be}),[me,be]);let xe;ne.type===`context-menu`&&(xe=ne.context),J.useImperativeHandle(xe?.positionerRef,()=>V,[V]),J.useImperativeHandle(xe?.actionsRef,()=>({setOpen:_e}),[_e]);let Se=zC(ve,{enabled:!H,bubbles:{escapeKey:f&&ne.type===`menu`},outsidePress(){return ne.type!==`context-menu`||W.current?.type===`contextmenu`||se.current},externalTree:de?R:void 0}),Ce=VE(),we=sT(ve,{enabled:!H,listRef:L.context.itemDomElements,activeIndex:re,virtual:v,nested:ne.type===`menubar`||!v&&ne.type!==void 0,parentOrientation:ne.type===`menubar`?ne.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?ie:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Ce===`rtl`,disabledIndices:fy,onNavigate(e,t){L.setActiveIndex(e,Gz(t),t?.nativeEvent)},openOnArrowKeyDown:ne.type!==`context-menu`&&!(v&&_),externalTree:!v&&de?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Te=J.useCallback(e=>{L.context.typingRef.current=e},[L]),Ee=cT(ve,{enabled:!H&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:re,resetMs:500,onMatch:(e,t)=>{z&&e!==re&&L.setActiveIndex(e,sx,t.nativeEvent)},onTyping:Te}),De=Z(a),Oe=J.useRef(-1),ke=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(Oe.current===n&&L.context.reportedItem===t)return;Oe.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Zb,L.context.highlightEvent=void 0,a&&De(t,Xb(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});Q(()=>{ke()},[re,ke]);let Ae=J.useMemo(()=>{if(!v)return we.reference;if(!we.trigger)return py;let{onFocus:e,...t}=we.trigger;return t},[v,we.reference,we.trigger]);L.useSyncedValue(`inputProps`,v?we.reference??py:py);let je=J.useMemo(()=>{let e=Nv(Ee.reference,Ae,Se.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},pe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=z,e},[L,Ee.reference,Ae,Se.reference,pe,z]),Me=J.useMemo(()=>{let e=Nv(we.trigger,Se.trigger,pe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[we.trigger,Se.trigger,pe]);Ev(()=>(L.update({inactiveTriggerProps:Me}),null)),vw(L,{floatingRootContext:ve,activeTriggerProps:je,inactiveTriggerProps:Me,popupProps:J.useMemo(()=>Nv(ow,{onMouseMove(){L.set(`allowMouseEnter`,!0),ne.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)}},Ee.floating,we.floating,Se.floating),[ne.type,L,Ee.floating,we.floating,Se.floating]),itemProps:we.item??py});let Ne=J.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:ke}),[L,D,u,l,b,k,v,E,ke]),Pe=typeof t==`function`?t({payload:ae}):t,Fe=(0,Y.jsxs)(qR.Provider,{value:Ne,children:[p&&(0,Y.jsx)(lw,{handle:p,store:L}),Pe]});return(ne.type===void 0||ne.type===`context-menu`)&&(Fe=(0,Y.jsx)(SC,{externalTree:R,children:Fe})),Fe});function eB(e){let t=J.useContext(Xz);if(t===null)return(0,Y.jsx)($z,{...e});let n=t.Root;return(0,Y.jsx)(Xz.Provider,{value:null,children:(0,Y.jsx)(n,{...t.options,...e})})}var tB=5;function nB(e,t){let n=rB(t);return e.clientX>=n.left-tB&&e.clientX<=n.right+tB&&e.clientY>=n.top-tB&&e.clientY<=n.bottom+tB}function rB(e){let t=e.getBoundingClientRect(),n=tv(e);if($y)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 iB(e){if(av(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!_v(e))return iB(bv(e))}function aB(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=J.useRef(!1);return J.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Zv(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:py,[t,n,r])}var oB=Py(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=JR(!0),h=Uw(d)??m?.store;if(!h)throw Error(qv(85));let g=FE(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=J.useRef(null),S=cB(),C=Yv(!0),w=yC(),T=J.useMemo(()=>w??new hC,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=hw(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:bC(T),floatingParentNodeId:vC(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=$v({disabled:A,native:o});J.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=J.useRef(null),P=zy(),F=Z(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;sb(N.current,t)||sb(h.select(`positionerElement`),t)||t===N.current||(t==null||iB(t)!==h.select(`rootId`))&&(nB(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:lx}))});J.useEffect(()=>{let e=Zv(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=eT(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:gT({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=sB(y,h.select(`lastOpenChangeReason`)),ee=NC(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Kw(v,{enabled:!A&&I}),B=aB({open:y,enabled:O,mouseDownAction:`open`}),V=J.useMemo(()=>Nv(z.reference,ee.reference),[z.reference,ee.reference]),te=h.useState(`triggerProps`,D),H=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:U,handleFocusTargetFocus:ne}=yN(h,x),re={disabled:A,open:y},ie=[N,t,M,E,x],ae=[V,L??py,te,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Zv(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},H,O?{role:`menuitem`}:{},B,p,j],oe=_y(`button`,e,{enabled:!O,stateAttributesMapping:Mb,state:re,ref:ie,props:ae});return O?(0,Y.jsx)(qM,{tag:`button`,render:n,className:r,style:i,state:re,refs:ie,props:ae,stateAttributesMapping:Mb}):y?(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(jx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:U},`${g}-pre-focus-guard`),(0,Y.jsx)(J.Fragment,{children:oe},g),(0,Y.jsx)(jx,{ref:h.context.triggerFocusTargetRef,onFocus:ne},`${g}-post-focus-guard`)]}):(0,Y.jsx)(J.Fragment,{children:oe},g)});function sB(e,t){let n=zy(),[r,i]=J.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 cB(){let e=Wz(!0);return J.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var lB=J.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return _y(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function uB(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function dB(e){return uB(e?.[0])}function fB(e){return dB(e)?e.flatMap(e=>e.items):e}function pB(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(dB(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 mB(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 QP(e)}function hB(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?QP(e.value):QP(e)}function gB(e,t,n){function r(){return mB(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=fB(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 _B(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Y.jsx)(J.Fragment,{children:gB(r,t,n)},i)),e),[])}function vB({...e}){return(0,Y.jsx)(eB,{"data-slot":`dropdown-menu`,...e})}function yB({...e}){return(0,Y.jsx)(oB,{"data-slot":`dropdown-menu-trigger`,...e})}function bB({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,Y.jsx)(Mz,{children:(0,Y.jsx)(Nz,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,Y.jsx)(kz,{"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 xB({...e}){return(0,Y.jsx)(_z,{"data-slot":`dropdown-menu-group`,...e})}function SB({className:e,inset:t,...n}){return(0,Y.jsx)(vz,{"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 CB({className:e,inset:t,variant:n=`default`,...r}){return(0,Y.jsx)(bz,{"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 wB({className:e,children:t,checked:n,inset:r,...i}){return(0,Y.jsxs)(fz,{"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,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-checkbox-item-indicator`,children:(0,Y.jsx)(pz,{children:(0,Y.jsx)(ng,{})})}),t]})}function TB({...e}){return(0,Y.jsx)(Lz,{"data-slot":`dropdown-menu-radio-group`,...e})}function EB({className:e,children:t,inset:n,...r}){return(0,Y.jsxs)(Vz,{"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,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,Y.jsx)(Hz,{children:(0,Y.jsx)(ng,{})})}),t]})}function DB({className:e,...t}){return(0,Y.jsx)(lB,{"data-slot":`dropdown-menu-separator`,className:X(`-mx-1 my-1 h-px bg-border`,e),...t})}var OB=({option:e,noteId:t})=>(0,Y.jsxs)(EB,{value:e.id,disabled:!e.available,"aria-describedby":e.available?void 0:t,children:[e.modelName,!e.measured&&(0,Y.jsx)(`span`,{className:`rounded-full border px-1.5 text-caption text-muted-foreground`,children:`unmeasured`})]}),kB=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())},AB=({first:e,options:t,separated:n,noteId:r,choice:i})=>{let[a,o]=(0,J.useState)(``),s=zR(t,i.chosen,i.defaultId),c=t.length-s.length,l=BR(t,s,a);return(0,Y.jsxs)(xB,{children:[n&&(0,Y.jsx)(DB,{}),(0,Y.jsxs)(SB,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:e.available?e.via:e.providerName}),!e.available&&(0,Y.jsx)(`span`,{id:r,className:`font-normal`,children:e.reason})]}),s.map(e=>(0,Y.jsx)(OB,{option:e,noteId:r},e.id)),c>0&&(0,Y.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,Y.jsx)(jF,{value:a,onChange:e=>o(e.target.value),onKeyDown:kB,placeholder:`Filter ${c} more models`,"aria-label":`Filter ${c} more models through ${e.via}`,className:`h-7`})}),l.map(e=>(0,Y.jsx)(OB,{option:e,noteId:r},e.id)),c>0&&a.trim()!==``&&l.length===0&&(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,children:`No model matches`})]})},jB=({choice:e,disabled:t,variant:n,size:r=`sm`})=>{let i=(0,J.useId)();return(0,Y.jsxs)(vB,{children:[(0,Y.jsx)(yB,{render:(0,Y.jsx)($,{variant:n,size:r,"data-slot":`model-menu`,disabled:t,"aria-label":e.chosen===null?`Choose a model`:`Model: ${e.chosen.modelName}`,className:X(`rounded-l-none px-0`,r===`sm`?`w-6`:`w-7`,n==="default"&&`border-l-primary-foreground/30`,n===`outline`&&`border-l-0`,n.startsWith(`ai`)&&`border-l-primary/30`)}),children:(0,Y.jsx)(ig,{"aria-hidden":`true`})}),(0,Y.jsx)(bB,{align:`start`,className:`w-80`,children:(0,Y.jsx)(TB,{value:e.chosen?.id??null,onValueChange:t=>e.choose(t),children:RR(e.options).map(([t,n],r)=>(0,Y.jsx)(AB,{first:t,options:n,separated:r>0,noteId:`${i}-${r}`,choice:e},t.id))})})]})},MB={is:`idle`},NB=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`,PB=(e,t)=>{let[n,r]=(0,J.useState)(t);return(0,J.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))},FB=async({choice:e,run:t,now:n=Date.now,onPhase:r})=>{r({is:`running`,since:n()});let i=await t(e.chosen?.id);r(i.ok?{is:`done`,said:i.said}:{is:`failed`,...i})},IB=({choice:e,what:t=`Runs`})=>e.locked??(e.chosen===null?null:`${t} ${e.chosen.modelName} through ${e.chosen.via}`),LB=e=>{let t=(0,J.useId)(),{label:n,icon:r,choice:i,phase:a}=e,o=a.is===`running`,s=IB(e);return(0,Y.jsxs)(`span`,{"data-slot":`model-action`,className:`flex shrink-0 items-center`,children:[(0,Y.jsxs)(YL,{disabled:s===null,children:[(0,Y.jsxs)(XL,{render:(0,Y.jsx)($,{variant:`ai-quiet`,disabled:o||i.locked!==null||i.chosen===null,focusableWhenDisabled:!0,"aria-busy":o,"aria-describedby":s===null?void 0:`${t}-note`,onClick:()=>void FB(e),className:`rounded-r-none`}),children:[o?(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:oL}):i.locked===null?r:(0,Y.jsx)(e_,{"aria-hidden":`true`}),n]}),(0,Y.jsxs)(ZL,{side:`bottom`,align:`end`,children:[i.locked!==null&&(0,Y.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),s]})]}),(0,Y.jsx)(jB,{choice:i,disabled:o||i.options.length===0,variant:`ai-quiet`,size:`default`}),s!==null&&(0,Y.jsx)(`span`,{id:`${t}-note`,hidden:!0,children:s})]})},RB=e=>{let{running:t,now:n=Date.now,phase:r,className:i}=e,a=PB(r.is===`running`?r.since:null,n);return r.is===`idle`?null:(0,Y.jsx)(`p`,{role:r.is===`failed`?`alert`:`status`,"data-slot":`model-action-status`,className:X(`flex min-w-0 flex-wrap items-center gap-x-2 text-caption`,r.is===`failed`?`text-destructive`:`text-muted-foreground`,i),children:r.is===`running`?(0,Y.jsxs)(Y.Fragment,{children:[t,` `,(0,Y.jsx)(`span`,{className:`tabular`,children:NB(a)})]}):r.is===`done`?r.said:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),r.message]}),(0,Y.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:()=>void FB(e),children:`Try again`})]})})},zB={"look-for":{label:`Look for`,icon:g_},"dont-flag":{label:`Don't flag`,icon:Qh}},BB=({kind:e,className:t})=>{let{label:n,icon:r}=zB[e];return(0,Y.jsxs)(`span`,{"data-slot":`preference-kind`,"data-kind":e,className:X(`inline-flex h-[22px] shrink-0 items-center gap-[5px] rounded-md border bg-secondary pr-2 pl-[7px] text-caption font-medium whitespace-nowrap text-secondary-foreground`,t),children:[(0,Y.jsx)(r,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`}),n]})},VB={kind:`global`},HB=({owner:e,repo:t})=>`${e}/${t}`,UB=({host:e,owner:t,repo:n})=>`${e}/${t}/${n}`,WB=e=>e.kind===`global`?`global`:UB(e.repo),GB=e=>[{key:WB(VB),label:`Everywhere`,scope:VB},...e.map(t=>{let n=e.some(e=>e!==t&&HB(e)===HB(t));return{key:UB(t),label:n?`${HB(t)} on ${iL[t.host]}`:HB(t),scope:{kind:`repo`,repo:t}}})],KB=({scope:e,className:t})=>e.kind===`global`?(0,Y.jsx)(Rg,{"aria-hidden":`true`,className:X(`size-[15px] shrink-0`,t)}):(0,Y.jsx)(WR,{host:e.repo.host,className:t}),qB=(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]}),JB=(e,t)=>({...e,preferences:e.preferences.filter(e=>e.id!==t)}),YB=(e,t)=>({...e,proposals:[...e.proposals,...t.filter(t=>!e.proposals.some(e=>e.id===t.id))]}),XB=(e,t)=>({...e,proposals:e.proposals.filter(e=>e.id!==t)}),ZB=(e,t,n,r)=>({...e,repositories:e.repositories.map(e=>hu(e.repo,t)&&e.guidelineFiles!==null?{...e,guidelineFiles:e.guidelineFiles.map(e=>e.path===n?{...e,enabled:r}:e)}:e)}),QB=(e,t)=>e.preferences.filter(e=>gu(e.scope,t)),$B=(e,t)=>e.proposals.filter(e=>gu(e.scope,t)),eV=(e,t)=>t.kind===`repo`&&QB(e,t).length===0&&$B(e,t).length===0,tV=`suggestions`,nV=(e,t)=>{if(e===`suggestions`)return{kind:`suggestions`};let n=t.find(t=>t.key===e)??t.find(e=>e.key===WB(VB))??t[0];return n===void 0?{kind:`suggestions`}:{kind:`scope`,option:n}},rV=(e,t)=>t.map(t=>({option:t,proposals:$B(e,t.scope)})).filter(e=>e.proposals.length>0),iV=new Intl.ListFormat(`en`,{type:`conjunction`}),aV=(e,t)=>{let n=t.map(t=>({label:t.label,count:e.filter(e=>gu(e.scope,t.scope)).length})).filter(e=>e.count>0),[r]=n;return n.length===1&&r!==void 0?`for ${r.label}`:iV.format(n.map(({count:e,label:t})=>`${e} for ${t}`))},oV=(e,t,n)=>{let r=[...e.comments>0?[`${fV(e.comments,`comment`)} from ${fV(e.pullRequests,`pull request`)}`]:[],...e.signals>0?[`${fV(e.signals,`action`)} recorded here`]:[]];if(r.length===0)return e.pullRequests===0?`Found nothing to suggest from: no comment of yours on its pull requests, and nothing you did here.`:`Found no comment of yours on its last ${fV(e.pullRequests,`pull request`)}, and nothing you did here.`;let i=`Read ${iV.format(r)}`;return t===0?`${i}: nothing new to suggest.`:`${i}: ${fV(t,`suggestion`)}, ${n}.`},sV=(e,t)=>({owner:t.some(t=>t.repo===e.repo&&!hu(t,e))?e.owner:null,name:e.repo}),cV=e=>{let t=[...e.repositories];for(let{scope:n}of[...e.preferences,...e.proposals])n.kind!==`repo`||t.some(e=>hu(e.repo,n.repo))||t.push({repo:n.repo,guidelineFiles:null,guidelineNote:`No pull request of this repository has been analyzed yet`});return t},lV=e=>{if(e<1024)return`${e} B`;let t=e/1024;return`${t<10?t.toFixed(1):Math.round(t)} KB`},uV=e=>{let t=e.trim();return t===``||/[.!?]$/.test(t)?t:`${t}.`},dV=e=>e.code===`bad-request`?uV(e.message):Gp(e),fV=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,pV=`megareviewer looks for ${new Intl.ListFormat(`en`,{type:`disjunction`}).format(ou)}.`,mV=({file:e,onSwitch:t})=>{let[n,r]=(0,J.useState)(null);return(0,Y.jsxs)(`li`,{"data-slot":`guideline-file`,className:`flex min-h-11 flex-wrap items-center gap-x-2.5 gap-y-1 px-4 py-2`,children:[(0,Y.jsx)(Sg,{"aria-hidden":`true`,className:`size-[15px] shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 font-mono text-code-compact break-all`,children:e.path}),(0,Y.jsx)(`span`,{className:`tabular shrink-0 text-caption text-muted-foreground`,children:lV(e.bytes)}),e.tooLarge?(0,Y.jsxs)(`span`,{className:`ml-auto text-caption text-muted-foreground`,children:[`Too large to send: a guideline file can be `,lV(cu)]}):(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)(CF,{checked:e.enabled,"aria-label":`Use ${e.path} in AI reviews`,onCheckedChange:async n=>{r(null),r(await t(e.path,n))}}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`text-caption`,e.enabled?`text-foreground`:`text-muted-foreground`),children:e.enabled?`Followed by AI reviews`:`Ignored`})]}),n!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),n]})]})},hV=()=>{let e=(0,J.useId)();return(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-ui text-muted-foreground`,children:[`None found at the repository's root.`,(0,Y.jsxs)(YL,{children:[(0,Y.jsx)(XL,{render:(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Files megareviewer looks for`,"aria-describedby":e}),children:(0,Y.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5`})}),(0,Y.jsx)(ZL,{side:`right`,children:pV})]}),(0,Y.jsx)(`span`,{id:e,hidden:!0,children:pV})]})},gV=({files:e,note:t,onSwitch:n})=>e===null?(0,Y.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:uV(t??`Couldn't look for them`)}):e.length===0?(0,Y.jsx)(hV,{}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2.5 max-w-[620px] text-ui text-muted-foreground`,children:`At the repository root, read at each pull request's base commit. When a file is on, AI reviews follow it the same way as your preferences; when off, it is ignored.`}),(0,Y.jsx)(`ul`,{"data-slot":`guideline-files`,className:`divide-y overflow-hidden rounded-lg border bg-card`,children:e.map(e=>(0,Y.jsx)(mV,{file:e,onSwitch:n},e.path))})]});function _V(e){let t=J.useRef(!0);t.current&&(t.current=!1,e())}var vV=J.createContext(void 0),yV=J.createContext(void 0);function bV(){let e=J.useContext(vV);if(e===void 0)throw Error(qv(60));return e}function xV(){let e=J.useContext(yV);if(e===void 0)throw Error(qv(61));return e}function SV(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 CV=(e,t)=>Object.is(e,t);function wV(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function TV(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!SV(e,t,(e,t)=>wV(e,t,n)):e!==t}function EV(e,t,n){return e?e.some(e=>e!==void 0&&wV(t,e,n)):!1}function DV(e,t,n){return e?e.findIndex(e=>e!==void 0&&wV(e,t,n)):-1}function OV(e,t){if(t!==CV)return n=>EV(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 kV(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(OV(t,n)):DV(e,t,n);return i===-1?null:i}function AV(e,t,n,r,i,a){return EV(r,t,i)?a!=null&&e>a&&EV(r,n[a],i)?a:e:e===a?kV(n,r,i,!0):a}function jV(e,t,n){return e.filter(e=>!wV(t,e,n))}var MV={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:hB(t,r)!==``},hasNullItemLabel:(e,t)=>t?pB(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=>wV(t,e,n)):wV(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 NV(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=CV,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=rF(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=BP(),F=YP({id:t}),I=M||d,L=j??c,[R,ee]=UO({controlled:n,default:y?r??fy:r,name:`Select`,state:`value`}),[z,B]=UO({controlled:a,default:o,name:`Select`,state:`open`}),V=J.useRef([]),te=J.useRef([]),H=J.useRef(null),U=J.useRef(null),ne=J.useRef(0),re=J.useRef(null),ie=J.useRef([]),ae=J.useRef(!1),oe=J.useRef(null),W=J.useRef(null),se=J.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ce=J.useRef(!1),le=J.useRef(R),{openMethod:ue,triggerProps:de}=Zj(z),fe=Ev(()=>new Nw({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:py,triggerProps:py,itemRoot:{props:py,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:dy,setOpen:dy,handleScrollArrowVisibility:dy,onOpenChangeComplete:dy,listRef:V,popupRef:H,scrollHandlerRef:U,scrollArrowsMountedCountRef:ne,valueRef:re,valuesRef:ie,labelsRef:te,typingRef:ae,selectionRef:se,firstItemTextRef:oe,selectedItemTextRef:W,alignItemWithTriggerActiveRef:ce,initialValueRef:le},MV)).current,[pe,me]=J.useState(!1),{mounted:he,transitionStatus:ge,forceUnmount:_e}=aw({open:z,ref:H,preventUnmountOnClose:pe,setPreventUnmountOnClose:me,onUnmount(){fe.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),ve=fe.useState(`activeIndex`),ye=fe.useState(`selectedIndex`),be=fe.useState(`triggerElement`),xe=fe.useState(`positionerElement`),Se=lD(ue),Ce=ue??Se,we=J.useMemo(()=>y?``:hB(R,x),[y,R,x]),Te=J.useMemo(()=>y&&Array.isArray(R)?R.map(e=>hB(e,x)):hB(R,x),[y,R,x]);tF(Sx(be),F,R,Z(()=>Te),!I,c);let Ee=y?Array.isArray(R)&&R.length>0:R!=null&&we!==``;Q(()=>{A(Ee)},[Ee,A]),Q(function(){let e=kV(ie.current,R,S,y);e===null&&(W.current=null),!z&&fe.set(`selectedIndex`,e)},[y,z,R,S,fe]),Yj(R,()=>{T(L),E(TV(R,k.initialValue,S)),N.change(R)});let De=Z((e,t)=>{let n=t,r=pw(n);s?.(e,n),!t.isCanceled&&(e||me(r()),B(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))});J.useImperativeHandle(h,()=>({unmount:_e,close:()=>{fe.state.open&&De(!1,Yb(mx))}}),[_e,De,fe]);let Oe=Z((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),ke=Z(e=>{let t=nI(e.scrollHeight,e.clientHeight),n=rI(e.scrollTop,t),r=n>0,i=n<t;fe.set(`scrollUpArrowVisible`,r),fe.set(`scrollDownArrowVisible`,i)}),Ae=Ww({open:z,onOpenChange:De,elements:{reference:be,floating:xe}}),je=NC(Ae,{enabled:!I,event:`mousedown`}),Me=zC(Ae),Ne=sT(Ae,{enabled:!I,listRef:V,activeIndex:ve,selectedIndex:ye,disabledIndices:fy,onNavigate(e){(e!==null||z)&&fe.set(`activeIndex`,e)},focusItemOnHover:C}),Pe=cT(Ae,{enabled:!I&&(z||!f&&!y),listRef:te,activeIndex:ve,selectedIndex:ye,disabledIndices:e=>vk(V.current[e]),onMatch(e){z?fe.set(`activeIndex`,e):Oe(ie.current[e],Yb(Zb))},onTyping(e){ae.current=e}}),Fe=J.useMemo(()=>Nv(Pe.reference,Ne.reference,Me.reference,je.reference,de),[je.reference,Pe.reference,Ne.reference,Me.reference,de]),Ie=J.useMemo(()=>Nv(ow,Pe.floating,Ne.floating,Me.floating),[Pe.floating,Ne.floating,Me.floating]),Le=Ne.item??py,Re=J.useMemo(()=>({props:Le,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S}),[Le,y,I,f,S]);fe.useContextCallback(`setValue`,Oe),fe.useContextCallback(`setOpen`,De),fe.useContextCallback(`handleScrollArrowVisibility`,ke),fe.useContextCallback(`onOpenChangeComplete`,_),_V(()=>{fe.update({popupProps:Ie,triggerProps:Fe,itemRoot:Re})}),fe.useSyncedValues({id:F,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,value:R,open:z,mounted:he,transitionStatus:ge,popupProps:Ie,triggerProps:Fe,itemRoot:Re,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Ce});let ze=ny(g,N.inputRef),Be=y?void 0:L,Ve=J.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=hB(e,x);return(0,Y.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,Y.jsxs)(vV.Provider,{value:fe,children:[(0,Y.jsx)(yV.Provider,{value:Ae,children:w}),(0,Y.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){fe.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Yb(Zb,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ie.current.findIndex(t=>hB(t,x).toLowerCase()===e||mB(t,b).toLowerCase()===e);r===-1&&(r=ie.current.findIndex((t,n)=>{let r=te.current[n];return r!=null&&r.toLowerCase()===e}));let i=ie.current[r];i!=null&&Oe(i,n)}fe.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Be==null?`${F}-hidden-input`:void 0,form:l,name:Be,autoComplete:u,value:we,disabled:I,required:p&&!(y&&Ee),readOnly:f,ref:ze,style:L?Ax:kx,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ve]})}function PV(e,t){return e??t}var FV=`data-popup-side`,IV=400,LV={...Mb,...PP,popupSide:e=>e?{[FV]:e}:null,value:()=>null},RV=J.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}=BP(),{labelId:m}=GP(),h=bV(),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=PV(m,O);YP({id:i});let N=Sx(w),P=J.useRef(null),F=VP(y,P),{getButtonProps:I,buttonRef:L}=$v({disabled:y,native:o}),R=h.useStateSetter(`triggerElement`),ee=zy(),z=zy(),B=zy();J.useEffect(()=>{if(b)return B.start(IV,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{B.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[b,h,z,B]);let V=Nv(C,{id:j,role:`combobox`,"aria-expanded":b,"aria-haspopup":`listbox`,"aria-controls":b?T?.id??Ub(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,Yb(Zb,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){sb(w,e.relatedTarget)||(l(!0),F(!1),u===`onBlur`&&d.commit(S))},onMouseDown(e){if(b)return;let t=Zv(e.currentTarget);function n(e){if(!P.current)return;let t=e.target;sb(P.current,t)||sb(N.current,t)||nB(e,P.current)||h.context.setOpen(!1,Yb(lx,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),te=d.getValidationProps(y,V);te.role=`combobox`;let H={...f,open:b,disabled:y,value:S,readOnly:g,popupSide:A,placeholder:!k};return _y(`button`,e,{ref:[t,P,L,R],state:H,stateAttributesMapping:LV,props:te})}),zV={value:()=>null},BV=J.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=bV(),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)?_B(l,u,d):gB(l,u,d)),_y(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:zV})}),VV=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return _y(`span`,e,{state:{open:bV().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:jb})}),HV=J.forwardRef(function(e,t){let n=bV(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Y.jsx)(pC,{ref:t,...e}):null}),UV=J.createContext(void 0);function WV(){let e=J.useContext(UV);if(!e)throw Error(qv(59));return e}function GV(e,t){e&&Object.assign(e.style,t)}var KV={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},qV={position:`fixed`},JV=J.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=aC,style:_,...v}=e,y=bV(),b=xV(),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=J.useRef(null),j=J.useRef(null),[M,N]=J.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),J.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),ON((P||C)&&x,T===`touch`,E,D);let F=tD({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?qV:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};Q(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=aD(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=J.useRef(0),B=Z(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=Yb(Zb);if(t!==0&&!y.state.multiple&&w!==null&&DV(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&DV(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=>DV(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:``};GV(E,e),GV(y.context.popupRef.current,e)}}),V=J.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,Y.jsx)(KO,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:B,children:(0,Y.jsxs)(UV.Provider,{value:V,children:[S&&C&&(0,Y.jsx)(Dj,{inert:cD(!x),cutout:D}),ee]})})}),YV=`--transform-origin`,XV={...Nb,...bb},ZV=J.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=bV(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=xV(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=WV(),_=XM(!0)!=null,v=VE(),{nonce:y,disableStyleElements:b}=mk(),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=J.useRef(!1),j=J.useRef(!1),M=J.useRef({}),N=Dx(),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=eH(O),i=tH(O.getBoundingClientRect().height,`y`,r),a=Zv(O),o=tv(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=QV(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=$V(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=eI(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=eI(g,0,$V(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});J.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),iw({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,GV(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(YV),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=iH(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=tv(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=Zv(D),c=eH(D),l=nH(D.getBoundingClientRect(),c),d=nH(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=QV(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=nH(n.getBoundingClientRect(),c);T=nH(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=`${eI(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=$V(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),B=(r.visualViewport?.scale??1)!==1&&Zy;if(z||B){GV(O,M.current),g(!1);return}let V=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=$V(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=eI(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(YV,`50% ${i}%`)}(V===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]),J.useEffect(()=>{if(!m||!O||!S)return;let e=tv(O);function t(e){s.context.setOpen(!1,Yb(hx,e))}return bx(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){_&&Ck.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:KV},className:!k&&m?IF.className:void 0},L=_y(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:XV,props:[T,I,iD(E),o]});return(0,Y.jsxs)(J.Fragment,{children:[!b&&IF.getElement(y),(0,Y.jsx)(MC,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function QV(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function $V(e){return nI(e.scrollHeight,e.clientHeight)}function eH(e){return $T.getScale(e)}function tH(e,t,n){return e/n[t]}function nH(e,t){return iS({x:tH(e.x,`x`,t),y:tH(e.y,`y`,t),width:tH(e.width,`x`,t),height:tH(e.height,`y`,t)})}var rH=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function iH(e){let{style:t}=e,n={};for(let[e,r]of rH)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of rH){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var aH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=bV(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=WV(),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:KV},className:u&&d!==`touch`?IF.className:void 0};return _y(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),oH=J.createContext(void 0);function sH(){let e=J.useContext(oH);if(!e)throw Error(qv(57));return e}var cH=J.memo(J.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=J.useRef(null),d=sk({guess:!0,label:o,textRef:u}),f=bV(),{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=J.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=AV(C,a,f.context.valuesRef.current,e,_,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&wV(a,e,_),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,_,f,a]);let T=J.useRef(`mouse`),E=J.useRef(!1),{getButtonProps:D,buttonRef:O}=$v({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?jV(n,a,_):[...n,a];f.context.setValue(r,Yb(nx,e))}else f.context.setValue(a,Yb(nx,e)),f.context.setOpen(!1,Yb(nx,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&&nb(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=_y(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=J.useMemo(()=>({selected:x,index:C,textRef:u,selectedByFocus:S}),[x,C,u,S]);return(0,Y.jsx)(oH.Provider,{value:P,children:N})})),lH=J.memo(J.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=J.useRef(null),{transitionStatus:l,setMounted:u}=$C(o),d=_y(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:bb});return iw({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),uH=J.forwardRef(function(e,t){let{selected:n}=sH();return e.keepMounted||n?(0,Y.jsx)(lH,{...e,selected:n,ref:t}):null}),dH=J.memo(J.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=sH(),a=bV(),{render:o,className:s,style:c,...l}=e;return _y(`div`,e,{ref:[J.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),fH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=bV(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=WV(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=zy(),v=c?f:d,{mounted:y,transitionStatus:b,setMounted:x}=$C(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]),iw({open:g,ref:v,onComplete(){g||x(!1)}});let S=_y(`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=nI(e.scrollHeight,e.clientHeight),r=rI(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=pH(a,c,r,e.clientHeight,t,n)}_.start(40,t)}}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:bb});return y||o?S:null});function pH(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?rI(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?rI(l.offsetTop+l.offsetHeight-r+i,a):a}var mH=J.forwardRef(function(e,t){return(0,Y.jsx)(fH,{...e,ref:t,direction:`down`})}),hH=J.forwardRef(function(e,t){return(0,Y.jsx)(fH,{...e,ref:t,direction:`up`})}),gH=J.createContext(void 0);function _H(){let e=J.useContext(gH);if(e===void 0)throw Error(qv(56));return e}var vH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=J.useState(),c=J.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=_y(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,Y.jsx)(gH.Provider,{value:c,children:l})}),yH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=_H(),c=FE(a);return Q(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),_y(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),bH=NV;function xH({className:e,...t}){return(0,Y.jsx)(vH,{"data-slot":`select-group`,className:X(`scroll-my-1 p-1`,e),...t})}function SH({className:e,...t}){return(0,Y.jsx)(BV,{"data-slot":`select-value`,className:X(`flex flex-1 text-left`,e),...t})}function CH({className:e,size:t=`default`,children:n,...r}){return(0,Y.jsxs)(RV,{"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,Y.jsx)(VV,{render:(0,Y.jsx)(ig,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function wH({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,Y.jsx)(HV,{children:(0,Y.jsx)(JV,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,Y.jsxs)(ZV,{"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,Y.jsx)(DH,{}),(0,Y.jsx)(aH,{children:t}),(0,Y.jsx)(OH,{})]})})})}function TH({className:e,...t}){return(0,Y.jsx)(yH,{"data-slot":`select-label`,className:X(`px-1.5 py-1 text-caption text-muted-foreground`,e),...t})}function EH({className:e,children:t,...n}){return(0,Y.jsxs)(cH,{"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,Y.jsx)(dH,{className:`flex flex-1 shrink-0 gap-2 whitespace-nowrap`,children:t}),(0,Y.jsx)(uH,{render:(0,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,Y.jsx)(ng,{className:`pointer-events-none`})})]})}function DH({className:e,...t}){return(0,Y.jsx)(hH,{"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,Y.jsx)(ug,{})})}function OH({className:e,...t}){return(0,Y.jsx)(mH,{"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,Y.jsx)(ig,{})})}var kH=e=>{let t=(0,J.useRef)(null),n=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{e?n.current=!0:n.current&&(n.current=!1,t.current?.focus())},[e]),t},AH=`Write the rule first.`,jH=e=>`${e} ${e===1?`character`:`characters`} over the limit. Keep it to one rule; add another preference for the rest.`,MH=[`look-for`,`dont-flag`],NH={"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 not flag`,example:`Naming`}},PH=({option:e})=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(KB,{scope:e.scope,className:`size-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]}),FH=({legend:e,initial:t,scopes:n,kindFixed:r=!1,inline:i=!1,submit:a,submitting:o,submitIcon:s,focus:c=!1,onSubmit:l,onCancel:u})=>{let d=(0,J.useId)(),[f,p]=(0,J.useState)(t.kind),[m,h]=(0,J.useState)(t.text),[g,_]=(0,J.useState)(WB(t.scope)),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(null),S=(0,J.useRef)(null);(0,J.useEffect)(()=>{c&&S.current!==null&&(S.current.focus(),S.current.setSelectionRange(S.current.value.length,S.current.value.length))},[]);let C=i?{key:WB(t.scope),label:``,scope:t.scope}:n.find(e=>e.key===g)??n[0],w=m.trim().length,T=w-300,E=b??(T>0?jH(T):null),D=w>=250,O=async e=>{if(e.preventDefault(),v||C===void 0||T>0)return;if(w===0){x(AH),S.current?.focus();return}y(!0),x(null);let t=await l({kind:f,text:m.trim(),scope:C.scope});y(!1),x(t),t===null&&h(``)},k=r?(0,Y.jsx)(BB,{kind:f}):(0,Y.jsx)(lF,{"aria-label":`Kind`,value:f,onValueChange:e=>{(e===`look-for`||e===`dont-flag`)&&p(e)},className:`inline-flex w-auto shrink-0 gap-0.5 rounded-md border border-input p-px`,children:MH.map(e=>{let{label:t,icon:n}=zB[e];return(0,Y.jsxs)(uF,{value:e,children:[(0,Y.jsx)(n,{"aria-hidden":`true`}),t]},e)})}),A=(0,Y.jsx)(`label`,{htmlFor:`${d}-text`,className:i?`sr-only`:`text-ui font-medium`,children:NH[f].label}),j=(0,Y.jsx)(Vk,{ref:S,id:`${d}-text`,rows:1,className:X(`resize-none bg-card text-body aria-invalid:focus-visible:outline-destructive`,i?`min-h-8 min-w-0 flex-1 basis-60 py-1`:`min-h-[72px]`),placeholder:NH[f].example,value:m,onChange:e=>{h(e.target.value.replace(/\s*\n\s*/g,` `)),x(null)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"aria-invalid":E!==null,"aria-describedby":D?`${d}-count ${d}-problem`:`${d}-problem`}),M=(0,Y.jsx)(`p`,{id:`${d}-problem`,role:`status`,className:`flex min-w-0 flex-1 basis-60 items-start gap-1.5 text-caption text-destructive`,children:E!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fg,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),E]})}),N=D&&(0,Y.jsxs)(`span`,{id:`${d}-count`,"data-slot":`character-count`,className:X(`tabular shrink-0 text-caption`,T>0?`font-medium text-destructive`:`text-muted-foreground`),children:[w,`/`,300,(0,Y.jsx)(`span`,{className:`sr-only`,children:` characters`})]}),P=(0,Y.jsxs)(Y.Fragment,{children:[u!==void 0&&(0,Y.jsx)($,{type:`button`,variant:`ghost`,onClick:u,children:`Cancel`}),(0,Y.jsxs)($,{type:`submit`,className:`shrink-0`,disabled:v||T>0,focusableWhenDisabled:!0,"aria-busy":v,"aria-describedby":T>0?`${d}-problem`:void 0,children:[s,v?o:a]})]});return(0,Y.jsx)(`form`,{"aria-label":e,"data-slot":`preference-form`,className:X(`flex flex-col`,!i&&`gap-3`),onSubmit:e=>void O(e),noValidate:!0,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[k,A,j,P]}),(0,Y.jsxs)(`div`,{className:X(`flex items-start justify-end gap-3`,(E!==null||D)&&`mt-1.5`),children:[M,N]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2`,children:[k,(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{id:`${d}-scope`,className:`shrink-0 text-ui text-muted-foreground`,children:`Applies to`}),C===void 0?null:n.length>1?(0,Y.jsxs)(bH,{value:C.key,items:n.map(e=>({value:e.key,label:e.label})),onValueChange:e=>{typeof e==`string`&&_(e)},children:[(0,Y.jsx)(CH,{className:`max-w-80 min-w-0`,"aria-labelledby":`${d}-scope`,children:(0,Y.jsx)(SH,{children:()=>(0,Y.jsx)(PH,{option:C})})}),(0,Y.jsx)(wH,{alignItemWithTrigger:!1,align:`start`,children:n.map(e=>(0,Y.jsx)(EH,{value:e.key,label:e.label,children:(0,Y.jsx)(PH,{option:e})},e.key))})]}):(0,Y.jsx)(PH,{option:C})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,j]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-2`,children:[M,N,P]})]})})},IH=({title:e,onClose:t,children:n,className:r,returnFocus:i=()=>!0})=>{let a=(0,J.useRef)(null);return(0,Y.jsx)(Qj,{open:!0,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(tM,{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,Y.jsx)(nM,{className:`shrink-0 pr-8`,children:(0,Y.jsx)(rM,{children:e})}),n]})})},LH=({preference:e,onDelete:t,onClose:n})=>{let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(null);return(0,Y.jsxs)(IH,{title:`Delete preference`,onClose:n,children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(BB,{kind:e.kind}),(0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}),(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:n,children:`Cancel`}),(0,Y.jsx)($,{variant:`destructive`,disabled:r,onClick:async()=>{i(!0);let e=await t();i(!1),o(e),e===null&&n()},children:r?`Deleting…`:`Delete`})]})]})},RH=({preference:e,scopes:t,actions:n})=>{let[r,i]=(0,J.useState)(`shown`),[a,o]=(0,J.useState)(null),s=kH(r===`editing`),{id:c,kind:l,text:u,source:d,enabled:f}=e;return r===`editing`?(0,Y.jsx)(`li`,{className:`px-4 py-3`,children:(0,Y.jsx)(FH,{legend:`Edit: ${u}`,initial:e,scopes:t,submit:`Save`,submitting:`Saving…`,focus:!0,onCancel:()=>i(`shown`),onSubmit:async e=>{let t=await n.onEdit(c,e);return t===null&&i(`shown`),t}})}):(0,Y.jsxs)(`li`,{"data-slot":`preference`,"data-enabled":f,className:`flex flex-wrap items-start gap-x-3 gap-y-1 px-4 py-2.5`,children:[(0,Y.jsx)(BB,{kind:l,className:`min-w-[98px]`}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-56 text-body break-words`,!f&&`text-muted-foreground`),children:u}),(0,Y.jsxs)(`span`,{className:`-my-[3px] ml-auto flex shrink-0 items-center gap-2`,children:[d!==`written`&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3 text-primary`}),`From your reviews`]}),!f&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`off`}),(0,Y.jsx)(CF,{checked:f,"aria-label":`Use in AI reviews: ${u}`,onCheckedChange:async e=>{o(null),o(await n.onSwitch(c,e))}}),(0,Y.jsxs)(`span`,{className:`flex gap-0.5`,children:[(0,Y.jsx)($,{ref:s,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Edit: ${u}`,onClick:()=>i(`editing`),children:(0,Y.jsx)(o_,{"aria-hidden":`true`,className:`size-3.5`})}),(0,Y.jsx)($,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Delete: ${u}`,onClick:()=>i(`deleting`),children:(0,Y.jsx)(A_,{"aria-hidden":`true`,className:`size-3.5`})})]})]}),a!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),a]}),r===`deleting`&&(0,Y.jsx)(LH,{preference:e,onDelete:()=>n.onDelete(c),onClose:()=>i(`shown`)})]})},zH=({preferences:e,scopes:t,actions:n,label:r})=>(0,Y.jsx)(`ul`,{"aria-label":r,className:`divide-y overflow-hidden rounded-lg border bg-card`,children:e.map(e=>(0,Y.jsx)(RH,{preference:e,scopes:t,actions:n},e.id))}),BH=({proposal:e,scopes:t,actions:n})=>{let{id:r,kind:i,text:a,evidence:o}=e,[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),p=async e=>{if(l!==null)return;if(e===`accept`&&a.length>300)return c(!0);u(e),f(null);let t=await(e===`accept`?n.onAccept(r,null):n.onReject(r));u(null),f(t)};return s?(0,Y.jsx)(`li`,{className:`bg-card px-4 py-3`,children:(0,Y.jsx)(FH,{legend:`Cut the suggestion to fit: ${a}`,initial:e,scopes:t,submit:`Add`,submitting:`Adding…`,submitIcon:(0,Y.jsx)(ng,{"aria-hidden":`true`}),focus:!0,onCancel:()=>c(!1),onSubmit:e=>n.onAccept(r,e)})}):(0,Y.jsxs)(`li`,{"data-slot":`proposal`,className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-4 py-2.5`,children:[(0,Y.jsx)(BB,{kind:i,className:`min-w-[98px]`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,Y.jsx)(`p`,{className:`text-body break-words`,children:a}),o.length>0&&(0,Y.jsx)(`ul`,{"aria-label":`Based on`,className:`flex flex-col text-caption text-muted-foreground`,children:[...new Set(o)].map(e=>(0,Y.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsxs)($,{variant:`ai-quiet`,size:`sm`,"aria-label":`Add suggestion: ${a}`,"aria-busy":l===`accept`,onClick:()=>void p(`accept`),children:[(0,Y.jsx)(ng,{"aria-hidden":`true`}),l===`accept`?`Adding…`:`Add`]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,className:`text-muted-foreground`,"aria-label":`Dismiss suggestion: ${a}`,"aria-busy":l===`reject`,onClick:()=>void p(`reject`),children:l===`reject`?`Dismissing…`:`Dismiss`})]}),d!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),d]})]})},VH=({proposals:e,scopes:t,actions:n,label:r,fallbackFocus:i})=>{let a=(0,J.useRef)(null),o=()=>(e.length>1?a.current:i.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(0,Y.jsx)(`ul`,{ref:a,tabIndex:-1,"aria-label":r,"data-slot":`suggestions`,className:`divide-y divide-ai-soft-bd overflow-hidden rounded-lg border border-ai-soft-bd bg-ai-soft`,children:e.map(e=>(0,Y.jsx)(BH,{proposal:e,scopes:t,actions:c},e.id))})},HH=({context:e,title:t,host:n,word:r,actions:i})=>(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start gap-x-4 gap-y-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`h2`,{ref:e.heading,id:e.headingId,tabIndex:-1,className:`text-[1.125rem] leading-[1.625rem] font-semibold [overflow-wrap:anywhere]`,children:t}),n!==void 0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,Y.jsx)(WR,{host:n,className:`size-3`}),iL[n]]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:r})]}),i]}),UH=({title:e,count:t=0,icon:n,children:r})=>{let i=(0,J.useId)();return(0,Y.jsxs)(`section`,{"aria-labelledby":i,className:`mt-7`,children:[(0,Y.jsxs)(`h3`,{id:i,className:`mb-2 flex items-center gap-1.5 text-caption font-semibold text-muted-foreground`,children:[n,e,t>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{className:`tabular font-medium`,children:t})]})]}),r]})},WH=({context:e,option:t,title:n=`Suggestions from your reviews`,icon:r})=>{let i=$B(e.view,t.scope);return i.length===0?null:(0,Y.jsx)(UH,{title:n,count:i.length,icon:r,children:(0,Y.jsx)(VH,{proposals:i,scopes:e.scopes,actions:e.proposals,label:`Suggestions for ${t.label}`,fallbackFocus:e.heading})})},GH=({context:e,option:t})=>{let n=QB(e.view,t.scope);return n.length===0?null:(0,Y.jsx)(UH,{title:`Preferences`,count:n.length,children:(0,Y.jsx)(zH,{preferences:n,scopes:e.scopes,actions:e.actions,label:`Preferences for ${t.label}`})})},KH=({context:e,option:t})=>(0,Y.jsx)(UH,{title:`Add a preference`,children:(0,Y.jsx)(FH,{legend:`Add a preference`,initial:{kind:`look-for`,text:``,scope:t.scope},scopes:e.scopes,inline:!0,submit:`Add preference`,submitting:`Adding…`,submitIcon:(0,Y.jsx)(c_,{"aria-hidden":`true`}),onSubmit:e.add},t.key)}),qH=({where:e})=>(0,Y.jsxs)(`p`,{className:`mt-5 text-ui text-muted-foreground`,children:[`No preferences for `,e,` yet.`]}),JH=({context:e,option:t})=>{let n=QB(e.view,t.scope).length===0&&$B(e.view,t.scope).length===0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HH,{context:e,title:`Everywhere`,word:`Used on every pull request, in every repository.`}),(0,Y.jsx)(WH,{context:e,option:t}),(0,Y.jsx)(GH,{context:e,option:t}),n&&(0,Y.jsx)(qH,{where:`every repository`}),(0,Y.jsx)(KH,{context:e,option:t})]})},YH=({context:e,option:t,repository:n})=>{let{repo:r,guidelineFiles:i,guidelineNote:a}=n,o=e.suggest(r);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HH,{context:e,title:HB(r),host:r.host,word:`Used on its pull requests, after the ones for Everywhere.`,actions:(0,Y.jsx)(LB,{...o})}),(0,Y.jsx)(RB,{...o,className:`mt-2`}),(0,Y.jsx)(WH,{context:e,option:t}),(0,Y.jsx)(GH,{context:e,option:t}),eV(e.view,t.scope)&&(0,Y.jsx)(qH,{where:`this repository`}),(0,Y.jsx)(KH,{context:e,option:t}),(0,Y.jsx)(UH,{title:`Guideline files`,children:(0,Y.jsx)(gV,{files:i,note:a,onSwitch:(t,n)=>e.switchGuideline(r,t,n)})})]})},XH=({context:e})=>{let t=rV(e.view,e.scopes);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HH,{context:e,title:`Suggestions`,word:`From the points you raised or dismissed and the comments you posted. Add one to make it a preference where shown.`}),t.length===0?(0,Y.jsx)(`p`,{className:`mt-5 max-w-[620px] text-ui text-muted-foreground`,children:`No suggestions yet. Suggest from my reviews, on a repository's panel, proposes rules from what you did on its pull requests and your comments on them.`}):t.map(({option:t})=>(0,Y.jsx)(WH,{context:e,option:t,title:t.label,icon:(0,Y.jsx)(KB,{scope:t.scope,className:`size-3.5`})},t.key))]})},ZH=e=>fV(e,`preference`),QH=e=>`${e} waiting`,$H=({full:e,count:t,counted:n})=>t>0?`${e}, ${n}`:e,eU=({entry:e})=>{let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(e.name);return(0,J.useLayoutEffect)(()=>{let n=t.current;if(n!==null&&e.repo)return OF(n,()=>{let t=n.firstElementChild,i=n.lastElementChild;if(n.clientWidth===0||i===null)return;let a=n.clientWidth-(t===null||t===i?0:DF(t,t.textContent??``)??0);r(kI(e.name,e=>(DF(i,e)??0)<=a+.5))})},[e.name,e.repo]),(0,Y.jsxs)(`span`,{ref:t,"aria-hidden":`true`,className:`min-w-0 flex-1 truncate text-left`,children:[e.owner!==null&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.owner,`/`]}),(0,Y.jsx)(`span`,{children:n})]})},tU=({entry:e})=>e.count>0?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`tabular shrink-0 text-caption`,e.ai?`font-medium text-primary in-data-highlighted:text-accent-foreground`:`text-muted-foreground`),children:e.count}):null,nU=({entry:e,current:t,onSelect:n})=>{let r=(0,Y.jsxs)(`button`,{type:`button`,"aria-current":e.key===t?`page`:void 0,"aria-label":$H(e),onClick:()=>n(e.key),className:X(`relative flex h-[34px] w-full items-center gap-2 rounded-md px-2.5 text-ui hover:bg-surface-row [&_svg]:text-muted-foreground`,`aria-[current=page]:bg-secondary aria-[current=page]:font-medium aria-[current=page]:before:absolute aria-[current=page]:before:inset-y-[7px] aria-[current=page]:before:left-0 aria-[current=page]:before:w-0.5 aria-[current=page]:before:rounded-full aria-[current=page]:before:bg-primary`,e.ai&&`[&_svg]:text-primary`),children:[e.icon,(0,Y.jsx)(eU,{entry:e}),(0,Y.jsx)(tU,{entry:e})]});return(0,Y.jsx)(`li`,{children:e.repo?(0,Y.jsxs)(YL,{children:[(0,Y.jsx)(XL,{delay:500,render:r}),(0,Y.jsx)(ZL,{side:`right`,sideOffset:8,children:e.full})]}):r})},rU=({id:e,children:t})=>(0,Y.jsx)(`p`,{id:e,className:`mt-4 mb-1 px-2.5 text-caption font-medium text-muted-foreground`,children:t}),iU=({entries:e,current:t,onSelect:n,className:r})=>{let i=(0,J.useId)();return(0,Y.jsxs)(`nav`,{"aria-label":`Scopes`,className:r,children:[(0,Y.jsxs)(`ul`,{children:[(0,Y.jsx)(nU,{entry:e.suggestions,current:t,onSelect:n}),(0,Y.jsx)(nU,{entry:e.everywhere,current:t,onSelect:n})]}),e.repositories.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(rU,{id:`${i}-repositories`,children:`Repositories`}),(0,Y.jsx)(`ul`,{"aria-labelledby":`${i}-repositories`,children:e.repositories.map(e=>(0,Y.jsx)(nU,{entry:e,current:t,onSelect:n},e.key))})]})]})},aU=({entry:e})=>(0,Y.jsxs)(EH,{value:e.key,label:e.full,"aria-label":$H(e),className:`h-[34px] gap-2 pl-2.5 data-selected:font-medium [&_svg]:text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:X(`flex`,e.ai&&`[&_svg]:text-primary`),children:e.icon}),(0,Y.jsx)(eU,{entry:e}),(0,Y.jsx)(tU,{entry:e})]}),oU=({entries:e,current:t,onSelect:n,className:r})=>{let i=(0,J.useId)(),a=[e.suggestions,e.everywhere,...e.repositories],o=a.find(e=>e.key===t)??e.everywhere;return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5`,r),children:[(0,Y.jsx)(`span`,{id:`${i}-label`,className:`text-caption font-medium text-muted-foreground`,children:`Scope`}),(0,Y.jsxs)(bH,{value:o.key,items:a.map(e=>({value:e.key,label:e.full})),onValueChange:e=>{typeof e==`string`&&n(e)},children:[(0,Y.jsx)(CH,{"aria-labelledby":`${i}-label`,className:`h-10 w-full max-w-[440px] gap-2 rounded-lg px-3 text-body font-medium data-popup-open:border-ring data-popup-open:ring-3 data-popup-open:ring-ring/20 [&_svg]:text-muted-foreground`,children:(0,Y.jsx)(SH,{children:()=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`flex`,o.ai&&`[&_svg]:text-primary`),children:o.icon}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.full}),(0,Y.jsx)(tU,{entry:o})]})})}),(0,Y.jsxs)(wH,{alignItemWithTrigger:!1,align:`start`,sideOffset:6,children:[(0,Y.jsxs)(xH,{children:[(0,Y.jsx)(aU,{entry:e.suggestions}),(0,Y.jsx)(aU,{entry:e.everywhere})]}),e.repositories.length>0&&(0,Y.jsxs)(xH,{children:[(0,Y.jsx)(TH,{children:`Repositories`}),e.repositories.map(e=>(0,Y.jsx)(aU,{entry:e},e.key))]})]})]})]})},sU=()=>(0,Y.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading your preferences`,className:`lg:grid lg:grid-cols-[240px_minmax(0,1fr)] lg:items-start lg:gap-10`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`hidden flex-col gap-2 lg:flex`,children:[28,20,32,24].map(e=>(0,Y.jsx)(pF,{className:`h-[34px] motion-reduce:animate-none`,style:{width:`${e*7}px`}},e))}),(0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`flex flex-col gap-3`,children:[(0,Y.jsx)(pF,{className:`h-10 w-full max-w-[440px] motion-reduce:animate-none lg:hidden`}),(0,Y.jsx)(pF,{className:`h-6 w-56 motion-reduce:animate-none`}),(0,Y.jsx)(pF,{className:`h-4 w-80 max-w-full motion-reduce:animate-none`}),(0,Y.jsx)(`div`,{className:`mt-5 flex flex-col gap-3 rounded-lg border bg-card px-4 py-3`,children:[1,2].map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(pF,{className:`h-[22px] w-24 motion-reduce:animate-none`}),(0,Y.jsx)(pF,{className:`h-4 flex-1 motion-reduce:animate-none`})]},e))})]})]}),cU=({now:e=Date.now,startOn:t})=>{let{client:n}=Pp(),r=HR(yL().status?.model??null),i=Bp(),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null);i.preferences!==a&&(o(i.preferences),c(i.preferences));let[l,u]=(0,J.useState)(new Map),[d,f]=(0,J.useState)(``),p=(0,J.useRef)(null),m=(0,J.useId)(),h=B_(J_()),[g,_]=(0,J.useState)(t??null),v=t===void 0?h:g,y=(0,J.useRef)(!1);(0,J.useEffect)(()=>{y.current&&(y.current=!1,p.current?.focus())},[v]);let b=e=>{y.current=!0,t===void 0?Y_(z_(e===WB(VB)?null:e)):_(e)},x=e=>c(t=>t===null?t:e(t)),S=(e,t,n)=>e.ok?(x(n=>t(n,e.value)),f(n),null):dV(e.error),C=async e=>S(await n.addPreference(e),qB,`Added: ${e.text}`),w={onSwitch:async(e,t)=>S(await n.updatePreference(e,{enabled:t}),qB,t?`Switched on`:`Switched off`),onEdit:async(e,t)=>S(await n.updatePreference(e,t),qB,`Saved: ${t.text}`),onDelete:async e=>S(await n.deletePreference(e),t=>JB(t,e),`Deleted`)},T={onAccept:async(e,t)=>S(await n.decideProposal(e,{decision:`accept`,...t}),(t,{preference:n})=>{let r=XB(t,e);return n===null?r:qB(r,n)},`Added to your preferences`),onReject:async e=>S(await n.decideProposal(e,{decision:`reject`}),t=>XB(t,e),`Dismissed`)},E=async(e,t,r)=>S(await n.setGuidelineSwitch({repo:e,path:t,enabled:r}),n=>ZB(n,e,t,r),r?`${t} switched on`:`${t} switched off`),D=t=>({phase:l.get(t)??MB,onPhase:e=>u(n=>new Map(n).set(t,e)),choice:r,now:e});return(0,Y.jsxs)(`div`,{"data-slot":`preferences-page`,className:`mx-auto w-full max-w-[1088px] pb-12 lg:pt-5`,children:[(0,Y.jsxs)(`header`,{className:`mb-6 flex flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{className:`text-[1.5rem] leading-8 font-semibold tracking-[-0.018em]`,children:`Preferences`}),(0,Y.jsx)(`p`,{className:`text-body text-muted-foreground`,children:`What you want an AI review to look for and to leave out. Used by Request AI review.`})]}),(()=>{if(s===null)return i.loading||i.error===null?(0,Y.jsx)(sU,{}):(0,Y.jsxs)(`div`,{className:X(dF,`flex flex-wrap items-center justify-between gap-2`),role:`alert`,children:[(0,Y.jsxs)(`p`,{children:[`Couldn't read your preferences. `,Gp(i.error)]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:i.refresh,children:`Try again`})]});let e=cV(s),t=e.map(e=>e.repo),r=GB(t),a=e=>aV(e,GB(cV(YB(s,e)).map(e=>e.repo))),o={view:s,scopes:r,actions:w,proposals:T,add:C,switchGuideline:E,suggest:e=>({...D(UB(e)),label:`Suggest from my reviews`,running:`Reading your reviews of ${HB(e)}…`,icon:(0,Y.jsx)(E_,{"aria-hidden":`true`}),what:`Reads what you did on its pull requests here and your comments on ${iL[e.host]}, then runs`,run:async t=>{let r=await n.suggestPreferences({repo:e,...t===void 0?{}:{optionId:t}});if(!r.ok)return{ok:!1,message:dV(r.error)};let{proposals:i,...o}=r.value;return x(e=>YB(e,i)),{ok:!0,said:oV(o,i.length,a(i))}}}),heading:p,headingId:m},c=nV(v,r),l=c.kind===`suggestions`?tV:c.option.key,u={suggestions:{key:tV,icon:(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),full:`Suggestions`,name:`Suggestions`,owner:null,count:s.proposals.length,counted:QH(s.proposals.length),ai:!0},everywhere:{key:WB(VB),icon:(0,Y.jsx)(Rg,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),full:`Everywhere`,name:`Everywhere`,owner:null,count:QB(s,VB).length,counted:ZH(QB(s,VB).length)},repositories:r.flatMap(e=>{if(e.scope.kind!==`repo`)return[];let n=QB(s,e.scope).length;return[{key:e.key,icon:(0,Y.jsx)(WR,{host:e.scope.repo.host}),full:e.label,...sV(e.scope.repo,t),count:n,counted:ZH(n),repo:!0}]})},d=(()=>{if(c.kind===`suggestions`)return(0,Y.jsx)(XH,{context:o});let{option:t}=c;if(t.scope.kind===`global`)return(0,Y.jsx)(JH,{context:o,option:t});let n=e.find(e=>UB(e.repo)===t.key);return n===void 0?null:(0,Y.jsx)(YH,{context:o,option:t,repository:n})})();return(0,Y.jsxs)(`div`,{className:`lg:grid lg:grid-cols-[240px_minmax(0,1fr)] lg:items-start lg:gap-10`,children:[(0,Y.jsx)(iU,{entries:u,current:l,onSelect:b,className:`hidden lg:sticky lg:top-4 lg:block`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(oU,{entries:u,current:l,onSelect:b,className:`mb-5 lg:hidden`}),(0,Y.jsx)(`section`,{"aria-labelledby":m,"data-slot":`scope-panel`,children:d})]})]})})(),(0,Y.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:d})]})},lU=[`import`,`call`,`type`,`request`],uU=e=>e.slice(e.lastIndexOf(`/`)+1),dU=(e,t)=>e<t?-1:+(e>t),fU=e=>/\.(md|mdx|rst|adoc)$/i.test(e),pU=/(^|[/_.-])(fakes?|mocks?|stubs?|fixtures?|testing|test[_-]?(utils?|helpers?|support))([/_.-]|$)/i,mU=e=>PI(e).split(`/`).slice(0,3).join(`/`),hU=e=>e===``?`.`:PI(MI(`${e}/x`)),gU=e=>`group:${e}`,_U=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},vU=`\0routes`,yU=e=>`${e.method} ${e.path}`,bU=e=>{let[t]=e;return e.length===1&&t!==void 0?`${t.method} ${t.path}`:`${e.length} routes`},xU=(e,t)=>{let n=il(e.parts),r=new Map(e.files.flatMap(e=>al(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:cd(t.file,t.hunk,[]);return n?.kind===`route`?n.routes:[]});if(t.length>0&&(a(n,vU),o.set(n,[...o.get(n)??[],...t])),!(new Set(t.map(yU)).size===i.length&&t.length>0))for(let t of e.title.split(`; `)){t.startsWith(`Page: `)&&a(n,t);let e=/^Command: (\S+) in (.+)$/.exec(t);e!==null&&e[2]===uU(n)&&a(n,`Command: ${e[1]}`)}}}return new Map([...i].map(([e,t])=>{let n=[...new Map((o.get(e)??[]).map(e=>[yU(e),e])).values()];return[e,t.map(e=>e===vU?bU(n):e)]}))},SU=(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},CU=()=>({uses:new Set,symbols:new Set,pairs:0}),wU=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)??{...CU(),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(nl(t.fromPartId)),n=r.get(nl(t.toPartId));e!==void 0&&n!==void 0&&o(e,n,t.use,t.symbol)}return{mechanical:t,files:n,pathOfHunk:r,links:a}},TU=(e,t=new Set)=>{let{mechanical:n,files:r,pathOfHunk:i,links:a}=wU(e),o=e.flows??[],s=new Set(o.flatMap(e=>e.partIds)),c=[...r].sort((e,t)=>NI(e.path,t.path)).flatMap(t=>al(t,il(e.parts)).map(e=>e.id)).filter(e=>!n.has(nl(e))&&!s.has(e)),l=[...new Set([...s,...c])],u=new Map(l.map((e,t)=>[e,t])),d=e=>u.get(e)??l.length,f=new Set(e.generated),p=new Map(r.map(t=>{let r=t.hunks.flatMap(e=>e.lines),i=al(t,il(e.parts)).map(e=>e.id).filter(e=>!n.has(nl(e))).sort((e,t)=>d(e)-d(t)),a=t.hunks.every(e=>n.has(e.id))?`mechanical`:`logic`;return[t.path,{added:r.filter(e=>e.kind===`add`).length,deleted:r.filter(e=>e.kind===`del`).length,partIds:i,risk:a,rank:i.reduce((e,t)=>Math.min(e,d(t)),1/0)}]})),m=e=>p.get(e)?.rank??1/0,h=(e,t)=>m(e)-m(t)||dU(e,t),g=r.map(e=>e.path).sort(h),_=e=>[...a.get(e)?.keys()??[]],v=e=>g.filter(t=>a.get(t)?.has(e)===!0),y=new Set(g.filter(ll));for(let e=!0;e;){e=!1;for(let t of g){let n=v(t);!y.has(t)&&pU.test(t)&&n.length>0&&n.every(e=>y.has(e))&&(y.add(t),e=!0)}}let b=g.filter(e=>!y.has(e)&&fU(e)),x=g.filter(e=>!y.has(e)&&!fU(e)),S=new Set(x),C=new Map;for(let e of[...y].sort(h)){let t=[],n=new Set([e]),r=e=>{for(let i of _(e))n.has(i)||(n.add(i),S.has(i)?t.push(i):r(i))};r(e),C.set(e,t)}let w=new Map;for(let[e,t]of C)for(let n of t)w.set(n,[...w.get(n)??[],e]);let T=[...y].filter(e=>(C.get(e)??[]).length===0),E=new Map;for(let e of[...x,...b,...T].sort(NI)){let n=gU(PI(e)),r=t.has(n)?e:n;E.set(r,[...E.get(r)??[],e])}let D=new Map;for(let[e,t]of E)for(let n of t)D.set(n,e);let O=e=>Math.min(...(E.get(e)??[e]).map(m)),k=(e,t)=>O(e)-O(t)||dU(e,t),A=[...E.keys()].sort(k),j=new Map;for(let[e,t]of a)for(let[n,r]of t){let t=D.get(e),i=D.get(n);if(t===void 0||i===void 0||t===i)continue;let a=j.get(t)??new Map,o=a.get(i)??CU();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),j.set(t,a)}let M=new Map;for(let{partId:t,symbol:n,uses:r}of e.unchangedCallers??[]){let e=i.get(nl(t)),a=e===void 0?void 0:D.get(e);if(a!==void 0)for(let e of r){let r=M.get(e.path)??{targets:new Map,uses:0,partIds:new Set},i=r.targets.get(a)??CU();i.uses.add(e.use),i.symbols.add(n),r.targets.set(a,i),r.uses+=1,r.partIds.add(t),M.set(e.path,r)}}let N=[...M.keys()].sort((e,t)=>Number(ll(e))-Number(ll(t))||dU(e,t)),P=new Map;for(let e of N){let t=N.length>10?`outside:${mU(e)}/`:`outside:${e}`;P.set(t,[...P.get(t)??[],e])}for(let[e,t]of[...P]){let[n]=t;e.endsWith(`/`)&&t.length===1&&n!==void 0&&(P.delete(e),P.set(`outside:${n}`,[n]))}let F=new Map;for(let[e,t]of P){let n=new Map;for(let e of t)for(let[t,r]of M.get(e)?.targets??[]){let e=n.get(t)??CU();for(let t of r.uses)e.uses.add(t);for(let t of r.symbols)e.symbols.add(t);n.set(t,e)}F.set(e,n)}let I=new Set([...[...j].flatMap(([e,t])=>t.size>0?[e,...t.keys()]:[]),...[...F.values()].flatMap(e=>[...e.keys()])]),L=A.filter(e=>I.has(e)),R=new Set,ee=(e,t)=>`${e}\u0000${t}`,z=e=>[...j.get(e)?.keys()??[]].filter(t=>!R.has(ee(e,t))),B=(e,t)=>j.get(e)?.get(t)?.pairs??0;for(let e=SU(L,z);e.length>0;e=SU(L,z))for(let t of e){let[e,n,r]=t;if(e!==void 0&&n!==void 0&&r===void 0&&B(e,n)!==B(n,e)){R.add(B(e,n)<B(n,e)?ee(e,n):ee(n,e));continue}let[i]=[...t].sort(k);for(let e of t)i!==void 0&&z(e).includes(i)&&R.add(ee(e,i))}let V=new Map(L.map(e=>[e,[]]));for(let e of L)for(let t of z(e))V.get(t)?.push(e);let te=new Map,H=e=>{let t=te.get(e);if(t!==void 0)return t;let n=Math.max(-1,...(V.get(e)??[]).map(H))+1;return te.set(e,n),n},U=[],ne=(e,t)=>{for(;U.length<=t;)U.push([]);U[t]?.push(e)};for(let e of L)ne(e,H(e));for(let[e,t]of F){let n=[...t.keys()];V.set(e,n),te.set(e,Math.max(...n.map(H))+1),ne(e,te.get(e)??0)}let re=()=>new Map(U.flatMap(e=>e.map((t,n)=>[t,n-(e.length-1)/2]))),ie=e=>z(e),ae=(e,t)=>{for(let n of e){let e=re(),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)||k(e,t))}},oe=e=>V.get(e)??[];ae(U.slice(1),oe),ae(U.slice(0,-1).reverse(),ie),ae(U.slice(1),oe);let W=_U(g),se=xU(e,o),ce=new Map;for(let e of o)if(e.kind===`flow`)for(let t of new Set(e.partIds.flatMap(e=>i.get(nl(e))??[])))ce.set(t,[...ce.get(t)??[],e.title]);let le=e=>[...new Set(e)],ue=_U(N),de=(e,t)=>{let n=P.get(e)??[],[r]=n;return{key:e,kind:`outside`,paths:n,label:e.endsWith(`/`)||r===void 0?e.slice(8):ue.get(r)??r,added:0,deleted:0,risk:`logic`,generated:!1,entries:[],flows:[],partIds:[...new Set(n.flatMap(e=>[...M.get(e)?.partIds??[]]))],uses:n.reduce((e,t)=>e+(M.get(t)?.uses??0),0),badges:[],row:t}},fe=(e,t)=>{if(P.has(e))return de(e,t);let n=E.get(e)??[e],r=n.flatMap(e=>p.get(e)??[]),i=e.startsWith(`group:`);return{key:e,kind:i?`group`:`file`,paths:n,label:i?`${hU(e.slice(6))}/`:W.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=>f.has(e)),entries:le(n.flatMap(e=>se.get(e)??[])),flows:le(n.flatMap(e=>ce.get(e)??[])),partIds:r.flatMap(e=>e.partIds).sort((e,t)=>d(e)-d(t)),badges:le(n.flatMap(e=>w.get(e)??[])).sort(h),uses:0,row:t}},pe=U.map((e,t)=>e.map(e=>fe(e,t))),me=A.filter(e=>!I.has(e)).map(e=>fe(e,-1)),he=new Map;for(let e of[...pe.flat(),...me])if(e.kind!==`outside`)for(let t of e.paths)he.set(t,e.key);for(let[e,t]of C){let[n]=t,r=n===void 0?void 0:D.get(n);r!==void 0&&he.set(e,r)}return{rows:pe,edges:[...[...j].map(e=>[e,!1]),...[...F].map(e=>[e,!0])].flatMap(([[e,t],n])=>[...t].map(([t,r])=>({from:e,to:t,uses:lU.filter(e=>r.uses.has(e)),symbols:[...r.symbols].sort(dU),back:R.has(ee(e,t)),outside:n}))),strip:me,placeOf:he}},EU=e=>e.kind!==`outside`&&!e.generated&&e.risk!==`mechanical`,DU=e=>e.kind===`group`?e.key.slice(6)||`.`:e.key,OU=e=>{let t=e.rows.map(e=>e.filter(EU)).filter(e=>e.length>0),n=e.strip.filter(EU),r=t.length>0,i=r?t:[n],a=i.flat();if(a.length===0)return null;let o=_U(a.map(DU)),s=8,c=i.map(e=>e.flatMap(e=>s===0?[]:(--s,[{label:o.get(DU(e))??DU(e),entries:e.entries}]))).filter(e=>e.length>0);return{rows:c,linked:r,more:a.length-c.flat().length+(r?n.length:0)}},kU=(e,t)=>{let n=e.flatMap(e=>{let n=t(e.partId);if(n===void 0||ll(n))return[];let r=e.uses.filter(e=>!ll(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)}},AU=e=>e.split(/`([^`\n]+)`/).map((e,t)=>({text:e,code:t%2==1})).filter(e=>e.text!==``),jU={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},MU=({kind:e,count:t,words:n,at:r,pressed:i,onPressed:a,label:o})=>{let[s,c]=n,l=e===`thread`?n_:DD[e];return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`point-chip`,"data-kind":e,"data-land":`rise`,"aria-pressed":i,"aria-label":o,style:Ph({"--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`:ED[e].className),children:[(0,Y.jsx)(l,{"aria-hidden":`true`,className:`size-3.5`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{"data-slot":`count-up`,"aria-hidden":`true`,className:`tabular`,style:Ph({"--count":t})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t}),` `,(0,Y.jsx)(`span`,{className:`max-xl:sr-only`,children:t===1?s:c})]})]})},NU=({choice:e,variant:t,compact:n,icon:r,label:i,note:a,locked:o=!1,disabled:s=!1,busy:c=null,slot:l,onClick:u})=>{let d=(0,J.useId)(),f=n?`sm`:`default`,p=(0,Y.jsx)($,{variant:t,size:f,"data-slot":l,disabled:s||c!==null,focusableWhenDisabled:!0,"aria-describedby":a===null?void 0:d,onClick:u,className:X(`rounded-r-none border-r-0`,c!==null&&`aria-disabled:cursor-progress aria-disabled:opacity-100`)});return(0,Y.jsxs)(`span`,{role:`group`,"aria-label":`AI review`,className:`flex shrink-0 items-center`,children:[(0,Y.jsxs)(YL,{disabled:a===null,children:[(0,Y.jsxs)(XL,{render:p,children:[(0,Y.jsx)(r,{"aria-hidden":`true`,className:X(c!==null&&`animate-spin motion-reduce:animate-none`)}),i]}),(0,Y.jsxs)(ZL,{side:`bottom`,align:`start`,children:[o&&(0,Y.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),a]})]}),a!==null&&(0,Y.jsx)(`span`,{id:d,hidden:!0,children:a}),(0,Y.jsx)(jB,{choice:e,disabled:c!==null||s||e.options.length===0,variant:t,size:f}),c!==null&&(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:c})]})},PU=e=>{let t=Zu.filter(t=>e.stages[t]!==`done`);return t.length===0||e.modelError===null?null:`${t.join(`, `)} missing: ${e.modelError.message}`},FU=({analysis:e,choice:t,running:n,starting:r,error:i,points:a,leftOut:o=0,threads:s=null,narrowed:c,onNarrow:l,onRun:u,onRerun:d,reanalyze:f=null,filesChanged:p=null,children:m})=>{let h=Bl(e.modelOption??t.chosen),g=m!=null&&m!==!1,{chosen:_,locked:v}=t,y=v??(_===null?null:`Runs ${_.modelName} through ${_.via}`),b=r||v!==null||_===null,x=id(e),S=rd(e),C=e.modelError,w=[`finding`,`risk`,`decision`].map(e=>[e,a.filter(t=>t.kind===e).length]).filter(([,e])=>e>0),T=!n&&a.length>0,E=T?w.length+(s===null?0:1):0,D=e=>T?{"data-land":`rise`,style:Ph({"--landing-i":E+e})}:{},O=ed(e),k=O.filter(t=>e.stages[t]===`done`).length,A=n?(0,Y.jsx)(NU,{choice:t,variant:`ai-quiet`,compact:!0,icon:Qg,label:`Reviewing · ${k} of ${O.length}`,note:null,busy:`${h} is reading this PR, ${k} of ${O.length} passes done`,slot:`claude-running`}):f===null?S?(0,Y.jsx)(NU,{choice:t,variant:C===null?`ai`:`ai-quiet`,compact:a.length>0,icon:v===null?C===null?E_:u_:e_,label:r?`Starting…`:C===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Request AI review`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`sm:hidden`,children:`AI review`})]}):`Try again`,note:y,locked:v!==null,disabled:b,slot:`request-review`,onClick:u}):d!==void 0&&(0,Y.jsx)(NU,{choice:t,variant:`ai-quiet`,compact:!0,icon:u_,label:r?`Starting…`:`Re-run`,note:v??(_===null?null:`Runs ${_.modelName} through ${_.via} again`),locked:v!==null,disabled:b,slot:`rerun`,onClick:d}):(0,Y.jsx)(NU,{choice:t,variant:`ai-strong`,compact:x,icon:u_,label:f.starting?`Starting…`:`Re-analyze · new commits`,note:`Reads the PR's new commits as a new analysis`,disabled:f.starting,slot:`reanalyze`,onClick:f.onReanalyze}),j=!n&&f===null&&!x&&(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 whitespace-nowrap text-muted-foreground max-lg:hidden`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`No AI review yet`}),p!==null&&p>0&&(0,Y.jsxs)(`span`,{className:`truncate max-xl:hidden`,children:[`Find bugs, risks and decisions across `,p,` `,p===1?`file`:`files`]})]}),M=i??(a.length>0?PU(e):null)??(C===null||a.length>0?null:`${h} couldn't finish: ${C.message}`),N=!n&&!S&&a.length===0&&e.stages.findings===`done`&&(0,Y.jsxs)(`span`,{"data-slot":`claude-receipt`,"data-land":`fade`,className:`shrink-0 whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),h,` found nothing to raise`,o>0&&`, and left out ${o} by your preferences`]}),P=T?(0,Y.jsxs)(`span`,{"data-slot":`claude-receipt`,className:`flex min-w-0 items-center gap-1.5`,children:[w.map(([e,t],n)=>(0,Y.jsx)(MU,{kind:e,count:t,words:jU[e],at:n,pressed:c===e,onPressed:t=>l(t?e:null)},e)),s!==null&&(0,Y.jsx)(MU,{kind:`thread`,count:s.count,words:s.words,label:s.label,at:w.length,pressed:c===`thread`,onPressed:e=>l(e?`thread`:null)}),g&&(0,Y.jsx)(`span`,{...D(0),className:`ml-1 flex min-w-0 items-center`,children:m})]}):(N!==!1||g)&&(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[N,g&&(0,Y.jsx)(`span`,{className:`flex min-w-0 items-center`,children:m})]});return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[P,(0,Y.jsxs)(`span`,{...D(1),className:X(`flex min-w-0 shrink-0 items-center gap-2`,P!==!1&&`border-l pl-2`),children:[j,A]}),M!==null&&(0,Y.jsx)(`span`,{...D(2),role:`alert`,title:M,className:`min-w-0 truncate text-caption text-destructive`,children:M})]})},IU=e=>`call-${e.partId}-${e.line}-${e.column}`,LU=(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=IU(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,Y.jsx)(BM,{handle:n,payload:a,id:o,children:e})}),s.set(i.line,c),r.set(i.partId,s))}return r},RU=(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}`}},zU=({children:e})=>(0,Y.jsx)(`code`,{className:`font-mono text-code-compact text-foreground`,children:e}),BU=e=>{let t=Xl[e];return`${/^[aeiou]/i.test(t)?`an`:`a`} ${t}`},VU=e=>{switch(e.is){case`rule`:return`A check could catch this next time: \`${e.rule}\` in ${Yl[e.tool]}.`;case`suggested`:return`A check could catch this next time: ${BU(e.kind)} in ${e.engine}. ${e.does}`}},HU=`flex items-start gap-1.5 text-caption text-muted-foreground`,UU=({guardrail:e,family:t,className:n,children:r})=>{switch(e.is){case`rule`:return(0,Y.jsxs)(`p`,{"data-slot":`guardrail`,"data-guardrail":`rule`,className:X(HU,n),children:[(0,Y.jsx)(v_,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:`A check could catch this:`}),` `,(0,Y.jsx)(zU,{children:e.rule}),` in `,Yl[e.tool],`, which`,` `,(0,Y.jsx)(zU,{children:e.configPath}),` doesn't turn on.`,r]})]});case`suggested`:return(0,Y.jsxs)(`p`,{"data-slot":`guardrail`,"data-guardrail":`suggested`,className:X(HU,n),children:[(0,Y.jsx)(b_,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:`This looks checkable:`}),` `,BU(e.kind),` in `,e.engine,`. `,e.does,` `,(0,Y.jsxs)(`span`,{className:`italic`,children:[`Suggested by `,t,`, not checked.`]}),r]})]})}},WU=({guardrail:e,family:t,body:n,onEdit:r})=>{let i=VU(e);return(0,Y.jsx)(`div`,{"data-slot":`draft-guardrail`,className:`border-t pt-2`,children:(0,Y.jsx)(UU,{guardrail:e,family:t,children:n.includes(i)?(0,Y.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-1 text-foreground`,children:[(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`size-3.5`}),`Added to the comment`]}):(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:`ml-1`,onClick:()=>r(`${n.trimEnd()}\n\n${i}`),children:`Add to comment`})]})})})},GU=e=>`hunk-${e}`,KU=e=>e===void 0?{}:{marks:e},qU=({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,Y.jsx)(`div`,{className:AM,children:(0,Y.jsx)(rN,{hunk:r,file:i,risk:a,proofs:o,onFocus:t.onFocusHunk})}):(0,Y.jsx)(LM,{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},...t.draftNote===void 0?{}:{draftNote:(n,r)=>t.draftNote?.(e,n,r)},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},...KU(t.marksOf(e))})},JU=`You opened this pull request, and its author can't approve it.`,YU=`The PR has new commits since the analysis: re-analyze to approve them.`,XU=({aiDone:e,running:t,pending:n,isAuthor:r,stale:i,verdict:a})=>{let o=a===`approved`,s=o?null:r?JU:i?YU:null,c={filled:n>0,count:n};if(o)return{approve:{filled:!1,disabledReason:s,revoke:!0},publish:c,order:n>0?[`approve`,`publish`]:[`approve`]};let l=n===0&&e&&!t&&s===null&&a!==`changes-requested`;return{approve:{filled:l,disabledReason:s,revoke:!1},publish:c,order:l?[`publish`,`approve`]:[`approve`,`publish`]}},ZU=(e,t,n)=>{let r=n?.url??null;return t?e===null?null:{kind:e,url:r}:n===null?null:{kind:`published`,url:r}},QU=(e,t)=>e===`approve`?`approved`:e===`request_changes`?`changes-requested`:t??`commented`,$U=1,eW=240,tW=6,nW=()=>{},rW=e=>{let t=e.left+e.width/2;for(let e=$U;e<Math.min(window.innerHeight,eW);e+=tW){let n=document.elementFromPoint(t,e);if(n===null||n.closest(`[data-slot=file-card-header]`)!==null)continue;let r=n.closest(`[role=row][data-line]`);if(r!==null&&r.getBoundingClientRect().top>=0)return r}return null},iW=e=>{let t=document.querySelector(e)?.getBoundingClientRect();if(window.scrollY<=$U||t===void 0||t.top>=0||typeof document.elementFromPoint!=`function`)return nW;let n=rW(t);if(n===null)return nW;let r=n.getBoundingClientRect().top;return()=>{if(!n.isConnected)return;let e=n.getBoundingClientRect().top-r;e!==0&&window.scrollBy({top:e,behavior:`instant`})}},aW=2e3,oW=[`wheel`,`touchmove`,`keydown`,`pointerdown`],sW=(e,t)=>{let n=document.querySelector(e);if(n===null||typeof ResizeObserver!=`function`)return nW;let r=new ResizeObserver(t),i=()=>{r.disconnect(),window.clearTimeout(a);for(let e of oW)window.removeEventListener(e,i)},a=window.setTimeout(i,aW);for(let e of oW)window.addEventListener(e,i,{passive:!0});return r.observe(n),i},cW=(e,t)=>sW(t,()=>document.getElementById(e)?.scrollIntoView({block:`start`,behavior:`instant`})),lW=/^#{1,6}\s+/,uW=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`),dW=e=>{let t=e.split(`
86
- `).map(e=>e.trim()).filter(e=>e!==``);return uW(t.find(e=>!lW.test(e))??t[0]?.replace(lW,``)??``)},fW=/^(.+?[.!?])\s+(?=[A-Z0-9"'(`[])/,pW=e=>{let t=dW(e);return fW.exec(t)?.[1]??t},mW=`font-semibold text-foreground`,hW=({text:e})=>(0,Y.jsx)(`span`,{"data-slot":`model-text`,className:`whitespace-pre-line`,children:AU(e).map((e,t)=>e.code?(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.text},t):(0,Y.jsx)(`span`,{children:uW(e.text)},t))}),gW=({through:e})=>(0,Y.jsxs)(`span`,{"data-slot":`through`,children:[e.rows.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&` → `,e.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.label}),e.entries.length>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.entries.join(`, `),`)`]})]},e.label))]},t)),e.more>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,e.more,` more `,e.more===1?`directory`:`directories`]})]}),_W=({reach:e})=>{let t=e.symbols.slice(0,3),n=e.symbols.length-t.length,r=t.map((e,r)=>(0,Y.jsxs)(`span`,{children:[r>0&&(r===t.length-1&&n===0?` and `:`, `),(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:e})]},e));return(0,Y.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.`]})},vW=({lead:e,children:t})=>(0,Y.jsxs)(`p`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:mW,children:e}),` `,t]}),yW=e=>e.modelOption===null?null:`${e.modelOption.modelName} through ${e.modelOption.providerName}`,bW=({analysis:e,running:t,stale:n,tour:r})=>{if(!t&&!id(e))return null;let i=yW(e),a=ed(e),o=a.filter(t=>e.stages[t]===`done`).length;return(0,Y.jsxs)(`div`,{"data-slot":`ai-status`,className:`mb-1.5 flex flex-wrap items-center gap-x-1.5 text-caption text-muted-foreground`,children:[t?(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:`size-3.5 animate-spin text-primary motion-reduce:animate-none`}):(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3.5 text-primary`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:t?`AI review running`:`AI review`}),i!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsx)(`span`,{children:i})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[o,` of `,a.length,` passes`]}),(0,Y.jsx)(`span`,{role:`progressbar`,"aria-label":`AI review progress`,"aria-valuemin":0,"aria-valuemax":a.length,"aria-valuenow":o,className:`ml-1 h-1 w-30 overflow-hidden rounded-full bg-secondary`,children:(0,Y.jsx)(`span`,{className:`block h-full bg-primary transition-[width] motion-reduce:transition-none`,style:{width:`${o/a.length*100}%`}})})]}):(0,Y.jsx)(`span`,{children:n?`new commits since`:`latest commit`}),r!==null&&!t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-link`,onClick:r.onOpen,className:`inline-flex cursor-pointer items-center gap-1 font-medium text-primary underline-offset-2 hover:underline`,children:[(0,Y.jsx)(f_,{"aria-hidden":`true`,className:`size-3.5`}),`Tour · `,r.steps,` steps`]})]})]})},xW=({analysis:e,through:t,running:n,stale:r=!1,tour:i=null,onDetails:a})=>{let{intent:o,pullRequest:s}=e,c=o?.mismatches??[],l=s===null?``:pW(s.description),[u,d]=(0,J.useState)(o!==null),[f,p]=(0,J.useState)(!1);o!==null!==u&&(d(o!==null),p(o!==null&&n)),f&&!n&&p(!1);let m=(o!==null||s!==null)&&(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Details`,title:`Details`,onClick:a,className:`ml-1 rounded-full align-middle text-muted-foreground`,children:(0,Y.jsx)(Wg,{"aria-hidden":`true`})}),h=new Map(e.files.flatMap(e=>e.hunks.map(t=>[t.id,e.path]))),g=kU(e.unchangedCallers,e=>h.get(nl(e))),_=t!==null&&(0,Y.jsx)(vW,{lead:t.linked?`Through:`:`In:`,children:(0,Y.jsx)(gW,{through:t})}),v=g!==null&&(0,Y.jsx)(vW,{lead:`Watch:`,children:(0,Y.jsx)(_W,{reach:g})}),y=s!==null&&(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0`,children:[l===``?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,Y.jsx)(`span`,{children:l}),!f&&m]}),_,v]}),b=o!==null&&(0,Y.jsxs)(`div`,{"data-arriving":f||void 0,className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:mW,children:c.length>0||o.stated===null?`From the code:`:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-0.125em] text-review-approved`}),`Does what was asked:`]})}),` `,(0,Y.jsx)(hW,{text:o.inferred.summary}),m]}),o.inferred.shape===``?_:(0,Y.jsx)(vW,{lead:`Through:`,children:(0,Y.jsx)(hW,{text:o.inferred.shape})}),o.inferred.watch.length===0?v:(0,Y.jsx)(vW,{lead:`Watch:`,children:o.inferred.watch.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&` · `,(0,Y.jsx)(hW,{text:e})]},t))})]});return(0,Y.jsxs)(`div`,{"data-slot":`intent-brief`,className:`flex min-w-0 flex-col gap-1 text-body`,children:[(0,Y.jsx)(bW,{analysis:e,running:n,stale:r,tour:i}),b===!1?y:f?(0,Y.jsxs)(`div`,{"data-slot":`intent-swap`,className:`min-w-0`,children:[(0,Y.jsx)(`div`,{"data-leaving":!0,"aria-hidden":`true`,children:y}),b]}):b]})},SW=`rounded-full border bg-muted px-2 py-0.5 text-caption`,CW=({pullRequest:e,tickets:t,missingTicketKeys:n})=>{let r=e.description.trim();return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r===``?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,Y.jsx)(`p`,{className:`text-body whitespace-pre-line`,children:r}),(t.length>0||n.length>0)&&(0,Y.jsxs)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets`,children:[t.map(e=>(0,Y.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.key,` · `,e.summary]})},e.key)),n.map(e=>(0,Y.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,Y.jsxs)(`details`,{className:`group`,children:[(0,Y.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Commits (`,e.commits.length,`)`]}),(0,Y.jsx)(`ol`,{className:`mt-1 flex flex-col gap-1`,children:e.commits.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`font-mono text-code-compact text-muted-foreground`,children:e.sha.slice(0,7)}),` `,e.message.split(`
87
- `)[0]]},e.sha))})]})]})},wW={description:`Description`,commits:`Commits`,branch:`Branch name`},TW={unrequested:`Unrequested`,missing:`Missing`,contradicts:`Contradicts`},EW={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`},DW=`whitespace-pre-line`,OW=`text-caption font-medium text-muted-foreground`,kW=({ticketKey:e,ticket:t})=>t===void 0?(0,Y.jsxs)(`li`,{className:SW,title:`Jira didn't return this ticket, or Jira isn't configured`,children:[e,` · not fetched`]}):(0,Y.jsx)(`li`,{className:SW,children:(0,Y.jsxs)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,title:t.summary,children:[t.key,` · `,t.status]})}),AW=({stated:e,ticketOf:t,unfetched:n})=>(0,Y.jsxs)(Y.Fragment,{children:[e!==null&&(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Sources`,children:e.sources.map(e=>e.kind===`ticket`&&e.ref!==null?(0,Y.jsx)(kW,{ticketKey:e.ref,ticket:t.get(e.ref)},`ticket:${e.ref}`):e.kind===`ticket`?null:(0,Y.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:wW[e.kind]},e.kind))}),n.length>0&&(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets mentioned but not fetched`,children:n.map(e=>(0,Y.jsx)(kW,{ticketKey:e,ticket:void 0},e))})]}),jW=`No stated intent: the PR has no description or linked tickets.`,MW=({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,Y.jsx)(AW,{stated:i,ticketOf:s,unfetched:l}),d=o.length===0?i:null,{behaviorChanges:f}=a;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 text-body`,children:[o.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`p`,{children:[i===null?(0,Y.jsx)(`span`,{className:`font-medium`,children:`From the code:`}):(0,Y.jsx)(`span`,{className:`font-medium text-review-approved`,children:`✓ Does what was asked:`}),` `,(0,Y.jsx)(`span`,{className:DW,children:a.summary})]}),i===null&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:jW}),u]}):(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:OW,children:`Stated`}),i===null?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:jW}):(0,Y.jsx)(`p`,{className:DW,children:i.summary}),u]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:OW,children:`Inferred from the code`}),(0,Y.jsx)(`p`,{className:DW,children:a.summary})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:OW,children:`Mismatches`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsxs)(`span`,{className:X(`rounded-full border px-2 text-caption font-medium`,EW[e.kind]),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),TW[e.kind]]}),(0,Y.jsx)(`span`,{className:DW,children:e.description})]})},t))})]})]}),(d!==null||f.length>0)&&(0,Y.jsxs)(`details`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Details`,f.length>0&&` (${f.length})`]}),d!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:X(OW,`mt-2`),children:`Asked`}),(0,Y.jsx)(`p`,{className:DW,children:d.summary})]}),f.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:X(OW,`mt-2`),children:`Behavior changes`}),(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:f.map((e,t)=>(0,Y.jsx)(`li`,{className:DW,children:e},t))})]})]})]})},NW=3,PW=(e,t)=>{let n=e.end??t;return n===null?null:Math.max(0,n-e.start+1)},FW=e=>({head:e.newLines===0?e.newStart+1:e.newStart+e.newLines,base:e.oldLines===0?e.oldStart+1:e.oldStart+e.oldLines}),IW=e=>e.newLines===0?e.newStart+1:e.newStart,LW=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<NW},RW=e=>!e.binary&&e.status!==`added`&&e.status!==`deleted`,zW=(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=IW(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=FW(i),o=n[e+1],s=a.base-a.head;if(o===void 0){LW(i)||r.push({before:null,after:t,start:a.head,end:null,offset:s});continue}let c=IW(o.hunk)-1;c>=a.head&&r.push({before:o.id,after:t,start:a.head,end:c,offset:s})}return r},BW=(e,t)=>Array.from({length:PW(e,t)??0},(t,n)=>e.start+n),VW=e=>{let t=e.split(`
88
- `);return t.at(-1)===``&&t.pop(),t.map(e=>e.endsWith(`\r`)?e.slice(0,-1):e)},HW=(e,t)=>{let{client:n}=Pp(),[r,i]=(0,J.useState)({status:`idle`}),a=(0,J.useRef)(`idle`);return{text:r,load:(0,J.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:VW(e.value.content)}:{status:`error`,message:Gp(e.error)}))},[n,e,t])}},UW=()=>(0,Y.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,Y.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`})}),WW=e=>`${e} ${e===1?`line`:`lines`}`,GW=(e,t,n,r)=>e.map(e=>({oldNo:e+t.offset,newNo:e,text:n[e-1]??``,tokens:r?.[e-1]??null})),KW=({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=uj(c,t),u=PW(e,c?.length??null);if(u===0)return null;if(r&&c!==null)return(0,Y.jsx)(`div`,{"data-slot":`file-fold`,children:(0,Y.jsx)(cN,{hunkId:n,lines:GW(BW(e,c.length),e,c,l)})});let d=r&&i.status===`loading`,f=u===null?`Unchanged lines below`:`${WW(u)} unchanged`;return(0,Y.jsxs)(`div`,{"data-slot":`file-gap`,className:X(`flex flex-wrap items-center bg-surface-subtle text-muted-foreground`,AM,o&&`border-t`,s?`border-b`:`rounded-b-lg`),children:[(0,Y.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,Y.jsx)(UW,{}),d?(0,Y.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5`,children:[(0,Y.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,Y.jsx)(`span`,{children:f})]}),r&&i.status===`error`&&(0,Y.jsx)(`span`,{role:`alert`,className:`px-3 text-destructive`,children:i.message})]})},qW=e=>e===`map`?`map`:e===`overview`||e===`tree`?`overview`:void 0,JW=`Not classified yet.`,YW=e=>{let t=il(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 al(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=nl(e);return i.get(t)??{hunkId:t,riskClass:`logic`,reason:JW,source:`fallback`,lines:null,guidance:null}},c=e=>e.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[{...t,id:e,hunkId:nl(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))}},XW=(e,t)=>[...e.files].sort((e,t)=>NI(e.path,t.path)).flatMap(e=>{let n=t.partsInFile(e);return n.every(e=>t.mechanical.has(e))?[]:[{file:e,partIds:n}]}),ZW=(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)},QW=(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:$W(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:nl(u);for(let e of d)nl(e)!==f&&c(a,e,t)}return{cards:i,mentions:a,cardPart:o,unplaced:s}},$W=(e,t,n)=>t.find(t=>n.parts.get(t)?.hunk.lines.some(t=>{let n=kM(t);return n!==null&&n.side===e.side&&n.line===e.startLine})),eG=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},tG=(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))},nG=(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=kM(e);return t!==null&&t.side===r.side&&t.line===r.line}));e!==void 0&&n.set(e,[...n.get(e)??[],r])}return n},rG=e=>({files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}),iG=`mechanical-changes`,aG=e=>`file-${e}`,oG=(0,J.memo)(function({render:e}){return e()},(e,t)=>e.signature===t.signature),sG=({id:e,joined:t,deps:n,signatureOf:r})=>(0,Y.jsx)(`div`,{id:GU(e),className:X(`scroll-mt-24`,!t&&`border-t first:border-t-0`),"data-hunk-id":e,children:(0,Y.jsx)(oG,{signature:r(e),render:()=>(0,Y.jsx)(qU,{id:e,deps:n})})}),cG=({lines:e})=>e===0?null:(0,Y.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`,AM),children:(0,Y.jsxs)(`span`,{children:[e,` `,e===1?`line`:`lines`,` unchanged`]})}),lG=({analysisId:e,group:t,deps:n,signatureOf:r})=>{let i=n.index.items(t.partIds),a=i.reduce((e,t)=>e+WA(t.hunk).added,0),o=i.reduce((e,t)=>e+WA(t.hunk).deleted,0),s=n.openThreads(t.file.path),c=n.earlierThreads(t.file.path),{text:l,load:u}=HW(e,t.file.path),[d,f]=(0,J.useState)(new Set),p=(0,J.useMemo)(()=>RW(t.file)?zW(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,Y.jsx)(KW,{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,Y.jsxs)(`section`,{id:aG(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,Y.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,Y.jsx)(FO,{file:t.file,status:t.file.status,className:`min-w-0 flex-1`}),(0,Y.jsx)(IO,{status:t.file.status}),(0,Y.jsxs)(`span`,{className:`tabular flex flex-wrap items-center gap-x-1.5 text-caption`,children:[s>0&&(0,Y.jsxs)(`span`,{"data-slot":`count-threads`,className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,Y.jsx)(QI,{count:s}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,a]}),` `,(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,o]})]})]})]}),(0,Y.jsx)(`div`,{"data-slot":`file-lines`,className:`@container overflow-x-auto rounded-b-lg`,children:(0,Y.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:ZW(a,e,n.index),s=p.find(t=>t.before===e);return(0,Y.jsxs)(J.Fragment,{children:[s===void 0?o!==null&&(0,Y.jsx)(cG,{lines:o}):h(s),(0,Y.jsx)(sG,{id:e,joined:o===0||s!==void 0,deps:n,signatureOf:r})]},e)}),p.filter(e=>e.before===null).map(h)]})}),c!==null&&(0,Y.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,Y.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Earlier comments`}),c]})]})},uG=({analysis:e,files:t,deps:n,before:r,after:i,trailingProofs:a,mechanicalCount:o,scrollRequest:s,signatureOf:c})=>((0,J.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,Y.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":`Changes`,children:[r,t.map(t=>(0,Y.jsx)(lG,{analysisId:e.id,group:t,deps:n,signatureOf:c},t.file.path)),i,(0,Y.jsxs)(`div`,{id:iG,className:`flex scroll-mt-2 flex-col gap-4 -outline-offset-2`,tabIndex:-1,children:[o===0&&e.stages.prep===`done`&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No mechanical changes in this pull request.`}),(0,Y.jsx)(iN,{files:e.files,proofs:a,risk:e.risk}),(0,Y.jsx)(sN,{files:e.files})]})]})),dG={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`,guardrails:`Guardrails`,steps:`Tour`},fG=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`,pG=e=>`$${e.toFixed(2)}`,mG=e=>e===void 0?`—`:`${(e/1e3).toFixed(1)} s`,hG=e=>e===null?null:`${e.modelName} through ${e.providerName}`,gG=new Intl.ListFormat(`en`,{type:`conjunction`}),_G=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:gG.format(n)},vG=(e,t)=>{let n=hG(e),r=_G(t);return r===null?n:n===null?`With ${r}`:`${n} with ${r}`},yG=e=>e===null?`—`:pG(e),bG=(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=pG(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}`},xG=e=>e.inputTokens+e.cacheWriteTokens,SG=({usage:e,option:t=null,guidance:n=null})=>{let r=(0,J.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,Y.jsxs)(`div`,{className:`group relative flex justify-end`,children:[(0,Y.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:[vG(t,n)===null?``:`${vG(t,n)} · `,`Usage: `,fG(i(xG)),` tokens in ·`,` `,fG(i(e=>e.cacheReadTokens)),` cache read ·`,` `,fG(i(e=>e.outputTokens)),` out ·`,` `,bG(e.map(e=>e.costUsd),a,Il(t))]}),(0,Y.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,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,Y.jsx)(`th`,{scope:`col`,children:`In`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Cache read`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Out`}),(0,Y.jsx)(`th`,{scope:`col`,children:a?`At API prices`:`Cost`}),o&&(0,Y.jsx)(`th`,{scope:`col`,children:`Time`})]})}),(0,Y.jsx)(`tbody`,{children:e.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`row`,children:dG[e.pass]}),(0,Y.jsx)(`td`,{children:fG(xG(e))}),(0,Y.jsx)(`td`,{children:fG(e.cacheReadTokens)}),(0,Y.jsx)(`td`,{children:fG(e.outputTokens)}),(0,Y.jsx)(`td`,{children:yG(e.costUsd)}),o&&(0,Y.jsx)(`td`,{children:mG(e.durationMs)})]},e.pass))})]})]})},CG={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`,guardrails:`Guardrails`,steps:`Tour`},wG=e=>{let t=Math.round(e/1e3);return`+${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},TG=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`}`},EG=e=>[...e].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)||e.attempt-t.attempt),DG=({guidance:e,leftOut:t})=>{let n=_G(e);return n===null?null:(0,Y.jsxs)(`section`,{"aria-label":`What the run read beside the code`,className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`h3`,{className:`font-medium`,children:`Read beside the code`}),(0,Y.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,Y.jsx)(Q_,{to:R_,className:`underline`,children:`Preferences`})]}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1 text-ui`,children:[e.preferences.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(BB,{kind:e.kind}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 break-words`,children:e.text}),(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.scope.kind===`global`?`Everywhere`:HB(e.scope.repo)})]},e.ref)),e.guidelines.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono text-code-compact break-all`,children:e.path}),(0,Y.jsx)(`span`,{className:`tabular text-caption text-muted-foreground`,children:lV(e.bytes)})]},e.ref))]})]})},OG=({calls:e,option:t,guidance:n=null,leftOut:r=0})=>{let[i,a]=(0,J.useState)(!1),o=EG(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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>a(!0),children:`Run details…`}),i&&(0,Y.jsxs)(IH,{title:`${Bl(t)}'s calls`,onClose:()=>a(!1),className:`sm:max-w-3xl`,children:[(0,Y.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[hG(t)===null?``:`On ${hG(t)}. `,mG(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,Y.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,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Started`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Time`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Outcome`})]})}),(0,Y.jsx)(`tbody`,{children:o.map(e=>{let t=e.error===null?e.problems:[e.error.message];return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsxs)(`th`,{scope:`row`,children:[CG[e.pass],e.attempt>1&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · again`})]}),(0,Y.jsx)(`td`,{children:wG(Date.parse(e.startedAt)-c)}),(0,Y.jsx)(`td`,{children:mG(e.durationMs)}),(0,Y.jsxs)(`td`,{children:[(0,Y.jsx)(`span`,{className:e.outcome===`failed`?`text-destructive`:void 0,children:TG(e)}),t.length>0&&(0,Y.jsx)(`ul`,{className:`mt-1 list-disc pl-4 text-muted-foreground`,children:t.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]})]},`${e.pass}/${e.attempt}/${e.startedAt}`)})})]}),n!==null&&(0,Y.jsx)(DG,{guidance:n,leftOut:r})]})]})},kG={logic:`border-risk-logic-solid bg-risk-logic-bg text-risk-logic`,mechanical:`border-risk-mechanical-solid bg-risk-mechanical-bg text-risk-mechanical`},AG=`border-dashed border-input bg-surface-subtle text-muted-foreground`,jG={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`},MG=56,NG=24,PG=16,FG=120,IG=300,LG=7.2,RG=6.6,zG=6.7,BG=32,VG=24,HG=20,UG=380,WG=e=>e.slice(e.lastIndexOf(`/`)+1),GG=e=>e===1?`1 use`:`${e} uses`,KG=e=>e===1?`1 file`:`${e} files`,qG=e=>e.kind===`outside`?`${e.paths.length>1?`${KG(e.paths.length)} · `:``}outside the PR · ${GG(e.uses)}`:[e.kind===`group`?KG(e.paths.length):`+${e.added} −${e.deleted}`,...e.entries].join(` · `),JG=e=>BG+(e.kind===`group`&&e.paths.length>1?VG:0),YG=e=>{let t=t=>t.length*LG+JG(e)<=UG,n=e.label.endsWith(`/`)?`/`:``,r=AI(e.label.slice(0,e.label.length-n.length),e=>t(e+n));if(n!==``||t(r))return r+n;let i=r.lastIndexOf(`/`)+1,[a,o]=jI(r.slice(i)),s=r.slice(0,i);return s+OI(a,e=>t(s+e+o))+o},XG=e=>{let t=e.badges.reduce((e,t)=>e+WG(t).length*zG+14,0),n=Math.min(Math.max(YG(e).length*LG+JG(e),qG(e).length*RG+HG,t+HG),UG),r=FG+Math.sqrt(e.added+e.deleted)*9;return Math.round(Math.max(n,Math.min(r,IG)))},ZG=72,QG=(e,t)=>{let n=e.map(e=>e.reduce((e,t,n)=>e+XG(t)+(n>0?NG:0),0)),r=Math.max(0,...n)+32,i=r+(t?ZG:0),a=new Map;return e.forEach((e,t)=>{let i=(r-(n[t]??0))/2;for(let n of e){let e=XG(n);a.set(n.key,{x:i,y:PG+t*120,width:e}),i+=e+NG}}),{boxes:a,width:i,height:e.length===0?0:32+e.length*64+(e.length-1)*MG}},$G=e=>e.outside?`outside`:e.uses.includes(`request`)?`request`:e.uses.includes(`call`)?`call`:e.uses.every(e=>e===`import`)?`import`:`type`,eK=(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}},tK=(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-ZG/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(MG/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(MG/2,(s-o)/2);return`M ${i} ${o} C ${i} ${o+c} ${a} ${s-c} ${a} ${s}`},nK={import:`imports`,call:`calls`,type:`uses types from`,request:`sends requests to`},rK=(e,t)=>{let n=e.uses.map(e=>nK[e]).join(`, `),r=e.symbols.length>0?`: ${e.symbols.join(`, `)}`:``;return`${t(e.from)} ${n} ${t(e.to)}${r}`},iK=({node:e,box:t,active:n,current:r,onOpen:i,onExpand:a,onFocus:o})=>{let s=e.kind===`group`,c=s&&e.paths.length>1,l=e.kind===`outside`,u=(l?[e.label,qG(e)]:[e.label,s?KG(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,Y.jsxs)(`div`,{"data-slot":`overview-node-box`,className:X(`grid`,t===void 0?`relative`:`absolute`),style:t===void 0?{width:XG(e)}:{left:t.x,top:t.y,width:t.width,height:64},children:[(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`overview-node`,"data-risk":l?`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`,l?AG:kG[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":u,"aria-current":r?`location`:void 0,title:s?`${e.key.slice(6)}/`:e.paths.length===1?e.paths[0]:void 0,onClick:()=>i(e),onFocus:()=>o(e),onMouseEnter:()=>o(e),onMouseLeave:()=>o(null),children:[(0,Y.jsx)(`span`,{className:X(`flex min-w-0 items-baseline gap-2`,c&&`pr-6`),children:(0,Y.jsx)(`span`,{"data-slot":`overview-label`,className:`min-w-0 truncate font-mono text-code-compact font-semibold`,children:YG(e)})}),(0,Y.jsx)(`span`,{className:`truncate`,children:qG(e)}),e.badges.length>0&&(0,Y.jsx)(`span`,{className:`flex gap-1 overflow-hidden`,children:e.badges.map(e=>(0,Y.jsx)(`span`,{className:`shrink-0 rounded-sm border border-current px-1 font-mono text-kbd`,children:WG(e)},e))})]}),c&&(0,Y.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,Y.jsx)(Jg,{"aria-hidden":`true`})})]})},aK=({overview:e,focusKey:t,currentPath:n,onOpen:r,onExpand:i,onCollapse:a,expandedGroups:o,onFocusNode:s})=>{let c=(0,J.useId)(),l=(0,J.useRef)(null),[u,d]=(0,J.useState)(null),{boxes:f,width:p,height:m}=(0,J.useMemo)(()=>QG(e.rows,e.edges.some(e=>e.back)),[e]),h=(0,J.useMemo)(()=>eK(e.edges,f),[e.edges,f]),g=(0,J.useMemo)(()=>new Map([...e.rows.flat(),...e.strip].map(e=>[e.key,e.label])),[e]),_=e=>g.get(e)??e,v=(0,J.useMemo)(()=>[...e.rows,e.strip].filter(e=>e.length>0),[e]);(0,J.useEffect)(()=>d(null),[e]);let y=(0,J.useRef)(-1);(0,J.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,Y.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Overview of the changed files`,ref:l,onKeyDown:x,children:[(0,Y.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,Y.jsx)(`p`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>a(e),children:[`Collapse `,e.slice(6),`/`]},e))}),e.rows.length>0?(0,Y.jsx)(`div`,{"data-slot":`overview-scroll`,className:`overflow-x-auto rounded-lg border bg-surface-subtle`,children:(0,Y.jsxs)(`div`,{"data-slot":`overview-diagram`,className:`relative mx-auto`,style:{width:p,height:m},children:[(0,Y.jsxs)(`svg`,{className:`absolute inset-0 overflow-visible`,width:p,height:m,"aria-hidden":`true`,children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`marker`,{id:`${c}-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.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=tK(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,Y.jsxs)(`g`,{"data-slot":`overview-edge`,"data-style":$G(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,Y.jsx)(`path`,{d:r,className:`fill-none stroke-transparent [stroke-width:10]`}),(0,Y.jsx)(`path`,{d:r,className:X(`fill-none stroke-input [stroke-width:1.5]`,jG[$G(e)],i&&`stroke-primary [stroke-width:2]`),markerEnd:`url(#${c}-arrow)`}),(0,Y.jsx)(`title`,{children:rK(e,_)})]},`${e.from}>${e.to}`)})]}),e.rows.flat().map(e=>(0,Y.jsx)(iK,{box:f.get(e.key),...E(e)},e.key))]})}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No changed file calls or imports another.`}),e.strip.length>0&&(0,Y.jsxs)(`section`,{"aria-label":`Not linked`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Not linked`}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.strip.map(e=>(0,Y.jsx)(iK,{...E(e)},e.key))})]}),(0,Y.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`?rK(u.edge,_):oK(u.node,e.edges,_)})]})},oK=(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(WG).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(WG).join(`, `)}`]:[]].join(` · `)}.`},sK=e=>`point-${e}`,cK={contradicts:`Contradicts what was asked`,missing:`Asked for, not done`,unrequested:`Done, not asked for`},lK={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},uK=({kind:e})=>{let t=DD[e];return(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 font-medium`,lK[e]),children:[(0,Y.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),ED[e].label]})},dK=({point:e,state:t,current:n,note:r,action:i,className:a,leftOut:o=!1})=>{let s=DD[e.kind];return(0,Y.jsxs)(`article`,{id:sK(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&&CK),children:[(0,Y.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[ED[e.kind].label,`: `]}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-40 truncate`,t===`dismissed`&&`line-through`),children:e.title}),(0,Y.jsx)(`span`,{className:`max-w-full min-w-0 truncate text-caption`,children:r}),i]})},fK=({effect:e,preferenceId:t})=>{let n=t===null?``:` your preference:`;return e===`raised`?`From${n}`:`Left out by${n}`},pK=({guidance:e,className:t})=>{let n=e.preferenceId===null?Sg:w_;return(0,Y.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,Y.jsx)(n,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[fK(e),` `,(0,Y.jsx)(Q_,{to:R_,className:X(`underline`,e.preferenceId===null&&`font-mono text-code-compact`),children:e.label})]})]})},mK=({point:e,guidance:t,state:n,current:r,onShow:i})=>(0,Y.jsx)(dK,{point:e,state:n,current:r,leftOut:!0,note:`${fK(t)} ${t.label}`,className:EK,action:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,"aria-label":`Show: ${e.title}`,onClick:i,children:`Show`})}),hK=(e,t,n)=>{let r=(0,J.useRef)(null),i=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{!e&&i.current&&(i.current=!1,r.current?.focus())},[e]),{card:r,show:()=>{i.current=!0,t(n)}}},gK=({point:e,size:t,disabled:n,onDismiss:r,onRule:i})=>(0,Y.jsxs)(`span`,{className:`flex items-center`,children:[(0,Y.jsxs)($,{variant:`ghost`,size:t,disabled:n,"aria-label":`Dismiss: ${e.title}`,className:`rounded-r-none`,onClick:r,children:[t===`sm`&&(0,Y.jsx)(I_,{"aria-hidden":`true`}),`Dismiss`]}),(0,Y.jsxs)(vB,{children:[(0,Y.jsx)(yB,{render:(0,Y.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,Y.jsx)(ig,{"aria-hidden":`true`})}),(0,Y.jsx)(bB,{align:`end`,className:`w-64`,children:(0,Y.jsxs)(CB,{onClick:i,children:[(0,Y.jsx)(wg,{"aria-hidden":`true`}),`Don't flag things like this…`]})})]})]}),_K=({point:e,scopes:t,onSave:n,onCancel:r})=>{let[i]=t;return i===void 0?null:(0,Y.jsxs)(`div`,{"data-slot":`point-rule`,className:`flex flex-col gap-2 rounded-md border bg-card p-3`,children:[(0,Y.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,Y.jsx)(FH,{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})]})},vK=(e,t)=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.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}}},yK=e=>e?(0,Y.jsxs)(Y.Fragment,{children:[`Dismissed, and saved to your`,` `,(0,Y.jsx)(Q_,{to:R_,className:`underline`,children:`preferences`})]}):`Dismissed`,bK={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`}},xK=({severity:e})=>(0,Y.jsxs)(`span`,{"data-slot":`severity`,className:X(gM,bK[e].className),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:bK[e].glyph}),e]}),SK=`animate-in duration-(--duration-slow) fade-in-0 slide-in-from-top-1`,CK=`shadow-[inset_0_0_0_2px_var(--ring)]`,wK=`relative max-w-3xl rounded-lg border bg-thread-bg`,TK=`scroll-mt-[calc(6rem+var(--lines-above)*var(--text-code--line-height))] -outline-offset-2`,EK=X(wK,`px-3 py-1.5`),DK={finding:`bg-review-changes`,risk:`bg-risk-contract-solid`},OK=({kind:e})=>(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`absolute top-2 bottom-2 left-1.5 w-[3px] rounded-full`,DK[e])}),kK=(0,J.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,family:h=`Claude`}){let g=(0,J.useId)(),{card:_,show:v}=hK(s,c,e.id),y=vK(e,u);if(t===`dismissed`)return(0,Y.jsx)(dK,{point:e,state:t,current:i,note:yK(y.saved),className:EK,action:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(t===`raised`&&d)return(0,Y.jsx)(dK,{point:e,state:t,current:i,note:`In your review, below`,className:`max-w-3xl px-1`,action:(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓`})});if(s&&e.guidance!==void 0)return(0,Y.jsx)(mK,{point:e,guidance:e.guidance,state:t,current:i,onShow:v});let b=r||n;return(0,Y.jsxs)(`article`,{ref:_,id:sK(e.id),"data-slot":`point`,"data-kind":`finding`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${g}-title`,tabIndex:-1,style:Ph({"--lines-above":m}),className:X(wK,TK,`flex flex-col gap-2 py-2.5 pr-4 pl-5`,i&&CK),children:[(0,Y.jsx)(OK,{kind:`finding`}),(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(uK,{kind:`finding`}),e.severity!==null&&(0,Y.jsx)(xK,{severity:e.severity}),(0,Y.jsx)(`span`,{className:X(gM,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:`Draft`}),e.lines!==null&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[`on`,` `,(0,Y.jsx)(xA,{children:bA(e.lines.side,e.lines.startLine,e.lines.line)})]}),(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,Y.jsx)(bg,{"aria-hidden":`true`,className:`size-3.5`}),`Only you see this`]})]}),(0,Y.jsx)(`h3`,{id:`${g}-title`,className:`font-semibold`,children:e.title}),e.explanation!==``&&(0,Y.jsx)(hM,{blocks:rf(e.explanation).blocks,suggestion:()=>null}),e.mismatch!==null&&(0,Y.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[cK[e.mismatch.kind],`:`]}),` `,e.mismatch.description]}),e.guidance!==void 0&&(0,Y.jsx)(pK,{guidance:e.guidance}),e.guardrail!==void 0&&(0,Y.jsx)(UU,{guardrail:e.guardrail,family:h}),e.suggestion!==null&&(0,Y.jsx)(hj,{title:`Suggested change`,removed:f,added:e.suggestion,language:p}),y.writing?(0,Y.jsx)(_K,{point:e,scopes:l,onSave:y.save,onCancel:()=>{y.setWriting(!1),_.current?.focus()}}):(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.jsx)(gK,{point:e,size:`sm`,disabled:b,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>y.setWriting(!0)}),e.lines!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,disabled:b,"aria-label":`Edit: ${e.title}`,onClick:()=>a(e,!1),children:[(0,Y.jsx)(o_,{"aria-hidden":`true`}),`Edit`]}),(0,Y.jsx)($,{size:`sm`,disabled:b,"aria-label":`Add to review: ${e.title}`,onClick:()=>a(e,!0),children:`Add to review`})]})]})]})}),AK=e=>e.slice(e.lastIndexOf(`/`)+1),jK=({checkedBy:e,peek:t,id:n})=>{let r=(0,Y.jsx)(`span`,{className:`font-code text-code-compact`,children:e.test});return(0,Y.jsxs)(`p`,{"data-slot":`checked-by`,className:`flex items-start gap-1.5 pb-0.5 text-muted-foreground`,children:[(0,Y.jsx)(Eg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:`Checked by`}),` `,t===null?r:(0,Y.jsx)(BM,{handle:t.handle,payload:t.payload,id:n,render:(0,Y.jsx)(`button`,{type:`button`,className:`text-left text-foreground`}),children:r}),` `,`in `,AK(e.path),`, which asserts: `,e.checks]})]})},MK=(0,J.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,family:p=`Claude`}){let m=(0,J.useId)(),{card:h,show:g}=hK(s,c,e.id),_=vK(e,u);if(t===`dismissed`)return(0,Y.jsx)(dK,{point:e,state:t,current:i,note:yK(_.saved),className:EK,action:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(s&&e.guidance!==void 0)return(0,Y.jsx)(mK,{point:e,guidance:e.guidance,state:t,current:i,onShow:g});let v=r||n;return(0,Y.jsxs)(`article`,{ref:h,id:sK(e.id),"data-slot":`point`,"data-kind":`risk`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${m}-title`,tabIndex:-1,style:Ph({"--lines-above":d}),className:X(wK,TK,`flex flex-col gap-0.5 py-1.5 pr-2 pl-5`,i&&CK),children:[(0,Y.jsx)(OK,{kind:`risk`}),(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(uK,{kind:`risk`}),e.lines!==null&&(0,Y.jsx)(xA,{children:bA(e.lines.side,e.lines.startLine,e.lines.line)}),t===`raised`&&(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:v||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>a(e,!1),children:`Comment`}),(0,Y.jsx)(gK,{point:e,size:`xs`,disabled:v,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>_.setWriting(!0)})]})]}),(0,Y.jsx)(`h3`,{id:`${m}-title`,className:`pb-0.5 font-normal`,children:e.title}),e.checkedBy!==void 0&&(0,Y.jsx)(jK,{checkedBy:e.checkedBy,peek:f,id:`${sK(e.id)}-test`}),e.guidance!==void 0&&(0,Y.jsx)(pK,{guidance:e.guidance,className:`pb-0.5`}),e.guardrail!==void 0&&(0,Y.jsx)(UU,{guardrail:e.guardrail,family:p,className:`pb-0.5`}),_.writing&&(0,Y.jsx)(`div`,{className:`py-1.5 pr-2`,children:(0,Y.jsx)(_K,{point:e,scopes:l,onSave:_.save,onCancel:()=>{_.setWriting(!1),h.current?.focus()}})})]})}),NK=({point:e,state:t,open:n,current:r,onToggle:i})=>{let a=DD.decision;return(0,Y.jsxs)(`button`,{type:`button`,id:sK(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(`mt-px ml-3 inline-flex min-h-5 scroll-mt-24 items-center gap-1 rounded-full border bg-background px-2 align-top font-sans text-caption text-muted-foreground hover:text-foreground`,t===`dismissed`&&`line-through`,r&&CK),onClick:t=>{t.stopPropagation(),i(e.id)},children:[(0,Y.jsx)(a,{"aria-hidden":`true`,className:`size-3`}),e.title]})},PK=({point:e,state:t,saving:n,readOnly:r,onRaise:i,onState:a})=>{let o=r||n;return(0,Y.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`,SK),children:[(0,Y.jsxs)(`p`,{className:`min-w-0 flex-1 basis-80 text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.title,`.`]}),` `,e.explanation]}),(0,Y.jsx)(`span`,{className:`flex items-center gap-1`,children:t===`dismissed`?(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>a(e.id,`open`),children:`Show again`}):(0,Y.jsxs)(Y.Fragment,{children:[t===`raised`&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:o||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>i(e,!1),children:`Comment`}),(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:o,"aria-label":`Hide: ${e.title}`,onClick:()=>a(e.id,`dismissed`),children:`Hide`})]})})]})},FK=({point:e,onGo:t})=>{let n=DD[e.kind];return(0,Y.jsxs)(`p`,{"data-slot":`point-mention`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(n,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),ED[e.kind].label,`:`,` `,(0,Y.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})]})},IK=({pointId:e,fresh:t,at:n,row:r=!1,className:i,bodyClassName:a,children:o})=>(0,Y.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:Ph({"--landing-i":n}),className:i,children:(0,Y.jsx)(`div`,{role:r?`cell`:void 0,children:(0,Y.jsx)(`div`,{className:a,children:o})})}),LK={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},RK=({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,J.useRef)(!1),[c,l]=t===null?[`point`,`points`]:LK[t];return(0,Y.jsx)(IH,{title:`${o.length} ${o.length===1?c:l} from ${a}`,onClose:i,returnFocus:()=>!s.current,className:`sm:max-w-2xl`,children:(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-1`,"aria-label":`Points`,children:o.map(e=>{let{label:t}=ED[e.kind],i=DD[e.kind],a=n(e.id);return(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(i,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[t,`: `]}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,a===`dismissed`&&`line-through`),children:e.title}),a!==`open`&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:a===`raised`?`Raised`:`Dismissed`}),e.path!==null&&(0,Y.jsx)(`span`,{className:`truncate font-mono text-code-compact text-muted-foreground`,children:e.path})]})},e.id)})})})},zK=(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}},BK=(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},VK=(e,t,n)=>{if(t===null)return null;let r=zK(e,t,n);return r.at===null?r.steps[0]?.id??null:null},HK={finding:`findings`,risk:`risks`,decision:`decisions`},UK={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},WK=({kind:e})=>{let t=DD[e];return(0,Y.jsx)(t,{"aria-hidden":`true`,className:X(`size-3.5 shrink-0`,UK[e])})},GK=({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,Y.jsxs)(`span`,{"data-slot":e,className:`flex min-w-0 items-center gap-0.5`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Previous ${t}`,disabled:n===0,onClick:()=>s(-1),children:(0,Y.jsx)(og,{"aria-hidden":`true`})}),(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:`tabular`,"aria-label":r===null?`${i}, show all`:`${u} ${l}, show all`,onClick:c,children:l}),(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Next ${t}`,disabled:n===0,onClick:()=>s(1),children:(0,Y.jsx)(cg,{"aria-hidden":`true`})}),a,(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:o})]})},KK=({points:e,current:t,stateOf:n,kind:r,onGo:i,onOpenList:a})=>{let o=zK(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} ${HK[r]}`,d=l!==void 0&&n(l.id)===`dismissed`;return(0,Y.jsx)(GK,{slot:`point-stepper`,noun:`point`,total:s.length,at:c,count:u,onStep:e=>{let t=BK(o,e);t!==null&&i(t)},onOpenList:a,title:l!==void 0&&(0,Y.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 ${ED[l.kind].label.toLowerCase()}: ${l.title}`,onClick:()=>i(l.id),children:[(0,Y.jsx)(WK,{kind:l.kind}),(0,Y.jsx)(`span`,{className:X(`min-w-0 truncate`,d&&`text-muted-foreground line-through`),children:l.title})]}),status:l===void 0||c===null?``:`${ED[l.kind].label} ${c+1} of ${s.length}: ${l.title}${d?` (dismissed)`:``}`})},qK={collect:`Collect`,prep:`Prepare`,intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`,steps:`Tour`},JK={pending:`waiting`,running:`running`,done:`done`,failed:`failed`,skipped:`skipped`},YK={pending:`text-muted-foreground`,running:`text-primary font-medium`,done:`text-review-approved`,failed:`text-destructive font-medium`,skipped:`text-muted-foreground`},XK={pending:`○`,running:`◐`,done:`●`,failed:`✗`,skipped:`–`},ZK=({stages:e,shown:t,filesFetched:n})=>(0,Y.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,Y.jsxs)(`li`,{"data-status":r,className:YK[r],children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:XK[r]}),` `,qK[t],(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`: `,JK[r]]}),t===`collect`&&r===`running`&&n!==null&&(0,Y.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[` `,`· `,n.done,` of `,n.total,` files`]})]},t)})}),QK=e=>qK[e],$K=Mu.options.filter(e=>!Zu.includes(e)&&e!==`steps`),eq=({legend:e,options:t,value:n,onChange:r})=>(0,Y.jsxs)(`fieldset`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:e}),t.map(e=>(0,Y.jsx)(QM,{variant:`outline`,size:`sm`,pressed:n===e.value,disabled:e.disabled===!0,onPressedChange:t=>{t&&r(e.value)},children:e.label},e.value))]}),tq=[{value:`comment`,label:`Comment`},{value:`approve`,label:`Approve`},{value:`request_changes`,label:`Request changes`}],nq=`whitespace-pre-wrap wrap-anywhere`,rq=(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`}`},iq=({analysisId:e,hunkComments:t,isAuthor:n,published:r,onClose:i,onPublished:a})=>{let{client:o}=Pp(),s=(0,J.useId)(),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(`comment`),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),[b]=(0,J.useState)(()=>uf.parse(crypto.randomUUID())),x=Hp(o.publish);(0,J.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=rq(S,f?.comments.length??t.length),w=f!==null&&df({...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,S):r.error.code===`stale-analysis`&&(x.reset(),_(!0))};return(0,Y.jsxs)(IH,{title:`Publish review`,onClose:i,className:`flex flex-col sm:max-w-2xl`,children:[r&&(0,Y.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,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Reading the comments…`}):f.comments.length>0&&(0,Y.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,Y.jsx)(`ul`,{"aria-label":`Comments`,className:`flex flex-col gap-1.5`,children:f.comments.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 border-l-2 border-l-review-pending py-0.5 pl-2.5`,children:[(0,Y.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,Y.jsx)(`p`,{className:nq,children:e.body})]},e.key))})}):(0,Y.jsxs)(`p`,{className:dF,role:`alert`,children:[`Couldn't read what will be posted. `,Gp(m)]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`Verdict`}),(0,Y.jsx)(eq,{legend:`Verdict`,options:tq.map(e=>({...e,disabled:n&&e.value!==`comment`})),value:S,onChange:d})]}),n&&(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`label`,{htmlFor:`${s}-summary`,className:`sr-only`,children:`Summary`}),(0,Y.jsx)(Vk,{id:`${s}-summary`,rows:2,"data-autofocus":!0,placeholder:`Summary (optional)`,value:c,onChange:e=>l(e.target.value)})]}),g?(0,Y.jsxs)(`div`,{className:X(fF,`flex flex-col gap-2`),role:`alert`,children:[(0,Y.jsx)(`p`,{children:`This PR changed since the analysis. Publish anyway?`}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,onClick:()=>_(!1),children:`Cancel`}),(0,Y.jsx)($,{onClick:()=>void T(!0),children:`Publish anyway`})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[x.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't publish. `,Gp(x.error)]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Retrying is safe: comments that were already posted aren't posted again.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[w&&(0,Y.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,Y.jsx)($,{variant:`outline`,onClick:i,children:`Cancel`}),(0,Y.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`})]})]})]})]})},aq=({children:e})=>(0,Y.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}),oq=({analysisId:e,family:t,onRemoved:n})=>{let{client:r}=Pp(),i=Hp(r.removeModelRun),[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>o(!0),children:`Remove AI review…`}),a&&(0,Y.jsxs)(IH,{title:`Remove AI review`,onClose:()=>{o(!1),i.reset()},children:[(0,Y.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,Y.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. `,Gp(i.error)]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:()=>o(!1),children:`Cancel`}),(0,Y.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`})]})]})]})},sq=({analysisId:e,view:t,family:n,chosen:r,tour:i,onClose:a,onRestart:o})=>{let{client:s}=Pp(),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),m=async()=>{l(!0),d(null);let n=f;if(n===null){let t=await s.removeModelRun(e);if(!t.ok)return l(!1),d({error:t.error,removed:!1});n=t.value,p(n)}let a=await s.runModel(e,{optionId:r.id,...i?{tour:!0}:{}});if(!a.ok)return l(!1),d({error:a.error,removed:!0});let c=await s.getAnalysis(e);o(c.ok?c.value:{...t,...n})},h=()=>{f===null?a():o({...t,...f})};return(0,Y.jsxs)(IH,{title:`Re-run AI review`,onClose:h,children:[(0,Y.jsxs)(`p`,{className:`text-ui`,children:[n,`'s intent, findings, risks and decisions go, with what you did with them, and`,` `,r.modelName,` through `,r.via,` reads the PR again. Your comments stay.`]}),u!==null&&(0,Y.jsxs)(`p`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[u.removed?`The old run is gone, but the new one couldn't start.`:`Couldn't remove the old run.`,` `,Gp(u.error)]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:h,children:f===null?`Cancel`:`Close`}),(0,Y.jsx)($,{variant:`ai`,disabled:c,onClick:()=>void m(),children:c?`Starting…`:u?.removed?`Try again`:`Re-run`})]})]})},cq=()=>{let e=(0,J.useRef)(null),[t,n]=(0,J.useState)(!1);return(0,J.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}},lq=({title:e,claude:t,tools:n,publish:r,verdict:i,hairline:a,stuck:o})=>{let s=cq(),c=o??s.stuck;return(0,Y.jsxs)(`div`,{ref:s.bar,"data-slot":`review-bar`,"data-stuck":c||void 0,className:`sticky top-0 z-20 flex h-(--review-bar-row,var(--review-bar-h)) min-w-0 items-center gap-3 border-y bg-background`,children:[a!==null&&(0,Y.jsx)(`span`,{"data-slot":`model-hairline`,"data-state":a,"aria-hidden":`true`,children:(0,Y.jsx)(`span`,{})}),c&&e!==null&&(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`flex max-w-96 shrink items-center gap-3 max-xl:hidden`,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold motion-safe:animate-in motion-safe:fade-in`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`h-4.5 w-px shrink-0 bg-border`})]}),(0,Y.jsx)(`div`,{"data-slot":`claude-slot`,className:`flex min-w-0 flex-1 items-center`,children:t}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n}),i!==null&&(0,Y.jsxs)(`p`,{role:`status`,"data-slot":`your-verdict`,className:X(`flex shrink-0 items-center gap-1 font-medium`,uq[i.kind].className),children:[(0,Y.jsx)(dq,{kind:i.kind}),i.url===null?uq[i.kind].label:(0,Y.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,className:`text-inherit`,children:uq[i.kind].label})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]})},uq={approved:{label:`Approved`,className:`text-review-approved`},"changes-requested":{label:`Changes requested`,className:`text-review-changes`},commented:{label:`Commented`,className:`text-muted-foreground`},published:{label:`Published`,className:`text-review-approved`}},dq=({kind:e})=>(0,Y.jsx)(e===`changes-requested`?I_:e===`commented`?n_:ng,{"aria-hidden":`true`,className:`size-4`}),fq=2,pq=()=>(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-border`}),mq=({error:e,onRetry:t})=>(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:`h-6 px-1.5 font-normal text-muted-foreground`,"data-slot":`status-unavailable`,children:`Status unavailable`})}),(0,Y.jsxs)(IN,{align:`end`,children:[(0,Y.jsx)(LN,{children:`The PR's status couldn't be read`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:Gp(e)}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:`self-start`,onClick:t,children:`Try again`})]})]}),hq={github:`GitHub`,bitbucket:`Bitbucket`},gq=({name:e})=>(0,Y.jsx)(`code`,{className:`rounded-sm bg-secondary px-1 font-mono text-code-compact text-foreground`,children:e}),_q=({view:e,intent:t,totals:n,status:r,statusError:i,onRetryStatus:a,now:o})=>{let{analysis:s}=e,{pullRequest:c,warnings:l}=s,{ref:u}=s.key,d=[r===null&&i!==null&&(0,Y.jsx)(mq,{error:i,onRetry:a},`unavailable`),r!==null&&(r.checks===null||r.checks.length>0)&&(0,Y.jsx)(GN,{checks:r.checks,unreadable:r.checksUnreadable,head:s.key.headSha},`ci`),r!==null&&r.reviewers.length>0&&(0,Y.jsx)(ZN,{reviewers:r.reviewers},`reviewers`)].filter(e=>e!==!1).flatMap((e,t)=>t===0?[e]:[(0,Y.jsx)(pq,{},`before-${e.key}`),e]);return(0,Y.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`h1`,{className:`min-w-0 text-title font-semibold tracking-[-0.01em] whitespace-pre-line`,children:c?.title??`Collecting the pull request…`}),(0,Y.jsxs)(`a`,{className:`-ml-1.5 text-title text-muted-foreground no-underline hover:underline`,href:c?.url??jf(u),target:`_blank`,rel:`noreferrer`,title:`Open on ${hq[u.repo.host]}`,children:[`#`,u.number]}),r!==null&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zN,{state:r.state}),(0,Y.jsx)(BN,{status:r.reviewStatus})]}),d.length>0&&(0,Y.jsx)(`div`,{"data-slot":`pr-standing`,className:`ml-auto flex flex-wrap items-center gap-x-3 gap-y-1`,children:d})]}),(0,Y.jsxs)(`p`,{"data-slot":`pr-byline`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:u.repo.repo}),c!==null&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:c.author.name}),` wants to merge `,(0,Y.jsx)(gq,{name:c.sourceBranch}),` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:`into`}),` `,(0,Y.jsx)(gq,{name:c.targetBranch})]}),` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`span`,{children:[`updated `,vA(c.updatedAt,o)]})]}),s.stages.prep===`done`&&n.additions+n.deletions>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{"aria-hidden":`true`,children:[n.additions>0&&(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,n.additions]}),n.additions>0&&n.deletions>0&&` `,n.deletions>0&&(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,n.deletions]})]}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[n.additions,` lines added, `,n.deletions,` removed`]})]})]})]}),(0,Y.jsx)(`div`,{className:`mt-3 max-w-[980px]`,children:t}),l.length>0&&l.length<=fq&&(0,Y.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Warnings`,children:l.map(e=>(0,Y.jsxs)(`li`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),e]},e))}),l.length>fq&&(0,Y.jsxs)(`details`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,Y.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),l.length,` warnings`]}),(0,Y.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]})]})},vq=e=>`thread-${e}`,yq=e=>`${e.side}:${e.line}`,bq={onLine:new Map,earlier:new Map,elsewhere:[],open:new Map},xq=(e,t,n)=>e.set(t,[...e.get(t)??[],n]),Sq=(e,t,n)=>{if(e===null||e.length===0)return bq;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=kM(e);return n!==null&&n.side===t.side&&n.line===c}));if(l===void 0||c===null){xq(a,t.path,t);continue}let u=i.get(l)??new Map;xq(u,yq({side:t.side,line:c}),t),i.set(l,u)}return{onLine:i,earlier:a,elsewhere:o,open:s}},Cq=(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},wq=(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=kM(e);if(t===null)continue;let n=yq(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},Tq=(e,t,n)=>t===`all`?e:e.filter(e=>!e.resolved||n.has(e.id)),Eq=(e,t,n)=>e===null?Tq(t,`unresolved`,n).length>0?`unresolved`:`all`:e,Dq=(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},Oq=(e,t,n)=>`${e} ${e===1?t:n}`,kq=e=>(e.line??e.originalLine)===null?`the file`:yM(e.outdated?{...e,line:null}:e),Aq=e=>{let[t]=e.comments;if(t===void 0)return kq(e);let n=Vd(t.body);return`${t.author.name}: ${n===``?`Suggested change`:n}`},jq=(e,t)=>e===`unresolved`?`${t} unresolved`:Oq(t,`thread`,`threads`),Mq=(e,t,n)=>{if(e.length===0)return null;let r=Tq(e,t,n).length;return t===`unresolved`?{count:r,words:[`unresolved`,`unresolved`],label:Oq(r,`unresolved thread`,`unresolved threads`)}:{count:r,words:[`thread`,`threads`],label:Oq(r,`thread`,`threads`)}},Nq=({resolved:e})=>e?(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-review-approved`}):(0,Y.jsx)(n_,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),Pq=({ordered:e,scope:t,resolvedHere:n,current:r,onGo:i,onOpenList:a})=>{let o=Tq(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?``:Aq(l);return(0,Y.jsx)(GK,{slot:`thread-stepper`,noun:`thread`,total:o.length,at:c,count:jq(t,o.length),onStep:t=>{let n=Dq(e,o,r,t);n!==null&&i(n)},onOpenList:a,title:l!==void 0&&(0,Y.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}, ${kq(l)}`,"aria-label":`Go to thread: ${u}`,onClick:()=>i(l.id),children:[(0,Y.jsx)(Nq,{resolved:l.resolved}),(0,Y.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} ${kq(l)}${l.resolved?`, resolved`:l.outdated?`, outdated`:``}: ${u}`})},Fq=({ordered:e,scope:t,onScope:n,onGo:r,onClose:i})=>{let a=e.filter(e=>!e.resolved).length,o=(0,J.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,Y.jsxs)(IH,{title:`${Oq(e.length,`thread`,`threads`)}, ${a} unresolved`,onClose:i,returnFocus:()=>!o.current,className:`sm:max-w-2xl`,children:[a>0&&a<e.length&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`Previous and Next go round`}),(0,Y.jsx)(eq,{legend:`Previous and Next go round`,options:[{value:`unresolved`,label:`Unresolved (${a})`},{value:`all`,label:`All (${e.length})`}],value:t,onChange:n})]}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:s.map(({path:e,threads:t})=>(0,Y.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h3`,{className:`truncate px-2 font-mono text-code-compact text-muted-foreground`,children:e}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(Nq,{resolved:e.resolved}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,e.resolved&&`text-muted-foreground`),children:Aq(e)}),(e.resolved||e.outdated)&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.resolved?`Resolved`:`Outdated`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:kq(e)})]})},e.id))})]},t[0]?.id??e))})]})},Iq={steps:`The rest of the steps' files`,tests:`Tests`,generated:`Generated and mechanical`,other:`Other files`},Lq=(e,t=0,n=e.lines.length)=>e.lines.slice(t,n).filter(e=>e.kind!==`context`).length,Rq=(e,t)=>{let n=n=>{let r=e.lines[n];return t.side===`new`?r?.newLine:r?.oldLine},r=e.lines.flatMap((e,r)=>{let i=n(r);return i!=null&&i>=t.startLine&&i<=t.line?[r]:[]}),i=r[0],a=r.at(-1);return i===void 0||a===void 0?null:{start:i,end:a+1}},zq=(e,t)=>e.start<t.end&&t.start<e.end,Bq=(e,t,n,r=()=>`open`)=>{if(e.steps===null||e.steps.length<3)return null;let i=new Map(e.files.flatMap(e=>e.hunks.map(e=>[e.id,e]))),a=new Map(e.files.flatMap(e=>e.hunks.map(t=>[t.id,e]))),o=il(e.parts),s=new Map([...t.rows.flat(),...t.strip].map(e=>[e.key,e])),c=e=>t.placeOf.get(e)??gU(PI(e)),l=e=>s.get(e)?.label??(e.startsWith(`group:`)?e.slice(6):e),u=new Set,d=e.steps.map((e,t)=>{let r=e.excerpts.flatMap((t,n)=>{let r=i.get(t.hunkId),s=a.get(t.hunkId),c=r===void 0?null:Rq(r,t);if(r===void 0||s===void 0||c===null)return[];for(let e=c.start;e<c.end;e+=1)r.lines[e]?.kind!==`context`&&u.add(`${r.id}:${e}`);let l=o.get(r.id)?.find(e=>c.start>=e.start&&c.start<e.end)?.id??r.id;return[{key:`${e.id}:${n}`,path:s.path,hunkId:r.id,partId:l,lines:t,...c,shown:Lq(r,c.start,c.end),fileChanged:s.hunks.reduce((e,t)=>e+Lq(t),0)}]}),s=n.filter(e=>{if(e.guidance?.effect===`left-out`||e.lines===null)return!1;let{lines:t}=e,n=i.get(t.hunkId),a=n===void 0?null:Rq(n,t);return a!==null&&r.some(e=>e.hunkId===t.hunkId&&zq(e,a))});return{id:e.id,number:t+1,sentence:e.sentence,boxes:[...new Set(r.map(e=>c(e.path)))],excerpts:r,points:[`finding`,`risk`,`decision`].flatMap(e=>s.filter(t=>t.kind===e))}}),f=[],p=[],m=(e,t)=>({key:`${e}#${t}`,directory:e,label:l(e),steps:[t]});for(let e of d){let[t,n]=e.boxes;if(t===void 0)continue;if(n!==void 0){let r=[m(t,e.number),m(n,e.number)];f.push(...r),p.push({step:e.number,keys:[r[0].key,r[1].key]});continue}let r=f.at(-1),i=r!==void 0&&p.some(e=>e.keys.includes(r.key));r!==void 0&&r.directory===t&&!i?f[f.length-1]={...r,steps:[...r.steps,e.number]}:f.push(m(t,e.number))}let h=new Set(f.map(e=>e.directory)),g=new Set(d.flatMap(e=>e.excerpts.map(e=>e.path))),_=new Set(e.proofs.flatMap(e=>e.hunkId??[])),v=new Set(e.generated),y=(e,t)=>g.has(e)?`steps`:ll(e)?`tests`:v.has(e)||t.length>0&&t.every(e=>_.has(e.id))?`generated`:`other`,b=(e,t)=>e.lines.filter((n,r)=>n.kind===t&&!u.has(`${e.id}:${r}`)).length,x=e.files.flatMap(e=>{let t=e.hunks.reduce((e,t)=>e+b(t,`add`),0),n=e.hunks.reduce((e,t)=>e+b(t,`del`),0),r=y(e.path,e.hunks);return r===`steps`&&t+n===0?[]:[{group:r,file:{path:e.path,added:t,deleted:n}}]}),S=[`steps`,`tests`,`generated`,`other`].flatMap(e=>{let t=x.filter(t=>t.group===e).map(e=>e.file);return t.length===0?[]:[{id:e,label:Iq[e],files:t}]}),C=new Map(x.map(e=>[e.file.path,e.group])),w=[...t.rows.flat(),...t.strip].filter(e=>e.kind===`group`&&!h.has(e.key)).map(e=>({key:e.key,directory:e.key,label:e.label,steps:[],group:e.paths.map(e=>C.get(e)).find(e=>e!==void 0)??null})),T=new Set(d.flatMap(e=>e.points.map(e=>e.id))),E=n.filter(e=>(e.kind===`finding`||e.kind===`risk`)&&e.guidance?.effect!==`left-out`&&!T.has(e.id)),D=e=>r(e)!==`dismissed`,O=d.filter(e=>e.points.some(e=>D(e)&&(e.kind===`finding`||e.kind===`risk`&&e.checkedBy===void 0))).map(e=>e.number),k=e.files.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+Lq(t),0),0);return{steps:d,boxes:f,spans:p,others:w,ledger:S,outside:E,depth:{read:O,findingsOutside:E.filter(e=>e.kind===`finding`&&D(e)).length,risksOutside:E.filter(e=>e.kind===`risk`&&D(e)).length},shown:u.size,total:k}},Vq=e=>{let t=e.stages.steps;return t===`running`||t===`pending`?{kind:`writing`}:t===`failed`?{kind:`failed`,message:e.stepsError?.message??`The tour pass failed`}:t===`done`?(e.steps??[]).length<3?{kind:`too-small`}:null:id(e)?{kind:`without-tour`}:{kind:`no-review`}},Hq=(e,t)=>`${e} ${e===1?t:`${t}s`}`,Uq=e=>e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`,Wq=e=>{let{read:t,findingsOutside:n,risksOutside:r}=e,i=t.length===0?`No step has an open finding or a risk no test checks.`:`Read ${t.length===1?`step`:`steps`} ${Uq(t)} in the code: ${t.length===1?`it has`:`each has`} an open finding or a risk no test checks.`,a=[...n>0?[Hq(n,`finding`)]:[],...r>0?[Hq(r,`risk`)]:[]];if(a.length===0)return i;let o=a.length>1||n+r>1;return`${i} ${a.join(` and `)} ${o?`are`:`is`} outside the steps.`},Gq=36,Kq=28,qq=e=>e.endsWith(`/`)?e.slice(0,-1):e,Jq=e=>t=>t.length<=e,Yq=e=>{let t=qq(e),n=t.lastIndexOf(`/`);return n===-1?{prefix:``,name:t||e}:{prefix:`${AI(t.slice(0,n),Jq(29))}/`,name:t.slice(n+1)}},Xq=e=>{let t=e.map(e=>AI(qq(e),Jq(Gq)));return t.map((n,r)=>t.some((e,t)=>t!==r&&e===n)?qq(e[r]??n):n)},Zq=e=>{let t=e=>e.includes(`/`)?e.slice(0,e.indexOf(`/`)):``,n=[...new Set(e.map(t).filter(e=>e.includes(`.`)))],[r,...i]=n.map(e=>e.split(`.`));if(r===void 0||i.length===0)return[...e];let a=0;for(;[r,...i].every(e=>e.length>a+1&&e[a]===r[a]);)a+=1;return e.map(e=>{let r=t(e);return n.includes(r)?r.split(`.`).slice(a).join(`.`)+e.slice(r.length):e})},Qq=e=>{let t=e.map(e=>qq(e).split(`/`));return Zq(t.map(e=>{let n=e.join(`/`);for(let r=1;r<e.length;r+=1){let i=e.slice(-r).join(`/`);if(!t.some(e=>e.join(`/`)!==n&&e.slice(-r).join(`/`)===i))return i}return n})).map(e=>AI(e,Jq(Kq)))},$q=e=>`tour-step-${e}`,eJ=e=>`tour-ledger-${e}`,tJ=`tour-end-title`,nJ=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,rJ=e=>{let{startLine:t,line:n,side:r}=e.lines,i=t===n?`line ${n}`:`lines ${t}–${n}`;return r===`old`?`base ${i}`:i},iJ=({number:e,current:t})=>(0,Y.jsx)(`span`,{className:X(`inline-flex size-5 shrink-0 items-center justify-center rounded-full border-[1.5px] border-primary font-semibold text-caption tabular-nums`,t?`bg-primary text-primary-foreground`:`text-primary`),children:e}),aJ=({box:e,current:t,compactName:n,focusable:r,onGo:i})=>{let a=n!==void 0,o=t!==null&&e.steps.includes(t),{prefix:s,name:c}=Yq(e.label);return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-box`,"aria-label":`${e.label}, ${e.steps.length===1?`step`:`steps`} ${Uq(e.steps)}${o?`, current step`:``}`,title:e.label,...o?{"aria-current":`step`}:{},...r?{}:{tabIndex:-1},onClick:i,className:X(`relative flex min-w-0 shrink-0 cursor-pointer rounded-lg text-left`,a?`max-w-md items-center gap-1.5 px-2 py-1`:`max-w-60 min-w-36 flex-col items-stretch gap-0.5 px-2.5 py-2`,o?`border-2 border-primary bg-background`:`border border-primary bg-ai-soft`),children:[!a&&s!==``&&(0,Y.jsx)(`span`,{className:`truncate font-mono text-caption text-muted-foreground`,children:s}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono font-semibold text-ui`,children:n??c}),(0,Y.jsx)(`span`,{className:`flex shrink-0 gap-1`,children:e.steps.map(e=>(0,Y.jsx)(iJ,{number:e,current:e===t},e))})]}),o&&(0,Y.jsx)(`span`,{className:X(`shrink-0 rounded-full bg-primary px-1.5 font-semibold text-caption text-primary-foreground`,!a&&`absolute -bottom-2.5 left-2`),children:`Current step`})]})},oJ=({tour:e,current:t,compact:n,focusable:r,onGoToStep:i})=>{let a=n?Qq(e.boxes.map(e=>e.label)):null,o=n=>{let o=e.boxes[n];if(o===void 0)return null;let s=a?.[n];return(0,Y.jsx)(aJ,{box:o,current:t,...s===void 0?{}:{compactName:s},focusable:r,onGo:()=>i(Math.min(...o.steps))},o.key)},s=[];for(let t=0;t<e.boxes.length;t+=1){let r=e.boxes[t];if(r===void 0)continue;let i=e.spans.find(e=>e.keys[0]===r.key);t>0&&s.push((0,Y.jsx)(cg,{"aria-hidden":`true`,className:`size-4 shrink-0 text-primary`},`arrow-${r.key}`)),i!==void 0&&e.boxes[t+1]!==void 0?(s.push((0,Y.jsxs)(`div`,{role:`group`,"aria-label":`Step ${i.step} spans both`,className:X(`flex min-w-0 items-center gap-1 rounded-xl border-[1.5px] border-dashed border-primary`,n?`px-1.5 py-1`:`flex-col items-start px-1.5 pt-1 pb-1.5`),children:[(0,Y.jsxs)(`span`,{className:`text-caption font-medium text-primary`,children:[`Step `,i.step,` spans both`]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[o(t),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`text-primary`,children:`+`}),o(t+1)]})]},`span-${r.key}`)),t+=1):s.push(o(t))}return s},sJ=({tour:e,current:t,onGoToStep:n,onGoToGroup:r})=>{let i=Xq(e.others.map(e=>e.label));return(0,Y.jsxs)(`div`,{"data-slot":`tour-strip`,role:`group`,"aria-label":`Directories on the tour`,className:`flex flex-col gap-3 border-b pt-3 pb-4`,children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-4`,children:(0,Y.jsx)(oJ,{tour:e,current:t,compact:!1,focusable:!0,onGoToStep:n})}),e.others.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`mr-1 text-caption text-muted-foreground`,children:`Not on the tour`}),e.others.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,"data-slot":`tour-box`,"aria-label":`${e.label}, no step, see Not in the tour`,title:e.label,onClick:()=>{e.group!==null&&r(e.group)},className:`max-w-full cursor-pointer truncate rounded-md border border-dashed border-input bg-background px-2 py-1 font-mono text-caption hover:bg-surface-row`,children:i[t]},e.key))]})]})},cJ=({tour:e,current:t,overlay:n,shown:r,onGoToStep:i,onGoToEnd:a})=>(0,Y.jsx)(`div`,{"data-slot":`tour-strip-compact`,...n?{"aria-hidden":!0}:{},className:X(`sticky top-(--review-bar-h) z-10`,n&&`h-0`),children:(0,Y.jsxs)(`div`,{role:`group`,"aria-label":`Directories on the tour`,className:X(`flex flex-wrap items-center gap-1.5 border-b bg-background px-1 py-2`,n?`absolute -inset-x-1 top-0`:`-mx-1`,n&&!r&&`invisible`),children:[(0,Y.jsx)(oJ,{tour:e,current:t,compact:!0,focusable:!n,onGoToStep:i}),e.others.length>0&&(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-off`,...n?{tabIndex:-1}:{},onClick:a,className:`ml-1 cursor-pointer rounded-md border border-dashed border-input bg-background px-2 py-1 text-caption text-muted-foreground hover:bg-surface-row`,children:[nJ(e.others.length,`directory`,`directories`),` not on the tour`]})]})}),lJ=({point:e,state:t,onOpen:n,wide:r=!1,after:i})=>{let a=ED[e.kind],o=DD[e.kind],s=t===`dismissed`;return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-point`,onClick:n,className:X(`flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-1.5 text-left text-body`,r?`w-full max-w-4xl`:`w-fit max-w-full`,a.className),children:[(0,Y.jsx)(o,{"aria-hidden":`true`,className:`mt-1 size-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:a.label}),(0,Y.jsxs)(`span`,{className:X(`min-w-0`,s&&`line-through`),children:[(0,Y.jsx)(hW,{text:e.title}),s&&(0,Y.jsx)(`span`,{className:`sr-only`,children:`, dismissed`}),i]})]})},uJ=({step:e,current:t,stateOf:n,renderExcerpt:r,onOpenPoint:i,onOpenInCode:a})=>{let o=`${$q(e.number)}-title`;return(0,Y.jsxs)(`section`,{id:$q(e.number),"data-slot":`tour-step`,"aria-labelledby":o,...t?{"aria-current":`step`}:{},className:`grid grid-cols-[1.5rem_1fr] gap-x-2.5 border-b py-5 lg:grid-cols-[1.875rem_1fr]`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`text-right font-semibold text-heading tabular-nums`,t?`text-primary`:`text-muted-foreground`),children:e.number}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,Y.jsxs)(`h2`,{id:o,tabIndex:-1,className:`font-semibold text-heading outline-none`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Step `,e.number,`: `]}),(0,Y.jsx)(hW,{text:e.sentence})]}),e.points.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.points.map(e=>(0,Y.jsx)(lJ,{point:e,state:n(e),onOpen:()=>i(e)},e.id))}),e.excerpts.map(t=>{let n=t.path.lastIndexOf(`/`)+1;return(0,Y.jsxs)(`div`,{"data-slot":`tour-card`,className:`mt-1 min-w-0 overflow-hidden rounded-lg border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 font-mono text-code-compact`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.path.slice(0,n)}),(0,Y.jsx)(`span`,{className:`font-medium`,children:t.path.slice(n)})]}),(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[rJ(t),` · `,t.shown,` of`,` `,nJ(t.fileChanged,`changed line`)]}),(0,Y.jsxs)($,{variant:`ghost`,size:`sm`,className:`ml-auto text-primary`,"aria-label":`Open ${t.path} ${rJ(t)} in code`,onClick:()=>a(e,t),children:[(0,Y.jsx)(vg,{"aria-hidden":`true`}),`Open in code`]})]}),r(t)]},t.key)})]})]})},dJ=({added:e,deleted:t})=>(0,Y.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[e>0&&(0,Y.jsxs)(`span`,{className:`text-stat-add`,children:[`+`,e]}),e>0&&t>0&&` `,t>0&&(0,Y.jsxs)(`span`,{className:`text-stat-del`,children:[`−`,t]})]}),fJ=({tour:e,stateOf:t,openGroups:n,onToggleGroup:r,flashed:i,onOpenFile:a,onOpenPoint:o})=>{let s=e.ledger.reduce((e,t)=>e+t.files.length,0);return(0,Y.jsxs)(`section`,{"aria-labelledby":tJ,"data-slot":`tour-end`,className:`flex flex-col gap-5 py-6 lg:pl-10`,children:[(0,Y.jsx)(`h2`,{id:tJ,tabIndex:-1,className:`font-semibold text-heading outline-none`,children:`After the tour`}),e.ledger.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`h3`,{className:`font-semibold text-body`,children:[`Not in the tour`,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,nJ(s,`file`)]})]}),e.ledger.map(e=>{let t=e.files.reduce((e,t)=>e+t.added,0),o=e.files.reduce((e,t)=>e+t.deleted,0);return(0,Y.jsxs)(`details`,{id:eJ(e.id),open:n.has(e.id),onToggle:t=>r(e.id,t.currentTarget.open),className:X(`group max-w-3xl rounded-lg border bg-card`,i===e.id&&`border-primary ring-2 ring-ai-soft-bd`),children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-body [&::-webkit-details-marker]:hidden`,children:[(0,Y.jsx)(cg,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-open:rotate-90`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,Y.jsxs)(`span`,{className:`ml-auto text-ui text-muted-foreground`,children:[nJ(e.files.length,`file`),` ·`,` `,(0,Y.jsx)(dJ,{added:t,deleted:o})]})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col border-t py-1`,children:e.files.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e.path),className:`flex w-full cursor-pointer items-center gap-3 px-3 py-1 text-left hover:bg-surface-row`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-code-compact`,children:e.path}),(0,Y.jsx)(dJ,{added:e.added,deleted:e.deleted})]})},e.path))})]},e.id)})]}),e.outside.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-body`,children:`Findings and risks outside the steps`}),e.outside.map(e=>(0,Y.jsx)(lJ,{point:e,state:t(e),wide:!0,onOpen:()=>o(e),after:e.path===null?null:(0,Y.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[` `,`· `,e.path.slice(e.path.lastIndexOf(`/`)+1)]})},e.id))]}),(0,Y.jsxs)(`div`,{"data-slot":`tour-depth`,className:`flex max-w-4xl items-start gap-2 rounded-lg border border-ai-soft-bd bg-ai-soft px-4 py-3 text-body`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`mt-1 size-4 shrink-0 text-primary`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:`Suggested depth`}),(0,Y.jsx)(`p`,{children:Wq(e.depth)})]})]})]})},pJ=e=>({top:e===null?0:Number.parseFloat(getComputedStyle(e).top)||0,height:e?.firstElementChild?.getBoundingClientRect().height??0}),mJ=(e,t,n)=>{let[r,i]=(0,J.useState)(n>0?1:null),[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(null),c=(0,J.useCallback)(e=>{s.current=e,i(e)},[]);return(0,J.useEffect)(()=>{let e=()=>{s.current=null},t=[`wheel`,`touchmove`,`keydown`,`pointerdown`];for(let n of t)window.addEventListener(n,e,{passive:!0});return()=>{for(let n of t)window.removeEventListener(n,e)}},[]),(0,J.useEffect)(()=>{let n=0,r=()=>{n=0;let r=e.current,a=t();if(r===null||a===null)return;let{top:c,height:l}=pJ(a),u=a.getBoundingClientRect().top,d=u+l+8,f=[...r.querySelectorAll(`[data-slot=tour-step]`)],p=f.length>0?1:null;f.forEach((e,t)=>{e.getBoundingClientRect().top<=d&&(p=t+1)}),s.current===null&&i(p),o(window.scrollY>0&&Math.abs(u-c)<=1)},a=()=>{n===0&&(n=window.requestAnimationFrame(r))};return r(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,a),()=>{window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a),n!==0&&window.cancelAnimationFrame(n)}},[e,t]),{current:r,stuck:a,pin:c}},hJ=()=>{let e=`(max-width: 1179px)`,[t,n]=(0,J.useState)(()=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches);return(0,J.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t},gJ=({tour:e,stateOf:t,renderExcerpt:n,onOpenPoint:r,onOpenFile:i,onOpenInCode:a,onCurrentStep:o,landOn:s=null})=>{let c=(0,J.useRef)(null),l=(0,J.useCallback)(()=>c.current?.querySelector(`[data-slot=tour-strip-compact]`)??null,[]),{current:u,stuck:d,pin:f}=mJ(c,l,e.steps.length),p=hJ(),[m,h]=(0,J.useState)(new Set),[g,_]=(0,J.useState)(null),v=(0,J.useRef)(o);v.current=o,(0,J.useEffect)(()=>v.current?.(u),[u]);let y=(0,J.useCallback)(e=>{let{top:t,height:n}=pJ(l()),r=window.scrollY+e.getBoundingClientRect().top-t-n-4;window.scrollTo({top:Math.max(0,r),behavior:`instant`})},[l]),[b,x]=(0,J.useState)(null),S=(0,J.useCallback)(e=>{x(t=>({step:e,n:(t?.n??0)+1}))},[]);(0,J.useLayoutEffect)(()=>{if(b===null)return;let e=document.getElementById($q(b.step));if(e!==null)return y(e),e.querySelector(`h2`)?.focus({preventScroll:!0}),f(b.step),sW(`[data-slot=understand]`,()=>y(e))},[b,y,f]);let C=()=>{let e=document.getElementById(tJ);e!==null&&(y(e),e.focus({preventScroll:!0}))},w=e=>{h(t=>new Set([...t,e])),_(e),window.setTimeout(()=>_(t=>t===e?null:t),1600);let t=document.getElementById(eJ(e));t!==null&&(y(t),t.querySelector(`summary`)?.focus({preventScroll:!0}))},T=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(s===null||T.current===s.n)return;if(T.current=s.n,s.step>0)return S(s.step);let e=c.current;if(e===null)return;let t=document.querySelector(`[data-slot=review-bar]`)?.getBoundingClientRect().height??0,n=window.scrollY+e.getBoundingClientRect().top-t-8;window.scrollTo({top:Math.max(0,n),behavior:`instant`})},[s,S]),(0,Y.jsxs)(`div`,{ref:c,"data-slot":`understand`,className:`flex min-w-0 flex-col`,children:[!p&&(0,Y.jsx)(sJ,{tour:e,current:u,onGoToStep:S,onGoToGroup:w}),(0,Y.jsx)(cJ,{tour:e,current:u,overlay:!p,shown:d,onGoToStep:S,onGoToEnd:C}),(0,Y.jsxs)(`section`,{className:`max-w-[73.75rem]`,"aria-label":`Tour steps`,children:[e.steps.map(e=>(0,Y.jsx)(uJ,{step:e,current:e.number===u,stateOf:t,renderExcerpt:n,onOpenPoint:r,onOpenInCode:a},e.id)),(0,Y.jsx)(fJ,{tour:e,stateOf:t,openGroups:m,onToggleGroup:(e,t)=>h(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),flashed:g,onOpenFile:i,onOpenPoint:r})]})]})},_J=({children:e,busy:t})=>(0,Y.jsxs)(`p`,{"data-slot":`no-tour`,...t?{role:`status`}:{},className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),e]}),vJ=`tour-landing`,yJ=({step:e,excerpt:t})=>(0,Y.jsxs)(`p`,{id:vJ,"data-slot":`tour-landing`,className:`scroll-mt-24 flex flex-wrap items-center gap-x-1.5 border-b bg-ai-soft px-3 py-1.5 text-ui text-primary`,children:[(0,Y.jsx)(f_,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`font-semibold`,children:[`Tour step `,e.number]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{children:rJ(t)}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-foreground`,children:(0,Y.jsx)(hW,{text:e.sentence})})]}),bJ=({step:e,onBack:t,onDismiss:n})=>(0,Y.jsxs)(`div`,{"data-slot":`back-to-tour`,className:`sticky top-(--review-bar-row) z-20 -mt-px flex h-9 items-center gap-2 border-b bg-background`,children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,className:`border-ai-soft-bd bg-ai-soft text-primary hover:bg-ai-soft-hover`,onClick:t,children:[(0,Y.jsx)(Xh,{"aria-hidden":`true`}),`Back to tour · Step `,e]}),(0,Y.jsx)($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Hide Back to tour`,onClick:n,children:(0,Y.jsx)(I_,{"aria-hidden":`true`})})]}),xJ=.25,SJ=(e,t,n)=>{let r=n?t-1:t*xJ;return(e.findLast(e=>e.top<=r)??e[0])?.path??null},CJ=()=>{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}))},wJ=(e,t)=>{let[n,r]=(0,J.useState)(null),i=e.join(`\0`);return(0,J.useEffect)(()=>{if(!t)return;let e=0,n=()=>{e=0;let t=document.documentElement,n=window.scrollY+window.innerHeight>=t.scrollHeight-2,i=CJ();if(i===null)return;let a=SJ(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},TJ=`[aria-label=Changes]`,EJ=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},DJ=e=>`✓ ${e} is done`,OJ=new Set,kJ=new Map,AJ=(e,t,n=`Claude`)=>{let[r,i]=(0,J.useState)({running:e,before:OJ}),[a,o]=(0,J.useState)(`done`),[s,c]=(0,J.useState)(kJ),[l,u]=(0,J.useState)(0);e!==r.running&&(i({running:e,before:e?new Set(t):r.before}),o(e?`done`:`measure`),c(kJ),e||u(l+1)),(0,J.useEffect)(()=>{if(l===0||!document.hidden)return;let e=document.title;document.title=`${DJ(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,J.useRef)(null);(0,J.useLayoutEffect)(()=>{if(a!==`measure`)return;if(d.current=iW(TJ),EJ(`--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=Su.safeParse(t.dataset.pointId);r.success&&n>=0&&n<window.innerHeight&&e.set(r.data,e.size)}c(e),o(`landing`)},[a]),(0,J.useLayoutEffect)(()=>{a!==`measure`&&d.current!==null&&(d.current(),d.current=null)},[a]),(0,J.useEffect)(()=>{if(a!==`landing`)return;let e=Math.max(0,s.size-1)*EJ(`--landing-step-code`),t=setTimeout(()=>o(`done`),EJ(`--landing-total`)+e);return()=>clearTimeout(t)},[a,s]);let{before:f}=r,p=(0,J.useCallback)(e=>a!==`done`&&!f.has(e),[a,f]);return{phase:a,running:e||a===`measure`,fresh:p,inView:a===`landing`?s:kJ}},jJ=`[aria-label=Changes]`,MJ=(e,t)=>e.id===t.id&&e.guardrails===`running`&&t.guardrails!==`running`,NJ=e=>{let[t,n]=(0,J.useState)(e),r=(0,J.useRef)(null),i=t!==e&&MJ(t,e);return(0,J.useLayoutEffect)(()=>{t===e?(r.current?.(),r.current=null):(MJ(t,e)&&(r.current=iW(jJ)),n(e))},[e,t]),i?t:e},PJ=(e,t)=>{let{client:n}=Pp(),[r,i]=(0,J.useState)(new Map),[a,o]=(0,J.useState)(new Set),[s,c]=(0,J.useState)(null),l=(0,J.useRef)(new Map),u=(0,J.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,J.useCallback)(e=>u.get(e)??`open`,[u]),setState:(0,J.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:Gp(s.error)})))},[e,n]),isSaving:e=>a.has(e),failure:s,dismissFailure:()=>c(null)}},FJ=6e4,IJ=e=>{let{client:t}=Pp(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),o=(0,J.useRef)(0),s=(0,J.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,J.useEffect)(()=>(s(),window.addEventListener(`focus`,s),()=>window.removeEventListener(`focus`,s)),[s]);let c=n?.checks?.some(e=>e.state===`running`)===!0;return(0,J.useEffect)(()=>{if(!c)return;let e=setInterval(()=>{document.visibilityState===`visible`&&s()},FJ);return()=>clearInterval(e)},[c,s]),{status:n,error:i,reload:s}},LJ=(e,t)=>{let{client:n}=Pp(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(0),c=(0,J.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,J.useEffect)(()=>{t&&c()},[t,c]),{list:r,error:a,reload:c,reply:(0,J.useCallback)(async(t,r)=>{let i=await n.replyToThread(e,t,{body:r});return i.ok?(c(),null):Gp(i.error)},[n,e,c]),resolve:(0,J.useCallback)(async(t,r)=>{let i=await n.resolveThread(e,t,{resolved:r});return i.ok?(c(),null):Gp(i.error)},[n,e,c]),post:(0,J.useCallback)(async t=>{let r=await n.postComment(e,t);return r.ok?(c(),null):Gp(r.error)},[n,e,c])}},RJ=[],zJ=e=>sf.array().safeParse(e).data,BJ=({analysisId:e})=>{let[t,n]=(0,J.useState)({count:0,seed:null}),r=(0,J.useCallback)((e=null)=>n(({count:t})=>({count:t+1,seed:e})),[]);return(0,Y.jsx)(VJ,{analysisId:e,seed:t.seed,restart:r},`${e}/${t.count}`)},VJ=({analysisId:e,seed:t,restart:n})=>{let{view:r,error:i,refetch:a,follow:o}=Vp(e,t);return r===null?i?.code===`not-found`?(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Analysis not found`}),(0,Y.jsx)(`p`,{className:`text-body`,children:Gp(i)}),(0,Y.jsx)(`p`,{children:(0,Y.jsx)(Q_,{to:`/`,children:`Pick a pull request to review`})})]}):i===null?(0,Y.jsx)(HJ,{}):(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 py-12`,children:[(0,Y.jsxs)(`p`,{className:dF,role:`alert`,children:[`Couldn't load the analysis. `,Gp(i)]}),(0,Y.jsx)($,{variant:`outline`,onClick:()=>void a(),children:`Try again`})]}):(0,Y.jsx)(rY,{view:r,refetch:a,follow:o,restart:n})},HJ=()=>(0,Y.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,Y.jsx)(pF,{className:`h-7 w-2/3`}),(0,Y.jsx)(pF,{className:`h-4 w-1/2`}),(0,Y.jsxs)(`div`,{className:UJ,children:[(0,Y.jsx)(hF,{}),(0,Y.jsx)(mF,{})]})]}),UJ=`grid items-start gap-5 lg:grid-cols-[17rem_minmax(0,1fr)]`,WJ=[],GJ=[{value:`map`,label:`Map`},{value:`overview`,label:`Overview`}],KJ=[{value:`map`,label:`Map`},{value:`overview`,label:`Understand`}],qJ=e=>{switch(e.kind){case`no-review`:return`No AI review yet. The tour through these directories is written with one: Request AI review above.`;case`without-tour`:return`This AI review ran without the tour. Re-run it to get one.`;case`writing`:return`The tour is being written.`;case`too-small`:return`The change is too small for a tour: it has fewer than 3 steps to make.`;case`failed`:return`The tour couldn't be written: ${e.message}`}},JJ=[`nextFile`,`previousFile`,`comment`,`openCall`,`moveFile`,`openFile`,`toggleLayout`,`openReview`,`close`,`help`],YJ=({analysis:e})=>{let{checkout:t,pullRequest:n}=e;if(t===`read`||n===null)return null;let{ref:r,headSha:i}=n;return(0,Y.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,Y.jsxs)(Y.Fragment,{children:[`the local checkout doesn't have the head commit`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:i.slice(0,7)}),`. Run`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`git fetch`}),` in it`,r.repo.host===`github`&&(0,Y.jsxs)(Y.Fragment,{children:[`, or`,` `,(0,Y.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,Y.jsxs)(Y.Fragment,{children:[`megareviewer didn't run in a checkout of `,r.repo.owner,`/`,r.repo.repo,`. Start it in one, or pass`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`--checkout <dir>`}),`, then open the pull request again.`]})]})},XJ=[],ZJ=(e,t)=>{let[n,r]=(0,J.useState)(e);return!t&&n!==e&&r(e),t?n:e},QJ=(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=kM(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}},$J={github:void 0,bitbucket:`Bitbucket can't anchor a range, so the comment goes on the last line and names them.`},eY=new WeakMap,tY=0,nY=e=>{let t=eY.get(e);return t===void 0?(tY+=1,eY.set(e,tY),tY):t},rY=({view:e,refetch:t,follow:n,restart:r})=>{let{client:i}=Pp(),a=HR(Lp().status?.model??null),{analysis:o,publication:s}=e,c=o.id,l=o.status===`complete`,u=l&&td(o),d=NJ(ZJ(o,u)),f=Hp(i.runModel),p=s!==null||!l,m=(0,J.useMemo)(()=>YW(d),[d]),h=(0,J.useMemo)(()=>XW(d,m),[d,m]),g=(0,J.useMemo)(()=>h.flatMap(e=>e.partIds),[h]),_=(0,J.useMemo)(()=>tG(d,m),[d,m]),v=eG(_),[y,b]=NR(`decisions`,!1,PR),[x,S]=NR(`tour`,!1,PR),C=(0,J.useMemo)(()=>Du(d).filter(e=>y||e.kind!==`decision`),[d,y]),w=(0,J.useMemo)(()=>C.map(e=>e.id),[C]),T=PJ(c,e.pointReviews),[E,D]=(0,J.useState)(new Set),{stateOf:O}=T,k=(0,J.useMemo)(()=>new Set(C.filter(e=>e.guidance?.effect===`left-out`&&O(e.id)===`open`&&!E.has(e.id)).map(e=>e.id)),[C,O,E]),A=(0,J.useMemo)(()=>C.filter(e=>!k.has(e.id)),[C,k]),j=(0,J.useCallback)(e=>D(t=>new Set(t).add(e)),[]),M=Bl(o.modelOption??a.chosen),N=AJ(u,w,M),P=(0,J.useMemo)(()=>QW(C,g,m),[C,g,m]),F=(0,J.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 P.cards){let s=m.parts.get(a);for(let c of o){let o=s===void 0?null:QJ(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}},[P,m]),I=(0,J.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 F.underLine.values())for(let n of e.values())t(n);for(let[e,n]of F.underHeader)t([...n,...P.mentions.get(e)??WJ]);for(let[e,n]of P.mentions)F.underHeader.has(e)||t(n);return t(P.unplaced),e},[F,P]),{inView:L}=N,R=(0,J.useCallback)(e=>L.get(I.get(e)??e),[L,I]),ee=(0,J.useMemo)(()=>{let e=new Map;for(let[t,n]of P.cards){let r=m.parts.get(t)?.file.path;if(r===void 0)continue;let i=n.filter(e=>!k.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},[P,m,k]),z=(0,J.useMemo)(()=>h.map(({file:e})=>({path:e.path,status:e.status,oldPath:e.oldPath,additions:e.additions,deletions:e.deletions,...ee.has(e.path)?{points:ee.get(e.path)}:{}})),[h,ee]),[B,V]=(0,J.useState)([]),te=(0,J.useMemo)(()=>TU(d,new Set(B)),[d,B]),H=(0,J.useMemo)(()=>TU(d),[d]),U=(0,J.useMemo)(()=>Du(d),[d]),ne=x?Vq(o):null,re=(0,J.useMemo)(()=>x?Bq(d,H,U,e=>O(e.id)):null,[x,d,H,U,O]),ie=(0,J.useMemo)(()=>d.stages.prep===`done`?OU(TU(d)):null,[d]),[ae,oe]=NR(`review-layout`,`map`,qW),W=ae===`overview`&&ne===null&&re!==null,se=wJ((0,J.useMemo)(()=>h.map(e=>e.file.path),[h]),ae===`map`&&d.stages.prep===`done`),[ce,le]=(0,J.useState)(!1),ue=(0,J.useMemo)(()=>{let e=new Map;for(let t of d.unchangedCallers)e.set(t.partId,[...e.get(t.partId)??[],t]);return e},[d.unchangedCallers]),de=(0,J.useCallback)(e=>ue.get(e)??XJ,[ue]),[fe]=(0,J.useState)(zM),pe=(0,J.useMemo)(()=>LU(d.callSites,m,fe),[d.callSites,m,fe]),me=(0,J.useCallback)(e=>pe.get(e),[pe]),he=(0,J.useMemo)(()=>new Map(C.flatMap(e=>{let t=RU(e,m);return t===null?[]:[[e.id,{handle:fe,payload:t}]]})),[C,m,fe]),[ge,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(null),be=(0,J.useRef)(null),[xe,Se]=(0,J.useState)(null),[Ce,we]=(0,J.useState)(null),[Te,Ee]=(0,J.useState)(null),[De,Oe]=(0,J.useState)(null),[ke,Ae]=(0,J.useState)(null),[je,Me]=(0,J.useState)(new Set),[Ne,Pe]=(0,J.useState)(!1),Fe=Te===`thread`||A.length===0,Ie=Fe?null:Ce,[Le,Re]=(0,J.useState)(!1),[ze,Be]=(0,J.useState)(new Set),Ve=(0,J.useCallback)(e=>Be(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),[G,He]=(0,J.useState)(!1),[Ue,We]=(0,J.useState)(new Set),[Ge,Ke]=(0,J.useState)(null),[qe,Je]=(0,J.useState)(!1),[Ye,Xe]=(0,J.useState)(!1),Ze=(0,J.useRef)(!0),[Qe,$e]=(0,J.useState)(!1),[et,tt]=NR(`hunk-comments:${c}`,RJ,zJ),[nt,rt]=(0,J.useState)(null),it=(0,J.useRef)(null),at=(0,J.useMemo)(()=>nG(et,m),[et,m]),ot=(0,J.useCallback)(e=>at.get(e)??RJ,[at]),st=(0,J.useCallback)((e,t)=>tt(n=>{let r=nl(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]}),[tt]),ct=(0,J.useCallback)((e,t)=>{it.current=null,rt(n=>{if(t?.startLine!==void 0&&n!==null&&n.partId===e){let r=nl(e),i=n.place;tt(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}})},[tt]),{setState:lt}=T,ut=(0,J.useCallback)((e,t)=>{let n=it.current;it.current=null,n!==null&&n.partId===e&&n.place.side===t.side&&n.place.line===t.line&&(st(e,n.before??{...n.place,body:``}),n.state!==`raised`&&lt(n.pointId,n.state))},[st,lt]),dt=LJ(c,d.stages.prep===`done`),ft=IJ(c),{post:pt}=dt,mt=(0,J.useCallback)((e,t)=>pt({hunkId:nl(e),...t}),[pt]),ht=(0,J.useMemo)(()=>Sq(dt.list?.threads??null,h,m),[dt.list,h,m]),gt=(0,J.useMemo)(()=>wq(ht,h,m),[ht,h,m]),_t=Eq(ke,gt,je),vt=Fe?De:null,{resolve:yt}=dt,bt=(0,J.useCallback)(async(e,t)=>{let n=await yt(e,t);return n===null&&t&&Me(t=>new Set(t).add(e)),n},[yt]),xt=d.pullRequest?.author.id??null,St=(e,t)=>(0,Y.jsx)(xM,{thread:e,authorId:xt,now:Date.now(),language:NA({path:e.path,language:null}),covered:t,mediaUrl:e=>i.attachmentUrl(c,e),onReply:t=>dt.reply(e.id,t),onResolve:t=>bt(e.id,t),current:vt===e.id,anchorId:vq(e.id),linesAbove:t?.length??0},e.id),Ct=(e,t)=>{let n=ht.onLine.get(e)?.get(yq(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 St(e,r===void 0?null:Cq(r,Math.min(n,t.line),t.line))})},wt=e=>{let t=ht.earlier.get(e);return t===void 0?null:t.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.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 ${yM(e)}, which the diff doesn't show`}),St(e,null)]},e.id))},Tt=e=>ht.open.get(e)??0,Et=(0,J.useMemo)(()=>z.map(e=>({...e,threads:ht.open.get(e.path)??0})),[z,ht]),Dt=e=>Ke(t=>({id:e,n:(t?.n??0)+1})),Ot=()=>ae===`overview`?null:ge,kt=(0,J.useCallback)(e=>_e(e),[]),At=e=>{te.placeOf.has(e)&&ye(t=>({key:e,n:(t?.n??0)+1}))},jt=(e,t=ae)=>{if(t===`overview`){let t=m.parts.get(e)?.file.path;t!==void 0&&At(t)}else Dt(g.includes(e)?GU(e):iG)},Mt=e=>{let t=C.find(t=>t.id===e),n=P.cardPart.get(e);t?.kind===`decision`&&Be(t=>new Set([...t,e])),k.has(e)&&j(e),Te===`thread`&&Ee(null),We(new Set((t?.hunkIds??[]).flatMap(m.partsOf))),ae===`overview`&&!W?n!==void 0&&jt(n):(ae===`overview`&&(oe(()=>`map`),Se(null)),Dt(sK(e))),we(e)},[Nt,Pt]=(0,J.useState)(null),[Ft,It]=(0,J.useState)(null),[Lt,Rt]=(0,J.useState)(0);(0,J.useEffect)(()=>{if(Lt!==0&&ae===`map`)return cW(vJ,`[aria-label=Changes]`)},[Lt,ae]);let zt=`tour-step:${c}`,Bt=()=>{let e=FR(zt);return typeof e==`number`?e:0},Vt=x&&ne===null&&re!==null,Ht=e=>{oe(()=>`overview`),Se(null),Pt(null),We(new Set),It(t=>({step:e,n:(t?.n??0)+1}))},Ut=()=>Ht(Nt?.step.number??Bt()),Wt=(e,t)=>{oe(()=>`map`),Se(null),Pt({step:e,excerpt:t}),_e(t.partId),IR(zt,e.number),Dt(vJ),Rt(e=>e+1)},Gt=e=>{oe(()=>`map`),Se(null),_e(e),We(new Set([e])),Dt(g.includes(e)?GU(e):iG)},Kt=e=>{if(e.kind!==`decision`||y)return Mt(e.id);let t=P.cardPart.get(e.id)??e.hunkIds.flatMap(m.partsOf)[0];t!==void 0&&Gt(t)},qt=e=>{oe(()=>`map`),Se(null),Dt(h.some(t=>t.file.path===e)?aG(e):iG)},Jt=e=>{Ee(`thread`),Oe(e),We(new Set),ae===`overview`&&oe(()=>`map`),Dt(vq(e))},Yt=e=>{if(Ee(e),e===`thread`){let e=Tq(gt,_t,je),[t]=e;t!==void 0&&!e.some(e=>e.id===De)&&Jt(t.id);return}let t=VK(A,e,Ce);t!==null&&Mt(t)},Xt=e=>{let t=Su.parse(`m${e+1}`),n=d.findings.find(t=>t.mismatch===`m${e+1}`);Mt(C.some(e=>e.id===t)||n===void 0?t:Su.parse(n.id))},Zt=()=>{let e=(document.activeElement?.closest(`[aria-label=Changes] [data-slot=file-card]`))?.dataset.path??se;oe(()=>`overview`),Se(null),e!==null&&At(e)},Qt=e=>{let[t]=e.kind===`outside`?[]:e.paths,n=t===void 0?e.partIds[0]:h.find(e=>e.file.path===t)?.partIds[0];n!==void 0&&(oe(()=>`map`),Se(e.key),_e(n),t===void 0?jt(n,`map`):Dt(aG(t)))},$t=()=>{if(ae===`map`)return Vt?Ht(Nt?.step.number??Bt()):Zt();if(W){let e=re?.steps.find(e=>e.number===Bt()),[t]=e?.excerpts??[];return e!==void 0&&t!==void 0?Wt(e,t):oe(()=>`map`)}let e=[...te.rows.flat(),...te.strip].find(e=>e.key===be.current);if(e!==void 0&&e.kind!==`outside`)return Qt(e);oe(()=>`map`)};Zp({label:`Layout`,options:x?KJ:GJ,value:ae,onChange:e=>{e!==ae&&$t()},toggles:[{label:`Decisions`,checked:y,onChange:e=>b(()=>e)},{label:`Tour (preview)`,checked:x,onChange:e=>S(()=>e)}]});let en=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&&Dt(r.id)},tn=(e,t=!1)=>{let n=P.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:kM(a));if(o===null)return;let s=e.explanation===``?e.title:`${e.title}\n\n${e.explanation}`,c=nl(n),l=et.find(e=>e.hunkId===c&&e.side===o.side&&e.line===o.line),u={...e.suggestion===null?{}:{suggestion:e.suggestion}};l===void 0?st(n,{...o,body:s,...u}):T.stateOf(e.id)!==`raised`&&!l.body.includes(s)&&st(n,{...u,...l,body:l.body===``?s:`${l.body}\n\n${s}`}),we(e.id);let d=T.stateOf(e.id);if(T.setState(e.id,`raised`),t)return;let{startLine:f}=l??o,h={side:o.side,line:o.line,...f===void 0?{}:{startLine:f}};rt({partId:n,place:h}),it.current={partId:n,place:h,before:l,pointId:e.id,state:d},Dt(GU(n))},nn=()=>{let e=Ot(),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=kM(n);r!==null&&e!==null&&(it.current=null,rt({partId:e,place:r}))},rn=()=>{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&&fe.open(n.id)},an=()=>{if(Ue.size>0)return We(new Set);if(ae===`map`&&Nt!==null)return Ut();ae===`map`&&xe!==null&&(oe(()=>`overview`),ye(e=>({key:xe,n:(e?.n??0)+1})),Se(null))},on=l;aA({...ae===`map`?{nextFile:()=>en(1),previousFile:()=>en(-1),comment:nn,openCall:rn,close:an}:{},toggleLayout:()=>$t(),openReview:()=>{on&&dn()},help:()=>Xe(!0)},!qe&&!Ye&&!Qe);let sn=d.pullRequest?.url??jf(d.key.ref),cn=Hp(i.startAnalysis),ln=Hp(i.retryAnalysis),un=e=>{e===c?r():Y_(G_(e))},dn=()=>Je(!0),[fn,pn]=(0,J.useState)(null),mn=(0,J.useRef)(ft.status);mn.current=ft.status;let hn=e.currentUserId===null?null:ft.status?.reviewers.find(t=>t.id===e.currentUserId)?.verdict??null,gn=fn!==null&&fn.over===ft.status,_n=gn?fn.verdict:hn,vn=gn||ft.status!==null&&e.currentUserId!==null,yn=e=>{pn({verdict:e,over:mn.current}),ft.reload()},bn=Hp(i.publish),xn=(0,J.useRef)(null),Sn=async()=>{xn.current??=uf.parse(crypto.randomUUID()),(await bn.run(c,{publicationId:xn.current,summary:``,allowStale:!1,hunkComments:[],verdict:`approve`})).ok&&(xn.current=null,yn(`approved`),dt.reload(),t())},Cn=Hp(i.revokeApproval),wn=async()=>{(await Cn.run(c)).ok&&yn(null)},Tn=et.length,En=XU({aiDone:Zu.every(e=>o.stages[e]===`done`),running:u,pending:Tn,isAuthor:e.isAuthor,stale:e.stale,verdict:_n}),Dn=(0,J.useMemo)(()=>rG(d.files),[d.files]),On=T.failure===null?``:C.find(e=>e.id===T.failure?.pointId)?.title??``,kn=async(e,t)=>{let n=await i.addPreference({...t,source:`learned`});return n.ok?(T.setState(e.id,`dismissed`),null):dV(n.error)},An=e=>({state:T.stateOf(e.id),saving:T.isSaving(e.id),readOnly:p,current:Ie===e.id,onRaise:Kn.raisePoint,onState:Kn.setPointState,leftOut:k.has(e.id),onShow:j,ruleScopes:Jn,onRule:Kn.saveRule}),jn=(e,t)=>{let n=t===null?void 0:m.parts.get(t),r=e.lines,i=t!==null&&r!==null&&ot(t).some(e=>e.side===r.side&&e.line===r.line);return(0,Y.jsx)(kK,{point:e,...An(e),family:M,linesAbove:F.rowsAbove.get(e.id)??0,inReview:i,removed:n===void 0||r===null||r.side===`old`?null:Cq(n.hunk,r.startLine,r.line),language:n===void 0?null:NA(n.file)},e.id)},Mn=e=>(0,Y.jsx)(MK,{point:e,...An(e),family:M,linesAbove:F.rowsAbove.get(e.id)??0,test:he.get(e.id)??null},e.id),Nn=e=>(0,Y.jsx)(PK,{point:e,...An(e)},e.id),Pn=(e,t=null)=>e.kind===`finding`?jn(e,t):e.kind===`risk`?Mn(e):Nn(e),Fn=(0,J.useMemo)(()=>{let e={finding:0,risk:1,decision:2,step:3},t=new Map;for(let[n,r]of P.cards){let i=new Map;for(let t of r){if(t.lines===null||t.kind===`decision`||k.has(t.id))continue;let{side:n,startLine:r,line:a}=t.lines,o=R(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},[P,R,k]),In=(0,J.useMemo)(()=>new Map(d.files.flatMap(e=>e.hunks.map(t=>[t.id,{hunk:t,file:e}]))),[d.files]),Ln=(0,J.useMemo)(()=>{if(Nt===null)return null;let e=In.get(Nt.excerpt.hunkId)?.hunk;if(e===void 0)return null;let t=e.lines.slice(Nt.excerpt.start,Nt.excerpt.end).flatMap(e=>{let t=kM(e);return t===null?[]:[`${t.side}:${t.line}`]});return{hunkId:Nt.excerpt.hunkId,keys:t}},[Nt,In]),Rn=(0,J.useCallback)(e=>{let t=Fn.get(e);if(Ln===null||nl(e)!==Ln.hunkId)return t;let n=new Map(t??[]);for(let e of Ln.keys)n.has(e)||n.set(e,{kind:`step`});return n},[Fn,Ln]),zn=(e,t,n)=>{let[r]=e;return r===void 0?null:(0,Y.jsx)(IK,{pointId:r.id,fresh:e.some(e=>N.fresh(e.id)),at:R(r.id),...t,children:n},r.id)},Bn=e=>{let t=F.underHeader.get(e)??WJ,n=P.mentions.get(e)??WJ,r=Nt!==null&&Nt.excerpt.partId===e?(0,Y.jsx)(yJ,{step:Nt.step,excerpt:Nt.excerpt}):null;return r===null?Vn(t,n,e):(0,Y.jsxs)(Y.Fragment,{children:[r,Vn(t,n,e)]})},Vn=(e,t,n)=>zn([...e,...t],{bodyClassName:`flex flex-col gap-2 border-b bg-surface-subtle p-3`},(0,Y.jsxs)(Y.Fragment,{children:[e.map(e=>Pn(e,n)),t.map(e=>(0,Y.jsx)(FK,{point:e,onGo:Kn.goToPoint},e.id))]})),Hn=(e,t)=>{let n=yq(t),r=F.underLine.get(e)?.get(n)??WJ,i=(F.atLineEnd.get(e)?.get(n)??WJ).filter(e=>ze.has(e.id));return(0,Y.jsxs)(Y.Fragment,{children:[zn(r,{row:!0,className:AM,bodyClassName:`flex max-w-3xl flex-col gap-2 py-2 pr-3 pl-29 font-sans`},r.map(t=>Pn(t,e))),i.length>0&&(0,Y.jsx)(MM,{inset:!0,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(Nn)})})]})},Un=(e,t)=>{let n=F.atLineEnd.get(e)?.get(yq(t));return n===void 0?null:n.map(e=>(0,Y.jsx)(NK,{point:e,state:T.stateOf(e.id),open:ze.has(e.id),current:Ie===e.id,onToggle:Ve},e.id))},Wn=(0,J.useCallback)(e=>{let t=F.underLine.get(e);if(t===void 0)return;let n=[...t].filter(([,e])=>e.some(e=>e.kind===`finding`&&!k.has(e.id)));return new Set(n.map(([e])=>e))},[F,k]),Gn=(0,J.useRef)({goToPoint:Mt,raisePoint:tn,saveRule:kn});Gn.current={goToPoint:Mt,raisePoint:tn,saveRule:kn};let Kn=(0,J.useMemo)(()=>({goToPoint:e=>Gn.current.goToPoint(e),raisePoint:(e,t)=>Gn.current.raisePoint(e,t),saveRule:(e,t)=>Gn.current.saveRule(e,t),setPointState:T.setState}),[T.setState]),qn=d.key.ref.repo,Jn=(0,J.useMemo)(()=>GB([qn]).reverse(),[qn]),Yn=(e,t)=>{let n=m.parts.get(e);if(n===void 0)return;let r=n.hunk.lines.find(e=>e.kind!==`context`),i=r===void 0?null:kM(r);return C.find(n=>{if(n.guardrail===void 0||P.cardPart.get(n.id)!==e||T.stateOf(n.id)!==`raised`)return!1;let r=n.lines===null?i:n.lines;return r!==null&&r.side===t.side&&r.line===t.line})},Xn=e=>{let t=[nY(d),p,Ue.has(e),nt?.partId===e?`${nt.place.side}${nt.place.line}`:``,...ot(e).map(e=>JSON.stringify(e))];ht.onLine.has(e)&&t.push(nY(ht),vt??``);let n=P.cards.get(e)??WJ,r=P.mentions.get(e)??WJ;for(let e of n)t.push(e.id,T.stateOf(e.id),T.isSaving(e.id)),t.push(Ie===e.id,k.has(e.id)),e.kind===`decision`&&t.push(ze.has(e.id));for(let e of r)t.push(e.id);for(let e of[...n,...r])t.push(N.fresh(e.id),R(e.id)??``);return Ln!==null&&nl(e)===Ln.hunkId&&t.push(Nt?.excerpt.key),t.join(`\0`)},Zn=e=>{let t=In.get(e.hunkId);if(t===void 0)return null;let n=rl(t.hunk,e),r=t=>t.hunkId===e.hunkId&&n.lines.some(e=>{let n=kM(e);return n!==null&&n.side===t.side&&n.line===t.line}),i=nt?.partId===e.partId?nt.place:null;return(0,Y.jsx)(LM,{id:e.partId,hunk:n,file:t.file,risk:m.items([e.partId])[0]?.risk??null,inFile:!0,comments:et.filter(r),openComment:i!==null&&n.lines.some(e=>kM(e)?.line===i.line)?i:null,onOpenComment:ct,onCancelComment:ut,...l?{onComment:st,onCommentNow:mt}:{},threadsAt:t=>Ct(e.partId,t),...$J[d.key.ref.repo.host]===void 0?{}:{rangeNote:$J[d.key.ref.repo.host]}})},Qn={index:m,unchangedOf:de,highlighted:Ue,commentsOf:ot,openComment:nt,onOpenComment:ct,onCancelComment:ut,onComment:l?st:void 0,...l?{onCommentNow:mt}:{},draftNote:(e,t,n)=>{let r=Yn(e,t);return r?.guardrail===void 0?null:(0,Y.jsx)(WU,{guardrail:r.guardrail,family:M,body:t.body,onEdit:n})},onFocusHunk:kt,marksOf:me,pointsOn:Bn,pointsAt:Hn,pointsAtEnd:Un,flaggedOf:Wn,pointLinesOf:Rn,threadsAt:Ct,earlierThreads:wt,openThreads:Tt,...$J[d.key.ref.repo.host]===void 0?{}:{rangeNote:$J[d.key.ref.repo.host]}},$n=(0,Y.jsx)(Y.Fragment,{children:P.unplaced.length>0&&(0,Y.jsx)(`section`,{"aria-label":`Points on no change shown here`,children:zn(P.unplaced,{bodyClassName:`flex flex-col gap-2`},P.unplaced.map(e=>Pn(e)))})});return(0,Y.jsxs)(`div`,{"data-slot":`review-page`,"data-layout":ae,"data-landing":N.phase,className:`mx-auto flex max-w-[1600px] flex-col gap-4`,children:[(0,Y.jsx)(_q,{view:e,intent:(0,Y.jsx)(xW,{analysis:o,through:ie,running:N.running,stale:e.stale,tour:Vt&&re!==null?{steps:re.steps.length,onOpen:()=>Ht(0)}:null,onDetails:()=>{Ze.current=!0,$e(!0)}}),totals:Dn,status:ft.status,statusError:ft.error,onRetryStatus:ft.reload,now:Date.now()}),(0,Y.jsx)(lq,{title:o.pullRequest?.title??null,claude:(0,Y.jsx)(FU,{analysis:o,choice:a,running:N.running,starting:f.pending,error:f.error===null?cn.error===null?null:Gp(cn.error):Gp(f.error),filesChanged:d.stages.prep===`done`?Dn.files:null,reanalyze:e.stale?{starting:cn.pending,onReanalyze:async()=>{let e=await cn.run({url:sn});e.ok&&un(e.value.analysisId)}}:null,onRerun:()=>He(!0),points:A,leftOut:k.size,threads:Mq(gt,_t,je),narrowed:Te,onNarrow:Yt,onRun:async()=>{let e=a.chosen?.id;(await f.run(c,{...e===void 0?{}:{optionId:e},...x?{tour:!0}:{}})).ok&&n()},children:Fe?gt.length>0&&(0,Y.jsx)(Pq,{ordered:gt,scope:_t,resolvedHere:je,current:De,onGo:Jt,onOpenList:()=>Pe(!0)}):(0,Y.jsx)(KK,{points:A,current:Ce,stateOf:T.stateOf,kind:Te,onGo:Mt,onOpenList:()=>Re(!0)})}),tools:ae===`map`&&(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:`lg:hidden`,"aria-expanded":ce,"aria-controls":`review-tree-rail`,onClick:()=>le(!ce),children:ce?`Hide files`:`Show files`}),publish:on&&(0,Y.jsxs)(Y.Fragment,{children:[En.order.map(e=>e===`approve`&&En.approve.revoke?(0,Y.jsxs)($,{variant:`outline`,"data-slot":`revoke-approval-button`,disabled:Cn.pending,onClick:()=>void wn(),children:[(0,Y.jsx)(P_,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:Cn.pending?`Revoking…`:`Revoke approval`})]},`approve`):e===`approve`?(0,Y.jsxs)(YL,{disabled:En.approve.disabledReason===null,children:[(0,Y.jsxs)(XL,{render:(0,Y.jsx)($,{variant:En.approve.filled?`approve`:`outline`,"data-slot":`approve-button`,disabled:bn.pending||En.approve.disabledReason!==null,focusableWhenDisabled:!0,"aria-describedby":En.approve.disabledReason===null?void 0:`approve-reason`,onClick:()=>void Sn()}),children:[(0,Y.jsx)(mg,{"aria-hidden":`true`,className:X(!En.approve.filled&&`text-review-approved`)}),(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:bn.pending?`Approving…`:`Approve`})]}),(0,Y.jsx)(ZL,{side:`bottom`,align:`end`,children:En.approve.disabledReason})]},`approve`):(0,Y.jsxs)($,{variant:En.publish.filled?`default`:`outline`,"data-slot":`publish-button`,"aria-haspopup":`dialog`,onClick:()=>void dn(),children:[(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Publish review…`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`sm:hidden`,children:`Publish…`}),En.publish.count>0&&(0,Y.jsxs)(`span`,{className:`tabular rounded-full bg-primary-foreground px-1.5 text-caption text-primary`,children:[En.publish.count,(0,Y.jsx)(`span`,{className:`sr-only`,children:` to post`})]})]},`publish`)),En.approve.disabledReason!==null&&(0,Y.jsx)(`span`,{id:`approve-reason`,hidden:!0,children:En.approve.disabledReason})]}),verdict:ZU(_n,vn,s),hairline:N.running?`running`:N.phase===`landing`?`finishing`:null}),ae===`map`&&Nt!==null&&(0,Y.jsx)(bJ,{step:Nt.step.number,onBack:Ut,onDismiss:()=>Pt(null)}),!l&&(0,Y.jsx)(ZK,{stages:o.stages,shown:$K,filesFetched:o.filesFetched}),o.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`The analysis failed at the `,QK(o.error.stage).toLowerCase(),` stage:`,` `,o.error.message]}),ln.error!==null&&(0,Y.jsxs)(`p`,{children:[`Couldn't retry. `,Gp(ln.error)]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:ln.pending,onClick:async()=>{let e=await ln.run(c);e.ok&&un(e.value.analysisId)},children:ln.pending?`Retrying…`:`Retry`})]}),bn.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't approve. `,Gp(bn.error)]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:bn.reset,children:`Dismiss`})]}),Cn.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't revoke the approval. `,Gp(Cn.error)]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:Cn.reset,children:`Dismiss`})]}),T.failure!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't save what you did with “`,On,`”. `,T.failure.message]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:T.dismissFailure,children:`Dismiss`})]}),dt.error!==null&&(0,Y.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,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),`Couldn't read the comments on the pull request. `,Gp(dt.error)]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:dt.reload,children:`Try again`})]}),d.stages.prep===`done`?ae===`map`?(0,Y.jsxs)(`div`,{className:X(UJ,`[&>aside]:hidden lg:[&>aside]:flex`,ce&&`[&>aside]:flex`),children:[(0,Y.jsx)(aq,{children:(0,Y.jsx)(UI,{files:Et,activePath:se,onSelect:e=>Dt(aG(e)),className:`min-h-0 flex-1`})}),(0,Y.jsx)(uG,{analysis:d,files:h,deps:Qn,before:$n,after:ht.elsewhere.length>0&&(0,Y.jsxs)(`section`,{"aria-label":`Comments on other files`,className:`flex flex-col gap-2 rounded-lg border bg-surface-subtle p-3`,children:[(0,Y.jsx)(`h2`,{className:`text-caption font-medium text-muted-foreground`,children:`Comments on files without a card here`}),ht.elsewhere.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-code-compact`,children:e.path}),St(e,null)]},e.id))]}),trailingProofs:_,mechanicalCount:v,scrollRequest:Ge,signatureOf:Xn})]}):W&&re!==null?(0,Y.jsx)(gJ,{tour:re,stateOf:e=>O(e.id),renderExcerpt:Zn,onOpenPoint:Kt,onOpenFile:qt,onOpenInCode:Wt,onCurrentStep:e=>{e!==null&&IR(zt,e)},landOn:Ft}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ne!==null&&(0,Y.jsx)(_J,{busy:ne.kind===`writing`,children:qJ(ne)}),(0,Y.jsx)(aK,{overview:te,focusKey:ve,currentPath:se,onOpen:Qt,onExpand:e=>V(t=>[...t,e]),expandedGroups:B,onCollapse:e=>V(t=>t.filter(t=>t!==e)),onFocusNode:e=>{be.current=e}})]}):(0,Y.jsx)(`section`,{"aria-busy":d.status===`running`,children:(0,Y.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,Y.jsxs)(`footer`,{className:`flex items-center justify-end gap-3`,children:[(0,Y.jsx)(OG,{calls:o.modelCalls,option:o.modelOption,guidance:o.guidance,leftOut:C.filter(e=>e.guidance?.effect===`left-out`).length}),l&&!u&&id(o)&&(0,Y.jsx)(oq,{analysisId:c,family:M,onRemoved:t=>r({...e,...t})}),(0,Y.jsx)(SG,{usage:o.usage,option:o.modelOption,guidance:o.guidance})]}),G&&a.chosen!==null&&(0,Y.jsx)(sq,{analysisId:c,view:e,family:M,chosen:a.chosen,tour:x,onClose:()=>He(!1),onRestart:e=>r(e)}),qe&&(0,Y.jsx)(iq,{analysisId:c,hunkComments:et,isAuthor:e.isAuthor,published:s!==null,onClose:()=>Je(!1),onPublished:(e,n)=>{Je(!1),tt(()=>[]),dt.reload(),yn(QU(n,_n)),t()}}),Ne&&(0,Y.jsx)(Fq,{ordered:gt,scope:_t,onScope:Ae,onGo:e=>{Pe(!1),Jt(e)},onClose:()=>Pe(!1)}),Le&&(0,Y.jsx)(RK,{points:A,family:M,kind:Te===`thread`?null:Te,stateOf:T.stateOf,onGo:e=>{Re(!1),Mt(e)},onClose:()=>Re(!1)}),(0,Y.jsx)(TF,{open:Ye,onOpenChange:Xe,ids:JJ}),(0,Y.jsx)(VM,{handle:fe,onGoTo:e=>Dt(GU(e))}),Qe&&(0,Y.jsxs)(IH,{title:d.intent===null?`What was asked`:`Intent`,onClose:()=>$e(!1),className:`sm:max-w-4xl`,returnFocus:()=>Ze.current,children:[d.intent===null?d.pullRequest!==null&&(0,Y.jsx)(CW,{pullRequest:d.pullRequest,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys}):(0,Y.jsx)(MW,{intent:d.intent,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys,onSelectMismatch:e=>{Ze.current=!1,$e(!1),Xt(e)}}),(0,Y.jsx)(YJ,{analysis:d})]}),(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground`,children:[`Press `,(0,Y.jsx)(cA,{id:`help`}),` for keyboard shortcuts.`]})]})},iY={theme:`megareviewer:theme`,diffPalette:`megareviewer:diffPalette`},aY=`(prefers-color-scheme: dark)`,oY=e=>e===`light`||e===`dark`?e:`system`,sY=e=>e===`cb`?`cb`:`default`,cY=(e,t)=>e===`system`?t?`dark`:`light`:e,lY=(e,t,n)=>{e.classList.toggle(`dark`,t===`dark`),n===`cb`?e.dataset.diffPalette=`cb`:delete e.dataset.diffPalette},uY=e=>{try{let t=window.localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}},dY=(e,t)=>{try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}},fY=new Set,pY=()=>{for(let e of fY)e()},mY=e=>{fY.add(e);let t=window.matchMedia(aY);return t.addEventListener(`change`,e),window.addEventListener(`storage`,e),()=>{fY.delete(e),t.removeEventListener(`change`,e),window.removeEventListener(`storage`,e)}},hY=()=>`${oY(uY(iY.theme))} ${sY(uY(iY.diffPalette))} ${window.matchMedia(aY).matches}`,gY=()=>{let[e=`system`,t=`default`,n]=(0,J.useSyncExternalStore)(mY,hY).split(` `),r=oY(e),i=sY(t),a=cY(r,n===`true`);return(0,J.useEffect)(()=>{lY(document.documentElement,a,i)},[a,i]),{theme:r,resolvedTheme:a,diffPalette:i,setTheme:(0,J.useCallback)(e=>{dY(iY.theme,e),pY()},[]),setDiffPalette:(0,J.useCallback)(e=>{dY(iY.diffPalette,e),pY()},[])}},_Y={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius-xl)`},vY=({...e})=>{let{resolvedTheme:t}=gY();return(0,Y.jsx)(OP,{theme:t,className:`toaster group`,icons:{success:(0,Y.jsx)(mg,{className:`size-4`}),info:(0,Y.jsx)(Wg,{className:`size-4`}),warning:(0,Y.jsx)(M_,{className:`size-4`}),error:(0,Y.jsx)(i_,{className:`size-4`}),loading:(0,Y.jsx)(Qg,{className:`size-4 animate-spin`})},style:_Y,toastOptions:{classNames:{toast:`cn-toast`}},...e})},yY={github:`GitHub`,bitbucket:`Bitbucket`},bY=`then restart megareviewer.`,xY={github:{connect:`Set GITHUB_TOKEN or run \`gh auth login\`, ${bY}`,adds:`Lists and opens GitHub pull requests.`},bitbucket:{connect:`Set BITBUCKET_EMAIL and BITBUCKET_API_TOKEN, and BITBUCKET_WORKSPACE to list its pull requests, ${bY}`,adds:`Lists and opens Bitbucket pull requests.`}},SY=e=>e===1?`1 pull request`:`${e} pull requests`,CY=(e,t,n,r,i)=>{let a=yY[e],{connect:o,adds:s}=xY[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, ${bY} 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} · ${SY(c)} listed ${nL(new Date(r.atMs).toISOString(),i)}`,fix:null}},wY={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`."}},TY=e=>e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`,EY=(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`${TY(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 ${TY(r)}`},DY=(e,{options:t,defaultId:n})=>{let{name:r,providers:i,adds:a,connect:o}=wY[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:EY(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)}, ${bY}`}},OY=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, ${bY}`},kY={failing:0,"not-connected":1,working:2,optional:2,checking:2},AY=(e,t)=>e===1?`1 ${t}`:`${e} ${t}s`,jY=[[`github`,`GitHub`],[`bitbucket`,`Bitbucket`],[`claude`,`Claude`],[`codex`,`Codex`],[`opencode`,`opencode`],[`jira`,`Jira`]],MY=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:Gp(n)};if(t===null)return{rows:jY.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 ${jY.length} connections…`,disconnected:null};let{github:s,bitbucket:c}=t.hosts,l=[CY(`github`,s,c,a,o),CY(`bitbucket`,c,s,a,o),DY(`claude`,t.model),DY(`codex`,t.model),DY(`opencode`,t.model),OY(t.jira.configured)].sort((e,t)=>kY[e.state]-kY[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 ${nL(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:AY(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}},NY={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`},PY={github:Ig,bitbucket:Ig,claude:E_,codex:E_,opencode:E_,jira:O_},FY={working:{label:`Connected`,icon:ng,tone:`text-ci-success`,row:``},failing:{label:`Failing`,icon:M_,tone:`text-destructive`,row:`border-l-3 border-l-destructive bg-review-changes-bg`},"not-connected":{label:`Not connected`,icon:gg,tone:`text-review-pending`,row:`border-l-3 border-l-review-pending bg-review-pending-bg`},optional:{label:`Not connected · Optional`,icon:gg,tone:`text-muted-foreground`,row:``},checking:{label:`Checking…`,icon:Qg,tone:`text-muted-foreground`,row:``}},IY=new Set([`claude`,`codex`,`opencode`]),LY=({className:e})=>(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,e)}),RY=({tone:e})=>e===`checking`?(0,Y.jsx)(LY,{}):e===`ok`?(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`text-ci-success`}):(0,Y.jsx)(M_,{"aria-hidden":`true`}),zY=({row:e})=>{let t=FY[e.state],n=e.state===`optional`&&IY.has(e.kind)?`Not connected`:t.label,r=PY[e.kind],i=t.icon;return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Y.jsxs)(`span`,{className:X(`ml-auto flex items-center gap-1 text-caption`,t.tone),children:[(0,Y.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,Y.jsx)(`p`,{className:`text-caption`,children:e.detail}),e.fix!==null&&(0,Y.jsx)(`p`,{className:`text-caption`,children:e.fix})]})},BY=({connections:e,version:t,checking:n,onCheckAgain:r,checkAgainRef:i})=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1`,children:[(0,Y.jsx)(LN,{className:`text-heading font-semibold`,children:`Connections`}),(0,Y.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:e.summary})]}),e.disconnected===null?(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.rows.map(e=>(0,Y.jsx)(zY,{row:e},e.kind))}):(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-1 pt-2`,children:[(0,Y.jsxs)($,{ref:i,variant:`outline`,size:`sm`,onClick:r,"aria-busy":n,"aria-disabled":n,children:[n&&(0,Y.jsx)(LY,{}),`Check again`]}),t!==null&&(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`megareviewer `,t]})]})]}),VY=({connections:e,version:t,checking:n,open:r,onOpenChange:i,onCheckAgain:a,focusCheckAgain:o=!1})=>{let s=(0,J.useCallback)(e=>{e!==null&&o&&e.focus()},[o]),{label:c,tone:l,name:u}=e.button;return(0,Y.jsxs)(PN,{...r===void 0?{}:{open:r},...i===void 0?{}:{onOpenChange:e=>i(e)},children:[(0,Y.jsxs)(FN,{render:(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:NY[l],"data-tone":l,"aria-label":u}),children:[(0,Y.jsx)(RY,{tone:l}),c]}),(0,Y.jsx)(IN,{align:`end`,className:`w-[min(340px,calc(100vw-24px))] p-2`,initialFocus:!1,children:(0,Y.jsx)(BY,{connections:e,version:t,checking:n,onCheckAgain:()=>{n||a()},checkAgainRef:s})})]})},HY=({now:e=Date.now})=>{let t=yL(),{status:n,error:r,checking:i,checkedAtMs:a,listed:o,open:s,setOpen:c,focusCheckAgain:l}=t,u=MY({status:n,error:r,checking:i,checkedAtMs:a,listed:o,nowMs:e()}),{label:d,tone:f}=u.button,[p,m]=(0,J.useState)(``),h=(0,J.useRef)(!0);return(0,J.useEffect)(()=>{f!==`checking`&&(h.current?h.current=!1:m(`Connections: ${d}`))},[d,f]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(VY,{connections:u,version:n?.version??null,checking:i,open:s,onOpenChange:e=>c(e),onCheckAgain:t.checkAgain,focusCheckAgain:l}),(0,Y.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:p})]})},UY=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}],WY=()=>{let{theme:e,diffPalette:t,setTheme:n,setDiffPalette:r}=gY(),i=Xp(),a=(0,J.useRef)(!1);return(0,Y.jsxs)(vB,{children:[(0,Y.jsx)(yB,{render:(0,Y.jsx)($,{variant:`ghost`,size:`sm`,className:`max-sm:px-1.5`}),children:`Display`}),(0,Y.jsxs)(bB,{align:`end`,className:`w-56`,finalFocus:()=>{let e=a.current;return a.current=!1,!e},children:[i!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(xB,{children:[(0,Y.jsx)(SB,{children:i.label}),(0,Y.jsx)(TB,{value:i.value,onValueChange:e=>{a.current=!0,i.onChange(e)},children:i.options.map(e=>(0,Y.jsx)(EB,{value:e.value,closeOnClick:!0,children:e.label},e.value))})]}),(0,Y.jsx)(DB,{}),i.toggles!==void 0&&(0,Y.jsxs)(Y.Fragment,{children:[i.toggles.map(e=>(0,Y.jsx)(wB,{checked:e.checked,onCheckedChange:e.onChange,children:e.label},e.label)),(0,Y.jsx)(DB,{})]})]}),(0,Y.jsxs)(xB,{children:[(0,Y.jsx)(SB,{children:`Theme`}),(0,Y.jsx)(TB,{value:e,onValueChange:e=>{let t=UY.find(t=>t.value===e);t!==void 0&&n(t.value)},children:UY.map(e=>(0,Y.jsx)(EB,{value:e.value,children:e.label},e.value))})]}),(0,Y.jsx)(DB,{}),(0,Y.jsx)(wB,{checked:t===`cb`,onCheckedChange:e=>r(e?`cb`:`default`),children:`Color-blind safe diff`})]})]})},GY=({current:e})=>(0,Y.jsxs)(Q_,{to:R_,"aria-current":e?`page`:void 0,className:X(Oy({variant:`ghost`,size:`sm`}),`min-w-7 text-foreground hover:no-underline aria-[current=page]:bg-muted max-sm:px-0`),children:[(0,Y.jsx)(w_,{"aria-hidden":`true`,className:`sm:hidden`}),(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Preferences`})]}),KY=()=>{let e=U_(q_());return(0,Y.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,Y.jsx)(Q_,{to:`/`,className:`text-heading font-semibold text-foreground hover:no-underline`,children:`megareviewer`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 max-sm:gap-1`,children:[(0,Y.jsx)(HY,{}),(0,Y.jsx)(GY,{current:e.page===`preferences`}),(0,Y.jsx)(WY,{})]})]})},qY=()=>(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Page not found`}),(0,Y.jsxs)(`p`,{className:`text-body`,children:[`There's nothing at this address. `,(0,Y.jsx)(Q_,{to:`/`,children:`Go to your pull requests`}),`.`]})]}),JY=({reason:e})=>(0,Y.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col gap-3 px-4 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Open megareviewer from your terminal`}),e===`missing`?(0,Y.jsxs)(`p`,{className:`text-body`,children:[`This page needs the link megareviewer printed when it started. It looks like`,` `,(0,Y.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,Y.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,Y.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Not running? Start it with`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`npx megareviewer`}),`.`]})]}),YY=({token:e,fetch:t,openEventStream:n})=>{let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(e.value),s=(0,J.useMemo)(()=>a===null?null:{client:Ap({fetch:t,token:a,onUnauthorized:()=>{let t=e.reject(a);t===null?i(!0):o(t)}}),subscribe:(e,t)=>Mp(e,a,t,n)},[t,n,e,a]);return r?(0,Y.jsx)(JY,{reason:`ended`}):s===null?(0,Y.jsx)(JY,{reason:`missing`}):(0,Y.jsx)(Np.Provider,{value:s,children:(0,Y.jsx)(XY,{},a)})},XY=()=>{let e=U_(q_());return(0,Y.jsx)(JL,{children:(0,Y.jsx)(Yp,{children:(0,Y.jsxs)(bL,{children:[(0,Y.jsx)(KY,{}),(0,Y.jsx)(`main`,{className:X(`px-4 py-5 sm:px-6`,e.page===`picker`&&`min-h-[calc(100dvh-3rem)] bg-surface-subtle`),children:e.page===`picker`?(0,Y.jsx)(kR,{}):e.page===`preferences`?(0,Y.jsx)(cU,{}):e.page===`review`?(0,Y.jsx)(BJ,{analysisId:e.analysisId}):e.page===`open`?(0,Y.jsx)(SL,{pullRequest:e.ref},W_(e.ref)):(0,Y.jsx)(qY,{})}),(0,Y.jsx)(vY,{})]})})})},ZY=class extends J.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,Y.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 px-4 py-12`,role:`alert`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Something went wrong`}),(0,Y.jsx)(`p`,{className:`text-body`,children:`megareviewer hit a bug while showing this page.`}),(0,Y.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,Y.jsx)($,{onClick:t,children:`Reload`})]})}},QY=`token`,$Y=`megareviewer.token`,eX=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(QY),a;return i!==null&&i!==``?(a=i,n(e=>e.setItem($Y,i))):a=n(e=>e.getItem($Y)),r.searchParams.has(QY)&&(r.searchParams.delete(QY),e.history.replaceState(e.history.state,``,`${r.pathname}${r.search}${r.hash}`)),{get value(){return a},reject(e){let t=n(e=>e.getItem($Y));return t===e&&n(e=>e.removeItem($Y)),a=t!==null&&t!==e?t:null,a}}},tX=document.getElementById(`root`);if(tX===null)throw Error(`index.html has no #root`);(0,bc.createRoot)(tX).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(ZY,{children:(0,Y.jsx)(YY,{token:eX(window),fetch:window.fetch.bind(window)})})}));export{s as t};
85
+ `);return(0,Y.jsx)(`pre`,{"data-slot":`thread-code`,className:`overflow-x-auto rounded-md border bg-surface-subtle px-2.5 py-1.5 font-code text-code-compact`,children:(0,Y.jsx)(`code`,{children:r.map((e,t)=>(0,Y.jsx)(`span`,{className:`block min-h-[1lh] whitespace-pre`,children:(0,Y.jsx)(pj,{text:e,tokens:n?.[t]})},t))})})},cM=({kind:e,alt:t,src:n,size:r})=>{let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1);if(i)return(0,Y.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,Y.jsx)(Bg,{"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,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.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,Y.jsx)(aM,{src:n,alt:l,onClose:()=>s(!1)})]}):(0,Y.jsx)(`video`,{"data-slot":`thread-media`,src:n,controls:!0,preload:`metadata`,onError:()=>a(!0),className:c})},lM=({span:e,mediaUrl:t})=>{switch(e.kind){case`text`:return(0,Y.jsx)(Y.Fragment,{children:e.text});case`code`:return(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-code text-code-compact`,children:e.text});case`strong`:return(0,Y.jsx)(`strong`,{className:`font-semibold`,children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`emphasis`:return(0,Y.jsx)(`em`,{children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`strike`:return(0,Y.jsx)(`del`,{children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`link`:return e.url===null?(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t}):(0,Y.jsx)(`a`,{href:e.url,title:e.url,target:`_blank`,rel:`noreferrer noopener nofollow`,className:`underline`,children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:t})});case`image`:case`video`:{if(e.url!==null&&t)return(0,Y.jsx)(cM,{kind:e.kind,alt:e.text,src:t(e.url),size:e.size});let n=e.kind===`image`?`Image`:`Video`;return(0,Y.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,Y.jsx)(Bg,{"aria-hidden":`true`,className:`size-3`}),e.text===``?n:`${n}: ${e.text}`,(0,Y.jsx)(`span`,{className:`sr-only`,children:`, not loaded: it isn't in the host's own attachments`})]})}}},uM=({spans:e,mediaUrl:t})=>e.map((e,n)=>(0,Y.jsx)(lM,{span:e,mediaUrl:t},`${e.kind}:${n}`)),dM={1:`text-heading font-semibold`,2:`text-heading font-semibold`,3:`text-body font-semibold`},fM={left:`text-left`,center:`text-center`,right:`text-right`},pM=({blocks:e,...t})=>e.map((e,n)=>(0,Y.jsx)(mM,{block:e,...t},`${e.kind}:${n}`)),mM=({block:e,suggestion:t,mediaUrl:n})=>{switch(e.kind){case`suggestion`:return(0,Y.jsx)(`div`,{children:t(e.lines)});case`code`:return(0,Y.jsx)(sM,{text:e.text,language:e.language});case`paragraph`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:n})});case`heading`:return(0,Y.jsx)(`p`,{"data-slot":`thread-heading`,className:X(`whitespace-pre-wrap`,dM[e.level]??`font-semibold`),children:(0,Y.jsx)(uM,{spans:e.spans,mediaUrl:n})});case`quote`:return(0,Y.jsx)(`blockquote`,{className:`flex flex-col gap-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,Y.jsx)(pM,{blocks:e.blocks,suggestion:t,mediaUrl:n})});case`list`:{let r=e.items.map((e,r)=>(0,Y.jsx)(`li`,{className:X(`pl-1`,e.checked!==null&&`list-none -ml-5 pl-0`),children:(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[e.checked!==null&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center`,children:e.checked?`☑`:`☐`}),e.checked!==null&&(0,Y.jsx)(`span`,{className:`sr-only`,children:e.checked?`Done: `:`Not done: `}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:(0,Y.jsx)(pM,{blocks:e.blocks,suggestion:t,mediaUrl:n})})]})},r));return e.ordered?(0,Y.jsx)(`ol`,{start:e.start,className:`flex list-decimal flex-col gap-1 pl-5`,children:r}):(0,Y.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5`,children:r})}case`table`:return(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`border-collapse text-ui`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsx)(`tr`,{children:e.head.map((t,r)=>(0,Y.jsx)(`th`,{className:X(`border bg-muted px-2 py-1 font-semibold`,fM[e.align[r]??`left`]),children:(0,Y.jsx)(uM,{spans:t,mediaUrl:n})},r))})}),(0,Y.jsx)(`tbody`,{children:e.rows.map((t,r)=>(0,Y.jsx)(`tr`,{children:t.map((t,r)=>(0,Y.jsx)(`td`,{className:X(`border px-2 py-1`,fM[e.align[r]??`left`]),children:(0,Y.jsx)(uM,{spans:t,mediaUrl:n})},r))},r))})]})});case`rule`:return(0,Y.jsx)(`hr`,{className:`border-border`})}},hM=({blocks:e,suggestion:t,mediaUrl:n})=>(0,Y.jsx)(`div`,{"data-slot":`thread-body`,className:`flex flex-col gap-2 text-body break-words`,children:(0,Y.jsx)(pM,{blocks:e,suggestion:t,mediaUrl:n})}),gM=`inline-flex items-center gap-1 rounded-sm border px-1.5 text-caption font-medium`,_M=`shadow-[inset_0_0_0_2px_var(--ring)]`,vM=({person:e})=>(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex size-6 shrink-0 items-center justify-center rounded-full text-caption font-medium`,mA(e.id)),children:fA(e.name)}),yM=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}`},bM=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},xM=({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,J.useState)(!e.resolved||u),[g,_]=(0,J.useState)(u);u!==g&&(_(u),u&&h(!0));let[v,y]=(0,J.useState)(l!==void 0),[b,x]=(0,J.useState)(0),[S,C]=(0,J.useState)(l?.text??``),[w,T]=(0,J.useState)(l?.status===`posting`),[E,D]=(0,J.useState)(l?.status===`failed`?l.error??``:null),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(null),M=(0,J.useRef)(null),N=(0,J.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,J.useEffect)(()=>{b>0&&M.current?.focus()},[b]),(0,J.useEffect)(()=>{s&&ee()},[s]);let z=()=>M.current?.closest(`[data-slot=review-thread]`)?.focus(),B=()=>{w||(z(),C(``),D(null),y(!1))},V=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)},te=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)},H=e=>(0,Y.jsx)(hj,{title:`Suggested change`,removed:F?i:null,added:e,language:r}),U=e=>(0,Y.jsx)(`time`,{dateTime:e.createdAt,title:yA(e.createdAt),className:`ml-auto shrink-0 pl-3 text-caption text-muted-foreground`,children:vA(e.createdAt,n)}),ne=e=>{let[n]=e;return n===void 0?null:(0,Y.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,Y.jsx)(vM,{person:n.author}),(0,Y.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:n.author.name}),t!==null&&n.author.id===t&&(0,Y.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`}),U(n)]}),e.length>1?(0,Y.jsx)(`span`,{"data-slot":`thread-run`,"aria-hidden":`true`,className:`flex justify-center pt-1.5 pb-1`,children:(0,Y.jsx)(`span`,{className:`w-px bg-thread-run`})}):(0,Y.jsx)(`span`,{"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:e.map((e,t)=>{let{blocks:n}=rf(e.body);return(0,Y.jsxs)(`div`,{"data-slot":`thread-comment`,className:`flex items-baseline`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(hM,{blocks:n,suggestion:H,...c===void 0?{}:{mediaUrl:c}})})}),t>0&&U(e)]},e.id)})})]})},[re]=e.comments,ie=e.line??e.originalLine,ae=e.resolvedBy?.name,oe=I||L;return(0,Y.jsx)(dA,{as:`article`,state:P,"data-slot":`review-thread`,id:d,"data-current":u||void 0,"aria-label":`Thread on ${yM(e)}${e.resolved?`, resolved`:``}`,tabIndex:-1,style:Ph({"--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&&_M,p),children:m?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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:[ie!==null&&(0,Y.jsxs)(Y.Fragment,{children:[e.startLine!==null&&e.line!==null?`Lines`:`Line`,` `,(0,Y.jsx)(xA,{children:bA(e.side,e.line===null?null:e.startLine,ie)}),(0,Y.jsx)(`span`,{children:`·`})]}),(0,Y.jsxs)(`span`,{children:[e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.outdated&&(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-review-approved`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,ae===void 0?``:` by ${ae}`]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),"aria-expanded":!0,children:`Hide`})]})]}),bM(e.comments).map((e,t)=>(0,Y.jsxs)(J.Fragment,{children:[t>0&&(0,Y.jsx)(`hr`,{"data-slot":`thread-divider`}),ne(e)]},e[0]?.id??t)),A!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ `,e.resolved?`Not reopened`:`Not resolved`,`: `,A]}),R?(0,Y.jsxs)(`div`,{"data-slot":`thread-reply`,className:`flex flex-col gap-1.5 border-t pt-3 pl-8.5`,children:[(0,Y.jsxs)(`label`,{htmlFor:N,className:`sr-only`,children:[`Reply to the thread on `,yM(e)]}),(0,Y.jsx)(Vk,{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 V(),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),B())},className:`min-h-14 bg-background`}),E!==null&&(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(lA,{hints:[{id:`submit`,action:`reply`},{id:`close`,action:`cancel`}]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`sm`,disabled:w,onClick:B,children:`Cancel`}),(0,Y.jsx)($,{size:`sm`,disabled:S.trim()===``||w,onClick:()=>void V(),children:w?`Sending…`:`Reply`})]})]})]}):oe&&(0,Y.jsxs)(`div`,{"data-slot":`thread-actions`,className:`flex items-center gap-2 pl-8.5`,children:[I&&(0,Y.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,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:O,onClick:()=>void te(),className:X(!I&&`ml-auto`),children:e.resolved?`Reopen`:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ng,{"aria-hidden":`true`}),`Resolve`]})})]})]}):(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Resolved`,ae===void 0?``:` by ${ae}`]}),re!==void 0&&(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-caption text-muted-foreground`,children:[re.author.name,`: `,Vd(re.body)]}),(0,Y.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>h(!0),"aria-expanded":!1,children:[`Show `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]})]})})},SM=/[\p{L}\p{N}_]+|\s+|[^\p{L}\p{N}_\s]/gu,CM=e=>e.match(SM)??[],wM=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=TM(e[r+n]?.text??``,e[i+n]?.text??``);a!==null&&(t.set(r+n,a.old),t.set(i+n,a.new))}}return t},TM=(e,t)=>{if(e.length>500||t.length>500)return null;let n=CM(e),r=CM(t),{inOld:i,inNew:a}=DM(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:EM(n,i),new:EM(r,a)}},EM=(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},DM=(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}},OM=(e,t=null)=>{let n=wM(e.lines);return UA(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`]:[]]}))},kM=e=>e.kind===`del`?e.oldLine===null?null:{side:`old`,line:e.oldLine}:e.newLine===null?null:{side:`new`,line:e.newLine},AM=`sticky left-0 w-[100cqw]`,jM=`pr-3 pl-29`,MM=({inset:e,children:t})=>(0,Y.jsx)(`div`,{role:`row`,"data-slot":`line-row`,className:X(e&&X(jM,`py-2`),`font-sans`,AM),children:(0,Y.jsx)(`div`,{role:`cell`,children:t})}),NM=(e,t)=>e.side===t.side&&e.line===t.line,PM=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}`,FM=(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},IM=[],LM=(0,J.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,draftNote:g,afterHeader:_,threadsAt:v,rangeNote:y,inFile:b=!1,marks:x,pointLines:S,pointsAt:C,pointsAtEnd:w,flagged:T}){let E=e??t.id,D=(0,J.useRef)(null),[O,k]=(0,J.useState)(!1),A=lj(t,n,cj(D)),j=(0,J.useMemo)(()=>OM(t,A),[t,A]),M=c===void 0||O||j.length<=c?j:j.slice(0,c);(0,J.useEffect)(()=>{let e=D.current;o&&e!==null&&!e.contains(document.activeElement)&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[o]);let N=WA(t),P=!b||i.length>0,F=f!==void 0&&m!==void 0,I=(e,t)=>{let n=d;if(n!==null&&n.side===e.side&&n.line===e.line)f?.(E,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?.(E,{side:e.side,line:r,startLine:t})}else f?.(E,e)};return(0,Y.jsxs)(`section`,{ref:D,"data-slot":`hunk-card`,"data-risk":r?.riskClass,"data-highlighted":a||void 0,className:X(`relative scroll-mt-24 bg-card -outline-offset-2`,!b&&`overflow-hidden rounded-lg border`,a&&`bg-primary/5 shadow-[inset_0_0_0_2px_var(--ring)]`),"aria-label":`${n.path}, ${KA(t)}`,tabIndex:0,onFocus:()=>s?.(E),children:[P&&(0,Y.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`,b&&`sticky left-0 w-[100cqw]`),children:[!b&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(FO,{file:n,status:n.status}),(0,Y.jsx)(IO,{status:n.status}),t.sectionHeading!==null&&(0,Y.jsx)(`code`,{className:`font-mono text-code-compact text-diff-hunk-fg`,children:t.sectionHeading}),(0,Y.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,N.added]}),` `,(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,N.deleted]})]})]}),i.map(e=>(0,Y.jsxs)(`span`,{className:`text-caption text-review-approved`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),e.detail]},e.kind)),!b&&r!==null&&(0,Y.jsxs)(`span`,{className:`ml-auto`,title:r.reason===``?void 0:r.reason,children:[(0,Y.jsx)(HO,{status:OD[r.riskClass]}),r.reason!==``&&(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`: `,r.reason]})]})]}),(l.length>0||_!=null)&&(0,Y.jsxs)(`div`,{className:X(b&&`sticky left-0 w-[100cqw]`),children:[l.map(e=>(0,Y.jsx)(RO,{callers:e,named:l.length>1},e.symbol)),_]}),(0,Y.jsx)(`div`,{role:`table`,"aria-label":`Lines`,className:X(`[content-visibility:auto]`,!b&&`overflow-x-auto`),style:{containIntrinsicSize:`auto ${M.length*20}px`},children:(0,Y.jsx)(`div`,{className:`w-max min-w-full`,children:M.map(e=>{let r=kM({kind:e.kind,oldLine:e.oldNo,newLine:e.newNo}),i=r===null?void 0:u.find(e=>NM(e,r)),a=r!==null&&d!==null&&NM(d,r),o=a?d:i,s=r===null?null:v?.(r)??null,c=r===null?null:C?.(r)??null,l=r===null?null:w?.(r)??null,_=r===null?null:`${r.side}:${r.line}`,D=_===null?void 0:S?.get(_);return(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(SD,{line:e,cellRole:`cell`,pointKind:D?.kind??null,flagged:_!==null&&T?.has(_)===!0,...l===null?{}:{end:l},...D?.landing===void 0?{}:{pointLanding:D.landing},marks:(e.kind===`del`||e.newNo===null?void 0:x?.get(e.newNo))??IM,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||!F?void 0:{side:r.side,label:PM(r),onClick:e=>I(r,e.shiftKey)},...r===null||!F?{}:{onRowClick:e=>{window.getSelection()?.isCollapsed!==!1&&(e.target instanceof Element&&e.target.closest(`button`)||I(r,e.shiftKey))}}}),c,r!==null&&o!=null&&(i!==void 0||a&&m!==void 0)&&(0,Y.jsx)(RM,{place:o,comment:i,editing:a&&m!==void 0,shown:(e,n)=>FM(t,e,n),language:NA(n),rangeNote:y,fileName:n.path.split(`/`).at(-1)??n.path,onChange:m===void 0?void 0:e=>m(E,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e}),onEdit:()=>f?.(E,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine}}),onDone:()=>f?.(E,null),onCancel:()=>p?.(E,o),...h===void 0?{}:{onPostNow:e=>h(E,{side:o.side,line:o.line,...o.startLine===void 0?{}:{startLine:o.startLine},...e})},pinned:b,...g===void 0||i===void 0||m===void 0?{}:{note:g(i,e=>m(E,{...i,body:e}))}}),s!==null&&(0,Y.jsx)(`div`,{role:`row`,"data-slot":`line-threads`,className:X(jM,`py-2 font-sans`,b&&`sticky left-0 w-[100cqw]`),children:(0,Y.jsx)(`div`,{role:`cell`,className:`flex max-w-3xl flex-col gap-2`,children:s})})]},e.key)})})}),M.length<j.length&&(0,Y.jsx)(`div`,{className:X(`border-t p-2`,b&&`sticky left-0 w-[100cqw]`),children:(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>k(!0),children:[`Show all `,j.length,` lines`]})})]})}),RM=({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,note:p})=>{let m=(0,J.useRef)(null),h=(0,J.useRef)(null),[g,_]=(0,J.useState)(`write`),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(null);(0,J.useEffect)(()=>{n?h.current?.focus():(_(`write`),x(null))},[n]);let S=PM(e),C=t?.body??``,w=t?.suggestion,T={body:C,...w===void 0?{}:{suggestion:w}},E=(0,J.useRef)(null);n?E.current===null&&(E.current=T):E.current=null;let D=e.side===`new`?r(e.startLine??e.line,e.line):null,O=e.startLine===void 0?null:`Lines ${e.startLine}–${e.line}`,k=()=>m.current?.closest(`[data-slot=hunk-card]`)?.focus({preventScroll:!0}),A=()=>s?.({body:``}),j=()=>{k(),C.trim()===``&&w===void 0&&s?.({body:``}),l()},M=async()=>{if(d===void 0||v||C.trim()===``)return;y(!0),x(null);let e=await d(T);y(!1),e===null?(k(),s?.({body:``}),l()):x(e)},N=()=>{k();let e=E.current;s?.(e===null||e.body.trim()===``&&e.suggestion===void 0?{body:``}:e),u?.(),l()},P=e=>(0,Y.jsx)(hj,{title:`Suggested change`,removed:D,added:e,language:i});return(0,Y.jsx)(`div`,{ref:m,role:`row`,"data-slot":`line-comment`,"data-editing":n||void 0,className:X(jM,`py-2 font-sans`,f&&`sticky left-0 w-[100cqw]`),children:(0,Y.jsx)(dA,{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(),j()}else e.key===`Escape`&&(e.stopPropagation(),N())}:void 0,children:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-muted-foreground`,children:[`Commenting on `,(0,Y.jsx)(xA,{children:o}),e.startLine===void 0?`line`:`lines`,` `,(0,Y.jsx)(xA,{children:bA(e.side,e.startLine??null,e.line)}),a!==void 0&&e.startLine!==void 0&&(0,Y.jsx)(`span`,{children:a})]}),(0,Y.jsxs)(Ik,{value:g,onValueChange:e=>_(e===`preview`?`preview`:`write`),children:[(0,Y.jsxs)(Rk,{children:[(0,Y.jsx)(zk,{value:`write`,children:`Write`}),(0,Y.jsx)(zk,{value:`preview`,children:`Preview`})]}),(0,Y.jsx)(Bk,{value:`write`,children:(0,Y.jsx)(Vk,{ref:h,rows:2,"aria-label":S,placeholder:`Leave a comment`,value:C,onChange:e=>s?.({...T,body:e.target.value}),onSubmitShortcut:j,className:`min-h-14 bg-background`})}),(0,Y.jsx)(Bk,{value:`preview`,"data-slot":`comment-preview`,className:`min-h-14 rounded-md border px-2.5 py-2`,children:C.trim()===``?(0,Y.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`Nothing to preview`}):(0,Y.jsx)(hM,{blocks:rf(C).blocks,suggestion:P})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(lA,{hints:[{id:`submit`,action:`add to review`},{id:`close`,action:`cancel`}]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`sm`,disabled:v,onClick:N,children:`Cancel`}),d!==void 0&&(0,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:v||C.trim()===``,onClick:()=>void M(),children:v?`Posting…`:`Comment now`}),(0,Y.jsx)($,{size:`sm`,disabled:v,onClick:j,children:`Add to review`})]})]}),b!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:[`✕ Not posted: `,b,` Your comment is still here.`]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[S,`: `]}),(0,Y.jsx)(`span`,{className:X(gM,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:s===void 0?`Posted with your review`:`Draft · posts with your review`}),O!==null&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:O})]}),C.trim()!==``&&(0,Y.jsx)(hM,{blocks:rf(C).blocks,suggestion:P}),w!==void 0&&P(w),s!==void 0&&p,s!==void 0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Edit`}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:A,children:`Discard`})]})]})})})},zM=()=>mD(),BM=({handle:e,payload:t,id:n,render:r=(0,Y.jsx)(`span`,{}),children:i})=>(0,Y.jsx)(pD,{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}),VM=({handle:e,onGoTo:t})=>(0,Y.jsx)(fD,{handle:e,children:({payload:n})=>n===void 0?null:(0,Y.jsx)(hD,{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,Y.jsx)(HM,{payload:n,onGoTo:n=>{e.close(),t(n)}})})}),HM=({payload:e,onGoTo:t})=>{let n=(0,J.useRef)(null),r=e.targets[0],i=r===void 0?null:`${r.hunk.id}:${WM(r.hunk,e.symbol)}`;return(0,J.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,Y.jsx)(`div`,{ref:n,"data-slot":`peek-scroller`,className:`@container relative min-h-0 overflow-auto`,children:(0,Y.jsx)(`div`,{className:`w-max min-w-full`,children:e.targets.map((n,r)=>(0,Y.jsx)(UM,{target:n,symbol:e.symbol,onGoTo:t,divided:r>0,last:r===e.targets.length-1},n.id))})})},UM=({target:e,symbol:t,onGoTo:n,divided:r,last:i})=>{let{hunk:a,file:o}=e,s=lj(a,o,!0),c=(0,J.useMemo)(()=>OM(a,s),[a,s]),l=WA(a),u=KA(a);return(0,Y.jsxs)(`section`,{"aria-label":`${o.path}, ${u}`,className:r?`border-t`:void 0,children:[(0,Y.jsxs)(`header`,{className:X(AM,`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,Y.jsx)(FO,{file:o,status:o.status}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:u}),(0,Y.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,l.added]}),` `,(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,l.deleted]})]}),(0,Y.jsx)($,{variant:`link`,size:`xs`,className:`ml-auto px-0`,onClick:()=>n(e.id),children:`Go to file`})]}),(0,Y.jsx)(`div`,{role:`table`,"aria-label":`Lines of ${t}`,className:`w-max min-w-full`,children:c.map(e=>(0,Y.jsx)(SD,{line:e,layout:`split-new`,cellRole:`cell`,density:`compact`},e.key))}),i&&(0,Y.jsx)(TD,{kind:c.at(-1)?.kind??`context`,className:`h-3`})]})},WM=(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},GM=J.createContext(void 0);function KM(){return J.useContext(GM)}function qM(e){let{render:t,className:n,style:r,state:i=py,props:a=fy,refs:o=fy,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=ck({metadata:s});return _y(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var JM=J.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=FE(u||void 0),h=KM(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=UO({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=$v({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=Yb(Zb,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=_y(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=J.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,Y.jsx)(qM,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),YM=J.createContext(void 0);function XM(e){let t=J.useContext(YM);if(t===void 0&&!e)throw Error(qv(69));return t}var ZM=Dy(`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 QM({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Y.jsx)(JM,{"data-slot":`toggle`,className:X(ZM({variant:t,size:n,className:e})),...r})}J.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});var $M=(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:eN(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}=WA(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]},eN=(e,t)=>e.kind===`rename`&&t.oldPath!==null?`${t.oldPath} → ${t.path} — renamed, content unchanged`:`${t.path} — ${e.detail}`,tN=`flex min-h-8 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-muted-foreground`,nN=({open:e,children:t,...n})=>(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`mechanical-toggle`,"aria-expanded":e,className:X(tN,`hover:bg-accent hover:text-accent-foreground`),...n,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 transition-transform duration-(--duration-fast) ease-standard`,!e&&`-rotate-90`),children:`▾`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:t})]}),rN=(0,J.memo)(function({hunk:e,file:t,risk:n,proofs:r,focused:i=!1,onFocus:a}){let o=(0,J.useRef)(null),[s,c]=(0,J.useState)(!1),{added:l,deleted:u}=WA(e);return(0,J.useEffect)(()=>{let e=o.current;i&&e!==null&&e!==document.activeElement&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:`start`}))},[i]),(0,Y.jsxs)(`div`,{"data-slot":`mechanical-hunk`,className:`bg-surface-subtle`,children:[(0,Y.jsxs)(nN,{ref:o,open:s,onClick:()=>c(e=>!e),onFocus:()=>a?.(e.id),children:[t.path,`, `,KA(e),` — `,r.map(e=>e.detail).join(`; `),` (+`,l,` −`,u,`)`]}),s&&(0,Y.jsx)(LM,{hunk:e,file:t,risk:n,proofs:r,lineLimit:500})]})}),iN=({files:e,proofs:t,risk:n})=>{let r=(0,J.useId)(),i=(0,J.useMemo)(()=>$M(e,t),[e,t]),[a,o]=(0,J.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,Y.jsxs)(`section`,{"aria-labelledby":r,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`h2`,{id:r,className:`flex items-center gap-2 text-heading font-semibold`,children:[`Mechanical changes`,` `,(0,Y.jsx)(`span`,{className:`tabular rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground`,children:i.length})]}),s.length>0&&(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:()=>o(new Set(c?[]:s)),children:c?`Collapse all`:`Expand all`})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>{let t=a.has(e.key);return(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[e.hunk===null||e.file===null?(0,Y.jsxs)(`span`,{className:tN,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0`}),e.summary]}):(0,Y.jsx)(nN,{open:t,onClick:()=>l(e.key),children:e.summary}),t&&e.hunk!==null&&e.file!==null&&(0,Y.jsx)(LM,{hunk:e.hunk,file:e.file,risk:n.find(t=>t.hunkId===e.hunk?.id)??null,proofs:e.proofs,lineLimit:500})]},e.key)})})]})},aN={added:`added`,deleted:`deleted`,modified:`changed`,renamed:`changed`},oN=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 ${aN[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}`}]:[]]}),sN=({files:e})=>{let t=(0,J.useId)(),n=oN(e);return n.length===0?null:(0,Y.jsxs)(`section`,{"aria-labelledby":t,className:`flex flex-col gap-2 rounded-lg border bg-card p-3`,children:[(0,Y.jsx)(`h2`,{id:t,className:`text-heading font-semibold`,children:`Changes without lines to show`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(({key:e,file:t,text:n})=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(FO,{file:t,status:t.status}),(0,Y.jsx)(IO,{status:t.status}),(0,Y.jsx)(`span`,{children:n})]},e))})]})},cN=({hunkId:e,lines:t})=>t.length===0?null:(0,Y.jsx)(`div`,{role:`table`,"aria-label":`Unchanged lines`,children:(0,Y.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,Y.jsx)(SD,{line:a,cellRole:`cell`},n)})})}),lN=J.createContext(void 0);function uN(e){let t=J.useContext(lN);if(t===void 0&&!e)throw Error(qv(47));return t}var dN={...Hw,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Hw.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Hw.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Hw.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},fN=class extends Nw{constructor(e,t,n){let r=new bw;super(pN(e,r,t,n),mN(r),dN)}setOpen=(e,t)=>{let n=t.reason===$b,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=pw(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=fw(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}),cC.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function pN(e,t,n,r=!1){let i={...Iw(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 mN(e){return{popupRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:J.createRef(),beforeTriggerFocusGuardRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),stickIfOpenTimeout:new Ry,stickIfOpen:!0,triggerElements:e}}var hN=Ny(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=_N(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),yw(u,d),gw(u);let{forceUnmount:m}=_w(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),J.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),J.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Yb(mx))}),[m,u]);let h=d||f||s!=null;return(0,Y.jsxs)(lN.Provider,{value:u,children:[s&&(0,Y.jsx)(lw,{handle:s,store:u}),h&&(0,Y.jsx)(vN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function gN(e){return uN(!0)?(0,Y.jsx)(hN,{props:e}):(0,Y.jsx)(SC,{children:(0,Y.jsx)(hN,{props:e})})}function _N(e,t){let n=cw((e,n)=>new fN(t,e,n));return J.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function vN({store:e,modal:t}){let n=zC(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return vw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}function yN(e,t){function n(n,r,i){let a=n.currentTarget;cC.flushSync(()=>{e.setOpen(!1,Yb(ix,n.nativeEvent,a))}),MS(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&&NS(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var bN=Py(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=uN(!0),h=Uw(s)??m;if(!h)throw Error(qv(74));let g=FE(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=J.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=hw(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=eT(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:gT(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=NC(v,{stickIfOpen:Z(()=>h.context.stickIfOpen)}),k=Xj(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=$v({disabled:a,native:o}),N={open(e){return w?Mb.open(e):jb.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=yN(h,x),I=_y(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[iC]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,Y.jsx)(J.Fragment,{children:I},g);return E?(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(jx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,Y.jsx)(jx,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),xN=J.createContext(void 0);function SN(){let e=J.useContext(xN);if(e===void 0)throw Error(qv(45));return e}var CN=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return uN().useState(`mounted`)||n?(0,Y.jsx)(xN.Provider,{value:n,children:(0,Y.jsx)(pC,{ref:t,...r})}):null}),wN=J.createContext(void 0);function TN(){let e=J.useContext(wN);if(!e)throw Error(qv(46));return e}function EN(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=J.useRef(null),o=J.useRef(null),s=rw(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 DN=20;function ON(e,t,n,r){let[i,a]=J.useState(!1);Q(()=>{if(!e||!t||n==null){a(!1);return}let r=Zv(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-DN)},[e,t,n]),zj(e&&(!t||i),r)}var kN=J.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=oC,..._}=e,v=uN(),y=SN(),b=bC(),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=tD({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`)});EN({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;ON(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=aD(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,Y.jsxs)(wN.Provider,{value:j,children:[S&&M&&(0,Y.jsx)(Dj,{inert:cD(!C),cutout:T}),(0,Y.jsx)(xC,{id:b,children:P})]})}),AN=J.createContext(void 0);function jN(){let[e,t]=J.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:J.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var MN=J.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=uN(),l=TN(),u=XM(!0)!=null,{context:d,hasClosePart:f}=jN(),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`);iw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Qw(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?sw(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=_y(`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`,...ow,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Ck.has(e.key)&&e.stopPropagation()}},iD(g),s],stateAttributesMapping:Pb});return(0,Y.jsx)(MC,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:av(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Y.jsx)(AN.Provider,{value:d,children:M})})}),NN=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=uN(),s=FE(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),_y(`h2`,e,{ref:t,props:[{id:s},a]})});function PN({...e}){return(0,Y.jsx)(gN,{"data-slot":`popover`,...e})}function FN({...e}){return(0,Y.jsx)(bN,{"data-slot":`popover-trigger`,...e})}function IN({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,Y.jsx)(CN,{children:(0,Y.jsx)(kN,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,Y.jsx)(MN,{"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 LN({className:e,...t}){return(0,Y.jsx)(NN,{"data-slot":`popover-title`,className:X(`font-medium`,e),...t})}var RN={open:Ag,draft:Pg,merged:Og,closed:Mg},zN=({state:e})=>{let{label:t,className:n}=AD[e],r=RN[e];return(0,Y.jsxs)(VO,{"data-slot":`pr-state`,variant:`outline`,className:n,children:[(0,Y.jsx)(r,{"aria-hidden":`true`}),t]})},BN=({status:e})=>e===null?null:(0,Y.jsx)(`span`,{"data-slot":`review-status`,children:(0,Y.jsx)(HO,{status:jD[e]})}),VN=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`}},HN=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`}},UN=`h-6 gap-1.5 px-1.5 font-normal text-muted-foreground`,WN=({check:e})=>{let t=MD[e.state];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`w-3 shrink-0 text-center`,t.tone),children:t.glyph}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),(0,Y.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:t.label}),e.url!==null&&(0,Y.jsx)(`a`,{className:`shrink-0 text-caption`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`Details of ${e.name}`,children:`Details`})]})},GN=({checks:e,unreadable:t,head:n})=>{let r=e===null?null:wf(e),i=r===null||r.state===null?null:HN(r),a=KN(i);if(e===null)return(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:UN,"data-slot":`ci-summary`,children:`CI not readable`})}),(0,Y.jsxs)(IN,{align:`end`,children:[(0,Y.jsx)(LN,{children:`CI not readable`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:t})]})]});if(r===null||r.state===null)return null;let o=MD[r.state];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsxs)($,{variant:`ghost`,size:`xs`,className:UN,"data-slot":`ci-summary`,"data-state":r.state,"aria-label":`${i}, show checks`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:o.tone,children:o.glyph}),(0,Y.jsx)(`span`,{className:`tabular`,children:VN(r)})]})}),(0,Y.jsxs)(IN,{align:`end`,className:`w-96`,children:[(0,Y.jsxs)(LN,{children:[`Checks on `,(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:n.slice(0,7)})]}),(0,Y.jsx)(`ul`,{className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,"aria-label":`Checks`,children:Cf(e).map(e=>(0,Y.jsx)(WN,{check:e},`${e.name}:${e.url??``}`))})]})]}),(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:a})]})},KN=e=>{let t=(0,J.useRef)(void 0),[n,r]=(0,J.useState)(``);return(0,J.useEffect)(()=>{t.current===void 0?t.current=e:e!==null&&e!==t.current&&(t.current=e,r(e))},[e]),n},qN={"changes-requested":I_,approved:ng,commented:n_},JN=3,YN=({reviewer:e})=>{let t=e.verdict===null?null:qN[e.verdict];return(0,Y.jsxs)(`span`,{className:X(`relative flex size-6 shrink-0 items-center justify-center rounded-full text-caption font-medium ring-2 ring-background`,mA(e.id)),children:[fA(e.name),t!==null&&e.verdict!==null&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 flex size-3 items-center justify-center rounded-full bg-background`,children:(0,Y.jsx)(t,{className:X(`size-2.5`,ND[e.verdict].tone),strokeWidth:3.5})})]})},XN=e=>{let t=new Map;for(let n of e){let e=ND[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(`, `)}`},ZN=({reviewers:e})=>{if(e.length===0)return null;let t=xf(e),n=t.length>JN?t.slice(0,2):t,r=t.length-n.length;return(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:`h-7 px-1`,"data-slot":`reviewers`,"aria-label":`${XN(t)}, show reviewers`,children:(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`flex items-center -space-x-1`,children:[n.map(e=>(0,Y.jsx)(YN,{reviewer:e},e.id)),r>0&&(0,Y.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,Y.jsxs)(IN,{align:`end`,children:[(0,Y.jsx)(LN,{children:`Reviewers`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Reviewers`,children:t.map(e=>{let t=ND[e.verdict??`waiting`];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:(0,Y.jsx)(YN,{reviewer:e})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,e.team&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` (team)`})]}),(0,Y.jsx)(`span`,{className:X(`shrink-0 text-caption`,t.tone),children:t.label})]},e.id)})})]})]})};function QN(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 $N=e=>{switch(e){case`success`:return nP;case`info`:return iP;case`warning`:return rP;case`error`:return aP;default:return null}},eP=Array(12).fill(0),tP=({visible:e,className:t})=>J.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},J.createElement(`div`,{className:`sonner-spinner`},eP.map((e,t)=>J.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),nP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),rP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),iP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),aP=J.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},J.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`})),oP=J.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`},J.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),J.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),sP=()=>{let[e,t]=J.useState(document.hidden);return J.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},cP=1,lP=100,uP=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:cP++,dP=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-lP;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=uP(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],J.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(pP(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`&&!J.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`&&!J.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`&&!J.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`&&!J.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=uP(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}},fP=(e,t)=>dP.message(e,t),pP=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`;Object.assign(fP,{success:dP.success,info:dP.info,warning:dP.warning,error:dP.error,custom:dP.custom,message:dP.message,promise:dP.promise,dismiss:dP.dismiss,loading:dP.loading},{getHistory:()=>dP.toasts,getToasts:()=>dP.getActiveToasts()}),QN(`[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 mP(e){return e.label!==void 0}var hP=3,gP=`24px`,_P=`16px`,vP=4e3,yP=356,bP=14,xP=45,SP=200;function CP(...e){return e.filter(Boolean).join(` `)}function wP(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var TP=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]=J.useState(null),[O,k]=J.useState(null),[A,j]=J.useState(!1),[M,N]=J.useState(!1),[P,F]=J.useState(!1),[I,L]=J.useState(!1),[R,ee]=J.useState(!1),[z,B]=J.useState(0),[V,te]=J.useState(0),H=J.useRef(n.duration||y||vP),U=J.useRef(null),ne=J.useRef(null),re=c===0,ie=c+1<=o,ae=n.type,oe=ae??`default`,W=n.dismissible!==!1,se=n.className||``,ce=n.descriptionClassName||``,le=J.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ue=J.useMemo(()=>n.closeButton??p,[n.closeButton,p]),de=J.useMemo(()=>n.duration||y||vP,[n.duration,y]),fe=J.useRef(0),pe=J.useRef(0),me=J.useRef(0),he=J.useRef(null),[ge,_e]=b.split(`-`),ve=J.useMemo(()=>s.reduce((e,t,n)=>n>=le?e:e+t.height,0),[s,le]),ye=sP(),be=J.useMemo(()=>e.swipeDirections??wP(b),[e.swipeDirections,b]),xe=n.invert||t,Se=ae===`loading`;pe.current=J.useMemo(()=>le*x+ve,[le,ve]),J.useEffect(()=>{H.current=de},[de]),J.useEffect(()=>{j(!0)},[]),J.useEffect(()=>{let e=ne.current;if(e){let t=e.getBoundingClientRect().height;return te(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),J.useLayoutEffect(()=>{if(!A)return;let e=ne.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,te(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 Ce=J.useCallback(()=>{N(!0),B(pe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},SP)},[n,d,a,pe]);J.useEffect(()=>{if(n.promise&&ae===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||ye?(()=>{if(me.current<fe.current){let e=new Date().getTime()-fe.current;H.current-=e}me.current=new Date().getTime()})():H.current!==1/0&&(fe.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Ce()},H.current)),()=>clearTimeout(e)},[u,i,n,ae,ye,Ce]),J.useEffect(()=>{n.delete&&(Ce(),n.onDismiss==null||n.onDismiss.call(n,n))},[Ce,n.delete]);function we(){return w?.loading?J.createElement(`div`,{className:CP(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ae===`loading`},w.loading):J.createElement(tP,{className:CP(C?.loader,n?.classNames?.loader),visible:ae===`loading`})}let Te=n.icon||w?.[ae]||$N(ae);return J.createElement(`li`,{tabIndex:0,ref:ne,className:CP(_,se,C?.toast,n?.classNames?.toast,C?.[oe],n?.classNames?.[oe]),"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":ie,"data-y-position":ge,"data-x-position":_e,"data-index":c,"data-front":re,"data-swiping":P,"data-dismissible":W,"data-type":ae,"data-invert":xe,"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:pe.current}px`,"--initial-height":S?`auto`:`${V}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),he.current=null},onPointerDown:e=>{e.button!==2&&!Se&&W&&(U.current=new Date,B(pe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),he.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{if(I||!W)return;he.current=null;let e=Number(ne.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ne.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-U.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if((E===`x`?be.includes(e>0?`right`:`left`):be.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=xP||a>.11))B(pe.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Ce(),L(!0);else{var o,s;(o=ne.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ne.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),ee(!1),F(!1),D(null)}},onPointerMove:e=>{var t,n;if(!he.current||!W||window.getSelection()?.toString().length>0)return;let r=e.clientY-he.current.y,i=e.clientX-he.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(be.includes(`top`)||be.includes(`bottom`)){if(be.includes(`top`)&&r<0||be.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`&&(be.includes(`left`)||be.includes(`right`))){if(be.includes(`left`)&&i<0||be.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=ne.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=ne.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},ue&&!n.jsx&&ae!==`loading`?J.createElement(`button`,{"aria-label":T,"data-disabled":Se,"data-close-button":!0,onClick:Se||!W?()=>{}:()=>{Ce(),n.onDismiss==null||n.onDismiss.call(n,n)},className:CP(C?.closeButton,n?.classNames?.closeButton)},w?.close??oP):null,(ae||n.icon||n.promise)&&n.icon!==null&&(w?.[ae]!==null||n.icon)?J.createElement(`div`,{"data-icon":``,className:CP(C?.icon,n?.classNames?.icon)},ae===`loading`?n.icon||we():n.promise?we():null,ae===`loading`?null:Te):null,J.createElement(`div`,{"data-content":``,className:CP(C?.content,n?.classNames?.content)},J.createElement(`div`,{"data-title":``,className:CP(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?J.createElement(`div`,{"data-description":``,className:CP(v,ce,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),J.isValidElement(n.cancel)?n.cancel:n.cancel&&mP(n.cancel)?J.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{mP(n.cancel)&&W&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Ce())},className:CP(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,J.isValidElement(n.action)?n.action:n.action&&mP(n.action)?J.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{mP(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Ce())},className:CP(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function EP(){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 DP(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?_P:gP;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 OP=J.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=hP,toastOptions:g,dir:_=EP(),gap:v=bP,icons:y,customAriaLabel:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=J.useState([]),w=J.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=J.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=J.useState([]),[O,k]=J.useState(!1),[A,j]=J.useState(!1),[M,N]=J.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=J.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=J.useRef(null),L=J.useRef(!1),R=J.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||dP.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return J.useEffect(()=>dP.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{cC.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)]})})})}),[]),J.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]),J.useEffect(()=>{S.length<=1&&k(!1)},[S]),J.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]),J.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),J.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?J.createElement(`ol`,{key:t,dir:_===`auto`?EP():_,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":`${yP}px`,"--gap":`${v}px`,...m,...DP(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)=>J.createElement(TP,{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 kP({className:e,...t}){return(0,Y.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 AP=`data-valid`,jP=`data-invalid`,MP={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},NP={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},PP={valid(e){return e===null?null:e?{[AP]:``}:{[jP]:``}}},FP=`data-checked`,IP=`data-unchecked`,LP={checked(e){return e?{[FP]:``}:{[IP]:``}},...bb,...PP},RP={invalid:void 0,name:void 0,validityData:{state:MP,errors:[],error:``,value:``,initialValue:null},setValidityData:dy,disabled:void 0,setTouched:dy,setDirty:dy,setFilled:dy,setFocused:dy,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:NP,registerFieldControl:dy,validation:{getValidationProps:(e,t=py)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:dy,getInputControl:()=>null,commit:async()=>{},change:dy}},zP=J.createContext(RP);function BP(e=!0){let t=J.useContext(zP);if(t.setValidityData===dy&&!e)throw Error(qv(28));return t}function VP(e,t,n){let{setFocused:r,focusOwnerRef:i}=BP(),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 HP=J.createContext({disabled:!1});function UP(){return J.useContext(HP)}var WP=J.createContext({controlId:void 0,registerControlId:dy,resetControlId:dy,labelId:void 0,setLabelId:dy,messageIds:[],setMessageIds:dy,getDescriptionProps:e=>e});function GP(){return J.useContext(WP)}function KP(e,t,n,r=!0,i,a){let[o,s]=J.useState(),c=FE(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:qP(n.current,c);o!==i&&s(i)}),u}function qP(e,t){let n=JP(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function JP(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 YP(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=GP(),o=FE(),s=Ev(()=>Symbol()),c=J.useRef(!1),l=J.useRef(!1),u=Z(()=>{c.current&&i!==dy&&(c.current=!1,i(s.current,void 0))});return Q(()=>{if(!n||i===dy){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}var XP=J.createContext(void 0);function ZP(){return J.useContext(XP)}function QP(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var $P=J.createContext(void 0),eF=J.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=ZP(),{disabled:h,readOnly:g,required:_,form:v,checkedValue:y,touched:b=!1,validation:x,name:S,setCheckedValue:C=dy,setTouched:w=dy,registerInputRef:T=dy}=m??{},{setTouched:E,setFilled:D,state:O,disabled:k}=BP(),A=UP(),{labelId:j,getDescriptionProps:M}=GP(),N=k||A.disabled||h||i,P=g||a,F=_||o,I=v,L=m?y===c:c===``,R=J.useRef(null),ee=VP(N,R),z=J.useRef(null),B=x?.registerInput,V=ny(l,z,T,J.useCallback(e=>B?.(e,{controlRef:R,value:void 0}),[B]));Q(()=>{z.current?.checked&&D(!0)},[D]),Q(()=>{z.current&&T(N&&L?null:z.current)},[L,N,T]);let te=FE(),H=YP({id:d}),U=u?void 0:H,ne={role:`radio`,"aria-checked":L,"aria-labelledby":KP(s,j,z,!u,U,p[`aria-label`]),[ok]:L?``:void 0,id:u?H:te,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||N||P)return;e.preventDefault();let t=z.current;t&&Qv(t,e)},onFocus(e){ee(!0),!(e.defaultPrevented||N||P||!b)&&(z.current?.click(),w(!1))},onBlur(){m||ee(!1)}},{getButtonProps:re,buttonRef:ie}=$v({disabled:N,native:u,composite:!1}),ae={type:`radio`,ref:V,form:I,id:U,name:S,tabIndex:-1,style:S?Ax:kx,"aria-hidden":!0,...c===void 0?py:{value:QP(c)},disabled:N,checked:L,required:F,readOnly:P,onChange(e){if(e.nativeEvent.defaultPrevented||N||P||c===void 0)return;let t=Yb(Zb,e.nativeEvent);C(c,t),!t.isCanceled&&E(!0)},onClick(e){e.stopPropagation()},onFocus(){R.current?.focus()}},oe=J.useMemo(()=>({...O,required:F,disabled:N,readOnly:P,checked:L}),[O,N,P,L,F]),W=oe,se=m!==void 0,ce=[t,R,ie],le=[ne,p,re,M,x?e=>x.getValidationProps(N,e):py],ue=_y(`span`,e,{enabled:!se,state:oe,ref:ce,props:le,stateAttributesMapping:LP});return(0,Y.jsxs)($P.Provider,{value:W,children:[se?(0,Y.jsx)(qM,{tag:`span`,render:n,className:r,style:f,state:oe,refs:ce,props:le,stateAttributesMapping:LP}):ue,(0,Y.jsx)(`input`,{...ae,suppressHydrationWarning:!0})]})});function tF(e,t,n,r,i=!0,a){let{registerFieldControl:o}=BP(),s=Ev(()=>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 nF=J.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:dy,validationMode:`onSubmit`,submitCountRef:{current:0}});function rF(){return J.useContext(nF)}Object.keys(MP);function iF(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var aF=J.createContext(void 0);function oF(e=!1){let t=J.useContext(aF);if(!t&&!e)throw Error(qv(86));return t}var sF=[wk],cF=J.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:g,setFocused:_,validationMode:v,name:y,disabled:b,state:x,validation:S,setDirty:C,setFilled:w,validityData:T}=BP(),{labelId:E}=GP(),{clearErrors:D,elementRef:O}=rF(),k=oF(!0),A=b||i,j=y??d,M=FE(p),[N,P]=UO({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[F,I]=J.useState(!1),L=Z((e,t)=>{s?.(e,t),!t.isCanceled&&P(e)}),R=S.getInputControl,ee=J.useMemo(()=>({get current(){return R()}}),[R]),z=J.useRef(null),B=J.useRef(null),V=ny(z,f),te=J.useRef(V),H=Z(e=>{(z.current!==e||te.current!==V)&&(te.current=V,V?.(e))});Q(()=>{H(z.current)},[V,H]);let U=Z(e=>{if(e){if(!e.disabled){B.current||=e;let t=z.current;(e.checked||t==null||t.disabled)&&H(e)}return()=>{B.current===e&&(B.current=null),z.current===e&&H(null)}}}),ne=Z(()=>{let e=O.current;if(!e)return N??null;for(let t of S.registeredInputs.keys())if(t.checked&&iF(t,e))return N??null;return null});tF(ee,M,N??null,ne,!A,d),Yj(N,()=>{D(j),C(N!==T.initialValue),w(N!=null),S.change(N);let e=B.current;N==null&&e&&!e.disabled&&H(e)});let re=E??k?.legendId,ie={...x,disabled:A??!1,required:o??!1,readOnly:a??!1},ae=J.useMemo(()=>({checkedValue:N,disabled:A,form:u,validation:S,name:j,readOnly:a,registerInputRef:U,required:o,setCheckedValue:L,setTouched:I,touched:F}),[N,A,u,S,j,a,U,o,L,I,F]),oe={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":A||void 0,"aria-readonly":a||void 0,"aria-labelledby":re,onBlur(e){sb(e.currentTarget,e.relatedTarget)||(I(!1),g(!0),_(!1),v===`onBlur`&&S.commit(N))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&I(!0)}};return(0,Y.jsx)(XP.Provider,{value:ae,children:(0,Y.jsx)(Pk,{render:n,className:r,style:m,state:ie,props:[oe,h,e=>S.getValidationProps(A??!1,e)],refs:[t],stateAttributesMapping:PP,enableHomeAndEndKeys:!1,modifierKeys:sF})})});function lF({className:e,...t}){return(0,Y.jsx)(cF,{"data-slot":`radio-group`,className:X(`grid w-full gap-2`,e),...t})}function uF({className:e,...t}){return(0,Y.jsx)(eF,{"data-slot":`radio-group-segment`,className:X(`inline-flex h-7 items-center gap-1.5 rounded-sm px-2.5 text-ui font-medium text-muted-foreground hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 data-checked:bg-secondary data-checked:text-foreground data-checked:inset-ring data-checked:inset-ring-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,e),...t})}var dF=`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,fF=`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`;function pF({className:e,...t}){return(0,Y.jsx)(`div`,{"data-slot":`skeleton`,className:X(`animate-pulse rounded-md bg-muted`,e),...t})}var mF=({lines:e=7})=>(0,Y.jsxs)(`div`,{role:`status`,"aria-label":`Loading the diff`,className:`overflow-hidden rounded-lg border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex h-10 items-center gap-3 border-b px-3`,children:[(0,Y.jsx)(pF,{className:`h-3 w-3`}),(0,Y.jsx)(pF,{className:`h-3 w-56`}),(0,Y.jsx)(pF,{className:`ml-auto h-3 w-12`})]}),(0,Y.jsx)(`div`,{className:`flex flex-col py-1`,children:Array.from({length:e},(e,t)=>(0,Y.jsxs)(`div`,{className:`flex h-5 items-center gap-3 px-3`,children:[(0,Y.jsx)(pF,{className:`h-2.5 w-8`}),(0,Y.jsx)(pF,{className:`h-2.5`,style:{width:`${30+t*37%55}%`}})]},t))})]}),hF=({rows:e=8})=>(0,Y.jsxs)(`div`,{role:`status`,"aria-label":`Loading the files`,className:`flex flex-col gap-2 px-1`,children:[(0,Y.jsx)(pF,{className:`h-7 w-full`}),Array.from({length:e},(e,t)=>(0,Y.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,style:{paddingLeft:`${t%3*12}px`},children:[(0,Y.jsx)(pF,{className:`h-2.5 flex-1`}),(0,Y.jsx)(pF,{className:`h-2.5 w-10`})]},t))]}),gF=J.createContext(void 0);function _F(){let e=J.useContext(gF);if(e===void 0)throw Error(qv(63));return e}var vF=`data-checked`,yF=`data-unchecked`,bF={...PP,checked(e){return e?{[vF]:``}:{[yF]:``}}},xF=J.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}=rF(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,validationMode:E,disabled:D,name:O,validation:k}=BP(),{labelId:A}=GP(),j=D||m,M=O??l,N=J.useRef(null),P=ny(N,c,k.inputRef),F=J.useRef(null),I=VP(j,F),L=FE(),R=YP({id:s}),ee=u?void 0:R,[z,B]=UO({controlled:n,default:!!i,name:`Switch`,state:`checked`});tF(F,L,z,void 0,!j,l),Q(()=>{T(z)},[z,T]),Yj(z,()=>{b(M),C(z!==w.initialValue),k.change(z)});let{getButtonProps:V,buttonRef:te}=$v({disabled:j,native:u}),H=KP(a,A,N,!u,ee,y[`aria-label`]),U={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":H,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&&Qv(t,e)}},ne={...k.getValidationProps(j),checked:z,disabled:j,form:o,id:ee,name:M,required:p,style:M?Ax:kx,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=Yb(Zb,e.nativeEvent);d?.(t,n),!n.isCanceled&&B(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?py:{value:_}},re=J.useMemo(()=>({...x,checked:z,disabled:j,readOnly:f,required:p}),[x,z,j,f,p]),ie=_y(`span`,e,{state:re,ref:[t,F,te],props:[U,y,V,e=>k.getValidationProps(j,e)],stateAttributesMapping:bF});return(0,Y.jsxs)(gF.Provider,{value:re,children:[ie,!z&&M&&g!==void 0&&(0,Y.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,Y.jsx)(`input`,{...ne,suppressHydrationWarning:!0})]})}),SF=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return _y(`span`,e,{state:_F(),ref:t,stateAttributesMapping:bF,props:a})});function CF({className:e,size:t=`default`,...n}){return(0,Y.jsx)(xF,{"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,Y.jsx)(SF,{"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 wF=[{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`}],TF=({open:e,onOpenChange:t,ids:n})=>{let r=Hk.filter(e=>n===void 0||n.includes(e.id)),[i,a]=iA(),o=(0,J.useMemo)($k,[]),s=(0,J.useId)();return(0,Y.jsx)(Qj,{open:e,onOpenChange:t,children:(0,Y.jsxs)(tM,{className:`max-h-[85vh] overflow-y-auto sm:max-w-lg`,children:[(0,Y.jsxs)(nM,{children:[(0,Y.jsx)(rM,{children:`Keyboard shortcuts`}),(0,Y.jsx)(iM,{children:`Keys don't fire while you type in a field.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3`,children:[(0,Y.jsxs)(kP,{htmlFor:s,className:`leading-snug`,children:[`Single-key shortcuts`,(0,Y.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,Y.jsx)(CF,{id:s,checked:i,onCheckedChange:a})]}),wF.filter(({scope:e})=>r.some(t=>t.scope===e)).map(({scope:e,title:t})=>(0,Y.jsxs)(`section`,{"aria-label":t,className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:t}),(0,Y.jsx)(`dl`,{className:`flex flex-col`,children:r.filter(t=>t.scope===e).map(e=>{let t=!i&&e.chords.every(qk);return(0,Y.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-4 border-b py-1 last:border-0`,children:[(0,Y.jsxs)(`dt`,{className:t?`text-muted-foreground line-through`:void 0,children:[e.action,t&&(0,Y.jsx)(`span`,{className:`sr-only`,children:` (off)`})]}),(0,Y.jsx)(`dd`,{className:`flex gap-2`,children:e.chords.map(e=>(0,Y.jsx)(sA,{children:Yk(e,o).map(e=>(0,Y.jsx)(oA,{children:e},e))},Yk(e,o).join(` `)))})]},e.id)})})]},e))]})})},EF,DF=(e,t)=>{if(EF??=document.createElement(`canvas`).getContext(`2d`),EF===null)return null;let n=getComputedStyle(e);return EF.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,EF.letterSpacing=n.letterSpacing===`normal`?`0px`:n.letterSpacing,EF.measureText(t).width},OF=(e,t)=>{if(t(),document.fonts?.ready.then(t),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},kF=J.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}=BP(),{clearErrors:S,elementRef:C,submitCountRef:w}=rF(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=GP(),k=YP({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=Z(()=>x.inputRef.current?.value);tF(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]),Yj(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=J.useRef(null),P=VP(T,N),F=zy();return _y(`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=Yb(Zb,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:PP})}),AF=J.forwardRef(function(e,t){return(0,Y.jsx)(kF,{ref:t,...e})});function jF({className:e,type:t,...n}){return(0,Y.jsx)(AF,{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 MF=J.createContext(void 0);function NF(){let e=J.useContext(MF);if(e===void 0)throw Error(qv(53));return e}function PF(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 FF=`base-ui-disable-scrollbar`,IF={className:FF,getElement(e){return(0,Y.jsx)(`style`,{nonce:e,href:FF,precedence:`base-ui:low`,children:`.${FF}{scrollbar-width:none}.${FF}::-webkit-scrollbar{display:none}`})}},LF=`data-has-overflow-x`,RF=`data-has-overflow-y`,zF=`data-overflow-x-start`,BF=`data-overflow-x-end`,VF=`data-overflow-y-start`,HF=`data-overflow-y-end`,UF=e=>t=>t?{[e]:``}:null,WF={hasOverflowX:UF(LF),hasOverflowY:UF(RF),overflowXStart:UF(zF),overflowXEnd:UF(BF),overflowYStart:UF(VF),overflowYEnd:UF(HF),cornerHidden:()=>null},GF=`--scroll-area-corner-height`,KF=`--scroll-area-corner-width`,qF=`data-orientation`,JF={x:0,y:0},YF={width:0,height:0},XF={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},ZF={x:!0,y:!0,corner:!0},QF=J.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=$F(i),d=FE(),f=zy(),p=zy(),{nonce:m,disableStyleElements:h}=mk(),[g,_]=J.useState(!1),[v,y]=J.useState(!1),[b,x]=J.useState(!1),[S,C]=J.useState(!1),[w,T]=J.useState(!1),[E,D]=J.useState(YF),[O,k]=J.useState(YF),[A,j]=J.useState(XF),[M,N]=J.useState(ZF),P=J.useRef(null),F=J.useRef(null),I=J.useRef(null),L=J.useRef(null),R=J.useRef(null),ee=J.useRef(null),z=J.useRef(null),B=J.useRef(null),V=J.useRef(0),te=J.useRef(0),H=J.useRef(0),U=J.useRef(0),ne=J.useRef(`vertical`),re=J.useRef(JF),ie=J.useRef(null);function ae(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let oe=Z(e=>{let t=e.x-re.current.x,n=e.y-re.current.y;re.current=e,n!==0&&ae(!0),t!==0&&ae(!1)}),W=Z(()=>{let e=F.current;e&&ie.current===null&&(ie.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),se=Z(e=>{if(e.button!==0||B.current!==null&&(ne.current===`vertical`?R.current:ee.current)?.hasPointerCapture(B.current))return;B.current=e.pointerId,V.current=e.clientY,te.current=e.clientX,ne.current=e.currentTarget.getAttribute(qF);let t=F.current;t&&(H.current=t.scrollTop,U.current=t.scrollLeft,W()),(ne.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),ce=Z(e=>{if(e.pointerId!==B.current)return;B.current=null,(ne.current===`vertical`?x:y)(!1),ie.current!==null&&(F.current&&(F.current.style.scrollSnapType=ie.current),ie.current=null);let t=ne.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),le=Z(e=>{if(e.pointerId!==B.current)return;if(e.buttons%2==0){ce(e);return}let t=F.current;if(!t)return;let n=ne.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=PF(i,`padding`,a),s=PF(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-V.current:e.clientX-te.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?H.current:U.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ae(n)});function ue(e){C(e.pointerType===`touch`)}function de(e){if(ue(e),e.pointerType!==`touch`){let t=sb(P.current,e.target);_(t)}}let fe=J.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]),pe={role:`presentation`,onPointerEnter:de,onPointerMove:de,onPointerDown:ue,onPointerLeave(){_(!1)},style:{position:`relative`,[GF]:`${E.height}px`,[KF]:`${E.width}px`}},me=_y(`div`,e,{state:fe,ref:[t,P],props:[pe,o],stateAttributesMapping:WF}),he=J.useMemo(()=>({handlePointerDown:se,handlePointerMove:le,handlePointerUp:ce,handleScroll:oe,disableViewportSnap:W,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:fe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[se,le,ce,oe,W,E,O,w,S,v,b,g,d,M,A,fe,s,c,l,u]);return(0,Y.jsxs)(MF.Provider,{value:he,children:[!h&&IF.getElement(m),me]})});function $F(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 eI(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var tI=J.createContext(void 0);function nI(e,t){return Math.max(0,e-t)}function rI(e,t){if(t<=0)return 0;let n=eI(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 iI=`--scroll-area-overflow-x-start`,aI=`--scroll-area-overflow-x-end`,oI=`--scroll-area-overflow-y-start`,sI=`--scroll-area-overflow-y-end`,cI=`--scroll-area-thumb-height`,lI=`--scroll-area-thumb-width`,uI=[iI,aI,oI,sI],dI=!1;function fI(){dI||Zy||(typeof CSS<`u`&&`registerProperty`in CSS&&uI.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),dI=!0)}var pI=J.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}=NF(),T=VE(),E=J.useRef(!0),D=J.useRef([NaN,NaN,NaN,NaN]),O=zy(),k=zy(),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=mI(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=rI(T===`rtl`?-w:w,P),L=P-I);let R=A?0:rI(x,F),ee=A?0:F-R,z=j?0:b,B=A?0:y,V=0,te=0;!j&&!A&&(V=t?.offsetWidth||0,te=n?.offsetHeight||0);let H=f.width===0&&f.height===0,U=H?V:0,ne=H?te:0,re=PF(n,`padding`,`x`),ie=PF(t,`padding`,`y`),ae=PF(i,`margin`,`x`),oe=PF(r,`margin`,`y`),W=z-re-ae,se=B-ie-oe,ce=n?Math.min(n.offsetWidth-U,W):W,le=t?Math.min(t.offsetHeight-ne,se):se,ue=Math.max(16,ce*M),de=Math.max(16,le*N);if(m(e=>hI(e,{width:ue,height:de})),t&&r){let e=gI(r,cI,x,F,h,de,t.offsetHeight-de-ie-oe);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-ue-re-ae,t=gI(i,lI,T===`rtl`?-w:w,P,_,ue,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let fe=[I,L,R,ee];uI.forEach((t,n)=>{e.style.setProperty(t,`${fe[n]}px`)}),a&&p(e=>hI(e,{width:V,height:te})),g(e=>hI(e,k));let pe={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>hI(e,pe))});Q(()=>{fI()},[]),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=ew(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(dy))).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:IF.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=_y(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:WF}),P=J.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Y.jsx)(tI.Provider,{value:P,children:N})});function mI(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function hI(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function gI(e,t,n,r,i,a,o){let s=eI(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 _I=J.createContext(void 0);function vI(){let e=J.useContext(_I);if(e===void 0)throw Error(qv(54));return e}var yI=J.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}=NF(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=VE(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;J.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 bx(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=lb(e.nativeEvent),n=T?h.current:g.current;if(n&&sb(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=PF(n,`margin`,a),s=PF(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(${GF})`,insetInlineEnd:0,[cI]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${KF})`,bottom:0,[lI]:`${S.width}px`}}},M=_y(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:WF});return A?(0,Y.jsx)(_I.Provider,{value:i,children:M}):null}),bI=J.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}=NF(),m=vI(),h=m===`vertical`;return _y(`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]})}),xI=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=NF(),l=_y(`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 SI({className:e,children:t,...n}){return(0,Y.jsxs)(QF,{"data-slot":`scroll-area`,className:X(`relative`,e),...n,children:[(0,Y.jsx)(pI,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] -outline-offset-2`,children:t}),(0,Y.jsx)(CI,{}),(0,Y.jsx)(xI,{})]})}function CI({className:e,orientation:t=`vertical`,...n}){return(0,Y.jsx)(yI,{"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,Y.jsx)(bI,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}var wI=(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))})},TI=`…`,EI=e=>e.match(/[A-Z]?[a-z0-9]+|[A-Z]+(?![a-z])|[^A-Za-z0-9]+/g)??[e],DI=(e,t,n)=>{for(let r=1;r<=e.length-2;r++)for(let i=Math.ceil((e.length-r)/2);i>=1;i--){if(i+r>e.length-1)continue;let a=[...e.slice(0,i),TI,...e.slice(i+r)].join(t);if(n(a))return a}return null},OI=(e,t)=>{if(t(e))return e;let n=EI(e);if(n.length>2&&n.join(``)===e){let e=DI(n,``,t);if(e!==null)return e}let r=Math.min(8,e.length>>1),i=e;for(let n=e.length-r-1;n>=3;n--)if(i=`${e.slice(0,n)}${TI}${e.slice(-r)}`,t(i))return i;return i},kI=(e,t)=>{if(t(e))return e;let n=e.split(/(?<=[-_.])(?=.)/);for(let e=1;e<=n.length-2;e++)for(let r=Math.ceil((n.length-e)/2);r>=1;r--){if(r+e>n.length-1)continue;let i=n[r+e-1]?.slice(-1)??``,a=`${n.slice(0,r).join(``)}${TI}${i}${n.slice(r+e).join(``)}`;if(t(a))return a}return OI(e,t)},AI=(e,t)=>{if(t(e))return e;let n=e.split(`/`);return n.length<2?e:DI(n,`/`,t)??`${TI}/${n.at(-1)??``}`},jI=e=>{let t=/(?<=.)\.[a-z][a-z0-9]{0,9}$/.exec(e)?.[0]??``;return[e.slice(0,e.length-t.length),t]},MI=e=>{let t=e.split(`/`);for(let e=0;e<t.length-2;e++){let n=t[e]??``;if(!n.includes(`.`)||t[e+1]!==`src`)continue;let r=n.split(`.`);if(t.slice(e+2,e+2+r.length).join(`.`)===n&&!(e+2+r.length>=t.length)){t.splice(e+1,1+r.length);break}}return t.join(`/`)},NI=(e,t)=>{let n=MI(e).split(`/`),r=MI(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},PI=e=>e.slice(0,Math.max(e.lastIndexOf(`/`),0)),FI=e=>e.slice(e.lastIndexOf(`/`)+1),II=e=>{let t={directories:new Map,files:[]};for(let n of e){let e=t;for(let t of MI(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,n,r)=>{let i=e,a=t,o=n===``?e:`${n}/${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];return{label:`${r}${i}`,path:o,inner:a}},r=(t,n,r)=>({kind:`directory`,path:n,label:t,folder:OO(n,e),children:a(r,n)}),i=e=>e.sort((e,t)=>NI(e.kind===`file`?e.path:`${e.path}/x`,t.kind===`file`?t.path:`${t.path}/x`)),a=(e,t)=>i([...[...e.directories].map(([e,i])=>{let{label:a,path:o,inner:s}=n(e,i,t,``);return r(a,o,s)}),...e.files.map(e=>({kind:`file`,path:e,name:FI(e)}))]),o=(e,t,i)=>[...e.directories].flatMap(([e,a])=>{let{label:s,path:c,inner:l}=n(e,a,t,i),u=s.slice(i.length);return l.files.length===0&&l.directories.size>1&&!u.includes(`.`)?o(l,c,`${s}/`):[{prefix:i,heading:r(s,c,l)}]}),s=o(t,``,``).sort((e,t)=>NI(`${e.heading.path}/x`,`${t.heading.path}/x`)),c=[];for(let e=0;e<s.length;){let t=s[e]?.prefix??``,n=e+1;for(;t!==``&&s[n]?.heading.path.startsWith(t);)n++;let r=s.slice(e,n).map(({heading:e})=>e);c.push(...r.length<2?r:[{kind:`group`,path:t.slice(0,-1),children:r.map(e=>({...e,label:e.path.slice(t.length)}))}]),e=n}return[...c,...i(t.files.map(e=>({kind:`file`,path:e,name:FI(e)})))]},LI=e=>e.flatMap(e=>e.kind===`file`?[e.path]:LI(e.children)),RI={added:`new file`,modified:`modified`,deleted:`deleted`,renamed:`renamed`},zI=(e,t)=>`${e} ${t}${e===1?``:`s`}`,BI=e=>e.status===`renamed`?e.oldPath??null:null,VI=e=>{let{finding:t=0,risk:n=0}=e.points??{},r=BI(e),i=r===null?``:` from ${r}`;return[FI(e.path),`${TO(e.path,e.status).label}, ${RI[e.status]}${i}`,e.additions>0?`${zI(e.additions,`line`)} added`:``,e.deletions>0?`${zI(e.deletions,`line`)} removed`:``,(e.threads??0)>0?zI(e.threads??0,`open thread`):``,t>0?zI(t,`finding`):``,n>0?zI(n,`risk`):``,PI(e.path)===``?``:`in ${PI(e.path)}`].filter(Boolean).join(`, `)},HI=e=>{let t=RI[e.status],n=BI(e),r=n===null?``:` · was ${FI(n)}`;return`${e.path}\n${t[0]?.toUpperCase()}${t.slice(1)}${r}`},UI=({files:e,activePath:t,onSelect:n,navigate:r=!1,className:i})=>{let a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(null),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(`all`),[f,p]=(0,J.useState)(new Set),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(t);if(g!==t){_(t);let e=t===null?null:MI(t),n=[...f].filter(t=>e?.startsWith(`${t}/`));n.length>0&&p(new Set([...f].filter(e=>!n.includes(e))))}aA({filterTree:()=>s.current?.focus()});let v=(0,J.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]),y=(0,J.useMemo)(()=>II(e.map(e=>e.path)),[e]),b=e.filter(e=>(e.points?.finding??0)>0).length,x=e.filter(e=>(e.points?.risk??0)>0).length,S=(0,J.useMemo)(()=>{let t=new Set(wI(e,c).map(e=>e.path));return new Set(e.filter(e=>t.has(e.path)).filter(e=>u===`all`||(e.points?.[u]??0)>0).map(e=>e.path))},[e,c,u]),C=c.trim()!==``,w=(0,J.useMemo)(()=>{let e=[],t=e=>e.kind===`file`?Number(S.has(e.path)):e.children.reduce((e,n)=>e+t(n),0),n=(r,i,a)=>{for(let o of r){if(o.kind===`group`){n(o.children,i,o.path);continue}if(o.kind===`file`){let t=v.get(o.path);t!==void 0&&S.has(t.path)&&e.push({kind:`file`,key:t.path,file:t,depth:i,group:a});continue}let r=t(o);if(r===0)continue;let s=C||!f.has(o.path);e.push({kind:`directory`,key:`${o.path}/`,label:o.label,entry:o,depth:i,group:a,open:s,count:r}),s&&n(o.children,i+1,a)}};return n(y,0,null),e},[y,v,S,f,C]),T=(0,J.useMemo)(()=>w.reduce((e,t)=>{let n=e.at(-1);return n!==void 0&&n.group===t.group?n.rows.push(t):e.push({group:t.group,rows:[t]}),e},[]),[w]),E=(0,J.useMemo)(()=>LI(y).filter(e=>S.has(e)),[y,S]),D=(0,J.useMemo)(()=>{let e=E.filter(e=>{let{finding:t=0,risk:n=0}=v.get(e)?.points??{};return t+n>0});return new Map(e.map((e,t)=>[e,t]))},[E,v]),O=e=>{let r=t===null?-1:E.indexOf(t),i=E[Math.min(E.length-1,Math.max(0,r+e))];i!==void 0&&n(i)};aA({nextFile:()=>O(1),previousFile:()=>O(-1)},r),(0,J.useEffect)(()=>{let e=a.current?.querySelector(`[data-slot=scroll-area-viewport]`),t=o.current?.querySelector(`[aria-selected=true]`);if(e==null||t==null)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;(n<e.scrollTop||n>e.scrollTop+e.clientHeight-40)&&(e.scrollTop=Math.max(0,n-e.clientHeight/3))},[t]);let k=w.find(e=>e.key===m)?.key??w.find(e=>e.kind===`file`&&e.file.path===t)?.key??w[0]?.key,A=e=>{e!==void 0&&(h(e),o.current?.querySelector(`[data-key="${CSS.escape(e)}"]`)?.focus())},j=e=>{let t=new Set(f);t.has(e)?t.delete(e):t.add(e),p(t)},M=e=>{h(e.key),e.kind===`file`?n(e.file.path):C||j(e.entry.path)};return(0,Y.jsxs)(`nav`,{ref:a,"aria-label":`Changed files`,className:X(`flex min-h-0 flex-col font-tree`,i),children:[(0,Y.jsxs)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(g_,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Y.jsx)(jF,{ref:s,type:`text`,value:c,spellCheck:!1,autoComplete:`off`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),l(``),e.currentTarget.blur()):e.key===`ArrowDown`&&(e.preventDefault(),A(k))},placeholder:`Filter files`,"aria-label":`Filter files by name or path`,className:`h-7.5 pl-7`})]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex h-7 items-center justify-between text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`tabular`,"aria-live":`polite`,children:S.size===e.length?`${e.length} files`:`${S.size} of ${e.length} files`}),(0,Y.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex gap-px`,children:[[`all`,`All`],[`finding`,`Findings ${b}`],[`risk`,`Risks ${x}`]].map(([e,t])=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:X(`tabular rounded-sm px-1.5 py-0.5 text-caption hover:text-foreground`,u===e&&`bg-secondary font-medium text-foreground`),children:t},e))})]})]}),w.length===0?(0,Y.jsxs)(`p`,{className:`border-t px-3 py-4 text-caption text-muted-foreground`,children:[`No files match.`,` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{l(``),d(`all`)},className:`text-primary underline`,children:`Clear filter`})]}):(0,Y.jsx)(SI,{className:`min-h-0 flex-1 border-t`,children:(0,Y.jsx)(`div`,{ref:o,role:`tree`,"aria-label":`Changed files`,onKeyDown:e=>{let t=w.findIndex(t=>t.key===e.target.dataset.key),n=w[t];if(n===void 0)return;let r=t=>{e.preventDefault(),A(w[Math.min(w.length-1,Math.max(0,t))]?.key)};switch(e.key){case`ArrowDown`:return r(t+1);case`ArrowUp`:if(t===0){e.preventDefault(),s.current?.focus();return}return r(t-1);case`Home`:return r(0);case`End`:return r(w.length-1);case`Enter`:case` `:return e.preventDefault(),M(n);case`ArrowRight`:n.kind===`directory`&&!n.open&&(e.preventDefault(),j(n.entry.path));return;case`ArrowLeft`:{if(n.kind===`directory`&&n.open&&!C){e.preventDefault(),j(n.entry.path);return}let i=w.slice(0,t).findLastIndex(e=>e.depth<n.depth);i>=0&&r(i);return}}},className:`pt-1 pb-4`,children:T.map(e=>{let n=e.rows.map(e=>e.kind===`directory`?(0,Y.jsx)(qI,{row:e,tabbable:e.key===k,onActivate:()=>M(e)},e.key):(0,Y.jsx)(ZI,{file:e.file,depth:e.depth,inset:e.group!==null,active:e.file.path===t,tabbable:e.key===k,onActivate:()=>M(e),...D.has(e.file.path)?{landing:{at:D.get(e.file.path)??0,of:D.size}}:{}},e.key)),r=e.rows[0]?.key??``;return e.group===null?(0,Y.jsx)(J.Fragment,{children:n},r):(0,Y.jsxs)(`div`,{role:`group`,"aria-label":`${e.group}/`,children:[(0,Y.jsx)(KI,{path:e.group}),n]},r)})})})]})},WI=`relative flex min-h-7.5 cursor-default items-center whitespace-nowrap pr-[7px] select-none hover:bg-surface-row focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`,GI=(e,t=!1)=>({paddingLeft:`${6+(e+Number(t))*14}px`}),KI=({path:e})=>(0,Y.jsx)(`div`,{"aria-hidden":`true`,title:e,className:`flex h-6 items-end pr-[7px] pb-0.5 whitespace-nowrap select-none`,style:GI(0),children:(0,Y.jsx)(YI,{path:e,caption:!0})}),qI=({row:e,tabbable:t,onActivate:n})=>(0,Y.jsxs)(`div`,{role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":e.open,"aria-label":`${e.entry.path}, folder, ${zI(e.count,`file`)}`,title:e.entry.path,"data-key":e.key,tabIndex:t?0:-1,onClick:n,className:X(WI,`gap-[5px]`),style:GI(e.depth,e.group!==null),children:[(0,Y.jsx)(cg,{"aria-hidden":`true`,className:X(`size-3 shrink-0 text-muted-foreground transition-transform duration-(--duration-fast) ease-standard`,e.open&&`rotate-90`)}),(0,Y.jsx)(`span`,{className:`mr-px`,children:(0,Y.jsx)(NO,{kind:e.entry.folder})}),(0,Y.jsx)(YI,{path:e.label}),!e.open&&(0,Y.jsx)(`span`,{className:`tabular font-code text-code-compact leading-none text-muted-foreground`,children:e.count})]}),JI={added:[`text-diff-add-fg`,`text-file-ext-add`],deleted:[`text-diff-del-fg line-through decoration-1`,`text-file-ext-del line-through decoration-1`],modified:[``,`text-muted-foreground`],renamed:[``,`text-muted-foreground`]},YI=({path:e,caption:t=!1})=>{let n=(0,J.useRef)(null),r=t?`/`:``,[i,a]=(0,J.useState)(e);(0,J.useLayoutEffect)(()=>{let t=n.current;if(t!==null)return OF(t,()=>{let n=t.clientWidth,i=t.firstElementChild,o=t.lastElementChild;n!==0&&i!==null&&o!==null&&a(AI(e,e=>{let t=e.lastIndexOf(`/`)+1,a=[DF(i,e.slice(0,t)),DF(o,e.slice(t)+r)];return(a[0]??0)+(a[1]??0)<=n+.5}))})},[e,r]);let o=i.lastIndexOf(`/`)+1;return(0,Y.jsxs)(`span`,{ref:n,className:`min-w-0 flex-1 basis-0 truncate text-tree-folder text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:i.slice(0,o)}),(0,Y.jsxs)(`span`,{className:t?void 0:`font-medium text-foreground`,children:[i.slice(o),r]})]})},XI=({file:e})=>{let t=(0,J.useRef)(null),[n,r]=jI(FI(e.path)),[i,a]=(0,J.useState)(n);(0,J.useLayoutEffect)(()=>{let e=t.current;if(e!==null)return OF(e,()=>{let t=e.clientWidth,i=e.firstElementChild,o=e.lastElementChild;if(t===0||i===null||o===null)return;let s=DF(o,r);s!==null&&a(OI(n,e=>(DF(i,e)??0)+s<=t+.5))})},[n,r]);let[o,s]=JI[e.status];return(0,Y.jsxs)(`span`,{ref:t,"data-slot":`file-name`,className:`min-w-0 flex-1 basis-0 truncate text-tree font-medium tracking-[-0.012em]`,children:[(0,Y.jsx)(`span`,{"data-slot":`file-stem`,className:o,children:i}),(0,Y.jsx)(`span`,{"data-slot":`file-extension`,className:X(`font-normal`,s),children:r})]})},ZI=({file:e,depth:t,inset:n,active:r,tabbable:i,landing:a,onActivate:o})=>{let{finding:s=0,risk:c=0}=e.points??{},l=e.threads??0;return(0,Y.jsxs)(`div`,{role:`treeitem`,"aria-level":t+1,"aria-selected":r,"aria-label":VI(e),title:HI(e),"data-key":e.path,"data-status":e.status,tabIndex:i?0:-1,onClick:o,className:X(WI,`gap-1.5`,r&&`bg-diff-hunk-bg before:absolute before:top-1 before:bottom-1 before:left-0 before:w-0.5 before:rounded-full before:bg-primary hover:bg-diff-hunk-bg`),style:GI(t,n),children:[(0,Y.jsx)(MO,{path:e.path,status:e.status}),(0,Y.jsx)(XI,{file:e}),(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`tabular flex flex-none items-center gap-1.5 font-code text-code-compact leading-none text-muted-foreground`,children:[l>0&&(0,Y.jsxs)(`span`,{"data-slot":`thread-count`,className:`inline-flex items-center gap-[2.5px]`,children:[(0,Y.jsx)(n_,{className:`size-3`,strokeWidth:1.75}),l]}),s+c>0&&(0,Y.jsxs)(`span`,{"data-land":`drop`,style:Ph({"--landing-i":a?.at??0,"--landing-n":a?.of??1}),className:`inline-flex items-center gap-1.5`,children:[s>0&&(0,Y.jsxs)(`span`,{"data-slot":`point-count`,"data-kind":`finding`,className:`inline-flex items-center gap-[2.5px]`,children:[(0,Y.jsx)(`i`,{className:`size-1.5 rounded-full bg-severity-minor`}),s>1&&s]}),c>0&&(0,Y.jsx)(`span`,{"data-slot":`point-count`,"data-kind":`risk`,className:`inline-flex items-center`,children:(0,Y.jsx)(`i`,{className:`size-[7px] rounded-full ring-[1.5px] ring-risk-contract-solid ring-inset`})})]}),(e.additions>0||e.deletions>0)&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-[5px]`,children:[e.additions>0&&(0,Y.jsxs)(`span`,{className:`text-stat-add`,children:[`+`,e.additions]}),e.deletions>0&&(0,Y.jsxs)(`span`,{className:`text-stat-del`,children:[`−`,e.deletions]})]})]})]})},QI=({count:e})=>(0,Y.jsxs)(`span`,{"data-slot":`thread-count`,className:`tabular inline-flex items-center gap-0.5 text-caption`,children:[(0,Y.jsx)(n_,{"aria-hidden":`true`,className:`size-3`}),e,(0,Y.jsxs)(`span`,{className:`sr-only`,children:[` open `,e===1?`thread`:`threads`]})]}),$I=60,eL=3600,tL=24*eL,nL=(e,t)=>{let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<$I)return`just now`;if(n<eL)return`${Math.floor(n/$I)} min ago`;if(n<tL)return`${Math.floor(n/eL)} h ago`;let r=Math.floor(n/tL);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`)},rL=e=>new Date(e).toLocaleString(`en`,{dateStyle:`full`,timeStyle:`short`}),iL={github:`GitHub`,bitbucket:`Bitbucket`},aL=({repo:e,number:t})=>`${e.owner}/${e.repo} #${t}`,oL=`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,sL=(e,t)=>{let n=e.role===`author`?`you`:e.author.name;return`${e.title}. ${aL(e.ref)} by ${n}, updated ${nL(e.updatedAt,t)}, ${iL[e.ref.repo.host]}`},cL=({item:e,nowMs:t,starting:n,tabbable:r,onOpen:i,onFocus:a})=>{let o=iL[e.ref.repo.host],s=e.role===`author`?`you`:e.author.name;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:W_(e.ref),"data-pr-row":``,tabIndex:r?0:-1,"aria-label":sL(e,t),"aria-busy":n,onClick:e=>{Z_(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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1 self-stretch`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-x-1.5 text-caption text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 gap-[1ch] font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.ref.repo.owner,`/`,e.ref.repo.repo]}),(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`#`,e.ref.number]})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-medium`,mA(e.author.id)),children:fA(e.author.name)}),(0,Y.jsx)(`span`,{className:`max-w-32 shrink-0 truncate`,children:s}),(0,Y.jsx)(`time`,{dateTime:e.updatedAt,title:rL(e.updatedAt),className:`shrink-0 whitespace-nowrap`,children:nL(e.updatedAt,t)}),(0,Y.jsx)(VO,{variant:`outline`,className:`ml-auto shrink-0 text-muted-foreground @min-[480px]:hidden`,children:o})]})]}),n?(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-caption`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-4 text-diff-hunk-fg`,oL)}),(0,Y.jsx)(`span`,{className:`font-medium text-diff-hunk-fg`,children:`Opening review…`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Esc to cancel`})]}):(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 @max-[479px]:hidden`,children:[(0,Y.jsx)(VO,{variant:`outline`,className:`text-muted-foreground @max-[479px]:hidden`,children:o}),(0,Y.jsx)(cA,{id:`openRow`,className:`hidden group-focus-visible:inline-flex`}),(0,Y.jsx)(cg,{"aria-hidden":`true`,className:`size-4 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 max-sm:hidden`})]})]})})},lL={ArrowDown:(e,t)=>Math.min(t,e+1),ArrowUp:e=>Math.max(0,e-1),Home:()=>0,End:(e,t)=>t},uL=({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,J.useId)(),p=(0,J.useRef)(null),[m,h]=(0,J.useState)(0),g=n??[],_=Math.min(m,Math.max(0,g.length-1)),v=e=>{let t=lL[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,Y.jsxs)(`section`,{"aria-labelledby":f,className:`@container flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:[(0,Y.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,Y.jsx)(`h2`,{id:f,className:`text-heading font-semibold`,children:e}),r!==null&&(0,Y.jsxs)(`span`,{className:`rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground tabular-nums`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,Y.jsx)(`span`,{className:`sr-only`,children:r===`…`?`Loading`:`${r} pull request${r===1?``:`s`}`})]}),(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 p-3 empty:hidden`,children:o}),s??(n===null?(0,Y.jsxs)(`div`,{"aria-busy":`true`,className:`flex flex-col`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 px-4 pt-3 text-caption text-muted-foreground`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-4`,`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`)}),i]}),(0,Y.jsx)(`ul`,{"aria-hidden":`true`,className:`flex flex-col gap-3 px-4 py-3`,children:Array.from({length:a},(e,t)=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(pF,{className:`h-4 w-3/4 motion-reduce:animate-none`}),(0,Y.jsx)(pF,{className:`h-3 w-1/2 motion-reduce:animate-none`})]},t))})]}):g.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-1 px-6 py-8 text-center`,children:[(0,Y.jsx)(y,{"aria-hidden":`true`,className:`mb-1 size-6 text-muted-foreground`}),(0,Y.jsx)(`p`,{className:`font-medium`,children:c.title}),(0,Y.jsx)(`p`,{className:`max-w-sm text-caption text-muted-foreground`,children:c.text})]}):(0,Y.jsx)(`ul`,{ref:p,className:`divide-y`,onKeyDown:v,children:g.map((e,t)=>(0,Y.jsx)(cL,{item:e,nowMs:l,starting:u===e.url,tabbable:t===_,onOpen:()=>d(e),onFocus:()=>h(t)},e.url))}))]})},dL=wc.options,fL=`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-caption`,pL=`h-6 min-w-6 px-1 text-caption`,mL=e=>e.map(e=>iL[e]).join(` and `),hL=(e,t)=>{let n=e===null?[]:dL.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))}},gL=(e,t)=>(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-8 text-center text-caption text-muted-foreground`,children:[(0,Y.jsx)(`p`,{children:e}),t]}),_L=({status:e,list:t,error:n,rowFailure:r,startingUrl:i,nowMs:a,onOpen:o,onRetry:s,onOpenConnections:c,onFix:l})=>{let u=hL(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?`${iL[u.shown[0]]} only`:null,m=e=>n===null?null:(0,Y.jsxs)(`p`,{className:X(dF,fL),role:`alert`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Couldn't list pull requests.`}),(0,Y.jsx)(`span`,{children:Gp(n)}),e&&(0,Y.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:s,children:`Retry`})]}),h=e=>r?.role===e?(0,Y.jsxs)(`p`,{className:X(dF,fL),role:`alert`,children:[(0,Y.jsx)(`span`,{children:r.message}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:r.onRetry,children:`Try again`})]}):null,g=u.failing.map(e=>(0,Y.jsxs)(`p`,{className:X(fF,fL),role:`status`,children:[(0,Y.jsxs)(`span`,{children:[iL[e],` pull requests are hidden until `,iL[e],` works again.`]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:l,children:`Fix…`})]},e)),_=u.listFailed.map(e=>(0,Y.jsxs)(`p`,{className:X(dF,fL),role:`alert`,children:[(0,Y.jsxs)(`span`,{className:`font-medium`,children:[`Couldn't load `,iL[e.host],` pull requests.`]}),(0,Y.jsx)(`span`,{children:e.message}),u.shown.length>0&&(0,Y.jsxs)(`span`,{children:[mL(u.shown),` pull requests are shown.`]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:s,children:`Retry`})]},e.host)),v=u.configured.length===0?`Loading`:`Loading from ${mL(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,Y.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.55fr_1fr]`,children:[(0,Y.jsx)(uL,{title:`To review`,word:p??`Waiting for your review`,items:y,count:x(y),loading:v,skeletonRows:5,notes:(0,Y.jsxs)(Y.Fragment,{children:[t!==null&&m(!0),g,_,h(`reviewer`)]}),blocked:d?gL(`Connect GitHub or Bitbucket to list pull requests.`,(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:c,children:`Open Connections`})):t===null&&n!==null?m(!0):!f&&void 0,empty:{icon:Hg,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,Y.jsx)(uL,{title:`Your pull requests`,word:p??`Open`,items:b,count:x(b),loading:`Loading`,skeletonRows:3,notes:(0,Y.jsxs)(Y.Fragment,{children:[t!==null&&m(!1),h(`author`)]}),blocked:d?gL(`Connect GitHub or Bitbucket to list pull requests.`):t===null&&n!==null?m(!1):f?gL(`Couldn't load pull requests.`):void 0,empty:{icon:Ig,title:`No open pull requests`,text:`Pull requests you open on GitHub or Bitbucket appear here.`},nowMs:a,startingUrl:i,onOpen:o})]})},vL=(0,J.createContext)(null),yL=()=>{let e=(0,J.useContext)(vL);if(e===null)throw Error(`useConnections needs a ConnectionsProvider`);return e},bL=({children:e,now:t=Date.now})=>{let{status:n,error:r,loading:i,refresh:a}=Lp(),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1);(0,J.useEffect)(()=>{!i&&n!==null&&s(t())},[i,n,t]);let g=(0,J.useCallback)(()=>{a(),d(e=>e+1)},[a]),_=(0,J.useCallback)((e,t)=>{h(e&&t?.focusCheckAgain===!0),p(e)},[]),v=(0,J.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,Y.jsx)(vL.Provider,{value:v,children:e})},xL=({pullRequest:e,error:t})=>{let{setOpen:n}=yL(),r=`Couldn't open ${aL(e)}: `;return t.code===`host-not-configured`?(0,Y.jsxs)(Y.Fragment,{children:[r,iL[e.repo.host],` isn't configured.`,` `,(0,Y.jsx)($,{variant:`link`,className:pL,onClick:()=>n(!0),children:`Open Connections`})]}):(0,Y.jsx)(Y.Fragment,{children:`${r}${Gp(t)}`})},SL=({pullRequest:e})=>{let{client:t}=Pp(),[n,r]=(0,J.useState)(0),[i,a]=(0,J.useState)(null),o=aL(e),s=(0,J.useRef)(0);return(0,J.useEffect)(()=>(s.current=n,t.startAnalysis({url:jf(e)}).then(e=>{s.current===n&&(e.ok?X_(G_(e.value.analysisId)):a(e.error))}),()=>{s.current=-1}),[t,e,n]),(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:o}),(0,Y.jsx)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-body`,children:i===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-4`,oL)}),`Fetching `,o,` from `,iL[e.repo.host],`…`]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:()=>{s.current=-1,X_(`/`)},children:`Cancel`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-4 align-[-3px]`}),(0,Y.jsx)(xL,{pullRequest:e,error:i})]}),(0,Y.jsx)($,{variant:`link`,className:pL,onClick:()=>{a(null),r(e=>e+1)},children:`Try again`})]})}),i!==null&&(0,Y.jsx)(`p`,{className:`text-body`,children:(0,Y.jsx)(Q_,{to:`/`,children:`Go to your pull requests`})})]})},CL=J.createContext(void 0);function wL(e){let t=J.useContext(CL);if(t===void 0&&!e)throw Error(qv(72));return t}var TL={...Hw,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},EL=class extends Nw{constructor(e,t,n){let r=new bw;super(OL(e,r,t,n),kL(r),TL)}setOpen=(e,t)=>{mw(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Yb(Qb,e))}};function DL(){let e=new bw,t=new SE(Object.freeze(OL(void 0,e)),Object.freeze(kL(e)),TL);return Object.assign(t,{setOpen:dy,cancelPendingOpen:dy})}function OL(e,t,n,r=!1){return{...Iw(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 kL(e){return{popupRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var AL=Ny(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=cw((e,t)=>new EL({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}),gw(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=_w(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=J.useRef(null);Q(()=>{m&&t&&p.setOpen(!1,Yb(dx))},[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]),J.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,Yb(mx))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Y.jsxs)(CL.Provider,{value:p,children:[l&&(0,Y.jsx)(lw,{handle:l,store:p}),T&&(0,Y.jsx)(jL,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function jL({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=zC(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=IC(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=J.useMemo(()=>Nv(a.reference,i.reference),[a.reference,i.reference]);return vw(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??py}),null}var ML=J.createContext(void 0);function NL(){return J.useContext(ML)}var PL=`data-base-ui-tooltip-trigger`;function FL(e){let t=lb(e);return iv(t)?t:null}var IL=Py(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=wL(!0),m=Uw(a)??p;if(!m)throw Error(qv(82));let h=FE(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=J.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=hw(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=NL(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=yx(v,{open:_}),O=Zw(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Sx(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=J.useRef(!1),F=zy(),I=J.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=cb(e,`[${PL}]`);return n!==null&&n!==t&&sb(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=eT(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?gT():null,restMs:L,delay(){return u==null&&D?{close:Gb(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),B=Kw(v,{enabled:!A}).reference,V=e=>{let t=P.current,n=FL(e),r=ee(n),i=y.current,a=i&&n&&sb(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,Yb($b,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&ib(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,Yb($b,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},te=m.useState(`appliedTriggerProps`,S||M!==`none`);return _y(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,B,te,{onMouseOver(e){V(e.nativeEvent)},onFocus(e){R(FL(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,[Fb]:A?``:void 0,[PL]:A?void 0:``},f],stateAttributesMapping:jb})}),LL=J.createContext(void 0);function RL(){let e=J.useContext(LL);if(e===void 0)throw Error(qv(70));return e}var zL=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return wL().useState(`mounted`)||n?(0,Y.jsx)(LL.Provider,{value:n,children:(0,Y.jsx)(NE,{ref:t,...r})}):null}),BL=J.createContext(void 0);function VL(){let e=J.useContext(BL);if(e===void 0)throw Error(qv(71));return e}var HL=J.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=oC,style:g,..._}=e,v=wL(),y=RL(),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=tD({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=aD(e,J.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,Y.jsx)(BL.Provider,{value:D,children:O})}),UL=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=wL(),{side:s,align:c}=VL(),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`);iw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Qw(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return _y(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[ow,f,iD(d),a],stateAttributesMapping:Pb})}),WL=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=wL(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=VL();return _y(`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:Nb})}),GL=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=J.useMemo(()=>({open:t,close:n}),[t,n]);return(0,Y.jsx)(ML.Provider,{value:t,children:(0,Y.jsx)(vx,{delay:i,timeoutMs:r,children:e.children})})},KL=class extends ZC{constructor(){super(DL(),`Tooltip`)}open(e){this.openByTrigger(e)}close(){this.closePopup()}get isOpen(){return this.attachedStore?.select(`open`)??!1}};function qL(){return new KL}function JL({delay:e=0,...t}){return(0,Y.jsx)(GL,{"data-slot":`tooltip-provider`,delay:e,...t})}function YL({...e}){return(0,Y.jsx)(AL,{"data-slot":`tooltip`,...e})}function XL({...e}){return(0,Y.jsx)(IL,{"data-slot":`tooltip-trigger`,...e})}function ZL({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,collisionBoundary:a,children:o,shortcut:s,...c}){return(0,Y.jsx)(zL,{children:(0,Y.jsx)(HL,{collisionBoundary:a,align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,Y.jsxs)(UL,{"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,Y.jsx)(oA,{children:s}),(0,Y.jsx)(WL,{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 QL=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))},$L=e=>String(e).padStart(2,`0`),eR=e=>{let t=new Date(e);return`${t.getFullYear()}-${$L(t.getMonth()+1)}-${$L(t.getDate())}`},tR=e=>new Date(`${e}T00:00:00Z`),nR=e=>tR(e).toLocaleDateString(`en`,{month:`short`,day:`numeric`,timeZone:`UTC`}),rR=e=>tR(e).toLocaleDateString(`en`,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}),iR=e=>tR(e).toLocaleDateString(`en`,{month:`short`,timeZone:`UTC`}),aR=e=>Number(e.slice(8,10)),oR=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=>aR(e.date)===1);if(i!==void 0)return iR(i.date);let a=r[0];return n===0&&a!==void 0&&aR(a.date)<=7?iR(a.date):null})},sR=e=>e===1?`1 PR`:`${e} PRs`,cR=e=>e===1?`1 comment`:`${e} comments`,lR=e=>`${e.pullRequests===0?`No PRs`:sR(e.pullRequests)} reviewed · ${cR(e.comments)}`,uR=(e,t)=>`${nR(e.date)}: ${e.pullRequests===0?`No PRs`:sR(e.pullRequests)} reviewed, ${cR(e.comments)}${e.date===t?` (today)`:``}`,dR=e=>`Busiest day: ${nR(e.date)}, ${sR(e.pullRequests)} and ${cR(e.comments)}.`,fR=(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},pR=e=>Fc(e),mR={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`},hR=[{level:0,label:`0`},{level:1,label:`1`},{level:2,label:`2`},{level:3,label:`3–4`},{level:4,label:`5+`}],gR=[``,`Mon`,``,`Wed`,``,`Fri`,``],_R=({level:e,className:t})=>(0,Y.jsx)(`span`,{className:X(`flex items-center justify-center rounded-[4px] border`,mR[e],t),children:e===4&&(0,Y.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),vR=e=>{let[t,n]=(0,J.useState)(null);return(0,J.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},yR=qL(),bR=({days:e,today:t,weeks:n})=>{let[r,i]=(0,J.useState)(t),a=(0,J.useRef)(new Map),o=(0,J.useRef)(null),s=e.some(e=>e.date===r)?r:e[0]?.date??t,c=oR(e),l=Math.ceil(e.length/7);return(0,Y.jsxs)(`div`,{ref:o,className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.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,Y.jsx)(`span`,{className:`h-4 overflow-visible whitespace-nowrap`,children:e},t))}),(0,Y.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=fR(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:gR.map((n,r)=>(0,Y.jsxs)(`div`,{role:`row`,className:`flex items-center`,children:[(0,Y.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||pR(c.date)!==r)return(0,Y.jsx)(`span`,{className:`size-6 shrink-0`},o);let l=zc(c.pullRequests);return(0,Y.jsx)(XL,{handle:yR,payload:c,delay:150,render:(0,Y.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":uR(c,t),onFocus:()=>i(c.date),className:`group flex size-6 shrink-0 items-center justify-center rounded-md`}),children:(0,Y.jsx)(_R,{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,Y.jsx)(AL,{handle:yR,children:({payload:e})=>e===void 0?null:(0,Y.jsx)(ZL,{collisionBoundary:o.current??void 0,children:(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`font-semibold`,children:rR(e.date)}),(0,Y.jsx)(`span`,{children:lR(e)})]})})}),(0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`flex items-start gap-2 pl-8 text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`leading-4`,children:`PRs a day`}),hR.map(({level:e,label:t})=>(0,Y.jsxs)(`span`,{className:`flex w-6 flex-col items-center gap-0.5`,children:[(0,Y.jsx)(_R,{level:e,className:`size-4`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:t})]},e))]})]})},xR=({value:e,label:t})=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-title font-semibold tabular-nums`,children:e}),(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:t})]}),SR=({activity:e,error:t,onRetry:n,now:r})=>{let i=(0,J.useId)(),a=(0,J.useRef)(null),o=vR(a),s=QL(o),c=o===null||o>=900,l=eR(r()),u=(0,J.useMemo)(()=>e===null?null:Rc(e,{today:l,weeks:s,dayOf:eR}),[e,l,s]),d=(0,J.useMemo)(()=>e===null?null:Rc(e,{today:l,weeks:26,dayOf:eR}),[e,l]),f=u===null?null:Bc(u),p=d?.every(e=>e.pullRequests===0&&e.comments===0)===!0;return(0,Y.jsxs)(`section`,{"aria-labelledby":i,className:`flex flex-col rounded-xl border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b px-4 py-2.5`,children:[(0,Y.jsx)(`h2`,{id:i,className:`text-heading font-semibold`,children:`Review activity`}),(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`Last `,s,` weeks`]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground max-sm:basis-full sm:ml-auto`,children:[(0,Y.jsx)(Kg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Reviews and comments posted from megareviewer on this machine`]})]}),(0,Y.jsx)(`div`,{className:`overflow-hidden px-4 py-4`,children:(0,Y.jsx)(`div`,{ref:a,children:u===null||f===null?t===null?(0,Y.jsx)(pF,{"aria-label":`Loading review activity`,className:`h-[244px] w-full motion-reduce:animate-none`}):(0,Y.jsxs)(`p`,{className:X(dF,`flex flex-wrap items-baseline gap-x-2 text-caption`),children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Couldn't read your review activity.`}),(0,Y.jsx)(`span`,{children:Gp(t)}),(0,Y.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:n,children:`Try again`})]}):(0,Y.jsxs)(`div`,{className:X(`flex gap-8`,c?`flex-row`:`flex-col`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(bR,{days:u,today:l,weeks:s}),p&&(0,Y.jsxs)(`p`,{className:`rounded-md bg-muted px-3 py-2 text-caption text-muted-foreground`,children:[(0,Y.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,Y.jsxs)(`div`,{className:X(`flex flex-col gap-3`,c&&`w-[260px] shrink-0`),children:[(0,Y.jsxs)(`div`,{className:X(`grid gap-x-6 gap-y-3`,c||o!==null&&o<520?`grid-cols-2`:`grid-cols-4`),children:[(0,Y.jsx)(xR,{value:f.pullRequests,label:`PRs reviewed`}),(0,Y.jsx)(xR,{value:f.comments,label:`comments posted`}),(0,Y.jsx)(xR,{value:f.daysWithReviews,label:`days with reviews`}),(0,Y.jsx)(xR,{value:f.thisWeek,label:`PRs this week`})]}),f.busiest!==null&&(0,Y.jsx)(`p`,{className:`border-t pt-3 text-caption text-muted-foreground`,children:dR(f.busiest)})]})]})})})]})},CR=`Paste a pull request link first.`,wR=`That isn't a pull request link. Use github.com/owner/repo/pull/123 or bitbucket.org/workspace/repo/pull-requests/45.`,TR=`h-6 min-w-6 px-1 text-caption`,ER=Wk(`openInNewTab`).chords[0]??{key:`Enter`,mod:!0},DR=({inputRef:e,start:t,onSubmit:n,onSubmitInNewTab:r,onEdit:i,initial:a})=>{let[o,s]=(0,J.useState)(a?.url??``),[c,l]=(0,J.useState)(a?.invalid??null),u=(0,J.useId)(),d=t?.state===`starting`,f=()=>{let e=o.trim();if(e===``)return l(CR),null;let t=Af(e);return t.ok||l(wR),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=$k();return(0,Y.jsx)(`search`,{children:(0,Y.jsxs)(`form`,{"aria-label":`Open a pull request by link`,className:`flex flex-col gap-1.5`,onSubmit:p,noValidate:!0,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2 max-sm:flex-col`,children:[(0,Y.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Y.jsx)(Xg,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Y.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=>{Xk(e,ER,h)&&m(e)},onChange:e=>{s(e.target.value),l(null),i()},"aria-invalid":c!==null,"aria-describedby":`${u}-message`}),(0,Y.jsx)(cA,{id:`focusLink`,className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2`})]}),(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:oL}),`Opening…`]}):`Review`})]}),(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`size-3.5`,oL)}),t.message]}),(0,Y.jsx)($,{type:`button`,variant:`link`,className:TR,onClick:t.onCancel,children:`Cancel`})]}):t?.state===`failed`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),t.message]}),(0,Y.jsx)($,{type:`button`,variant:`link`,className:TR,onClick:t.onRetry,children:`Try again`})]}):null:(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),c]})})]})})},OR=wc.options,kR=({now:e=Date.now})=>{let{client:t}=Pp(),{status:n,checks:r,reportListed:i,setOpen:a}=yL(),o=Rp(),s=zp(),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),f=(0,J.useRef)(0),p=(0,J.useRef)(null),m=(0,J.useRef)(null),{refresh:h}=o,{refresh:g}=s,_=(0,J.useCallback)(()=>{h(),g()},[h,g]),v=(0,J.useRef)(r);(0,J.useEffect)(()=>{r!==v.current&&(v.current=r,_())},[r,_]),(0,J.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 OR)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,J.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&m.current!==null&&e()-m.current>12e4&&_()};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,_]),(0,J.useEffect)(()=>{let e=e=>{e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey||Zk(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 ${aL(n)}`);let o=await t.startAnalysis({url:e});f.current===a&&(o.ok?Y_(G_(o.value.analysisId)):l({from:r,url:e,ref:n,role:i,state:`failed`,error:o.error}))},b=(0,J.useCallback)(e=>{f.current+=1,l(null),e===`form`?p.current?.focus():d(`Cancelled`)},[]),x=c?.state===`starting`&&c.from===`row`;(0,J.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,Y.jsx)(xL,{pullRequest:e.ref,error:e.error}),C=c?.from===`form`?c.state===`starting`?{state:`starting`,message:`Fetching ${aL(c.ref)} from ${iL[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,Y.jsxs)(`div`,{className:`mx-auto flex max-w-[1240px] flex-col gap-4`,children:[(0,Y.jsx)(`h1`,{className:`sr-only`,children:`Pull requests`}),(0,Y.jsx)(DR,{inputRef:p,start:C,onSubmit:(e,t)=>void y(e,t,`form`,null),onSubmitInNewTab:e=>window.open(W_(e),`_blank`,`noopener`),onEdit:()=>{c?.from===`form`&&c.state===`failed`&&l(null)}}),(0,Y.jsx)(_L,{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,Y.jsx)(SR,{activity:s.activity,error:s.error,onRetry:g,now:e}),(0,Y.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:u})]})},AR=`megareviewer:`,jR=e=>{try{let t=window.localStorage.getItem(AR+e);return t===null?void 0:JSON.parse(t)}catch{return}},MR=(e,t)=>{try{window.localStorage.setItem(AR+e,JSON.stringify(t))}catch{}},NR=(e,t,n)=>{let[r,i]=(0,J.useState)(()=>({key:e,value:n(jR(e))??t}));return[r.key===e?r.value:n(jR(e))??t,(0,J.useCallback)(r=>i(i=>{let a=r(i.key===e?i.value:n(jR(e))??t);return MR(e,a),{key:e,value:a}}),[e,t,n])]},PR=e=>typeof e==`boolean`?e:void 0,FR=e=>{try{let t=window.sessionStorage.getItem(AR+e);return t===null?void 0:JSON.parse(t)}catch{return}},IR=(e,t)=>{try{window.sessionStorage.setItem(AR+e,JSON.stringify(t))}catch{}},LR=e=>typeof e==`string`?e:void 0,RR=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]]})},zR=(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)},BR=(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)))},VR=e=>e.length===0?`No model is known to megareviewer`:e.some(e=>e.available)?null:RR(e).map(([e])=>e.reason??`${e.providerName} can't run`).join(`; or `),HR=e=>{let[t,n]=NR(`model-option`,null,LR),r=e?.options??[],i=r.find(e=>e.id===t&&e.available)??r.find(t=>t.id===e?.defaultId)??null,a=(0,J.useCallback)(e=>n(()=>e),[n]);return{options:r,chosen:i,defaultId:e?.defaultId??null,locked:e===null?null:VR(r),choose:a}},UR={github:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`,bitbucket:`M.778 1.213a.768.768 0 00-.768.892l3.263 19.81c.084.5.515.868 1.022.873H19.95a.772.772 0 00.77-.646l3.27-20.03a.768.768 0 00-.768-.891zM14.52 15.53H9.522L8.17 8.466h7.561z`},WR=({host:e,className:t})=>(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,"data-host":e,className:X(`size-[15px] shrink-0`,t),children:(0,Y.jsx)(`path`,{d:UR[e]})}),GR=J.createContext(void 0);function KR(e){let t=J.useContext(GR);if(t===void 0&&!e)throw Error(qv(33));return t}var qR=J.createContext(void 0);function JR(e){let t=J.useContext(qR);if(t===void 0&&!e)throw Error(qv(36));return t}var YR=J.createContext(void 0);function XR(e=!0){let t=J.useContext(YR);if(t===void 0&&!e)throw Error(qv(25));return t}var ZR=J.createContext(null);function QR(e=`root`){let t=J.useContext(ZR),n=J.useContext(qR);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var $R={visible:!0,ref:null};function ez(){return $R}function tz(e,t,n=`root`){let r=QR(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??ez)({label:e.label,children:e.children,render:e.render}),a=ny(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var nz=J.createContext(void 0);function rz(){let e=J.useContext(nz);if(e===void 0)throw Error(qv(30));return e}function iz(e){e.preventDefault()}function az(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=JR(),u=XR(!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 J.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?iz: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:nx})},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&&!Yy&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Qv(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var oz={type:`regular-item`};function sz(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=J.useRef(null),{getButtonProps:d,buttonRef:f}=$v({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=az({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=J.useCallback(e=>Nv(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=ny(u,f);return J.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var cz=`data-checked`,lz=`data-unchecked`,uz={checked(e){return e?{[cz]:``}:{[lz]:``}},...bb},dz=J.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}=JR(),m=sk({guess:!0,label:a}),h=FE(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}=sz({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:oz}),C=J.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=Yb(nx,e.nativeEvent,void 0,{preventUnmountOnClose:dy});u?.(!l,t)}let T=_y(`div`,e,{state:C,stateAttributesMapping:uz,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,Y.jsx)(nz.Provider,{value:C,children:T})}),fz=J.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=UO({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=tz(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,Y.jsx)(dz,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),pz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=rz(),c=J.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=$C(s.checked);return iw({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),_y(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:uz,props:{"aria-hidden":!0,...o},enabled:a||u})}),mz=J.createContext(void 0);function hz(){let e=J.useContext(mz);if(e===void 0)throw Error(qv(31));return e}var gz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=J.useState(void 0),c=_y(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Y.jsx)(mz.Provider,{value:s,children:c})}),_z=J.forwardRef(function(e,t){let n=QR()?.Group??gz;return(0,Y.jsx)(n,{...e,ref:t})}),vz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=FE(a),c=hz();return Q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),_y(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),yz=J.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}=JR(),f=sk({guess:!0,label:a}),p=FE(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}=sz({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:oz});return _y(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),bz=J.forwardRef(function(e,t){let n=tz(e,t);return n.visible?(0,Y.jsx)(yz,{...e,ref:n.ref}):null}),xz=J.createContext(void 0);function Sz(){return J.useContext(xz)}function Cz(e,t){let n=xy(e.render);if(J.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function wz(e,t,n){let r=Cz(e,t),i=r===t?void 0:r;return[r,J.useCallback(e=>n?.(e?i:void 0),[i,n])]}function Tz(e,t,n){let r=xy(e.render),i=J.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 Ez=J.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}=JR(),m=Sz(),{side:h,align:g}=KR(),_=XM(!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]=wz(e,u,d),L=Tz(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),iw({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),J.useEffect(()=>{function e(e){l.setOpen(!1,Yb(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Qw(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let B=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:V,handleFocus:te}=(J.useContext(ZR)?.useParentHandoff??Oz)(l,w,v,f),H=_y(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,B,I],stateAttributesMapping:Pb,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&Ck.has(e.key)&&e.stopPropagation()},onFocus:te},iD(y),c,{"data-rootownerid":E}]}),U=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(U=!0);let ne=R?.getReturnElement??V;return(0,Y.jsx)(MC,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??ne??U,explicitReturnFocus:a===void 0&&ne?!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:H})}),Dz={parentVirtualFocusRef:void 0,handleFocus:void 0};function Oz(){return Dz}var kz=J.forwardRef(function(e,t){let n=QR()?.Popup??Ez;return(0,Y.jsx)(n,{...e,ref:t})}),Az=J.createContext(void 0);function jz(){let e=J.useContext(Az);if(e===void 0)throw Error(qv(32));return e}var Mz=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=JR();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Y.jsx)(Az.Provider,{value:n,children:(0,Y.jsx)(pC,{ref:t,...r,portalOwnerRole:o})})}),Nz=J.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=aC,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=JR(),x=jz(),S=XR(!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,B=l,V=s,te=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,V??=`start`,!o&&V!==`center`&&(B=e.alignOffset??2,z=e.sideOffset??-5));let H=o,U=V;C.type===`menu`?(H??=`inline-end`,U??=`start`,te=e.collisionAvoidance??oC):C.type===`menubar`&&(H??=C.context.orientation===`vertical`?`inline-end`:`bottom`,U??=`start`);let ne=C.type===`context-menu`,re=tD({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:H,sideOffset:z,align:U,alignOffset:B,arrowPadding:ne?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:te,shift:ne?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});J.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Yb(ux)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),J.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,Yb(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ie=zy();J.useEffect(()=>{D||ie.clear()},[D,ie]),J.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?ie.isStarted()||ie.start(e,()=>{v.setOpen(!1,Yb(ux))}):v.setOpen(!1,Yb(ux))}else ie.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ie]),J.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),EN({store:v,domReference:R,positionerElement:M,open:D});let ae={open:D,side:re.side,align:re.align,anchorHidden:re.anchorHidden,nested:C.type===`menu`,instant:N},oe=C.type===`menubar`&&C.context.modal;ON(D&&(oe||O&&F!==`trigger-hover`),k===`touch`,M,A);let W=aD(e,ae,{styles:re.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),se=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),ce=null;return C.type===`menubar`?ce=C.context.contentElement:C.type===void 0&&(ce=A),(0,Y.jsxs)(GR.Provider,{value:re,children:[se&&(0,Y.jsx)(Dj,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:cD(!D),cutout:ce}),(0,Y.jsx)(xC,{id:I,children:(0,Y.jsx)(KO,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:W})})]})}),Pz=J.createContext(void 0);function Fz(){let e=J.useContext(Pz);if(e===void 0)throw Error(qv(34));return e}var Iz=J.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]=J.useState(void 0),[p,m]=UO({controlled:i,default:a,name:`MenuRadioGroup`}),h=Z((e,t)=>{o?.(e,t),!t.isCanceled&&m(e)}),g=_y(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=J.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return(0,Y.jsx)(mz.Provider,{value:f,children:(0,Y.jsx)(Pz.Provider,{value:_,children:g})})}),Lz=J.memo(J.forwardRef(function(e,t){let n=QR()?.RadioGroup??Iz;return(0,Y.jsx)(n,{...e,ref:t})})),Rz=J.createContext(void 0);function zz(){let e=J.useContext(Rz);if(e===void 0)throw Error(qv(35));return e}var Bz=J.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}=JR(),{value:p,setValue:m,disabled:h}=Fz(),g=sk({guess:!0,label:a}),_=FE(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}=sz({closeOnClick:c,disabled:S,highlighted:v,id:_,store:f,nativeButton:o,nodeId:y,itemMetadata:oz}),E=J.useMemo(()=>({disabled:S,highlighted:v,checked:C}),[S,v,C]);function D(e){let t=Yb(nx,e.nativeEvent,void 0,{preventUnmountOnClose:dy});m(l,t)}let O=_y(`div`,e,{state:E,stateAttributesMapping:uz,props:[b,{role:`menuitemradio`,"aria-checked":C,onClick:D},d,w],ref:[T,t,g.ref]});return(0,Y.jsx)(Rz.Provider,{value:E,children:O})}),Vz=J.forwardRef(function(e,t){let n=tz(e,t);return n.visible?(0,Y.jsx)(Bz,{...e,ref:n.ref}):null}),Hz=J.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=zz(),c=J.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=$C(s.checked);return iw({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),_y(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:uz,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),Uz=J.createContext(null);function Wz(e){let t=J.useContext(Uz);if(t===null&&!e)throw Error(qv(5));return t}function Gz(e){return e==null?Zb:e.type.startsWith(`key`)?sx:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?cx:Zb}var Kz={...Hw,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=Hw.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Zy&&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`&&!Hw.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 Nw{constructor(e,t,n=!1){let r=new bw,i=Yz(r,t,n,e);super(i,Jz(r),Kz),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 Jz(e){return{positionerRef:J.createRef(),popupRef:J.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:J.createRef(),beforeTriggerFocusGuardRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Yz(e,t,n=!1,r){return{...Iw(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:py,inputProps:py,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new hC,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:py,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Xz=J.createContext(null);function Zz(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Qz(e,t){return e===`list-navigation`||Zz(e,t)}var $z=Ny(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=XR(!0),C=JR(!0),w=Wz(!0),T=C?.store,E=C?.virtualFocus??!1,D=J.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=FE(),k=FE(),[A,j]=J.useState(void 0),M=(A??k)||void 0,N=vC(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=Ev(()=>F?P?.state.instantType:void 0).current,L=Ev(()=>{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=bC(R),z=L.useState(`open`),B=L.useState(`activeTriggerElement`),V=L.useState(`positionerElement`),te=L.useState(`hoverEnabled`),H=L.useState(`disabled`),U=L.useState(`lastOpenChangeReason`),ne=L.useState(`parent`),re=L.useState(`activeIndex`),ie=L.useState(`keyboardOpen`),ae=L.useState(`payload`),oe=L.useState(`floatingParentNodeId`),W=J.useRef(null),se=J.useRef(ne.type!==`context-menu`),ce=zy(),le=J.useRef(!0),ue=zy(),de=oe!=null,{openMethod:fe,triggerProps:pe}=Zj(z);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:ne.type===void 0?c:void 0,openMethod:fe,rootId:O}),gw(L);let{forceUnmount:me,transitionStatus:he}=_w(z,L,()=>{L.set(`allowMouseEnter`,!1)},F),ge=rw(L.context.popupRef);J.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!z){e();return}if(he!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return ge(e,t.signal),()=>{t.abort()}},[I,z,he,ge,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,B,L]),J.useEffect(()=>{z||(W.current=null),ne.type===`context-menu`&&(z?ce.start(500,()=>{se.current=!0}):(ce.clear(),se.current=!1))},[ce,z,ne.type]),Q(()=>{!z&&!te&&L.set(`hoverEnabled`,!0)},[z,te,L]);let _e=Z((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||z===e&&t.trigger===B&&U===n)return;let i=pw(t);if(!e&&t.trigger==null&&(t.trigger=B??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`&&!le.current)return;e&&n===`trigger-focus`?(le.current=!1,ue.start(300,()=>{le.current=!0})):(le.current=!0,ue.clear());let o=!e&&(n===`escape-key`||n==null);W.current=t.event;let s=fw(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Qz(n,a),s.instantType=ne.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:Zz(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),ve=QC({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:_e}),ye=ve.context.events;Q(()=>{let e=({open:e,eventDetails:t})=>_e(e,t);return ye.on(`setOpen`,e),()=>{ye?.off(`setOpen`,e)}},[ye,_e]),Q(()=>L.subscribeToParentMenu(),[L]);let be=J.useCallback(()=>{L.setOpen(!1,Yb(mx))},[L]);J.useImperativeHandle(d,()=>({unmount:me,close:be}),[me,be]);let xe;ne.type===`context-menu`&&(xe=ne.context),J.useImperativeHandle(xe?.positionerRef,()=>V,[V]),J.useImperativeHandle(xe?.actionsRef,()=>({setOpen:_e}),[_e]);let Se=zC(ve,{enabled:!H,bubbles:{escapeKey:f&&ne.type===`menu`},outsidePress(){return ne.type!==`context-menu`||W.current?.type===`contextmenu`||se.current},externalTree:de?R:void 0}),Ce=VE(),we=sT(ve,{enabled:!H,listRef:L.context.itemDomElements,activeIndex:re,virtual:v,nested:ne.type===`menubar`||!v&&ne.type!==void 0,parentOrientation:ne.type===`menubar`?ne.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?ie:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Ce===`rtl`,disabledIndices:fy,onNavigate(e,t){L.setActiveIndex(e,Gz(t),t?.nativeEvent)},openOnArrowKeyDown:ne.type!==`context-menu`&&!(v&&_),externalTree:!v&&de?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Te=J.useCallback(e=>{L.context.typingRef.current=e},[L]),Ee=cT(ve,{enabled:!H&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:re,resetMs:500,onMatch:(e,t)=>{z&&e!==re&&L.setActiveIndex(e,sx,t.nativeEvent)},onTyping:Te}),De=Z(a),Oe=J.useRef(-1),ke=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(Oe.current===n&&L.context.reportedItem===t)return;Oe.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Zb,L.context.highlightEvent=void 0,a&&De(t,Xb(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});Q(()=>{ke()},[re,ke]);let Ae=J.useMemo(()=>{if(!v)return we.reference;if(!we.trigger)return py;let{onFocus:e,...t}=we.trigger;return t},[v,we.reference,we.trigger]);L.useSyncedValue(`inputProps`,v?we.reference??py:py);let je=J.useMemo(()=>{let e=Nv(Ee.reference,Ae,Se.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},pe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=z,e},[L,Ee.reference,Ae,Se.reference,pe,z]),Me=J.useMemo(()=>{let e=Nv(we.trigger,Se.trigger,pe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[we.trigger,Se.trigger,pe]);Ev(()=>(L.update({inactiveTriggerProps:Me}),null)),vw(L,{floatingRootContext:ve,activeTriggerProps:je,inactiveTriggerProps:Me,popupProps:J.useMemo(()=>Nv(ow,{onMouseMove(){L.set(`allowMouseEnter`,!0),ne.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)}},Ee.floating,we.floating,Se.floating),[ne.type,L,Ee.floating,we.floating,Se.floating]),itemProps:we.item??py});let Ne=J.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:ke}),[L,D,u,l,b,k,v,E,ke]),Pe=typeof t==`function`?t({payload:ae}):t,Fe=(0,Y.jsxs)(qR.Provider,{value:Ne,children:[p&&(0,Y.jsx)(lw,{handle:p,store:L}),Pe]});return(ne.type===void 0||ne.type===`context-menu`)&&(Fe=(0,Y.jsx)(SC,{externalTree:R,children:Fe})),Fe});function eB(e){let t=J.useContext(Xz);if(t===null)return(0,Y.jsx)($z,{...e});let n=t.Root;return(0,Y.jsx)(Xz.Provider,{value:null,children:(0,Y.jsx)(n,{...t.options,...e})})}var tB=5;function nB(e,t){let n=rB(t);return e.clientX>=n.left-tB&&e.clientX<=n.right+tB&&e.clientY>=n.top-tB&&e.clientY<=n.bottom+tB}function rB(e){let t=e.getBoundingClientRect(),n=tv(e);if($y)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 iB(e){if(av(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!_v(e))return iB(bv(e))}function aB(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=J.useRef(!1);return J.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Zv(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:py,[t,n,r])}var oB=Py(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=JR(!0),h=Uw(d)??m?.store;if(!h)throw Error(qv(85));let g=FE(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=J.useRef(null),S=cB(),C=Yv(!0),w=yC(),T=J.useMemo(()=>w??new hC,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=hw(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:bC(T),floatingParentNodeId:vC(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=$v({disabled:A,native:o});J.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=J.useRef(null),P=zy(),F=Z(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;sb(N.current,t)||sb(h.select(`positionerElement`),t)||t===N.current||(t==null||iB(t)!==h.select(`rootId`))&&(nB(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:lx}))});J.useEffect(()=>{let e=Zv(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=eT(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:gT({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=sB(y,h.select(`lastOpenChangeReason`)),ee=NC(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Kw(v,{enabled:!A&&I}),B=aB({open:y,enabled:O,mouseDownAction:`open`}),V=J.useMemo(()=>Nv(z.reference,ee.reference),[z.reference,ee.reference]),te=h.useState(`triggerProps`,D),H=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:U,handleFocusTargetFocus:ne}=yN(h,x),re={disabled:A,open:y},ie=[N,t,M,E,x],ae=[V,L??py,te,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Zv(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},H,O?{role:`menuitem`}:{},B,p,j],oe=_y(`button`,e,{enabled:!O,stateAttributesMapping:Mb,state:re,ref:ie,props:ae});return O?(0,Y.jsx)(qM,{tag:`button`,render:n,className:r,style:i,state:re,refs:ie,props:ae,stateAttributesMapping:Mb}):y?(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(jx,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:U},`${g}-pre-focus-guard`),(0,Y.jsx)(J.Fragment,{children:oe},g),(0,Y.jsx)(jx,{ref:h.context.triggerFocusTargetRef,onFocus:ne},`${g}-post-focus-guard`)]}):(0,Y.jsx)(J.Fragment,{children:oe},g)});function sB(e,t){let n=zy(),[r,i]=J.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 cB(){let e=Wz(!0);return J.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var lB=J.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return _y(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function uB(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function dB(e){return uB(e?.[0])}function fB(e){return dB(e)?e.flatMap(e=>e.items):e}function pB(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(dB(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 mB(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 QP(e)}function hB(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?QP(e.value):QP(e)}function gB(e,t,n){function r(){return mB(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=fB(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 _B(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Y.jsx)(J.Fragment,{children:gB(r,t,n)},i)),e),[])}function vB({...e}){return(0,Y.jsx)(eB,{"data-slot":`dropdown-menu`,...e})}function yB({...e}){return(0,Y.jsx)(oB,{"data-slot":`dropdown-menu-trigger`,...e})}function bB({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,Y.jsx)(Mz,{children:(0,Y.jsx)(Nz,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,Y.jsx)(kz,{"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 xB({...e}){return(0,Y.jsx)(_z,{"data-slot":`dropdown-menu-group`,...e})}function SB({className:e,inset:t,...n}){return(0,Y.jsx)(vz,{"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 CB({className:e,inset:t,variant:n=`default`,...r}){return(0,Y.jsx)(bz,{"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 wB({className:e,children:t,checked:n,inset:r,...i}){return(0,Y.jsxs)(fz,{"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,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-checkbox-item-indicator`,children:(0,Y.jsx)(pz,{children:(0,Y.jsx)(ng,{})})}),t]})}function TB({...e}){return(0,Y.jsx)(Lz,{"data-slot":`dropdown-menu-radio-group`,...e})}function EB({className:e,children:t,inset:n,...r}){return(0,Y.jsxs)(Vz,{"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,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,Y.jsx)(Hz,{children:(0,Y.jsx)(ng,{})})}),t]})}function DB({className:e,...t}){return(0,Y.jsx)(lB,{"data-slot":`dropdown-menu-separator`,className:X(`-mx-1 my-1 h-px bg-border`,e),...t})}var OB=({option:e,noteId:t})=>(0,Y.jsxs)(EB,{value:e.id,disabled:!e.available,"aria-describedby":e.available?void 0:t,children:[e.modelName,!e.measured&&(0,Y.jsx)(`span`,{className:`rounded-full border px-1.5 text-caption text-muted-foreground`,children:`unmeasured`})]}),kB=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())},AB=({first:e,options:t,separated:n,noteId:r,choice:i})=>{let[a,o]=(0,J.useState)(``),s=zR(t,i.chosen,i.defaultId),c=t.length-s.length,l=BR(t,s,a);return(0,Y.jsxs)(xB,{children:[n&&(0,Y.jsx)(DB,{}),(0,Y.jsxs)(SB,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:e.available?e.via:e.providerName}),!e.available&&(0,Y.jsx)(`span`,{id:r,className:`font-normal`,children:e.reason})]}),s.map(e=>(0,Y.jsx)(OB,{option:e,noteId:r},e.id)),c>0&&(0,Y.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,Y.jsx)(jF,{value:a,onChange:e=>o(e.target.value),onKeyDown:kB,placeholder:`Filter ${c} more models`,"aria-label":`Filter ${c} more models through ${e.via}`,className:`h-7`})}),l.map(e=>(0,Y.jsx)(OB,{option:e,noteId:r},e.id)),c>0&&a.trim()!==``&&l.length===0&&(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,children:`No model matches`})]})},jB=({choice:e,disabled:t,variant:n,size:r=`sm`})=>{let i=(0,J.useId)();return(0,Y.jsxs)(vB,{children:[(0,Y.jsx)(yB,{render:(0,Y.jsx)($,{variant:n,size:r,"data-slot":`model-menu`,disabled:t,"aria-label":e.chosen===null?`Choose a model`:`Model: ${e.chosen.modelName}`,className:X(`rounded-l-none px-0`,r===`sm`?`w-6`:`w-7`,n==="default"&&`border-l-primary-foreground/30`,n===`outline`&&`border-l-0`,n.startsWith(`ai`)&&`border-l-primary/30`)}),children:(0,Y.jsx)(ig,{"aria-hidden":`true`})}),(0,Y.jsx)(bB,{align:`start`,className:`w-80`,children:(0,Y.jsx)(TB,{value:e.chosen?.id??null,onValueChange:t=>e.choose(t),children:RR(e.options).map(([t,n],r)=>(0,Y.jsx)(AB,{first:t,options:n,separated:r>0,noteId:`${i}-${r}`,choice:e},t.id))})})]})},MB={is:`idle`},NB=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`,PB=(e,t)=>{let[n,r]=(0,J.useState)(t);return(0,J.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))},FB=async({choice:e,run:t,now:n=Date.now,onPhase:r})=>{r({is:`running`,since:n()});let i=await t(e.chosen?.id);r(i.ok?{is:`done`,said:i.said}:{is:`failed`,...i})},IB=({choice:e,what:t=`Runs`})=>e.locked??(e.chosen===null?null:`${t} ${e.chosen.modelName} through ${e.chosen.via}`),LB=e=>{let t=(0,J.useId)(),{label:n,icon:r,choice:i,phase:a}=e,o=a.is===`running`,s=IB(e);return(0,Y.jsxs)(`span`,{"data-slot":`model-action`,className:`flex shrink-0 items-center`,children:[(0,Y.jsxs)(YL,{disabled:s===null,children:[(0,Y.jsxs)(XL,{render:(0,Y.jsx)($,{variant:`ai-quiet`,disabled:o||i.locked!==null||i.chosen===null,focusableWhenDisabled:!0,"aria-busy":o,"aria-describedby":s===null?void 0:`${t}-note`,onClick:()=>void FB(e),className:`rounded-r-none`}),children:[o?(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:oL}):i.locked===null?r:(0,Y.jsx)(e_,{"aria-hidden":`true`}),n]}),(0,Y.jsxs)(ZL,{side:`bottom`,align:`end`,children:[i.locked!==null&&(0,Y.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),s]})]}),(0,Y.jsx)(jB,{choice:i,disabled:o||i.options.length===0,variant:`ai-quiet`,size:`default`}),s!==null&&(0,Y.jsx)(`span`,{id:`${t}-note`,hidden:!0,children:s})]})},RB=e=>{let{running:t,now:n=Date.now,phase:r,className:i}=e,a=PB(r.is===`running`?r.since:null,n);return r.is===`idle`?null:(0,Y.jsx)(`p`,{role:r.is===`failed`?`alert`:`status`,"data-slot":`model-action-status`,className:X(`flex min-w-0 flex-wrap items-center gap-x-2 text-caption`,r.is===`failed`?`text-destructive`:`text-muted-foreground`,i),children:r.is===`running`?(0,Y.jsxs)(Y.Fragment,{children:[t,` `,(0,Y.jsx)(`span`,{className:`tabular`,children:NB(a)})]}):r.is===`done`?r.said:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),r.message]}),(0,Y.jsx)($,{variant:`link`,className:`h-6 min-w-6 px-1 text-caption`,onClick:()=>void FB(e),children:`Try again`})]})})},zB={"look-for":{label:`Look for`,icon:g_},"dont-flag":{label:`Don't flag`,icon:Qh}},BB=({kind:e,className:t})=>{let{label:n,icon:r}=zB[e];return(0,Y.jsxs)(`span`,{"data-slot":`preference-kind`,"data-kind":e,className:X(`inline-flex h-[22px] shrink-0 items-center gap-[5px] rounded-md border bg-secondary pr-2 pl-[7px] text-caption font-medium whitespace-nowrap text-secondary-foreground`,t),children:[(0,Y.jsx)(r,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`}),n]})},VB={kind:`global`},HB=({owner:e,repo:t})=>`${e}/${t}`,UB=({host:e,owner:t,repo:n})=>`${e}/${t}/${n}`,WB=e=>e.kind===`global`?`global`:UB(e.repo),GB=e=>[{key:WB(VB),label:`Everywhere`,scope:VB},...e.map(t=>{let n=e.some(e=>e!==t&&HB(e)===HB(t));return{key:UB(t),label:n?`${HB(t)} on ${iL[t.host]}`:HB(t),scope:{kind:`repo`,repo:t}}})],KB=({scope:e,className:t})=>e.kind===`global`?(0,Y.jsx)(Rg,{"aria-hidden":`true`,className:X(`size-[15px] shrink-0`,t)}):(0,Y.jsx)(WR,{host:e.repo.host,className:t}),qB=(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]}),JB=(e,t)=>({...e,preferences:e.preferences.filter(e=>e.id!==t)}),YB=(e,t)=>({...e,proposals:[...e.proposals,...t.filter(t=>!e.proposals.some(e=>e.id===t.id))]}),XB=(e,t)=>({...e,proposals:e.proposals.filter(e=>e.id!==t)}),ZB=(e,t,n,r)=>({...e,repositories:e.repositories.map(e=>hu(e.repo,t)&&e.guidelineFiles!==null?{...e,guidelineFiles:e.guidelineFiles.map(e=>e.path===n?{...e,enabled:r}:e)}:e)}),QB=(e,t)=>e.preferences.filter(e=>gu(e.scope,t)),$B=(e,t)=>e.proposals.filter(e=>gu(e.scope,t)),eV=(e,t)=>t.kind===`repo`&&QB(e,t).length===0&&$B(e,t).length===0,tV=`suggestions`,nV=(e,t)=>{if(e===`suggestions`)return{kind:`suggestions`};let n=t.find(t=>t.key===e)??t.find(e=>e.key===WB(VB))??t[0];return n===void 0?{kind:`suggestions`}:{kind:`scope`,option:n}},rV=(e,t)=>t.map(t=>({option:t,proposals:$B(e,t.scope)})).filter(e=>e.proposals.length>0),iV=new Intl.ListFormat(`en`,{type:`conjunction`}),aV=(e,t)=>{let n=t.map(t=>({label:t.label,count:e.filter(e=>gu(e.scope,t.scope)).length})).filter(e=>e.count>0),[r]=n;return n.length===1&&r!==void 0?`for ${r.label}`:iV.format(n.map(({count:e,label:t})=>`${e} for ${t}`))},oV=(e,t,n)=>{let r=[...e.comments>0?[`${fV(e.comments,`comment`)} from ${fV(e.pullRequests,`pull request`)}`]:[],...e.signals>0?[`${fV(e.signals,`action`)} recorded here`]:[]];if(r.length===0)return e.pullRequests===0?`Found nothing to suggest from: no comment of yours on its pull requests, and nothing you did here.`:`Found no comment of yours on its last ${fV(e.pullRequests,`pull request`)}, and nothing you did here.`;let i=`Read ${iV.format(r)}`;return t===0?`${i}: nothing new to suggest.`:`${i}: ${fV(t,`suggestion`)}, ${n}.`},sV=(e,t)=>({owner:t.some(t=>t.repo===e.repo&&!hu(t,e))?e.owner:null,name:e.repo}),cV=e=>{let t=[...e.repositories];for(let{scope:n}of[...e.preferences,...e.proposals])n.kind!==`repo`||t.some(e=>hu(e.repo,n.repo))||t.push({repo:n.repo,guidelineFiles:null,guidelineNote:`No pull request of this repository has been analyzed yet`});return t},lV=e=>{if(e<1024)return`${e} B`;let t=e/1024;return`${t<10?t.toFixed(1):Math.round(t)} KB`},uV=e=>{let t=e.trim();return t===``||/[.!?]$/.test(t)?t:`${t}.`},dV=e=>e.code===`bad-request`?uV(e.message):Gp(e),fV=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,pV=`megareviewer looks for ${new Intl.ListFormat(`en`,{type:`disjunction`}).format(ou)}.`,mV=({file:e,onSwitch:t})=>{let[n,r]=(0,J.useState)(null);return(0,Y.jsxs)(`li`,{"data-slot":`guideline-file`,className:`flex min-h-11 flex-wrap items-center gap-x-2.5 gap-y-1 px-4 py-2`,children:[(0,Y.jsx)(Sg,{"aria-hidden":`true`,className:`size-[15px] shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 font-mono text-code-compact break-all`,children:e.path}),(0,Y.jsx)(`span`,{className:`tabular shrink-0 text-caption text-muted-foreground`,children:lV(e.bytes)}),e.tooLarge?(0,Y.jsxs)(`span`,{className:`ml-auto text-caption text-muted-foreground`,children:[`Too large to send: a guideline file can be `,lV(cu)]}):(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,Y.jsx)(CF,{checked:e.enabled,"aria-label":`Use ${e.path} in AI reviews`,onCheckedChange:async n=>{r(null),r(await t(e.path,n))}}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`text-caption`,e.enabled?`text-foreground`:`text-muted-foreground`),children:e.enabled?`Followed by AI reviews`:`Ignored`})]}),n!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),n]})]})},hV=()=>{let e=(0,J.useId)();return(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-ui text-muted-foreground`,children:[`None found at the repository's root.`,(0,Y.jsxs)(YL,{children:[(0,Y.jsx)(XL,{render:(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Files megareviewer looks for`,"aria-describedby":e}),children:(0,Y.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5`})}),(0,Y.jsx)(ZL,{side:`right`,children:pV})]}),(0,Y.jsx)(`span`,{id:e,hidden:!0,children:pV})]})},gV=({files:e,note:t,onSwitch:n})=>e===null?(0,Y.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:uV(t??`Couldn't look for them`)}):e.length===0?(0,Y.jsx)(hV,{}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2.5 max-w-[620px] text-ui text-muted-foreground`,children:`At the repository root, read at each pull request's base commit. When a file is on, AI reviews follow it the same way as your preferences; when off, it is ignored.`}),(0,Y.jsx)(`ul`,{"data-slot":`guideline-files`,className:`divide-y overflow-hidden rounded-lg border bg-card`,children:e.map(e=>(0,Y.jsx)(mV,{file:e,onSwitch:n},e.path))})]});function _V(e){let t=J.useRef(!0);t.current&&(t.current=!1,e())}var vV=J.createContext(void 0),yV=J.createContext(void 0);function bV(){let e=J.useContext(vV);if(e===void 0)throw Error(qv(60));return e}function xV(){let e=J.useContext(yV);if(e===void 0)throw Error(qv(61));return e}function SV(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 CV=(e,t)=>Object.is(e,t);function wV(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function TV(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!SV(e,t,(e,t)=>wV(e,t,n)):e!==t}function EV(e,t,n){return e?e.some(e=>e!==void 0&&wV(t,e,n)):!1}function DV(e,t,n){return e?e.findIndex(e=>e!==void 0&&wV(e,t,n)):-1}function OV(e,t){if(t!==CV)return n=>EV(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 kV(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(OV(t,n)):DV(e,t,n);return i===-1?null:i}function AV(e,t,n,r,i,a){return EV(r,t,i)?a!=null&&e>a&&EV(r,n[a],i)?a:e:e===a?kV(n,r,i,!0):a}function jV(e,t,n){return e.filter(e=>!wV(t,e,n))}var MV={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:hB(t,r)!==``},hasNullItemLabel:(e,t)=>t?pB(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=>wV(t,e,n)):wV(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 NV(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=CV,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=rF(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=BP(),F=YP({id:t}),I=M||d,L=j??c,[R,ee]=UO({controlled:n,default:y?r??fy:r,name:`Select`,state:`value`}),[z,B]=UO({controlled:a,default:o,name:`Select`,state:`open`}),V=J.useRef([]),te=J.useRef([]),H=J.useRef(null),U=J.useRef(null),ne=J.useRef(0),re=J.useRef(null),ie=J.useRef([]),ae=J.useRef(!1),oe=J.useRef(null),W=J.useRef(null),se=J.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ce=J.useRef(!1),le=J.useRef(R),{openMethod:ue,triggerProps:de}=Zj(z),fe=Ev(()=>new Nw({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:py,triggerProps:py,itemRoot:{props:py,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:dy,setOpen:dy,handleScrollArrowVisibility:dy,onOpenChangeComplete:dy,listRef:V,popupRef:H,scrollHandlerRef:U,scrollArrowsMountedCountRef:ne,valueRef:re,valuesRef:ie,labelsRef:te,typingRef:ae,selectionRef:se,firstItemTextRef:oe,selectedItemTextRef:W,alignItemWithTriggerActiveRef:ce,initialValueRef:le},MV)).current,[pe,me]=J.useState(!1),{mounted:he,transitionStatus:ge,forceUnmount:_e}=aw({open:z,ref:H,preventUnmountOnClose:pe,setPreventUnmountOnClose:me,onUnmount(){fe.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),ve=fe.useState(`activeIndex`),ye=fe.useState(`selectedIndex`),be=fe.useState(`triggerElement`),xe=fe.useState(`positionerElement`),Se=lD(ue),Ce=ue??Se,we=J.useMemo(()=>y?``:hB(R,x),[y,R,x]),Te=J.useMemo(()=>y&&Array.isArray(R)?R.map(e=>hB(e,x)):hB(R,x),[y,R,x]);tF(Sx(be),F,R,Z(()=>Te),!I,c);let Ee=y?Array.isArray(R)&&R.length>0:R!=null&&we!==``;Q(()=>{A(Ee)},[Ee,A]),Q(function(){let e=kV(ie.current,R,S,y);e===null&&(W.current=null),!z&&fe.set(`selectedIndex`,e)},[y,z,R,S,fe]),Yj(R,()=>{T(L),E(TV(R,k.initialValue,S)),N.change(R)});let De=Z((e,t)=>{let n=t,r=pw(n);s?.(e,n),!t.isCanceled&&(e||me(r()),B(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))});J.useImperativeHandle(h,()=>({unmount:_e,close:()=>{fe.state.open&&De(!1,Yb(mx))}}),[_e,De,fe]);let Oe=Z((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),ke=Z(e=>{let t=nI(e.scrollHeight,e.clientHeight),n=rI(e.scrollTop,t),r=n>0,i=n<t;fe.set(`scrollUpArrowVisible`,r),fe.set(`scrollDownArrowVisible`,i)}),Ae=Ww({open:z,onOpenChange:De,elements:{reference:be,floating:xe}}),je=NC(Ae,{enabled:!I,event:`mousedown`}),Me=zC(Ae),Ne=sT(Ae,{enabled:!I,listRef:V,activeIndex:ve,selectedIndex:ye,disabledIndices:fy,onNavigate(e){(e!==null||z)&&fe.set(`activeIndex`,e)},focusItemOnHover:C}),Pe=cT(Ae,{enabled:!I&&(z||!f&&!y),listRef:te,activeIndex:ve,selectedIndex:ye,disabledIndices:e=>vk(V.current[e]),onMatch(e){z?fe.set(`activeIndex`,e):Oe(ie.current[e],Yb(Zb))},onTyping(e){ae.current=e}}),Fe=J.useMemo(()=>Nv(Pe.reference,Ne.reference,Me.reference,je.reference,de),[je.reference,Pe.reference,Ne.reference,Me.reference,de]),Ie=J.useMemo(()=>Nv(ow,Pe.floating,Ne.floating,Me.floating),[Pe.floating,Ne.floating,Me.floating]),Le=Ne.item??py,Re=J.useMemo(()=>({props:Le,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S}),[Le,y,I,f,S]);fe.useContextCallback(`setValue`,Oe),fe.useContextCallback(`setOpen`,De),fe.useContextCallback(`handleScrollArrowVisibility`,ke),fe.useContextCallback(`onOpenChangeComplete`,_),_V(()=>{fe.update({popupProps:Ie,triggerProps:Fe,itemRoot:Re})}),fe.useSyncedValues({id:F,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,value:R,open:z,mounted:he,transitionStatus:ge,popupProps:Ie,triggerProps:Fe,itemRoot:Re,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Ce});let ze=ny(g,N.inputRef),Be=y?void 0:L,Ve=J.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=hB(e,x);return(0,Y.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,Y.jsxs)(vV.Provider,{value:fe,children:[(0,Y.jsx)(yV.Provider,{value:Ae,children:w}),(0,Y.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){fe.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Yb(Zb,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ie.current.findIndex(t=>hB(t,x).toLowerCase()===e||mB(t,b).toLowerCase()===e);r===-1&&(r=ie.current.findIndex((t,n)=>{let r=te.current[n];return r!=null&&r.toLowerCase()===e}));let i=ie.current[r];i!=null&&Oe(i,n)}fe.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Be==null?`${F}-hidden-input`:void 0,form:l,name:Be,autoComplete:u,value:we,disabled:I,required:p&&!(y&&Ee),readOnly:f,ref:ze,style:L?Ax:kx,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ve]})}function PV(e,t){return e??t}var FV=`data-popup-side`,IV=400,LV={...Mb,...PP,popupSide:e=>e?{[FV]:e}:null,value:()=>null},RV=J.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}=BP(),{labelId:m}=GP(),h=bV(),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=PV(m,O);YP({id:i});let N=Sx(w),P=J.useRef(null),F=VP(y,P),{getButtonProps:I,buttonRef:L}=$v({disabled:y,native:o}),R=h.useStateSetter(`triggerElement`),ee=zy(),z=zy(),B=zy();J.useEffect(()=>{if(b)return B.start(IV,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{B.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[b,h,z,B]);let V=Nv(C,{id:j,role:`combobox`,"aria-expanded":b,"aria-haspopup":`listbox`,"aria-controls":b?T?.id??Ub(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,Yb(Zb,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){sb(w,e.relatedTarget)||(l(!0),F(!1),u===`onBlur`&&d.commit(S))},onMouseDown(e){if(b)return;let t=Zv(e.currentTarget);function n(e){if(!P.current)return;let t=e.target;sb(P.current,t)||sb(N.current,t)||nB(e,P.current)||h.context.setOpen(!1,Yb(lx,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),te=d.getValidationProps(y,V);te.role=`combobox`;let H={...f,open:b,disabled:y,value:S,readOnly:g,popupSide:A,placeholder:!k};return _y(`button`,e,{ref:[t,P,L,R],state:H,stateAttributesMapping:LV,props:te})}),zV={value:()=>null},BV=J.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=bV(),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)?_B(l,u,d):gB(l,u,d)),_y(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:zV})}),VV=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return _y(`span`,e,{state:{open:bV().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:jb})}),HV=J.forwardRef(function(e,t){let n=bV(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Y.jsx)(pC,{ref:t,...e}):null}),UV=J.createContext(void 0);function WV(){let e=J.useContext(UV);if(!e)throw Error(qv(59));return e}function GV(e,t){e&&Object.assign(e.style,t)}var KV={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},qV={position:`fixed`},JV=J.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=aC,style:_,...v}=e,y=bV(),b=xV(),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=J.useRef(null),j=J.useRef(null),[M,N]=J.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),J.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),ON((P||C)&&x,T===`touch`,E,D);let F=tD({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?qV:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};Q(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=aD(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=J.useRef(0),B=Z(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=Yb(Zb);if(t!==0&&!y.state.multiple&&w!==null&&DV(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&DV(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=>DV(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:``};GV(E,e),GV(y.context.popupRef.current,e)}}),V=J.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,Y.jsx)(KO,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:B,children:(0,Y.jsxs)(UV.Provider,{value:V,children:[S&&C&&(0,Y.jsx)(Dj,{inert:cD(!x),cutout:D}),ee]})})}),YV=`--transform-origin`,XV={...Nb,...bb},ZV=J.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=bV(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=xV(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=WV(),_=XM(!0)!=null,v=VE(),{nonce:y,disableStyleElements:b}=mk(),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=J.useRef(!1),j=J.useRef(!1),M=J.useRef({}),N=Dx(),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=eH(O),i=tH(O.getBoundingClientRect().height,`y`,r),a=Zv(O),o=tv(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=QV(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=$V(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=eI(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=eI(g,0,$V(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});J.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),iw({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,GV(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(YV),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=iH(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=tv(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=Zv(D),c=eH(D),l=nH(D.getBoundingClientRect(),c),d=nH(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=QV(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=nH(n.getBoundingClientRect(),c);T=nH(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=`${eI(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=$V(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),B=(r.visualViewport?.scale??1)!==1&&Zy;if(z||B){GV(O,M.current),g(!1);return}let V=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=$V(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=eI(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(YV,`50% ${i}%`)}(V===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]),J.useEffect(()=>{if(!m||!O||!S)return;let e=tv(O);function t(e){s.context.setOpen(!1,Yb(hx,e))}return bx(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){_&&Ck.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:KV},className:!k&&m?IF.className:void 0},L=_y(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:XV,props:[T,I,iD(E),o]});return(0,Y.jsxs)(J.Fragment,{children:[!b&&IF.getElement(y),(0,Y.jsx)(MC,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function QV(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function $V(e){return nI(e.scrollHeight,e.clientHeight)}function eH(e){return $T.getScale(e)}function tH(e,t,n){return e/n[t]}function nH(e,t){return iS({x:tH(e.x,`x`,t),y:tH(e.y,`y`,t),width:tH(e.width,`x`,t),height:tH(e.height,`y`,t)})}var rH=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function iH(e){let{style:t}=e,n={};for(let[e,r]of rH)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of rH){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var aH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=bV(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=WV(),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:KV},className:u&&d!==`touch`?IF.className:void 0};return _y(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),oH=J.createContext(void 0);function sH(){let e=J.useContext(oH);if(!e)throw Error(qv(57));return e}var cH=J.memo(J.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=J.useRef(null),d=sk({guess:!0,label:o,textRef:u}),f=bV(),{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=J.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=AV(C,a,f.context.valuesRef.current,e,_,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&wV(a,e,_),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,_,f,a]);let T=J.useRef(`mouse`),E=J.useRef(!1),{getButtonProps:D,buttonRef:O}=$v({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?jV(n,a,_):[...n,a];f.context.setValue(r,Yb(nx,e))}else f.context.setValue(a,Yb(nx,e)),f.context.setOpen(!1,Yb(nx,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&&nb(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=_y(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=J.useMemo(()=>({selected:x,index:C,textRef:u,selectedByFocus:S}),[x,C,u,S]);return(0,Y.jsx)(oH.Provider,{value:P,children:N})})),lH=J.memo(J.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=J.useRef(null),{transitionStatus:l,setMounted:u}=$C(o),d=_y(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:bb});return iw({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),uH=J.forwardRef(function(e,t){let{selected:n}=sH();return e.keepMounted||n?(0,Y.jsx)(lH,{...e,selected:n,ref:t}):null}),dH=J.memo(J.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=sH(),a=bV(),{render:o,className:s,style:c,...l}=e;return _y(`div`,e,{ref:[J.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),fH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=bV(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=WV(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=zy(),v=c?f:d,{mounted:y,transitionStatus:b,setMounted:x}=$C(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]),iw({open:g,ref:v,onComplete(){g||x(!1)}});let S=_y(`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=nI(e.scrollHeight,e.clientHeight),r=rI(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=pH(a,c,r,e.clientHeight,t,n)}_.start(40,t)}}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:bb});return y||o?S:null});function pH(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?rI(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?rI(l.offsetTop+l.offsetHeight-r+i,a):a}var mH=J.forwardRef(function(e,t){return(0,Y.jsx)(fH,{...e,ref:t,direction:`down`})}),hH=J.forwardRef(function(e,t){return(0,Y.jsx)(fH,{...e,ref:t,direction:`up`})}),gH=J.createContext(void 0);function _H(){let e=J.useContext(gH);if(e===void 0)throw Error(qv(56));return e}var vH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=J.useState(),c=J.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=_y(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,Y.jsx)(gH.Provider,{value:c,children:l})}),yH=J.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=_H(),c=FE(a);return Q(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),_y(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),bH=NV;function xH({className:e,...t}){return(0,Y.jsx)(vH,{"data-slot":`select-group`,className:X(`scroll-my-1 p-1`,e),...t})}function SH({className:e,...t}){return(0,Y.jsx)(BV,{"data-slot":`select-value`,className:X(`flex flex-1 text-left`,e),...t})}function CH({className:e,size:t=`default`,children:n,...r}){return(0,Y.jsxs)(RV,{"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,Y.jsx)(VV,{render:(0,Y.jsx)(ig,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function wH({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,Y.jsx)(HV,{children:(0,Y.jsx)(JV,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,Y.jsxs)(ZV,{"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,Y.jsx)(DH,{}),(0,Y.jsx)(aH,{children:t}),(0,Y.jsx)(OH,{})]})})})}function TH({className:e,...t}){return(0,Y.jsx)(yH,{"data-slot":`select-label`,className:X(`px-1.5 py-1 text-caption text-muted-foreground`,e),...t})}function EH({className:e,children:t,...n}){return(0,Y.jsxs)(cH,{"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,Y.jsx)(dH,{className:`flex flex-1 shrink-0 gap-2 whitespace-nowrap`,children:t}),(0,Y.jsx)(uH,{render:(0,Y.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,Y.jsx)(ng,{className:`pointer-events-none`})})]})}function DH({className:e,...t}){return(0,Y.jsx)(hH,{"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,Y.jsx)(ug,{})})}function OH({className:e,...t}){return(0,Y.jsx)(mH,{"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,Y.jsx)(ig,{})})}var kH=e=>{let t=(0,J.useRef)(null),n=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{e?n.current=!0:n.current&&(n.current=!1,t.current?.focus())},[e]),t},AH=`Write the rule first.`,jH=e=>`${e} ${e===1?`character`:`characters`} over the limit. Keep it to one rule; add another preference for the rest.`,MH=[`look-for`,`dont-flag`],NH={"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 not flag`,example:`Naming`}},PH=({option:e})=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(KB,{scope:e.scope,className:`size-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]}),FH=({legend:e,initial:t,scopes:n,kindFixed:r=!1,inline:i=!1,submit:a,submitting:o,submitIcon:s,focus:c=!1,onSubmit:l,onCancel:u})=>{let d=(0,J.useId)(),[f,p]=(0,J.useState)(t.kind),[m,h]=(0,J.useState)(t.text),[g,_]=(0,J.useState)(WB(t.scope)),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(null),S=(0,J.useRef)(null);(0,J.useEffect)(()=>{c&&S.current!==null&&(S.current.focus(),S.current.setSelectionRange(S.current.value.length,S.current.value.length))},[]);let C=i?{key:WB(t.scope),label:``,scope:t.scope}:n.find(e=>e.key===g)??n[0],w=m.trim().length,T=w-300,E=b??(T>0?jH(T):null),D=w>=250,O=async e=>{if(e.preventDefault(),v||C===void 0||T>0)return;if(w===0){x(AH),S.current?.focus();return}y(!0),x(null);let t=await l({kind:f,text:m.trim(),scope:C.scope});y(!1),x(t),t===null&&h(``)},k=r?(0,Y.jsx)(BB,{kind:f}):(0,Y.jsx)(lF,{"aria-label":`Kind`,value:f,onValueChange:e=>{(e===`look-for`||e===`dont-flag`)&&p(e)},className:`inline-flex w-auto shrink-0 gap-0.5 rounded-md border border-input p-px`,children:MH.map(e=>{let{label:t,icon:n}=zB[e];return(0,Y.jsxs)(uF,{value:e,children:[(0,Y.jsx)(n,{"aria-hidden":`true`}),t]},e)})}),A=(0,Y.jsx)(`label`,{htmlFor:`${d}-text`,className:i?`sr-only`:`text-ui font-medium`,children:NH[f].label}),j=(0,Y.jsx)(Vk,{ref:S,id:`${d}-text`,rows:1,className:X(`resize-none bg-card text-body aria-invalid:focus-visible:outline-destructive`,i?`min-h-8 min-w-0 flex-1 basis-60 py-1`:`min-h-[72px]`),placeholder:NH[f].example,value:m,onChange:e=>{h(e.target.value.replace(/\s*\n\s*/g,` `)),x(null)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"aria-invalid":E!==null,"aria-describedby":D?`${d}-count ${d}-problem`:`${d}-problem`}),M=(0,Y.jsx)(`p`,{id:`${d}-problem`,role:`status`,className:`flex min-w-0 flex-1 basis-60 items-start gap-1.5 text-caption text-destructive`,children:E!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fg,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),E]})}),N=D&&(0,Y.jsxs)(`span`,{id:`${d}-count`,"data-slot":`character-count`,className:X(`tabular shrink-0 text-caption`,T>0?`font-medium text-destructive`:`text-muted-foreground`),children:[w,`/`,300,(0,Y.jsx)(`span`,{className:`sr-only`,children:` characters`})]}),P=(0,Y.jsxs)(Y.Fragment,{children:[u!==void 0&&(0,Y.jsx)($,{type:`button`,variant:`ghost`,onClick:u,children:`Cancel`}),(0,Y.jsxs)($,{type:`submit`,className:`shrink-0`,disabled:v||T>0,focusableWhenDisabled:!0,"aria-busy":v,"aria-describedby":T>0?`${d}-problem`:void 0,children:[s,v?o:a]})]});return(0,Y.jsx)(`form`,{"aria-label":e,"data-slot":`preference-form`,className:X(`flex flex-col`,!i&&`gap-3`),onSubmit:e=>void O(e),noValidate:!0,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[k,A,j,P]}),(0,Y.jsxs)(`div`,{className:X(`flex items-start justify-end gap-3`,(E!==null||D)&&`mt-1.5`),children:[M,N]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2`,children:[k,(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{id:`${d}-scope`,className:`shrink-0 text-ui text-muted-foreground`,children:`Applies to`}),C===void 0?null:n.length>1?(0,Y.jsxs)(bH,{value:C.key,items:n.map(e=>({value:e.key,label:e.label})),onValueChange:e=>{typeof e==`string`&&_(e)},children:[(0,Y.jsx)(CH,{className:`max-w-80 min-w-0`,"aria-labelledby":`${d}-scope`,children:(0,Y.jsx)(SH,{children:()=>(0,Y.jsx)(PH,{option:C})})}),(0,Y.jsx)(wH,{alignItemWithTrigger:!1,align:`start`,children:n.map(e=>(0,Y.jsx)(EH,{value:e.key,label:e.label,children:(0,Y.jsx)(PH,{option:e})},e.key))})]}):(0,Y.jsx)(PH,{option:C})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,j]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-2`,children:[M,N,P]})]})})},IH=({title:e,onClose:t,children:n,className:r,returnFocus:i=()=>!0})=>{let a=(0,J.useRef)(null);return(0,Y.jsx)(Qj,{open:!0,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(tM,{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,Y.jsx)(nM,{className:`shrink-0 pr-8`,children:(0,Y.jsx)(rM,{children:e})}),n]})})},LH=({preference:e,onDelete:t,onClose:n})=>{let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(null);return(0,Y.jsxs)(IH,{title:`Delete preference`,onClose:n,children:[(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(BB,{kind:e.kind}),(0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}),(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:n,children:`Cancel`}),(0,Y.jsx)($,{variant:`destructive`,disabled:r,onClick:async()=>{i(!0);let e=await t();i(!1),o(e),e===null&&n()},children:r?`Deleting…`:`Delete`})]})]})},RH=({preference:e,scopes:t,actions:n})=>{let[r,i]=(0,J.useState)(`shown`),[a,o]=(0,J.useState)(null),s=kH(r===`editing`),{id:c,kind:l,text:u,source:d,enabled:f}=e;return r===`editing`?(0,Y.jsx)(`li`,{className:`px-4 py-3`,children:(0,Y.jsx)(FH,{legend:`Edit: ${u}`,initial:e,scopes:t,submit:`Save`,submitting:`Saving…`,focus:!0,onCancel:()=>i(`shown`),onSubmit:async e=>{let t=await n.onEdit(c,e);return t===null&&i(`shown`),t}})}):(0,Y.jsxs)(`li`,{"data-slot":`preference`,"data-enabled":f,className:`flex flex-wrap items-start gap-x-3 gap-y-1 px-4 py-2.5`,children:[(0,Y.jsx)(BB,{kind:l,className:`min-w-[98px]`}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-56 text-body break-words`,!f&&`text-muted-foreground`),children:u}),(0,Y.jsxs)(`span`,{className:`-my-[3px] ml-auto flex shrink-0 items-center gap-2`,children:[d!==`written`&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3 text-primary`}),`From your reviews`]}),!f&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`off`}),(0,Y.jsx)(CF,{checked:f,"aria-label":`Use in AI reviews: ${u}`,onCheckedChange:async e=>{o(null),o(await n.onSwitch(c,e))}}),(0,Y.jsxs)(`span`,{className:`flex gap-0.5`,children:[(0,Y.jsx)($,{ref:s,variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Edit: ${u}`,onClick:()=>i(`editing`),children:(0,Y.jsx)(o_,{"aria-hidden":`true`,className:`size-3.5`})}),(0,Y.jsx)($,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Delete: ${u}`,onClick:()=>i(`deleting`),children:(0,Y.jsx)(A_,{"aria-hidden":`true`,className:`size-3.5`})})]})]}),a!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),a]}),r===`deleting`&&(0,Y.jsx)(LH,{preference:e,onDelete:()=>n.onDelete(c),onClose:()=>i(`shown`)})]})},zH=({preferences:e,scopes:t,actions:n,label:r})=>(0,Y.jsx)(`ul`,{"aria-label":r,className:`divide-y overflow-hidden rounded-lg border bg-card`,children:e.map(e=>(0,Y.jsx)(RH,{preference:e,scopes:t,actions:n},e.id))}),BH=({proposal:e,scopes:t,actions:n})=>{let{id:r,kind:i,text:a,evidence:o}=e,[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),p=async e=>{if(l!==null)return;if(e===`accept`&&a.length>300)return c(!0);u(e),f(null);let t=await(e===`accept`?n.onAccept(r,null):n.onReject(r));u(null),f(t)};return s?(0,Y.jsx)(`li`,{className:`bg-card px-4 py-3`,children:(0,Y.jsx)(FH,{legend:`Cut the suggestion to fit: ${a}`,initial:e,scopes:t,submit:`Add`,submitting:`Adding…`,submitIcon:(0,Y.jsx)(ng,{"aria-hidden":`true`}),focus:!0,onCancel:()=>c(!1),onSubmit:e=>n.onAccept(r,e)})}):(0,Y.jsxs)(`li`,{"data-slot":`proposal`,className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-4 py-2.5`,children:[(0,Y.jsx)(BB,{kind:i,className:`min-w-[98px]`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,Y.jsx)(`p`,{className:`text-body break-words`,children:a}),o.length>0&&(0,Y.jsx)(`ul`,{"aria-label":`Based on`,className:`flex flex-col text-caption text-muted-foreground`,children:[...new Set(o)].map(e=>(0,Y.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsxs)($,{variant:`ai-quiet`,size:`sm`,"aria-label":`Add suggestion: ${a}`,"aria-busy":l===`accept`,onClick:()=>void p(`accept`),children:[(0,Y.jsx)(ng,{"aria-hidden":`true`}),l===`accept`?`Adding…`:`Add`]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,className:`text-muted-foreground`,"aria-label":`Dismiss suggestion: ${a}`,"aria-busy":l===`reject`,onClick:()=>void p(`reject`),children:l===`reject`?`Dismissing…`:`Dismiss`})]}),d!==null&&(0,Y.jsxs)(`p`,{role:`alert`,className:`basis-full text-caption text-destructive`,children:[(0,Y.jsx)(M_,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px]`}),d]})]})},VH=({proposals:e,scopes:t,actions:n,label:r,fallbackFocus:i})=>{let a=(0,J.useRef)(null),o=()=>(e.length>1?a.current:i.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(0,Y.jsx)(`ul`,{ref:a,tabIndex:-1,"aria-label":r,"data-slot":`suggestions`,className:`divide-y divide-ai-soft-bd overflow-hidden rounded-lg border border-ai-soft-bd bg-ai-soft`,children:e.map(e=>(0,Y.jsx)(BH,{proposal:e,scopes:t,actions:c},e.id))})},HH=({context:e,title:t,host:n,word:r,actions:i})=>(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start gap-x-4 gap-y-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`h2`,{ref:e.heading,id:e.headingId,tabIndex:-1,className:`text-[1.125rem] leading-[1.625rem] font-semibold [overflow-wrap:anywhere]`,children:t}),n!==void 0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,Y.jsx)(WR,{host:n,className:`size-3`}),iL[n]]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-ui text-muted-foreground`,children:r})]}),i]}),UH=({title:e,count:t=0,icon:n,children:r})=>{let i=(0,J.useId)();return(0,Y.jsxs)(`section`,{"aria-labelledby":i,className:`mt-7`,children:[(0,Y.jsxs)(`h3`,{id:i,className:`mb-2 flex items-center gap-1.5 text-caption font-semibold text-muted-foreground`,children:[n,e,t>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{className:`tabular font-medium`,children:t})]})]}),r]})},WH=({context:e,option:t,title:n=`Suggestions from your reviews`,icon:r})=>{let i=$B(e.view,t.scope);return i.length===0?null:(0,Y.jsx)(UH,{title:n,count:i.length,icon:r,children:(0,Y.jsx)(VH,{proposals:i,scopes:e.scopes,actions:e.proposals,label:`Suggestions for ${t.label}`,fallbackFocus:e.heading})})},GH=({context:e,option:t})=>{let n=QB(e.view,t.scope);return n.length===0?null:(0,Y.jsx)(UH,{title:`Preferences`,count:n.length,children:(0,Y.jsx)(zH,{preferences:n,scopes:e.scopes,actions:e.actions,label:`Preferences for ${t.label}`})})},KH=({context:e,option:t})=>(0,Y.jsx)(UH,{title:`Add a preference`,children:(0,Y.jsx)(FH,{legend:`Add a preference`,initial:{kind:`look-for`,text:``,scope:t.scope},scopes:e.scopes,inline:!0,submit:`Add preference`,submitting:`Adding…`,submitIcon:(0,Y.jsx)(c_,{"aria-hidden":`true`}),onSubmit:e.add},t.key)}),qH=({where:e})=>(0,Y.jsxs)(`p`,{className:`mt-5 text-ui text-muted-foreground`,children:[`No preferences for `,e,` yet.`]}),JH=({context:e,option:t})=>{let n=QB(e.view,t.scope).length===0&&$B(e.view,t.scope).length===0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HH,{context:e,title:`Everywhere`,word:`Used on every pull request, in every repository.`}),(0,Y.jsx)(WH,{context:e,option:t}),(0,Y.jsx)(GH,{context:e,option:t}),n&&(0,Y.jsx)(qH,{where:`every repository`}),(0,Y.jsx)(KH,{context:e,option:t})]})},YH=({context:e,option:t,repository:n})=>{let{repo:r,guidelineFiles:i,guidelineNote:a}=n,o=e.suggest(r);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HH,{context:e,title:HB(r),host:r.host,word:`Used on its pull requests, after the ones for Everywhere.`,actions:(0,Y.jsx)(LB,{...o})}),(0,Y.jsx)(RB,{...o,className:`mt-2`}),(0,Y.jsx)(WH,{context:e,option:t}),(0,Y.jsx)(GH,{context:e,option:t}),eV(e.view,t.scope)&&(0,Y.jsx)(qH,{where:`this repository`}),(0,Y.jsx)(KH,{context:e,option:t}),(0,Y.jsx)(UH,{title:`Guideline files`,children:(0,Y.jsx)(gV,{files:i,note:a,onSwitch:(t,n)=>e.switchGuideline(r,t,n)})})]})},XH=({context:e})=>{let t=rV(e.view,e.scopes);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HH,{context:e,title:`Suggestions`,word:`From the points you raised or dismissed and the comments you posted. Add one to make it a preference where shown.`}),t.length===0?(0,Y.jsx)(`p`,{className:`mt-5 max-w-[620px] text-ui text-muted-foreground`,children:`No suggestions yet. Suggest from my reviews, on a repository's panel, proposes rules from what you did on its pull requests and your comments on them.`}):t.map(({option:t})=>(0,Y.jsx)(WH,{context:e,option:t,title:t.label,icon:(0,Y.jsx)(KB,{scope:t.scope,className:`size-3.5`})},t.key))]})},ZH=e=>fV(e,`preference`),QH=e=>`${e} waiting`,$H=({full:e,count:t,counted:n})=>t>0?`${e}, ${n}`:e,eU=({entry:e})=>{let t=(0,J.useRef)(null),[n,r]=(0,J.useState)(e.name);return(0,J.useLayoutEffect)(()=>{let n=t.current;if(n!==null&&e.repo)return OF(n,()=>{let t=n.firstElementChild,i=n.lastElementChild;if(n.clientWidth===0||i===null)return;let a=n.clientWidth-(t===null||t===i?0:DF(t,t.textContent??``)??0);r(kI(e.name,e=>(DF(i,e)??0)<=a+.5))})},[e.name,e.repo]),(0,Y.jsxs)(`span`,{ref:t,"aria-hidden":`true`,className:`min-w-0 flex-1 truncate text-left`,children:[e.owner!==null&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.owner,`/`]}),(0,Y.jsx)(`span`,{children:n})]})},tU=({entry:e})=>e.count>0?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`tabular shrink-0 text-caption`,e.ai?`font-medium text-primary in-data-highlighted:text-accent-foreground`:`text-muted-foreground`),children:e.count}):null,nU=({entry:e,current:t,onSelect:n})=>{let r=(0,Y.jsxs)(`button`,{type:`button`,"aria-current":e.key===t?`page`:void 0,"aria-label":$H(e),onClick:()=>n(e.key),className:X(`relative flex h-[34px] w-full items-center gap-2 rounded-md px-2.5 text-ui hover:bg-surface-row [&_svg]:text-muted-foreground`,`aria-[current=page]:bg-secondary aria-[current=page]:font-medium aria-[current=page]:before:absolute aria-[current=page]:before:inset-y-[7px] aria-[current=page]:before:left-0 aria-[current=page]:before:w-0.5 aria-[current=page]:before:rounded-full aria-[current=page]:before:bg-primary`,e.ai&&`[&_svg]:text-primary`),children:[e.icon,(0,Y.jsx)(eU,{entry:e}),(0,Y.jsx)(tU,{entry:e})]});return(0,Y.jsx)(`li`,{children:e.repo?(0,Y.jsxs)(YL,{children:[(0,Y.jsx)(XL,{delay:500,render:r}),(0,Y.jsx)(ZL,{side:`right`,sideOffset:8,children:e.full})]}):r})},rU=({id:e,children:t})=>(0,Y.jsx)(`p`,{id:e,className:`mt-4 mb-1 px-2.5 text-caption font-medium text-muted-foreground`,children:t}),iU=({entries:e,current:t,onSelect:n,className:r})=>{let i=(0,J.useId)();return(0,Y.jsxs)(`nav`,{"aria-label":`Scopes`,className:r,children:[(0,Y.jsxs)(`ul`,{children:[(0,Y.jsx)(nU,{entry:e.suggestions,current:t,onSelect:n}),(0,Y.jsx)(nU,{entry:e.everywhere,current:t,onSelect:n})]}),e.repositories.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(rU,{id:`${i}-repositories`,children:`Repositories`}),(0,Y.jsx)(`ul`,{"aria-labelledby":`${i}-repositories`,children:e.repositories.map(e=>(0,Y.jsx)(nU,{entry:e,current:t,onSelect:n},e.key))})]})]})},aU=({entry:e})=>(0,Y.jsxs)(EH,{value:e.key,label:e.full,"aria-label":$H(e),className:`h-[34px] gap-2 pl-2.5 data-selected:font-medium [&_svg]:text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:X(`flex`,e.ai&&`[&_svg]:text-primary`),children:e.icon}),(0,Y.jsx)(eU,{entry:e}),(0,Y.jsx)(tU,{entry:e})]}),oU=({entries:e,current:t,onSelect:n,className:r})=>{let i=(0,J.useId)(),a=[e.suggestions,e.everywhere,...e.repositories],o=a.find(e=>e.key===t)??e.everywhere;return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5`,r),children:[(0,Y.jsx)(`span`,{id:`${i}-label`,className:`text-caption font-medium text-muted-foreground`,children:`Scope`}),(0,Y.jsxs)(bH,{value:o.key,items:a.map(e=>({value:e.key,label:e.full})),onValueChange:e=>{typeof e==`string`&&n(e)},children:[(0,Y.jsx)(CH,{"aria-labelledby":`${i}-label`,className:`h-10 w-full max-w-[440px] gap-2 rounded-lg px-3 text-body font-medium data-popup-open:border-ring data-popup-open:ring-3 data-popup-open:ring-ring/20 [&_svg]:text-muted-foreground`,children:(0,Y.jsx)(SH,{children:()=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:X(`flex`,o.ai&&`[&_svg]:text-primary`),children:o.icon}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.full}),(0,Y.jsx)(tU,{entry:o})]})})}),(0,Y.jsxs)(wH,{alignItemWithTrigger:!1,align:`start`,sideOffset:6,children:[(0,Y.jsxs)(xH,{children:[(0,Y.jsx)(aU,{entry:e.suggestions}),(0,Y.jsx)(aU,{entry:e.everywhere})]}),e.repositories.length>0&&(0,Y.jsxs)(xH,{children:[(0,Y.jsx)(TH,{children:`Repositories`}),e.repositories.map(e=>(0,Y.jsx)(aU,{entry:e},e.key))]})]})]})]})},sU=()=>(0,Y.jsxs)(`div`,{role:`status`,"aria-busy":`true`,"aria-label":`Loading your preferences`,className:`lg:grid lg:grid-cols-[240px_minmax(0,1fr)] lg:items-start lg:gap-10`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`hidden flex-col gap-2 lg:flex`,children:[28,20,32,24].map(e=>(0,Y.jsx)(pF,{className:`h-[34px] motion-reduce:animate-none`,style:{width:`${e*7}px`}},e))}),(0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`flex flex-col gap-3`,children:[(0,Y.jsx)(pF,{className:`h-10 w-full max-w-[440px] motion-reduce:animate-none lg:hidden`}),(0,Y.jsx)(pF,{className:`h-6 w-56 motion-reduce:animate-none`}),(0,Y.jsx)(pF,{className:`h-4 w-80 max-w-full motion-reduce:animate-none`}),(0,Y.jsx)(`div`,{className:`mt-5 flex flex-col gap-3 rounded-lg border bg-card px-4 py-3`,children:[1,2].map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(pF,{className:`h-[22px] w-24 motion-reduce:animate-none`}),(0,Y.jsx)(pF,{className:`h-4 flex-1 motion-reduce:animate-none`})]},e))})]})]}),cU=({now:e=Date.now,startOn:t})=>{let{client:n}=Pp(),r=HR(yL().status?.model??null),i=Bp(),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null);i.preferences!==a&&(o(i.preferences),c(i.preferences));let[l,u]=(0,J.useState)(new Map),[d,f]=(0,J.useState)(``),p=(0,J.useRef)(null),m=(0,J.useId)(),h=B_(J_()),[g,_]=(0,J.useState)(t??null),v=t===void 0?h:g,y=(0,J.useRef)(!1);(0,J.useEffect)(()=>{y.current&&(y.current=!1,p.current?.focus())},[v]);let b=e=>{y.current=!0,t===void 0?Y_(z_(e===WB(VB)?null:e)):_(e)},x=e=>c(t=>t===null?t:e(t)),S=(e,t,n)=>e.ok?(x(n=>t(n,e.value)),f(n),null):dV(e.error),C=async e=>S(await n.addPreference(e),qB,`Added: ${e.text}`),w={onSwitch:async(e,t)=>S(await n.updatePreference(e,{enabled:t}),qB,t?`Switched on`:`Switched off`),onEdit:async(e,t)=>S(await n.updatePreference(e,t),qB,`Saved: ${t.text}`),onDelete:async e=>S(await n.deletePreference(e),t=>JB(t,e),`Deleted`)},T={onAccept:async(e,t)=>S(await n.decideProposal(e,{decision:`accept`,...t}),(t,{preference:n})=>{let r=XB(t,e);return n===null?r:qB(r,n)},`Added to your preferences`),onReject:async e=>S(await n.decideProposal(e,{decision:`reject`}),t=>XB(t,e),`Dismissed`)},E=async(e,t,r)=>S(await n.setGuidelineSwitch({repo:e,path:t,enabled:r}),n=>ZB(n,e,t,r),r?`${t} switched on`:`${t} switched off`),D=t=>({phase:l.get(t)??MB,onPhase:e=>u(n=>new Map(n).set(t,e)),choice:r,now:e});return(0,Y.jsxs)(`div`,{"data-slot":`preferences-page`,className:`mx-auto w-full max-w-[1088px] pb-12 lg:pt-5`,children:[(0,Y.jsxs)(`header`,{className:`mb-6 flex flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{className:`text-[1.5rem] leading-8 font-semibold tracking-[-0.018em]`,children:`Preferences`}),(0,Y.jsx)(`p`,{className:`text-body text-muted-foreground`,children:`What you want an AI review to look for and to leave out. Used by Request AI review.`})]}),(()=>{if(s===null)return i.loading||i.error===null?(0,Y.jsx)(sU,{}):(0,Y.jsxs)(`div`,{className:X(dF,`flex flex-wrap items-center justify-between gap-2`),role:`alert`,children:[(0,Y.jsxs)(`p`,{children:[`Couldn't read your preferences. `,Gp(i.error)]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:i.refresh,children:`Try again`})]});let e=cV(s),t=e.map(e=>e.repo),r=GB(t),a=e=>aV(e,GB(cV(YB(s,e)).map(e=>e.repo))),o={view:s,scopes:r,actions:w,proposals:T,add:C,switchGuideline:E,suggest:e=>({...D(UB(e)),label:`Suggest from my reviews`,running:`Reading your reviews of ${HB(e)}…`,icon:(0,Y.jsx)(E_,{"aria-hidden":`true`}),what:`Reads what you did on its pull requests here and your comments on ${iL[e.host]}, then runs`,run:async t=>{let r=await n.suggestPreferences({repo:e,...t===void 0?{}:{optionId:t}});if(!r.ok)return{ok:!1,message:dV(r.error)};let{proposals:i,...o}=r.value;return x(e=>YB(e,i)),{ok:!0,said:oV(o,i.length,a(i))}}}),heading:p,headingId:m},c=nV(v,r),l=c.kind===`suggestions`?tV:c.option.key,u={suggestions:{key:tV,icon:(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),full:`Suggestions`,name:`Suggestions`,owner:null,count:s.proposals.length,counted:QH(s.proposals.length),ai:!0},everywhere:{key:WB(VB),icon:(0,Y.jsx)(Rg,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),full:`Everywhere`,name:`Everywhere`,owner:null,count:QB(s,VB).length,counted:ZH(QB(s,VB).length)},repositories:r.flatMap(e=>{if(e.scope.kind!==`repo`)return[];let n=QB(s,e.scope).length;return[{key:e.key,icon:(0,Y.jsx)(WR,{host:e.scope.repo.host}),full:e.label,...sV(e.scope.repo,t),count:n,counted:ZH(n),repo:!0}]})},d=(()=>{if(c.kind===`suggestions`)return(0,Y.jsx)(XH,{context:o});let{option:t}=c;if(t.scope.kind===`global`)return(0,Y.jsx)(JH,{context:o,option:t});let n=e.find(e=>UB(e.repo)===t.key);return n===void 0?null:(0,Y.jsx)(YH,{context:o,option:t,repository:n})})();return(0,Y.jsxs)(`div`,{className:`lg:grid lg:grid-cols-[240px_minmax(0,1fr)] lg:items-start lg:gap-10`,children:[(0,Y.jsx)(iU,{entries:u,current:l,onSelect:b,className:`hidden lg:sticky lg:top-4 lg:block`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(oU,{entries:u,current:l,onSelect:b,className:`mb-5 lg:hidden`}),(0,Y.jsx)(`section`,{"aria-labelledby":m,"data-slot":`scope-panel`,children:d})]})]})})(),(0,Y.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:d})]})},lU=[`import`,`call`,`type`,`request`],uU=e=>e.slice(e.lastIndexOf(`/`)+1),dU=(e,t)=>e<t?-1:+(e>t),fU=e=>/\.(md|mdx|rst|adoc)$/i.test(e),pU=/(^|[/_.-])(fakes?|mocks?|stubs?|fixtures?|testing|test[_-]?(utils?|helpers?|support))([/_.-]|$)/i,mU=e=>PI(e).split(`/`).slice(0,3).join(`/`),hU=e=>e===``?`.`:PI(MI(`${e}/x`)),gU=e=>`group:${e}`,_U=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},vU=`\0routes`,yU=e=>`${e.method} ${e.path}`,bU=e=>{let[t]=e;return e.length===1&&t!==void 0?`${t.method} ${t.path}`:`${e.length} routes`},xU=(e,t)=>{let n=il(e.parts),r=new Map(e.files.flatMap(e=>al(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:cd(t.file,t.hunk,[]);return n?.kind===`route`?n.routes:[]});if(t.length>0&&(a(n,vU),o.set(n,[...o.get(n)??[],...t])),!(new Set(t.map(yU)).size===i.length&&t.length>0))for(let t of e.title.split(`; `)){t.startsWith(`Page: `)&&a(n,t);let e=/^Command: (\S+) in (.+)$/.exec(t);e!==null&&e[2]===uU(n)&&a(n,`Command: ${e[1]}`)}}}return new Map([...i].map(([e,t])=>{let n=[...new Map((o.get(e)??[]).map(e=>[yU(e),e])).values()];return[e,t.map(e=>e===vU?bU(n):e)]}))},SU=(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},CU=()=>({uses:new Set,symbols:new Set,pairs:0}),wU=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)??{...CU(),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(nl(t.fromPartId)),n=r.get(nl(t.toPartId));e!==void 0&&n!==void 0&&o(e,n,t.use,t.symbol)}return{mechanical:t,files:n,pathOfHunk:r,links:a}},TU=(e,t=new Set)=>{let{mechanical:n,files:r,pathOfHunk:i,links:a}=wU(e),o=e.flows??[],s=new Set(o.flatMap(e=>e.partIds)),c=[...r].sort((e,t)=>NI(e.path,t.path)).flatMap(t=>al(t,il(e.parts)).map(e=>e.id)).filter(e=>!n.has(nl(e))&&!s.has(e)),l=[...new Set([...s,...c])],u=new Map(l.map((e,t)=>[e,t])),d=e=>u.get(e)??l.length,f=new Set(e.generated),p=new Map(r.map(t=>{let r=t.hunks.flatMap(e=>e.lines),i=al(t,il(e.parts)).map(e=>e.id).filter(e=>!n.has(nl(e))).sort((e,t)=>d(e)-d(t)),a=t.hunks.every(e=>n.has(e.id))?`mechanical`:`logic`;return[t.path,{added:r.filter(e=>e.kind===`add`).length,deleted:r.filter(e=>e.kind===`del`).length,partIds:i,risk:a,rank:i.reduce((e,t)=>Math.min(e,d(t)),1/0)}]})),m=e=>p.get(e)?.rank??1/0,h=(e,t)=>m(e)-m(t)||dU(e,t),g=r.map(e=>e.path).sort(h),_=e=>[...a.get(e)?.keys()??[]],v=e=>g.filter(t=>a.get(t)?.has(e)===!0),y=new Set(g.filter(ll));for(let e=!0;e;){e=!1;for(let t of g){let n=v(t);!y.has(t)&&pU.test(t)&&n.length>0&&n.every(e=>y.has(e))&&(y.add(t),e=!0)}}let b=g.filter(e=>!y.has(e)&&fU(e)),x=g.filter(e=>!y.has(e)&&!fU(e)),S=new Set(x),C=new Map;for(let e of[...y].sort(h)){let t=[],n=new Set([e]),r=e=>{for(let i of _(e))n.has(i)||(n.add(i),S.has(i)?t.push(i):r(i))};r(e),C.set(e,t)}let w=new Map;for(let[e,t]of C)for(let n of t)w.set(n,[...w.get(n)??[],e]);let T=[...y].filter(e=>(C.get(e)??[]).length===0),E=new Map;for(let e of[...x,...b,...T].sort(NI)){let n=gU(PI(e)),r=t.has(n)?e:n;E.set(r,[...E.get(r)??[],e])}let D=new Map;for(let[e,t]of E)for(let n of t)D.set(n,e);let O=e=>Math.min(...(E.get(e)??[e]).map(m)),k=(e,t)=>O(e)-O(t)||dU(e,t),A=[...E.keys()].sort(k),j=new Map;for(let[e,t]of a)for(let[n,r]of t){let t=D.get(e),i=D.get(n);if(t===void 0||i===void 0||t===i)continue;let a=j.get(t)??new Map,o=a.get(i)??CU();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),j.set(t,a)}let M=new Map;for(let{partId:t,symbol:n,uses:r}of e.unchangedCallers??[]){let e=i.get(nl(t)),a=e===void 0?void 0:D.get(e);if(a!==void 0)for(let e of r){let r=M.get(e.path)??{targets:new Map,uses:0,partIds:new Set},i=r.targets.get(a)??CU();i.uses.add(e.use),i.symbols.add(n),r.targets.set(a,i),r.uses+=1,r.partIds.add(t),M.set(e.path,r)}}let N=[...M.keys()].sort((e,t)=>Number(ll(e))-Number(ll(t))||dU(e,t)),P=new Map;for(let e of N){let t=N.length>10?`outside:${mU(e)}/`:`outside:${e}`;P.set(t,[...P.get(t)??[],e])}for(let[e,t]of[...P]){let[n]=t;e.endsWith(`/`)&&t.length===1&&n!==void 0&&(P.delete(e),P.set(`outside:${n}`,[n]))}let F=new Map;for(let[e,t]of P){let n=new Map;for(let e of t)for(let[t,r]of M.get(e)?.targets??[]){let e=n.get(t)??CU();for(let t of r.uses)e.uses.add(t);for(let t of r.symbols)e.symbols.add(t);n.set(t,e)}F.set(e,n)}let I=new Set([...[...j].flatMap(([e,t])=>t.size>0?[e,...t.keys()]:[]),...[...F.values()].flatMap(e=>[...e.keys()])]),L=A.filter(e=>I.has(e)),R=new Set,ee=(e,t)=>`${e}\u0000${t}`,z=e=>[...j.get(e)?.keys()??[]].filter(t=>!R.has(ee(e,t))),B=(e,t)=>j.get(e)?.get(t)?.pairs??0;for(let e=SU(L,z);e.length>0;e=SU(L,z))for(let t of e){let[e,n,r]=t;if(e!==void 0&&n!==void 0&&r===void 0&&B(e,n)!==B(n,e)){R.add(B(e,n)<B(n,e)?ee(e,n):ee(n,e));continue}let[i]=[...t].sort(k);for(let e of t)i!==void 0&&z(e).includes(i)&&R.add(ee(e,i))}let V=new Map(L.map(e=>[e,[]]));for(let e of L)for(let t of z(e))V.get(t)?.push(e);let te=new Map,H=e=>{let t=te.get(e);if(t!==void 0)return t;let n=Math.max(-1,...(V.get(e)??[]).map(H))+1;return te.set(e,n),n},U=[],ne=(e,t)=>{for(;U.length<=t;)U.push([]);U[t]?.push(e)};for(let e of L)ne(e,H(e));for(let[e,t]of F){let n=[...t.keys()];V.set(e,n),te.set(e,Math.max(...n.map(H))+1),ne(e,te.get(e)??0)}let re=()=>new Map(U.flatMap(e=>e.map((t,n)=>[t,n-(e.length-1)/2]))),ie=e=>z(e),ae=(e,t)=>{for(let n of e){let e=re(),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)||k(e,t))}},oe=e=>V.get(e)??[];ae(U.slice(1),oe),ae(U.slice(0,-1).reverse(),ie),ae(U.slice(1),oe);let W=_U(g),se=xU(e,o),ce=new Map;for(let e of o)if(e.kind===`flow`)for(let t of new Set(e.partIds.flatMap(e=>i.get(nl(e))??[])))ce.set(t,[...ce.get(t)??[],e.title]);let le=e=>[...new Set(e)],ue=_U(N),de=(e,t)=>{let n=P.get(e)??[],[r]=n;return{key:e,kind:`outside`,paths:n,label:e.endsWith(`/`)||r===void 0?e.slice(8):ue.get(r)??r,added:0,deleted:0,risk:`logic`,generated:!1,entries:[],flows:[],partIds:[...new Set(n.flatMap(e=>[...M.get(e)?.partIds??[]]))],uses:n.reduce((e,t)=>e+(M.get(t)?.uses??0),0),badges:[],row:t}},fe=(e,t)=>{if(P.has(e))return de(e,t);let n=E.get(e)??[e],r=n.flatMap(e=>p.get(e)??[]),i=e.startsWith(`group:`);return{key:e,kind:i?`group`:`file`,paths:n,label:i?`${hU(e.slice(6))}/`:W.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=>f.has(e)),entries:le(n.flatMap(e=>se.get(e)??[])),flows:le(n.flatMap(e=>ce.get(e)??[])),partIds:r.flatMap(e=>e.partIds).sort((e,t)=>d(e)-d(t)),badges:le(n.flatMap(e=>w.get(e)??[])).sort(h),uses:0,row:t}},pe=U.map((e,t)=>e.map(e=>fe(e,t))),me=A.filter(e=>!I.has(e)).map(e=>fe(e,-1)),he=new Map;for(let e of[...pe.flat(),...me])if(e.kind!==`outside`)for(let t of e.paths)he.set(t,e.key);for(let[e,t]of C){let[n]=t,r=n===void 0?void 0:D.get(n);r!==void 0&&he.set(e,r)}return{rows:pe,edges:[...[...j].map(e=>[e,!1]),...[...F].map(e=>[e,!0])].flatMap(([[e,t],n])=>[...t].map(([t,r])=>({from:e,to:t,uses:lU.filter(e=>r.uses.has(e)),symbols:[...r.symbols].sort(dU),back:R.has(ee(e,t)),outside:n}))),strip:me,placeOf:he}},EU=e=>e.kind!==`outside`&&!e.generated&&e.risk!==`mechanical`,DU=e=>e.kind===`group`?e.key.slice(6)||`.`:e.key,OU=e=>{let t=e.rows.map(e=>e.filter(EU)).filter(e=>e.length>0),n=e.strip.filter(EU),r=t.length>0,i=r?t:[n],a=i.flat();if(a.length===0)return null;let o=_U(a.map(DU)),s=8,c=i.map(e=>e.flatMap(e=>s===0?[]:(--s,[{label:o.get(DU(e))??DU(e),entries:e.entries}]))).filter(e=>e.length>0);return{rows:c,linked:r,more:a.length-c.flat().length+(r?n.length:0)}},kU=(e,t)=>{let n=e.flatMap(e=>{let n=t(e.partId);if(n===void 0||ll(n))return[];let r=e.uses.filter(e=>!ll(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)}},AU=e=>e.split(/`([^`\n]+)`/).map((e,t)=>({text:e,code:t%2==1})).filter(e=>e.text!==``),jU={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},MU=({kind:e,count:t,words:n,at:r,pressed:i,onPressed:a,label:o})=>{let[s,c]=n,l=e===`thread`?n_:DD[e];return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`point-chip`,"data-kind":e,"data-land":`rise`,"aria-pressed":i,"aria-label":o,style:Ph({"--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`:ED[e].className),children:[(0,Y.jsx)(l,{"aria-hidden":`true`,className:`size-3.5`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{"data-slot":`count-up`,"aria-hidden":`true`,className:`tabular`,style:Ph({"--count":t})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t}),` `,(0,Y.jsx)(`span`,{className:`max-xl:sr-only`,children:t===1?s:c})]})]})},NU=({choice:e,variant:t,compact:n,icon:r,label:i,note:a,locked:o=!1,disabled:s=!1,busy:c=null,slot:l,onClick:u})=>{let d=(0,J.useId)(),f=n?`sm`:`default`,p=(0,Y.jsx)($,{variant:t,size:f,"data-slot":l,disabled:s||c!==null,focusableWhenDisabled:!0,"aria-describedby":a===null?void 0:d,onClick:u,className:X(`rounded-r-none border-r-0`,c!==null&&`aria-disabled:cursor-progress aria-disabled:opacity-100`)});return(0,Y.jsxs)(`span`,{role:`group`,"aria-label":`AI review`,className:`flex shrink-0 items-center`,children:[(0,Y.jsxs)(YL,{disabled:a===null,children:[(0,Y.jsxs)(XL,{render:p,children:[(0,Y.jsx)(r,{"aria-hidden":`true`,className:X(c!==null&&`animate-spin motion-reduce:animate-none`)}),i]}),(0,Y.jsxs)(ZL,{side:`bottom`,align:`start`,children:[o&&(0,Y.jsx)(Wg,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),a]})]}),a!==null&&(0,Y.jsx)(`span`,{id:d,hidden:!0,children:a}),(0,Y.jsx)(jB,{choice:e,disabled:c!==null||s||e.options.length===0,variant:t,size:f}),c!==null&&(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:c})]})},PU=e=>{let t=Zu.filter(t=>e.stages[t]!==`done`);return t.length===0||e.modelError===null?null:`${t.join(`, `)} missing: ${e.modelError.message}`},FU=({analysis:e,choice:t,running:n,starting:r,error:i,points:a,leftOut:o=0,threads:s=null,narrowed:c,onNarrow:l,onRun:u,onRerun:d,reanalyze:f=null,filesChanged:p=null,children:m})=>{let h=Bl(e.modelOption??t.chosen),g=m!=null&&m!==!1,{chosen:_,locked:v}=t,y=v??(_===null?null:`Runs ${_.modelName} through ${_.via}`),b=r||v!==null||_===null,x=id(e),S=rd(e),C=e.modelError,w=[`finding`,`risk`,`decision`].map(e=>[e,a.filter(t=>t.kind===e).length]).filter(([,e])=>e>0),T=!n&&a.length>0,E=T?w.length+(s===null?0:1):0,D=e=>T?{"data-land":`rise`,style:Ph({"--landing-i":E+e})}:{},O=ed(e),k=O.filter(t=>e.stages[t]===`done`).length,A=n?(0,Y.jsx)(NU,{choice:t,variant:`ai-quiet`,compact:!0,icon:Qg,label:`Reviewing · ${k} of ${O.length}`,note:null,busy:`${h} is reading this PR, ${k} of ${O.length} passes done`,slot:`claude-running`}):f===null?S?(0,Y.jsx)(NU,{choice:t,variant:C===null?`ai`:`ai-quiet`,compact:a.length>0,icon:v===null?C===null?E_:u_:e_,label:r?`Starting…`:C===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Request AI review`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`sm:hidden`,children:`AI review`})]}):`Try again`,note:y,locked:v!==null,disabled:b,slot:`request-review`,onClick:u}):d!==void 0&&(0,Y.jsx)(NU,{choice:t,variant:`ai-quiet`,compact:!0,icon:u_,label:r?`Starting…`:`Re-run`,note:v??(_===null?null:`Runs ${_.modelName} through ${_.via} again`),locked:v!==null,disabled:b,slot:`rerun`,onClick:d}):(0,Y.jsx)(NU,{choice:t,variant:`ai-strong`,compact:x,icon:u_,label:f.starting?`Starting…`:`Re-analyze · new commits`,note:`Reads the PR's new commits as a new analysis`,disabled:f.starting,slot:`reanalyze`,onClick:f.onReanalyze}),j=!n&&f===null&&!x&&(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 whitespace-nowrap text-muted-foreground max-lg:hidden`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`No AI review yet`}),p!==null&&p>0&&(0,Y.jsxs)(`span`,{className:`truncate max-xl:hidden`,children:[`Find bugs, risks and decisions across `,p,` `,p===1?`file`:`files`]})]}),M=i??(a.length>0?PU(e):null)??(C===null||a.length>0?null:`${h} couldn't finish: ${C.message}`),N=!n&&!S&&a.length===0&&e.stages.findings===`done`&&(0,Y.jsxs)(`span`,{"data-slot":`claude-receipt`,"data-land":`fade`,className:`shrink-0 whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),h,` found nothing to raise`,o>0&&`, and left out ${o} by your preferences`]}),P=T?(0,Y.jsxs)(`span`,{"data-slot":`claude-receipt`,className:`flex min-w-0 items-center gap-1.5`,children:[w.map(([e,t],n)=>(0,Y.jsx)(MU,{kind:e,count:t,words:jU[e],at:n,pressed:c===e,onPressed:t=>l(t?e:null)},e)),s!==null&&(0,Y.jsx)(MU,{kind:`thread`,count:s.count,words:s.words,label:s.label,at:w.length,pressed:c===`thread`,onPressed:e=>l(e?`thread`:null)}),g&&(0,Y.jsx)(`span`,{...D(0),className:`ml-1 flex min-w-0 items-center`,children:m})]}):(N!==!1||g)&&(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[N,g&&(0,Y.jsx)(`span`,{className:`flex min-w-0 items-center`,children:m})]});return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[P,(0,Y.jsxs)(`span`,{...D(1),className:X(`flex min-w-0 shrink-0 items-center gap-2`,P!==!1&&`border-l pl-2`),children:[j,A]}),M!==null&&(0,Y.jsx)(`span`,{...D(2),role:`alert`,title:M,className:`min-w-0 truncate text-caption text-destructive`,children:M})]})},IU=e=>`call-${e.partId}-${e.line}-${e.column}`,LU=(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=IU(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,Y.jsx)(BM,{handle:n,payload:a,id:o,children:e})}),s.set(i.line,c),r.set(i.partId,s))}return r},RU=(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}`}},zU=({children:e})=>(0,Y.jsx)(`code`,{className:`font-mono text-code-compact text-foreground`,children:e}),BU=e=>{let t=Xl[e];return`${/^[aeiou]/i.test(t)?`an`:`a`} ${t}`},VU=e=>{switch(e.is){case`rule`:return`A check could catch this next time: \`${e.rule}\` in ${Yl[e.tool]}.`;case`suggested`:return`A check could catch this next time: ${BU(e.kind)} in ${e.engine}. ${e.does}`}},HU=`flex items-start gap-1.5 text-caption text-muted-foreground`,UU=({guardrail:e,family:t,className:n,children:r})=>{switch(e.is){case`rule`:return(0,Y.jsxs)(`p`,{"data-slot":`guardrail`,"data-guardrail":`rule`,className:X(HU,n),children:[(0,Y.jsx)(v_,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:`A check could catch this:`}),` `,(0,Y.jsx)(zU,{children:e.rule}),` in `,Yl[e.tool],`, which`,` `,(0,Y.jsx)(zU,{children:e.configPath}),` doesn't turn on.`,r]})]});case`suggested`:return(0,Y.jsxs)(`p`,{"data-slot":`guardrail`,"data-guardrail":`suggested`,className:X(HU,n),children:[(0,Y.jsx)(b_,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:`This looks checkable:`}),` `,BU(e.kind),` in `,e.engine,`. `,e.does,` `,(0,Y.jsxs)(`span`,{className:`italic`,children:[`Suggested by `,t,`, not checked.`]}),r]})]})}},WU=({guardrail:e,family:t,body:n,onEdit:r})=>{let i=VU(e);return(0,Y.jsx)(`div`,{"data-slot":`draft-guardrail`,className:`border-t pt-2`,children:(0,Y.jsx)(UU,{guardrail:e,family:t,children:n.includes(i)?(0,Y.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-1 text-foreground`,children:[(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`size-3.5`}),`Added to the comment`]}):(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:`ml-1`,onClick:()=>r(`${n.trimEnd()}\n\n${i}`),children:`Add to comment`})]})})})},GU=e=>`hunk-${e}`,KU=e=>e===void 0?{}:{marks:e},qU=({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,Y.jsx)(`div`,{className:AM,children:(0,Y.jsx)(rN,{hunk:r,file:i,risk:a,proofs:o,onFocus:t.onFocusHunk})}):(0,Y.jsx)(LM,{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},...t.draftNote===void 0?{}:{draftNote:(n,r)=>t.draftNote?.(e,n,r)},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},...KU(t.marksOf(e))})},JU=`You opened this pull request, and its author can't approve it.`,YU=({aiDone:e,running:t,pending:n,isAuthor:r,stale:i,verdict:a})=>{let o=a===`approved`,s=!o&&r?JU:null,c={filled:n>0,count:n};if(o)return{approve:{filled:!1,disabledReason:s,revoke:!0},publish:c,order:n>0?[`approve`,`publish`]:[`approve`]};let l=n===0&&e&&!t&&s===null&&!i&&a!==`changes-requested`;return{approve:{filled:l,disabledReason:s,revoke:!1},publish:c,order:l?[`publish`,`approve`]:[`approve`,`publish`]}},XU=(e,t,n)=>{let r=n?.url??null;return t?e===null?null:{kind:e,url:r}:n===null?null:{kind:`published`,url:r}},ZU=(e,t)=>e===`approve`?`approved`:e===`request_changes`?`changes-requested`:t??`commented`,QU=1,$U=240,eW=6,tW=()=>{},nW=e=>{let t=e.left+e.width/2;for(let e=QU;e<Math.min(window.innerHeight,$U);e+=eW){let n=document.elementFromPoint(t,e);if(n===null||n.closest(`[data-slot=file-card-header]`)!==null)continue;let r=n.closest(`[role=row][data-line]`);if(r!==null&&r.getBoundingClientRect().top>=0)return r}return null},rW=e=>{let t=document.querySelector(e)?.getBoundingClientRect();if(window.scrollY<=QU||t===void 0||t.top>=0||typeof document.elementFromPoint!=`function`)return tW;let n=nW(t);if(n===null)return tW;let r=n.getBoundingClientRect().top;return()=>{if(!n.isConnected)return;let e=n.getBoundingClientRect().top-r;e!==0&&window.scrollBy({top:e,behavior:`instant`})}},iW=2e3,aW=[`wheel`,`touchmove`,`keydown`,`pointerdown`],oW=(e,t)=>{let n=document.querySelector(e);if(n===null||typeof ResizeObserver!=`function`)return tW;let r=new ResizeObserver(t),i=()=>{r.disconnect(),window.clearTimeout(a);for(let e of aW)window.removeEventListener(e,i)},a=window.setTimeout(i,iW);for(let e of aW)window.addEventListener(e,i,{passive:!0});return r.observe(n),i},sW=(e,t)=>oW(t,()=>document.getElementById(e)?.scrollIntoView({block:`start`,behavior:`instant`})),cW=/^#{1,6}\s+/,lW=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`),uW=e=>{let t=e.split(`
86
+ `).map(e=>e.trim()).filter(e=>e!==``);return lW(t.find(e=>!cW.test(e))??t[0]?.replace(cW,``)??``)},dW=/^(.+?[.!?])\s+(?=[A-Z0-9"'(`[])/,fW=e=>{let t=uW(e);return dW.exec(t)?.[1]??t},pW=`font-semibold text-foreground`,mW=({text:e})=>(0,Y.jsx)(`span`,{"data-slot":`model-text`,className:`whitespace-pre-line`,children:AU(e).map((e,t)=>e.code?(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.text},t):(0,Y.jsx)(`span`,{children:lW(e.text)},t))}),hW=({through:e})=>(0,Y.jsxs)(`span`,{"data-slot":`through`,children:[e.rows.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&` → `,e.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&`, `,(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:e.label}),e.entries.length>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.entries.join(`, `),`)`]})]},e.label))]},t)),e.more>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,e.more,` more `,e.more===1?`directory`:`directories`]})]}),gW=({reach:e})=>{let t=e.symbols.slice(0,3),n=e.symbols.length-t.length,r=t.map((e,r)=>(0,Y.jsxs)(`span`,{children:[r>0&&(r===t.length-1&&n===0?` and `:`, `),(0,Y.jsx)(`code`,{className:`font-mono text-code-compact`,children:e})]},e));return(0,Y.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.`]})},_W=({lead:e,children:t})=>(0,Y.jsxs)(`p`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:pW,children:e}),` `,t]}),vW=e=>e.modelOption===null?null:`${e.modelOption.modelName} through ${e.modelOption.providerName}`,yW=({analysis:e,running:t,stale:n,tour:r})=>{if(!t&&!id(e))return null;let i=vW(e),a=ed(e),o=a.filter(t=>e.stages[t]===`done`).length;return(0,Y.jsxs)(`div`,{"data-slot":`ai-status`,className:`mb-1.5 flex flex-wrap items-center gap-x-1.5 text-caption text-muted-foreground`,children:[t?(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:`size-3.5 animate-spin text-primary motion-reduce:animate-none`}):(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3.5 text-primary`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:t?`AI review running`:`AI review`}),i!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsx)(`span`,{children:i})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[o,` of `,a.length,` passes`]}),(0,Y.jsx)(`span`,{role:`progressbar`,"aria-label":`AI review progress`,"aria-valuemin":0,"aria-valuemax":a.length,"aria-valuenow":o,className:`ml-1 h-1 w-30 overflow-hidden rounded-full bg-secondary`,children:(0,Y.jsx)(`span`,{className:`block h-full bg-primary transition-[width] motion-reduce:transition-none`,style:{width:`${o/a.length*100}%`}})})]}):(0,Y.jsx)(`span`,{children:n?`new commits since`:`latest commit`}),r!==null&&!t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-link`,onClick:r.onOpen,className:`inline-flex cursor-pointer items-center gap-1 font-medium text-primary underline-offset-2 hover:underline`,children:[(0,Y.jsx)(f_,{"aria-hidden":`true`,className:`size-3.5`}),`Tour · `,r.steps,` steps`]})]})]})},bW=({analysis:e,through:t,running:n,stale:r=!1,tour:i=null,onDetails:a})=>{let{intent:o,pullRequest:s}=e,c=o?.mismatches??[],l=s===null?``:fW(s.description),[u,d]=(0,J.useState)(o!==null),[f,p]=(0,J.useState)(!1);o!==null!==u&&(d(o!==null),p(o!==null&&n)),f&&!n&&p(!1);let m=(o!==null||s!==null)&&(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Details`,title:`Details`,onClick:a,className:`ml-1 rounded-full align-middle text-muted-foreground`,children:(0,Y.jsx)(Wg,{"aria-hidden":`true`})}),h=new Map(e.files.flatMap(e=>e.hunks.map(t=>[t.id,e.path]))),g=kU(e.unchangedCallers,e=>h.get(nl(e))),_=t!==null&&(0,Y.jsx)(_W,{lead:t.linked?`Through:`:`In:`,children:(0,Y.jsx)(hW,{through:t})}),v=g!==null&&(0,Y.jsx)(_W,{lead:`Watch:`,children:(0,Y.jsx)(gW,{reach:g})}),y=s!==null&&(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0`,children:[l===``?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,Y.jsx)(`span`,{children:l}),!f&&m]}),_,v]}),b=o!==null&&(0,Y.jsxs)(`div`,{"data-arriving":f||void 0,className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:pW,children:c.length>0||o.stated===null?`From the code:`:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-0.125em] text-review-approved`}),`Does what was asked:`]})}),` `,(0,Y.jsx)(mW,{text:o.inferred.summary}),m]}),o.inferred.shape===``?_:(0,Y.jsx)(_W,{lead:`Through:`,children:(0,Y.jsx)(mW,{text:o.inferred.shape})}),o.inferred.watch.length===0?v:(0,Y.jsx)(_W,{lead:`Watch:`,children:o.inferred.watch.map((e,t)=>(0,Y.jsxs)(`span`,{children:[t>0&&` · `,(0,Y.jsx)(mW,{text:e})]},t))})]});return(0,Y.jsxs)(`div`,{"data-slot":`intent-brief`,className:`flex min-w-0 flex-col gap-1 text-body`,children:[(0,Y.jsx)(yW,{analysis:e,running:n,stale:r,tour:i}),b===!1?y:f?(0,Y.jsxs)(`div`,{"data-slot":`intent-swap`,className:`min-w-0`,children:[(0,Y.jsx)(`div`,{"data-leaving":!0,"aria-hidden":`true`,children:y}),b]}):b]})},xW=`rounded-full border bg-muted px-2 py-0.5 text-caption`,SW=({pullRequest:e,tickets:t,missingTicketKeys:n})=>{let r=e.description.trim();return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r===``?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`The pull request has no description.`}):(0,Y.jsx)(`p`,{className:`text-body whitespace-pre-line`,children:r}),(t.length>0||n.length>0)&&(0,Y.jsxs)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets`,children:[t.map(e=>(0,Y.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.key,` · `,e.summary]})},e.key)),n.map(e=>(0,Y.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,Y.jsxs)(`details`,{className:`group`,children:[(0,Y.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Commits (`,e.commits.length,`)`]}),(0,Y.jsx)(`ol`,{className:`mt-1 flex flex-col gap-1`,children:e.commits.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`font-mono text-code-compact text-muted-foreground`,children:e.sha.slice(0,7)}),` `,e.message.split(`
87
+ `)[0]]},e.sha))})]})]})},CW={description:`Description`,commits:`Commits`,branch:`Branch name`},wW={unrequested:`Unrequested`,missing:`Missing`,contradicts:`Contradicts`},TW={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`},EW=`whitespace-pre-line`,DW=`text-caption font-medium text-muted-foreground`,OW=({ticketKey:e,ticket:t})=>t===void 0?(0,Y.jsxs)(`li`,{className:xW,title:`Jira didn't return this ticket, or Jira isn't configured`,children:[e,` · not fetched`]}):(0,Y.jsx)(`li`,{className:xW,children:(0,Y.jsxs)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,title:t.summary,children:[t.key,` · `,t.status]})}),kW=({stated:e,ticketOf:t,unfetched:n})=>(0,Y.jsxs)(Y.Fragment,{children:[e!==null&&(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Sources`,children:e.sources.map(e=>e.kind===`ticket`&&e.ref!==null?(0,Y.jsx)(OW,{ticketKey:e.ref,ticket:t.get(e.ref)},`ticket:${e.ref}`):e.kind===`ticket`?null:(0,Y.jsx)(`li`,{className:`rounded-full border bg-muted px-2 py-0.5 text-caption`,children:CW[e.kind]},e.kind))}),n.length>0&&(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"aria-label":`Tickets mentioned but not fetched`,children:n.map(e=>(0,Y.jsx)(OW,{ticketKey:e,ticket:void 0},e))})]}),AW=`No stated intent: the PR has no description or linked tickets.`,jW=({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,Y.jsx)(kW,{stated:i,ticketOf:s,unfetched:l}),d=o.length===0?i:null,{behaviorChanges:f}=a;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 text-body`,children:[o.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`p`,{children:[i===null?(0,Y.jsx)(`span`,{className:`font-medium`,children:`From the code:`}):(0,Y.jsx)(`span`,{className:`font-medium text-review-approved`,children:`✓ Does what was asked:`}),` `,(0,Y.jsx)(`span`,{className:EW,children:a.summary})]}),i===null&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:AW}),u]}):(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:DW,children:`Stated`}),i===null?(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:AW}):(0,Y.jsx)(`p`,{className:EW,children:i.summary}),u]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:DW,children:`Inferred from the code`}),(0,Y.jsx)(`p`,{className:EW,children:a.summary})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:DW,children:`Mismatches`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsxs)(`span`,{className:X(`rounded-full border px-2 text-caption font-medium`,TW[e.kind]),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),wW[e.kind]]}),(0,Y.jsx)(`span`,{className:EW,children:e.description})]})},t))})]})]}),(d!==null||f.length>0)&&(0,Y.jsxs)(`details`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`summary`,{className:`min-h-6 cursor-pointer font-medium`,children:[`Details`,f.length>0&&` (${f.length})`]}),d!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:X(DW,`mt-2`),children:`Asked`}),(0,Y.jsx)(`p`,{className:EW,children:d.summary})]}),f.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:X(DW,`mt-2`),children:`Behavior changes`}),(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:f.map((e,t)=>(0,Y.jsx)(`li`,{className:EW,children:e},t))})]})]})]})},MW=3,NW=(e,t)=>{let n=e.end??t;return n===null?null:Math.max(0,n-e.start+1)},PW=e=>({head:e.newLines===0?e.newStart+1:e.newStart+e.newLines,base:e.oldLines===0?e.oldStart+1:e.oldStart+e.oldLines}),FW=e=>e.newLines===0?e.newStart+1:e.newStart,IW=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<MW},LW=e=>!e.binary&&e.status!==`added`&&e.status!==`deleted`,RW=(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=FW(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=PW(i),o=n[e+1],s=a.base-a.head;if(o===void 0){IW(i)||r.push({before:null,after:t,start:a.head,end:null,offset:s});continue}let c=FW(o.hunk)-1;c>=a.head&&r.push({before:o.id,after:t,start:a.head,end:c,offset:s})}return r},zW=(e,t)=>Array.from({length:NW(e,t)??0},(t,n)=>e.start+n),BW=e=>{let t=e.split(`
88
+ `);return t.at(-1)===``&&t.pop(),t.map(e=>e.endsWith(`\r`)?e.slice(0,-1):e)},VW=(e,t)=>{let{client:n}=Pp(),[r,i]=(0,J.useState)({status:`idle`}),a=(0,J.useRef)(`idle`);return{text:r,load:(0,J.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:BW(e.value.content)}:{status:`error`,message:Gp(e.error)}))},[n,e,t])}},HW=()=>(0,Y.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,Y.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`})}),UW=e=>`${e} ${e===1?`line`:`lines`}`,WW=(e,t,n,r)=>e.map(e=>({oldNo:e+t.offset,newNo:e,text:n[e-1]??``,tokens:r?.[e-1]??null})),GW=({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=uj(c,t),u=NW(e,c?.length??null);if(u===0)return null;if(r&&c!==null)return(0,Y.jsx)(`div`,{"data-slot":`file-fold`,children:(0,Y.jsx)(cN,{hunkId:n,lines:WW(zW(e,c.length),e,c,l)})});let d=r&&i.status===`loading`,f=u===null?`Unchanged lines below`:`${UW(u)} unchanged`;return(0,Y.jsxs)(`div`,{"data-slot":`file-gap`,className:X(`flex flex-wrap items-center bg-surface-subtle text-muted-foreground`,AM,o&&`border-t`,s?`border-b`:`rounded-b-lg`),children:[(0,Y.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,Y.jsx)(HW,{}),d?(0,Y.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5`,children:[(0,Y.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,Y.jsx)(`span`,{children:f})]}),r&&i.status===`error`&&(0,Y.jsx)(`span`,{role:`alert`,className:`px-3 text-destructive`,children:i.message})]})},KW=e=>e===`map`?`map`:e===`overview`||e===`tree`?`overview`:void 0,qW=`Not classified yet.`,JW=e=>{let t=il(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 al(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=nl(e);return i.get(t)??{hunkId:t,riskClass:`logic`,reason:qW,source:`fallback`,lines:null,guidance:null}},c=e=>e.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[{...t,id:e,hunkId:nl(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))}},YW=(e,t)=>[...e.files].sort((e,t)=>NI(e.path,t.path)).flatMap(e=>{let n=t.partsInFile(e);return n.every(e=>t.mechanical.has(e))?[]:[{file:e,partIds:n}]}),XW=(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)},ZW=(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:QW(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:nl(u);for(let e of d)nl(e)!==f&&c(a,e,t)}return{cards:i,mentions:a,cardPart:o,unplaced:s}},QW=(e,t,n)=>t.find(t=>n.parts.get(t)?.hunk.lines.some(t=>{let n=kM(t);return n!==null&&n.side===e.side&&n.line===e.startLine})),$W=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},eG=(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))},tG=(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=kM(e);return t!==null&&t.side===r.side&&t.line===r.line}));e!==void 0&&n.set(e,[...n.get(e)??[],r])}return n},nG=e=>({files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}),rG=`mechanical-changes`,iG=e=>`file-${e}`,aG=(0,J.memo)(function({render:e}){return e()},(e,t)=>e.signature===t.signature),oG=({id:e,joined:t,deps:n,signatureOf:r})=>(0,Y.jsx)(`div`,{id:GU(e),className:X(`scroll-mt-24`,!t&&`border-t first:border-t-0`),"data-hunk-id":e,children:(0,Y.jsx)(aG,{signature:r(e),render:()=>(0,Y.jsx)(qU,{id:e,deps:n})})}),sG=({lines:e})=>e===0?null:(0,Y.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`,AM),children:(0,Y.jsxs)(`span`,{children:[e,` `,e===1?`line`:`lines`,` unchanged`]})}),cG=({analysisId:e,group:t,deps:n,signatureOf:r})=>{let i=n.index.items(t.partIds),a=i.reduce((e,t)=>e+WA(t.hunk).added,0),o=i.reduce((e,t)=>e+WA(t.hunk).deleted,0),s=n.openThreads(t.file.path),c=n.earlierThreads(t.file.path),{text:l,load:u}=VW(e,t.file.path),[d,f]=(0,J.useState)(new Set),p=(0,J.useMemo)(()=>LW(t.file)?RW(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,Y.jsx)(GW,{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,Y.jsxs)(`section`,{id:iG(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,Y.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,Y.jsx)(FO,{file:t.file,status:t.file.status,className:`min-w-0 flex-1`}),(0,Y.jsx)(IO,{status:t.file.status}),(0,Y.jsxs)(`span`,{className:`tabular flex flex-wrap items-center gap-x-1.5 text-caption`,children:[s>0&&(0,Y.jsxs)(`span`,{"data-slot":`count-threads`,className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,Y.jsx)(QI,{count:s}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,a]}),` `,(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,o]})]})]})]}),(0,Y.jsx)(`div`,{"data-slot":`file-lines`,className:`@container overflow-x-auto rounded-b-lg`,children:(0,Y.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:XW(a,e,n.index),s=p.find(t=>t.before===e);return(0,Y.jsxs)(J.Fragment,{children:[s===void 0?o!==null&&(0,Y.jsx)(sG,{lines:o}):h(s),(0,Y.jsx)(oG,{id:e,joined:o===0||s!==void 0,deps:n,signatureOf:r})]},e)}),p.filter(e=>e.before===null).map(h)]})}),c!==null&&(0,Y.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,Y.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Earlier comments`}),c]})]})},lG=({analysis:e,files:t,deps:n,before:r,after:i,trailingProofs:a,mechanicalCount:o,scrollRequest:s,signatureOf:c})=>((0,J.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,Y.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":`Changes`,children:[r,t.map(t=>(0,Y.jsx)(cG,{analysisId:e.id,group:t,deps:n,signatureOf:c},t.file.path)),i,(0,Y.jsxs)(`div`,{id:rG,className:`flex scroll-mt-2 flex-col gap-4 -outline-offset-2`,tabIndex:-1,children:[o===0&&e.stages.prep===`done`&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No mechanical changes in this pull request.`}),(0,Y.jsx)(iN,{files:e.files,proofs:a,risk:e.risk}),(0,Y.jsx)(sN,{files:e.files})]})]})),uG={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`,guardrails:`Guardrails`,steps:`Tour`},dG=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`,fG=e=>`$${e.toFixed(2)}`,pG=e=>e===void 0?`—`:`${(e/1e3).toFixed(1)} s`,mG=e=>e===null?null:`${e.modelName} through ${e.providerName}`,hG=new Intl.ListFormat(`en`,{type:`conjunction`}),gG=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:hG.format(n)},_G=(e,t)=>{let n=mG(e),r=gG(t);return r===null?n:n===null?`With ${r}`:`${n} with ${r}`},vG=e=>e===null?`—`:fG(e),yG=(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=fG(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}`},bG=e=>e.inputTokens+e.cacheWriteTokens,xG=({usage:e,option:t=null,guidance:n=null})=>{let r=(0,J.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,Y.jsxs)(`div`,{className:`group relative flex justify-end`,children:[(0,Y.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:[_G(t,n)===null?``:`${_G(t,n)} · `,`Usage: `,dG(i(bG)),` tokens in ·`,` `,dG(i(e=>e.cacheReadTokens)),` cache read ·`,` `,dG(i(e=>e.outputTokens)),` out ·`,` `,yG(e.map(e=>e.costUsd),a,Il(t))]}),(0,Y.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,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,Y.jsx)(`th`,{scope:`col`,children:`In`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Cache read`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Out`}),(0,Y.jsx)(`th`,{scope:`col`,children:a?`At API prices`:`Cost`}),o&&(0,Y.jsx)(`th`,{scope:`col`,children:`Time`})]})}),(0,Y.jsx)(`tbody`,{children:e.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`row`,children:uG[e.pass]}),(0,Y.jsx)(`td`,{children:dG(bG(e))}),(0,Y.jsx)(`td`,{children:dG(e.cacheReadTokens)}),(0,Y.jsx)(`td`,{children:dG(e.outputTokens)}),(0,Y.jsx)(`td`,{children:vG(e.costUsd)}),o&&(0,Y.jsx)(`td`,{children:pG(e.durationMs)})]},e.pass))})]})]})},SG={intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`,guardrails:`Guardrails`,steps:`Tour`},CG=e=>{let t=Math.round(e/1e3);return`+${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},wG=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`}`},TG=e=>[...e].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)||e.attempt-t.attempt),EG=({guidance:e,leftOut:t})=>{let n=gG(e);return n===null?null:(0,Y.jsxs)(`section`,{"aria-label":`What the run read beside the code`,className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`h3`,{className:`font-medium`,children:`Read beside the code`}),(0,Y.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,Y.jsx)(Q_,{to:R_,className:`underline`,children:`Preferences`})]}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1 text-ui`,children:[e.preferences.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(BB,{kind:e.kind}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 break-words`,children:e.text}),(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.scope.kind===`global`?`Everywhere`:HB(e.scope.repo)})]},e.ref)),e.guidelines.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sg,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono text-code-compact break-all`,children:e.path}),(0,Y.jsx)(`span`,{className:`tabular text-caption text-muted-foreground`,children:lV(e.bytes)})]},e.ref))]})]})},DG=({calls:e,option:t,guidance:n=null,leftOut:r=0})=>{let[i,a]=(0,J.useState)(!1),o=TG(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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>a(!0),children:`Run details…`}),i&&(0,Y.jsxs)(IH,{title:`${Bl(t)}'s calls`,onClose:()=>a(!1),className:`sm:max-w-3xl`,children:[(0,Y.jsxs)(`p`,{className:`text-ui text-muted-foreground`,children:[mG(t)===null?``:`On ${mG(t)}. `,pG(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,Y.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,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Pass`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Started`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Time`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Outcome`})]})}),(0,Y.jsx)(`tbody`,{children:o.map(e=>{let t=e.error===null?e.problems:[e.error.message];return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsxs)(`th`,{scope:`row`,children:[SG[e.pass],e.attempt>1&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · again`})]}),(0,Y.jsx)(`td`,{children:CG(Date.parse(e.startedAt)-c)}),(0,Y.jsx)(`td`,{children:pG(e.durationMs)}),(0,Y.jsxs)(`td`,{children:[(0,Y.jsx)(`span`,{className:e.outcome===`failed`?`text-destructive`:void 0,children:wG(e)}),t.length>0&&(0,Y.jsx)(`ul`,{className:`mt-1 list-disc pl-4 text-muted-foreground`,children:t.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]})]},`${e.pass}/${e.attempt}/${e.startedAt}`)})})]}),n!==null&&(0,Y.jsx)(EG,{guidance:n,leftOut:r})]})]})},OG={logic:`border-risk-logic-solid bg-risk-logic-bg text-risk-logic`,mechanical:`border-risk-mechanical-solid bg-risk-mechanical-bg text-risk-mechanical`},kG=`border-dashed border-input bg-surface-subtle text-muted-foreground`,AG={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`},jG=56,MG=24,NG=16,PG=120,FG=300,IG=7.2,LG=6.6,RG=6.7,zG=32,BG=24,VG=20,HG=380,UG=e=>e.slice(e.lastIndexOf(`/`)+1),WG=e=>e===1?`1 use`:`${e} uses`,GG=e=>e===1?`1 file`:`${e} files`,KG=e=>e.kind===`outside`?`${e.paths.length>1?`${GG(e.paths.length)} · `:``}outside the PR · ${WG(e.uses)}`:[e.kind===`group`?GG(e.paths.length):`+${e.added} −${e.deleted}`,...e.entries].join(` · `),qG=e=>zG+(e.kind===`group`&&e.paths.length>1?BG:0),JG=e=>{let t=t=>t.length*IG+qG(e)<=HG,n=e.label.endsWith(`/`)?`/`:``,r=AI(e.label.slice(0,e.label.length-n.length),e=>t(e+n));if(n!==``||t(r))return r+n;let i=r.lastIndexOf(`/`)+1,[a,o]=jI(r.slice(i)),s=r.slice(0,i);return s+OI(a,e=>t(s+e+o))+o},YG=e=>{let t=e.badges.reduce((e,t)=>e+UG(t).length*RG+14,0),n=Math.min(Math.max(JG(e).length*IG+qG(e),KG(e).length*LG+VG,t+VG),HG),r=PG+Math.sqrt(e.added+e.deleted)*9;return Math.round(Math.max(n,Math.min(r,FG)))},XG=72,ZG=(e,t)=>{let n=e.map(e=>e.reduce((e,t,n)=>e+YG(t)+(n>0?MG:0),0)),r=Math.max(0,...n)+32,i=r+(t?XG:0),a=new Map;return e.forEach((e,t)=>{let i=(r-(n[t]??0))/2;for(let n of e){let e=YG(n);a.set(n.key,{x:i,y:NG+t*120,width:e}),i+=e+MG}}),{boxes:a,width:i,height:e.length===0?0:32+e.length*64+(e.length-1)*jG}},QG=e=>e.outside?`outside`:e.uses.includes(`request`)?`request`:e.uses.includes(`call`)?`call`:e.uses.every(e=>e===`import`)?`import`:`type`,$G=(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}},eK=(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-XG/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(jG/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(jG/2,(s-o)/2);return`M ${i} ${o} C ${i} ${o+c} ${a} ${s-c} ${a} ${s}`},tK={import:`imports`,call:`calls`,type:`uses types from`,request:`sends requests to`},nK=(e,t)=>{let n=e.uses.map(e=>tK[e]).join(`, `),r=e.symbols.length>0?`: ${e.symbols.join(`, `)}`:``;return`${t(e.from)} ${n} ${t(e.to)}${r}`},rK=({node:e,box:t,active:n,current:r,onOpen:i,onExpand:a,onFocus:o})=>{let s=e.kind===`group`,c=s&&e.paths.length>1,l=e.kind===`outside`,u=(l?[e.label,KG(e)]:[e.label,s?GG(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,Y.jsxs)(`div`,{"data-slot":`overview-node-box`,className:X(`grid`,t===void 0?`relative`:`absolute`),style:t===void 0?{width:YG(e)}:{left:t.x,top:t.y,width:t.width,height:64},children:[(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`overview-node`,"data-risk":l?`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`,l?kG:OG[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":u,"aria-current":r?`location`:void 0,title:s?`${e.key.slice(6)}/`:e.paths.length===1?e.paths[0]:void 0,onClick:()=>i(e),onFocus:()=>o(e),onMouseEnter:()=>o(e),onMouseLeave:()=>o(null),children:[(0,Y.jsx)(`span`,{className:X(`flex min-w-0 items-baseline gap-2`,c&&`pr-6`),children:(0,Y.jsx)(`span`,{"data-slot":`overview-label`,className:`min-w-0 truncate font-mono text-code-compact font-semibold`,children:JG(e)})}),(0,Y.jsx)(`span`,{className:`truncate`,children:KG(e)}),e.badges.length>0&&(0,Y.jsx)(`span`,{className:`flex gap-1 overflow-hidden`,children:e.badges.map(e=>(0,Y.jsx)(`span`,{className:`shrink-0 rounded-sm border border-current px-1 font-mono text-kbd`,children:UG(e)},e))})]}),c&&(0,Y.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,Y.jsx)(Jg,{"aria-hidden":`true`})})]})},iK=({overview:e,focusKey:t,currentPath:n,onOpen:r,onExpand:i,onCollapse:a,expandedGroups:o,onFocusNode:s})=>{let c=(0,J.useId)(),l=(0,J.useRef)(null),[u,d]=(0,J.useState)(null),{boxes:f,width:p,height:m}=(0,J.useMemo)(()=>ZG(e.rows,e.edges.some(e=>e.back)),[e]),h=(0,J.useMemo)(()=>$G(e.edges,f),[e.edges,f]),g=(0,J.useMemo)(()=>new Map([...e.rows.flat(),...e.strip].map(e=>[e.key,e.label])),[e]),_=e=>g.get(e)??e,v=(0,J.useMemo)(()=>[...e.rows,e.strip].filter(e=>e.length>0),[e]);(0,J.useEffect)(()=>d(null),[e]);let y=(0,J.useRef)(-1);(0,J.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,Y.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Overview of the changed files`,ref:l,onKeyDown:x,children:[(0,Y.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,Y.jsx)(`p`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,Y.jsxs)($,{variant:`outline`,size:`sm`,onClick:()=>a(e),children:[`Collapse `,e.slice(6),`/`]},e))}),e.rows.length>0?(0,Y.jsx)(`div`,{"data-slot":`overview-scroll`,className:`overflow-x-auto rounded-lg border bg-surface-subtle`,children:(0,Y.jsxs)(`div`,{"data-slot":`overview-diagram`,className:`relative mx-auto`,style:{width:p,height:m},children:[(0,Y.jsxs)(`svg`,{className:`absolute inset-0 overflow-visible`,width:p,height:m,"aria-hidden":`true`,children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`marker`,{id:`${c}-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.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=eK(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,Y.jsxs)(`g`,{"data-slot":`overview-edge`,"data-style":QG(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,Y.jsx)(`path`,{d:r,className:`fill-none stroke-transparent [stroke-width:10]`}),(0,Y.jsx)(`path`,{d:r,className:X(`fill-none stroke-input [stroke-width:1.5]`,AG[QG(e)],i&&`stroke-primary [stroke-width:2]`),markerEnd:`url(#${c}-arrow)`}),(0,Y.jsx)(`title`,{children:nK(e,_)})]},`${e.from}>${e.to}`)})]}),e.rows.flat().map(e=>(0,Y.jsx)(rK,{box:f.get(e.key),...E(e)},e.key))]})}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`No changed file calls or imports another.`}),e.strip.length>0&&(0,Y.jsxs)(`section`,{"aria-label":`Not linked`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-caption font-medium text-muted-foreground`,children:`Not linked`}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.strip.map(e=>(0,Y.jsx)(rK,{...E(e)},e.key))})]}),(0,Y.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`?nK(u.edge,_):aK(u.node,e.edges,_)})]})},aK=(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(UG).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(UG).join(`, `)}`]:[]].join(` · `)}.`},oK=e=>`point-${e}`,sK={contradicts:`Contradicts what was asked`,missing:`Asked for, not done`,unrequested:`Done, not asked for`},cK={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},lK=({kind:e})=>{let t=DD[e];return(0,Y.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 font-medium`,cK[e]),children:[(0,Y.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),ED[e].label]})},uK=({point:e,state:t,current:n,note:r,action:i,className:a,leftOut:o=!1})=>{let s=DD[e.kind];return(0,Y.jsxs)(`article`,{id:oK(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&&SK),children:[(0,Y.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[ED[e.kind].label,`: `]}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 basis-40 truncate`,t===`dismissed`&&`line-through`),children:e.title}),(0,Y.jsx)(`span`,{className:`max-w-full min-w-0 truncate text-caption`,children:r}),i]})},dK=({effect:e,preferenceId:t})=>{let n=t===null?``:` your preference:`;return e===`raised`?`From${n}`:`Left out by${n}`},fK=({guidance:e,className:t})=>{let n=e.preferenceId===null?Sg:w_;return(0,Y.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,Y.jsx)(n,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[dK(e),` `,(0,Y.jsx)(Q_,{to:R_,className:X(`underline`,e.preferenceId===null&&`font-mono text-code-compact`),children:e.label})]})]})},pK=({point:e,guidance:t,state:n,current:r,onShow:i})=>(0,Y.jsx)(uK,{point:e,state:n,current:r,leftOut:!0,note:`${dK(t)} ${t.label}`,className:TK,action:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,"aria-label":`Show: ${e.title}`,onClick:i,children:`Show`})}),mK=(e,t,n)=>{let r=(0,J.useRef)(null),i=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{!e&&i.current&&(i.current=!1,r.current?.focus())},[e]),{card:r,show:()=>{i.current=!0,t(n)}}},hK=({point:e,size:t,disabled:n,onDismiss:r,onRule:i})=>(0,Y.jsxs)(`span`,{className:`flex items-center`,children:[(0,Y.jsxs)($,{variant:`ghost`,size:t,disabled:n,"aria-label":`Dismiss: ${e.title}`,className:`rounded-r-none`,onClick:r,children:[t===`sm`&&(0,Y.jsx)(I_,{"aria-hidden":`true`}),`Dismiss`]}),(0,Y.jsxs)(vB,{children:[(0,Y.jsx)(yB,{render:(0,Y.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,Y.jsx)(ig,{"aria-hidden":`true`})}),(0,Y.jsx)(bB,{align:`end`,className:`w-64`,children:(0,Y.jsxs)(CB,{onClick:i,children:[(0,Y.jsx)(wg,{"aria-hidden":`true`}),`Don't flag things like this…`]})})]})]}),gK=({point:e,scopes:t,onSave:n,onCancel:r})=>{let[i]=t;return i===void 0?null:(0,Y.jsxs)(`div`,{"data-slot":`point-rule`,className:`flex flex-col gap-2 rounded-md border bg-card p-3`,children:[(0,Y.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,Y.jsx)(FH,{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})]})},_K=(e,t)=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.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}}},vK=e=>e?(0,Y.jsxs)(Y.Fragment,{children:[`Dismissed, and saved to your`,` `,(0,Y.jsx)(Q_,{to:R_,className:`underline`,children:`preferences`})]}):`Dismissed`,yK={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`}},bK=({severity:e})=>(0,Y.jsxs)(`span`,{"data-slot":`severity`,className:X(gM,yK[e].className),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:yK[e].glyph}),e]}),xK=`animate-in duration-(--duration-slow) fade-in-0 slide-in-from-top-1`,SK=`shadow-[inset_0_0_0_2px_var(--ring)]`,CK=`relative max-w-3xl rounded-lg border bg-thread-bg`,wK=`scroll-mt-[calc(6rem+var(--lines-above)*var(--text-code--line-height))] -outline-offset-2`,TK=X(CK,`px-3 py-1.5`),EK={finding:`bg-review-changes`,risk:`bg-risk-contract-solid`},DK=({kind:e})=>(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`absolute top-2 bottom-2 left-1.5 w-[3px] rounded-full`,EK[e])}),OK=(0,J.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,family:h=`Claude`}){let g=(0,J.useId)(),{card:_,show:v}=mK(s,c,e.id),y=_K(e,u);if(t===`dismissed`)return(0,Y.jsx)(uK,{point:e,state:t,current:i,note:vK(y.saved),className:TK,action:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(t===`raised`&&d)return(0,Y.jsx)(uK,{point:e,state:t,current:i,note:`In your review, below`,className:`max-w-3xl px-1`,action:(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓`})});if(s&&e.guidance!==void 0)return(0,Y.jsx)(pK,{point:e,guidance:e.guidance,state:t,current:i,onShow:v});let b=r||n;return(0,Y.jsxs)(`article`,{ref:_,id:oK(e.id),"data-slot":`point`,"data-kind":`finding`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${g}-title`,tabIndex:-1,style:Ph({"--lines-above":m}),className:X(CK,wK,`flex flex-col gap-2 py-2.5 pr-4 pl-5`,i&&SK),children:[(0,Y.jsx)(DK,{kind:`finding`}),(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(lK,{kind:`finding`}),e.severity!==null&&(0,Y.jsx)(bK,{severity:e.severity}),(0,Y.jsx)(`span`,{className:X(gM,`border-review-pending/25 bg-review-pending-bg text-review-pending`),children:`Draft`}),e.lines!==null&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[`on`,` `,(0,Y.jsx)(xA,{children:bA(e.lines.side,e.lines.startLine,e.lines.line)})]}),(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,Y.jsx)(bg,{"aria-hidden":`true`,className:`size-3.5`}),`Only you see this`]})]}),(0,Y.jsx)(`h3`,{id:`${g}-title`,className:`font-semibold`,children:e.title}),e.explanation!==``&&(0,Y.jsx)(hM,{blocks:rf(e.explanation).blocks,suggestion:()=>null}),e.mismatch!==null&&(0,Y.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[sK[e.mismatch.kind],`:`]}),` `,e.mismatch.description]}),e.guidance!==void 0&&(0,Y.jsx)(fK,{guidance:e.guidance}),e.guardrail!==void 0&&(0,Y.jsx)(UU,{guardrail:e.guardrail,family:h}),e.suggestion!==null&&(0,Y.jsx)(hj,{title:`Suggested change`,removed:f,added:e.suggestion,language:p}),y.writing?(0,Y.jsx)(gK,{point:e,scopes:l,onSave:y.save,onCancel:()=>{y.setWriting(!1),_.current?.focus()}}):(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Y.jsx)(hK,{point:e,size:`sm`,disabled:b,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>y.setWriting(!0)}),e.lines!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,disabled:b,"aria-label":`Edit: ${e.title}`,onClick:()=>a(e,!1),children:[(0,Y.jsx)(o_,{"aria-hidden":`true`}),`Edit`]}),(0,Y.jsx)($,{size:`sm`,disabled:b,"aria-label":`Add to review: ${e.title}`,onClick:()=>a(e,!0),children:`Add to review`})]})]})]})}),kK=e=>e.slice(e.lastIndexOf(`/`)+1),AK=({checkedBy:e,peek:t,id:n})=>{let r=(0,Y.jsx)(`span`,{className:`font-code text-code-compact`,children:e.test});return(0,Y.jsxs)(`p`,{"data-slot":`checked-by`,className:`flex items-start gap-1.5 pb-0.5 text-muted-foreground`,children:[(0,Y.jsx)(Eg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:`Checked by`}),` `,t===null?r:(0,Y.jsx)(BM,{handle:t.handle,payload:t.payload,id:n,render:(0,Y.jsx)(`button`,{type:`button`,className:`text-left text-foreground`}),children:r}),` `,`in `,kK(e.path),`, which asserts: `,e.checks]})]})},jK=(0,J.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,family:p=`Claude`}){let m=(0,J.useId)(),{card:h,show:g}=mK(s,c,e.id),_=_K(e,u);if(t===`dismissed`)return(0,Y.jsx)(uK,{point:e,state:t,current:i,note:vK(_.saved),className:TK,action:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>o(e.id,`open`),children:`Undo`})});if(s&&e.guidance!==void 0)return(0,Y.jsx)(pK,{point:e,guidance:e.guidance,state:t,current:i,onShow:g});let v=r||n;return(0,Y.jsxs)(`article`,{ref:h,id:oK(e.id),"data-slot":`point`,"data-kind":`risk`,"data-state":t,"data-current":i||void 0,"aria-labelledby":`${m}-title`,tabIndex:-1,style:Ph({"--lines-above":d}),className:X(CK,wK,`flex flex-col gap-0.5 py-1.5 pr-2 pl-5`,i&&SK),children:[(0,Y.jsx)(DK,{kind:`risk`}),(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(lK,{kind:`risk`}),e.lines!==null&&(0,Y.jsx)(xA,{children:bA(e.lines.side,e.lines.startLine,e.lines.line)}),t===`raised`&&(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:v||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>a(e,!1),children:`Comment`}),(0,Y.jsx)(hK,{point:e,size:`xs`,disabled:v,onDismiss:()=>o(e.id,`dismissed`),onRule:()=>_.setWriting(!0)})]})]}),(0,Y.jsx)(`h3`,{id:`${m}-title`,className:`pb-0.5 font-normal`,children:e.title}),e.checkedBy!==void 0&&(0,Y.jsx)(AK,{checkedBy:e.checkedBy,peek:f,id:`${oK(e.id)}-test`}),e.guidance!==void 0&&(0,Y.jsx)(fK,{guidance:e.guidance,className:`pb-0.5`}),e.guardrail!==void 0&&(0,Y.jsx)(UU,{guardrail:e.guardrail,family:p,className:`pb-0.5`}),_.writing&&(0,Y.jsx)(`div`,{className:`py-1.5 pr-2`,children:(0,Y.jsx)(gK,{point:e,scopes:l,onSave:_.save,onCancel:()=>{_.setWriting(!1),h.current?.focus()}})})]})}),MK=({point:e,state:t,open:n,current:r,onToggle:i})=>{let a=DD.decision;return(0,Y.jsxs)(`button`,{type:`button`,id:oK(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(`mt-px ml-3 inline-flex min-h-5 scroll-mt-24 items-center gap-1 rounded-full border bg-background px-2 align-top font-sans text-caption text-muted-foreground hover:text-foreground`,t===`dismissed`&&`line-through`,r&&SK),onClick:t=>{t.stopPropagation(),i(e.id)},children:[(0,Y.jsx)(a,{"aria-hidden":`true`,className:`size-3`}),e.title]})},NK=({point:e,state:t,saving:n,readOnly:r,onRaise:i,onState:a})=>{let o=r||n;return(0,Y.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`,xK),children:[(0,Y.jsxs)(`p`,{className:`min-w-0 flex-1 basis-80 text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.title,`.`]}),` `,e.explanation]}),(0,Y.jsx)(`span`,{className:`flex items-center gap-1`,children:t===`dismissed`?(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:r,onClick:()=>a(e.id,`open`),children:`Show again`}):(0,Y.jsxs)(Y.Fragment,{children:[t===`raised`&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`✓ `}),`Commented`]}),(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:o||e.lines===null,"aria-label":`Comment: ${e.title}`,onClick:()=>i(e,!1),children:`Comment`}),(0,Y.jsx)($,{variant:`ghost`,size:`xs`,disabled:o,"aria-label":`Hide: ${e.title}`,onClick:()=>a(e.id,`dismissed`),children:`Hide`})]})})]})},PK=({point:e,onGo:t})=>{let n=DD[e.kind];return(0,Y.jsxs)(`p`,{"data-slot":`point-mention`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Y.jsx)(n,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),ED[e.kind].label,`:`,` `,(0,Y.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})]})},FK=({pointId:e,fresh:t,at:n,row:r=!1,className:i,bodyClassName:a,children:o})=>(0,Y.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:Ph({"--landing-i":n}),className:i,children:(0,Y.jsx)(`div`,{role:r?`cell`:void 0,children:(0,Y.jsx)(`div`,{className:a,children:o})})}),IK={finding:[`finding`,`findings`],risk:[`risk`,`risks`],decision:[`decision`,`decisions`]},LK=({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,J.useRef)(!1),[c,l]=t===null?[`point`,`points`]:IK[t];return(0,Y.jsx)(IH,{title:`${o.length} ${o.length===1?c:l} from ${a}`,onClose:i,returnFocus:()=>!s.current,className:`sm:max-w-2xl`,children:(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-1`,"aria-label":`Points`,children:o.map(e=>{let{label:t}=ED[e.kind],i=DD[e.kind],a=n(e.id);return(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(i,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[t,`: `]}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,a===`dismissed`&&`line-through`),children:e.title}),a!==`open`&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:a===`raised`?`Raised`:`Dismissed`}),e.path!==null&&(0,Y.jsx)(`span`,{className:`truncate font-mono text-code-compact text-muted-foreground`,children:e.path})]})},e.id)})})})},RK=(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}},zK=(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},BK=(e,t,n)=>{if(t===null)return null;let r=RK(e,t,n);return r.at===null?r.steps[0]?.id??null:null},VK={finding:`findings`,risk:`risks`,decision:`decisions`},HK={finding:`text-review-changes`,risk:`text-risk-contract`,decision:`text-muted-foreground`},UK=({kind:e})=>{let t=DD[e];return(0,Y.jsx)(t,{"aria-hidden":`true`,className:X(`size-3.5 shrink-0`,HK[e])})},WK=({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,Y.jsxs)(`span`,{"data-slot":e,className:`flex min-w-0 items-center gap-0.5`,children:[(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Previous ${t}`,disabled:n===0,onClick:()=>s(-1),children:(0,Y.jsx)(og,{"aria-hidden":`true`})}),(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:`tabular`,"aria-label":r===null?`${i}, show all`:`${u} ${l}, show all`,onClick:c,children:l}),(0,Y.jsx)($,{variant:`ghost`,size:`icon-xs`,"aria-label":`Next ${t}`,disabled:n===0,onClick:()=>s(1),children:(0,Y.jsx)(cg,{"aria-hidden":`true`})}),a,(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:o})]})},GK=({points:e,current:t,stateOf:n,kind:r,onGo:i,onOpenList:a})=>{let o=RK(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} ${VK[r]}`,d=l!==void 0&&n(l.id)===`dismissed`;return(0,Y.jsx)(WK,{slot:`point-stepper`,noun:`point`,total:s.length,at:c,count:u,onStep:e=>{let t=zK(o,e);t!==null&&i(t)},onOpenList:a,title:l!==void 0&&(0,Y.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 ${ED[l.kind].label.toLowerCase()}: ${l.title}`,onClick:()=>i(l.id),children:[(0,Y.jsx)(UK,{kind:l.kind}),(0,Y.jsx)(`span`,{className:X(`min-w-0 truncate`,d&&`text-muted-foreground line-through`),children:l.title})]}),status:l===void 0||c===null?``:`${ED[l.kind].label} ${c+1} of ${s.length}: ${l.title}${d?` (dismissed)`:``}`})},KK={collect:`Collect`,prep:`Prepare`,intent:`Intent`,findings:`Findings`,risk:`Risk`,decisions:`Decisions`,steps:`Tour`},qK={pending:`waiting`,running:`running`,done:`done`,failed:`failed`,skipped:`skipped`},JK={pending:`text-muted-foreground`,running:`text-primary font-medium`,done:`text-review-approved`,failed:`text-destructive font-medium`,skipped:`text-muted-foreground`},YK={pending:`○`,running:`◐`,done:`●`,failed:`✗`,skipped:`–`},XK=({stages:e,shown:t,filesFetched:n})=>(0,Y.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,Y.jsxs)(`li`,{"data-status":r,className:JK[r],children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:YK[r]}),` `,KK[t],(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`: `,qK[r]]}),t===`collect`&&r===`running`&&n!==null&&(0,Y.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[` `,`· `,n.done,` of `,n.total,` files`]})]},t)})}),ZK=e=>KK[e],QK=Mu.options.filter(e=>!Zu.includes(e)&&e!==`steps`),$K=({legend:e,options:t,value:n,onChange:r})=>(0,Y.jsxs)(`fieldset`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:e}),t.map(e=>(0,Y.jsx)(QM,{variant:`outline`,size:`sm`,pressed:n===e.value,disabled:e.disabled===!0,onPressedChange:t=>{t&&r(e.value)},children:e.label},e.value))]}),eq=[{value:`comment`,label:`Comment`},{value:`approve`,label:`Approve`},{value:`request_changes`,label:`Request changes`}],tq=`whitespace-pre-wrap wrap-anywhere`,nq=(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`}`},rq=({analysisId:e,hunkComments:t,isAuthor:n,published:r,onClose:i,onPublished:a})=>{let{client:o}=Pp(),s=(0,J.useId)(),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(`comment`),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),[b]=(0,J.useState)(()=>uf.parse(crypto.randomUUID())),x=Hp(o.publish);(0,J.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=nq(S,f?.comments.length??t.length),w=f!==null&&df({...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,S):r.error.code===`stale-analysis`&&(x.reset(),_(!0))};return(0,Y.jsxs)(IH,{title:`Publish review`,onClose:i,className:`flex flex-col sm:max-w-2xl`,children:[r&&(0,Y.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,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Reading the comments…`}):f.comments.length>0&&(0,Y.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,Y.jsx)(`ul`,{"aria-label":`Comments`,className:`flex flex-col gap-1.5`,children:f.comments.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 border-l-2 border-l-review-pending py-0.5 pl-2.5`,children:[(0,Y.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,Y.jsx)(`p`,{className:tq,children:e.body})]},e.key))})}):(0,Y.jsxs)(`p`,{className:dF,role:`alert`,children:[`Couldn't read what will be posted. `,Gp(m)]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`Verdict`}),(0,Y.jsx)($K,{legend:`Verdict`,options:eq.map(e=>({...e,disabled:n&&e.value!==`comment`})),value:S,onChange:d})]}),n&&(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`label`,{htmlFor:`${s}-summary`,className:`sr-only`,children:`Summary`}),(0,Y.jsx)(Vk,{id:`${s}-summary`,rows:2,"data-autofocus":!0,placeholder:`Summary (optional)`,value:c,onChange:e=>l(e.target.value)})]}),g?(0,Y.jsxs)(`div`,{className:X(fF,`flex flex-col gap-2`),role:`alert`,children:[(0,Y.jsx)(`p`,{children:`This PR changed since the analysis. Publish anyway?`}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,onClick:()=>_(!1),children:`Cancel`}),(0,Y.jsx)($,{onClick:()=>void T(!0),children:`Publish anyway`})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[x.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't publish. `,Gp(x.error)]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Retrying is safe: comments that were already posted aren't posted again.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[w&&(0,Y.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,Y.jsx)($,{variant:`outline`,onClick:i,children:`Cancel`}),(0,Y.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`})]})]})]})]})},iq=({children:e})=>(0,Y.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}),aq=({analysisId:e,family:t,onRemoved:n})=>{let{client:r}=Pp(),i=Hp(r.removeModelRun),[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{variant:`ghost`,size:`xs`,onClick:()=>o(!0),children:`Remove AI review…`}),a&&(0,Y.jsxs)(IH,{title:`Remove AI review`,onClose:()=>{o(!1),i.reset()},children:[(0,Y.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,Y.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. `,Gp(i.error)]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:()=>o(!1),children:`Cancel`}),(0,Y.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`})]})]})]})},oq=({analysisId:e,view:t,family:n,chosen:r,tour:i,onClose:a,onRestart:o})=>{let{client:s}=Pp(),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),m=async()=>{l(!0),d(null);let n=f;if(n===null){let t=await s.removeModelRun(e);if(!t.ok)return l(!1),d({error:t.error,removed:!1});n=t.value,p(n)}let a=await s.runModel(e,{optionId:r.id,...i?{tour:!0}:{}});if(!a.ok)return l(!1),d({error:a.error,removed:!0});let c=await s.getAnalysis(e);o(c.ok?c.value:{...t,...n})},h=()=>{f===null?a():o({...t,...f})};return(0,Y.jsxs)(IH,{title:`Re-run AI review`,onClose:h,children:[(0,Y.jsxs)(`p`,{className:`text-ui`,children:[n,`'s intent, findings, risks and decisions go, with what you did with them, and`,` `,r.modelName,` through `,r.via,` reads the PR again. Your comments stay.`]}),u!==null&&(0,Y.jsxs)(`p`,{className:`rounded-lg border border-review-changes/25 bg-review-changes-bg px-3 py-2 text-review-changes`,role:`alert`,children:[u.removed?`The old run is gone, but the new one couldn't start.`:`Couldn't remove the old run.`,` `,Gp(u.error)]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)($,{variant:`outline`,"data-autofocus":!0,onClick:h,children:f===null?`Cancel`:`Close`}),(0,Y.jsx)($,{variant:`ai`,disabled:c,onClick:()=>void m(),children:c?`Starting…`:u?.removed?`Try again`:`Re-run`})]})]})},sq=()=>{let e=(0,J.useRef)(null),[t,n]=(0,J.useState)(!1);return(0,J.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}},cq=({title:e,claude:t,tools:n,publish:r,verdict:i,hairline:a,stuck:o})=>{let s=sq(),c=o??s.stuck;return(0,Y.jsxs)(`div`,{ref:s.bar,"data-slot":`review-bar`,"data-stuck":c||void 0,className:`sticky top-0 z-20 flex h-(--review-bar-row,var(--review-bar-h)) min-w-0 items-center gap-3 border-y bg-background`,children:[a!==null&&(0,Y.jsx)(`span`,{"data-slot":`model-hairline`,"data-state":a,"aria-hidden":`true`,children:(0,Y.jsx)(`span`,{})}),c&&e!==null&&(0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`flex max-w-96 shrink items-center gap-3 max-xl:hidden`,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold motion-safe:animate-in motion-safe:fade-in`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`h-4.5 w-px shrink-0 bg-border`})]}),(0,Y.jsx)(`div`,{"data-slot":`claude-slot`,className:`flex min-w-0 flex-1 items-center`,children:t}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n}),i!==null&&(0,Y.jsxs)(`p`,{role:`status`,"data-slot":`your-verdict`,className:X(`flex shrink-0 items-center gap-1 font-medium`,lq[i.kind].className),children:[(0,Y.jsx)(uq,{kind:i.kind}),i.url===null?lq[i.kind].label:(0,Y.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,className:`text-inherit`,children:lq[i.kind].label})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]})},lq={approved:{label:`Approved`,className:`text-review-approved`},"changes-requested":{label:`Changes requested`,className:`text-review-changes`},commented:{label:`Commented`,className:`text-muted-foreground`},published:{label:`Published`,className:`text-review-approved`}},uq=({kind:e})=>(0,Y.jsx)(e===`changes-requested`?I_:e===`commented`?n_:ng,{"aria-hidden":`true`,className:`size-4`}),dq=2,fq=()=>(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-border`}),pq=({error:e,onRetry:t})=>(0,Y.jsxs)(PN,{children:[(0,Y.jsx)(FN,{render:(0,Y.jsx)($,{variant:`ghost`,size:`xs`,className:`h-6 px-1.5 font-normal text-muted-foreground`,"data-slot":`status-unavailable`,children:`Status unavailable`})}),(0,Y.jsxs)(IN,{align:`end`,children:[(0,Y.jsx)(LN,{children:`The PR's status couldn't be read`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:Gp(e)}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:`self-start`,onClick:t,children:`Try again`})]})]}),mq={github:`GitHub`,bitbucket:`Bitbucket`},hq=({name:e})=>(0,Y.jsx)(`code`,{className:`rounded-sm bg-secondary px-1 font-mono text-code-compact text-foreground`,children:e}),gq=({view:e,intent:t,totals:n,status:r,statusError:i,onRetryStatus:a,now:o})=>{let{analysis:s}=e,{pullRequest:c,warnings:l}=s,{ref:u}=s.key,d=[r===null&&i!==null&&(0,Y.jsx)(pq,{error:i,onRetry:a},`unavailable`),r!==null&&(r.checks===null||r.checks.length>0)&&(0,Y.jsx)(GN,{checks:r.checks,unreadable:r.checksUnreadable,head:s.key.headSha},`ci`),r!==null&&r.reviewers.length>0&&(0,Y.jsx)(ZN,{reviewers:r.reviewers},`reviewers`)].filter(e=>e!==!1).flatMap((e,t)=>t===0?[e]:[(0,Y.jsx)(fq,{},`before-${e.key}`),e]);return(0,Y.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`h1`,{className:`min-w-0 text-title font-semibold tracking-[-0.01em] whitespace-pre-line`,children:c?.title??`Collecting the pull request…`}),(0,Y.jsxs)(`a`,{className:`-ml-1.5 text-title text-muted-foreground no-underline hover:underline`,href:c?.url??jf(u),target:`_blank`,rel:`noreferrer`,title:`Open on ${mq[u.repo.host]}`,children:[`#`,u.number]}),r!==null&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zN,{state:r.state}),(0,Y.jsx)(BN,{status:r.reviewStatus})]}),d.length>0&&(0,Y.jsx)(`div`,{"data-slot":`pr-standing`,className:`ml-auto flex flex-wrap items-center gap-x-3 gap-y-1`,children:d})]}),(0,Y.jsxs)(`p`,{"data-slot":`pr-byline`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:u.repo.repo}),c!==null&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:c.author.name}),` wants to merge `,(0,Y.jsx)(hq,{name:c.sourceBranch}),` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),` `,(0,Y.jsx)(`span`,{className:`sr-only`,children:`into`}),` `,(0,Y.jsx)(hq,{name:c.targetBranch})]}),` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`span`,{children:[`updated `,vA(c.updatedAt,o)]})]}),s.stages.prep===`done`&&n.additions+n.deletions>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` `,(0,Y.jsxs)(`span`,{className:`tabular font-mono text-code-compact`,children:[(0,Y.jsxs)(`span`,{"aria-hidden":`true`,children:[n.additions>0&&(0,Y.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,n.additions]}),n.additions>0&&n.deletions>0&&` `,n.deletions>0&&(0,Y.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,n.deletions]})]}),(0,Y.jsxs)(`span`,{className:`sr-only`,children:[n.additions,` lines added, `,n.deletions,` removed`]})]})]})]}),(0,Y.jsx)(`div`,{className:`mt-3 max-w-[980px]`,children:t}),l.length>0&&l.length<=dq&&(0,Y.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`Warnings`,children:l.map(e=>(0,Y.jsxs)(`li`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),e]},e))}),l.length>dq&&(0,Y.jsxs)(`details`,{className:`rounded-lg border border-review-pending/25 bg-review-pending-bg px-3 py-2 text-review-pending`,children:[(0,Y.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),l.length,` warnings`]}),(0,Y.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:l.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]})]})},_q=e=>`thread-${e}`,vq=e=>`${e.side}:${e.line}`,yq={onLine:new Map,earlier:new Map,elsewhere:[],open:new Map},bq=(e,t,n)=>e.set(t,[...e.get(t)??[],n]),xq=(e,t,n)=>{if(e===null||e.length===0)return yq;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=kM(e);return n!==null&&n.side===t.side&&n.line===c}));if(l===void 0||c===null){bq(a,t.path,t);continue}let u=i.get(l)??new Map;bq(u,vq({side:t.side,line:c}),t),i.set(l,u)}return{onLine:i,earlier:a,elsewhere:o,open:s}},Sq=(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},Cq=(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=kM(e);if(t===null)continue;let n=vq(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},wq=(e,t,n)=>t===`all`?e:e.filter(e=>!e.resolved||n.has(e.id)),Tq=(e,t,n)=>e===null?wq(t,`unresolved`,n).length>0?`unresolved`:`all`:e,Eq=(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},Dq=(e,t,n)=>`${e} ${e===1?t:n}`,Oq=e=>(e.line??e.originalLine)===null?`the file`:yM(e.outdated?{...e,line:null}:e),kq=e=>{let[t]=e.comments;if(t===void 0)return Oq(e);let n=Vd(t.body);return`${t.author.name}: ${n===``?`Suggested change`:n}`},Aq=(e,t)=>e===`unresolved`?`${t} unresolved`:Dq(t,`thread`,`threads`),jq=(e,t,n)=>{if(e.length===0)return null;let r=wq(e,t,n).length;return t===`unresolved`?{count:r,words:[`unresolved`,`unresolved`],label:Dq(r,`unresolved thread`,`unresolved threads`)}:{count:r,words:[`thread`,`threads`],label:Dq(r,`thread`,`threads`)}},Mq=({resolved:e})=>e?(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-review-approved`}):(0,Y.jsx)(n_,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),Nq=({ordered:e,scope:t,resolvedHere:n,current:r,onGo:i,onOpenList:a})=>{let o=wq(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?``:kq(l);return(0,Y.jsx)(WK,{slot:`thread-stepper`,noun:`thread`,total:o.length,at:c,count:Aq(t,o.length),onStep:t=>{let n=Eq(e,o,r,t);n!==null&&i(n)},onOpenList:a,title:l!==void 0&&(0,Y.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}, ${Oq(l)}`,"aria-label":`Go to thread: ${u}`,onClick:()=>i(l.id),children:[(0,Y.jsx)(Mq,{resolved:l.resolved}),(0,Y.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} ${Oq(l)}${l.resolved?`, resolved`:l.outdated?`, outdated`:``}: ${u}`})},Pq=({ordered:e,scope:t,onScope:n,onGo:r,onClose:i})=>{let a=e.filter(e=>!e.resolved).length,o=(0,J.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,Y.jsxs)(IH,{title:`${Dq(e.length,`thread`,`threads`)}, ${a} unresolved`,onClose:i,returnFocus:()=>!o.current,className:`sm:max-w-2xl`,children:[a>0&&a<e.length&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-caption text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`Previous and Next go round`}),(0,Y.jsx)($K,{legend:`Previous and Next go round`,options:[{value:`unresolved`,label:`Unresolved (${a})`},{value:`all`,label:`All (${e.length})`}],value:t,onChange:n})]}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:s.map(({path:e,threads:t})=>(0,Y.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h3`,{className:`truncate px-2 font-mono text-code-compact text-muted-foreground`,children:e}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(Mq,{resolved:e.resolved}),(0,Y.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,e.resolved&&`text-muted-foreground`),children:kq(e)}),(e.resolved||e.outdated)&&(0,Y.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:e.resolved?`Resolved`:`Outdated`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:Oq(e)})]})},e.id))})]},t[0]?.id??e))})]})},Fq={steps:`The rest of the steps' files`,tests:`Tests`,generated:`Generated and mechanical`,other:`Other files`},Iq=(e,t=0,n=e.lines.length)=>e.lines.slice(t,n).filter(e=>e.kind!==`context`).length,Lq=(e,t)=>{let n=n=>{let r=e.lines[n];return t.side===`new`?r?.newLine:r?.oldLine},r=e.lines.flatMap((e,r)=>{let i=n(r);return i!=null&&i>=t.startLine&&i<=t.line?[r]:[]}),i=r[0],a=r.at(-1);return i===void 0||a===void 0?null:{start:i,end:a+1}},Rq=(e,t)=>e.start<t.end&&t.start<e.end,zq=(e,t,n,r=()=>`open`)=>{if(e.steps===null||e.steps.length<3)return null;let i=new Map(e.files.flatMap(e=>e.hunks.map(e=>[e.id,e]))),a=new Map(e.files.flatMap(e=>e.hunks.map(t=>[t.id,e]))),o=il(e.parts),s=new Map([...t.rows.flat(),...t.strip].map(e=>[e.key,e])),c=e=>t.placeOf.get(e)??gU(PI(e)),l=e=>s.get(e)?.label??(e.startsWith(`group:`)?e.slice(6):e),u=new Set,d=e.steps.map((e,t)=>{let r=e.excerpts.flatMap((t,n)=>{let r=i.get(t.hunkId),s=a.get(t.hunkId),c=r===void 0?null:Lq(r,t);if(r===void 0||s===void 0||c===null)return[];for(let e=c.start;e<c.end;e+=1)r.lines[e]?.kind!==`context`&&u.add(`${r.id}:${e}`);let l=o.get(r.id)?.find(e=>c.start>=e.start&&c.start<e.end)?.id??r.id;return[{key:`${e.id}:${n}`,path:s.path,hunkId:r.id,partId:l,lines:t,...c,shown:Iq(r,c.start,c.end),fileChanged:s.hunks.reduce((e,t)=>e+Iq(t),0)}]}),s=n.filter(e=>{if(e.guidance?.effect===`left-out`||e.lines===null)return!1;let{lines:t}=e,n=i.get(t.hunkId),a=n===void 0?null:Lq(n,t);return a!==null&&r.some(e=>e.hunkId===t.hunkId&&Rq(e,a))});return{id:e.id,number:t+1,sentence:e.sentence,boxes:[...new Set(r.map(e=>c(e.path)))],excerpts:r,points:[`finding`,`risk`,`decision`].flatMap(e=>s.filter(t=>t.kind===e))}}),f=[],p=[],m=(e,t)=>({key:`${e}#${t}`,directory:e,label:l(e),steps:[t]});for(let e of d){let[t,n]=e.boxes;if(t===void 0)continue;if(n!==void 0){let r=[m(t,e.number),m(n,e.number)];f.push(...r),p.push({step:e.number,keys:[r[0].key,r[1].key]});continue}let r=f.at(-1),i=r!==void 0&&p.some(e=>e.keys.includes(r.key));r!==void 0&&r.directory===t&&!i?f[f.length-1]={...r,steps:[...r.steps,e.number]}:f.push(m(t,e.number))}let h=new Set(f.map(e=>e.directory)),g=new Set(d.flatMap(e=>e.excerpts.map(e=>e.path))),_=new Set(e.proofs.flatMap(e=>e.hunkId??[])),v=new Set(e.generated),y=(e,t)=>g.has(e)?`steps`:ll(e)?`tests`:v.has(e)||t.length>0&&t.every(e=>_.has(e.id))?`generated`:`other`,b=(e,t)=>e.lines.filter((n,r)=>n.kind===t&&!u.has(`${e.id}:${r}`)).length,x=e.files.flatMap(e=>{let t=e.hunks.reduce((e,t)=>e+b(t,`add`),0),n=e.hunks.reduce((e,t)=>e+b(t,`del`),0),r=y(e.path,e.hunks);return r===`steps`&&t+n===0?[]:[{group:r,file:{path:e.path,added:t,deleted:n}}]}),S=[`steps`,`tests`,`generated`,`other`].flatMap(e=>{let t=x.filter(t=>t.group===e).map(e=>e.file);return t.length===0?[]:[{id:e,label:Fq[e],files:t}]}),C=new Map(x.map(e=>[e.file.path,e.group])),w=[...t.rows.flat(),...t.strip].filter(e=>e.kind===`group`&&!h.has(e.key)).map(e=>({key:e.key,directory:e.key,label:e.label,steps:[],group:e.paths.map(e=>C.get(e)).find(e=>e!==void 0)??null})),T=new Set(d.flatMap(e=>e.points.map(e=>e.id))),E=n.filter(e=>(e.kind===`finding`||e.kind===`risk`)&&e.guidance?.effect!==`left-out`&&!T.has(e.id)),D=e=>r(e)!==`dismissed`,O=d.filter(e=>e.points.some(e=>D(e)&&(e.kind===`finding`||e.kind===`risk`&&e.checkedBy===void 0))).map(e=>e.number),k=e.files.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+Iq(t),0),0);return{steps:d,boxes:f,spans:p,others:w,ledger:S,outside:E,depth:{read:O,findingsOutside:E.filter(e=>e.kind===`finding`&&D(e)).length,risksOutside:E.filter(e=>e.kind===`risk`&&D(e)).length},shown:u.size,total:k}},Bq=e=>{let t=e.stages.steps;return t===`running`||t===`pending`?{kind:`writing`}:t===`failed`?{kind:`failed`,message:e.stepsError?.message??`The tour pass failed`}:t===`done`?(e.steps??[]).length<3?{kind:`too-small`}:null:id(e)?{kind:`without-tour`}:{kind:`no-review`}},Vq=(e,t)=>`${e} ${e===1?t:`${t}s`}`,Hq=e=>e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`,Uq=e=>{let{read:t,findingsOutside:n,risksOutside:r}=e,i=t.length===0?`No step has an open finding or a risk no test checks.`:`Read ${t.length===1?`step`:`steps`} ${Hq(t)} in the code: ${t.length===1?`it has`:`each has`} an open finding or a risk no test checks.`,a=[...n>0?[Vq(n,`finding`)]:[],...r>0?[Vq(r,`risk`)]:[]];if(a.length===0)return i;let o=a.length>1||n+r>1;return`${i} ${a.join(` and `)} ${o?`are`:`is`} outside the steps.`},Wq=36,Gq=28,Kq=e=>e.endsWith(`/`)?e.slice(0,-1):e,qq=e=>t=>t.length<=e,Jq=e=>{let t=Kq(e),n=t.lastIndexOf(`/`);return n===-1?{prefix:``,name:t||e}:{prefix:`${AI(t.slice(0,n),qq(29))}/`,name:t.slice(n+1)}},Yq=e=>{let t=e.map(e=>AI(Kq(e),qq(Wq)));return t.map((n,r)=>t.some((e,t)=>t!==r&&e===n)?Kq(e[r]??n):n)},Xq=e=>{let t=e=>e.includes(`/`)?e.slice(0,e.indexOf(`/`)):``,n=[...new Set(e.map(t).filter(e=>e.includes(`.`)))],[r,...i]=n.map(e=>e.split(`.`));if(r===void 0||i.length===0)return[...e];let a=0;for(;[r,...i].every(e=>e.length>a+1&&e[a]===r[a]);)a+=1;return e.map(e=>{let r=t(e);return n.includes(r)?r.split(`.`).slice(a).join(`.`)+e.slice(r.length):e})},Zq=e=>{let t=e.map(e=>Kq(e).split(`/`));return Xq(t.map(e=>{let n=e.join(`/`);for(let r=1;r<e.length;r+=1){let i=e.slice(-r).join(`/`);if(!t.some(e=>e.join(`/`)!==n&&e.slice(-r).join(`/`)===i))return i}return n})).map(e=>AI(e,qq(Gq)))},Qq=e=>`tour-step-${e}`,$q=e=>`tour-ledger-${e}`,eJ=`tour-end-title`,tJ=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,nJ=e=>{let{startLine:t,line:n,side:r}=e.lines,i=t===n?`line ${n}`:`lines ${t}–${n}`;return r===`old`?`base ${i}`:i},rJ=({number:e,current:t})=>(0,Y.jsx)(`span`,{className:X(`inline-flex size-5 shrink-0 items-center justify-center rounded-full border-[1.5px] border-primary font-semibold text-caption tabular-nums`,t?`bg-primary text-primary-foreground`:`text-primary`),children:e}),iJ=({box:e,current:t,compactName:n,focusable:r,onGo:i})=>{let a=n!==void 0,o=t!==null&&e.steps.includes(t),{prefix:s,name:c}=Jq(e.label);return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-box`,"aria-label":`${e.label}, ${e.steps.length===1?`step`:`steps`} ${Hq(e.steps)}${o?`, current step`:``}`,title:e.label,...o?{"aria-current":`step`}:{},...r?{}:{tabIndex:-1},onClick:i,className:X(`relative flex min-w-0 shrink-0 cursor-pointer rounded-lg text-left`,a?`max-w-md items-center gap-1.5 px-2 py-1`:`max-w-60 min-w-36 flex-col items-stretch gap-0.5 px-2.5 py-2`,o?`border-2 border-primary bg-background`:`border border-primary bg-ai-soft`),children:[!a&&s!==``&&(0,Y.jsx)(`span`,{className:`truncate font-mono text-caption text-muted-foreground`,children:s}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono font-semibold text-ui`,children:n??c}),(0,Y.jsx)(`span`,{className:`flex shrink-0 gap-1`,children:e.steps.map(e=>(0,Y.jsx)(rJ,{number:e,current:e===t},e))})]}),o&&(0,Y.jsx)(`span`,{className:X(`shrink-0 rounded-full bg-primary px-1.5 font-semibold text-caption text-primary-foreground`,!a&&`absolute -bottom-2.5 left-2`),children:`Current step`})]})},aJ=({tour:e,current:t,compact:n,focusable:r,onGoToStep:i})=>{let a=n?Zq(e.boxes.map(e=>e.label)):null,o=n=>{let o=e.boxes[n];if(o===void 0)return null;let s=a?.[n];return(0,Y.jsx)(iJ,{box:o,current:t,...s===void 0?{}:{compactName:s},focusable:r,onGo:()=>i(Math.min(...o.steps))},o.key)},s=[];for(let t=0;t<e.boxes.length;t+=1){let r=e.boxes[t];if(r===void 0)continue;let i=e.spans.find(e=>e.keys[0]===r.key);t>0&&s.push((0,Y.jsx)(cg,{"aria-hidden":`true`,className:`size-4 shrink-0 text-primary`},`arrow-${r.key}`)),i!==void 0&&e.boxes[t+1]!==void 0?(s.push((0,Y.jsxs)(`div`,{role:`group`,"aria-label":`Step ${i.step} spans both`,className:X(`flex min-w-0 items-center gap-1 rounded-xl border-[1.5px] border-dashed border-primary`,n?`px-1.5 py-1`:`flex-col items-start px-1.5 pt-1 pb-1.5`),children:[(0,Y.jsxs)(`span`,{className:`text-caption font-medium text-primary`,children:[`Step `,i.step,` spans both`]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[o(t),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`text-primary`,children:`+`}),o(t+1)]})]},`span-${r.key}`)),t+=1):s.push(o(t))}return s},oJ=({tour:e,current:t,onGoToStep:n,onGoToGroup:r})=>{let i=Yq(e.others.map(e=>e.label));return(0,Y.jsxs)(`div`,{"data-slot":`tour-strip`,role:`group`,"aria-label":`Directories on the tour`,className:`flex flex-col gap-3 border-b pt-3 pb-4`,children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-4`,children:(0,Y.jsx)(aJ,{tour:e,current:t,compact:!1,focusable:!0,onGoToStep:n})}),e.others.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`mr-1 text-caption text-muted-foreground`,children:`Not on the tour`}),e.others.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,"data-slot":`tour-box`,"aria-label":`${e.label}, no step, see Not in the tour`,title:e.label,onClick:()=>{e.group!==null&&r(e.group)},className:`max-w-full cursor-pointer truncate rounded-md border border-dashed border-input bg-background px-2 py-1 font-mono text-caption hover:bg-surface-row`,children:i[t]},e.key))]})]})},sJ=({tour:e,current:t,overlay:n,shown:r,onGoToStep:i,onGoToEnd:a})=>(0,Y.jsx)(`div`,{"data-slot":`tour-strip-compact`,...n?{"aria-hidden":!0}:{},className:X(`sticky top-(--review-bar-h) z-10`,n&&`h-0`),children:(0,Y.jsxs)(`div`,{role:`group`,"aria-label":`Directories on the tour`,className:X(`flex flex-wrap items-center gap-1.5 border-b bg-background px-1 py-2`,n?`absolute -inset-x-1 top-0`:`-mx-1`,n&&!r&&`invisible`),children:[(0,Y.jsx)(aJ,{tour:e,current:t,compact:!0,focusable:!n,onGoToStep:i}),e.others.length>0&&(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-off`,...n?{tabIndex:-1}:{},onClick:a,className:`ml-1 cursor-pointer rounded-md border border-dashed border-input bg-background px-2 py-1 text-caption text-muted-foreground hover:bg-surface-row`,children:[tJ(e.others.length,`directory`,`directories`),` not on the tour`]})]})}),cJ=({point:e,state:t,onOpen:n,wide:r=!1,after:i})=>{let a=ED[e.kind],o=DD[e.kind],s=t===`dismissed`;return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`tour-point`,onClick:n,className:X(`flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-1.5 text-left text-body`,r?`w-full max-w-4xl`:`w-fit max-w-full`,a.className),children:[(0,Y.jsx)(o,{"aria-hidden":`true`,className:`mt-1 size-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:a.label}),(0,Y.jsxs)(`span`,{className:X(`min-w-0`,s&&`line-through`),children:[(0,Y.jsx)(mW,{text:e.title}),s&&(0,Y.jsx)(`span`,{className:`sr-only`,children:`, dismissed`}),i]})]})},lJ=({step:e,current:t,stateOf:n,renderExcerpt:r,onOpenPoint:i,onOpenInCode:a})=>{let o=`${Qq(e.number)}-title`;return(0,Y.jsxs)(`section`,{id:Qq(e.number),"data-slot":`tour-step`,"aria-labelledby":o,...t?{"aria-current":`step`}:{},className:`grid grid-cols-[1.5rem_1fr] gap-x-2.5 border-b py-5 lg:grid-cols-[1.875rem_1fr]`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:X(`text-right font-semibold text-heading tabular-nums`,t?`text-primary`:`text-muted-foreground`),children:e.number}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,Y.jsxs)(`h2`,{id:o,tabIndex:-1,className:`font-semibold text-heading outline-none`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Step `,e.number,`: `]}),(0,Y.jsx)(mW,{text:e.sentence})]}),e.points.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.points.map(e=>(0,Y.jsx)(cJ,{point:e,state:n(e),onOpen:()=>i(e)},e.id))}),e.excerpts.map(t=>{let n=t.path.lastIndexOf(`/`)+1;return(0,Y.jsxs)(`div`,{"data-slot":`tour-card`,className:`mt-1 min-w-0 overflow-hidden rounded-lg border bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 font-mono text-code-compact`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.path.slice(0,n)}),(0,Y.jsx)(`span`,{className:`font-medium`,children:t.path.slice(n)})]}),(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[nJ(t),` · `,t.shown,` of`,` `,tJ(t.fileChanged,`changed line`)]}),(0,Y.jsxs)($,{variant:`ghost`,size:`sm`,className:`ml-auto text-primary`,"aria-label":`Open ${t.path} ${nJ(t)} in code`,onClick:()=>a(e,t),children:[(0,Y.jsx)(vg,{"aria-hidden":`true`}),`Open in code`]})]}),r(t)]},t.key)})]})]})},uJ=({added:e,deleted:t})=>(0,Y.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[e>0&&(0,Y.jsxs)(`span`,{className:`text-stat-add`,children:[`+`,e]}),e>0&&t>0&&` `,t>0&&(0,Y.jsxs)(`span`,{className:`text-stat-del`,children:[`−`,t]})]}),dJ=({tour:e,stateOf:t,openGroups:n,onToggleGroup:r,flashed:i,onOpenFile:a,onOpenPoint:o})=>{let s=e.ledger.reduce((e,t)=>e+t.files.length,0);return(0,Y.jsxs)(`section`,{"aria-labelledby":eJ,"data-slot":`tour-end`,className:`flex flex-col gap-5 py-6 lg:pl-10`,children:[(0,Y.jsx)(`h2`,{id:eJ,tabIndex:-1,className:`font-semibold text-heading outline-none`,children:`After the tour`}),e.ledger.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`h3`,{className:`font-semibold text-body`,children:[`Not in the tour`,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,tJ(s,`file`)]})]}),e.ledger.map(e=>{let t=e.files.reduce((e,t)=>e+t.added,0),o=e.files.reduce((e,t)=>e+t.deleted,0);return(0,Y.jsxs)(`details`,{id:$q(e.id),open:n.has(e.id),onToggle:t=>r(e.id,t.currentTarget.open),className:X(`group max-w-3xl rounded-lg border bg-card`,i===e.id&&`border-primary ring-2 ring-ai-soft-bd`),children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-body [&::-webkit-details-marker]:hidden`,children:[(0,Y.jsx)(cg,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-open:rotate-90`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,Y.jsxs)(`span`,{className:`ml-auto text-ui text-muted-foreground`,children:[tJ(e.files.length,`file`),` ·`,` `,(0,Y.jsx)(uJ,{added:t,deleted:o})]})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col border-t py-1`,children:e.files.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e.path),className:`flex w-full cursor-pointer items-center gap-3 px-3 py-1 text-left hover:bg-surface-row`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-code-compact`,children:e.path}),(0,Y.jsx)(uJ,{added:e.added,deleted:e.deleted})]})},e.path))})]},e.id)})]}),e.outside.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-body`,children:`Findings and risks outside the steps`}),e.outside.map(e=>(0,Y.jsx)(cJ,{point:e,state:t(e),wide:!0,onOpen:()=>o(e),after:e.path===null?null:(0,Y.jsxs)(`span`,{className:`font-mono text-code-compact`,children:[` `,`· `,e.path.slice(e.path.lastIndexOf(`/`)+1)]})},e.id))]}),(0,Y.jsxs)(`div`,{"data-slot":`tour-depth`,className:`flex max-w-4xl items-start gap-2 rounded-lg border border-ai-soft-bd bg-ai-soft px-4 py-3 text-body`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`mt-1 size-4 shrink-0 text-primary`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:`Suggested depth`}),(0,Y.jsx)(`p`,{children:Uq(e.depth)})]})]})]})},fJ=e=>({top:e===null?0:Number.parseFloat(getComputedStyle(e).top)||0,height:e?.firstElementChild?.getBoundingClientRect().height??0}),pJ=(e,t,n)=>{let[r,i]=(0,J.useState)(n>0?1:null),[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(null),c=(0,J.useCallback)(e=>{s.current=e,i(e)},[]);return(0,J.useEffect)(()=>{let e=()=>{s.current=null},t=[`wheel`,`touchmove`,`keydown`,`pointerdown`];for(let n of t)window.addEventListener(n,e,{passive:!0});return()=>{for(let n of t)window.removeEventListener(n,e)}},[]),(0,J.useEffect)(()=>{let n=0,r=()=>{n=0;let r=e.current,a=t();if(r===null||a===null)return;let{top:c,height:l}=fJ(a),u=a.getBoundingClientRect().top,d=u+l+8,f=[...r.querySelectorAll(`[data-slot=tour-step]`)],p=f.length>0?1:null;f.forEach((e,t)=>{e.getBoundingClientRect().top<=d&&(p=t+1)}),s.current===null&&i(p),o(window.scrollY>0&&Math.abs(u-c)<=1)},a=()=>{n===0&&(n=window.requestAnimationFrame(r))};return r(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,a),()=>{window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a),n!==0&&window.cancelAnimationFrame(n)}},[e,t]),{current:r,stuck:a,pin:c}},mJ=()=>{let e=`(max-width: 1179px)`,[t,n]=(0,J.useState)(()=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches);return(0,J.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t},hJ=({tour:e,stateOf:t,renderExcerpt:n,onOpenPoint:r,onOpenFile:i,onOpenInCode:a,onCurrentStep:o,landOn:s=null})=>{let c=(0,J.useRef)(null),l=(0,J.useCallback)(()=>c.current?.querySelector(`[data-slot=tour-strip-compact]`)??null,[]),{current:u,stuck:d,pin:f}=pJ(c,l,e.steps.length),p=mJ(),[m,h]=(0,J.useState)(new Set),[g,_]=(0,J.useState)(null),v=(0,J.useRef)(o);v.current=o,(0,J.useEffect)(()=>v.current?.(u),[u]);let y=(0,J.useCallback)(e=>{let{top:t,height:n}=fJ(l()),r=window.scrollY+e.getBoundingClientRect().top-t-n-4;window.scrollTo({top:Math.max(0,r),behavior:`instant`})},[l]),[b,x]=(0,J.useState)(null),S=(0,J.useCallback)(e=>{x(t=>({step:e,n:(t?.n??0)+1}))},[]);(0,J.useLayoutEffect)(()=>{if(b===null)return;let e=document.getElementById(Qq(b.step));if(e!==null)return y(e),e.querySelector(`h2`)?.focus({preventScroll:!0}),f(b.step),oW(`[data-slot=understand]`,()=>y(e))},[b,y,f]);let C=()=>{let e=document.getElementById(eJ);e!==null&&(y(e),e.focus({preventScroll:!0}))},w=e=>{h(t=>new Set([...t,e])),_(e),window.setTimeout(()=>_(t=>t===e?null:t),1600);let t=document.getElementById($q(e));t!==null&&(y(t),t.querySelector(`summary`)?.focus({preventScroll:!0}))},T=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(s===null||T.current===s.n)return;if(T.current=s.n,s.step>0)return S(s.step);let e=c.current;if(e===null)return;let t=document.querySelector(`[data-slot=review-bar]`)?.getBoundingClientRect().height??0,n=window.scrollY+e.getBoundingClientRect().top-t-8;window.scrollTo({top:Math.max(0,n),behavior:`instant`})},[s,S]),(0,Y.jsxs)(`div`,{ref:c,"data-slot":`understand`,className:`flex min-w-0 flex-col`,children:[!p&&(0,Y.jsx)(oJ,{tour:e,current:u,onGoToStep:S,onGoToGroup:w}),(0,Y.jsx)(sJ,{tour:e,current:u,overlay:!p,shown:d,onGoToStep:S,onGoToEnd:C}),(0,Y.jsxs)(`section`,{className:`max-w-[73.75rem]`,"aria-label":`Tour steps`,children:[e.steps.map(e=>(0,Y.jsx)(lJ,{step:e,current:e.number===u,stateOf:t,renderExcerpt:n,onOpenPoint:r,onOpenInCode:a},e.id)),(0,Y.jsx)(dJ,{tour:e,stateOf:t,openGroups:m,onToggleGroup:(e,t)=>h(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),flashed:g,onOpenFile:i,onOpenPoint:r})]})]})},gJ=({children:e,busy:t})=>(0,Y.jsxs)(`p`,{"data-slot":`no-tour`,...t?{role:`status`}:{},className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,Y.jsx)(E_,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),e]}),_J=`tour-landing`,vJ=({step:e,excerpt:t})=>(0,Y.jsxs)(`p`,{id:_J,"data-slot":`tour-landing`,className:`scroll-mt-24 flex flex-wrap items-center gap-x-1.5 border-b bg-ai-soft px-3 py-1.5 text-ui text-primary`,children:[(0,Y.jsx)(f_,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`font-semibold`,children:[`Tour step `,e.number]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{children:nJ(t)}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-foreground`,children:(0,Y.jsx)(mW,{text:e.sentence})})]}),yJ=({step:e,onBack:t,onDismiss:n})=>(0,Y.jsxs)(`div`,{"data-slot":`back-to-tour`,className:`sticky top-(--review-bar-row) z-20 -mt-px flex h-9 items-center gap-2 border-b bg-background`,children:[(0,Y.jsxs)($,{variant:`outline`,size:`sm`,className:`border-ai-soft-bd bg-ai-soft text-primary hover:bg-ai-soft-hover`,onClick:t,children:[(0,Y.jsx)(Xh,{"aria-hidden":`true`}),`Back to tour · Step `,e]}),(0,Y.jsx)($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Hide Back to tour`,onClick:n,children:(0,Y.jsx)(I_,{"aria-hidden":`true`})})]}),bJ=.25,xJ=(e,t,n)=>{let r=n?t-1:t*bJ;return(e.findLast(e=>e.top<=r)??e[0])?.path??null},SJ=()=>{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}))},CJ=(e,t)=>{let[n,r]=(0,J.useState)(null),i=e.join(`\0`);return(0,J.useEffect)(()=>{if(!t)return;let e=0,n=()=>{e=0;let t=document.documentElement,n=window.scrollY+window.innerHeight>=t.scrollHeight-2,i=SJ();if(i===null)return;let a=xJ(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},wJ=`[aria-label=Changes]`,TJ=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},EJ=e=>`✓ ${e} is done`,DJ=new Set,OJ=new Map,kJ=(e,t,n=`Claude`)=>{let[r,i]=(0,J.useState)({running:e,before:DJ}),[a,o]=(0,J.useState)(`done`),[s,c]=(0,J.useState)(OJ),[l,u]=(0,J.useState)(0);e!==r.running&&(i({running:e,before:e?new Set(t):r.before}),o(e?`done`:`measure`),c(OJ),e||u(l+1)),(0,J.useEffect)(()=>{if(l===0||!document.hidden)return;let e=document.title;document.title=`${EJ(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,J.useRef)(null);(0,J.useLayoutEffect)(()=>{if(a!==`measure`)return;if(d.current=rW(wJ),TJ(`--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=Su.safeParse(t.dataset.pointId);r.success&&n>=0&&n<window.innerHeight&&e.set(r.data,e.size)}c(e),o(`landing`)},[a]),(0,J.useLayoutEffect)(()=>{a!==`measure`&&d.current!==null&&(d.current(),d.current=null)},[a]),(0,J.useEffect)(()=>{if(a!==`landing`)return;let e=Math.max(0,s.size-1)*TJ(`--landing-step-code`),t=setTimeout(()=>o(`done`),TJ(`--landing-total`)+e);return()=>clearTimeout(t)},[a,s]);let{before:f}=r,p=(0,J.useCallback)(e=>a!==`done`&&!f.has(e),[a,f]);return{phase:a,running:e||a===`measure`,fresh:p,inView:a===`landing`?s:OJ}},AJ=`[aria-label=Changes]`,jJ=(e,t)=>e.id===t.id&&e.guardrails===`running`&&t.guardrails!==`running`,MJ=e=>{let[t,n]=(0,J.useState)(e),r=(0,J.useRef)(null),i=t!==e&&jJ(t,e);return(0,J.useLayoutEffect)(()=>{t===e?(r.current?.(),r.current=null):(jJ(t,e)&&(r.current=rW(AJ)),n(e))},[e,t]),i?t:e},NJ=(e,t)=>{let{client:n}=Pp(),[r,i]=(0,J.useState)(new Map),[a,o]=(0,J.useState)(new Set),[s,c]=(0,J.useState)(null),l=(0,J.useRef)(new Map),u=(0,J.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,J.useCallback)(e=>u.get(e)??`open`,[u]),setState:(0,J.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:Gp(s.error)})))},[e,n]),isSaving:e=>a.has(e),failure:s,dismissFailure:()=>c(null)}},PJ=6e4,FJ=e=>{let{client:t}=Pp(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),o=(0,J.useRef)(0),s=(0,J.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,J.useEffect)(()=>(s(),window.addEventListener(`focus`,s),()=>window.removeEventListener(`focus`,s)),[s]);let c=n?.checks?.some(e=>e.state===`running`)===!0;return(0,J.useEffect)(()=>{if(!c)return;let e=setInterval(()=>{document.visibilityState===`visible`&&s()},PJ);return()=>clearInterval(e)},[c,s]),{status:n,error:i,reload:s}},IJ=(e,t)=>{let{client:n}=Pp(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(0),c=(0,J.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,J.useEffect)(()=>{t&&c()},[t,c]),{list:r,error:a,reload:c,reply:(0,J.useCallback)(async(t,r)=>{let i=await n.replyToThread(e,t,{body:r});return i.ok?(c(),null):Gp(i.error)},[n,e,c]),resolve:(0,J.useCallback)(async(t,r)=>{let i=await n.resolveThread(e,t,{resolved:r});return i.ok?(c(),null):Gp(i.error)},[n,e,c]),post:(0,J.useCallback)(async t=>{let r=await n.postComment(e,t);return r.ok?(c(),null):Gp(r.error)},[n,e,c])}},LJ=[],RJ=e=>sf.array().safeParse(e).data,zJ=({analysisId:e})=>{let[t,n]=(0,J.useState)({count:0,seed:null}),r=(0,J.useCallback)((e=null)=>n(({count:t})=>({count:t+1,seed:e})),[]);return(0,Y.jsx)(BJ,{analysisId:e,seed:t.seed,restart:r},`${e}/${t.count}`)},BJ=({analysisId:e,seed:t,restart:n})=>{let{view:r,error:i,refetch:a,follow:o}=Vp(e,t);return r===null?i?.code===`not-found`?(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Analysis not found`}),(0,Y.jsx)(`p`,{className:`text-body`,children:Gp(i)}),(0,Y.jsx)(`p`,{children:(0,Y.jsx)(Q_,{to:`/`,children:`Pick a pull request to review`})})]}):i===null?(0,Y.jsx)(VJ,{}):(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 py-12`,children:[(0,Y.jsxs)(`p`,{className:dF,role:`alert`,children:[`Couldn't load the analysis. `,Gp(i)]}),(0,Y.jsx)($,{variant:`outline`,onClick:()=>void a(),children:`Try again`})]}):(0,Y.jsx)(nY,{view:r,refetch:a,follow:o,restart:n})},VJ=()=>(0,Y.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,Y.jsx)(pF,{className:`h-7 w-2/3`}),(0,Y.jsx)(pF,{className:`h-4 w-1/2`}),(0,Y.jsxs)(`div`,{className:HJ,children:[(0,Y.jsx)(hF,{}),(0,Y.jsx)(mF,{})]})]}),HJ=`grid items-start gap-5 lg:grid-cols-[17rem_minmax(0,1fr)]`,UJ=[],WJ=[{value:`map`,label:`Map`},{value:`overview`,label:`Overview`}],GJ=[{value:`map`,label:`Map`},{value:`overview`,label:`Understand`}],KJ=e=>{switch(e.kind){case`no-review`:return`No AI review yet. The tour through these directories is written with one: Request AI review above.`;case`without-tour`:return`This AI review ran without the tour. Re-run it to get one.`;case`writing`:return`The tour is being written.`;case`too-small`:return`The change is too small for a tour: it has fewer than 3 steps to make.`;case`failed`:return`The tour couldn't be written: ${e.message}`}},qJ=[`nextFile`,`previousFile`,`comment`,`openCall`,`moveFile`,`openFile`,`toggleLayout`,`openReview`,`close`,`help`],JJ=({analysis:e})=>{let{checkout:t,pullRequest:n}=e;if(t===`read`||n===null)return null;let{ref:r,headSha:i}=n;return(0,Y.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,Y.jsxs)(Y.Fragment,{children:[`the local checkout doesn't have the head commit`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:i.slice(0,7)}),`. Run`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`git fetch`}),` in it`,r.repo.host===`github`&&(0,Y.jsxs)(Y.Fragment,{children:[`, or`,` `,(0,Y.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,Y.jsxs)(Y.Fragment,{children:[`megareviewer didn't run in a checkout of `,r.repo.owner,`/`,r.repo.repo,`. Start it in one, or pass`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`--checkout <dir>`}),`, then open the pull request again.`]})]})},YJ=[],XJ=(e,t)=>{let[n,r]=(0,J.useState)(e);return!t&&n!==e&&r(e),t?n:e},ZJ=(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=kM(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}},QJ={github:void 0,bitbucket:`Bitbucket can't anchor a range, so the comment goes on the last line and names them.`},$J=new WeakMap,eY=0,tY=e=>{let t=$J.get(e);return t===void 0?(eY+=1,$J.set(e,eY),eY):t},nY=({view:e,refetch:t,follow:n,restart:r})=>{let{client:i}=Pp(),a=HR(Lp().status?.model??null),{analysis:o,publication:s}=e,c=o.id,l=o.status===`complete`,u=l&&td(o),d=MJ(XJ(o,u)),f=Hp(i.runModel),p=s!==null||!l,m=(0,J.useMemo)(()=>JW(d),[d]),h=(0,J.useMemo)(()=>YW(d,m),[d,m]),g=(0,J.useMemo)(()=>h.flatMap(e=>e.partIds),[h]),_=(0,J.useMemo)(()=>eG(d,m),[d,m]),v=$W(_),[y,b]=NR(`decisions`,!1,PR),[x,S]=NR(`tour`,!1,PR),C=(0,J.useMemo)(()=>Du(d).filter(e=>y||e.kind!==`decision`),[d,y]),w=(0,J.useMemo)(()=>C.map(e=>e.id),[C]),T=NJ(c,e.pointReviews),[E,D]=(0,J.useState)(new Set),{stateOf:O}=T,k=(0,J.useMemo)(()=>new Set(C.filter(e=>e.guidance?.effect===`left-out`&&O(e.id)===`open`&&!E.has(e.id)).map(e=>e.id)),[C,O,E]),A=(0,J.useMemo)(()=>C.filter(e=>!k.has(e.id)),[C,k]),j=(0,J.useCallback)(e=>D(t=>new Set(t).add(e)),[]),M=Bl(o.modelOption??a.chosen),N=kJ(u,w,M),P=(0,J.useMemo)(()=>ZW(C,g,m),[C,g,m]),F=(0,J.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 P.cards){let s=m.parts.get(a);for(let c of o){let o=s===void 0?null:ZJ(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}},[P,m]),I=(0,J.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 F.underLine.values())for(let n of e.values())t(n);for(let[e,n]of F.underHeader)t([...n,...P.mentions.get(e)??UJ]);for(let[e,n]of P.mentions)F.underHeader.has(e)||t(n);return t(P.unplaced),e},[F,P]),{inView:L}=N,R=(0,J.useCallback)(e=>L.get(I.get(e)??e),[L,I]),ee=(0,J.useMemo)(()=>{let e=new Map;for(let[t,n]of P.cards){let r=m.parts.get(t)?.file.path;if(r===void 0)continue;let i=n.filter(e=>!k.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},[P,m,k]),z=(0,J.useMemo)(()=>h.map(({file:e})=>({path:e.path,status:e.status,oldPath:e.oldPath,additions:e.additions,deletions:e.deletions,...ee.has(e.path)?{points:ee.get(e.path)}:{}})),[h,ee]),[B,V]=(0,J.useState)([]),te=(0,J.useMemo)(()=>TU(d,new Set(B)),[d,B]),H=(0,J.useMemo)(()=>TU(d),[d]),U=(0,J.useMemo)(()=>Du(d),[d]),ne=x?Bq(o):null,re=(0,J.useMemo)(()=>x?zq(d,H,U,e=>O(e.id)):null,[x,d,H,U,O]),ie=(0,J.useMemo)(()=>d.stages.prep===`done`?OU(TU(d)):null,[d]),[ae,oe]=NR(`review-layout`,`map`,KW),W=ae===`overview`&&ne===null&&re!==null,se=CJ((0,J.useMemo)(()=>h.map(e=>e.file.path),[h]),ae===`map`&&d.stages.prep===`done`),[ce,le]=(0,J.useState)(!1),ue=(0,J.useMemo)(()=>{let e=new Map;for(let t of d.unchangedCallers)e.set(t.partId,[...e.get(t.partId)??[],t]);return e},[d.unchangedCallers]),de=(0,J.useCallback)(e=>ue.get(e)??YJ,[ue]),[fe]=(0,J.useState)(zM),pe=(0,J.useMemo)(()=>LU(d.callSites,m,fe),[d.callSites,m,fe]),me=(0,J.useCallback)(e=>pe.get(e),[pe]),he=(0,J.useMemo)(()=>new Map(C.flatMap(e=>{let t=RU(e,m);return t===null?[]:[[e.id,{handle:fe,payload:t}]]})),[C,m,fe]),[ge,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(null),be=(0,J.useRef)(null),[xe,Se]=(0,J.useState)(null),[Ce,we]=(0,J.useState)(null),[Te,Ee]=(0,J.useState)(null),[De,Oe]=(0,J.useState)(null),[ke,Ae]=(0,J.useState)(null),[je,Me]=(0,J.useState)(new Set),[Ne,Pe]=(0,J.useState)(!1),Fe=Te===`thread`||A.length===0,Ie=Fe?null:Ce,[Le,Re]=(0,J.useState)(!1),[ze,Be]=(0,J.useState)(new Set),Ve=(0,J.useCallback)(e=>Be(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),[]),[G,He]=(0,J.useState)(!1),[Ue,We]=(0,J.useState)(new Set),[Ge,Ke]=(0,J.useState)(null),[qe,Je]=(0,J.useState)(!1),[Ye,Xe]=(0,J.useState)(!1),Ze=(0,J.useRef)(!0),[Qe,$e]=(0,J.useState)(!1),[et,tt]=NR(`hunk-comments:${c}`,LJ,RJ),[nt,rt]=(0,J.useState)(null),it=(0,J.useRef)(null),at=(0,J.useMemo)(()=>tG(et,m),[et,m]),ot=(0,J.useCallback)(e=>at.get(e)??LJ,[at]),st=(0,J.useCallback)((e,t)=>tt(n=>{let r=nl(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]}),[tt]),ct=(0,J.useCallback)((e,t)=>{it.current=null,rt(n=>{if(t?.startLine!==void 0&&n!==null&&n.partId===e){let r=nl(e),i=n.place;tt(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}})},[tt]),{setState:lt}=T,ut=(0,J.useCallback)((e,t)=>{let n=it.current;it.current=null,n!==null&&n.partId===e&&n.place.side===t.side&&n.place.line===t.line&&(st(e,n.before??{...n.place,body:``}),n.state!==`raised`&&lt(n.pointId,n.state))},[st,lt]),dt=IJ(c,d.stages.prep===`done`),ft=FJ(c),{post:pt}=dt,mt=(0,J.useCallback)((e,t)=>pt({hunkId:nl(e),...t}),[pt]),ht=(0,J.useMemo)(()=>xq(dt.list?.threads??null,h,m),[dt.list,h,m]),gt=(0,J.useMemo)(()=>Cq(ht,h,m),[ht,h,m]),_t=Tq(ke,gt,je),vt=Fe?De:null,{resolve:yt}=dt,bt=(0,J.useCallback)(async(e,t)=>{let n=await yt(e,t);return n===null&&t&&Me(t=>new Set(t).add(e)),n},[yt]),xt=d.pullRequest?.author.id??null,St=(e,t)=>(0,Y.jsx)(xM,{thread:e,authorId:xt,now:Date.now(),language:NA({path:e.path,language:null}),covered:t,mediaUrl:e=>i.attachmentUrl(c,e),onReply:t=>dt.reply(e.id,t),onResolve:t=>bt(e.id,t),current:vt===e.id,anchorId:_q(e.id),linesAbove:t?.length??0},e.id),Ct=(e,t)=>{let n=ht.onLine.get(e)?.get(vq(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 St(e,r===void 0?null:Sq(r,Math.min(n,t.line),t.line))})},wt=e=>{let t=ht.earlier.get(e);return t===void 0?null:t.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.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 ${yM(e)}, which the diff doesn't show`}),St(e,null)]},e.id))},Tt=e=>ht.open.get(e)??0,Et=(0,J.useMemo)(()=>z.map(e=>({...e,threads:ht.open.get(e.path)??0})),[z,ht]),Dt=e=>Ke(t=>({id:e,n:(t?.n??0)+1})),Ot=()=>ae===`overview`?null:ge,kt=(0,J.useCallback)(e=>_e(e),[]),At=e=>{te.placeOf.has(e)&&ye(t=>({key:e,n:(t?.n??0)+1}))},jt=(e,t=ae)=>{if(t===`overview`){let t=m.parts.get(e)?.file.path;t!==void 0&&At(t)}else Dt(g.includes(e)?GU(e):rG)},Mt=e=>{let t=C.find(t=>t.id===e),n=P.cardPart.get(e);t?.kind===`decision`&&Be(t=>new Set([...t,e])),k.has(e)&&j(e),Te===`thread`&&Ee(null),We(new Set((t?.hunkIds??[]).flatMap(m.partsOf))),ae===`overview`&&!W?n!==void 0&&jt(n):(ae===`overview`&&(oe(()=>`map`),Se(null)),Dt(oK(e))),we(e)},[Nt,Pt]=(0,J.useState)(null),[Ft,It]=(0,J.useState)(null),[Lt,Rt]=(0,J.useState)(0);(0,J.useEffect)(()=>{if(Lt!==0&&ae===`map`)return sW(_J,`[aria-label=Changes]`)},[Lt,ae]);let zt=`tour-step:${c}`,Bt=()=>{let e=FR(zt);return typeof e==`number`?e:0},Vt=x&&ne===null&&re!==null,Ht=e=>{oe(()=>`overview`),Se(null),Pt(null),We(new Set),It(t=>({step:e,n:(t?.n??0)+1}))},Ut=()=>Ht(Nt?.step.number??Bt()),Wt=(e,t)=>{oe(()=>`map`),Se(null),Pt({step:e,excerpt:t}),_e(t.partId),IR(zt,e.number),Dt(_J),Rt(e=>e+1)},Gt=e=>{oe(()=>`map`),Se(null),_e(e),We(new Set([e])),Dt(g.includes(e)?GU(e):rG)},Kt=e=>{if(e.kind!==`decision`||y)return Mt(e.id);let t=P.cardPart.get(e.id)??e.hunkIds.flatMap(m.partsOf)[0];t!==void 0&&Gt(t)},qt=e=>{oe(()=>`map`),Se(null),Dt(h.some(t=>t.file.path===e)?iG(e):rG)},Jt=e=>{Ee(`thread`),Oe(e),We(new Set),ae===`overview`&&oe(()=>`map`),Dt(_q(e))},Yt=e=>{if(Ee(e),e===`thread`){let e=wq(gt,_t,je),[t]=e;t!==void 0&&!e.some(e=>e.id===De)&&Jt(t.id);return}let t=BK(A,e,Ce);t!==null&&Mt(t)},Xt=e=>{let t=Su.parse(`m${e+1}`),n=d.findings.find(t=>t.mismatch===`m${e+1}`);Mt(C.some(e=>e.id===t)||n===void 0?t:Su.parse(n.id))},Zt=()=>{let e=(document.activeElement?.closest(`[aria-label=Changes] [data-slot=file-card]`))?.dataset.path??se;oe(()=>`overview`),Se(null),e!==null&&At(e)},Qt=e=>{let[t]=e.kind===`outside`?[]:e.paths,n=t===void 0?e.partIds[0]:h.find(e=>e.file.path===t)?.partIds[0];n!==void 0&&(oe(()=>`map`),Se(e.key),_e(n),t===void 0?jt(n,`map`):Dt(iG(t)))},$t=()=>{if(ae===`map`)return Vt?Ht(Nt?.step.number??Bt()):Zt();if(W){let e=re?.steps.find(e=>e.number===Bt()),[t]=e?.excerpts??[];return e!==void 0&&t!==void 0?Wt(e,t):oe(()=>`map`)}let e=[...te.rows.flat(),...te.strip].find(e=>e.key===be.current);if(e!==void 0&&e.kind!==`outside`)return Qt(e);oe(()=>`map`)};Zp({label:`Layout`,options:x?GJ:WJ,value:ae,onChange:e=>{e!==ae&&$t()},toggles:[{label:`Decisions`,checked:y,onChange:e=>b(()=>e)},{label:`Tour (preview)`,checked:x,onChange:e=>S(()=>e)}]});let en=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&&Dt(r.id)},tn=(e,t=!1)=>{let n=P.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:kM(a));if(o===null)return;let s=e.explanation===``?e.title:`${e.title}\n\n${e.explanation}`,c=nl(n),l=et.find(e=>e.hunkId===c&&e.side===o.side&&e.line===o.line),u={...e.suggestion===null?{}:{suggestion:e.suggestion}};l===void 0?st(n,{...o,body:s,...u}):T.stateOf(e.id)!==`raised`&&!l.body.includes(s)&&st(n,{...u,...l,body:l.body===``?s:`${l.body}\n\n${s}`}),we(e.id);let d=T.stateOf(e.id);if(T.setState(e.id,`raised`),t)return;let{startLine:f}=l??o,h={side:o.side,line:o.line,...f===void 0?{}:{startLine:f}};rt({partId:n,place:h}),it.current={partId:n,place:h,before:l,pointId:e.id,state:d},Dt(GU(n))},nn=()=>{let e=Ot(),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=kM(n);r!==null&&e!==null&&(it.current=null,rt({partId:e,place:r}))},rn=()=>{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&&fe.open(n.id)},an=()=>{if(Ue.size>0)return We(new Set);if(ae===`map`&&Nt!==null)return Ut();ae===`map`&&xe!==null&&(oe(()=>`overview`),ye(e=>({key:xe,n:(e?.n??0)+1})),Se(null))},on=l;aA({...ae===`map`?{nextFile:()=>en(1),previousFile:()=>en(-1),comment:nn,openCall:rn,close:an}:{},toggleLayout:()=>$t(),openReview:()=>{on&&dn()},help:()=>Xe(!0)},!qe&&!Ye&&!Qe);let sn=d.pullRequest?.url??jf(d.key.ref),cn=Hp(i.startAnalysis),ln=Hp(i.retryAnalysis),un=e=>{e===c?r():Y_(G_(e))},dn=()=>Je(!0),[fn,pn]=(0,J.useState)(null),mn=(0,J.useRef)(ft.status);mn.current=ft.status;let hn=e.currentUserId===null?null:ft.status?.reviewers.find(t=>t.id===e.currentUserId)?.verdict??null,gn=fn!==null&&fn.over===ft.status,_n=gn?fn.verdict:hn,vn=gn||ft.status!==null&&e.currentUserId!==null,yn=e=>{pn({verdict:e,over:mn.current}),ft.reload()},bn=Hp(i.publish),xn=(0,J.useRef)(null),Sn=async()=>{xn.current??=uf.parse(crypto.randomUUID()),(await bn.run(c,{publicationId:xn.current,summary:``,allowStale:!0,hunkComments:[],verdict:`approve`})).ok&&(xn.current=null,yn(`approved`),dt.reload(),t())},Cn=Hp(i.revokeApproval),wn=async()=>{(await Cn.run(c)).ok&&yn(null)},Tn=et.length,En=YU({aiDone:Zu.every(e=>o.stages[e]===`done`),running:u,pending:Tn,isAuthor:e.isAuthor,stale:e.stale,verdict:_n}),Dn=(0,J.useMemo)(()=>nG(d.files),[d.files]),On=T.failure===null?``:C.find(e=>e.id===T.failure?.pointId)?.title??``,kn=async(e,t)=>{let n=await i.addPreference({...t,source:`learned`});return n.ok?(T.setState(e.id,`dismissed`),null):dV(n.error)},An=e=>({state:T.stateOf(e.id),saving:T.isSaving(e.id),readOnly:p,current:Ie===e.id,onRaise:Kn.raisePoint,onState:Kn.setPointState,leftOut:k.has(e.id),onShow:j,ruleScopes:Jn,onRule:Kn.saveRule}),jn=(e,t)=>{let n=t===null?void 0:m.parts.get(t),r=e.lines,i=t!==null&&r!==null&&ot(t).some(e=>e.side===r.side&&e.line===r.line);return(0,Y.jsx)(OK,{point:e,...An(e),family:M,linesAbove:F.rowsAbove.get(e.id)??0,inReview:i,removed:n===void 0||r===null||r.side===`old`?null:Sq(n.hunk,r.startLine,r.line),language:n===void 0?null:NA(n.file)},e.id)},Mn=e=>(0,Y.jsx)(jK,{point:e,...An(e),family:M,linesAbove:F.rowsAbove.get(e.id)??0,test:he.get(e.id)??null},e.id),Nn=e=>(0,Y.jsx)(NK,{point:e,...An(e)},e.id),Pn=(e,t=null)=>e.kind===`finding`?jn(e,t):e.kind===`risk`?Mn(e):Nn(e),Fn=(0,J.useMemo)(()=>{let e={finding:0,risk:1,decision:2,step:3},t=new Map;for(let[n,r]of P.cards){let i=new Map;for(let t of r){if(t.lines===null||t.kind===`decision`||k.has(t.id))continue;let{side:n,startLine:r,line:a}=t.lines,o=R(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},[P,R,k]),In=(0,J.useMemo)(()=>new Map(d.files.flatMap(e=>e.hunks.map(t=>[t.id,{hunk:t,file:e}]))),[d.files]),Ln=(0,J.useMemo)(()=>{if(Nt===null)return null;let e=In.get(Nt.excerpt.hunkId)?.hunk;if(e===void 0)return null;let t=e.lines.slice(Nt.excerpt.start,Nt.excerpt.end).flatMap(e=>{let t=kM(e);return t===null?[]:[`${t.side}:${t.line}`]});return{hunkId:Nt.excerpt.hunkId,keys:t}},[Nt,In]),Rn=(0,J.useCallback)(e=>{let t=Fn.get(e);if(Ln===null||nl(e)!==Ln.hunkId)return t;let n=new Map(t??[]);for(let e of Ln.keys)n.has(e)||n.set(e,{kind:`step`});return n},[Fn,Ln]),zn=(e,t,n)=>{let[r]=e;return r===void 0?null:(0,Y.jsx)(FK,{pointId:r.id,fresh:e.some(e=>N.fresh(e.id)),at:R(r.id),...t,children:n},r.id)},Bn=e=>{let t=F.underHeader.get(e)??UJ,n=P.mentions.get(e)??UJ,r=Nt!==null&&Nt.excerpt.partId===e?(0,Y.jsx)(vJ,{step:Nt.step,excerpt:Nt.excerpt}):null;return r===null?Vn(t,n,e):(0,Y.jsxs)(Y.Fragment,{children:[r,Vn(t,n,e)]})},Vn=(e,t,n)=>zn([...e,...t],{bodyClassName:`flex flex-col gap-2 border-b bg-surface-subtle p-3`},(0,Y.jsxs)(Y.Fragment,{children:[e.map(e=>Pn(e,n)),t.map(e=>(0,Y.jsx)(PK,{point:e,onGo:Kn.goToPoint},e.id))]})),Hn=(e,t)=>{let n=vq(t),r=F.underLine.get(e)?.get(n)??UJ,i=(F.atLineEnd.get(e)?.get(n)??UJ).filter(e=>ze.has(e.id));return(0,Y.jsxs)(Y.Fragment,{children:[zn(r,{row:!0,className:AM,bodyClassName:`flex max-w-3xl flex-col gap-2 py-2 pr-3 pl-29 font-sans`},r.map(t=>Pn(t,e))),i.length>0&&(0,Y.jsx)(MM,{inset:!0,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(Nn)})})]})},Un=(e,t)=>{let n=F.atLineEnd.get(e)?.get(vq(t));return n===void 0?null:n.map(e=>(0,Y.jsx)(MK,{point:e,state:T.stateOf(e.id),open:ze.has(e.id),current:Ie===e.id,onToggle:Ve},e.id))},Wn=(0,J.useCallback)(e=>{let t=F.underLine.get(e);if(t===void 0)return;let n=[...t].filter(([,e])=>e.some(e=>e.kind===`finding`&&!k.has(e.id)));return new Set(n.map(([e])=>e))},[F,k]),Gn=(0,J.useRef)({goToPoint:Mt,raisePoint:tn,saveRule:kn});Gn.current={goToPoint:Mt,raisePoint:tn,saveRule:kn};let Kn=(0,J.useMemo)(()=>({goToPoint:e=>Gn.current.goToPoint(e),raisePoint:(e,t)=>Gn.current.raisePoint(e,t),saveRule:(e,t)=>Gn.current.saveRule(e,t),setPointState:T.setState}),[T.setState]),qn=d.key.ref.repo,Jn=(0,J.useMemo)(()=>GB([qn]).reverse(),[qn]),Yn=(e,t)=>{let n=m.parts.get(e);if(n===void 0)return;let r=n.hunk.lines.find(e=>e.kind!==`context`),i=r===void 0?null:kM(r);return C.find(n=>{if(n.guardrail===void 0||P.cardPart.get(n.id)!==e||T.stateOf(n.id)!==`raised`)return!1;let r=n.lines===null?i:n.lines;return r!==null&&r.side===t.side&&r.line===t.line})},Xn=e=>{let t=[tY(d),p,Ue.has(e),nt?.partId===e?`${nt.place.side}${nt.place.line}`:``,...ot(e).map(e=>JSON.stringify(e))];ht.onLine.has(e)&&t.push(tY(ht),vt??``);let n=P.cards.get(e)??UJ,r=P.mentions.get(e)??UJ;for(let e of n)t.push(e.id,T.stateOf(e.id),T.isSaving(e.id)),t.push(Ie===e.id,k.has(e.id)),e.kind===`decision`&&t.push(ze.has(e.id));for(let e of r)t.push(e.id);for(let e of[...n,...r])t.push(N.fresh(e.id),R(e.id)??``);return Ln!==null&&nl(e)===Ln.hunkId&&t.push(Nt?.excerpt.key),t.join(`\0`)},Zn=e=>{let t=In.get(e.hunkId);if(t===void 0)return null;let n=rl(t.hunk,e),r=t=>t.hunkId===e.hunkId&&n.lines.some(e=>{let n=kM(e);return n!==null&&n.side===t.side&&n.line===t.line}),i=nt?.partId===e.partId?nt.place:null;return(0,Y.jsx)(LM,{id:e.partId,hunk:n,file:t.file,risk:m.items([e.partId])[0]?.risk??null,inFile:!0,comments:et.filter(r),openComment:i!==null&&n.lines.some(e=>kM(e)?.line===i.line)?i:null,onOpenComment:ct,onCancelComment:ut,...l?{onComment:st,onCommentNow:mt}:{},threadsAt:t=>Ct(e.partId,t),...QJ[d.key.ref.repo.host]===void 0?{}:{rangeNote:QJ[d.key.ref.repo.host]}})},Qn={index:m,unchangedOf:de,highlighted:Ue,commentsOf:ot,openComment:nt,onOpenComment:ct,onCancelComment:ut,onComment:l?st:void 0,...l?{onCommentNow:mt}:{},draftNote:(e,t,n)=>{let r=Yn(e,t);return r?.guardrail===void 0?null:(0,Y.jsx)(WU,{guardrail:r.guardrail,family:M,body:t.body,onEdit:n})},onFocusHunk:kt,marksOf:me,pointsOn:Bn,pointsAt:Hn,pointsAtEnd:Un,flaggedOf:Wn,pointLinesOf:Rn,threadsAt:Ct,earlierThreads:wt,openThreads:Tt,...QJ[d.key.ref.repo.host]===void 0?{}:{rangeNote:QJ[d.key.ref.repo.host]}},$n=(0,Y.jsx)(Y.Fragment,{children:P.unplaced.length>0&&(0,Y.jsx)(`section`,{"aria-label":`Points on no change shown here`,children:zn(P.unplaced,{bodyClassName:`flex flex-col gap-2`},P.unplaced.map(e=>Pn(e)))})});return(0,Y.jsxs)(`div`,{"data-slot":`review-page`,"data-layout":ae,"data-landing":N.phase,className:`mx-auto flex max-w-[1600px] flex-col gap-4`,children:[(0,Y.jsx)(gq,{view:e,intent:(0,Y.jsx)(bW,{analysis:o,through:ie,running:N.running,stale:e.stale,tour:Vt&&re!==null?{steps:re.steps.length,onOpen:()=>Ht(0)}:null,onDetails:()=>{Ze.current=!0,$e(!0)}}),totals:Dn,status:ft.status,statusError:ft.error,onRetryStatus:ft.reload,now:Date.now()}),(0,Y.jsx)(cq,{title:o.pullRequest?.title??null,claude:(0,Y.jsx)(FU,{analysis:o,choice:a,running:N.running,starting:f.pending,error:f.error===null?cn.error===null?null:Gp(cn.error):Gp(f.error),filesChanged:d.stages.prep===`done`?Dn.files:null,reanalyze:e.stale?{starting:cn.pending,onReanalyze:async()=>{let e=await cn.run({url:sn});e.ok&&un(e.value.analysisId)}}:null,onRerun:()=>He(!0),points:A,leftOut:k.size,threads:jq(gt,_t,je),narrowed:Te,onNarrow:Yt,onRun:async()=>{let e=a.chosen?.id;(await f.run(c,{...e===void 0?{}:{optionId:e},...x?{tour:!0}:{}})).ok&&n()},children:Fe?gt.length>0&&(0,Y.jsx)(Nq,{ordered:gt,scope:_t,resolvedHere:je,current:De,onGo:Jt,onOpenList:()=>Pe(!0)}):(0,Y.jsx)(GK,{points:A,current:Ce,stateOf:T.stateOf,kind:Te,onGo:Mt,onOpenList:()=>Re(!0)})}),tools:ae===`map`&&(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:`lg:hidden`,"aria-expanded":ce,"aria-controls":`review-tree-rail`,onClick:()=>le(!ce),children:ce?`Hide files`:`Show files`}),publish:on&&(0,Y.jsxs)(Y.Fragment,{children:[En.order.map(e=>e===`approve`&&En.approve.revoke?(0,Y.jsxs)($,{variant:`outline`,"data-slot":`revoke-approval-button`,disabled:Cn.pending,onClick:()=>void wn(),children:[(0,Y.jsx)(P_,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:Cn.pending?`Revoking…`:`Revoke approval`})]},`approve`):e===`approve`?(0,Y.jsxs)(YL,{disabled:En.approve.disabledReason===null,children:[(0,Y.jsxs)(XL,{render:(0,Y.jsx)($,{variant:En.approve.filled?`approve`:`outline`,"data-slot":`approve-button`,disabled:bn.pending||En.approve.disabledReason!==null,focusableWhenDisabled:!0,"aria-describedby":En.approve.disabledReason===null?void 0:`approve-reason`,onClick:()=>void Sn()}),children:[(0,Y.jsx)(mg,{"aria-hidden":`true`,className:X(!En.approve.filled&&`text-review-approved`)}),(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:bn.pending?`Approving…`:`Approve`})]}),(0,Y.jsx)(ZL,{side:`bottom`,align:`end`,children:En.approve.disabledReason})]},`approve`):(0,Y.jsxs)($,{variant:En.publish.filled?`default`:`outline`,"data-slot":`publish-button`,"aria-haspopup":`dialog`,onClick:()=>void dn(),children:[(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Publish review…`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`sm:hidden`,children:`Publish…`}),En.publish.count>0&&(0,Y.jsxs)(`span`,{className:`tabular rounded-full bg-primary-foreground px-1.5 text-caption text-primary`,children:[En.publish.count,(0,Y.jsx)(`span`,{className:`sr-only`,children:` to post`})]})]},`publish`)),En.approve.disabledReason!==null&&(0,Y.jsx)(`span`,{id:`approve-reason`,hidden:!0,children:En.approve.disabledReason})]}),verdict:XU(_n,vn,s),hairline:N.running?`running`:N.phase===`landing`?`finishing`:null}),ae===`map`&&Nt!==null&&(0,Y.jsx)(yJ,{step:Nt.step.number,onBack:Ut,onDismiss:()=>Pt(null)}),!l&&(0,Y.jsx)(XK,{stages:o.stages,shown:QK,filesFetched:o.filesFetched}),o.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`The analysis failed at the `,ZK(o.error.stage).toLowerCase(),` stage:`,` `,o.error.message]}),ln.error!==null&&(0,Y.jsxs)(`p`,{children:[`Couldn't retry. `,Gp(ln.error)]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,disabled:ln.pending,onClick:async()=>{let e=await ln.run(c);e.ok&&un(e.value.analysisId)},children:ln.pending?`Retrying…`:`Retry`})]}),bn.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't approve. `,Gp(bn.error)]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:bn.reset,children:`Dismiss`})]}),Cn.error!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't revoke the approval. `,Gp(Cn.error)]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:Cn.reset,children:`Dismiss`})]}),T.failure!==null&&(0,Y.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,Y.jsxs)(`p`,{children:[`Couldn't save what you did with “`,On,`”. `,T.failure.message]}),(0,Y.jsx)($,{variant:`ghost`,size:`sm`,onClick:T.dismissFailure,children:`Dismiss`})]}),dt.error!==null&&(0,Y.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,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),`Couldn't read the comments on the pull request. `,Gp(dt.error)]}),(0,Y.jsx)($,{variant:`outline`,size:`sm`,onClick:dt.reload,children:`Try again`})]}),d.stages.prep===`done`?ae===`map`?(0,Y.jsxs)(`div`,{className:X(HJ,`[&>aside]:hidden lg:[&>aside]:flex`,ce&&`[&>aside]:flex`),children:[(0,Y.jsx)(iq,{children:(0,Y.jsx)(UI,{files:Et,activePath:se,onSelect:e=>Dt(iG(e)),className:`min-h-0 flex-1`})}),(0,Y.jsx)(lG,{analysis:d,files:h,deps:Qn,before:$n,after:ht.elsewhere.length>0&&(0,Y.jsxs)(`section`,{"aria-label":`Comments on other files`,className:`flex flex-col gap-2 rounded-lg border bg-surface-subtle p-3`,children:[(0,Y.jsx)(`h2`,{className:`text-caption font-medium text-muted-foreground`,children:`Comments on files without a card here`}),ht.elsewhere.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-code-compact`,children:e.path}),St(e,null)]},e.id))]}),trailingProofs:_,mechanicalCount:v,scrollRequest:Ge,signatureOf:Xn})]}):W&&re!==null?(0,Y.jsx)(hJ,{tour:re,stateOf:e=>O(e.id),renderExcerpt:Zn,onOpenPoint:Kt,onOpenFile:qt,onOpenInCode:Wt,onCurrentStep:e=>{e!==null&&IR(zt,e)},landOn:Ft}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ne!==null&&(0,Y.jsx)(gJ,{busy:ne.kind===`writing`,children:KJ(ne)}),(0,Y.jsx)(iK,{overview:te,focusKey:ve,currentPath:se,onOpen:Qt,onExpand:e=>V(t=>[...t,e]),expandedGroups:B,onCollapse:e=>V(t=>t.filter(t=>t!==e)),onFocusNode:e=>{be.current=e}})]}):(0,Y.jsx)(`section`,{"aria-busy":d.status===`running`,children:(0,Y.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,Y.jsxs)(`footer`,{className:`flex items-center justify-end gap-3`,children:[(0,Y.jsx)(DG,{calls:o.modelCalls,option:o.modelOption,guidance:o.guidance,leftOut:C.filter(e=>e.guidance?.effect===`left-out`).length}),l&&!u&&id(o)&&(0,Y.jsx)(aq,{analysisId:c,family:M,onRemoved:t=>r({...e,...t})}),(0,Y.jsx)(xG,{usage:o.usage,option:o.modelOption,guidance:o.guidance})]}),G&&a.chosen!==null&&(0,Y.jsx)(oq,{analysisId:c,view:e,family:M,chosen:a.chosen,tour:x,onClose:()=>He(!1),onRestart:e=>r(e)}),qe&&(0,Y.jsx)(rq,{analysisId:c,hunkComments:et,isAuthor:e.isAuthor,published:s!==null,onClose:()=>Je(!1),onPublished:(e,n)=>{Je(!1),tt(()=>[]),dt.reload(),yn(ZU(n,_n)),t()}}),Ne&&(0,Y.jsx)(Pq,{ordered:gt,scope:_t,onScope:Ae,onGo:e=>{Pe(!1),Jt(e)},onClose:()=>Pe(!1)}),Le&&(0,Y.jsx)(LK,{points:A,family:M,kind:Te===`thread`?null:Te,stateOf:T.stateOf,onGo:e=>{Re(!1),Mt(e)},onClose:()=>Re(!1)}),(0,Y.jsx)(TF,{open:Ye,onOpenChange:Xe,ids:qJ}),(0,Y.jsx)(VM,{handle:fe,onGoTo:e=>Dt(GU(e))}),Qe&&(0,Y.jsxs)(IH,{title:d.intent===null?`What was asked`:`Intent`,onClose:()=>$e(!1),className:`sm:max-w-4xl`,returnFocus:()=>Ze.current,children:[d.intent===null?d.pullRequest!==null&&(0,Y.jsx)(SW,{pullRequest:d.pullRequest,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys}):(0,Y.jsx)(jW,{intent:d.intent,tickets:d.tickets,missingTicketKeys:d.missingTicketKeys,onSelectMismatch:e=>{Ze.current=!1,$e(!1),Xt(e)}}),(0,Y.jsx)(JJ,{analysis:d})]}),(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground`,children:[`Press `,(0,Y.jsx)(cA,{id:`help`}),` for keyboard shortcuts.`]})]})},rY={theme:`megareviewer:theme`,diffPalette:`megareviewer:diffPalette`},iY=`(prefers-color-scheme: dark)`,aY=e=>e===`light`||e===`dark`?e:`system`,oY=e=>e===`cb`?`cb`:`default`,sY=(e,t)=>e===`system`?t?`dark`:`light`:e,cY=(e,t,n)=>{e.classList.toggle(`dark`,t===`dark`),n===`cb`?e.dataset.diffPalette=`cb`:delete e.dataset.diffPalette},lY=e=>{try{let t=window.localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}},uY=(e,t)=>{try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}},dY=new Set,fY=()=>{for(let e of dY)e()},pY=e=>{dY.add(e);let t=window.matchMedia(iY);return t.addEventListener(`change`,e),window.addEventListener(`storage`,e),()=>{dY.delete(e),t.removeEventListener(`change`,e),window.removeEventListener(`storage`,e)}},mY=()=>`${aY(lY(rY.theme))} ${oY(lY(rY.diffPalette))} ${window.matchMedia(iY).matches}`,hY=()=>{let[e=`system`,t=`default`,n]=(0,J.useSyncExternalStore)(pY,mY).split(` `),r=aY(e),i=oY(t),a=sY(r,n===`true`);return(0,J.useEffect)(()=>{cY(document.documentElement,a,i)},[a,i]),{theme:r,resolvedTheme:a,diffPalette:i,setTheme:(0,J.useCallback)(e=>{uY(rY.theme,e),fY()},[]),setDiffPalette:(0,J.useCallback)(e=>{uY(rY.diffPalette,e),fY()},[])}},gY={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius-xl)`},_Y=({...e})=>{let{resolvedTheme:t}=hY();return(0,Y.jsx)(OP,{theme:t,className:`toaster group`,icons:{success:(0,Y.jsx)(mg,{className:`size-4`}),info:(0,Y.jsx)(Wg,{className:`size-4`}),warning:(0,Y.jsx)(M_,{className:`size-4`}),error:(0,Y.jsx)(i_,{className:`size-4`}),loading:(0,Y.jsx)(Qg,{className:`size-4 animate-spin`})},style:gY,toastOptions:{classNames:{toast:`cn-toast`}},...e})},vY={github:`GitHub`,bitbucket:`Bitbucket`},yY=`then restart megareviewer.`,bY={github:{connect:`Set GITHUB_TOKEN or run \`gh auth login\`, ${yY}`,adds:`Lists and opens GitHub pull requests.`},bitbucket:{connect:`Set BITBUCKET_EMAIL and BITBUCKET_API_TOKEN, and BITBUCKET_WORKSPACE to list its pull requests, ${yY}`,adds:`Lists and opens Bitbucket pull requests.`}},xY=e=>e===1?`1 pull request`:`${e} pull requests`,SY=(e,t,n,r,i)=>{let a=vY[e],{connect:o,adds:s}=bY[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, ${yY} 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} · ${xY(c)} listed ${nL(new Date(r.atMs).toISOString(),i)}`,fix:null}},CY={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`."}},wY=e=>e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`,TY=(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`${wY(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 ${wY(r)}`},EY=(e,{options:t,defaultId:n})=>{let{name:r,providers:i,adds:a,connect:o}=CY[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:TY(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)}, ${yY}`}},DY=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, ${yY}`},OY={failing:0,"not-connected":1,working:2,optional:2,checking:2},kY=(e,t)=>e===1?`1 ${t}`:`${e} ${t}s`,AY=[[`github`,`GitHub`],[`bitbucket`,`Bitbucket`],[`claude`,`Claude`],[`codex`,`Codex`],[`opencode`,`opencode`],[`jira`,`Jira`]],jY=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:Gp(n)};if(t===null)return{rows:AY.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 ${AY.length} connections…`,disconnected:null};let{github:s,bitbucket:c}=t.hosts,l=[SY(`github`,s,c,a,o),SY(`bitbucket`,c,s,a,o),EY(`claude`,t.model),EY(`codex`,t.model),EY(`opencode`,t.model),DY(t.jira.configured)].sort((e,t)=>OY[e.state]-OY[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 ${nL(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:kY(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}},MY={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`},NY={github:Ig,bitbucket:Ig,claude:E_,codex:E_,opencode:E_,jira:O_},PY={working:{label:`Connected`,icon:ng,tone:`text-ci-success`,row:``},failing:{label:`Failing`,icon:M_,tone:`text-destructive`,row:`border-l-3 border-l-destructive bg-review-changes-bg`},"not-connected":{label:`Not connected`,icon:gg,tone:`text-review-pending`,row:`border-l-3 border-l-review-pending bg-review-pending-bg`},optional:{label:`Not connected · Optional`,icon:gg,tone:`text-muted-foreground`,row:``},checking:{label:`Checking…`,icon:Qg,tone:`text-muted-foreground`,row:``}},FY=new Set([`claude`,`codex`,`opencode`]),IY=({className:e})=>(0,Y.jsx)(Qg,{"aria-hidden":`true`,className:X(`animate-spin motion-reduce:animate-[spin_3s_linear_infinite]`,e)}),LY=({tone:e})=>e===`checking`?(0,Y.jsx)(IY,{}):e===`ok`?(0,Y.jsx)(ng,{"aria-hidden":`true`,className:`text-ci-success`}):(0,Y.jsx)(M_,{"aria-hidden":`true`}),RY=({row:e})=>{let t=PY[e.state],n=e.state===`optional`&&FY.has(e.kind)?`Not connected`:t.label,r=NY[e.kind],i=t.icon;return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Y.jsxs)(`span`,{className:X(`ml-auto flex items-center gap-1 text-caption`,t.tone),children:[(0,Y.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,Y.jsx)(`p`,{className:`text-caption`,children:e.detail}),e.fix!==null&&(0,Y.jsx)(`p`,{className:`text-caption`,children:e.fix})]})},zY=({connections:e,version:t,checking:n,onCheckAgain:r,checkAgainRef:i})=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1`,children:[(0,Y.jsx)(LN,{className:`text-heading font-semibold`,children:`Connections`}),(0,Y.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:e.summary})]}),e.disconnected===null?(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.rows.map(e=>(0,Y.jsx)(RY,{row:e},e.kind))}):(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-1 pt-2`,children:[(0,Y.jsxs)($,{ref:i,variant:`outline`,size:`sm`,onClick:r,"aria-busy":n,"aria-disabled":n,children:[n&&(0,Y.jsx)(IY,{}),`Check again`]}),t!==null&&(0,Y.jsxs)(`span`,{className:`text-caption text-muted-foreground`,children:[`megareviewer `,t]})]})]}),BY=({connections:e,version:t,checking:n,open:r,onOpenChange:i,onCheckAgain:a,focusCheckAgain:o=!1})=>{let s=(0,J.useCallback)(e=>{e!==null&&o&&e.focus()},[o]),{label:c,tone:l,name:u}=e.button;return(0,Y.jsxs)(PN,{...r===void 0?{}:{open:r},...i===void 0?{}:{onOpenChange:e=>i(e)},children:[(0,Y.jsxs)(FN,{render:(0,Y.jsx)($,{variant:`outline`,size:`sm`,className:MY[l],"data-tone":l,"aria-label":u}),children:[(0,Y.jsx)(LY,{tone:l}),c]}),(0,Y.jsx)(IN,{align:`end`,className:`w-[min(340px,calc(100vw-24px))] p-2`,initialFocus:!1,children:(0,Y.jsx)(zY,{connections:e,version:t,checking:n,onCheckAgain:()=>{n||a()},checkAgainRef:s})})]})},VY=({now:e=Date.now})=>{let t=yL(),{status:n,error:r,checking:i,checkedAtMs:a,listed:o,open:s,setOpen:c,focusCheckAgain:l}=t,u=jY({status:n,error:r,checking:i,checkedAtMs:a,listed:o,nowMs:e()}),{label:d,tone:f}=u.button,[p,m]=(0,J.useState)(``),h=(0,J.useRef)(!0);return(0,J.useEffect)(()=>{f!==`checking`&&(h.current?h.current=!1:m(`Connections: ${d}`))},[d,f]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(BY,{connections:u,version:n?.version??null,checking:i,open:s,onOpenChange:e=>c(e),onCheckAgain:t.checkAgain,focusCheckAgain:l}),(0,Y.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:p})]})},HY=[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`system`,label:`System`}],UY=()=>{let{theme:e,diffPalette:t,setTheme:n,setDiffPalette:r}=hY(),i=Xp(),a=(0,J.useRef)(!1);return(0,Y.jsxs)(vB,{children:[(0,Y.jsx)(yB,{render:(0,Y.jsx)($,{variant:`ghost`,size:`sm`,className:`max-sm:px-1.5`}),children:`Display`}),(0,Y.jsxs)(bB,{align:`end`,className:`w-56`,finalFocus:()=>{let e=a.current;return a.current=!1,!e},children:[i!==null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(xB,{children:[(0,Y.jsx)(SB,{children:i.label}),(0,Y.jsx)(TB,{value:i.value,onValueChange:e=>{a.current=!0,i.onChange(e)},children:i.options.map(e=>(0,Y.jsx)(EB,{value:e.value,closeOnClick:!0,children:e.label},e.value))})]}),(0,Y.jsx)(DB,{}),i.toggles!==void 0&&(0,Y.jsxs)(Y.Fragment,{children:[i.toggles.map(e=>(0,Y.jsx)(wB,{checked:e.checked,onCheckedChange:e.onChange,children:e.label},e.label)),(0,Y.jsx)(DB,{})]})]}),(0,Y.jsxs)(xB,{children:[(0,Y.jsx)(SB,{children:`Theme`}),(0,Y.jsx)(TB,{value:e,onValueChange:e=>{let t=HY.find(t=>t.value===e);t!==void 0&&n(t.value)},children:HY.map(e=>(0,Y.jsx)(EB,{value:e.value,children:e.label},e.value))})]}),(0,Y.jsx)(DB,{}),(0,Y.jsx)(wB,{checked:t===`cb`,onCheckedChange:e=>r(e?`cb`:`default`),children:`Color-blind safe diff`})]})]})},WY=({current:e})=>(0,Y.jsxs)(Q_,{to:R_,"aria-current":e?`page`:void 0,className:X(Oy({variant:`ghost`,size:`sm`}),`min-w-7 text-foreground hover:no-underline aria-[current=page]:bg-muted max-sm:px-0`),children:[(0,Y.jsx)(w_,{"aria-hidden":`true`,className:`sm:hidden`}),(0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Preferences`})]}),GY=()=>{let e=U_(q_());return(0,Y.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,Y.jsx)(Q_,{to:`/`,className:`text-heading font-semibold text-foreground hover:no-underline`,children:`megareviewer`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 max-sm:gap-1`,children:[(0,Y.jsx)(VY,{}),(0,Y.jsx)(WY,{current:e.page===`preferences`}),(0,Y.jsx)(UY,{})]})]})},KY=()=>(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col gap-3 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Page not found`}),(0,Y.jsxs)(`p`,{className:`text-body`,children:[`There's nothing at this address. `,(0,Y.jsx)(Q_,{to:`/`,children:`Go to your pull requests`}),`.`]})]}),qY=({reason:e})=>(0,Y.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col gap-3 px-4 py-12`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Open megareviewer from your terminal`}),e===`missing`?(0,Y.jsxs)(`p`,{className:`text-body`,children:[`This page needs the link megareviewer printed when it started. It looks like`,` `,(0,Y.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,Y.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,Y.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Not running? Start it with`,` `,(0,Y.jsx)(`code`,{className:`rounded-sm bg-muted px-1 font-mono text-code-compact`,children:`npx megareviewer`}),`.`]})]}),JY=({token:e,fetch:t,openEventStream:n})=>{let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(e.value),s=(0,J.useMemo)(()=>a===null?null:{client:Ap({fetch:t,token:a,onUnauthorized:()=>{let t=e.reject(a);t===null?i(!0):o(t)}}),subscribe:(e,t)=>Mp(e,a,t,n)},[t,n,e,a]);return r?(0,Y.jsx)(qY,{reason:`ended`}):s===null?(0,Y.jsx)(qY,{reason:`missing`}):(0,Y.jsx)(Np.Provider,{value:s,children:(0,Y.jsx)(YY,{},a)})},YY=()=>{let e=U_(q_());return(0,Y.jsx)(JL,{children:(0,Y.jsx)(Yp,{children:(0,Y.jsxs)(bL,{children:[(0,Y.jsx)(GY,{}),(0,Y.jsx)(`main`,{className:X(`px-4 py-5 sm:px-6`,e.page===`picker`&&`min-h-[calc(100dvh-3rem)] bg-surface-subtle`),children:e.page===`picker`?(0,Y.jsx)(kR,{}):e.page===`preferences`?(0,Y.jsx)(cU,{}):e.page===`review`?(0,Y.jsx)(zJ,{analysisId:e.analysisId}):e.page===`open`?(0,Y.jsx)(SL,{pullRequest:e.ref},W_(e.ref)):(0,Y.jsx)(KY,{})}),(0,Y.jsx)(_Y,{})]})})})},XY=class extends J.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,Y.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col items-start gap-3 px-4 py-12`,role:`alert`,children:[(0,Y.jsx)(`h1`,{className:`text-title font-semibold tracking-[-0.01em]`,children:`Something went wrong`}),(0,Y.jsx)(`p`,{className:`text-body`,children:`megareviewer hit a bug while showing this page.`}),(0,Y.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,Y.jsx)($,{onClick:t,children:`Reload`})]})}},ZY=`token`,QY=`megareviewer.token`,$Y=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(ZY),a;return i!==null&&i!==``?(a=i,n(e=>e.setItem(QY,i))):a=n(e=>e.getItem(QY)),r.searchParams.has(ZY)&&(r.searchParams.delete(ZY),e.history.replaceState(e.history.state,``,`${r.pathname}${r.search}${r.hash}`)),{get value(){return a},reject(e){let t=n(e=>e.getItem(QY));return t===e&&n(e=>e.removeItem(QY)),a=t!==null&&t!==e?t:null,a}}},eX=document.getElementById(`root`);if(eX===null)throw Error(`index.html has no #root`);(0,bc.createRoot)(eX).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(XY,{children:(0,Y.jsx)(JY,{token:$Y(window),fetch:window.fetch.bind(window)})})}));export{s as t};