import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Ei as s,Mi as a,ki as t}from"./vendor-frame-CwiylG4Y.js";import{nn as r,rn as n}from"./vendor-all-2-BJdkbLSj.js";import{$ as l,R as o,bt as i,i as d}from"./shared-frame-DbQbH4Yr.js";import{Ts as m}from"./shared-2-CMUBhYOn.js";import{Gr as p,Hr as h,Nr as c,Pr as f,Ur as u,Wr as x}from"./shared-7-VxUxSmVa.js";import{t as j}from"./c2eed10ca-DDZovmAC.js";var g=e(a()),N=t(),b=(0,g.memo)(({children:e,className:s})=>(0,N.jsx)("div",{className:i("flex-1 flex flex-col min-h-0 overflow-hidden bg-surface-1 text-body border border-border-300 rounded-xl p-5",s),children:e})),v=(0,g.memo)(({files:e,isLoading:a=!1,hideCopyButton:t,omitStructuredHooksFrontmatter:i,contentClassName:v})=>{const w=n(),[F,k]=(0,g.useState)(null),[y,C]=(0,g.useState)(!1),[M,S,L]=c(),z=(0,g.useMemo)(()=>e.length>0?h(e):null,[e]),B=(0,g.useRef)(!1);(0,g.useEffect)(()=>{if(z&&!B.current){B.current=!0;const e=p(z),s=x(z);if(s){const a=s.split("/");for(let s=1;s<a.length;s++)e.add(a.slice(0,s).join("/"))}L(e)}},[z,L]);const H=(0,g.useMemo)(()=>u(e),[e]),T=(0,g.useMemo)(()=>{if(0===e.length)return null;const s=e=>e.split("/").filter(Boolean).join("/"),a=e.find(e=>"SKILL.md"===e.path||e.path.endsWith("/SKILL.md")),t=a?s(a.path).split("/").slice(H?1:0).join("/"):null,r=F??t??(z?x(z):null)??e[0].path,n=H?`${H}/${r}`:r;return{...e.find(e=>s(e.path)===n)??e[0],path:r}},[e,z,F,H]),E=(0,g.useCallback)((e,s)=>{"file"===s.type&&(k(s.path),C(!1))},[]),P=!!z&&e.length>1,R=m(T?.path.split("/").pop()??T?.path??""),$=P?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(d.Root,{open:y,onOpenChange:C,children:[(0,N.jsx)(d.Trigger,{render:(0,N.jsxs)(o,{variant:"secondary",size:"sm","aria-label":w.formatMessage({defaultMessage:"{name}. Choose a file in this skill",id:"iaA9zpzp0N"},{name:R}),children:[(0,N.jsx)("span",{className:"truncate max-w-[220px] font-normal",children:R}),(0,N.jsx)(l,{name:"CaretDown",size:"sm"})]})}),(0,N.jsx)(d.Popup,{side:"bottom",align:"start",className:"w-[260px] max-h-[min(400px,60vh)] p-sm overflow-y-auto",children:(0,N.jsx)(f,{fileTree:z,selectedPath:T?.path??null,expandedFolders:M,onFileSelect:E,onToggleFolder:S,variant:"settings",className:"w-full"})})]}),(0,N.jsx)("span",{className:"text-muted text-caption shrink-0",children:(0,N.jsx)(r,{defaultMessage:"{total, plural, one {# file} other {# files}}",id:"fy9BG3dE9F",values:{total:e.length}})})]}):null;return(0,N.jsx)(b,{className:s("min-w-0 p-0",v),children:(0,N.jsx)(j,{file:T,isLoading:a,hideFileName:!0,hideCopyButton:t,hideDescriptionHeading:!0,omitStructuredHooksFrontmatter:i,leadingActions:$})})});export{b as n,v as t};