1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e8275712-1437-4925-b2a0-858a1c2db03d",e._sentryDebugIdIdentifier="sentry-dbid-e8275712-1437-4925-b2a0-858a1c2db03d")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8518],{435:(e,t,s)=>{s.d(t,{jz:()=>n,pJ:()=>l,vw:()=>a});let n={hook_resid_pre:{displayName:"Residual Stream Pre",sourceSetSuffix:"resid-pre"},hook_resid_post:{displayName:"Residual Stream Post",sourceSetSuffix:"resid-post"}};function a(e){var t;return null==e||null==(t=e.layer)?void 0:t.includes("-neuronpedia")}function l(e){return(null==e?void 0:e.vector)&&e.vector.length>0}},7270:(e,t,s)=>{s.d(t,{z:()=>i});var n,a=s(90747),l=s(39493);let r=globalThis,i=null!=(n=r.prisma)?n:new l.PrismaClient;"production"!==a.X$&&(r.prisma=i)},13637:(e,t,s)=>{s.d(t,{Et:()=>o,d0:()=>i,jc:()=>r});var n=s(95155),a=s(64089);s(12115);var l=s(69236);function r(e){let{...t}=e;return(0,n.jsx)(a.bL,{"data-slot":"hover-card",...t,"data-sentry-element":"HoverCardPrimitive.Root","data-sentry-component":"HoverCard","data-sentry-source-file":"hover-card.tsx"})}function i(e){let{...t}=e;return(0,n.jsx)(a.l9,{"data-slot":"hover-card-trigger",...t,"data-sentry-element":"HoverCardPrimitive.Trigger","data-sentry-component":"HoverCardTrigger","data-sentry-source-file":"hover-card.tsx"})}function o(e){let{className:t,align:s="center",sideOffset:r=4,...i}=e;return(0,n.jsx)(a.ZL,{"data-slot":"hover-card-portal","data-sentry-element":"HoverCardPrimitive.Portal","data-sentry-component":"HoverCardContent","data-sentry-source-file":"hover-card.tsx",children:(0,n.jsx)(a.UC,{"data-slot":"hover-card-content",align:s,sideOffset:r,className:(0,l.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 origin-(--radix-hover-card-content-transform-origin) outline-hidden z-50 w-64 rounded-md border p-4 shadow-md",t),...i,"data-sentry-element":"HoverCardPrimitive.Content","data-sentry-source-file":"hover-card.tsx"})})}},31050:(e,t,s)=>{s.d(t,{default:()=>ey});var n=s(95155),a=s(79276),l=s(85556),r=s(96851),i=s(62195),o=s(45108),d=s(78234),c=s(18695),x=s(33210),m=s(37882),u=s(98500),p=s.n(u),f=s(12115);function h(e){let{initialComments:t,neuron:s}=e,a=(0,m.useSession)(),{setSignInModalOpen:l}=(0,c.SF)(),{comments:r,setComments:i,submitComment:o,isSubmittingComment:u,deleteComment:h}=(0,d.MZ)(),[v,y]=(0,f.useState)(""),[b,g]=(0,f.useState)(!1);function j(){var e;return(null==(e=a.data)?void 0:e.user)?(y(v.trim()),v.length<5)?void alert("Comment too short. Minimum length 5 characters."):v.length>1024?void alert("Comment too long. Maximum length 1024 characters."):void(s&&o(v,s.modelId,s.layer,s.index).then(()=>{y("")})):void l(!0)}return(0,f.useEffect)(()=>{i(t)},[t,i]),(0,n.jsxs)("div",{className:"overflow-hidden rounded-lg rounded-t-none bg-white","data-sentry-component":"CommentsPane","data-sentry-source-file":"comments-pane.tsx",children:[0===r.length?(0,n.jsx)("div",{children:(0,n.jsx)("div",{className:"flex h-16 w-full flex-col items-center justify-center",children:(0,n.jsx)("h1",{className:"text-sm font-bold text-slate-300",children:"No Comments"})})}):(0,n.jsx)("div",{className:"px-1 py-2.5 text-left",children:r.map(e=>{var t,s,l,r,i;return(0,n.jsxs)("div",{className:"relative grid-cols-[auto_1fr] gap-1.5 py-1 pl-3 pr-6 text-sm leading-tight text-slate-600",children:[(0,n.jsx)(p(),{className:"whitespace-nowrap text-xs font-semibold text-slate-400/70 hover:text-sky-500",href:"/user/".concat(null==(t=e.user)?void 0:t.name),prefetch:!1,children:null==(s=e.user)?void 0:s.name}),(0,n.jsx)("div",{className:"text-[13px]",children:e.text}),(null==(l=e.user)?void 0:l.name)===((null==(i=a.data)||null==(r=i.user)?void 0:r.name)||"notmatch")&&(0,n.jsx)(x.A,{className:"absolute right-2 top-1 h-3 w-3 cursor-pointer text-slate-300 hover:text-red-500",strokeWidth:3,onClick:t=>{t.preventDefault(),h(e.id,e.text)}})]},e.id)})}),(0,n.jsx)("div",{className:"px-2 pb-2 pt-0",children:(0,n.jsxs)("div",{className:"flex w-full flex-row gap-0",id:"submitCommentFieldAndButton",children:[(0,n.jsx)("label",{htmlFor:"commentText",className:"mt-0 grow","aria-label":"Add Comment",children:(0,n.jsx)("input",{id:"commentText",name:"commentText",value:v,onKeyUp:e=>{"Enter"===e.key&&j()},onChange:e=>{y(e.target.value),e.target.value.length>0?g(!0):g(!1)},required:!0,className:"text-left ".concat(b?"rounded-l-md":"rounded-md"," form-input mt-0 block w-full border-0 bg-slate-200 px-2 py-2 text-xs font-normal text-slate-700 placeholder-slate-700/60 focus:outline-none focus:ring-0 sm:py-2"),placeholder:"Add Comment"})}),(0,n.jsx)("button",{type:"submit",disabled:u,onClick:()=>{j()},className:"".concat(b?"px-2 sm:px-3":"w-0 px-0"," font-semi overflow-hidden rounded-r-md bg-slate-400 font-mono text-xs font-semibold uppercase text-white transition-all hover:bg-slate-300 hover:text-slate-700 focus:ring-0 disabled:bg-slate-300 disabled:text-slate-400"),children:"ADD"})]})})]})}var v=s(64069),y=s(95999),b=s(43312),g=s(7270),j=s(90747),w=s(34300);let N=async function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n={where:{modelId_name:{modelId:e,name:t},...(0,w.B3)(s,w.by.EVERYONE)},include:{sources:{where:(0,w.B3)(s,w.by.CREATOR_AND_ALLOWED_USERS)},releases:{where:(0,w.B3)(s,w.by.EVERYONE)},model:!0}};return g.z.sourceSet.findUnique(n)};var k=s(36376),S=s(23714),C=s(97285);function I(e){let{currentNeuron:t}=e,{setFeatureModalFeature:s,setFeatureModalOpen:a,getSource:l}=(0,c.SF)(),[r,i]=(0,f.useState)([]),[o,d]=(0,f.useState)(10),[x,m]=(0,f.useState)([]),[u,h]=(0,f.useState)([]),[v,g]=(0,f.useState)(void 0);return(0,f.useEffect)(()=>
1{if(t&&t.topkCosSimIndices&&t.topkCosSimIndices.length>0&&fetch("/api/features",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.topkCosSimIndices.filter((e,s)=>e.toString()!==t.index.toString()&&s<=50).map(e=>({modelId:t.modelId,layer:t.layer,index:e,maxActsToReturn:3})))}).then(e=>e.json()).then(e=>{i(e)}),t&&t.layer){let e=l(t.modelId,t.layer);e&&e.cosSimMatchSourceId&&e.cosSimMatchModelId&&(g(l(e.cosSimMatchModelId,e.cosSimMatchSourceId)),fetch("/api/cossim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:t.modelId,source:t.layer,index:t.index,targetModelId:e.cosSimMatchModelId,targetSourceId:e.cosSimMatchSourceId})}).then(e=>e.json()).then(t=>{var s;let n=[];t.topkDecoderCossimFeatures&&t.topkDecoderCossimFeatures.forEach(e=>{var t,s;(null==(t=e.feature)?void 0:t.index)&&n.push(null==(s=e.feature)?void 0:s.index)});let a=n.map(t=>({modelId:e.cosSimMatchModelId,layer:e.cosSimMatchSourceId,index:t.toString(),maxActsToReturn:3}));return h((null==(s=t.topkDecoderCossimFeatures)?void 0:s.map(e=>e.cosineSimilarity||0))||[]),fetch("/api/features",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}).then(e=>e.json()).then(e=>{m(e)}).catch(e=>{}))}},[t,N]),(0,n.jsxs)("div",{className:"mt-2 hidden flex-col gap-x-2 overflow-hidden rounded-lg border bg-white px-3 pb-4 pt-2 text-xs shadow transition-all sm:mt-3 ".concat((null==t?void 0:t.topkCosSimIndices)&&(null==t?void 0:t.topkCosSimIndices.length)>0||v?"sm:flex":"sm:hidden"),"data-sentry-component":"CosSimPane","data-sentry-source-file":"cossim-pane.tsx",children:[(0,n.jsxs)("div",{className:"mb-1.5 flex w-full flex-row items-center justify-center gap-x-1 text-[10px] font-normal uppercase text-slate-400",children:["Top Features by Cosine Similarity",(0,n.jsx)(k.Kq,{delayDuration:0,skipDelayDuration:0,"data-sentry-element":"Tooltip.Provider","data-sentry-source-file":"cossim-pane.tsx",children:(0,n.jsxs)(k.bL,{"data-sentry-element":"Tooltip.Root","data-sentry-source-file":"cossim-pane.tsx",children:[(0,n.jsx)(k.l9,{asChild:!0,"data-sentry-element":"Tooltip.Trigger","data-sentry-source-file":"cossim-pane.tsx",children:(0,n.jsx)("button",{type:"button",children:(0,n.jsx)(S.A,{className:"h-2.5 w-2.5","data-sentry-element":"HelpCircle","data-sentry-source-file":"cossim-pane.tsx"})})}),(0,n.jsx)(k.ZL,{"data-sentry-element":"Tooltip.Portal","data-sentry-source-file":"cossim-pane.tsx",children:(0,n.jsxs)(k.UC,{className:"rounded bg-slate-500 px-3 py-2 text-xs text-white",sideOffset:5,"data-sentry-element":"Tooltip.Content","data-sentry-source-file":"cossim-pane.tsx",children:["Top features by cosine similarity to this feature.",(0,n.jsx)(k.i3,{className:"fill-slate-500","data-sentry-element":"Tooltip.Arrow","data-sentry-source-file":"cossim-pane.tsx"})]})})]})})]}),(null==t?void 0:t.topkCosSimIndices)&&(null==t?void 0:t.topkCosSimValues)&&(null==t?void 0:t.topkCosSimIndices.length)>0&&(0,n.jsxs)("div",{className:"relative flex-col",children:[(0,n.jsxs)("div",{className:"mb-1 w-full text-center text-[10px] font-normal uppercase text-slate-400",children:["Comparing With"," ",(0,n.jsxs)(p(),{prefetch:!1,href:"/".concat(t.modelId,"/").concat(t.layer),className:"text-[10px] text-sky-700 hover:underline",children:[t.modelId.toUpperCase()," @ ",t.layer]})]}),(0,n.jsxs)("div",{className:"relative flex w-full flex-col gap-y-0.5 text-slate-600",children:[r.length>0?r.filter((e,t)=>t<=o).map((e,l)=>{var r,i;return(0,n.jsxs)(y.default,{trigger:(0,n.jsxs)("div",{className:"mx-0 flex w-full cursor-pointer flex-row items-center gap-x-4 py-0.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{s({modelId:e.modelId||"",layer:e.layer||"",index:e.index.toString()}),a(!0)},className:"cursor-pointer text-left text-[11px] leading-snug text-sky-700 hover:cursor-pointer hover:underline",children:(()=>{if(e.explanations&&e.explanations.length>0){var t,s,n,a,l,r,i,o,d;return(null==(s=e.explanations)||null==(t=s[0])?void 0:t.description)&&(null==(l=e.explanations)||null==(a=l[0])||null==(n=a.description)?void 0:n.length)>128?"".concat(null==(d=e.explanations)||null==(o=d[0].description)?void 0:o.slice(0,128),"..."):null==(i=e.explanations)||null==(r=i[0])?void 0:r.description}return"".concat(e.modelId.toUpperCase()," | ").concat(e.layer.toUpperCase()," | Index ").concat(e.index)})()}),(0,n.jsx)("div",{className:"flex-1 text-right font-mono text-[10px] font-medium text-slate-400",children:null==t||null==(i=t.topkCosSimValues)||null==(r=i[l+1])?void 0:r.toFixed(2)})]},e.index),children:[e.modelId.toUpperCase(),(0,n.jsx)("br",{}),e.layer.toUpperCase(),(0,n.jsx)("br",{}),"Index ",e.index]},e.index)}):(0,n.jsx)("div",{className:"flex h-20 flex-col items-center justify-center text-xs font-bold text-slate-300 sm:h-16 sm:text-sm",children:(0,n.jsx)(C.K,{size:18,className:"text-sky-700"})}),r.length>
1o&&(0,n.jsx)("div",{className:"mt-1.5 flex w-full flex-row items-center justify-center gap-x-1.5",children:(0,n.jsx)(b.$,{variant:"outline",size:"sm",className:"h-6 text-[10px] text-slate-400",onClick:()=>d(50),children:"Show More"})})]})]}),v&&(0,n.jsxs)("div",{className:"relative flex-col",children:[(0,n.jsxs)("div",{className:"mb-1 w-full text-center text-[10px] font-normal uppercase text-slate-400",children:["Comparing With"," ",(0,n.jsxs)(p(),{prefetch:!1,href:"/".concat(v.modelId,"/").concat(v.id),className:"text-[10px] text-sky-700 hover:underline",children:[v.modelId.toUpperCase()," @ ",v.id]})]}),(0,n.jsx)("div",{className:"relative flex w-full flex-col gap-y-0.5 text-slate-600",children:x.length>0?x.filter((e,t)=>t<=o).map((e,t)=>{var l;return(0,n.jsxs)(y.default,{trigger:(0,n.jsxs)("div",{className:"mx-0 flex w-full cursor-pointer flex-row items-center gap-x-4 py-0.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{s({modelId:e.modelId||"",layer:e.layer||"",index:e.index.toString()}),a(!0)},className:"cursor-pointer text-left text-[11px] leading-snug text-sky-700 hover:cursor-pointer hover:underline",children:(()=>{if(e.explanations&&e.explanations.length>0){var t,s,n,a,l,r,i,o,d;return(null==(s=e.explanations)||null==(t=s[0])?void 0:t.description)&&(null==(l=e.explanations)||null==(a=l[0])||null==(n=a.description)?void 0:n.length)>128?"".concat(null==(d=e.explanations)||null==(o=d[0].description)?void 0:o.slice(0,128),"..."):null==(i=e.explanations)||null==(r=i[0])?void 0:r.description}return"".concat(e.modelId.toUpperCase()," | ").concat(e.layer.toUpperCase()," | Index ").concat(e.index)})()}),(0,n.jsx)("div",{className:"flex-1 text-right font-mono text-[10px] font-medium text-slate-400",children:null==u||null==(l=u[t])?void 0:l.toFixed(2)})]},e.index),children:[e.modelId.toUpperCase(),(0,n.jsx)("br",{}),e.layer.toUpperCase(),(0,n.jsx)("br",{}),"Index ",e.index]},e.index)}):(0,n.jsx)("div",{className:"flex h-20 flex-col items-center justify-center text-xs font-bold text-slate-300 sm:h-16 sm:text-sm",children:(0,n.jsx)(C.K,{size:18,className:"text-sky-700"})})})]})]})}var T=s(47279),E=s(77830),A=s.n(E),_=s(94514),D=s(67635);function L(e){var t,s;let{currentNeuron:a,testTextResult:l}=e,[r,i]=(0,f.useState)(!0),[o,d]=(0,f.useState)(!0),[c,x]=(0,f.useState)(!0),[m,u]=(0,f.useState)(!1),[h,v]=(0,f.useState)(!0),[y,b]=(0,f.useState)(!0),[g,w]=(0,f.useState)(!0);return(0,n.jsxs)("div",{className:"relative mb-0 mt-2 hidden flex-col gap-x-2 overflow-hidden rounded-lg border bg-white px-3 pb-5 pt-2 text-xs shadow transition-all sm:mt-3 sm:flex","data-sentry-component":"EmbedsPane","data-sentry-source-file":"embeds-pane.tsx",children:[(0,n.jsxs)("div",{className:"mb-2 flex w-full flex-row items-center justify-center gap-x-1 text-[10px] font-normal uppercase text-slate-400",children:["Embeds",(0,n.jsx)(p(),{href:"https://docs.neuronpedia.org/embed-iframe",target:"_blank",rel:"noreferrer","data-sentry-element":"Link","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(S.A,{className:"h-3 w-3","data-sentry-element":"HelpCircle","data-sentry-source-file":"embeds-pane.tsx"})})]}),(0,n.jsxs)("div",{className:"mt-1 flex w-full flex-col gap-x-2 gap-y-1.5",children:[(0,n.jsxs)("div",{className:"grid grid-cols-3 items-center gap-y-1.5 px-1",children:[(0,n.jsxs)("label",{className:"flex flex-row items-center gap-x-1 leading-none text-slate-400",htmlFor:"c2",children:[(0,n.jsx)(T.bL,{className:"flex h-4 w-4 appearance-none items-center justify-center rounded-[3px] border border-slate-300 bg-white outline-none",defaultChecked:!0,checked:o,onCheckedChange:e=>{!0===e?d(!0):d(!1)},id:"c2","data-sentry-element":"Checkbox.Root","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(T.C1,{className:"text-sky-700","data-sentry-element":"Checkbox.Indicator","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"embeds-pane.tsx"})})}),"Show Plots"]}),(0,n.jsxs)("label",{className:"flex flex-row items-center gap-x-1 leading-none text-slate-400",htmlFor:"c1",children:[(0,n.jsx)(T.bL,{className:"flex h-4 w-4 appearance-none items-center justify-center rounded-[3px] border border-slate-300 bg-white outline-none",defaultChecked:!0,checked:r,onCheckedChange:e=>{!0===e?i(!0):i(!1)},id:"c1","data-sentry-element":"Checkbox.Root","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(T.C1,{className:"text-sky-700","data-sentry-element":"Checkbox.Indicator","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"embeds-pane.tsx"})})}),"Show Explanation"]}),(0,n.jsxs)("label",{className:"flex flex-row items-center gap-x-1 leading-none text-slate-400",htmlFor:"c5",children:[(0,n.jsx)(T.bL,{className:"flex h-4 w-4 appearance-none items-center justify-center rounded-[3px] border border-slate-300 bg-white outline-none",defaultChecked:!0,checked:h,onCheckedChange:e=>{!0===e?v(!0):v(!1)},id:"c5","data-sentry-element":"Checkbox.Root","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(T.C1,{className:"text-sky-700","data-sentry-element":"Checkbox.Indicator","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"embeds-pane.tsx"})})}),"Show Activations"]}),(0,n.jsxs)("label",{className:"flex flex-row items-center gap-x-1 leading-none text-slate-400",htmlFor:"c3",children:[(0,n.jsx)(T.bL,{className:"flex h-4 w-4 appearance-none items-center justify-center rounded-[3px] border border-slate-300 bg-white outline-none",defaultChecked:!0,onCheckedChange:e=>{!0===e?x(!0):x(!1)},id:"c3","data-sentry-element":"Checkbox.Root","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(T.C1,{className:"text-sky-700","data-sentry-element":"Checkbox.Indicator","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"embeds-pane.tsx"})})}),"Show Test Field"]}),(0,n.jsxs)("label",{className:"flex flex-row items-center gap-x-1 leading-none text-slate-400",htmlFor:"c7",children:[(0,n.jsx)(T.bL,{className:"flex h-4 w-4 appearance-none items-center justify-center rounded-[3px] border border-slate-300 bg-white outline-none",defaultChecked:!0,checked:g,onCheckedChange:e=>{!0===e?w(!0):w(!1)},id:"c7","data-sentry-element":"Checkbox.Root","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(T.C1,{className:"text-sky-700","data-sentry-element":"Checkbox.Indicator","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"embeds-pane.tsx"})})}),"Show Steer"]}),(0,n.jsxs)("label",{className:"flex flex-row items-center gap-x-1 leading-none text-slate-400",htmlFor:"c6",children:[(0,n.jsx)(T.bL,{className:"flex h-4 w-4 appearance-none items-center justify-center rounded-[3px] border border-slate-300 bg-white outline-none",defaultChecked:!0,checked:y,onCheckedChange:e=>{!0===e?b(!0):b(!1)},id:"c6","data-sentry-element":"Checkbox.Root","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(T.C1,{className:"text-sky-700","data-sentry-element":"Checkbox.Indicator","data-sentry-source-file":"embeds-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"embeds-pane.tsx"})})}),"Show Link"]})]}),(0,n.jsxs)("div",{className:"mt-0.5 flex flex-1 flex-col",children:[(0,n.jsx)("div",{className:"text-left text-[10px] font-bold uppercase text-slate-400",children:"IFrame"}),(0,n.jsxs)("div",{className:"mt-0.5 flex flex-row items-center justify-center gap-x-1.5",children:[(0,n.jsx)("textarea",{disabled:!0,className:"disabled form-input block h-8 w-full resize-none whitespace-pre-wrap break-words rounded-md border-0 bg-slate-100 px-2.5 py-[5px] font-mono text-[8px] leading-normal text-slate-500 outline-none focus:outline-none focus:ring-0",value:'<iframe src="'.concat(j._T,"/").concat(null==a?void 0:a.modelId,"/").concat(null==a?void 0:a.layer,"/").concat(null==a?void 0:a.index,"?embed=true&embedexplanation=").concat(r?"true":"false","&embedplots=").concat(o?"true":"false","&embedsteer=").concat(g?"true":"false","&embedactivations=").concat(h?"true":"false","&embedlink=").concat(y?"true":"false","&embedtest=").concat(c?"true":"false").concat(m?"&defaulttesttext=".concat(encodeURIComponent((null==l||null==(t=l.tokens)?void 0:t.join(""))||"")):"",'" title="Neuronpedia" style="height: 300px; width: 540px;"></iframe>')}),(0,n.jsx)("button",{type:"button",onClick:e=>{var t;e.preventDefault(),A()('<iframe src="'.concat(j._T,"/").concat(null==a?void 0:a.modelId,"/").concat(null==a?void 0:a.layer,"/").concat(null==a?void 0:a.index,"?embed=true&embedexplanation=").concat(r?"true":"false","&embedplots=").concat(o?"true":"false","&embedsteer=").concat(g?"true":"false","&embedactivations=").concat(h?"true":"false","&embedlink=").concat(y?"true":"false","&embedtest=").concat(c?"true":"false").concat(m?"&defaulttesttext=".concat(encodeURIComponent((null==l||null==(t=l.tokens)?void 0:t.join(""))||"")):"",'" title="Neuronpedia" style="height: 300px; width: 540px;"></iframe>'))},children:(0,n.jsx)(D.A,{className:"h-8 w-8 rounded-md bg-slate-200 px-2 py-2 text-slate-400 hover:bg-slate-300 active:bg-sky-300","data-sentry-element":"Copy","data-sentry-source-file":"embeds-pane.tsx"})})]})]}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col",children:[(0,n.jsx)("div",{className:"flex flex-row justify-start",children:(0,n.jsx)("div",{className:"text-left text-[10px] font-bold uppercase text-slate-400",children:"Link"})}),(0,n.jsxs)("div",{className:"mt-0.5 flex flex-row items-center justify-center gap-x-1.5",children:[(0,n.jsx)("textarea",{disabled:!0,className:"disabled form-input block h-8 w-full resize-none whitespace-pre-wrap break-words rounded-md border-0 bg-slate-100 px-2.5 py-[5px] font-mono text-[8px] leading-normal text-slate-500 outline-none focus:outline-none focus:ring-0",value:"".concat(j._T,"/").concat(null==a?void 0:a.modelId,"/").concat(null==a?void 0:a.layer,"/").concat(null==a?void 0:a.index,"?embed=true&embedexplanation=").concat(r?"true":"false","&embedplots=").concat(o?"true":"false","&embedsteer=").concat(g?"true":"false","&embedactivations=").concat(h?"true":"false","&embedlink=").concat(y?"true":"false","&embedtest=").concat(c?"true":"false").concat(m?"&defaulttesttext=".concat(encodeURIComponent((null==l||null==(s=l.tokens)?void 0:s.join(""))||"")):"")}),(0,n.jsx)("button",{type:"button",onClick:e=>{var t;e.preventDefault(),A()("".concat(j._T,"/").concat(null==a?void 0:a.modelId,"/").concat(null==a?void 0:a.layer,"/").concat(null==a?void 0:a.index,"?embed=true&embedexplanation=").concat(r?"true":"false","&embedplots=").concat(o?"true":"false","&embedsteer=").concat(g?"true":"false","&embedactivations=").concat(h?"true":"false","&embedlink=").concat(y?"true":"false","&embedtest=").concat(c?"true":"false").concat(m?"&defaulttesttext=".concat(encodeURIComponent((null==l||null==(t=l.tokens)?void 0:t.join(""))||"")):""))},children:(0,n.jsx)(D.A,{className:"h-8 w-8 rounded-md bg-slate-200 px-2 py-2 text-slate-400 hover:bg-slate-300 active:bg-sky-300","data-sentry-element":"Copy","data-sentry-source-file":"embeds-pane.tsx"})})]})]})]})]})}var M=s(68822),P=s(53869),O=s(30208);let U={top:"Top Activation",zero:"Intruder (Zero Activation)",decoy:"Intruder"};function R(e){let{group:t}=e;return(0,n.jsx)(n.Fragment,{children:t.examples.map((e,s)=>{let a=s===t.picked_index,l=Math.max(...e.values);return(0,n.jsxs)("tr",{className:e.is_intruder&&a?"bg-emerald-50":e.is_intruder||a?"bg-red-50":"",children:[(0,n.jsx)("td",{className:"whitespace-pre px-2 text-center font-mono text-[10px] text-slate-400",children:s}),(0,n.jsx)("td",{className:"px-2 py-1.5 font-mono text-[10px]",children:(0,n.jsx)(P.default,{tokensToDisplayAroundMaxActToken:64,activation:{tokens:e.tokens,values:e.values,maxValueTokenIndex:e.values.indexOf(l)},overallMaxActivationValueInList:l,overrideTextSize:"text-[10.5px]"})}),(0,n.jsx)("td",{className:"whitespace-pre px-2 text-center",children:U[e.kind]||e.kind}),(0,n.jsxs)("td",{className:"whitespace-pre px-2 text-center",children:[(100*t.probabilities[s]).toFixed(0),"%",a?" \xb7 Picked":""]})]},s)})})}function F(e){var t;let{open:s,onOpenChange:a,loading:l,error:r,result:i,featureLabel:o,explanations:d}=e;return(0,n.jsx)(O.lG,{open:s,onOpenChange:a,"data-sentry-element":"Dialog","data-sentry-component":"InterpretabilityCheckDialog","data-sentry-source-file":"interpretability-check-dialog.tsx",children:(0,n.jsx)(O.Cf,{"aria-describedby":void 0,className:"fixed left-[50%] top-[50%] z-50 flex max-h-[92vh] w-[95vw] max-w-[95vw] translate-x-[-50%] translate-y-[-50%] flex-col items-center justify-center rounded-md bg-slate-50 shadow-xl transition-all focus:outline-none sm:top-[50%] sm:w-[90vw] md:rounded-md md:border md:border-slate-200","data-sentry-element":"DialogContent","data-sentry-source-file":"interpretability-check-dialog.tsx",children:!l&&(i||r)?r?(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-y-2 px-6 py-8",children:[(0,n.jsx)(O.L3,{className:"text-xs font-bold uppercase text-slate-400",children:"Check Failed"}),(0,n.jsx)("div",{className:"text-center text-sm text-red-600",children:r})]}):i&&(0,n.jsxs)("div",{className:"z-50 flex w-full flex-col gap-y-0 overflow-scroll px-0 text-xs",children:[(0,n.jsxs)("div",{className:"top-0 flex w-full flex-col items-start justify-center border-b bg-slate-50 pt-4 sm:sticky",children:[(0,n.jsxs)("div",{className:"mb-4 flex w-full flex-col items-start gap-y-1 px-2 pr-10 sm:flex-row sm:items-center sm:justify-between sm:gap-x-4 sm:px-6 sm:pr-12",children:[(0,n.jsxs)(O.L3,{className:"flex flex-row items-center gap-x-1.5 text-sm font-medium text-slate-700",children:["Interpretable Score (Intrusion Detection)",(0,n.jsx)(y.default,{trigger:(0,n.jsx)("span",{className:"ml-1 cursor-pointer rounded border border-sky-600 bg-white px-1.5 py-1 text-[9px] font-bold uppercase tracking-wide text-sky-700 transition-colors hover:bg-sky-600 hover:text-white",children:"How It Works"}),side:"bottom",wide:!0,children:(0,n.jsxs)("p",{className:"leading-relaxed",children:["We score how interpretable a latent is by seeing if a judge model is able to distinguish the"," ","latent's"," true top activations from fake activations (",(0,n.jsx)("a",{href:"https://arxiv.org/pdf/2507.08473",target:"_blank",rel:"noreferrer",className:"text-sky-700 underline hover:text-sky-900",children:"Paulo & Belrose, 2025"}),"). We show the judge model groups of five activation samples. In each group, there are four true top activations, and one ",'"intruder"'," (a zero or made up activation). The judge model is asked to identify the intruder. The overall score is the percentage of times that the judge correctly picked the intruder."]})})]}),(0,n.jsx)("div",{className:"truncate text-xs font-medium text-slate-500 sm:text-right",children:o})]}),(0,n.jsxs)("div",{className:"relative mb-4 flex w-full flex-col gap-x-5 gap-y-4 px-2 text-left text-sm text-slate-600 sm:flex-row sm:px-6 sm:text-base",children:[(0,n.jsxs)("div",{className:"flex flex-col items-start sm:basis-2/6",children:[(0,n.jsx)("div",{className:"mb-0 text-[10px] font-medium uppercase text-slate-400",children:"Score"}),(0,n.jsxs)("div",{className:"flex flex-row items-center gap-x-3",children:[(0,n.jsx)("div",{className:"rounded-xl p-3 text-lg font-bold text-white ".concat((t=i.score)>=80?"bg-emerald-500":t>=60?"bg-amber-500":"bg-red-500"),children:i.score}),(0,n.jsxs)("div",{className:"text-xs text-slate-600",children:[i.correct," of ",i.total," Intruders Detected"]})]})]}),(0,n.jsxs)("div",{className:"flex flex-col sm:basis-1/3",children:[(0,n.jsx)("div",{className:"mb-0 flex flex-row items-center gap-x-1 text-[10px] font-medium uppercase text-slate-400",children:"Current Explanations"}),0===d.length?(0,n.jsx)("div",{className:"text-xs text-slate-400",children:"No explanations yet."}):(0,n.jsx)("div",{className:"flex max-h-36 flex-col gap-y-1.5 overflow-y-auto pr-1",children:d.map(e=>(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("div",{className:"text-xs leading-snug text-slate-700",chil
1dren:e.description}),(0,n.jsx)("div",{className:"font-sans text-[10px] font-medium text-slate-400",children:e.typeName?"".concat(e.typeName," \xb7 ").concat(e.explanationModelName):"human"})]},e.id))})]}),(0,n.jsxs)("div",{className:"flex flex-col sm:basis-2/6",children:[(0,n.jsx)("div",{className:"mb-0 text-[10px] font-medium uppercase text-slate-400",children:"Judge Model"}),(0,n.jsx)("div",{className:"font-mono text-xs text-slate-600",children:i.model})]})]})]}),(0,n.jsx)("div",{className:"flex w-full flex-col divide-y divide-slate-200 px-5 pb-10 text-slate-600",children:i.groups.map((e,t)=>(0,n.jsxs)("div",{className:"flex flex-col gap-y-1 py-4",children:[(0,n.jsxs)("div",{className:"flex flex-row flex-wrap items-center gap-x-3 text-[10px] font-medium uppercase text-slate-400",children:[(0,n.jsxs)("span",{children:["Group ",t+1]}),(0,n.jsxs)("span",{children:["Intruder at ",e.intruder_index]}),(0,n.jsxs)("span",{children:["Picked ",e.picked_index," (",(100*e.probabilities[e.picked_index]).toFixed(0),"%)"]}),(0,n.jsx)("span",{className:e.correct?"font-bold text-emerald-600":"font-bold text-red-600",children:e.correct?"Correct":"Incorrect"})]}),(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"whitespace-pre px-2 py-1.5 text-[10px] text-slate-400",children:"#"}),(0,n.jsx)("th",{className:"gap-x-1 whitespace-pre px-2 py-1.5 text-left",children:"Text"}),(0,n.jsxs)("th",{className:"gap-x-1 whitespace-pre px-2 py-1.5",children:["Truth"," ",(0,n.jsx)(y.default,{trigger:(0,n.jsx)(M.A,{className:"h-3 w-3"}),children:"Top activations fire this feature. The intruder is a zero-activation text for this feature, or a made up one when none is stored."})]}),(0,n.jsxs)("th",{className:"gap-x-1 whitespace-pre px-2 py-1.5",children:["Model's"," Pick"," ",(0,n.jsxs)(y.default,{trigger:(0,n.jsx)(M.A,{className:"h-3 w-3"}),children:["The judge model's"," probability that this text is the intruder. The five sum to 100%."]})]})]})}),(0,n.jsx)("tbody",{children:(0,n.jsx)(R,{group:e})})]})]},t))})]}):(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-y-4 py-5",children:[(0,n.jsx)(O.L3,{className:"text-center",children:(0,n.jsx)("div",{className:"text-sm font-medium text-slate-400",children:"Performing Intruder Detection Check..."})}),(0,n.jsx)(C.K,{size:32,className:"text-sky-700"})]})})})}var z=s(51002),B=s(70147);let J={"gemma-3-27b-it":{41:function(e){return e.SAELens="SAELens",e.GemmaScope2="GemmaScope2",e}({}).GemmaScope2}};var W=s(57303),V=s(61108),H=s(67198),K=s(45384),Y=s(66088),Z=s(68458),G=s(44867);function q(e){var t,s,a;let{currentNeuron:l,setCurrentNeuron:r}=e,{getSourceSet:i,explanationTypes:o,explanationModels:d,explanationScoreTypes:m,explanationScoreModelTypes:u,setSignInModalOpen:h,showToastServerError:v,showToastMessage:g,user:j}=(0,c.SF)(),[w,N]=(0,f.useState)([]),[k,I]=(0,f.useState)(!1),[T,E]=(0,f.useState)(),{loadExplanationScoreDetail:A}=(0,z.TN)(),[_,D]=(0,f.useState)(void 0),[L,P]=(0,f.useState)(d.length>0?d[0]:void 0),[O,U]=(0,f.useState)(void 0),[R,q]=(0,f.useState)(u.length>0?u.filter(e=>e.featured)[0]:void 0),[$,X]=(0,f.useState)(!1),[Q,ee]=(0,f.useState)(!1),[et,es]=(0,f.useState)(!1),[en,ea]=(0,f.useState)(""),[el,er]=(0,f.useState)(null),[ei,eo]=(0,f.useState)(null),ed=(0,f.useRef)(null),[ec,ex]=(0,f.useState)(!1),[em,eu]=(0,f.useState)(!1),[ep,ef]=(0,f.useState)(null),[eh,ev]=(0,f.useState)(null);(0,f.useEffect)(()=>{w.length>0&&D(w[0])},[w]),(0,f.useEffect)(()=>{m.length>0&&U(m.filter(e=>e.featured).reverse()[0])},[m]),(0,f.useEffect)(()=>{N(o.filter(e=>{let t=i((null==l?void 0:l.modelId)||"",(null==l?void 0:l.sourceSetName)||"");return t&&t.showDfa?e.isAttention:!e.isAttention}).sort((e,t)=>{var s,n,a,l;return(null!=(a=null==(s=e.createdAt)?void 0:s.getTime())?a:0)-(null!=(l=null==(n=t.createdAt)?void 0:n.getTime())?l:0)}))},[o,l,i]);let ey=(()=>{if(!(null==l?void 0:l.modelId)||!(null==l?void 0:l.layer))return;let e=(0,W.$B)(l.layer),t=J[l.modelId];return t?t[e]:void 0})(),eb=void 0!==ey,eg=async()=>{if((null==l?void 0:l.modelId)&&(null==l?void 0:l.layer)&&(null==l?void 0:l.index)){ex(!0),eu(!0),ef(null),ev(null);try{let e=await fetch("/api/feature/interpretable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:l.modelId,layer:l.layer,index:l.index})}),t=await e.json();
1e.ok?ef(t):ev(t.message||t.error||"Error: ".concat(e.status))}catch(e){ev(e instanceof Error?e.message:"Unknown error")}finally{eu(!1)}}},ej=async()=>{var e,t,s,n;let a=null==l||null==(e=l.source)?void 0:e.hfRepoId,r=null==l||null==(t=l.source)?void 0:t.hfFolderId,i=(null==l?void 0:l.index)!==void 0?parseInt(l.index,10):void 0,o=null==l?void 0:l.modelId,d=null==l?void 0:l.layer;if(!a||!r||void 0===i||Number.isNaN(i)||!ey||!o||!d)return;let c=(0,W.$B)(d);null==(s=ed.current)||s.abort();let x=new AbortController;ed.current=x,ee(!0),es(!0),ea(""),er(null),eo(null);try{let e=await fetch("/api/nla/explain-saelens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hfRepoId:a,hfFolderId:r,index:i,format:ey,modelId:o,layerNum:c}),signal:x.signal});if(!e.ok){let t=await e.json();eo(t.error||"Error: ".concat(e.status)),es(!1);return}if(!e.body){eo("No response body"),es(!1);return}let t=e.body.pipeThrough(new TextDecoderStream).pipeThrough(new K.Z).getReader();for(;;){let{done:e,value:s}=await t.read();if(e)break;let a=s.data;if("[DONE]"===a)break;let l=JSON.parse(a);"done"in l&&!1===l.done?ea((l.text||"").replace(/<\/?explanation>/g,"").replace(/<explanation\s*$/g,"").replace(/<\/explanation\s*$/g,"").trim()):"description"in l&&(er({description:l.description,cosine_similarity:null!=(n=l.cosine_similarity)?n:null}),ea(""))}}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;eo(e instanceof Error?e.message:"Unknown error")}finally{es(!1),ed.current=null}};return(0,n.jsxs)("div",{className:"relative mb-0 flex flex-col gap-x-2 overflow-hidden border bg-white px-0 pb-0 pt-2 text-xs transition-all sm:rounded-lg sm:shadow","data-sentry-component":"ExplanationsPane","data-sentry-source-file":"explanations-pane.tsx",children:[(0,n.jsxs)("div",{className:"mb-0 flex w-full flex-row items-center justify-center gap-x-1 text-[10px] font-normal uppercase text-slate-400",children:["Explanations",(0,n.jsx)(y.default,{trigger:(0,n.jsx)(S.A,{className:"h-2.5 w-2.5"}),"data-sentry-element":"CustomTooltip","data-sentry-source-file":"explanations-pane.tsx",children:(0,n.jsx)("div",{className:"flex flex-col gap-2",children:(0,n.jsxs)("div",{className:"flex flex-col text-xs font-medium text-slate-500",children:[(0,n.jsxs)("div",{className:"mt-0",children:["⢠",(0,n.jsx)("strong",{children:"Auto-Interp explanations"})," are created by showing an AI model (like GPT4o-mini or Claude 3.5 Sonnet) the top activating texts, then asking it to guess what this feature is about. Various prompting methods are used, including"," ",(0,n.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://openaipublic.blob.core.windows.net/neuron-explainer/paper/index.html#sec-algorithm-explain",className:"font-bold text-sky-700 hover:underline",children:"token activation pairs"}),"."]}),(0,n.jsxs)("div",{className:"mt-2",children:["⢠",(0,n.jsx)("strong",{children:"Scoring of explanations"})," is done with various methods, including"," ",(0,n.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://openaipublic.blob.core.windows.net/neuron-explainer/paper/index.html#sec-algorithm-simulate",className:"font-bold text-sky-700 hover:underline",children:"simulation"}),"."]}),(0,n.jsx)("div",{className:"mt-2",children:"⢠Click the explanation's score to see scoring details."})]})})})]}),l&&l.explanations&&0!==l.explanations.length?(0,n.jsx)("div",{className:"divide-y-slate-100 my-0 flex flex-col divide-y",children:null==l||null==(t=l.explanations)?void 0:t.map(e=>{var t,s,a,i,o,d;return(0,n.jsx)("div",{className:"transition-all",children:(0,n.jsx)("div",{className:"py-2",children:(0,n.jsxs)("div",{className:"relative flex w-full flex-row items-center gap-3 px-2 sm:px-3",children:[(0,n.jsxs)("div",{className:"h-fill flex-1",children:[(0,n.jsx)("div",{className:"flex-inline relative flex items-center",children:(0,n.jsx)("h1",{className:"cursor-text select-text py-0 text-xs font-medium leading-snug text-slate-700",title:e.description,children:e.description})}),(0,n.jsxs)("div",{className:"mt-1.5 flex flex-row items-center justify-between font-mono text-xs text-slate-400",children:[e.typeName&&e.typeName!==B.Sl?(0,n.jsxs)("div",{className:"flex flex-col items-start justify-center gap-y-0.5",children:[(0,n.jsxs)("a",{className:"font-sans text-[11px] font-medium text-slate-500 hover:text-sky-600",href:"/explanation-type/".concat(e.typeName),target:"_blank",rel:"noreferrer",children:[e.typeName," \xb7 ",e.explanationModelName]}),e.triggeredByUser&&(0,n.jsxs)("a",{className:"cursor-pointer font-sans text-[10px] font-medium leading-none text-slate-300 hover:text-sky-600",href:"/user/".concat(null==(o=e.triggeredByUser)?void 0:o.name),target:"_blank",rel:"noreferrer",children:["Triggered by"," @",e.triggeredByUser.name]})]}):(null==(i=e.triggeredByUser)?void 0:i.name)?(0,n.jsx)("button",{type:"button",className:"hidden cursor-pointer font-sans text-[11px] font-medium text-slate-400/70 hover:text-sky-600 sm:inline-block",onClick:t=>{var s;t.preventDefault(),t.stopPropagation(),Z.default.push("/user/".concat(null==(s=e.author)?void 0:s.name))},children:e.triggeredByUser&&(0,n.jsxs)("a",{className:"cursor-pointer font-sans text-[10px] font-medium leading-none text-slate-300 hover:text-sky-600",href:"/user/".concat(null==(d=e.triggeredByUser)?void 0:d.name),target:"_blank",rel:"noreferrer",children:["Triggered by"," @",e.triggeredByUser.name]})}):(0,n.jsx)("div",{className:"font-sans text-[10px] font-medium text-slate-300",children:"Explanation Uploaded by User"}),!(null==l||null==(t=l.sourceSet)?void 0:t.showDfa)&&(0,n.jsxs)(V.bL,{children:[(0,n.jsx)(V.l9,{asChild:!0,children:(0,n.jsxs)(b.$,{variant:"outline",size:"xs",className:"flex flex-row items-center justify-center gap-x-1 whitespace-pre rounded px-2 font-medium text-slate-500 sm:pl-2 sm:pr-1.5",children:[(0,n.jsx)("div",{className:"flex select-none flex-col items-center justify-center gap-y-1 py-1 font-sans text-[10px] leading-none",children:e.scores&&e.scores.length>0?(0,n.jsxs)(n.Fragment,{children:["Avg Score:"," ",(e.scores.reduce((e,t)=>
1e+(t.value||0),0)/e.scores.length*100).toFixed(0)]}):(0,n.jsx)(n.Fragment,{children:"No Scores"})}),(0,n.jsx)(Y.A,{className:"-mr-1 ml-0 h-4 w-4 leading-none text-slate-400"})]})}),(0,n.jsx)(V.ZL,{children:(0,n.jsx)(V.UC,{className:"z-30 max-h-[900px] overflow-hidden rounded-md border border-slate-200 bg-white text-xs font-medium text-slate-500 shadow-lg",sideOffset:2,align:"center",children:(0,n.jsxs)("div",{className:"flex h-full flex-col items-stretch",children:[e.scores&&e.scores.length>0&&(0,n.jsxs)("div",{className:"flex flex-col pb-0.5",children:[(0,n.jsx)("div",{className:"flex items-center justify-center pt-2 text-center text-[10px] uppercase text-slate-400",children:"Current Scores"}),(0,n.jsx)("div",{className:"flex w-full flex-col gap-x-3 gap-y-1 divide-y divide-slate-100 pb-2 pt-1",children:null==(s=e.scores)?void 0:s.sort((e,t)=>(e.explanationScoreTypeName||"").localeCompare(t.explanationScoreTypeName||"")).map(t=>(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-center gap-x-2.5 px-3 pt-1 text-center text-slate-500",children:[(0,n.jsx)(b.$,{onClick:s=>{s.preventDefault(),s.stopPropagation(),A(e,t)},className:"h-auto whitespace-pre rounded-md bg-emerald-500 p-1.5 px-2 text-[12px] font-bold text-white hover:bg-emerald-600",size:"sm",children:(100*(t.value||0)).toFixed(0)}),(0,n.jsxs)("div",{className:"flex flex-1 flex-row items-center justify-start gap-x-0.5 whitespace-pre text-left text-[11px]",children:[t.explanationScoreTypeName," \xb7 ",t.explanationScoreModelName,(0,n.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),window.open("/score-type/".concat(t.explanationScoreTypeName),"_blank","noopener,noreferrer")},className:"rounded p-1 hover:bg-sky-300 hover:text-sky-700",children:(0,n.jsx)(M.A,{className:"h-3 w-3 text-slate-400 hover:text-sky-700"})})]}),(0,n.jsx)("div",{className:"flex flex-row items-center justify-center gap-x-3",children:(0,n.jsx)(b.$,{onClick:s=>{s.preventDefault(),s.stopPropagation(),A(e,t)},variant:"outline",className:"h-7 font-sans text-[11px] text-slate-500",size:"sm",children:"Details"})}),t.initiatedByUserId===(null==j?void 0:j.id)&&j&&(0,n.jsx)("button",{type:"button",onClick:async s=>{if(s.preventDefault(),window.confirm("Delete this score?"))if(200!==(await fetch("/api/explanation/score/".concat(t.id,"/delete"),{method:"POST",headers:{"Content-Type":"application/json"}})).status)v();else{var n,a;let s=null==(n=e.scores)?void 0:n.filter(e=>e.id!==t.id),i=null==l||null==(a=l.explanations)?void 0:a.map(t=>t.id===e.id?{...t,scores:s}:t),o={...l};o.explanations=i,r(o)}},className:"rounded bg-red-400 p-0.5 hover:bg-red-600",children:(0,n.jsx)(x.A,{className:"h-2.5 w-2.5 text-[5px] font-bold uppercase text-white"})})]},t.id))})]}),(0,n.jsxs)("div",{className:"flex w-full min-w-[500px] flex-col items-center justify-center gap-x-1 border-t border-slate-200 px-3 pb-5 pt-3 text-slate-500",children:[(0,n.jsx)("div",{className:"mb-1.5 text-[10px] font-normal uppercase text-slate-400",children:"Generate New Score"}),(0,n.jsxs)("div",{className:"flex w-full flex-row gap-x-2",children:[(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center ".concat((null==O?void 0:O.name)==="eleuther_embedding"||(null==O?void 0:O.name.startsWith("nla_"))?"":"min-w-[calc(50%-35px)] max-w-[calc(50%-35px)]"),children:(0,n.jsxs)(V.bL,{children:[(0,n.jsx)(V.l9,{asChild:!0,children:(0,n.jsxs)("button",{type:"button",className:"flex w-full flex-1 flex-row items-center justify-center gap-x-1 whitespace-pre rounded border border-slate-300 bg-white px-2 text-[11px] font-medium text-slate-500 hover:bg-slate-50 focus:outline-none sm:pl-3 sm:pr-2",children:[(0,n.jsx)("div",{className:"flex flex-col items-center justify-center gap-y-1 py-2 leading-none",children:(0,n.jsx)("div",{className:"flex flex-row items-center justify-center gap-x-0.5",children:(null==O?void 0:O.displayName)||"Scorer Type"})}),(0,n.jsx)(Y.A,{className:"-mr-1 ml-0 w-4 leading-none text-slate-400"})]})}),(0,n.jsx)(V.ZL,{children:(0,n.jsxs)(V.UC,{className:"z-30 max-h-[900px] cursor-pointer overflow-hidden rounded-md border border-slate-300 bg-white text-xs font-medium text-slate-500 shadow",sideOffset:2,align:"center",children:[(0,n.jsx)("div",{className:"bg-slate-200 py-1.5 text-center text-[10px] uppercase text-slate-500",children:"Scorer Types"}),m.filter(e=>e.featured||e.name.startsWith("nla_")&&eb).map(e=>(0,n.jsx)(V.q7,{className:"overflow-hidden ".concat((null==O?void 0:O.name)===e.name?"bg-sky-100 text-slate-600":"text-slate-600"," flex flex-col items-start gap-y-0.5 border-b px-3 py-2.5 font-mono text-xs hover:bg-slate-100 focus:outline-none"),onSelect:()=>U(e),children:(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-between gap-x-3",children:[(0,n.jsx)("span",{className:"",children:e.displayName}),(0,n.jsx)("button",{type:"button",onClick:t=>{t.preventDefault(),t.stopPropagation(),window.open("/score-type/".concat(e.name),"_blank","noopener,noreferrer")},className:"rounded p-1 transition-all hover:bg-sky-300 hover:text-sky-700",children:(0,n.jsx)(M.A,{className:"h-3.5 w-3.5"})})]})},e.name))]})})]})}),(0,n.jsx)("div",{className:"".concat((null==O?void 0:O.name)==="eleuther_embedding"||(null==O?void 0:O.name.startsWith("nla_"))||(null==O?void 0:O.name.startsWith("jev_"))?"hidden":"flex"," min-w-[calc(50%-35px)] max-w-[calc(50%-35px)] flex-1 flex-row items-center justify-start gap-x-2 overflow-hidden text-ellipsis whitespace-pre"),children:(0,n.jsxs)(V.bL,{children:[(0,n.jsx)(V.l9,{asChild:!0,children:(0,n.jsxs)("button",{type:"button",className:"relative flex h-7 w-full flex-row items-center justify-center gap-x-1 overflow-hidden text-ellipsis whitespace-pre rounded border border-slate-300 bg-white px-2 text-[11px] font-medium text-slate-500 hover:bg-slate-50 focus:outline-none sm:pl-3 sm:pr-2",children:[(null==R?void 0:R.displayName)||"Scorer Model",(0,n.jsx)(Y.A,{className:"absolute right-0 bg-white px-1 leading-none text-slate-400"})]})}),(0,n.jsx)(V.ZL,{children:(0,n.jsxs)(V.UC,{className:"z-30 max-h-[420px] cursor-pointer overflow-scroll roun
1ded-md border border-slate-300 bg-white text-xs font-medium text-slate-600 shadow",sideOffset:2,align:"center",children:[(0,n.jsx)("div",{className:"bg-slate-200 py-1.5 text-center text-[10px] uppercase text-slate-500",children:"Scorer Models"}),u.filter(e=>e.featured).map(e=>(0,n.jsx)(V.q7,{className:"overflow-hidden ".concat((null==R?void 0:R.name)===e.name?"bg-sky-100 text-slate-600":"text-slate-600"," flex flex-col items-start gap-y-0.5 border-b px-3 py-2.5 font-mono text-xs hover:bg-slate-100 focus:outline-none"),onSelect:()=>q(e),children:(0,n.jsx)("div",{className:"flex w-full flex-row items-center justify-between gap-x-3",children:(0,n.jsx)("span",{className:"",children:e.displayName})})},e.name))]})})]})}),(0,n.jsx)("button",{type:"button",onClick:async t=>{var s,a;if(t.preventDefault(),null==l||null==(s=l.explanations)?void 0:s.find(t=>{var s;return null==(s=t.scores)?void 0:s.find(t=>t.explanationId===e.id&&t.explanationScoreTypeName===(null==O?void 0:O.name)&&t.explanationScoreModelName===(null==R?void 0:R.name))}))return void alert("An auto-interp score with this explanation type and model already exists.");if(!O)return void alert("Please select a scoring method.");if(!R&&(null==O?void 0:O.name)!=="eleuther_embedding"&&!(null==O?void 0:O.name.startsWith("nla_"))&&!(null==O?void 0:O.name.startsWith("jev_")))return void alert("Please select a scorer model.");if(!j){alert("Please log in to generate auto-interp explanation scores."),h(!0);return}E(e.id);let i=await fetch("/api/explanation/score",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({explanationId:e.id,scorerType:null==O?void 0:O.name,scorerModel:null==R?void 0:R.name})});if(429===i.status||405===i.status)alert("Sorry, you've been rate limited. Try again later."),E(void 0);else if(200!==i.status)try{let e=await i.json();e.message===B.Zr?g((0,n.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,n.jsxs)("div",{children:["Missing auto-interp API key for ",null==L?void 0:L.name,"."]}),(0,n.jsxs)("div",{children:["Set your key under Settings ",">"," Auto-Interp Keys"]}),(0,n.jsx)(p(),{href:"/account",className:"mt-2 rounded-md bg-sky-600 px-2.5 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN SETTINGS"})]})):e.message===B.iJ?g((0,n.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,n.jsx)("div",{children:"This auto-interp type requires an OpenRouter key."}),(0,n.jsxs)("div",{children:["Set your key under Settings ",">"," Auto-Interp Keys."]}),(0,n.jsx)(p(),{href:"/account",className:"mt-2 rounded-md bg-sky-600 px-2.5 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN SETTINGS"})]})):e.message===B.FA?g((0,n.jsxs)("div",{className:"flex flex-col items-center justify-center text-xs",children:[(0,n.jsx)("div",{children:"Error: API Key"}),(0,n.jsxs)("div",{children:["Your API key was valid, but we received errors when using it.",(0,n.jsx)("br",{}),"Check that your OpenRouter/other account has sufficient funds and that it has not been revoked."]}),(0,n.jsx)(p(),{href:"/account",className:"mt-2 rounded-md bg-sky-600 px-2.5 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN SETTINGS"})]})):v(),E(void 0)}catch(e){v(),E(void 0)}else{let t=await i.json(),s=t.score;if(l){let e={...l};e.explanations=null==(a=l.explanations)?void 0:a.map(e=>e.id===s.explanationId?{...e,scores:e.scores?[...e.scores,s]:[s]}:e),r(e)}A(e,t.score),q(void 0),U(void 0),E(void 0)}},disabled:void 0!==T,className:"flex max-w-[70px] flex-1 items-center justify-center rounded bg-slate-200 px-0 py-1.5 text-[10px] font-medium text-slate-500 transition-all hover:bg-slate-300 disabled:bg-slate-300",children:void 0!==T?(0,n.jsx)(G.k,{size:16,className:"text-sky-700"}):"Generate"})]})]})]})})})]})]})]}),(null==(a=e.triggeredByUser)?void 0:a.id)===(null==j?void 0:j.id)&&j&&(0,n.jsx)("button",{type:"button",onClick:async t=>{if(t.preventDefault(),window.confirm("Delete this explanation?"))if(200!==(await fetch("/api/explanation/".concat(e.id,"/delete"),{method:"POST",headers:{"Content-Type":"application/json"}})).status)v();else{var s;let t=null==l||null==(s=l.explanations)?void 0:s.filter(t=>t.id!==e.id);if(l){let e={...l};e.explanations=t,r(e)}}},className:"absolute right-2 top-0 rounded bg-red-400 p-0.5 hover:bg-red-600",children:(0,n.jsx)(x.A,{className:"h-2.5 w-2.5 text-[5px] font-bold uppercase text-white"})})]})})},e.id)})}):(0,n.jsx)("div",{className:"flex h-10 flex-col items-center justify-center text-xs font-bold text-slate-300 sm:h-16 sm:text-sm",children:(0,n.jsx)("div",{children:"No Explanations Found"})}),(0,n.jsxs)("div",{className:"flex w-full flex-col rounded-b-md border-t border-slate-200 px-3 py-3 pt-3",children:[(0,n.jsx)("div",{className:"mb-1.5 w-full text-center text-[10px] font-normal uppercase leading-none text-slate-400",children:"New Auto-Interp"}),(0,n.jsxs)("div",{className:"flex w-full min-w-0 flex-row items-center justify-center gap-x-1 text-slate-500",children:[(0,n.jsx)("div",{className:"flex min-w-[calc(50%-35px)] max-w-[calc(50%-35px)] flex-1 flex-col items-center",children:(0,n.jsxs)(V.bL,{"data-sentry-element":"DropdownMenu.Root","data-sentry-source-file":"explanations-pane.tsx",children:[(0,n.jsx)(V.l9,{asChild:!0,"data-sentry-element":"DropdownMenu.Trigger","data-sentry-source-file":"explanations-pane.tsx",children:(0,n.jsxs)("button",{type:"button",className:"flex w-full flex-1 flex-row items-center justify-center gap-x-1 whitespace-pre rounded border border-slate-300 bg-white px-2 text-[11px] font-medium text-slate-500 hover:bg-slate-50 focus:outline-none sm:pl-3 sm:pr-2",children:[(0,n.jsx)("div",{className:"flex flex-col items-center justify-center gap-y-1 py-2 leading-none",children:(0,n.jsx)("div",{className:"flex flex-row items-center justify-center gap-x-0.5",children:(null==_?void 0:_.displayName)||"AutoInterp Type"})}),(0,n.jsx)(Y.A,{className:"-mr-1 ml-0 w-4 leading-none text-slate-400","data-sentry-element":"ChevronDownIcon","data-sentry-source-file":"explanations-pane.tsx"})]})}),(0,n.jsx)(V.ZL,{"data-sentry-element":"DropdownMenu.Portal","data-sentry-source-file":"explanations-pane.tsx",children:(0,n.jsxs)(V.UC,{className:"z-30 max-h-[900px] cursor-pointer overflow-hidden rounded-md border border-slate-300 bg-white text-xs font-medium text-slate-500 shadow",sideOffset:2,align:"center","data-sentry-element":"DropdownMenu.Content","data-sentry-source-file":"explanations-pane.tsx",children:[(0,n.jsx)("div",{className:"bg-slate-200 py-1.5 text-center text-[10px] uppercase text-slate-500",children:"Auto-Interp Methods"}),w.map(e=>(0,n.jsx)(V.q7,{className:"overflow-hidden ".concat((null==_?void 0:_.name)===e.name?"bg-sky-100 text-slate-600":"text-slate-600"," flex flex-col items-start gap-y-0.5 border-b px-3 py-2.5 font-mono text-xs hover:bg-slate-100 focus:outline-none"),onSelect:()=>D(e),children:(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-between gap-x-3",children:[(0,n.jsx)("span",{className:"",children:e.displayName}),(0,n.jsx)("button",{type:"button",onClick:t=>{t.preventDefault(),t.stopPropagation(),window.open("/explanation-type/".concat(e.name),"_blank","noopener,noreferrer")},className:"rounded p-1 transition-all hover:bg-sky-300 hover:text-sky-700",children:(0,n.jsx)(M.A,{className:"h-3.5 w-3.5"})})]})},e.name))]})})]})}),(0,n.jsx)("div",{className:"flex min-w-[calc(50%-35px)] max-w-[calc(50%-35px)] flex-1 flex-row items-center justify-start gap-x-2 overflow-hidden text-ellipsis whitespace-pre",children:(0,n.jsxs)(V.bL,{"data-sentry-element":"DropdownMenu.Root","data-sentry-source-file":"explanations-pane.tsx",children:[(0,n.jsx)(V.l9,{asChild:!0,"data-sentry-element":"DropdownMenu.Trigger","data-sentry-source-file":"explanations-pane.tsx",children:(0,n.jsxs)("button",{type:"button",className:"relative flex h-7 w-full flex-row items-center justify-center gap-x-1 overflow-hidden text-ellipsis whitespace-pre rounded border border-slate-300 bg-white px-2 text-[11px] font-medium text-slate-500 hover:bg-slate-50 focus:outline-none sm:pl-3 sm:pr-2",children:[(null==L?void 0:L.displayName)||"AutoInterp Model",(0,n.jsx)(Y.A,{className:"absolute right-0 bg-white px-1 leading-none text-slate-400","data-sentry-element":"ChevronDownIcon","data-sentry-source-file":"explanations-pane.tsx"})]})}),(0,n.jsx)(V.ZL,{"data-sentry-element":"DropdownMenu.Portal","data-sentry-source-file":"explanations-pane.tsx",children:(0,n.jsxs)(V.UC,{className:"z-30 max-h-[420px] cursor-pointer overflow-scroll roun
1ded-md border border-slate-300 bg-white text-xs font-medium text-slate-600 shadow",sideOffset:2,align:"center","data-sentry-element":"DropdownMenu.Content","data-sentry-source-file":"explanations-pane.tsx",children:[(0,n.jsx)("div",{className:"bg-slate-200 py-1.5 text-center text-[10px] uppercase text-slate-500",children:"Auto-Interp Models"}),d.map(e=>(0,n.jsx)(V.q7,{className:"overflow-hidden ".concat((null==L?void 0:L.name)===e.name?"bg-sky-100 text-slate-600":"text-slate-600"," flex flex-col items-start gap-y-0.5 border-b px-3 py-2.5 font-mono text-xs hover:bg-slate-100 focus:outline-none"),onSelect:()=>P(e),children:(0,n.jsx)("div",{className:"flex w-full flex-row items-center justify-between gap-x-3",children:(0,n.jsx)("span",{className:"",children:e.displayName})})},e.name))]})})]})}),(0,n.jsx)("button",{type:"button",onClick:async e=>{var t;if(e.preventDefault(),null==l||null==(t=l.explanations)?void 0:t.find(e=>e.typeName===(null==_?void 0:_.name)&&e.explanationModelName===(null==L?void 0:L.name)))return void alert("An auto-interp with this explanation type and model already exists.");if(!j){alert("Please log in to generate auto-interp explanations."),h(!0);return}I(!0);let s=await fetch("/api/explanation/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:null==l?void 0:l.modelId,layer:null==l?void 0:l.layer,index:null==l?void 0:l.index,explanationType:(null==_?void 0:_.name)||"",explanationModelName:(null==L?void 0:L.name)||""})});if(429===s.status||405===s.status)alert("Sorry, you've been rate limited. Try again later."),I(!1);else if(200!==s.status){try{let e=await s.json();e.message===B.Zr?g((0,n.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,n.jsxs)("div",{children:["Missing auto-interp API key for ",null==L?void 0:L.displayName,"."]}),(0,n.jsxs)("div",{children:["Set your key under Settings ",">"," Auto-Interp Keys."]}),(0,n.jsx)(p(),{href:"/account",className:"mt-2 rounded-md bg-sky-600 px-2.5 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN SETTINGS"})]})):e.message===B.iJ?g((0,n.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,n.jsx)("div",{children:"This auto-interp type requires an OpenRouter key."}),(0,n.jsxs)("div",{children:["Set your key under Settings ",">"," Auto-Interp Keys."]}),(0,n.jsx)(p(),{href:"/account",className:"mt-2 rounded-md bg-sky-600 px-2.5 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN SETTINGS"})]})):v()}catch(e){v()}I(!1)}else{let e=(await s.json()).explanation;if(l&&l.explanations){let t={...l};t.explanations=[...l.explanations,e],r(t)}I(!1)}},disabled:k,className:"flex max-w-[70px] flex-1 items-center justify-center rounded bg-slate-200 px-0 py-1.5 text-[10px] font-medium text-slate-500 transition-all hover:bg-slate-300 disabled:bg-slate-300",children:k?(0,n.jsx)(G.k,{size:16,className:"text-sky-700"}):"Generate"})]})]}),(0,n.jsxs)("div",{className:"flex w-full flex-col divide-y divide-slate-200 border-t border-slate-200 px-3 py-3 sm:flex-row sm:divide-x sm:divide-y-0",children:[eb&&(0,n.jsxs)("div",{className:"flex flex-1 items-center justify-center gap-x-1.5 py-1.5 sm:py-0",children:[(0,n.jsxs)(H.bL,{open:Q,onOpenChange:ee,children:[(0,n.jsx)(H.l9,{asChild:!0,children:(0,n.jsx)("button",{type:"button",onClick:ej,disabled:et||!(null==l||null==(s=l.source)?void 0:s.hfRepoId)||!(null==l||null==(a=l.source)?void 0:a.hfFolderId),className:"flex h-9 w-[140px] items-center justify-center rounded bg-slate-200 px-3 text-[10px] font-medium text-slate-500 transition-all hover:bg-slate-300 disabled:bg-slate-300",children:et?(0,n.jsx)(G.k,{size:16,className:"text-sky-700"}):"Explain With NLA"})}),(0,n.jsx)(H.ZL,{children:(0,n.jsxs)(H.UC,{className:"z-50 min-h-[320px] w-[320px] rounded-lg border border-slate-200 bg-white px-5 py-4 shadow-lg",sideOffset:6,side:"bottom",onInteractOutside:()=>ee(!1),children:[ei&&(0,n.jsx)("div",{className:"text-xs text-red-500",children:ei}),!ei&&et&&!en&&(0,n.jsxs)("div",{className:"flex items-center justify-center gap-x-2 py-2 text-xs text-slate-400",children:[(0,n.jsx)(C.K,{size:18}),(0,n.jsx)("span",{children:"Generating NLA explanation..."})]}),!ei&&et&&en&&(0,n.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,n.jsx)("div",{className:"whitespace-pre-wrap border-l-2 border-slate-200 pl-2 text-xs font-medium leading-snug text-slate-700",children:en}),(0,n.jsx)("div",{className:"flex items-center gap-x-1.5 text-[10px] text-slate-400",children:(0,n.jsx)(C.K,{size:14})})]}),el&&(0,n.jsx)("div",{className:"flex flex-col gap-y-2",children:(0,n.jsx)("div",{className:"whitespace-pre-wrap text-xs font-medium leading-snug text-slate-700",children:el.description})}),(0,n.jsx)(H.i3,{className:"fill-slate-200"})]})})]}),(0,n.jsx)(y.default,{trigger:(0,n.jsx)(S.A,{className:"h-3.5 w-3.5 text-slate-400"}),side:"top",children:(0,n.jsxs)("p",{className:"leading-relaxed",children:["Generates an explanation with a Natural Language Autoencoder, which reads the ","feature's"," decoder vector directly instead of its activating texts."]})})]}),(0,n.jsxs)("div",{className:"flex flex-1 items-center justify-center gap-x-1.5 py-1.5
1sm:py-0",children:[(0,n.jsx)("button",{type:"button",onClick:eg,disabled:em||!(null==l?void 0:l.index),className:"flex h-9 w-[140px] flex-col items-center justify-center rounded bg-slate-200 px-3 text-[10px] font-medium leading-tight text-slate-500 transition-all hover:bg-slate-300 disabled:bg-slate-300",children:em?(0,n.jsx)(G.k,{size:16,className:"text-sky-700"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:"Interpretable Score"}),(0,n.jsx)("span",{className:"text-[8px] uppercase text-slate-400",children:"Intrusion Detection"})]})}),(0,n.jsxs)(y.default,{trigger:(0,n.jsx)(S.A,{className:"h-3.5 w-3.5 text-slate-400"}),side:"top","data-sentry-element":"CustomTooltip","data-sentry-source-file":"explanations-pane.tsx",children:[(0,n.jsx)("p",{className:"leading-relaxed",children:"Tests whether this feature is interpretable from its contexts alone, with no explanation. Shows a model groups of four activating texts plus one intruder and asks it to find the odd one out."}),(0,n.jsxs)("p",{className:"mt-2 leading-relaxed",children:["Based on the intruder detection task in"," ",(0,n.jsx)("a",{href:"https://arxiv.org/pdf/2507.08473",target:"_blank",rel:"noreferrer",className:"text-sky-700 underline hover:text-sky-900",children:"Paulo & Belrose (2025)"}),"."]})]})]})]}),(0,n.jsx)(F,{open:ec,onOpenChange:ex,loading:em,error:eh,result:ep,featureLabel:"".concat(null==l?void 0:l.modelId," \xb7 ").concat(null==l?void 0:l.layer," \xb7 ").concat(null==l?void 0:l.index),explanations:(null==l?void 0:l.explanations)||[],"data-sentry-element":"InterpretabilityCheckDialog","data-sentry-source-file":"explanations-pane.tsx"})]})}var $=s(29483),X=s(42695),Q=s(73691);function ee(e){var t,s,a;let{currentNeuron:l,reloadNeuron:r}=e,{setSignInModalOpen:i,user:o,refreshUser:d}=(0,c.SF)(),[x,u]=(0,f.useState)(!1),[p,h]=(0,f.useState)(!1),[v,y]=(0,f.useState)(),b=(0,m.useSession)();function g(e){var t;return l&&l.lists&&(null==l||null==(t=l.lists)?void 0:t.filter(t=>t.listId===e.id).length)>0}async function j(e,t,s){let n=await fetch("/api/list/add-features",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({listId:e,featuresToAdd:[{modelId:t.modelId,layer:t.layer,index:t.index,description:s}]})});return await n.json()}async function w(e,t){let s=await fetch("/api/list/remove",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({listId:e,modelId:t.modelId,layer:t.layer,index:t.index})});return await s.json()}return(0,f.useEffect)(()=>{x||setTimeout(()=>{document.body.style.pointerEvents=""},500)},[x,p]),(0,n.jsxs)("div",{className:"relative mb-0 mt-2 hidden flex-col rounded-lg border border-slate-200 bg-white text-xs shadow transition-all sm:mt-3 sm:flex","data-sentry-component":"ListsPane","data-sentry-source-file":"lists-pane.tsx",children:[l&&l.lists&&(null==l||null==(t=l.lists)?void 0:t.length)>0?(0,n.jsx)("div",{className:"flex flex-col gap-y-1 px-5 pb-4 pt-3",children:null==l||null==(s=l.lists)?void 0:s.map(e=>{var t;return(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsxs)("div",{className:"mt-1 flex flex-row items-center gap-x-1 text-xs leading-none text-slate-400",children:["â¢",(0,n.jsx)("a",{href:"/list/".concat(e.listId),target:"_blank",rel:"noreferrer",className:"text-sky-700",children:null==(t=e.list)?void 0:t.name})]}),e.description&&(0,n.jsx)("div",{className:"pl-2.5 text-[10px] font-medium text-slate-400",children:e.description})]},e.listId)})}):(0,n.jsx)("div",{className:"flex h-10 flex-col items-center justify-center text-xs font-bold text-slate-300 sm:h-16 sm:text-sm",children:"Not in Any Lists"}),(0,n.jsx)($.bL,{open:x,"data-sentry-element":"Dialog.Root","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsx)($.ZL,{"data-sentry-element":"Dialog.Portal","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsx)($.hJ,{className:"fixed left-0 top-0 h-full w-full bg-white/50","data-sentry-element":"Dialog.Overlay","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsxs)($.UC,{className:"fixed left-[50%] top-[50%] max-h-[85vh] w-[90vw] max-w-[450px] translate-x-[-50%] translate-y-[-50%] rounded-md border bg-white p-[25px] text-slate-500 shadow-md focus:outline-none","data-sentry-element":"Dialog.Content","data-sentry-source-file":"lists-p
1ane.tsx",children:[(0,n.jsxs)($.hE,{className:"mb-2 text-center text-sm font-medium text-slate-500","data-sentry-element":"Dialog.Title","data-sentry-source-file":"lists-pane.tsx",children:['Add Feature to "',null==v?void 0:v.name,'"']}),(0,n.jsx)(Q.l1,{initialValues:{description:""},onSubmit:async e=>{l&&(await j((null==v?void 0:v.id)||"",l,e.description),u(!1),y(void 0),r())},"data-sentry-element":"Formik","data-sentry-source-file":"lists-pane.tsx",children:e=>{let{submitForm:t,isSubmitting:s}=e;return(0,n.jsxs)(Q.lV,{onClick:e=>{e.stopPropagation()},onKeyDown:e=>{"Enter"===e.key&&t()},className:"flex max-w-sm flex-1 flex-col gap-y-1.5",children:[(0,n.jsx)(Q.D0,{type:"text",name:"description",required:!0,placeholder:"(optional) Override the explanation with your own",className:"mt-0 flex-1 rounded border border-slate-200 px-3 py-2 text-left text-xs font-medium text-slate-800 placeholder-slate-400 transition-all focus:outline-none focus:ring-0 disabled:bg-slate-200 sm:text-[13px]"}),(0,n.jsxs)("div",{className:"mt-3 flex flex-row gap-x-1",children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),u(!1),y(void 0)},className:"mb-0 mt-0 flex w-full flex-1 items-center justify-center overflow-hidden rounded bg-slate-700 py-1.5 font-sans text-xs font-medium text-white transition-all hover:bg-slate-400 hover:text-slate-700 focus:ring-0 disabled:bg-slate-300 disabled:text-slate-400",children:"Cancel"}),(0,n.jsx)("button",{type:"submit",disabled:s,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:"mb-0 mt-0 flex w-full flex-1 items-center justify-center overflow-hidden rounded bg-sky-700 py-1.5 font-sans text-xs font-medium text-white transition-all hover:bg-slate-400 hover:text-slate-700 focus:ring-0 disabled:bg-slate-300 disabled:text-slate-400",children:"Add"})]})]})}})]})})})}),(0,n.jsx)($.bL,{open:p,"data-sentry-element":"Dialog.Root","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsx)($.ZL,{"data-sentry-element":"Dialog.Portal","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsx)($.hJ,{className:"fixed left-0 top-0 h-full w-full bg-white/50","data-sentry-element":"Dialog.Overlay","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsxs)($.UC,{className:"fixed left-[50%] top-[50%] max-h-[85vh] w-[90vw] max-w-[450px] translate-x-[-50%] translate-y-[-50%] rounded-md border bg-white p-[25px] text-slate-500 shadow-md focus:outline-none","data-sentry-element":"Dialog.Content","data-sentry-source-file":"lists-pane.tsx",children:[(0,n.jsx)($.hE,{className:"mb-2 text-center text-sm font-medium text-slate-500","data-sentry-element":"Dialog.Title","data-sentry-source-file":"lists-pane.tsx",children:"Create New List and Add Feature"}),(0,n.jsx)(Q.l1,{initialValues:{listName:"",listDescription:"",description:""},onSubmit:async(e,t)=>{let{resetForm:s}=t;if(l){if(0===e.listName.trim().length)return void alert("List name cannot be blank.");let t=await fetch("/api/list/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.listName,description:e.listDescription})}),n=await t.json();await j(n.id,l,e.description),s(),h(!1),r(),d()}},"data-sentry-element":"Formik","data-sentry-source-file":"lists-pane.tsx",children:e=>{let{submitForm:t,isSubmitting:s}=e;return(0,n.jsxs)(Q.lV,{onClick:e=>{e.stopPropagation()},onKeyDown:e=>{"Enter"===e.key&&t()},className:"flex max-w-sm flex-1 flex-col gap-y-1.5",children:[(0,n.jsx)(Q.D0,{type:"text",name:"listName",required:!0,placeholder:"List Name",className:"mt-0 flex-1 rounded border border-slate-200 px-3 py-2 text-left text-xs font-medium text-slate-800 placeholder-slate-400 transition-all focus:outline-none focus:ring-0 disabled:bg-slate-200 sm:text-[13px]"}),(0,n.jsx)(Q.D0,{type:"text",name:"listDescription",placeholder:"List Description (optional)",className:"mt-0 flex-1 rounded border border-slate-200 px-3 py-2 text-left text-xs font-medium text-slate-800 placeholder-slate-400 transition-all focus:outline-none focus:ring-0 disabled:bg-slate-200 sm:text-[13px]"}),(0,n.jsx)(Q.D0,{type:"text",name:"description",placeholder:"How is this neuron relevant? (optional)",className:"mt-0 flex-1 rounded border border-slate-200 px-3 py-2 text-left text-xs font-medium text-slate-800 placeholder-slate-400 transition-all focus:outline-none focus:ring-0 disabled:bg-slate-200 sm:text-[13px]"}),(0,n.jsxs)("div",{className:"mt-3 flex flex-row gap-x-1",children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),h(!1)},className:"mb-0 mt-0 flex w-full flex-1 items-center justify-center overflow-hidden rounded bg-slate-700 py-1.5 font-sans text-xs font-medium text-white transition-all hover:bg-slate-400 hover:text-slate-700 focus:ring-0 disabled:bg-slate-300 disabled:text-slate-400",children:"Cancel"}),(0,n.jsx)("button",{type:"submit",disabled:s,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:"mb-0 mt-0 flex w-full flex-1 items-center justify-center overflow-hidden rounded bg-sky-700 py-1.5 font-sans text-xs font-medium text-white transition-all hover:bg-slate-400 hover:text-slate-700 focus:ring-0 disabled:bg-slate-300 disabled:text-slate-400",children:"Add"})]})]})}})]})})})}),(0,n.jsxs)(V.bL,{onOpenChange:()=>!!b||(i(!0),!1),"data-sentry-element":"DropdownMenu.Root","data-sentry-source-file":"lists-p
1ane.tsx",children:[(0,n.jsxs)(V.l9,{className:"flex w-full flex-1 flex-row items-center justify-center overflow-hidden rounded-b border-t bg-white px-4 py-3 text-xs font-medium leading-tight text-slate-500 outline-none hover:bg-slate-100","data-sentry-element":"DropdownMenu.Trigger","data-sentry-source-file":"lists-pane.tsx",children:["Add to List",(0,n.jsx)(X.In,{className:"ml-1 text-[10px]","data-sentry-element":"Select.Icon","data-sentry-source-file":"lists-pane.tsx"})]}),(0,n.jsx)(V.ZL,{"data-sentry-element":"DropdownMenu.Portal","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsxs)(V.UC,{side:"right",className:"max-h-[340px] cursor-pointer overflow-y-auto rounded-md border border-slate-200 bg-white text-[10px] font-medium text-sky-700 shadow",sideOffset:-120,"data-sentry-element":"DropdownMenu.Content","data-sentry-source-file":"lists-pane.tsx",children:[o&&o.lists&&(null==o||null==(a=o.lists)?void 0:a.map(e=>(0,n.jsxs)(V.H_,{className:"flex h-8 min-w-[200px] flex-row items-center overflow-hidden border-b px-3 font-sans text-xs hover:bg-slate-100 focus:outline-none",checked:g(e),onSelect:async()=>{l&&e.id&&(g(e)?window.confirm('Are you sure you want to remove this neuron from "'.concat(e.name,'"?'))&&(await w(e.id,l),r()):(y(e),u(!0)))},children:[(0,n.jsx)("div",{className:"w-7",children:(0,n.jsx)(V.VF,{children:(0,n.jsx)(_.A,{className:"h-4 w-4"})})}),(0,n.jsx)("div",{className:"flex items-center justify-center leading-none",children:e.name})]},e.id))),(0,n.jsxs)(V.H_,{className:"sticky bottom-0 flex h-8 min-w-[200px] flex-row items-center overflow-hidden border-b bg-slate-100 px-3 font-sans text-xs hover:bg-slate-200 focus:outline-none",onSelect:()=>{h(!0)},"data-sentry-element":"DropdownMenu.CheckboxItem","data-sentry-source-file":"lists-pane.tsx",children:[(0,n.jsx)("div",{className:"w-7",children:(0,n.jsx)(V.VF,{"data-sentry-element":"DropdownMenu.ItemIndicator","data-sentry-source-file":"lists-pane.tsx",children:(0,n.jsx)(_.A,{className:"h-4 w-4","data-sentry-element":"Check","data-sentry-source-file":"lists-pane.tsx"})})}),(0,n.jsx)("div",{className:"flex items-center justify-center leading-none",children:"+ New List"})]})]})})]})]})}var et=s(50347),es=s(13078),en=s(52252),ea=s(22164),el=s(44440);function er(e){var t;let{vector:s,isInNeuronDetails:a}=e,{getInferenceEnabledForModel:l}=(0,c.SF)();async function r(){window.confirm("Are you sure you want to delete this vector?")&&(await fetch("/api/vector/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:s.modelId,source:s.layer,index:s.index})}),window.location.reload())}return(0,n.jsxs)("div",{className:"flex w-full flex-col px-2 py-2 pb-3 text-xs","data-sentry-component":"VectorItem","data-sentry-source-file":"vector-item.tsx",children:[(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center",children:s.vectorLabel&&(0,n.jsxs)("div",{className:"flex flex-1 grid-cols-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-0 text-[9px] uppercase text-slate-400",children:"Vector Label"}),(0,n.jsx)(p(),{href:"/".concat(s.modelId,"/").concat(s.layer,"/").concat(s.index),className:"text-sm leading-none text-sky-700 hover:underline",prefetch:!1,children:s.vectorLabel})]})}),(0,n.jsxs)("div",{className:"grid w-full ".concat(a?"mt-1 grid-cols-4 gap-y-0.5":"mt-2 grid-cols-2 gap-y-1"," items-start justify-center gap-x-2"),children:[(0,n.jsxs)("div",{className:"flex flex-1 grid-cols-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Model"}),(0,n.jsx)("div",{className:"mt-0 text-xs text-slate-500",children:s.modelId})]}),(0,n.jsxs)("div",{className:"flex flex-1 grid-cols-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Layer #"}),(0,n.jsx)("div",{className:"mt-0 font-mono text-sm text-slate-500",children:(0,W.$B)(s.layer)})]}),(0,n.jsxs)("div",{className:"flex flex-1 grid-cols-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Steering Hook"}),(0,n.jsx)("div",{className:"mt-0 text-xs text-slate-500",children:s.hookName})]}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Steering Strength"}),(0,n.jsx)("div",{className:"mt-0 text-xs text-slate-500",children:s.vectorDefaultSteerStrength})]}),s.creator&&(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Uploader"}),(0,n.jsx)("div",{className:"mt-0 text-xs text-slate-500",children:null==(t=s.creator)?void 0:t.name})]}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Created At"}),(0,n.jsx)("div",{className:"mt-0 text-xs text-slate-500",children:"".concat(new Date(s.createdAt).toLocaleDateString()," ").concat(new Date(s.createdAt).toLocaleTimeString())})]}),(0,n.jsxs)("div",{className:"col-span-1 flex flex-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Raw Vector"}),(0,n.jsxs)("div",{className:"mt-0 flex flex-row items-center justify-center gap-x-2",children:[(0,n.jsx)("input",{readOnly:!0,className:"h-8 min-h-8 w-32 min-w-32 rounded border-slate-300 px-2.5 py-1 font-mono text-[10px] leading-tight text-slate-400 outline-none focus:border-slate-400 focus:outline-none focus:ring-0",value:JSON.stringify(s.vector)}
1),(0,n.jsx)(b.$,{variant:"outline",size:"icon",onClick:()=>{A()(JSON.stringify(s.vector)),alert("Copied to clipboard.")},className:"h-8 w-8 min-w-8","data-sentry-element":"Button","data-sentry-source-file":"vector-item.tsx",children:(0,n.jsx)(D.A,{className:"h-4 w-4 text-slate-500","data-sentry-element":"Copy","data-sentry-source-file":"vector-item.tsx"})})]})]}),(0,n.jsxs)("div",{className:"col-span-1 flex flex-1 flex-col items-center justify-center",children:[(0,n.jsx)("div",{className:"mb-0.5 mt-1.5 text-[9px] uppercase text-slate-400",children:"Actions"}),(0,n.jsxs)("div",{className:"mt-0 flex flex-row items-center justify-center gap-x-1.5",children:[(0,n.jsxs)(b.$,{variant:"outline",size:"icon",onClick:()=>{"llama3.3-70b-it"===s.modelId&&"40-neuronpedia-resid-post"===s.layer&&"101874252"===s.index?window.open("/assistant-axis","_blank"):window.open("/".concat(s.modelId,"/steer/?source=").concat(s.layer,"&index=").concat(s.index),"_blank")},"aria-label":"Steer",className:"h-8 w-20 gap-x-1.5 text-xs ".concat(l(s.modelId)?"":"hidden"),"data-sentry-element":"Button","data-sentry-source-file":"vector-item.tsx",children:[(0,n.jsx)(en.A,{className:"h-4 w-4 text-slate-500","data-sentry-element":"Joystick","data-sentry-source-file":"vector-item.tsx"}),"Steer"]}),!a&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b.$,{variant:"outline",size:"icon",onClick:()=>{window.open("/".concat(s.modelId,"/").concat(s.layer,"/").concat(s.index),"_blank")},"aria-label":"Open in New Tab",className:"h-8 w-8 min-w-8",children:(0,n.jsx)(ea.A,{className:"h-4 w-4 text-slate-500"})}),(0,n.jsx)(b.$,{variant:"outline",size:"icon",onClick:()=>{r()},className:"h-8 w-8 border border-red-200 text-red-400 hover:bg-red-50",children:(0,n.jsx)(el.A,{className:"h-4 w-4"})})]})]})]})]})]})}var ei=s(53947),eo=s(47783),ed=s(435),ec=s(6962),ex=s(5772),em=s(73321),eu=s(35625),ep=s(4109),ef=s(48934),eh=s(41762);function ev(e){var t;let{mini:s,currentNeuron:a}=e,l=(0,m.useSession)(),r=(0,eu.jE)(),{setSignInModalOpen:i,showToastMessage:o}=(0,c.SF)(),{data:d=[]}=(0,ep.I)({queryKey:["bookmarks"],queryFn:async()=>{var e;return(null==(e=l.data)?void 0:e.user)?(await fetch("/api/user/bookmarks",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json():[]},enabled:!!(null==(t=l.data)?void 0:t.user)}),x=!!a&&d.some(e=>e.modelId===a.modelId&&e.layer===a.layer&&e.index===a.index),u=(0,ef.n)({mutationFn:async()=>(await fetch("/api/bookmark/add",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:null==a?void 0:a.modelId,layer:null==a?void 0:a.layer,index:null==a?void 0:a.index})})).json(),onSuccess:()=>{var e,t;r.invalidateQueries({queryKey:["bookmarks"]}),o((0,n.jsxs)("div",{className:"flex flex-row items-center justify-center gap-2",children:[(0,n.jsx)("div",{children:"\uD83D\uDCD8 Bookmarked"}),(0,n.jsx)(p(),{href:"/user/".concat(null==(t=l.data)||null==(e=t.user)?void 0:e.name),className:"rounded-md bg-sky-600 px-2 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN"})]}))},onError:()=>{o((0,n.jsx)("div",{className:"flex flex-row items-center justify-center gap-2",children:(0,n.jsx)("div",{children:"Error bookmarking feature."})}))}}),f=(0,ef.n)({mutationFn:async()=>(await fetch("/api/bookmark/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:null==a?void 0:a.modelId,layer:null==a?void 0:a.layer,index:null==a?void 0:a.index})})).json(),onSuccess:()=>{var e,t;r.invalidateQueries({queryKey:["bookmarks"]}),o((0,n.jsxs)("div",{className:"flex flex-row items-center justify-center gap-2",children:[(0,n.jsx)("div",{children:"\uD83D\uDC4B Un-Bookmarked"}),(0,n.jsx)(p(),{href:"/user/".concat(null==(t=l.data)||null==(e=t.user)?void 0:e.name),className:"rounded-md bg-sky-600 px-2 py-1.5 text-xs font-semibold uppercase text-sky-100",children:"OPEN"})]}))}}),h=()=>{var e;if(!(null==(e=l.data)?void 0:e.user))return void i(!0);x?f.mutate():u.mutate()};return s?(0,n.jsx)("button",{type:"button",onClick:h,id:"bookmarkButton",className:"".concat(x?"bg-sky-700 text-white hover:bg-sky-800":"bg-slate-500 text-slate-700 hover:enabled:bg-sky-300 hover:enabled:text-sky-800 disabled:bg-slate-400 disabled:opacity-60"," w-12 overflow-hidden rounded-lg px-0 py-1.5 text-center text-xs font-bold uppercase transition-all"),"data-sentry-component":"BookmarkButton","data-sentry-source-file":"bookmark-button.tsx",children:(0,n.jsx)("div",{className:"-mt-0.5 flex flex-row items-center justify-center",children:(0,n.jsx)(eh.A,{className:"h-5 w-5 sm:h-6 sm:w-6"})})}):(0,n.jsx)("button",{type:"button",onClick:h,id:"bookmarkButton",disabled:!a,className:"".concat(x?"bg-sky-700 text-white hover:bg-sky-800":"bg-slate-200 text-slate-500/80 hover:enabled:bg-sky-300 hover:enabled:text-sky-800 disabled:bg-slate-400 disabled:opacity-60"," h-9 w-9 overflow-hidden rounded-full px-0 py-1.5 text-center text-xs font-bold uppercase transition-all"),"data-sentry-component":"BookmarkButton","data-sentry-source-file":"bookmark-button.tsx",children:(0,n.jsx)("div",{className:"flex flex-row items-center justify-center",children:(0,n.jsx)(eh.A,{className:"h-5 w-5"})})})}function ey(e){var t,s,d,x,m,u,p,y,b,g,j,w,N,k,S;let{initialNeuron:C,embed:T=!1,embedPlots:E=!0,embedTest:A=!0,defaultTestText:_,embedTestField:D=!0,embedExplanation:M=!0,embedActivations:P=!0,embedLink:O=!0,embedSteer:U=!0,forceMiniStats:R=!1,activationMarkerValue:F}=e,[z,B]=(0,f.useState)(C),{getReleaseForSourceSet:J}=(0,c.SF)(),[V,H]=(0,f.useState)(!1),[K,Y]=(0,f.useState)(),Z=(0,em.usePathname)(),[G,$]=(0,f.useState)(!1),X=(0,f.useMemo)(()=>(null==z?void 0:z.modelId)==="llama3.3-70b-it"&&(null==z?void 0:z.layer)==="40-neuronpedia-resid-post"&&(null==z?void 0:z.index)==="101874252",[z]),Q=()=>{var e,t;return!X&&((null==z?!!void 0:!!z.hasVector)&&(null==z||null==(e=z.model)?!!void 0:!!e.inferenceEnabled)||(null==z||null==(t=z.source)?void 0:t.inferenceEnabled)===!0)&&(!T||A)};async function en(){z&&await fetch("/api/feature/".concat(z.modelId,"/").concat(z.layer,"/").concat(z.index),{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{B(e),$(!0)}).catch(e=>{})}return(0,f.useEffect)(()=>{z&&z.activations&&z.activations.length<2&&!G&&en()},[z,G,en]),(0,n.jsxs)("div",{className:"relative mx-auto flex w-full flex-col gap-x-3 pt-0 sm:mt-0","data-sentry-component":"FeatureDashboard","data-sentry-source-file":"feature-dashboard.tsx",children:[(0,n.jsx)(r.A,{"data-sentry-element":"ExplanationScoreDetailDialog","data-sentry-source-file":"feature-dashboard.tsx"}),!T&&(!(0,ed.pJ)(z)||(0,ed.pJ)(z)&&!(0,ed.vw)(z))&&(0,n.jsx)(l.default,{crumbsArray:[[...J((null==z?void 0:z.modelId)||"",(null==z?void 0:z.sourceSetName)||"")?[(0,n.jsx)(es.w1,{href:"/".concat(null==(t=J((null==z?void 0:z.modelId)||"",(null==z?void 0:z.sourceSetName)||""))?void 0:t.name),children:"".concat(null==(s=J((null==z?void 0:z.modelId)||"",(null==z?void 0:z.sourceSetName)||""))?void 0:s.creatorNameShort," \xb7 ").concat(null==(d=J((null==z?void 0:z.modelId)||"",(null==z?void 0:z.sourceSetName)||""))?void 0:d.descriptionShort)},0)]:[]],(0,n.jsx)(es.w1,{href:"/".concat(null==z?void 0:z.modelId),children:null==z||null==(x=z.model)?void 0:x.displayName},1),...(null==z?void 0:z.sourceSet)?[(0,n.jsx)(es.w1,{href:"/".concat(null==z?void 0:z.modelId,"/").concat(null==z||null==(m
1=z.sourceSet)?void 0:m.name),children:null==z||null==(u=z.sourceSet)?void 0:u.type},2.5)]:[],(0,n.jsx)(es.w1,{href:"/".concat(null==z?void 0:z.modelId,"/").concat(null==z?void 0:z.layer),children:null==z?void 0:z.layer.toUpperCase()},2),(0,n.jsx)(es.tJ,{children:null==z?void 0:z.index},3)]}),!T&&(!(0,ed.pJ)(z)||(0,ed.pJ)(z)&&!(0,ed.vw)(z))&&(0,n.jsxs)("div",{className:"fixed left-0 right-0 top-12 z-20 mb-0 flex justify-center gap-y-2 border-b bg-white px-2 pb-2 pt-1 shadow-[rgba(0,0,0,0.2)_0px_4px_3px_-3px] sm:static sm:top-16 sm:z-0 sm:mb-2 sm:flex-row sm:gap-y-0 sm:border-b-0 sm:border-t-0 sm:bg-transparent sm:px-2 sm:pb-0 sm:pt-3 sm:shadow-[0]",children:[(0,n.jsx)("div",{className:"flex w-full flex-1 select-none flex-row justify-center gap-x-3 overflow-hidden px-0 pb-1 text-center font-sans text-xs font-bold leading-none text-slate-700 sm:gap-x-5 sm:px-0 sm:pt-0 sm:text-base",children:(0,n.jsx)(i.default,{filterToPublic:!0,showNextPrev:!0,defaultModelId:(null==z?void 0:z.modelId)||Z.split("/")[1],defaultSourceSet:(null==z?void 0:z.sourceSetName)||(0,W.EX)(Z.split("/")[2]||"")||W.jG,includeHeads:!0,defaultSource:(null==z?void 0:z.layer)||Z.split("/")[2],defaultIndex:(null==z?void 0:z.index)||Z.split("/")[3],openInNewTab:!1,filterToFeaturedReleases:!1})}),(0,n.jsxs)("div",{className:"hidden flex-row items-start justify-start gap-x-2 px-0 pt-1 sm:flex",children:[Q()&&(0,n.jsx)("button",{type:"button",onClick:async()=>{let e=await fetch("/api/vector/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:null==z?void 0:z.modelId,source:null==z?void 0:z.layer,index:null==z?void 0:z.index})}),t=new Blob([JSON.stringify((await e.json()).vector,null,2)],{type:"application/json"}),s=URL.createObjectURL(t),n=document.createElement("a");n.href=s,n.download="".concat(null==z?void 0:z.modelId,"_").concat(null==z?void 0:z.layer,"_").concat(null==z?void 0:z.index,".json"),n.click(),URL.revokeObjectURL(s)},"aria-label":"Download vector as JSON",className:"h-9 w-9 overflow-hidden rounded-full bg-slate-200 px-0 py-1.5 text-center text-xs font-bold uppercase text-slate-500/80 transition-all hover:enabled:bg-sky-300 hover:enabled:text-sky-800 disabled:bg-slate-400 disabled:opacity-60",children:(0,n.jsx)("div",{className:"-mt-0.5 flex flex-row items-center justify-center",children:(0,n.jsx)(ec.A,{className:"h-5 w-5"})})}),(0,n.jsx)(ev,{mini:!1,currentNeuron:z})]})]}),(0,ed.pJ)(z)&&z&&(0,n.jsx)("div",{className:"mt-2 flex w-full flex-row justify-center px-2",children:(0,n.jsx)("div",{className:"w-full rounded-md border bg-white py-2",children:(0,n.jsx)(er,{vector:z,isInNeuronDetails:!0})})}),(0,n.jsxs)("div",{className:"relative ".concat(T||(0,ed.pJ)(z)?"sm:pt-2":"mt-16 sm:pt-0"," flex h-full flex-col sm:mt-0 sm:flex-row sm:gap-x-2 sm:gap-y-0 ").concat(R?"sm:px-0":"pt-2 sm:px-2"),children:[(0,n.jsxs)("div",{className:"".concat(T?"hidden":"mb-3 flex flex-col sm:mb-0 sm:basis-1/2 sm:overflow-auto sm:overflow-y-scroll lg:basis-1/3"),children:[ei.le.includes((null==z?void 0:z.modelId)||"")&&(null==z?void 0:z.layer.includes("mlp"))&&(0,n.jsx)(v.default,{currentNeuron:z}),(0,n.jsx)(q,{currentNeuron:z,setCurrentNeuron:B,"data-sentry-element":"ExplanationsPane","data-sentry-source-file":"feature-dashboard.tsx"}),(0,n.jsx)(I,{currentNeuron:z,"data-sentry-element":"CosSimPane","data-sentry-source-file":"feature-dashboard.tsx"}),(null==z?void 0:z.source)&&((null==z||null==(p=z.source)?void 0:p.saelensConfig)||(null==z||null==(y=z.source)?void 0:y.num_tokens_in_prompt))&&(0,n.jsx)("div",{className:"mt-2 hidden sm:mt-3 sm:block",children:(0,n.jsx)(et.default,{sae:z.source,numPrompts:(null==z||null==(b=z.source)?void 0:b.num_prompts)||void 0,numTokensInPrompt:(null==z||null==(g=z.source)?void 0:g.num_tokens_in_prompt)||void 0,dashboardDataset:(null==z||null==(j=z.source)?void 0:j.dataset)||""})}),(0,n.jsx)(L,{currentNeuron:z,testTextResult:K,"data-sentry-element":"EmbedsPane","data-sentry-source-file":"feature-dashboard.tsx"}),(0,n.jsx)(ee,{currentNeuron:z,reloadNeuron:en,"data-sentry-element":"ListsPane","data-sentry-source-file":"feature-dashboard.tsx"}),(0,n.jsx)("div",{className:"relative mb-0 mt-2 hidden flex-col overflow-hidden rounded-lg border bg-white text-xs shadow-md transition-all sm:mt-4 sm:flex",children:(0,n.jsx)(h,{initialComments:(null==z?void 0:z.comments)||[],neuron:z,"data-sentry-element":"CommentsPane","data-sentry-source-file":"feature-dashboard.tsx"})})]}),(0,n.jsxs)("div",{className:"flex flex-col overflow-y-scroll px-0 ".concat(T?"flex-1":"sm:basis-1/2 lg:basis-2/3"," sm:overflow-auto sm:px-0"),children:[T&&!(null==z?void 0:z.hasVector)&&!R&&O&&(0,n.jsxs)("div",{className:"mb-2 flex w-full flex-row items-center sm:mb-2 ".concat(M?"justify-between gap-x-2 pl-2":"justify-center"," rounded-md py-0.5 pr-0 text-right font-mono text-[10px] font-semibold leading-[1.25] text-slate-600 sm:py-1 sm:text-[11px]"),children:[M&&(0,n.jsx)("div",{className:"text-left font-sans text-[11.5px] sm:text-[13px]",children:z&&z.explanations&&z.explanations.length>0&&(null==(w=z.explanations[0])?void 0:w.description)}),(0,n.jsxs)("a",{className:"mr-1.5 flex shrink-0 flex-row items-center gap-x-1 whitespace-nowrap rounded-md bg-slate-200 px-[8px] py-[6px] text-[9px] font-medium leading-none text-slate-700 hover:bg-sky-200 hover:text-sky-700 sm:mr-0 sm:px-2.5 sm:py-1.5 sm:text-[11px]",href:(0,eo.uy)(null==z?void 0:z.modelId,null==z?void 0:z.layer,null==z?void 0:z.index),target:"_blank",rel:"noreferrer",children:[(0,n.jsx)(ex.default,{src:"/logo.png",alt:"Neuronpedia logo",width:"24",height:"24",className:"mr-0.5"}),(0,n.jsxs)("div",{className:"flex flex-col gap-y-[2px]",children:[(0,n.jsx)("div",{className:"",children:null==z?void 0:z.modelId.toUpperCase()}),(0,n.jsx)("div",{className:"",children:null==z?void 0:z.layer.toUpperCase()}),(0,n.jsxs)("div",{className:"",children:["INDEX ",null==z?void 0:z.index.toUpperCase()]})]})]})]}),!O&&(0,n.jsx)("div",{className:"mb-1.5 flex flex-row justify-end px-1",children:(0,n.jsx)(ex.default,{src:"/logo.png",alt:"Neuronpedia logo",width:"18",height:"18"})}),(0,n.jsx)("div",{className:"relative ".concat(R?"mb-0":"mb-5"," flex h-full w-full flex-1 cursor-default flex-col overflow-hidden bg-white px-0 pt-0 shadow sm:overflow-visible sm:rounded-lg"),id:"activationScrollDiv",children:(0,n.jsxs)("div",{className:"flex-1 overflow-y-scroll border border-slate-200 sm:rounded-lg",children:[(null==z?void 0:z.pos_str)&&(null==z||null==(N=z.pos_str)?void 0:N.length)>0&&E&&(0,n.jsx)("div",{className:"border-b px-2.5 pb-1.5 pt-1.5 sm:px-4 sm:pb-2 sm:pt-2",children:(0,n.jsx)(o.A,{currentNeuron:z,embed:T,embedPlots:E,activationMarkerValue:F,forceMiniStats:R})}),(0,n.jsx)(a.A,{feature:z,defaultRange:R?1:null==z||null==(k=z.sourceSet)?void 0:k.defaultRange,defaultShowLineBreaks:!R&&(null==z||null==(S=z.sourceSet)?void 0:S.defaultShowBreaks),showCopy:Q(),showTest:Q(),defaultActivationTestText:_,showControls:!T,overrideLeading:R?"leading-none sm:leading-none":"leading-tight sm:leading-tight",overrideTextSize:T?R?"text-[10px]":"text-[10px] sm:text-[12px]":void 0,embed:T,activations:null==z?void 0:z.activations,activationTestTextCallback:e=>{Y(e)},showActivations:P,showSteerButton:U,showTestField:D,"data-sentry-element":"ActivationsList","data-sentry-source-file":"feature-dashboard.tsx"})]})})]}),(null==z?void 0:z.maxActApprox)===0&&!ei.le.includes((null==z?void 0:z.modelId)||"")&&!V&&!(null==z?void 0:z.hasVector)&&(0,n.jsxs)("div",{className:"absolute left-0 top-0 flex h-full w-full flex-col items-center bg-slate-50 pt-12",children:[(0,n.jsx)("div",{className:"font-bold text-slate-900",children:"This feature has no known activations."}),(0,n.jsx)("button",{type:"button",onClick:()=>{H(!0)},className:"mt-3 rounded-lg bg-slate-600 px-5 py-2 text-slate-200 hover:bg-slate-500",children:"Show Anyway"})]})]})]})}},34300:(e,t,s)=>{s.d(t,{B3:()=>l,by:()=>a}),s(7270);var n=s(39493);s(22195),s(90747)._T;var a=function(e){return e[e.EVERYONE=0]="EVERYONE",e[e.CREATOR_AND_ALLOWED_USERS=1]="CREATOR_AND_ALLOWED_USERS",e}({});function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return{OR:[{visibility:n.Visibility.PUBLIC},...0===t?[{visibility:n.Visibility.UNLISTED}]:1===t&&e?[{AND:[{visibility:n.Visibility.UNLISTED,OR:[{creatorId:null==e?void 0:e.id}]}]}]:[],...e?[{creatorId:e.id}]:[]]}}},44867:(e,t,s)=>{s.d(t,{k:()=>l});var n=s(95155),a=s(69236);function l(e){let{size:t=24,className:s,...l}=e;return(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,...l,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:(0,a.cn)("animate-spin",s),"data-sentry-element":"svg","data-sentry-component":"LoadingSpinner","data-sentry-source-file":"loading-spinner.tsx",children:(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56","data-sentry-element":"path","data-sentry-source-file":"loading-spinner.tsx"})})}},64069:(e,t,s)=>{s.d(t,{default:()=>j});var n=s(95155),a=s(31050),l=s(18695),r=s(13637),i=s(47783),o=s(57303),d=s(42695),c=s(36376),x=s(23714),m=s(41641),u=s(21362),p=s(66088),f=s(9921),h=s(22164),v=s(98500),y=s.n(v),b=s(12115),g=s(97285);function j(e){let{currentNeuron:t,showSelectors:s=!1}=e,{getSourcesForSourceSet:v}=(0,l.SF)(),[j,w]=(0,b.useState)(null),[N,k]=(0,b.useState)(null),[S,C]=(0,b.useState)(),[I,T]=(0,b.useState)((null==t?void 0:t.layer)||""),[E,A]=(0,b.useState)((null==t?void 0:t.index)||""),_=I?(0,o.EX)(I):"",[D,L]=(0,b.useState)((null==t?void 0:t.layer)||""),[M,P]=(0,b.useState)((null==t?void 0:t.index)||"0");(0,b.useEffect)(()=>{(null==t?void 0:t.layer)&&(T(t.layer),L(t.layer)),(null==t?void 0:t.index)&&(A(t.index),P(t.index))},[null==t?void 0:t.layer,null==t?void 0:t.index]);let O=()=>{(null==t?void 0:t.modelId)&&D&&void 0!==M&&0!==M.trim().length&&/^\+?\d+$/.test(M)&&(T(D),A(M))},U=e=>
1{if(!(null==t?void 0:t.modelId)||!I)return;let s=parseInt(E,10);if(Number.isNaN(s))return;let n=s+e;if(n<0)return;let a=n.toString();A(a),P(a)},[R,F]=(0,b.useState)(null),[z,B]=(0,b.useState)(!1),[J,W]=(0,b.useState)(null);(0,b.useEffect)(()=>{(async()=>{if(!(null==t?void 0:t.modelId)||!I||!E)return F(null);let e=I.match(/^(\d+)/);if(!e)return W("Invalid layer format");let s=parseInt(e[1],10);B(!0),W(null);try{let e=await fetch("/api/sparsity/connected-neurons?modelId=".concat(encodeURIComponent(t.modelId),"&layer=").concat(s,"&index=").concat(encodeURIComponent(E)));if(!e.ok){let t=await e.json();throw Error(t.error||"API error: ".concat(e.status))}let n=await e.json();F({layer:n.layer,neuron:n.neuron,trace_forward:n.trace_forward,trace_backward:n.trace_backward,neuronExplanations:n.neuronExplanations||[],residChannelExplanations:n.residChannelExplanations||[]})}catch(e){W(e instanceof Error?e.message:"Failed to fetch connected neurons"),F(null)}finally{B(!1)}})()},[null==t?void 0:t.modelId,I,E]);let V=R?function(e,t){let s=new Set,n=new Set,a=e=>{e.forEach(e=>{s.add(e.via_channel),e.parents&&a(e.parents)})},l=e=>{e.forEach(e=>{n.add(e.via_channel),e.children&&l(e.children)})};a(t),l(e);let r=Array.from(s).filter(e=>!n.has(e)).sort((e,t)=>e-t);return[...r,...Array.from(s).filter(e=>n.has(e)).sort((e,t)=>e-t),...Array.from(n).filter(e=>!s.has(e)).sort((e,t)=>e-t)].map(e=>({id:"channel.".concat(e),index:e}))}(R.trace_forward,R.trace_backward):[],H=R?function(e,t,s,n,a){let l=[],r=new Map(a.map(e=>[e.index,e]));n.forEach(e=>{let t=r.get(e.via_channel);t&&l.push({layer:e.layer,index:String(e.neuron),current:!1,resChannels:[t],direction:"backward",readWeight:e.read_weight,writeWeight:e.write_weight})});let i=[...new Set([...s.map(e=>e.via_channel),...n.map(e=>e.via_channel)])].map(e=>r.get(e)).filter(e=>void 0!==e);return l.push({layer:e,index:String(t),current:!0,resChannels:i,direction:"current"}),s.forEach(e=>{let t=r.get(e.via_channel);t&&l.push({layer:e.layer,index:String(e.neuron),current:!1,resChannels:[t],direction:"forward",readWeight:e.read_weight,writeWeight:e.write_weight})}),l.sort((e,t)=>e.layer-t.layer||e.index.localeCompare(t.index))}(R.layer,R.neuron,R.trace_forward,R.trace_backward,V):[],K=(e,t)=>{if(!(null==R?void 0:R.neuronExplanations))return[];let s="".concat(e,"-mlp");return R.neuronExplanations.filter(e=>e.layer===s&&e.index===t).flatMap(e=>e.explanations)},Y=(e,t,s)=>{if(!(null==R?void 0:R.neuronExplanations))return null;let n="".concat(e,"-mlp"),a=R.neuronExplanations.find(e=>e.layer===n&&e.index===t);if(!(null==a?void 0:a.explanations)||0===a.explanations.length)return null;let l=" (negative activations)";if("bottom"===s){let e=a.explanations.find(e=>e.description.includes(l));return e?e.description.replace(l,""):null}if("top"===s){var r;return(null==(r=a.explanations.find(e=>!e.description.includes(l)))?void 0:r.description)||null}let i=a.explanations.find(e=>!e.description.includes(l));if(i)return i.description;let o=a.explanations.find(e=>e.description.includes(l));return o?o.description.replace(l,""):null},Z=(V.length-1)*20+5,G=H.filter(e=>"backward"===e.direction),q=H.filter(e=>"backward"!==e.direction),$=e=>{let t=new Map;return e.forEach(e=>t.set(e.layer,(t.get(e.layer)||0)+1)),Math.max(0,...t.values())},X=$(G),Q=30*X+30+20+Z+(30*$(q)+30+20),ee=Q/2-Z/2,et=function(e,t,s){let n=new Map,a=e.filter(e=>"backward"===e.direction),l=e.filter(e=>"backward"!==e.direction),r=new Map;a.forEach(e=>{let t=r.get(e.layer)||[];t.push(e),r.set(e.layer,t)});let i=new Map;l.forEach(e=>{let t=i.get(e.layer)||[];t.push(e),i.set(e.layer,t)});let o=Array.from(new Set([...r.keys(),...i.keys()])).sort((e,t)=>e-t),d=o.map(e=>Math.max((r.get(e)||[]).length,(i.get(e)||[]).length,1)),c=[],x=52;return o.forEach((e,t)=>{c.push(x);let s=Math.max(40,24*d[t]);x+=s+20}),o.forEach((e,s)=>{let a=r.get(e)||[],l=c[s]+Math.max(40,24*d[s])/2;a.forEach((e,r)=>{let i=(r-(a.length-1)/2)*24;n.set(e.index,{left:t,top:l+i-6,layerIndex:s,indexInLayer:r})})}),o.forEach((e,t)=>{let a=i.get(e)||[],l=c[t]+Math.max(40,24*d[t])/2;a.forEach((e,r)=>{let i=(r-(a.length-1)/2)*24;n.set(e.index,{left:s,top:l+i-6,layerIndex:t,indexInLayer:r})})}),n}(H,ee-30-8,ee+Z+30+5),es=new Set(H.map(e=>e.layer)).size,en=(()=>{let e=new Map;H.forEach(t=>{let s=et.get(t.index);if(s){let n=e.get(t.layer)||[];n.push(s.top),e.set(t.layer,n)}});let t=[];return e.forEach((e,s)=>{let n=Math.min(...e),a=Math.max(...e);t.push({layer:s,centerY:(n+a)/2+6,minY:n-12,maxY:a+12+12})}),t.sort((e,t)=>
1e.layer-t.layer)})(),ea=en.length>0?en[0].minY-16:0;return(0,n.jsxs)("div",{className:"mb-2 flex w-full flex-col gap-x-2 overflow-hidden rounded-lg border bg-white px-3 pb-4 pt-2 text-xs shadow transition-all sm:mb-3","data-sentry-component":"ConnectedNeuronsPane","data-sentry-source-file":"connected-neurons-pane.tsx",children:[(0,n.jsxs)("div",{className:"mb-1.5 flex w-full flex-row items-center justify-center gap-x-1 text-[10px] font-normal uppercase text-slate-400",children:["Circuit Sparsity",(0,n.jsx)(c.Kq,{delayDuration:0,skipDelayDuration:0,"data-sentry-element":"Tooltip.Provider","data-sentry-source-file":"connected-neurons-pane.tsx",children:(0,n.jsxs)(c.bL,{"data-sentry-element":"Tooltip.Root","data-sentry-source-file":"connected-neurons-pane.tsx",children:[(0,n.jsx)(c.l9,{asChild:!0,"data-sentry-element":"Tooltip.Trigger","data-sentry-source-file":"connected-neurons-pane.tsx",children:(0,n.jsx)("button",{type:"button",children:(0,n.jsx)(x.A,{className:"h-2.5 w-2.5","data-sentry-element":"HelpCircle","data-sentry-source-file":"connected-neurons-pane.tsx"})})}),(0,n.jsx)(c.ZL,{"data-sentry-element":"Tooltip.Portal","data-sentry-source-file":"connected-neurons-pane.tsx",children:(0,n.jsxs)(c.UC,{className:"rounded bg-slate-500 px-3 py-2 text-xs text-white",sideOffset:5,side:"right","data-sentry-element":"Tooltip.Content","data-sentry-source-file":"connected-neurons-pane.tsx",children:["This model is a weight-sparse transformer. Hover over the vertical lines for details on residual stream channels, or hover over the neurons (circles) for a preview of its dashboard. You can also click the lines or circles to navigate to their dashboards.",(0,n.jsx)(c.i3,{className:"fill-slate-500","data-sentry-element":"Tooltip.Arrow","data-sentry-source-file":"connected-neurons-pane.tsx"})]})})]})})]}),s&&(null==t?void 0:t.modelId)&&_&&(0,n.jsxs)("div",{className:"mb-4 flex w-full flex-row items-center justify-center gap-x-1.5",children:[(0,n.jsxs)("div",{className:"flex flex-row divide-x divide-slate-300 overflow-hidden rounded bg-slate-200",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>U(-1),disabled:0>=parseInt(E,10)||Number.isNaN(parseInt(E,10)),className:"group flex h-10 min-h-[40px] select-none flex-col items-center justify-center px-1.5 text-[11px] font-medium uppercase text-slate-500 hover:bg-sky-700 hover:text-white ".concat(parseInt(E,10)>0?"":"pointer-events-none opacity-50"),children:[(0,n.jsx)(m.A,{className:"h-4 w-4"}),(0,n.jsx)("div",{className:"mt-0.5 text-center text-[8px] font-medium uppercase leading-none text-slate-400 group-hover:text-white",children:"Prev"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>U(1),className:"group flex h-10 min-h-[40px] select-none flex-col items-center justify-center px-1.5 text-[11px] font-medium uppercase text-slate-500 hover:bg-sky-700 hover:text-white",children:[(0,n.jsx)(u.A,{className:"h-4 w-4"}),(0,n.jsx)("div",{className:"mt-0.5 text-center text-[8px] font-medium uppercase leading-none text-slate-400 group-hover:text-white",children:"Next"})]})]}),(0,n.jsxs)(d.bL,{value:D,onValueChange:e=>L(e),children:[(0,n.jsxs)(d.l9,{className:"flex h-10 max-h-[40px] min-h-[40px] flex-row items-center justify-center gap-x-1 whitespace-pre rounded border border-slate-300 bg-white px-2 font-mono text-xs font-medium text-sky-700 hover:bg-slate-50 focus:outline-none sm:pl-5 sm:pr-2",children:[(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)(d.WT,{}),(0,n.jsx)("div",{className:"mt-0.5 text-center text-[8px] font-medium leading-none text-slate-400",children:"SOURCE"})]}),(0,n.jsx)(d.In,{children:(0,n.jsx)(p.A,{className:"-mr-1 ml-0 w-4 leading-none"})})]}),(0,n.jsx)(d.ZL,{children:(0,n.jsxs)(d.UC,{position:"item-aligned",align:"center",sideOffset:2,className:"z-30 cursor-pointer overflow-hidden rounded-md border border-slate-300 bg-white text-xs font-medium text-sky-700 shadow",children:[(0,n.jsx)(d.PP,{className:"flex justify-center border-b text-slate-600",children:(0,n.jsx)(f.A,{})}),(0,n.jsx)(d.LM,{className:"text-center",children:v(t.modelId,_,!0,!1,!1).map(e=>(0,n.jsx)(d.q7,{value:e,className:"overflow-hidden border-b px-3 py-2 font-mono ".concat(D===e?"bg-sky-100 text-sky-700":"text-slate-600"," text-xs hover:bg-slate-100 focus:outline-none"),children:(0,n.jsx)(d.p4,{children:(0,n.jsx)("span",{className:"uppercase",children:e})})},e))}),(0,n.jsx)(d.wn,{className:"flex justify-center border-t text-slate-600",children:(0,n.jsx)(p.A,{})})]})})]}),(0,n.jsxs)("div",{className:"flex h-10 max-h-[40px] min-h-[40px] flex-col items-center justify-center rounded border border-slate-300 bg-white px-0.5 py-0 text-center font-mono text-xs font-medium text-sky-700 placeholder-slate-400 focus-within:border-sky-700 sm:w-[60px] sm:px-1",children:[(0,n.jsx)("input",{type:"text",value:M,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)?P(""):P(t.toString())},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),O())},placeholder:"0",className:"w-[50px] border-none bg-transparent px-0 py-0 text-center text-[11px] leading-none text-sky-700 placeholder-slate-400 focus:border-none focus:ring-0 sm:w-[60px] sm:text-xs"}),(0,n.jsx)("div",{className:"mt-0.5 text-center font-mono text-[8px] font-medium leading-none text-slate-400",children:"INDEX"})]}),(0,n.jsx)("button",{type:"button",onClick:O,className:"flex h-10 max-h-[40px] min-h-[40px] select-none items-center justify-center rounded bg-slate-200 px-3 text-[11px] font-medium uppercase text-slate-500 hover:bg-sky-700 hover:text-white",children:"Go"})]}),J&&(0,n.jsxs)("div",{className:"mb-2 rounded bg-red-50 px-2 py-1 text-[10px] text-red-600",children:["Error: ",J]}),(0,n.jsxs)("div",{className:"relative mb-3 mt-0 flex-col",style:{minHeight:"".concat(z||!R?320:Math.max(320,en.length>0?en[en.length-1].maxY+30:320),"px")},children:[z&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,n.jsx)(g.K,{size:24})}),!R&&!z&&!J&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:"No connected neurons data available"}),R&&!z&&(0,n.jsxs)(n.Fragment,{children:[en.map(e=>{let{layer:t,minY:s}=e;return(0,n.jsxs)("div",{className:"absolute text-[9px] font-medium text-slate-400",style:{left:"-4px",top:"".concat(s-2,"px"),whiteSpace:"nowrap"},children:["L",t]},"layer-label-".concat(t))}),(0,n.jsxs)("div",{className:"relative",style:{width:"".concat(Q,"px"),height:"100%",marginLeft:"calc(50% - ".concat(Q/2,"px - 6px)")},children:[(0,n.jsx)("div",{className:"absolute text-[10px] font-medium text-slate-400",style:{left:"".concat(ee+((V.length-1)*20+5)/2,"px"),top:"".concat(ea-34,"px"),transform:"translateX(-50%)",whiteSpace:"nowrap"},children:"Residual Stream"}),(()=>{let e=H.filter(e=>!e.current),t=Math.max(...e.map(e=>{let t="backward"===e.direction?e.writeWeight:e.readWeight;return Math.abs(null!=t?t:0)}),.001);return e.map(e=>{let s=et.get(e.index);return s?(0,n.jsx)("div",{children:e.resChannels.map(a=>{let l=ee+20*V.findIndex(e=>e.id===a.id),r=s.left,i=s.top,o=j===e.index,d=N===a.id,c="backward"===e.direction,x=i+6,m=i+6,u=c?r+12:r,p=o||d?"#64748b":"#cbd5e1",f=c?e.writeWeight:e.readWeight,h=Math.abs(null!=f?f:0),v="arrow-end-".concat(e.index,"-").concat(a.id),y="arrow-start-".concat(e.index,"-").concat(a.id);return(0,n.jsxs)("svg",{className:"pointer-events-none absolute",style:{left:2.5,top:0,width:"100%",height:"100%",overflow:"visible"},children:[(0,n.jsxs)("defs",{children:[(0,n.jsx)("marker",{id:v,markerWidth:"3",markerHeight:"3",refX:"2.7",refY:"1.5",orient:"auto",markerUnits:"strokeWidth",children:(0,n.jsx)("path",{d:"M0,0 L0,3 L3,1.5 z",fill:p})}),(0,n.jsx)("marker",{id:y,markerWidth:"3",markerHeight:"3",refX:"0.3",refY:"1.5",orient:"auto",markerUnits:"strokeWidth",children:(0,n.jsx)("path",{d:"M3,0 L3,3 L0,1.5 z",fill:p})})]}),(0,n.jsx)("path",{d:"M ".concat(l+2+(c?-6:0)," ").concat(m," \n Q ").concat(l+2.5+(u-l
1-2.5)*.6," ").concat((m+x)/2,",\n ").concat(c?u-3:u-2," ").concat(x),stroke:p,strokeWidth:1+h/t*3,fill:"none",markerStart:c?"url(#".concat(y,")"):void 0,markerEnd:c?void 0:"url(#".concat(v,")"),style:{transition:"stroke 0.3s ease, stroke-width 0.3s ease"}})]},"line-".concat(e.index,"-").concat(a.id))})},"lines-".concat(e.index)):null})})(),V.map((e,s)=>{var a,l,r,o;let d=!!j&&(null==(a=H.find(e=>e.index===j))?void 0:a.resChannels.some(t=>t.id===e.id)),x=null!=(l=null==R?void 0:R.trace_backward.some(t=>t.via_channel===e.index))&&l,m=null!=(r=null==R?void 0:R.trace_forward.some(t=>t.via_channel===e.index))&&r,u=N===e.id||d||null===N&&null===j&&(x||m),p=Math.max(400,64+80*es+40),f=[...en].sort((e,t)=>e.layer-t.layer),h=[],v=null!=(o=null==R?void 0:R.layer)?o:0,b=[f[0].minY-16];for(let e=0;e<f.length-1;e+=1){let t=f[e],s=f[e+1],n=(t.maxY+s.minY)/2;b.push(n)}let g=f[f.length-1];b.push(g.maxY+16),f.forEach((e,t)=>{let s=b[t],n=b[t+1];if(e.layer===v)s=e.centerY-34,n=e.centerY+34;else{if(t>0){let e=f[t-1];e.layer===v&&(s=e.centerY+34+28)}if(t<f.length-1){let e=f[t+1];e.layer===v&&(n=e.centerY-34-28)}}h.push({layer:e.layer,top:s,height:n-s})});let w=h.length>0?h[h.length-1].top+h[h.length-1].height:p;return(0,n.jsxs)("div",{className:"absolute",style:{left:"".concat(ee+20*s,"px")},children:[(0,n.jsx)("div",{className:"absolute text-[8px] font-medium transition-colors",style:{top:"".concat(ea-16,"px"),left:"50%",transform:"translateX(-50%)",whiteSpace:"nowrap",color:u?"#0369a1":"#94a3b8"},children:e.index}),(()=>{var s,a,l,r,o,x,m;let u=null!=(s=null==R?void 0:R.trace_backward.some(t=>t.via_channel===e.index))&&s,p=null!=(a=null==R?void 0:R.trace_forward.some(t=>t.via_channel===e.index))&&a,f=N===e.id,b=h.filter(e=>e.layer<v),g=h.filter(e=>e.layer>v),w="rgba(3, 105, 161, 0.3)",S=f||d||null===N&&null===j&&(u||p)?"#0369a1":w,C=(m=e.index,(null==R?void 0:R.residChannelExplanations)?R.residChannelExplanations.filter(e=>e.index===m.toString()).map(e=>({layer:e.layer,explanations:e.explanations})).sort((e,t)=>parseInt(e.layer.split("-")[0],10)-parseInt(t.layer.split("-")[0],10)):[]),I=[...b,...g],T=I.length>0?Math.min(...I.map(e=>e.top)):0,E=I.length>0?Math.max(...I.map(e=>e.top+e.height)):0;return(0,n.jsx)(c.Kq,{delayDuration:0,skipDelayDuration:0,children:(0,n.jsxs)(c.bL,{children:[(0,n.jsx)(c.l9,{asChild:!0,children:(0,n.jsxs)("div",{className:"absolute w-[5px] cursor-pointer",style:{top:"".concat(T,"px"),height:"".concat(E-T,"px")},onMouseEnter:()=>k(e.id),onMouseLeave:()=>k(null),children:[b.map((e,t)=>{let s=p&&!u?w:S;return(0,n.jsx)("div",{className:"absolute w-[5px]",style:{top:"".concat(e.top-T,"px"),height:"".concat(e.height,"px"),background:0===t?"linear-gradient(to bottom, transparent 0%, ".concat(s," 20%, ").concat(s," 100%)"):s,transition:"background 0.3s ease",borderRadius:0===t?"2px 2px 0 0":"0"}},"above-".concat(e.layer))}),g.map(e=>{let t=u&&!p?w:S;return(0,n.jsx)("div",{className:"absolute w-[5px]",style:{top:"".concat(e.top-T,"px"),height:"".concat(e.height,"px"),background:t,transition:"background 0.3s ease"}},"below-".concat(e.layer))})]})}),(0,n.jsx)(c.ZL,{children:(0,n.jsxs)(c.UC,{className:"min-w-[240px] max-w-[240px] rounded-md border border-slate-300 bg-white px-3 py-3 text-xs text-slate-600 shadow-md",sideOffset:3,side:p&&!u?"left":"right",align:"center",avoidCollisions:!1,children:[(0,n.jsxs)("div",{className:"text-xs font-bold",children:["Residual Channel ",e.index]}),(null!=(l=null==R?void 0:R.trace_backward)?l:[]).some(t=>t.via_channel===e.index)&&(0,n.jsx)("div",{className:"mt-2 text-[10px] font-semibold",children:"Neurons Writing"}),(null!=(r=null==R?void 0:R.trace_backward)?r:[]).filter(t=>t.via_channel===e.index).map(e=>{let s=K(e.layer,String(e.neuron));return(0,n.jsxs)("div",{className:"mb-1 ml-2",children:[(0,n.jsxs)("div",{className:"text-[10px] font-medium",children:[(0,n.jsxs)(y(),{href:(0,i.uy)(null==t?void 0:t.modelId,"".concat(e.layer,"-mlp"),e.neuron),className:"font-mono text-sky-700 hover:underline",children:[e.layer,"-MLP @ ",e.neuron]})," ",(0,n.jsxs)("span",{className:"text-slate-400",children:["(w: ",e.write_weight.toFixed(3),")"]})]}),s.length>0&&(0,n.jsx)("div",{className:"ml-3",children:s.sort((e,t)=>
1{let s=e.description.includes("(negative activations)");return s===t.description.includes("(negative activations)")?0:s?1:-1}).map(e=>{let t=e.description.includes("(negative activations)");return(0,n.jsxs)("div",{className:"flex items-center gap-x-1 text-[9px] font-medium leading-snug",children:[(0,n.jsx)("span",{className:"font-mono text-[11px] font-bold leading-none ".concat(t?"text-rose-500":"text-emerald-600"),children:t?"-":"+"}),(0,n.jsx)("span",{className:"text-slate-600",children:e.description.replace(" (negative activations)","")})]},e.id)})})]},"writer-".concat(e.neuron))}),(null!=(o=null==R?void 0:R.trace_forward)?o:[]).some(t=>t.via_channel===e.index)&&(0,n.jsx)("div",{className:"mt-2 text-[10px] font-semibold",children:"Neurons Reading"}),(null!=(x=null==R?void 0:R.trace_forward)?x:[]).filter(t=>t.via_channel===e.index).map(e=>{let s=K(e.layer,String(e.neuron));return(0,n.jsxs)("div",{className:"mb-1 ml-2",children:[(0,n.jsxs)("div",{className:"text-[10px] font-medium",children:[(0,n.jsxs)(y(),{href:(0,i.uy)(null==t?void 0:t.modelId,"".concat(e.layer,"-mlp"),e.neuron),className:"font-mono text-sky-700 hover:underline",children:[e.layer,"-MLP @ ",e.neuron]})," ",(0,n.jsxs)("span",{className:"text-slate-400",children:["(r: ",e.read_weight.toFixed(3),")"]})]}),s.length>0&&(0,n.jsx)("div",{className:"ml-3",children:s.sort((e,t)=>{let s=e.description.includes("(negative activations)");return s===t.description.includes("(negative activations)")?0:s?1:-1}).map(e=>{let t=e.description.includes("(negative activations)");return(0,n.jsxs)("div",{className:"flex items-center gap-x-1 text-[9px] font-medium leading-snug",children:[(0,n.jsx)("span",{className:"font-mono text-[11px] font-bold leading-none ".concat(t?"text-rose-500":"text-emerald-600"),children:t?"-":"+"}),(0,n.jsx)("span",{className:"text-slate-600",children:e.description.replace(" (negative activations)","")})]},e.id)})})]},"reader-".concat(e.neuron))}),C.length>0&&(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("div",{className:"mb-0.5 text-[10px] font-semibold",children:"Resid Explanations"}),C.map(s=>(0,n.jsxs)("div",{className:"mb-1 ml-2",children:[(0,n.jsx)("div",{className:"text-[10px] font-medium uppercase text-slate-400",children:(0,n.jsxs)(y(),{href:(0,i.uy)(null==t?void 0:t.modelId,s.layer,e.index),className:"font-mono text-sky-700 hover:underline",children:[s.layer," @ ",e.index]})}),s.explanations.sort((e,t)=>{let s=e.description.includes("(negative activations)");return s===t.description.includes("(negative activations)")?0:s?1:-1}).map(e=>{let t=e.description.includes("(negative activations)");return(0,n.jsxs)("div",{className:"mb-0.5 ml-3 flex items-center gap-x-1 text-[10px] font-medium leading-snug",children:[(0,n.jsx)("span",{className:"font-mono text-[12px] font-bold leading-none ".concat(t?"text-rose-500":"text-emerald-600"),children:t?"-":"+"}),(0,n.jsx)("span",{className:"text-slate-600",children:e.description.replace(" (negative activations)","")})]},e.id)})]},s.layer))]}),(0,n.jsx)(c.i3,{className:"fill-slate-300"})]})})]})})})(),(()=>{var t,s;let a=N===e.id,l=null!=(t=null==R?void 0:R.trace_forward.some(t=>t.via_channel===e.index))&&t,r=null!=(s=null==R?void 0:R.trace_backward.some(t=>t.via_channel===e.index))&&s,i="#0369a1",o="#b3d2e3";return(0,n.jsx)("div",{className:"absolute",style:{top:"".concat(w,"px"),left:"0px",width:"5px",height:"".concat(16,"px"),background:!(r&&!l)&&(d||a||null===N&&null===j&&(r||l))?"linear-gradient(to bottom, ".concat(i," 0%, ").concat(i," 20%, #ffffff 100%)"):"linear-gradient(to bottom, ".concat(o," 0%, ").concat(o," 20%, #ffffff 100%)"),transition:"background 0.3s ease"}})})()]},e.id)}),(()=>{var e,t,s;let a=H.find(e=>e.current);if(!a)return null;let l=en.find(e=>e.layer===a.layer);if(!l)return null;let r=(null!=(e=null==R?void 0:R.trace_backward)?e:[]).map(e=>e.via_channel).sort((e,t)=>e-t),i=(null!=(t=null==R?void 0:R.trace_forward)?t:[]).map(e=>e.via_channel).sort((e,t)=>e-t),o=[...new Set(r)],d=[...new Set(i)],c=Math.max(Z+40+60,250),x=l.centerY-34,m=new Map;
1return(null!=(s=null==R?void 0:R.trace_backward)?s:[]).forEach(e=>{m.has(e.via_channel)||m.set(e.via_channel,e.layer)}),(0,n.jsxs)(n.Fragment,{children:[V.map((e,t)=>{var s;let a=ee+20*t+2,l=o.includes(e.index),r=!!j&&(null==(s=H.find(e=>e.index===j))?void 0:s.resChannels.some(t=>t.id===e.id)),i=N===e.id,c=d.includes(e.index),m=i||r||null===N&&null===j&&(l||c),u="#0369a1",p=m?u:"rgba(3, 105, 161, 0.3)";if(l)return(0,n.jsxs)("svg",{className:"absolute cursor-pointer",style:{left:"".concat(a-6,"px"),top:"".concat(x-28,"px"),width:"13px",height:"".concat(28,"px")},viewBox:"0 0 13 ".concat(28),onMouseEnter:()=>k(e.id),onMouseLeave:()=>k(null),children:[(0,n.jsx)("rect",{x:"4",y:"0",width:"5",height:20,fill:p,style:{transition:"fill 0.3s ease"}}),(0,n.jsx)("path",{d:"M6.5 ".concat(28,"L0 ").concat(20,"H13L6.5 ").concat(28,"Z"),fill:p,style:{transition:"fill 0.3s ease"}})]},"arrow-input-".concat(e.id));if(0===o.length)return null;let f="#b3d2e3",h=c&&!l;return(0,n.jsx)("div",{className:"absolute ".concat(h?"":"cursor-pointer"),style:{left:"".concat(a-2,"px"),top:"".concat(x-28,"px"),width:"5px",height:"".concat(28,"px"),background:h?"linear-gradient(to bottom, ".concat(f," 0%, #ffffff 90%)"):m?"linear-gradient(to bottom, ".concat(u," 0%, #ffffff 90%)"):"linear-gradient(to bottom, ".concat(f," 0%, #ffffff 90%)"),transition:"background 0.3s ease"},onMouseEnter:h?void 0:()=>k(e.id),onMouseLeave:h?void 0:()=>k(null)},"fade-".concat(e.id))}),(0,n.jsxs)("div",{className:"absolute flex w-full flex-col overflow-hidden rounded-md border border-sky-700 bg-slate-50",style:{left:"".concat(ee+Z/2-c/2,"px"),top:"".concat(x,"px"),width:"".concat(c,"px"),height:"".concat(68,"px")},children:[(0,n.jsxs)("div",{className:"mb-1 flex w-full items-center justify-center bg-sky-700 py-2 pt-2 text-center font-mono text-[10px] font-bold uppercase leading-none text-white",children:[I," - Index ",a.index]}),(0,n.jsxs)("div",{className:"flex flex-col gap-x-2 text-[10px] font-bold",children:[(0,n.jsxs)("div",{className:"flex flex-row items-center gap-x-1 px-2",children:[(0,n.jsx)("span",{className:"font-mono text-[12px] font-bold leading-none text-emerald-600",children:"+"}),(0,n.jsx)("span",{className:"text-slate-600",children:Y(a.layer,a.index,"top")})]}),(0,n.jsxs)("div",{className:"flex flex-row items-center gap-x-1 px-2",children:[(0,n.jsx)("span",{className:"font-mono text-[12px] font-bold leading-none text-rose-500",children:"-"}),(0,n.jsx)("span",{className:"text-slate-600",children:Y(a.layer,a.index,"bottom")})]})]})]}),V.map((e,t)=>{var s;let a=ee+20*t+2.5,l=d.includes(e.index),r=!!j&&(null==(s=H.find(e=>e.index===j))?void 0:s.resChannels.some(t=>t.id===e.id)),i=N===e.id,c=o.includes(e.index),m=i||r||null===N&&null===j&&(c||l),u="#0369a1",p="#b3d2e3",f=x+68;if(l)return(0,n.jsx)("svg",{className:"absolute cursor-pointer",style:{left:"".concat(a-6.5,"px"),top:"".concat(f,"px"),width:"13px",height:"".concat(28,"px")},viewBox:"0 0 13 ".concat(28),onMouseEnter:()=>k(e.id),onMouseLeave:()=>k(null),children:(0,n.jsx)("path",{d:"M0 0 L13 0 L9 ".concat(5," L9 ").concat(28," L4 ").concat(28," L4 ").concat(5," Z"),fill:m?u:"rgba(3, 105, 161, 0.3)",style:{transition:"fill 0.3s ease"}})},"arrow-output-".concat(e.id));if(0===d.length)return null;let h=c&&!l;return(0,n.jsx)("div",{className:"absolute ".concat(h?"":"cursor-pointer"),style:{left:"".concat(a-2.5,"px"),top:"".concat(f,"px"),width:"5px",height:"".concat(28,"px"),background:h?"linear-gradient(to bottom, #ffffff 15%, ".concat(p," 100%)"):m?"linear-gradient(to bottom, #ffffff 15%, ".concat(u," 100%)"):"linear-gradient(to bottom, #ffffff 15%, ".concat(p," 100%)"),transition:"background 0.3s ease"},onMouseEnter:h?void 0:()=>k(e.id),onMouseLeave:h?void 0:()=>k(null)},"fade-below-".concat(e.id))})]})})(),H.filter(e=>!e.current).map(e=>{var s;let l=et.get(e.index);if(!l)return null;let o=!!N&&e.resChannels.some(e=>e.id===N),d=j===e.index||o,c=K(e.layer,e.index),x=[...c].sort((e,t)=>{let s=e.description.includes("(negative activations)");return s===t.description.includes("(negative activations)")?0:s?1:-1}),m="backward"===e.direction;return(0,n.jsxs)("div",{children:[x.length>0&&(0,n.jsx)("div",{className:"absolute flex max-w-[120px] flex-col",style:{to
1p:"".concat(l.top-3*(x.length>1),"px"),...m?{right:"calc(100% - ".concat(l.left,"px + 4px)"),alignItems:"flex-end"}:{left:"".concat(l.left+16,"px"),alignItems:"flex-start"}},children:x.map(e=>{let t=e.description.includes("(negative activations)"),s=e.description.replace(" (negative activations)","");return(0,n.jsxs)("div",{className:"flex items-center gap-x-0.5 text-[8px] font-medium leading-[10px]",style:{maxWidth:"120px"},title:s,children:[(0,n.jsx)("span",{className:"font-mono text-[10px] font-bold ".concat(t?"text-rose-500":"text-emerald-600"),style:{lineHeight:"10px"},children:t?"-":"+"}),(0,n.jsx)("span",{className:"truncate text-slate-600",children:s})]},e.id)})}),(0,n.jsxs)(r.jc,{openDelay:300,closeDelay:400,children:[(0,n.jsx)(r.d0,{asChild:!0,children:(0,n.jsx)(y(),{href:(0,i.uy)(null==t?void 0:t.modelId,"".concat(e.layer,"-mlp"),e.index),"aria-label":"Go to neuron ".concat(e.layer,"-MLP @ ").concat(e.index),className:"absolute block h-3 w-3 rounded-full border transition-colors ".concat(d?"bg-slate-500":"bg-slate-300"," ").concat(d?"border-slate-600":"border-slate-400"),style:{left:"".concat(l.left,"px"),top:"".concat(l.top,"px")},onMouseEnter:()=>{w(e.index);let s="".concat(e.layer,"-mlp");S&&S.layer===s&&S.index===e.index||(C(void 0),fetch("/api/feature/".concat(null==t?void 0:t.modelId,"/").concat(s,"/").concat(e.index),{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{C(e)}).catch(e=>{}))},onMouseLeave:()=>w(null)})}),(0,n.jsxs)(r.Et,{className:"max-h-[640px] min-h-[640px] w-[640px] min-w-[640px] max-w-[640px] overflow-y-auto border bg-white p-0",side:"backward"===e.direction?"left":"right",sideOffset:5,children:[(0,n.jsxs)("div",{className:"px-3 py-3 text-xs text-slate-600",children:[(0,n.jsxs)(y(),{href:(0,i.uy)(null==t?void 0:t.modelId,"".concat(e.layer,"-mlp"),e.index),className:"flex flex-row items-center gap-x-1 font-mono text-xs font-bold uppercase text-sky-700 hover:underline",children:[e.layer,"-MLP @ ",e.index," ",(0,n.jsx)(h.A,{className:"h-3 w-3"})]}),c.length>0&&(0,n.jsx)("div",{className:"mb-0 mt-3 text-[9px] font-bold uppercase text-slate-500",children:"Explanations"}),c.length>0&&(0,n.jsx)("div",{className:"mb-3 ml-2",children:c.sort((e,t)=>{let s=e.description.includes("(negative activations)");return s===t.description.includes("(negative activations)")?0:s?1:-1}).map(e=>{let t=e.description.includes("(negative activations)");return(0,n.jsxs)("div",{className:"mb-0.5 flex items-center gap-x-1.5 text-[12px] font-medium leading-snug",children:[(0,n.jsx)("span",{className:"font-mono text-[14px] font-bold leading-none ".concat(t?"text-rose-500":"text-emerald-600"),children:t?"-":"+"}),(0,n.jsx)("span",{className:"text-slate-600",children:e.description.replace(" (negative activations)","")})]},e.id)})}),(0,n.jsx)("div",{className:"mb-0 mt-2",children:(0,n.jsx)("span",{className:"text-[9px] font-bold uppercase text-slate-500",children:"backward"!==e.direction?"Reads From":"Writes To"})}),e.resChannels.map(s=>(0,n.jsx)("div",{className:"mb-1 font-mono text-[10px] font-medium",children:(0,n.jsxs)(y(),{href:(0,i.uy)(null==t?void 0:t.modelId,"".concat(e.layer,"-resid"),s.index),className:"ml-2 uppercase text-sky-700 hover:underline",children:[e.layer,"-resid @ ",s.index]})},s.id))]}),(null==S?void 0:S.activations)&&(null==S||null==(s=S.activations)?void 0:s.length)>0&&(null==S?void 0:S.layer)==="".concat(e.layer,"-mlp")&&(null==S?void 0:S.index)===e.index?(0,n.jsx)("div",{className:"-mt-2 h-[386px] w-full",children:(0,n.jsx)(a.default,{initialNeuron:S,embed:!0,forceMiniStats:!0},"".concat(null==S?void 0:S.modelId,"-").concat(null==S?void 0:S.layer,"-").concat(null==S?void 0:S.index))}):(0,n.jsx)("div",{className:"flex h-[386px] w-full items-center justify-center",children:(0,n.jsx)(g.K,{className:"h-6 w-6"})})]})]})]},e.index)})]})]})]})]})}},78234:(e,t,s)=>{s.d(t,{Ay:()=>d,MZ:()=>o});var n=s(95155),a=s(12115),l=s(11362),r=s(18695);let[i,o]=(0,s(26654).A)("CommentContext");function d(e){let{children:t}=e,[s,o]=(0,a.useState)([]),[d,c]=(0,a.useState)(!1),{currentFeature:x}=(0,l.VS)(),{user:m}=(0,r.SF)();(0,a.useEffect)(()=>{x&&x.comments&&(x.comments=s)},[s]);let u=(e,t,n,a)=>(c(!0),fetch("/api/comment/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e,modelId:t,layer:n,index:a})}).then(e=>(c(!1),e.json())).then(e=>{o([...s,{...e,user:m}])}).catch(e=>{alert(e),c(!1)})),p=(e,t)=>{window.confirm('Are you sure you want to delete this comment?\n\n"'.concat(t,'"'))&&fetch("/api/comment/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})}).then(e=>e.json()).then(()=>{o(s.filter(t=>t.id!==e))}).catch(e=>{alert(e)})},f=(0,a.useMemo)(()=>({comments:s,setComments:o,submitComment:u,deleteComment:p,isSubmittingComment:d,setIsSubmittingComment:c}),[s,u,p,d]);return(0,n.jsx)(i.Provider,{value:f,"data-sentry-element":"CommentContext.Provider","data-sentry-component":"CommentProvider","data-sentry-source-file":"comment-provider.tsx",children:t})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.