UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

163 lines • 79.2 kB
import{c as L,b as de,j as t,e3 as ge,v as nt,D as lt,a6 as Le,q as ps,r as Y,x as rt,B as ce,hI as ms,b8 as Pt,m as ne,I as Ge,K as Oe,t as oe,Y as Ke,X as hs,Z as bs,_ as xs,i as gs,hJ as ut,eR as ys,o as vs,d as Mt,u as Bt,n as He,P as Ct,hw as ws,w as Dt,aW as Ot,y as $t,aR as js,aQ as ks,aN as Ns,aL as Ss,aM as Ps,aP as Cs,aO as Ds,bc as Os}from"./index-DoEtSiIe.js";import{s as $s}from"./Eye-DwRCQHLk.js";import{s as Ts}from"./Plus-BoPsX_T8.js";import{i as qe}from"./Upload01-DgxprpI7.js";import{u as Fs}from"./use-mobile-BjsAkqwr.js";import{S as zs}from"./search-input-wk0beNbE.js";import{R as ye,W as ze,J as le,O as at,X as At,Y as Es,Z as Ee,_ as xe,$ as Ms,a0 as Bs,a1 as Ye,a2 as Lt,a3 as ft,a4 as As,a5 as Ls,a6 as Is}from"./chat-context-vJ6R-Clt.js";import{u as Vs}from"./use-debounced-value-DqHSmPMR.js";import{r as It,h as ke,l as Ie,d as Rs,k as it,u as We,s as Us,t as _s,p as Vt}from"./use-org-fs-C62_MbqW.js";import{u as Hs,a as Ks}from"./use-org-repo-syncs-SmfSLgc1.js";import{T as qs}from"./textarea-CP9TQ5HN.js";import{t as Gs}from"./ChevronDown-Dm2xO7jf.js";import{n as Ys}from"./ChevronUp-BKdcyIOm.js";import{af as Me,bg as Xs,b as Qs,k as pt,aw as Ws,aO as Js,bh as Zs,A as en}from"./agent-icon-DoabtHNW.js";import{M as tn,k as sn}from"./markdown-DeZATUv_.js";import{f as nn,b as ln,g as rn,u as an,e as on}from"./context-shell-0fpmlncZ.js";import{S as cn}from"./file-share-button--SjJonFb.js";import{L as Rt}from"./preview-dialog-CGhTVXYZ.js";import{F as Je,S as Ut}from"./folder-icon-DC-T6LMD.js";import{d as dn}from"./repository-binding-BAQCDq-W.js";import{i as mt}from"./Zap-CxPsn4FS.js";import{E as _t}from"./empty-state-UX_DOq42.js";import{F as ht,d as un}from"./file-type-icon-R4tsODq6.js";import{a as fn}from"./SwitchHorizontal01-CHtrDs50.js";import{i as pn}from"./Key01-DfLmV_su.js";import{s as mn}from"./Trash01-Ctp9Olbr.js";import{n as hn,i as bn}from"./ArrowUp-s5a8DQxj.js";import{c as Ne,b as Ht,T as Se,a as xn,d as gn,e as yn}from"./table-RDPVkrI6.js";import{s as vn}from"./use-project-scope-AMUoXt2c.js";function wn(a){const e=L.c(28),s=de(),n=Hs(),r=It();if(a!==ye){let b;return e[0]===Symbol.for("react.memo_cache_sentinel")?(b=[],e[0]=b):b=e[0],b}let l;e[1]!==s?(l=s("library.library.all"),e[1]=s,e[2]=l):l=e[2];let i;e[3]!==a||e[4]!==l?(i={key:"all",label:l,path:a},e[3]=a,e[4]=l,e[5]=i):i=e[5];let o;e[6]!==s?(o=s("library.library.placeProjects"),e[6]=s,e[7]=o):o=e[7];let d;e[8]!==o?(d={key:ze,label:o,path:`${ye}/${ze}`},e[8]=o,e[9]=d):d=e[9];let c;e[10]!==s?(c=s("library.library.placeUploads"),e[10]=s,e[11]=c):c=e[11];let u;e[12]!==c?(u={key:"uploads",label:c,path:"uploads"},e[12]=c,e[13]=u):u=e[13];let p;e[14]!==s?(p=s("library.library.placeOutputs"),e[14]=s,e[15]=p):p=e[15];let f;e[16]!==p?(f={key:"outputs",label:p,path:"outputs"},e[16]=p,e[17]=f):f=e[17];let m;e[18]!==r.data?.length||e[19]!==s?(m=(r.data?.length??0)>0?[{key:"public",label:s("library.library.placeSkills"),path:"public"}]:[],e[18]=r.data?.length,e[19]=s,e[20]=m):m=e[20];let x;return e[21]!==n.data||e[22]!==i||e[23]!==d||e[24]!==u||e[25]!==f||e[26]!==m?(x=[i,d,u,f,...m,...(n.data??[]).map(jn)],e[21]=n.data,e[22]=i,e[23]=d,e[24]=u,e[25]=f,e[26]=m,e[27]=x):x=e[27],x}function jn(a){return{key:a.volume,label:a.volume,path:a.volume}}function kn(a){return a.kind==="file"?"file":a.hasSkill?"skill":a.hasBrand?"brand":"folder"}function Te(a){return{kind:kn(a),path:a.path,name:le(a.path),updatedAt:a.updatedAt,size:a.size??0,entry:a}}const Nn=["name","updated","size"];function Tt(a){return a.kind==="file"?1:0}function Xe(a,e){const s=(n,r)=>n.name.localeCompare(r.name,void 0,{numeric:!0,sensitivity:"base"});return[...a].sort((n,r)=>{const l=Tt(n)-Tt(r);if(l!==0)return l;if(e==="updated"){const i=(r.updatedAt??"").localeCompare(n.updatedAt??"");if(i!==0)return i}if(e==="size"){const i=r.size-n.size;if(i!==0)return i}return s(n,r)})}function Sn(a){if(a.kind!=="file")return null;const e=a.size;if(!e)return null;const s=["B","KB","MB","GB","TB"];let n=e,r=0;for(;n>=1024&&r<s.length-1;)n/=1024,r++;return`${n>=10||r===0?Math.round(n):n.toFixed(1)} ${s[r]}`}function Pn(a){const e=a("library.brandComponentsPreview.title"),s=a("library.brandComponentsPreview.subtitle"),n=a("library.brandComponentsPreview.monthlySavingsLabel"),r=a("library.brandComponentsPreview.primaryButton"),l=a("library.brandComponentsPreview.secondaryButton"),i=a("library.brandComponentsPreview.ghostButton"),o=a("library.brandComponentsPreview.successBadge"),d=a("library.brandComponentsPreview.warningBadge"),c=a("library.brandComponentsPreview.errorBadge"),u=a("library.brandComponentsPreview.infoBadge"),p=a("library.brandComponentsPreview.allChip"),f=a("library.brandComponentsPreview.incomeChip"),m=a("library.brandComponentsPreview.spendingChip"),x=a("library.brandComponentsPreview.emailPlaceholder");return`
  <div class="stack">
    <div>
      <h1>${e}</h1>
      <p class="muted" style="margin:6px 0 0">${s}</p>
    </div>
    <div class="row">
      <button class="btn btn-primary">${r}</button>
      <button class="btn btn-secondary">${l}</button>
      <button class="btn btn-ghost">${i}</button>
    </div>
    <div class="card">
      <p class="muted" style="margin:0 0 6px">${n}</p>
      <div class="kpi">$240</div>
    </div>
    <input class="input" placeholder="${x}" />
    <div class="row">
      <span class="badge badge-success">${o}</span>
      <span class="badge badge-warning">${d}</span>
      <span class="badge badge-error">${c}</span>
      <span class="badge badge-info">${u}</span>
    </div>
    <div class="row">
      <span class="chip chip-active">${p}</span>
      <span class="chip">${f}</span>
      <span class="chip">${m}</span>
    </div>
  </div>
`}const Cn=`
  *{box-sizing:border-box}
  body{margin:0;padding:24px;background:var(--brand-bg,#0b0f1a);color:var(--brand-fg,#f5f7ff);font-family:var(--brand-font-body,system-ui,sans-serif);font-size:14px;line-height:1.5}
  .stack{display:flex;flex-direction:column;gap:18px;max-width:760px}
  .row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
  h1{font-family:var(--brand-font-display,inherit);font-size:28px;font-weight:700;letter-spacing:-0.02em;margin:0}
  .muted{color:var(--brand-fg-muted,#9fb0c9)}
  .btn{border:0;border-radius:var(--brand-radius,12px);padding:10px 16px;font:inherit;font-weight:600;cursor:pointer}
  .btn-primary{background:var(--brand-primary,#0a84ff);color:#fff}
  .btn-secondary{background:transparent;color:var(--brand-fg,#f5f7ff);border:1.5px solid var(--brand-border-strong,rgba(255,255,255,.22))}
  .btn-ghost{background:transparent;color:var(--brand-fg-muted,#9fb0c9)}
  .card{background:var(--brand-bg-subtle,#121826);border:1px solid var(--brand-border,rgba(255,255,255,.1));border-radius:var(--brand-radius-lg,16px);padding:20px;box-shadow:var(--brand-shadow-md,0 6px 16px rgba(8,12,22,.45))}
  .kpi{font-family:var(--brand-font-display,inherit);font-size:44px;font-weight:700;color:var(--brand-primary,#0a84ff);line-height:1;letter-spacing:-0.02em}
  .input{width:100%;background:var(--brand-bg-elevated,#1a2233);border:1.5px solid var(--brand-border,rgba(255,255,255,.12));border-radius:var(--brand-radius,12px);padding:10px 12px;color:inherit;font:inherit}
  .badge{display:inline-flex;align-items:center;border-radius:999px;padding:4px 10px;font-size:12px;font-weight:600}
  .badge-success{background:var(--brand-success-bg,#e7f6ec);color:var(--brand-success-fg,#0f7a37)}
  .badge-warning{background:var(--brand-warning-bg,#fdf3d6);color:var(--brand-warning-fg,#8a6500)}
  .badge-error{background:var(--brand-error-bg,#fde7e8);color:var(--brand-error-fg,#b01319)}
  .badge-info{background:var(--brand-info-bg,#e8f1ff);color:var(--brand-info-fg,#0b54a8)}
  .chip{border:1.5px solid var(--brand-border-strong,rgba(255,255,255,.22));border-radius:999px;padding:6px 14px;font-size:13px}
  .chip-active{background:var(--brand-primary,#0a84ff);border-color:transparent;color:#fff}
`;function Dn(a,e){return`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><style>${a??""}</style><style>${Cn}</style></head><body>${e}</body></html>`}function On(a){const e=L.c(11),{tokensUrl:s}=a,n=de(),r=ke(s??"");if(s&&r.isPending){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("div",{className:"flex h-full w-full items-center justify-center p-6",children:t.jsx(ge,{className:"h-full w-full rounded-xl"})}),e[0]=u):u=e[0],u}let l;e[1]!==n?(l=n("library.brandComponentsPreview.iframeTitle"),e[1]=n,e[2]=l):l=e[2];const i=l;let o,d;if(e[3]!==i||e[4]!==n||e[5]!==r.data){const u=Pn(n);o=i,d=Dn(r.data??null,u),e[3]=i,e[4]=n,e[5]=r.data,e[6]=o,e[7]=d}else o=e[6],d=e[7];let c;return e[8]!==o||e[9]!==d?(c=t.jsx("iframe",{title:o,srcDoc:d,sandbox:"",className:"block h-full w-full border-0 bg-white"}),e[8]=o,e[9]=d,e[10]=c):c=e[10],c}const $n="Theme preview",Tn=[`<section class="slide-center">
    <p class="eyebrow">Brand deck</p>
    <h1 class="deck-h1">Your brand, on every slide</h1>
    <p class="deck-sub">A live preview of each slide layout in your brand style.</p>
    <p class="deck-meta">Theme preview</p>
  </section>`,`<section>
    <p class="eyebrow">Agenda</p>
    <h2 class="deck-h2">What's in this theme</h2>
    <ol class="agenda">
      <li>Title &amp; section dividers</li>
      <li>Bulleted content</li>
      <li>Side-by-side columns</li>
      <li>Metrics &amp; timelines</li>
      <li>Quotes &amp; closing</li>
    </ol>
  </section>`,`<section class="slide-center divider">
    <p class="giant-number">01</p>
    <h2 class="deck-h1">Content layouts</h2>
    <p class="deck-sub">How text-heavy slides look.</p>
  </section>`,`<section>
    <p class="eyebrow">Bullets</p>
    <h2 class="deck-h2">Key points land cleanly</h2>
    <p class="deck-body intro">Short, scannable lines with the brand accent marker.</p>
    <ul class="bullets">
      <li>Each point is one idea</li>
      <li>Accent color draws the eye</li>
      <li>Plenty of breathing room</li>
    </ul>
  </section>`,`<section>
    <p class="eyebrow">Two column</p>
    <h2 class="deck-h2">Compare side by side</h2>
    <div class="cols">
      <div class="card grow">
        <h3 class="col-title">Before</h3>
        <div class="deck-body"><p>Generic slides that ignore your brand.</p></div>
      </div>
      <div class="card grow">
        <h3 class="col-title">After</h3>
        <div class="deck-body"><p>Every deck on-brand, automatically.</p></div>
      </div>
    </div>
  </section>`,`<section>
    <p class="eyebrow">Metrics</p>
    <h2 class="deck-h2">Numbers that matter</h2>
    <div class="cols kpis">
      <div class="card kpi grow">
        <p class="kpi-value">3&times;</p>
        <p class="kpi-label">Faster deck creation</p>
        <p class="kpi-delta">since adopting the theme</p>
      </div>
      <div class="card kpi grow">
        <p class="kpi-value">100%</p>
        <p class="kpi-label">On-brand slides</p>
        <p class="kpi-delta">no manual restyling</p>
      </div>
      <div class="card kpi grow">
        <p class="kpi-value">1</p>
        <p class="kpi-label">Source of truth</p>
        <p class="kpi-delta">tokens.css</p>
      </div>
    </div>
  </section>`,`<section>
    <p class="eyebrow">Timeline</p>
    <h2 class="deck-h2">How it unfolds</h2>
    <div class="cols timeline">
      <div class="step grow">
        <p class="step-label">Step 1</p>
        <h3 class="col-title">Define</h3>
        <p class="deck-body">Set brand tokens once.</p>
      </div>
      <div class="step grow">
        <p class="step-label">Step 2</p>
        <h3 class="col-title">Generate</h3>
        <p class="deck-body">Create decks from data.</p>
      </div>
      <div class="step grow">
        <p class="step-label">Step 3</p>
        <h3 class="col-title">Present</h3>
        <p class="deck-body">Ship, always on-brand.</p>
      </div>
    </div>
  </section>`,`<section>
    <p class="eyebrow">Comparison</p>
    <h2 class="deck-h2">Plans at a glance</h2>
    <div class="cols">
      <div class="card grow">
        <h3 class="col-title">Starter</h3>
        <ul class="bullets compact">
          <li>Core layouts</li>
          <li>Brand colors</li>
          <li>Logo</li>
        </ul>
      </div>
      <div class="card grow">
        <h3 class="col-title">Pro</h3>
        <ul class="bullets compact">
          <li>Everything in Starter</li>
          <li>Custom fonts</li>
          <li>Theme shell</li>
        </ul>
      </div>
    </div>
  </section>`,`<section class="slide-center">
    <blockquote class="deck-quote">&ldquo;Design once, stay on-brand everywhere.&rdquo;</blockquote>
    <p class="attribution">Brand system &middot; Studio</p>
  </section>`,`<section class="slide-center">
    <h2 class="deck-h1">Ready to present</h2>
    <p class="deck-sub">Generate a deck with this theme via the slides skill.</p>
    <p class="cta">slides-create --theme &hellip;</p>
  </section>`].join(`

`);function Fn(a,e){const s=e?`<style>${e}</style>`:"";return a.replaceAll("{{{slides}}}",Tn).replaceAll("{{title}}",$n).replace(/(src=")(\/deck-runtime\/)/g,`$1${window.location.origin}$2`).replace("</head>",`${s}</head>`)}function zn(a){const e=L.c(8),{readUrl:s,title:n,tokensUrl:r}=a,l=ke(s),i=ke(r??"");if(l.isPending||r&&i.isPending){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("div",{className:"flex h-full w-full items-center justify-center p-6",children:t.jsx(ge,{className:"aspect-[16/9] w-full max-w-3xl rounded-xl"})}),e[0]=u):u=e[0],u}if(l.isError||!l.data){let u;return e[1]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"This theme is no longer available."}),e[1]=u):u=e[1],u}const o=i.data??null;let d;e[2]!==o||e[3]!==l.data?(d=Fn(l.data,o),e[2]=o,e[3]=l.data,e[4]=d):d=e[4];let c;return e[5]!==d||e[6]!==n?(c=t.jsx("iframe",{title:n,srcDoc:d,sandbox:"allow-scripts",className:"block h-full w-full border-0 bg-white"}),e[5]=d,e[6]=n,e[7]=c):c=e[7],c}function $e(a){const e=L.c(2),{children:s}=a;let n;return e[0]!==s?(n=t.jsx("p",{className:"text-sm font-medium text-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function En(a){const e=L.c(16),{family:s,tokens:n,editing:r,valueOf:l,onEdit:i}=a;let o;e[0]!==s?(o=t.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[0]=s,e[1]=o):o=e[1];let d;if(e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==l){let p;e[7]!==r||e[8]!==i||e[9]!==l?(p=f=>{const m=l(f),x=`${f.name.replace(/^--brand-/,"")}: ${m}`;return r&&/^#/.test(m)?t.jsx("input",{type:"color","aria-label":f.name,title:x,value:on(m),onChange:b=>i(f.name,b.target.value),className:"size-7 cursor-pointer rounded-md border border-border/60 bg-transparent p-0.5"},f.name):t.jsx("span",{title:x,className:"size-7 rounded-md border border-border/60",style:{backgroundColor:m}},f.name)},e[7]=r,e[8]=i,e[9]=l,e[10]=p):p=e[10],d=n.map(p),e[2]=r,e[3]=i,e[4]=n,e[5]=l,e[6]=d}else d=e[6];let c;e[11]!==d?(c=t.jsx("div",{className:"flex flex-wrap gap-1",children:d}),e[11]=d,e[12]=c):c=e[12];let u;return e[13]!==o||e[14]!==c?(u=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[o,c]}),e[13]=o,e[14]=c,e[15]=u):u=e[15],u}function Mn(a){const e=L.c(9),{token:s,value:n}=a;if(s.kind==="space"){let l;return e[0]!==n?(l=t.jsx("span",{className:"flex h-7 w-16 shrink-0 items-center",children:t.jsx("span",{className:"h-1.5 rounded-full bg-primary",style:{width:n,maxWidth:"100%"}})}),e[0]=n,e[1]=l):l=e[1],l}if(s.kind==="radius"){let l;return e[2]!==n?(l=t.jsx("span",{className:"size-7 shrink-0 border border-border bg-muted/50",style:{borderRadius:n}}),e[2]=n,e[3]=l):l=e[3],l}if(s.kind==="shadow"){let l;return e[4]!==n?(l=t.jsx("span",{className:"size-7 shrink-0 rounded-md bg-background",style:{boxShadow:n}}),e[4]=n,e[5]=l):l=e[5],l}if(s.kind==="type"&&/^--brand-text-/.test(s.name)){const l=`min(${n}, 22px)`;let i;return e[6]!==l?(i=t.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center overflow-hidden leading-none text-foreground",style:{fontSize:l},children:"Ag"}),e[6]=l,e[7]=i):i=e[7],i}let r;return e[8]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{className:"size-7 shrink-0"}),e[8]=r):r=e[8],r}function Kt(a){const e=L.c(17),{token:s,value:n,editing:r,onEdit:l}=a;let i;e[0]!==s||e[1]!==n?(i=t.jsx(Mn,{token:s,value:n}),e[0]=s,e[1]=n,e[2]=i):i=e[2];let o;if(e[3]!==s.name){let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=/^--brand-/,e[5]=p):p=e[5],o=s.name.replace(p,""),e[3]=s.name,e[4]=o}else o=e[4];let d;e[6]!==o?(d=t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:o}),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==r||e[9]!==l||e[10]!==s.name||e[11]!==n?(c=r?t.jsx(Ge,{value:n,onChange:p=>l(s.name,p.target.value),className:"h-8 w-40 font-mono text-xs"}):t.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:n}),e[8]=r,e[9]=l,e[10]=s.name,e[11]=n,e[12]=c):c=e[12];let u;return e[13]!==i||e[14]!==d||e[15]!==c?(u=t.jsxs("div",{className:"flex items-center gap-3",children:[i,d,c]}),e[13]=i,e[14]=d,e[15]=c,e[16]=u):u=e[16],u}function Pe(a){const e=L.c(16),{label:s,tokens:n,editing:r,valueOf:l,onEdit:i}=a;if(n.length===0)return null;let o;e[0]!==s?(o=t.jsx($e,{children:s}),e[0]=s,e[1]=o):o=e[1];let d;if(e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==l){let p;e[7]!==r||e[8]!==i||e[9]!==l?(p=f=>t.jsx(Kt,{token:f,value:l(f),editing:r,onEdit:i},f.name),e[7]=r,e[8]=i,e[9]=l,e[10]=p):p=e[10],d=n.map(p),e[2]=r,e[3]=i,e[4]=n,e[5]=l,e[6]=d}else d=e[6];let c;e[11]!==d?(c=t.jsx("div",{className:"flex flex-col gap-2.5",children:d}),e[11]=d,e[12]=c):c=e[12];let u;return e[13]!==o||e[14]!==c?(u=t.jsxs("div",{className:"flex flex-col gap-3",children:[o,c]}),e[13]=o,e[14]=c,e[15]=u):u=e[15],u}function Bn({brandPath:a,onClose:e,variant:s}){const n=de(),{org:r}=Le(),l=at(a),i=l.volume??"",o=l.dirPath,d=le(o),c=l.readOnly,u=ps(),p=Ie(),f=Rs(i),{upload:m,remove:x}=it(i),b=Y.useRef(null),N=We(i,o),j=N.data??[],w=P=>j.some(J=>J.kind==="file"&&le(J.path)===P),k=w("tokens.css"),$=w("brand.md"),y=w("slides-theme.html"),D=nn(j),S=p(i,`${o}/tokens.css`),I=p(i,`${o}/brand.md`),v=p(i,`${o}/slides-theme.html`),z=ke(S,{enabled:k}),V=ke(I,{enabled:$}),[T,A]=Y.useState(!1),[F,B]=Y.useState({}),[M,R]=Y.useState(null),[C,U]=Y.useState(!1),[O,E]=Y.useState(!1),[q,Z]=Y.useState("deck"),_=z.data?ln(z.data):[],ee=P=>_.find(J=>J.name===P)?.value,H=P=>F[P.name]??P.value,X=rn(_),Q=_.filter(P=>P.kind==="font"),te=_.filter(P=>P.kind==="type"),re=_.filter(P=>P.kind==="space"),ae=_.filter(P=>P.kind==="radius"),he=_.filter(P=>P.kind==="shadow"),pe=_.filter(P=>P.kind==="motion"),be=_.filter(P=>P.kind==="other"),ie=(P,J)=>B(je=>({...je,[P]:J})),ve=y&&q==="deck",h=M??V.data??"",K=Object.entries(F).filter(([P,J])=>ee(P)!==J),W=M!==null&&M!==(V.data??""),se=K.length>0||W;function fe(){B({}),R(null),A(!1)}async function me(){U(!0);try{if(K.length>0){let P=z.data??"";for(const[J,je]of K)P=an(P,J,je);await f.mutateAsync({path:`${o}/tokens.css`,body:P,contentType:"text/css; charset=utf-8"}),u.invalidateQueries({queryKey:Oe.fileText(S)})}W&&M!==null&&(await f.mutateAsync({path:`${o}/brand.md`,body:M,contentType:"text/markdown; charset=utf-8"}),u.invalidateQueries({queryKey:Oe.fileText(I)})),u.invalidateQueries({queryKey:Oe.orgFsVolume(r.id,i)}),u.invalidateQueries({queryKey:Oe.orgFsRecent(r.id)}),B({}),R(null),A(!1),oe.success(n("library.brandPreview.brandSaved"))}catch(P){oe.error(P instanceof Error?P.message:n("library.brandPreview.failedSaveBrand"))}finally{U(!1)}}async function et(P){const J=P?.[0];if(!J)return;const Ue=`logo.${(J.name.split(".").pop()??"png").toLowerCase()}`;try{await m.mutateAsync({dir:o,files:[new File([J],Ue,{type:J.type})]}),D&&le(D)!==Ue&&await x.mutateAsync(D),oe.success(n("library.brandPreview.logoUpdated"))}catch(_e){oe.error(_e instanceof Error?_e.message:n("library.brandPreview.logoUploadFailed"))}finally{b.current&&(b.current.value="")}}const Re=!N.isPending&&!k&&!$&&!D;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[t.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:t.jsx(Me,{size:18})}),s==="dialog"?t.jsx(rt,{className:"flex-1 truncate text-base font-medium text-foreground",children:d}):t.jsx("span",{className:"flex-1 truncate text-base font-medium text-foreground",children:d}),!c&&(T?t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"sm",onClick:fe,disabled:C,children:n("library.brandPreview.cancel")}),t.jsx(ce,{size:"sm",disabled:!se||C,onClick:()=>{me()},children:n(C?"library.brandPreview.saving":"library.brandPreview.save")})]}):t.jsxs(ce,{variant:"outline",size:"sm",onClick:()=>A(!0),children:[t.jsx(Xs,{size:14}),n("library.brandPreview.edit")]})),s==="dialog"?t.jsx(ms,{asChild:!0,children:t.jsx(ce,{variant:"ghost",size:"icon",className:"shrink-0",children:t.jsx(Pt,{size:16})})}):t.jsx(ce,{variant:"ghost",size:"icon",className:"shrink-0",onClick:e,children:t.jsx(Pt,{size:16})})]}),t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:N.isPending?t.jsxs("div",{className:"flex flex-col gap-3 p-6",children:[t.jsx(ge,{className:"h-40 w-full rounded-xl"}),t.jsx(ge,{className:"h-4 w-1/3"}),t.jsx(ge,{className:"h-4 w-2/3"})]}):Re?t.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:n("library.brandPreview.brandNotAvailable")}):t.jsxs(t.Fragment,{children:[(y||k)&&t.jsxs("div",{className:"shrink-0 border-b border-border",children:[t.jsxs("div",{role:"button",tabIndex:0,"aria-label":n(O?"library.brandPreview.showPreview":"library.brandPreview.hidePreview"),onClick:()=>E(P=>!P),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),E(J=>!J))},className:"flex cursor-pointer items-center justify-between gap-2 px-4 py-2.5 hover:bg-accent",children:[t.jsxs("div",{className:"surface-inset flex gap-0.5 p-0.5 text-xs font-medium",onClick:P=>P.stopPropagation(),children:[y&&t.jsx("button",{type:"button",onClick:()=>{Z("deck"),E(!1)},className:ne("rounded-lg px-2.5 py-1",ve?"bg-background text-foreground shadow-edge":"text-muted-foreground hover:text-foreground"),children:n("library.brandPreview.deck")}),t.jsx("button",{type:"button",onClick:()=>{Z("components"),E(!1)},className:ne("rounded-lg px-2.5 py-1",ve?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-edge"),children:n("library.brandPreview.components")})]}),O?t.jsx(Gs,{size:16,className:"shrink-0 text-muted-foreground"}):t.jsx(Ys,{size:16,className:"shrink-0 text-muted-foreground"})]}),!O&&t.jsx("div",{className:"px-4 pb-4",children:t.jsx("div",{className:ne("w-full overflow-hidden rounded-xl border border-border bg-muted/30",ve?"aspect-[16/9]":"h-96"),children:ve?t.jsx(zn,{readUrl:v,title:`${d} deck theme`,tokensUrl:S}):t.jsx(On,{tokensUrl:S})})})]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto p-6",children:[t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx($e,{children:n("library.brandPreview.logo")}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:"flex size-24 items-center justify-center overflow-hidden rounded-xl border border-border bg-muted/30",children:D?t.jsx("img",{src:p(i,D),alt:`${d} logo`,className:"max-h-full max-w-full object-contain"}):t.jsx(Me,{size:28,className:"text-muted-foreground/50"})}),T&&t.jsxs("div",{children:[t.jsxs(ce,{variant:"outline",size:"sm",disabled:m.isPending,onClick:()=>b.current?.click(),children:[t.jsx(qe,{size:14}),n(D?"library.brandPreview.replaceLogo":"library.brandPreview.addLogo")]}),t.jsx("input",{ref:b,type:"file",accept:"image/*",className:"hidden",onChange:P=>{et(P.target.files)}})]})]})]}),X.length>0&&t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx($e,{children:n("library.brandPreview.colors")}),X.map(P=>t.jsx(En,{family:P.family,tokens:P.tokens,editing:T,valueOf:H,onEdit:ie},P.family))]}),(Q.length>0||te.length>0)&&t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx($e,{children:n("library.brandPreview.typography")}),Q.map(P=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:P.name.replace(/^--brand-font-?/,"")||n("library.brandPreview.defaultFont")}),T?t.jsx(Ge,{value:H(P),onChange:J=>ie(P.name,J.target.value),className:"h-9"}):t.jsx("span",{className:"truncate text-lg text-foreground",style:{fontFamily:H(P)},children:H(P)})]},P.name)),te.map(P=>t.jsx(Kt,{token:P,value:H(P),editing:T,onEdit:ie},P.name))]}),t.jsx(Pe,{label:n("library.brandPreview.spacing"),tokens:re,editing:T,valueOf:H,onEdit:ie}),t.jsx(Pe,{label:n("library.brandPreview.radius"),tokens:ae,editing:T,valueOf:H,onEdit:ie}),t.jsx(Pe,{label:n("library.brandPreview.shadows"),tokens:he,editing:T,valueOf:H,onEdit:ie}),t.jsx(Pe,{label:n("library.brandPreview.motion"),tokens:pe,editing:T,valueOf:H,onEdit:ie}),t.jsx(Pe,{label:n("library.brandPreview.tokens"),tokens:be,editing:T,valueOf:H,onEdit:ie}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx($e,{children:n("library.brandPreview.voiceGuidelines")}),T?t.jsx(qs,{value:h,onChange:P=>R(P.target.value),placeholder:n("library.brandPreview.voicePlaceholder"),className:"min-h-48 font-mono text-sm"}):V.isPending&&$?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(ge,{className:"h-3 w-full"}),t.jsx(ge,{className:"h-3 w-5/6"})]}):h.trim()?t.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t.jsx(tn,{id:`brand-preview-${a}`,text:h})}):t.jsx("p",{className:"text-sm text-muted-foreground",children:n("library.brandPreview.noVoiceYet")})]})]})]})})]})}function qt(a){const e=L.c(8),{brandPath:s,onClose:n}=a;let r;e[0]!==n?(r=o=>{o||n()},e[0]=n,e[1]=r):r=e[1];let l;e[2]!==s||e[3]!==n?(l=t.jsx(nt,{className:"flex h-[88vh] w-[94vw] max-w-none! flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl!",closeButtonClassName:"hidden",children:t.jsx(Bn,{brandPath:s,onClose:n,variant:"dialog"})}),e[2]=s,e[3]=n,e[4]=l):l=e[4];let i;return e[5]!==r||e[6]!==l?(i=t.jsx(lt,{open:!0,onOpenChange:r,children:l}),e[5]=r,e[6]=l,e[7]=i):i=e[7],i}const An=new Set(["pdf","doc","docx","odt","rtf","txt","md","markdown","xls","xlsx","ods","csv","tsv","ppt","pptx","odp","key","pages","numbers","html","htm","epub"]),Ln=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","tif","tiff","ico","heic","heif","mp4","webm","mov","m4v","avi","mkv","mp3","wav","ogg","oga","m4a","aac","flac"]);function ot(a,e){if(e==="all")return!0;const s=a.slice(a.lastIndexOf("/")+1),n=s.lastIndexOf(".");if(n<=0)return!1;const r=s.slice(n+1).toLowerCase();return(e==="media"?Ln:An).has(r)}const In={today:1,week:7,month:30};function Vn(a,e,s=Date.now()){if(e==="any")return!0;const n=Date.parse(a);return Number.isNaN(n)?!1:s-n<=In[e]*24*60*60*1e3}const Rn=new Set(["png","jpg","jpeg","gif","webp","svg","avif"]),Un=new Set(["csv","tsv"]),_n=new Set(["mp4","webm","mov","m4v"]),Hn=new Set(["txt","json","log","yaml","yml","xml"]),Ft=256*1024;function Kn(a){return a.split(".").pop()?.toLowerCase()??""}async function qn(a,e){const s=await fetch(a,{credentials:"include",...e});if(!s.ok)throw new Error(`fetch failed: ${s.status}`);return s.text()}function Gn(a){const e=L.c(6),{onShare:s,t:n}=a;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Js,{size:14}),e[0]=r):r=e[0];let l;e[1]!==n?(l=n("library.cards.share"),e[1]=n,e[2]=l):l=e[2];let i;return e[3]!==s||e[4]!==l?(i=t.jsxs(Ke,{onClick:s,children:[r,l]}),e[3]=s,e[4]=l,e[5]=i):i=e[5],i}function Qe(a){const e=L.c(12),{state:s,t:n}=a;let r;e[0]!==s||e[1]!==n?(r=n(s==="password"?"library.cards.passwordProtected":s==="inherited"?"library.cards.sharedViaParent":"library.cards.publicBadge"),e[0]=s,e[1]=n,e[2]=r):r=e[2];const l=r,i=s==="password"?pn:Qs,o=s==="inherited"?"text-muted-foreground/60":"text-primary";let d;e[3]!==o?(d=ne(o),e[3]=o,e[4]=d):d=e[4];let c;e[5]!==i||e[6]!==l||e[7]!==d?(c=t.jsx(i,{size:12,className:d,"aria-label":l}),e[5]=i,e[6]=l,e[7]=d,e[8]=c):c=e[8];let u;return e[9]!==l||e[10]!==c?(u=t.jsx("span",{title:l,className:"mt-0.5 flex shrink-0 items-center",children:c}),e[9]=l,e[10]=c,e[11]=u):u=e[11],u}function bt(a){const e=L.c(26),{label:s,onBrowse:n,onShare:r,download:l,onDelete:i,t:o}=a;if(!n&&!r&&!l&&!i)return;let d;e[0]!==s||e[1]!==o?(d=o("library.cards.actionsFor",{label:s}),e[0]=s,e[1]=o,e[2]=d):d=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(fn,{size:14}),e[3]=c):c=e[3];let u;e[4]!==d?(u=t.jsx(hs,{asChild:!0,children:t.jsx(ce,{variant:"ghost",size:"icon-xs",className:"shrink-0 opacity-0 transition-opacity group-hover/card:opacity-100 data-[state=open]:opacity-100",onClick:Xn,"aria-label":d,children:c})}),e[4]=d,e[5]=u):u=e[5];let p;e[6]!==n||e[7]!==o?(p=n&&t.jsxs(Ke,{onClick:n,children:[t.jsx(pt,{size:14}),o("library.cards.browseFiles")]}),e[6]=n,e[7]=o,e[8]=p):p=e[8];let f;e[9]!==r||e[10]!==o?(f=r&&t.jsx(Gn,{onShare:r,t:o}),e[9]=r,e[10]=o,e[11]=f):f=e[11];let m;e[12]!==l||e[13]!==o?(m=l&&t.jsx(Ke,{asChild:!0,children:t.jsxs("a",{href:l.url,download:l.filename,children:[t.jsx(Ws,{size:14}),o("library.cards.download")]})}),e[12]=l,e[13]=o,e[14]=m):m=e[14];let x;e[15]!==i||e[16]!==o?(x=i&&t.jsxs(Ke,{variant:"destructive",onClick:i,children:[t.jsx(mn,{size:14}),o("library.cards.delete")]}),e[15]=i,e[16]=o,e[17]=x):x=e[17];let b;e[18]!==p||e[19]!==f||e[20]!==m||e[21]!==x?(b=t.jsxs(bs,{align:"end",onClick:Yn,children:[p,f,m,x]}),e[18]=p,e[19]=f,e[20]=m,e[21]=x,e[22]=b):b=e[22];let N;return e[23]!==u||e[24]!==b?(N=t.jsxs(xs,{children:[u,b]}),e[23]=u,e[24]=b,e[25]=N):N=e[25],N}function Yn(a){return a.stopPropagation()}function Xn(a){return a.stopPropagation()}function Gt(a){const e=L.c(44),{size:s,filename:n,downloadUrl:r,subtitle:l,publicState:i,selected:o,compact:d,onOpen:c,onShare:u,onDelete:p,draggable:f,onDragStart:m,onContextMenu:x}=a,b=s===void 0?0:s,N=o===void 0?!1:o,j=d===void 0?!1:d,w=de();let k;e[0]!==c?(k=B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),c())},e[0]=c,e[1]=k):k=e[1];let $;e[2]!==j||e[3]!==r||e[4]!==n||e[5]!==b?($=t.jsx(nl,{filename:n,size:b,downloadUrl:r,compact:j}),e[2]=j,e[3]=r,e[4]=n,e[5]=b,e[6]=$):$=e[6];let y;e[7]!==n?(y=t.jsx(ht,{filename:n,className:"h-5 w-4 shrink-0"}),e[7]=n,e[8]=y):y=e[8];let D;e[9]!==n?(D=t.jsx("span",{className:"truncate text-sm font-medium text-foreground",title:n,children:n}),e[9]=n,e[10]=D):D=e[10];let S;e[11]!==i||e[12]!==w?(S=i&&t.jsx(Qe,{state:i,t:w}),e[11]=i,e[12]=w,e[13]=S):S=e[13];let I;e[14]!==D||e[15]!==S?(I=t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[D,S]}),e[14]=D,e[15]=S,e[16]=I):I=e[16];let v;e[17]!==l?(v=t.jsx("span",{className:"text-meta truncate",title:l,children:l}),e[17]=l,e[18]=v):v=e[18];let z;e[19]!==v||e[20]!==I?(z=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[I,v]}),e[19]=v,e[20]=I,e[21]=z):z=e[21];let V;e[22]!==r||e[23]!==n?(V={url:r,filename:n},e[22]=r,e[23]=n,e[24]=V):V=e[24];let T;e[25]!==n||e[26]!==p||e[27]!==u||e[28]!==w||e[29]!==V?(T=t.jsx(bt,{label:n,download:V,onShare:u,onDelete:p,t:w}),e[25]=n,e[26]=p,e[27]=u,e[28]=w,e[29]=V,e[30]=T):T=e[30];let A;e[31]!==z||e[32]!==T||e[33]!==y?(A=t.jsxs("div",{className:"flex min-w-0 items-center gap-2 pl-1.5",children:[y,z,T]}),e[31]=z,e[32]=T,e[33]=y,e[34]=A):A=e[34];let F;return e[35]!==f||e[36]!==x||e[37]!==m||e[38]!==c||e[39]!==N||e[40]!==A||e[41]!==k||e[42]!==$?(F=t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":N,draggable:f,onClick:c,onKeyDown:k,onDragStart:m,onContextMenu:x,className:"group/card surface surface-interactive focus-ring flex min-w-0 cursor-pointer flex-col gap-2.5 p-1.5 pb-2 text-left aria-pressed:bg-accent",children:[$,A]}),e[35]=f,e[36]=x,e[37]=m,e[38]=c,e[39]=N,e[40]=A,e[41]=k,e[42]=$,e[43]=F):F=e[43],F}function Ce(a){const e=L.c(4),{children:s,whileVisible:n}=a,r=n===void 0?!1:n,[l,i]=Y.useState(!1);let o;e[0]!==r?(o=()=>p=>{if(!p)return;const f=new IntersectionObserver(m=>{const[x]=m;x?.isIntersecting?(i(!0),r||f.disconnect()):r&&i(!1)},{rootMargin:"200px"});return f.observe(p),()=>f.disconnect()},e[0]=r,e[1]=o):o=e[1];const[d]=Y.useState(o),c=l&&s;let u;return e[2]!==c?(u=t.jsx("div",{ref:d,className:"h-full w-full",children:c}),e[2]=c,e[3]=u):u=e[3],u}function Qn(a){const e=L.c(6),{url:s,filename:n}=a,{data:r}=ke(s);if(r===void 0)return null;if(r===null||!r.trim()){let o;return e[0]!==n?(o=t.jsx(Be,{filename:n}),e[0]=n,e[1]=o):o=e[1],o}let l;e[2]!==r?(l=r.slice(0,2e3),e[2]=r,e[3]=l):l=e[3];let i;return e[4]!==l?(i=t.jsx("pre",{className:"pointer-events-none h-full w-full overflow-hidden bg-background p-3 font-mono text-[9px] leading-[1.5] text-muted-foreground select-none",children:l}),e[4]=l,e[5]=i):i=e[5],i}function Wn(a){const e=L.c(6),{url:s,filename:n}=a,{data:r}=ke(s);if(r===void 0)return null;if(r===null||!r.trim()){let o;return e[0]!==n?(o=t.jsx(Be,{filename:n}),e[0]=n,e[1]=o):o=e[1],o}let l;e[2]!==r?(l=r.slice(0,4e3),e[2]=r,e[3]=l):l=e[3];let i;return e[4]!==l?(i=t.jsx("div",{className:"pointer-events-none h-[200%] w-[200%] origin-top-left scale-50 overflow-hidden bg-background p-6 text-sm select-none",children:t.jsx(sn,{children:l})}),e[4]=l,e[5]=i):i=e[5],i}function Be(a){const e=L.c(2),{filename:s}=a;let n;return e[0]!==s?(n=t.jsx("div",{className:"flex h-full w-full items-center justify-center",children:t.jsx(ht,{filename:s,className:"h-14 w-11 opacity-60"})}),e[0]=s,e[1]=n):n=e[1],n}function Jn(a){const e=L.c(23),{url:s,ext:n}=a;let r;e[0]!==s?(r=Oe.csvThumb(s),e[0]=s,e[1]=r):r=e[1];let l;e[2]!==s?(l=()=>qn(s,{headers:{Range:"bytes=0-8191"}}),e[2]=s,e[3]=l):l=e[3];let i;e[4]!==r||e[5]!==l?(i={queryKey:r,queryFn:l,staleTime:6e4,retry:!1},e[4]=r,e[5]=l,e[6]=i):i=e[6];const{data:o}=gs(i);if(!o)return null;const d=n==="tsv"?"	":",";let c,u,p,f;if(e[7]!==o||e[8]!==d){f=Symbol.for("react.early_return_sentinel");e:{let N;e[13]!==d?(N=w=>w.split(d).slice(0,6).map(tl),e[13]=d,e[14]=N):N=e[14];const j=o.split(`
`).filter(Boolean).slice(0,7).map(N);if(j.length===0){f=null;break e}p="pointer-events-none h-full w-full overflow-hidden bg-background p-2 select-none",u="w-full border-collapse",c=j.map(Zn)}e[7]=o,e[8]=d,e[9]=c,e[10]=u,e[11]=p,e[12]=f}else c=e[9],u=e[10],p=e[11],f=e[12];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;e[15]!==c?(m=t.jsx("tbody",{children:c}),e[15]=c,e[16]=m):m=e[16];let x;e[17]!==u||e[18]!==m?(x=t.jsx("table",{className:u,children:m}),e[17]=u,e[18]=m,e[19]=x):x=e[19];let b;return e[20]!==p||e[21]!==x?(b=t.jsx("div",{className:p,children:x}),e[20]=p,e[21]=x,e[22]=b):b=e[22],b}function Zn(a,e){return t.jsx("tr",{className:ne(e===0&&"bg-muted/50 font-medium"),children:a.map(el)},e)}function el(a,e){return t.jsx("td",{className:"max-w-[56px] overflow-hidden border border-border/30 px-1 py-px text-[7px] leading-[1.4] text-muted-foreground",style:{maxWidth:56},children:t.jsx("span",{className:"block truncate",children:a})},e)}function tl(a){return a.trim().replace(/^"|"$/g,"")}function sl(a){const e=L.c(12),{url:s,filename:n}=a,[r,l]=Y.useState(!1);let i;e[0]!==n||e[1]!==r?(i=!r&&t.jsx(Be,{filename:n}),e[0]=n,e[1]=r,e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=()=>l(!0),e[3]=o):o=e[3];const d=r?"opacity-100":"opacity-0";let c;e[4]!==d?(c=ne("absolute top-0 left-0 h-[400%] w-[400%] origin-top-left scale-25 border-0 bg-white transition-opacity duration-300",d),e[4]=d,e[5]=c):c=e[5];let u;e[6]!==c||e[7]!==s?(u=t.jsx("iframe",{src:s,title:"","aria-hidden":!0,tabIndex:-1,sandbox:"allow-scripts",onLoad:o,className:c}),e[6]=c,e[7]=s,e[8]=u):u=e[8];let p;return e[9]!==i||e[10]!==u?(p=t.jsxs("div",{className:"pointer-events-none relative h-full w-full overflow-hidden",children:[i,u]}),e[9]=i,e[10]=u,e[11]=p):p=e[11],p}function nl(a){const e=L.c(26),{filename:s,size:n,downloadUrl:r,compact:l}=a,i=l===void 0?!1:l;let o;if(e[0]!==r||e[1]!==s||e[2]!==n){const p=Kn(s);if(Rn.has(p)){let f;e[4]!==r?(f=t.jsx("img",{src:r,alt:"",loading:"lazy",className:"h-full w-full object-cover"}),e[4]=r,e[5]=f):f=e[5],o=f}else if(_n.has(p)){const f=`${r}#t=0.1`;let m;e[6]!==f?(m=t.jsx(Ce,{children:t.jsx("video",{src:f,preload:"metadata",muted:!0,playsInline:!0,className:"pointer-events-none h-full w-full object-cover"})}),e[6]=f,e[7]=m):m=e[7],o=m}else if(p==="pdf"){let f;e[8]!==s?(f=t.jsx(Be,{filename:s}),e[8]=s,e[9]=f):f=e[9],o=f}else if(Un.has(p))o=t.jsx(Ce,{children:t.jsx(Jn,{url:r,ext:p})});else if(p==="html"||p==="htm"){let f;e[10]!==r||e[11]!==s?(f=t.jsx(Ce,{whileVisible:!0,children:t.jsx(sl,{url:r,filename:s})}),e[10]=r,e[11]=s,e[12]=f):f=e[12],o=f}else if((p==="md"||p==="markdown")&&n<=Ft){let f;e[13]!==r||e[14]!==s?(f=t.jsx(Ce,{children:t.jsx(Wn,{url:r,filename:s})}),e[13]=r,e[14]=s,e[15]=f):f=e[15],o=f}else if(Hn.has(p)&&n<=Ft){let f;e[16]!==r||e[17]!==s?(f=t.jsx(Ce,{children:t.jsx(Qn,{url:r,filename:s})}),e[16]=r,e[17]=s,e[18]=f):f=e[18],o=f}else{let f;e[19]!==s?(f=t.jsx(Be,{filename:s}),e[19]=s,e[20]=f):f=e[20],o=f}e[0]=r,e[1]=s,e[2]=n,e[3]=o}else o=e[3];const d=i?"aspect-[3/1]":"aspect-[400/265]";let c;e[21]!==d?(c=ne("w-full overflow-hidden rounded-lg border border-border/60 bg-muted/30",d),e[21]=d,e[22]=c):c=e[22];let u;return e[23]!==o||e[24]!==c?(u=t.jsx("div",{className:c,children:o}),e[23]=o,e[24]=c,e[25]=u):u=e[25],u}const Yt={location:"hidden w-32 @2xl/library:table-cell",owner:"hidden w-36 @3xl/library:table-cell",size:"hidden w-20 text-right @xl/library:table-cell",updated:"hidden w-24 text-right @md/library:table-cell",menu:"w-10"},Xt=Y.createContext(!1),Qt=Y.createContext(!1),Wt={location:"hidden w-32 @2xl/library:table-cell",owner:"hidden w-36 @xl/library:table-cell",size:"hidden w-20 @lg/library:table-cell",updated:"hidden w-24 @md/library:table-cell",menu:"w-10"};function ll(a){const e=L.c(2),{kind:s}=a,n=s==="folder"?pt:s==="skill"?mt:s==="brand"?Me:Zs;let r;return e[0]!==n?(r=t.jsx(n,{size:16,className:"shrink-0 text-muted-foreground"}),e[0]=n,e[1]=r):r=e[1],r}function rl(a){const e=L.c(5),{kind:s,name:n}=a;if(s==="folder"){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Je,{className:"size-5 shrink-0"}),e[0]=l):l=e[0],l}if(s==="skill"||s==="brand"){const l=s==="skill"?mt:Me;let i;return e[1]!==l?(i=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:t.jsx(l,{size:12})}),e[1]=l,e[2]=i):i=e[2],i}let r;return e[3]!==n?(r=t.jsx(ht,{filename:n,className:"h-5 w-4 shrink-0"}),e[3]=n,e[4]=r):r=e[4],r}function al(a){const e=L.c(18),{userId:s}=a,n=!!s;let r;e[0]!==n?(r={enabled:n},e[0]=n,e[1]=r):r=e[1];const{data:l}=ys(r);let i,o;if(e[2]!==l?.data?.members||e[3]!==s){const x=l?.data?.members??[];i=s?x.find(b=>b.userId===s):void 0,o=i?.user?.name?.trim(),e[2]=l?.data?.members,e[3]=s,e[4]=i,e[5]=o}else i=e[4],o=e[5];const d=o;if(!d)return null;const c=i?.user?.image??void 0;let u;e[6]!==d||e[7]!==c?(u=t.jsx(vs,{url:c,fallback:d,shape:"circle",size:"2xs",className:"shrink-0"}),e[6]=d,e[7]=c,e[8]=u):u=e[8];let p;if(e[9]!==d){let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=/\s+/,e[11]=x):x=e[11],p=d.split(x),e[9]=d,e[10]=p}else p=e[10];let f;e[12]!==p[0]?(f=t.jsx("span",{className:"truncate",children:p[0]}),e[12]=p[0],e[13]=f):f=e[13];let m;return e[14]!==d||e[15]!==u||e[16]!==f?(m=t.jsxs("span",{className:"flex min-w-0 items-center gap-2",title:d,children:[u,f]}),e[14]=d,e[15]=u,e[16]=f,e[17]=m):m=e[17],m}function ct(a){const e=L.c(74),{entry:s,publicState:n,secondary:r,selected:l,actions:i}=a,o=l===void 0?!1:l,d=de();let c;e[0]!==s?(c=Sn(s),e[0]=s,e[1]=c):c=e[1];const u=c,p=Y.use(Xt),f=Y.use(Qt),m=f?Wt:Yt;let x;e[2]!==i||e[3]!==m.location||e[4]!==f||e[5]!==r||e[6]!==p?(x=p&&t.jsx(Ne,{className:ne(m.location,"truncate text-muted-foreground"),title:r,children:r&&i.onOpenSecondary?t.jsx("button",{type:"button",className:"max-w-full truncate hover:text-foreground hover:underline",onClick:ae=>{ae.stopPropagation(),i.onOpenSecondary?.()},children:r}):r&&f?t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(pt,{size:14,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:r})]}):r}),e[2]=i,e[3]=m.location,e[4]=f,e[5]=r,e[6]=p,e[7]=x):x=e[7];const b=x,N=f?"text-foreground":"text-muted-foreground";let j;e[8]!==m.owner||e[9]!==N?(j=ne(m.owner,N),e[8]=m.owner,e[9]=N,e[10]=j):j=e[10];let w;e[11]!==s.entry.createdBy?(w=t.jsx(al,{userId:s.entry.createdBy}),e[11]=s.entry.createdBy,e[12]=w):w=e[12];let k;e[13]!==j||e[14]!==w?(k=t.jsx(Ne,{className:j,children:w}),e[13]=j,e[14]=w,e[15]=k):k=e[15];const $=k;let y;e[16]!==m.size?(y=ne(m.size,"tabular-nums text-muted-foreground"),e[16]=m.size,e[17]=y):y=e[17];const D=u??"";let S;e[18]!==y||e[19]!==D?(S=t.jsx(Ne,{className:y,children:D}),e[18]=y,e[19]=D,e[20]=S):S=e[20];const I=S;let v;e[21]!==m.updated?(v=ne(m.updated,"tabular-nums text-muted-foreground"),e[21]=m.updated,e[22]=v):v=e[22];let z;e[23]!==s.updatedAt?(z=ut(s.updatedAt),e[23]=s.updatedAt,e[24]=z):z=e[24];let V;e[25]!==v||e[26]!==z?(V=t.jsx(Ne,{className:v,children:z}),e[25]=v,e[26]=z,e[27]=V):V=e[27];const T=V,A=o?"selected":void 0,F=i.draggable,B=i.onOpen,M=i.onDragStart,R=i.onContextMenu,C=i.onDrop?il:void 0,U=i.onDrop;let O;e[28]!==s.kind||e[29]!==s.name||e[30]!==f?(O=f?t.jsx(ll,{kind:s.kind}):t.jsx(rl,{kind:s.kind,name:s.name}),e[28]=s.kind,e[29]=s.name,e[30]=f,e[31]=O):O=e[31];const E=f&&"font-medium";let q;e[32]!==E?(q=ne("truncate text-foreground",E),e[32]=E,e[33]=q):q=e[33];let Z;e[34]!==s.name||e[35]!==q?(Z=t.jsx("span",{className:q,title:s.name,children:s.name}),e[34]=s.name,e[35]=q,e[36]=Z):Z=e[36];let _;e[37]!==n||e[38]!==d?(_=n&&t.jsx(Qe,{state:n,t:d}),e[37]=n,e[38]=d,e[39]=_):_=e[39];let ee;e[40]!==O||e[41]!==Z||e[42]!==_?(ee=t.jsx(Ne,{className:"min-w-0 max-w-0 pl-4",children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[O,Z,_]})}),e[40]=O,e[41]=Z,e[42]=_,e[43]=ee):ee=e[43];let H;e[44]!==b||e[45]!==$||e[46]!==f||e[47]!==I||e[48]!==T?(H=f?t.jsxs(t.Fragment,{children:[T,I,$,b]}):t.jsxs(t.Fragment,{children:[b,$,I,T]}),e[44]=b,e[45]=$,e[46]=f,e[47]=I,e[48]=T,e[49]=H):H=e[49];let X;e[50]!==m.menu?(X=ne(m.menu,"pr-2 text-right"),e[50]=m.menu,e[51]=X):X=e[51];let Q;e[52]!==i.download||e[53]!==i.onBrowse||e[54]!==i.onDelete||e[55]!==i.onShare||e[56]!==s.name||e[57]!==d?(Q=t.jsx(bt,{label:s.name,onBrowse:i.onBrowse,onShare:i.onShare,download:i.download,onDelete:i.onDelete,t:d}),e[52]=i.download,e[53]=i.onBrowse,e[54]=i.onDelete,e[55]=i.onShare,e[56]=s.name,e[57]=d,e[58]=Q):Q=e[58];let te;e[59]!==X||e[60]!==Q?(te=t.jsx(Ne,{className:X,children:Q}),e[59]=X,e[60]=Q,e[61]=te):te=e[61];let re;return e[62]!==i.draggable||e[63]!==i.onContextMenu||e[64]!==i.onDragStart||e[65]!==i.onDrop||e[66]!==i.onOpen||e[67]!==o||e[68]!==A||e[69]!==C||e[70]!==ee||e[71]!==H||e[72]!==te?(re=t.jsxs(Ht,{"data-state":A,"aria-selected":o,className:"group/card cursor-pointer hover:bg-accent",draggable:F,onClick:B,onDragStart:M,onContextMenu:R,onDragOver:C,onDrop:U,children:[ee,H,te]}),e[62]=i.draggable,e[63]=i.onContextMenu,e[64]=i.onDragStart,e[65]=i.onDrop,e[66]=i.onOpen,e[67]=o,e[68]=A,e[69]=C,e[70]=ee,e[71]=H,e[72]=te,e[73]=re):re=e[73],re}function il(a){return a.preventDefault()}function st(a){const e=L.c(11),{label:s,active:n,descending:r,className:l,onClick:i}=a,o=r?hn:bn,d=n?"text-foreground":"text-muted-foreground";let c;e[0]!==l||e[1]!==d?(c=ne("flex items-center gap-1 truncate font-medium transition-colors hover:text-foreground",d,l),e[0]=l,e[1]=d,e[2]=c):c=e[2];let u;e[3]!==o||e[4]!==n?(u=n&&t.jsx(o,{size:11,className:"shrink-0"}),e[3]=o,e[4]=n,e[5]=u):u=e[5];let p;return e[6]!==s||e[7]!==i||e[8]!==c||e[9]!==u?(p=t.jsxs("button",{type:"button",onClick:i,className:c,children:[s,u]}),e[6]=s,e[7]=i,e[8]=c,e[9]=u,e[10]=p):p=e[10],p}function Jt(a){const e=L.c(67),{sort:s,onSort:n,locationLabel:r,plain:l,children:i}=a,o=l===void 0?!1:l,d=de(),c=o?Wt:Yt,u=o?"font-normal":"ml-auto";let p;e[0]!==c.location||e[1]!==r?(p=r&&t.jsx(Se,{className:c.location,children:r}),e[0]=c.location,e[1]=r,e[2]=p):p=e[2];const f=p,m=c.owner;let x;e[3]!==d?(x=d("library.entries.createdBy"),e[3]=d,e[4]=x):x=e[4];let b;e[5]!==c.owner||e[6]!==x?(b=t.jsx(Se,{className:m,children:x}),e[5]=c.owner,e[6]=x,e[7]=b):b=e[7];const N=b,j=c.size;let w;e[8]!==d?(w=d("library.entries.size"),e[8]=d,e[9]=w):w=e[9];const k=s==="size";let $;e[10]!==n?($=()=>n("size"),e[10]=n,e[11]=$):$=e[11];let y;e[12]!==u||e[13]!==w||e[14]!==k||e[15]!==$?(y=t.jsx(st,{label:w,active:k,descending:!0,className:u,onClick:$}),e[12]=u,e[13]=w,e[14]=k,e[15]=$,e[16]=y):y=e[16];let D;e[17]!==c.size||e[18]!==y?(D=t.jsx(Se,{className:j,children:y}),e[17]=c.size,e[18]=y,e[19]=D):D=e[19];const S=D,I=c.updated;let v;e[20]!==d?(v=d("library.library.updated"),e[20]=d,e[21]=v):v=e[21];const z=s==="updated";let V;e[22]!==n?(V=()=>n("updated"),e[22]=n,e[23]=V):V=e[23];let T;e[24]!==u||e[25]!==v||e[26]!==z||e[27]!==V?(T=t.jsx(st,{label:v,active:z,descending:!0,className:u,onClick:V}),e[24]=u,e[25]=v,e[26]=z,e[27]=V,e[28]=T):T=e[28];let A;e[29]!==c.updated||e[30]!==T?(A=t.jsx(Se,{className:I,children:T}),e[29]=c.updated,e[30]=T,e[31]=A):A=e[31];const F=A,B=o&&"table-fixed";let M;e[32]!==B?(M=ne(B),e[32]=B,e[33]=M):M=e[33];let R;e[34]!==d?(R=d("library.library.name"),e[34]=d,e[35]=R):R=e[35];const C=s==="name",U=o&&"font-normal";let O;e[36]!==U?(O=ne(U),e[36]=U,e[37]=O):O=e[37];let E;e[38]!==n?(E=()=>n("name"),e[38]=n,e[39]=E):E=e[39];let q;e[40]!==R||e[41]!==C||e[42]!==O||e[43]!==E?(q=t.jsx(Se,{className:"pl-4",children:t.jsx(st,{label:R,active:C,className:O,onClick:E})}),e[40]=R,e[41]=C,e[42]=O,e[43]=E,e[44]=q):q=e[44];let Z;e[45]!==f||e[46]!==N||e[47]!==o||e[48]!==S||e[49]!==F?(Z=o?t.jsxs(t.Fragment,{children:[F,S,N,f]}):t.jsxs(t.Fragment,{children:[f,N,S,F]}),e[45]=f,e[46]=N,e[47]=o,e[48]=S,e[49]=F,e[50]=Z):Z=e[50];let _;e[51]!==c.menu?(_=t.jsx(Se,{className:c.menu}),e[51]=c.menu,e[52]=_):_=e[52];let ee;e[53]!==q||e[54]!==Z||e[55]!==_?(ee=t.jsx(xn,{children:t.jsxs(Ht,{children:[q,Z,_]})}),e[53]=q,e[54]=Z,e[55]=_,e[56]=ee):ee=e[56];const H=!!r;let X;e[57]!==i||e[58]!==H?(X=t.jsx(Xt,{value:H,children:i}),e[57]=i,e[58]=H,e[59]=X):X=e[59];let Q;e[60]!==o||e[61]!==X?(Q=t.jsx(gn,{children:t.jsx(Qt,{value:o,children:X})}),e[60]=o,e[61]=X,e[62]=Q):Q=e[62];let te;return e[63]!==M||e[64]!==ee||e[65]!==Q?(te=t.jsx("div",{className:"@container/library min-w-0",children:t.jsxs(yn,{className:M,children:[ee,Q]})}),e[63]=M,e[64]=ee,e[65]=Q,e[66]=te):te=e[66],te}const Zt=24;function ol(a){return a?a<=2?1:a<=8?2:3:0}function Fe(a){const e=L.c(44),{name:s,meta:n,icon:r,glyph:l,tone:i,readOnly:o,overlay:d,badge:c,counts:u,onOpen:p,onBrowse:f,onShare:m,onDelete:x,draggable:b,onDragStart:N,onContextMenu:j,onDrop:w}=a,k=de(),$=!!u&&u.enabled;let y;e[0]!==$?(y={enabled:$},e[0]=$,e[1]=y):y=e[1];const D=We(u?.volume??"",u?.path??"",y),S=u?D.data?.length:void 0;let I;e[2]!==S||e[3]!==n||e[4]!==k?(I=n??(S===void 0?void 0:S===0?k("library.entries.emptyFolder"):S===1?k("library.entries.itemCount"):k("library.entries.itemsCount",{count:S})),e[2]=S,e[3]=n,e[4]=k,e[5]=I):I=e[5];const v=I;let z;e[6]!==p?(z=O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),p())},e[6]=p,e[7]=z):z=e[7];const V=w?cl:void 0;let T;e[8]!==S||e[9]!==l||e[10]!==r||e[11]!==o||e[12]!==i?(T=r??t.jsx(Je,{glyph:l,tone:i,readOnly:o,sheets:ol(S),className:"size-6"}),e[8]=S,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=T):T=e[13];let A;e[14]!==d?(A=d&&t.jsx("span",{className:"absolute -right-1.5 -bottom-1 flex rounded-lg ring-2 ring-card",children:d}),e[14]=d,e[15]=A):A=e[15];let F;e[16]!==T||e[17]!==A?(F=t.jsxs("span",{className:"relative flex shrink-0",children:[T,A]}),e[16]=T,e[17]=A,e[18]=F):F=e[18];let B;e[19]!==s?(B=t.jsx("span",{className:"truncate text-sm font-medium text-foreground",title:s,children:s}),e[19]=s,e[20]=B):B=e[20];let M;e[21]!==c||e[22]!==B?(M=t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[B,c]}),e[21]=c,e[22]=B,e[23]=M):M=e[23];let R;e[24]!==v?(R=v&&t.jsx("span",{className:"text-meta shrink-0 group-hover/card:hidden group-has-[[data-state=open]]/card:hidden",children:v}),e[24]=v,e[25]=R):R=e[25];let C;e[26]!==s||e[27]!==f||e[28]!==x||e[29]!==m||e[30]!==k?(C=t.jsx(bt,{label:s,onBrowse:f,onShare:m,onDelete:x,t:k}),e[26]=s,e[27]=f,e[28]=x,e[29]=m,e[30]=k,e[31]=C):C=e[31];let U;return e[32]!==b||e[33]!==j||e[34]!==N||e[35]!==w||e[36]!==p||e[37]!==M||e[38]!==R||e[39]!==C||e[40]!==z||e[41]!==V||e[42]!==F?(U=t.jsxs("div",{role:"button",tabIndex:0,draggable:b,onClick:p,onKeyDown:z,onDragStart:N,onContextMenu:j,onDragOver:V,onDrop:w,className:"group/card surface surface-interactive focus-ring relative flex h-12 min-w-0 cursor-pointer items-center gap-2.5 pr-1.5 pl-3",children:[F,M,R,C]}),e[32]=b,e[33]=j,e[34]=N,e[35]=w,e[36]=p,e[37]=M,e[38]=R,e[39]=C,e[40]=z,e[41]=V,e[42]=F,e[43]=U):U=e[43],U}function cl(a){return a.preventDefault()}function xt(a){const e=L.c(2),{children:s}=a;let n;return e[0]!==s?(n=t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-2",children:s}),e[0]=s,e[1]=n):n=e[1],n}function dl(a){return`${a.volume}/${At(a.path)}`}function ul(a,e){const s=new Map;for(const n of a){if(!ot(n.path,"documents")&&!ot(n.path,"media"))continue;const r=dl(n),l=s.get(r);l?l.more+=1:s.set(r,{entry:n,more:0})}return[...s.values()].slice(0,e)}function gt(a){return`${window.location.origin}${a}`}function we(a){if(a.shareMode==="password")return"password";if(a.shareMode==="public"||a.readPublic)return"public";if(a.effectivePublic)return"inherited"}const es=["uploads","outputs"],dt=new Set([...es,ze,Ye("public")]),fl=4;function yt(a,e,s){const n=At(e);if(n)return Ye(le(n));const r=Lt(a);return r||(a===ye?ft(s):a)}function De(a,e,s){return{onDragStart:n=>{s.onDragStart?.(a),n.dataTransfer.effectAllowed="move",n.dataTransfer.setData("application/x-studio-library-path",a)},onContextMenu:n=>{n.preventDefault(),s.onContextMenu?.(a,e)},onDrop:s.onDrop?n=>{n.preventDefault();const r=n.dataTransfer.getData("application/x-studio-library-path");r&&r!==a&&!a.startsWith(r+"/")&&s.onDrop(r,a)}:void 0}}function Ae(a,e){return ot(a.path,e.fileView)&&Vn(a.updatedAt,e.modified)}function pl(a){const e=L.c(8),{label:s,count:n,action:r}=a;let l;e[0]!==n?(l=n!==void 0&&n>0&&t.jsx("span",{className:"text-meta",children:n}),e[0]=n,e[1]=l):l=e[1];let i;e[2]!==s||e[3]!==l?(i=t.jsxs("h2",{className:"flex items-baseline gap-2 text-sm font-medium text-foreground",children:[s,l]}),e[2]=s,e[3]=l,e[4]=i):i=e[4];let o;return e[5]!==r||e[6]!==i?(o=t.jsxs("div",{className:"flex h-7 items-center justify-between gap-3",children:[i,r]}),e[5]=r,e[6]=i,e[7]=o):o=e[7],o}function Ve(a){const e=L.c(7),{label:s,count:n,action:r,children:l}=a;let i;e[0]!==r||e[1]!==n||e[2]!==s?(i=t.jsx(pl,{label:s,count:n,action:r}),e[0]=r,e[1]=n,e[2]=s,e[3]=i):i=e[3];let o;return e[4]!==l||e[5]!==i?(o=t.jsxs("section",{className:"flex flex-col gap-3",children:[i,l]}),e[4]=l,e[5]=i,e[6]=o):o=e[6],o}function ts(a){const e=L.c(2),{children:s}=a;let n;return e[0]!==s?(n=t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 gap-3 @[440px]:grid-cols-2 @[660px]:grid-cols-3 @[980px]:grid-cols-4",children:s})}),e[0]=s,e[1]=n):n=e[1],n}function ml(a){const e=L.c(2),{rows:s}=a,n=s===void 0?1:s;let r;return e[0]!==n?(r=t.jsx(ts,{children:Array.from({length:n*3},hl)}),e[0]=n,e[1]=r):r=e[1],r}function hl(a,e){return t.jsx(ge,{className:"h-16 rounded-2xl"},e)}function bl(a){const e=L.c(2),{rows:s}=a,n=s===void 0?6:s;let r;return e[0]!==n?(r=t.jsx("div",{className:"flex flex-col gap-px",children:Array.from({length:n},xl)}),e[0]=n,e[1]=r):r=e[1],r}function xl(a,e){return t.jsx(ge,{className:"h-11 rounded-lg"},e)}function Ze(a){const e=L.c(2),{layout:s}=a;let n;return e[0]!==s?(n=s==="grid"?t.jsx(ml,{rows:2}):t.jsx(bl,{}),e[0]=s,e[1]=n):n=e[1],n}function vt(a){const e=L.c(2),{children:s}=a;let n;return e[0]!==s?(n=t.jsx("p",{className:"text-sm text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function wt(a){const e=L.c(24),{entry:s,view:n,secondary:r,publicState:l,downloadUrl:i,selected:o,actions:d}=a;if(n.layout==="list"){let b;return e[0]!==d||e[1]!==s||e[2]!==l||e[3]!==r||e[4]!==o?(b=t.jsx(ct,{entry:s,selected:o,secondary:r,publicState:l,actions:d}),e[0]=d,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=b):b=e[5],b}const c=s.size,u=s.name;let p;e[6]!==s.name||e[7]!==r?(p=r??un(s.name),e[6]=s.name,e[7]=r,e[8]=p):p=e[8];let f;e[9]!==s.updatedAt?(f=ut(s.updatedAt),e[9]=s.updatedAt,e[10]=f):f=e[10];const m=`${p} · ${f}`;let x;return e[11]!==d.draggable||e[12]!==d.onContextMenu||e[13]!==d.onDelete||e[14]!==d.onDragStart||e[15]!==d.onOpen||e[16]!==d.onShare||e[17]!==i||e[18]!==s.name||e[19]!==s.size||e[20]!==l||e[21]!==o||e[22]!==m?(x=t.jsx(Gt,{size:c,filename:u,downloadUrl:i,subtitle:m,publicState:l,selected:o,onOpen:d.onOpen,onShare:d.onShare,onDelete:d.onDelete,draggable:d.draggable,onDragStart:d.onDragStart,onContextMenu:d.onContextMenu}),e[11]=d.draggable,e[12]=d.onContextMenu,e[13]=d.onDelete,e[14]=d.onDragStart,e[15]=d.onOpen,e[16]=d.onShare,e[17]=i,e[18]=s.name,e[19]=s.size,e[20]=l,e[21]=o,e[22]=m,e[23]=x):x=e[23],x}function jt(a){const e=L.c(17),{view:s,count:n,label:r,locationLabel:l,note:i,children:o}=a,d=de();let c;e[0]!==r||e[1]!==d?(c=r??d("library.libraryViews.files"),e[0]=r,e[1]=d,e[2]=c):c=e[2];let u;e[3]!==i?(u=i&&t.jsx("span",{className:"text-meta",children:i}),e[3]=i,e[4]=u):u=e[4];let p;e[5]!==o||e[6]!==l||e[7]!==s.flat||e[8]!==s.layout||e[9]!==s.onSort||e[10]!==s.sort?(p=s.layout==="grid"?t.jsx(ts,{children:o}):t.jsx(Jt,{sort:s.sort,onSort:s.onSort,locationLabel:l,plain:s.flat,children:o}),e[5]=o,e[6]=l,e[7]=s.flat,e[8]=s.layout,e[9]=s.onSort,e[10]=s.sort,e[11]=p):p=e[11];let f;return e[12]!==n||e[13]!==c||e[14]!==u||e[15]!==p?(f=t.jsx(Ve,{label:c,count:n,action:u,children:p}),e[12]=n,e[13]=c,e[14]=u,e[15]=p,e[16]=f):f=e[16],f}function zt(a){const e=L.c(2),{Glyph:s}=a;let n;return e[0]!==s?(n=t.jsx("span",{className:"flex size-6 items-center justify-center rounded-md bg-primary/10 text-primary",children:t.jsx(s,{className:"size-3.5"})}),e[0]=s,e[1]=n):n=e[1],n}function gl(){const a=L.c(2),e=dn();let s;if(a[0]!==e){s=new Map;for(const n of vn(e))s.set(Bs(n),n);a[0]=e,a[1]=s}else s=a[1];return s}function yl(a){const e=L.c(54),{query:s,scope:n,stale:r,view:l,onOpenFile:i,onShare:o,onDelete:d}=a,c=de(),{org:u}=Le(),p=Ie(),f=Us(s,n);let m;e[0]!==p||e[1]!==o?(m=v=>o({volume:v.volume,path:v.path,kind:"file",shareMode:v.shareMode??"private",effectivePublic:v.effectivePublic??!1,url:gt(p(v.volume,v.path))}),e[0]=p,e[1]=o,e[2]=m):m=e[2];const x=m;if(f.isPending){let v;return e[3]!==l.layout?(v=t.jsx(Ze,{layout:l.layout}),e[3]=l.layout,e[4]=v):v=e[4],v}let b,N,j,w,k,$,y,D;if(e[5]!==p||e[6]!==d||e[7]!==i||e[8]!==u||e[9]!==s||e[10]!==f.data||e[11]!==f.isPlaceholderData||e[12]!==x||e[13]!==r||e[14]!==c||e[15]!==l){D=Symbol.for("react.early_return_sentinel");e:{let v;e[24]!==l?(v=F=>Ae(F,l),e[24]=l,e[25]=v):v=e[25];const z=(f.data??[]).filter(v);if(z.length===0){let F;e[26]!==s||e[27]!==c?(F=c("library.libraryViews.noFilesMatch",{query:s}),e[26]=s,e[27]=c,e[28]=F):F=e[28];let B;e[29]!==F?(B=t.jsx(vt,{children:F}),e[29]=F,e[30]=B):B=e[30],D=B;break e}const V=Xe(z.map(Te),l.sort).map(F=>({item:F,hit:z.find(B=>B.path===F.path)})),T=(r||f.isPlaceholderData)&&"opacity-50";e[31]!==T?(y=ne(T),e[31]=T,e[32]=y):y=e[32],b=jt,N=l,e[33]!==c?(j=c("library.libraryViews.results"),e[33]=c,e[34]=j):j=e[34],e[35]!==c?(w=c("library.entries.location"),e[35]=c,e[36]=w):w=e[36],k=z.length;let A;e[37]!==p||e[38]!==d||e[39]!==i||e[40]!==u||e[41]!==x||e[42]!==l?(A=F=>{const{item:B,hit:M}=F,R=Lt(M.volume)!==null,C=p(M.volume,M.path),U=Ee(M.volume,M.path);return t.jsx(wt,{entry:B,view:l,selected:l.previewPath===U,secondary:yt(M.volume,M.path,u.slug),publicState:we(M),downloadUrl:C,actions:{onOpen:()=>i(U),download:{url:C,filename:B.name},onShare:R?void 0:()=>x(M),onDelete:R?void 0:()=>d({volume:M.volume,path:M.path,kind:"file"})}},`${M.volume}/${M.path}`)},e[37]=p,e[38]=d,e[39]=i,e[40]=u,e[41]=x,e[42]=l,e[43]=A):A=e[43],$=V.map(A)}e[5]=p,e[6]=d,e[7]=i,e[8]=u,e[9]=s,e[10]=f.data,e[11]=f.isPlaceholderData,e[12]=x,e[13]=r,e[14]=c,e[15]=l,e[16]=b,e[17]=N,e[18]=j,e[19]=w,e[20]=k,e[21]=$,e[22]=y,e[23]=D}else b=e[16],N=e[17],j=e[18],w=e[19],k=e[20],$=e[21],y=e[22],D=e[23];if(D!==Symbol.for("react.early_return_sentinel"))return D;let S;e[44]!==b||e[45]!==N||e[46]!==j||e[47]!==w||e[48]!==k||e[49]!==$?(S=t.jsx(b,{view:N,label:j,locationLabel:w,count:k,children:$}),e[44]=b,e[45]=N,e[46]=j,e[47]=w,e[48]=k,e[49]=$,e[50]=S):S=e[50];let I;return e[51]!==y||e[52]!==S?(I=t.jsx("div",{className:y,children:S}),e[51]=y,e[52]=S,e[53]=I):I=e[53],I}function vl(a){const e=L.c(34),{view:s,onOpenFile:n}=a,r=de(),{org:l}=Le(),i=Vt(),o=Ie();if(i.isPending)return null;let d,c,u,p,f,m;if(e[0]!==o||e[1]!==n||e[2]!==l||e[3]!==i.data||e[4]!==r||e[5]!==s){m=Symbol.for("react.early_return_sentinel");e:{let j;e[12]!==s?(j=D=>Ae(D,s),e[12]=s,e[13]=j):j=e[13];const w=ul((i.data??[]).filter(j),fl);if(w.length===0){m=null;break e}let k;e[14]!==l||e[15]!==r?(k=(D,S)=>[yt(D.volume,D.path,l.slug),ut(D.updatedAt),S>0&&r("library.libraryViews.moreInFolder",{count:S})].filter(Boolean).join(" · "),e[14]=l,e[15]=r,e[16]=k):k=e[16];const $=k;d=Ve,e[17]!==r?(f=r("library.libraryViews.recent"),e[17]=r,e[18]=f):f=e[18],p="@container",c="grid grid-cols-2 gap-3 @[720px]:grid-cols-4";let y;e[19]!==$||e[20]!==o||e[21]!==n||e[22]!==s?(y=D=>{const{entry:S,more:I}=D,v=Ee(S.volume,S.path),z=le(S.path);return t.jsx(Gt,{size:S.size,filename:z,downloadUrl:o(S.volume,S.path),subtitle:$(S,I),publicState:we(S),selected:s.previewPath===v,compact:!0,onOpen:()=>n(v)},`${S.volume}/${S.path}`)},e[19]=$,e[20]=o,e[21]=n,e[22]=s,e[23]=y):y=e[23],u=w.map(y)}e[0]=o,e[1]=n,e[2]=l,e[3]=i.data,e[4]=r,e[5]=s,e[6]=d,e[7]=c,e[8]=u,e[9]=p,e[10]=f,e[11]=m}else d=e[6],c=e[7],u=e[8],p=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;let x;e[24]!==c||e[25]!==u?(x=t.jsx("div",{className:c,children:u}),e[24]=c,e[25]=u,e[26]=x):x=e[26];let b;e[27]!==p||e[28]!==x?(b=t.jsx("div",{className:p,children:x}),e[27]=p,e[28]=x,e[29]=b):b=e[29];let N;return e[30]!==d||e[31]!==f||e[32]!==b?(N=t.jsx(d,{label:f,children:b}),e[30]=d,e[31]=f,e[32]=b,e[33]=N):N=e[33],N}const wl=new Set(es);function Et(a){return a!==null&&wl.has(a)}function jl(a){const e=L.c(52),{volume:s,view:n,onOpenDir:r,onOpenFile:l,onShare:i,onDelete:o,emptyActions:d}=a,c=de(),u=Ie(),p=_s(s),f=We(s,""),{navigateToTask:m}=Es();if(p.isPending||f.isPending){let v;return e[0]!==n.layout?(v=t.jsx(Ze,{layout:n.layout}),e[0]=n.layout,e[1]=v):v=e[1],v}const x=p.error??f.error;if(x){let v;e[2]!==x||e[3]!==c?(v=x instanceof Error?x.message:c("library.libraryViews.failedToLoad"),e[2]=x,e[3]=c,e[4]=v):v=e[4];let z;return e[5]!==v?(z=t.jsx("p",{className:"text-sm text-destructive",children:v}),e[5]=v,e[6]=z):z=e[6],z}let b,N,j,w,k,$,y;if(e[7]!==d||e[8]!==u||e[9]!==m||e[10]!==o||e[11]!==r||e[12]!==l||e[13]!==i||e[14]!==f.data||e[15]!==c||e[16]!==n||e[17]!==s||e[18]!==p.data?.pages){y=Symbol.for("react.early_return_sentinel");e:{const v=p.data?.pages??[],z=v.flatMap(Sl),V=Object.assign({},...v.map(Nl)),T=new Map(z.map(C=>[C.path,C.sourceThreadId?{id:C.sourceThreadId,...V[C.sourceThreadId]}:void 0]));let A;e[26]!==n?(A=C=>Ae(C,n),e[26]=n,e[27]=A):A=e[27];const F=z.filter(A),B=(f.data??[]).filter(kl);if(F.length===0&&B.length===0){let C;e[28]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Je,{className:"size-16"}),e[28]=C):C=e[28];let U;e[29]!==c?(U=c("library.libraryViews.emptyFolder"),e[29]=c,e[30]=U):U=e[30];let O;e[31]!==c?(O=c("library.libraryViews.emptyFolderHint"),e[31]=c,e[32]=O):O=e[32];let E;e[33]!==d||e[34]!==O||e[35]!==U?(E=t.jsx("div",{className:"rounded-2xl border border-dashed border-border",children:t.jsx(_t,{illustration:C,title:U,description:O,buttonComponent:d})}),e[33]=d,e[34]=O,e[35]=U,e[36]=E):E=e[36],y=E;break e}const M=B.length>0&&t.jsx(Ve,{label:c("library.libraryViews.folders"),count:B.length,children:t.jsx(xt,{children:B.map((C,U)=>t.jsx(Fe,{name:le(C.path),counts:{volume:s,path:C.path,enabled:U<Zt},onOpen:()=>r(Ee(s,C.path)),onDelete:()=>o({volume:s,path:C.path,kind:"dir"})},C.path))})});if(F.length===0){y=M;break e}const R=Xe(F.map(Te),n.sort);$=M,b=jt,N=n,j=F.length,e[37]!==c?(w=c("library.libraryViews.sourceChat"),e[37]=c,e[38]=w):w=e[38],k=R.map(C=>{const U=Ee(s,C.path),O=u(s,C.path),E=T.get(C.path);return t.jsx(wt,{entry:C,view:n,secondary:E?.title,selected:n.previewPath===U,publicState:we(C.entry),downloadUrl:O,actions:{onOpen:()=>l(U),onOpenSecondary:E?.agentId!==void 0?()=>m(E.id,{virtualMcpId:E.agentId}):void 0,download:{url:O,filename:C.name},onShare:()=>i({volume:s,path:C.path,kind:"file",shareMode:C.entry.shareMode??"private",effectivePublic:C.entry.effectivePublic??!1,url:gt(O)}),onDelete:()=>o({volume:s,path:C.path,kind:"file"})}},C.path)})}e[7]=d,e[8]=u,e[9]=m,e[10]=o,e[11]=r,e[12]=l,e[13]=i,e[14]=f.data,e[15]=c,e[16]=n,e[17]=s,e[18]=p.data?.pages,e[19]=b,e[20]=N,e[21]=j,e[22]=w,e[23]=k,e[24]=$,e[25]=y}else b=e[19],N=e[20],j=e[21],w=e[22],k=e[23],$=e[24],y=e[25];if(y!==Symbol.for("react.early_return_sentinel"))return y;let D;e[39]!==b||e[40]!==N||e[41]!==j||e[42]!==w||e[43]!==k?(D=t.jsx(b,{view:N,count:j,locationLabel:w,children:k}),e[39]=b,e[40]=N,e[41]=j,e[42]=w,e[43]=k,e[44]=D):D=e[44];let S;e[45]!==c||e[46]!==p?(S=p.hasNextPage&&t.jsx(ce,{variant:"outline",className:"self-center",disabled:p.isFetchingNextPage,onClick:()=>{p.fetchNextPage()},children:c("library.libraryViews.loadMore")}),e[45]=c,e[46]=p,e[47]=S):S=e[47];let I;return e[48]!==$||e[49]!==D||e[50]!==S?(I=t.jsxs(t.Fragment,{children:[$,D,S]}),e[48]=$,e[49]=D,e[50]=S,e[51]=I):I=e[51],I}function kl(a){return a.kind==="dir"&&!Ms(le(a.path))}function Nl(a){return a.threads}function Sl(a){return a.entries}function Pl(a){const e=L.c(21),{view:s,onOpenDir:n}=a,r=de(),l=It();if(l.isPending){let m;return e[0]!==s.layout?(m=t.jsx(Ze,{layout:s.layout}),e[0]=s.layout,e[1]=m):m=e[1],m}let i;e[2]!==l.data?(i=l.data??[],e[2]=l.data,e[3]=i):i=e[3];const o=i;if(o.length===0){let m;e[4]!==r?(m=r("library.libraryViews.noPublicSkillSetsConfigured"),e[4]=r,e[5]=m):m=e[5];let x;return e[6]!==m?(x=t.jsx(vt,{children:m}),e[6]=m,e[7]=x):x=e[7],x}let d;e[8]!==r?(d=r("library.libraryViews.folders"),e[8]=r,e[9]=d):d=e[9];const c=o.length;let u;if(e[10]!==n||e[11]!==o){let m;e[13]!==n?(m=x=>t.jsx(Fe,{name:x,readOnly:!0,counts:{volume:`public-${x}`,path:"",enabled:!0},onOpen:()=>n(`public/${x}`)},x),e[13]=n,e[14]=m):m=e[14],u=o.map(m),e[10]=n,e[11]=o,e[12]=u}else u=e[12];let p;e[15]!==u?(p=t.jsx(xt,{children:u}),e[15]=u,e[16]=p):p=e[16];let f;return e[17]!==o.length||e[18]!==d||e[19]!==p?(f=t.jsx(Ve,{label:d,count:c,children:p}),e[17]=o.length,e[18]=d,e[19]=p,e[20]=f):f=e[20],f}function Cl(a){const e=L.c(86),{location:s,root:n,onOpenDir:r,view:l,onOpenFile:i,onOpenSkill:o,onOpenBrand:d,onShare:c,onDelete:u,onDragStart:p,onContextMenu:f,onMove:m,emptyActions:x}=a,b=de(),{org:N}=Le(),j=s.volume??"",w=We(j,s.dirPath),k=Ie(),$=gl(),y=s.isHomeRoot&&n===ye,D=j===ye&&s.dirPath===ze;let S;e[0]!==y||e[1]!==N?(S=O=>y&&dt.has(O.toLowerCase())?`${ft(N.slug)}/${O}`:void 0,e[0]=y,e[1]=N,e[2]=S):S=e[2];const I=S,v=y&&!!l.flat;let z;e[3]!==v?(z={enabled:v},e[3]=v,e[4]=z):z=e[4];const V=Vt(void 0,z);let T;e[5]!==v||e[6]!==y||e[7]!==i||e[8]!==l?(T=y&&!v?t.jsx(vl,{view:l,onOpenFile:i}):null,e[5]=v,e[6]=y,e[7]=i,e[8]=l,e[9]=T):T=e[9];const A=T;if(w.isPending){let O;e[10]!==l.layout?(O=t.jsx(Ze,{layout:l.layout}),e[10]=l.layout,e[11]=O):O=e[11];let E;return e[12]!==A||e[13]!==O?(E=t.jsxs(t.Fragment,{children:[A,O]}),e[12]=A,e[13]=O,e[14]=E):E=e[14],E}if(w.isError){let O;e[15]!==w.error||e[16]!==b?(O=w.error instanceof Error?w.error.message:b("library.libraryViews.failedToLoad"),e[15]=w.error,e[16]=b,e[17]=O):O=e[17];let E;return e[18]!==O?(E=t.jsx("p",{className:"text-sm text-destructive",children:O}),e[18]=O,e[19]=E):E=e[19],E}let F,B,M,R;if(e[20]!==I||e[21]!==x||e[22]!==k||e[23]!==v||e[24]!==D||e[25]!==y||e[26]!==w.data||e[27]!==s||e[28]!==f||e[29]!==u||e[30]!==p||e[31]!==m||e[32]!==d||e[33]!==r||e[34]!==i||e[35]!==o||e[36]!==c||e[37]!==N||e[38]!==$||e[39]!==A||e[40]!==V||e[41]!==b||e[42]!==l||e[43]!==j){R=Symbol.for("react.early_return_sentinel");e:{const O=w.data??[];let E;e[48]!==y?(E=h=>!(y&&h.kind==="dir"&&le(h.path)===ze),e[48]=y,e[49]=E):E=e[49];const q=O.filter(E);if(q.length===0&&!y){let h;e[50]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Je,{className:"size-16"}),e[50]=h):h=e[50];let K;e[51]!==b?(K=b("library.libraryViews.emptyFolder"),e[51]=b,e[52]=K):K=e[52];const W=s.readOnly?"library.libraryViews.emptyReadOnlySet":"library.libraryViews.emptyFolderHint";let se;e[53]!==b||e[54]!==W?(se=b(W),e[53]=b,e[54]=W,e[55]=se):se=e[55];const fe=s.readOnly?void 0:x;let me;e[56]!==se||e[57]!==fe||e[58]!==K?(me=t.jsx("div",{className:"rounded-2xl border border-dashed border-border",children:t.jsx(_t,{illustration:h,title:K,description:se,buttonComponent:fe})}),e[56]=se,e[57]=fe,e[58]=K,e[59]=me):me=e[59],R=me;break e}let Z;e[60]!==s.readOnly||e[61]!==u||e[62]!==j?(Z=h=>s.readOnly?void 0:()=>u({volume:j,path:h.path,kind:h.kind}),e[60]=s.readOnly,e[61]=u,e[62]=j,e[63]=Z):Z=e[63];const _=Z;let ee;e[64]!==k||e[65]!==s.readOnly||e[66]!==c||e[67]!==j?(ee=h=>s.readOnly?void 0:()=>c({volume:j,path:h.path,kind:h.kind,shareMode:h.shareMode??"private",effectivePublic:h.effectivePublic??!1,url:h.kind==="file"?gt(k(j,h.path)):void 0}),e[64]=k,e[65]=s.readOnly,e[66]=c,e[67]=j,e[68]=ee):ee=e[68];const H=ee,X=q.filter($l),Q=q.filter(Ol),te=q.filter(Dl);let re;e[69]!==l?(re=h=>h.kind==="file"&&Ae(h,l),e[69]=l,e[70]=re):re=e[70],F=q.filter(re);const ae=Xe(F.map(Te),l.sort),he=Xe([...X,...Q,...te,...F].map(Te),l.sort);let pe;e[71]!==s||e[72]!==d||e[73]!==r||e[74]!==i||e[75]!==o?(pe=h=>{const K=xe(s,h.path);switch(h.kind){case"folder":return()=>r(K);case"skill":return()=>o(K);case"brand":return()=>d(K);case"file":return()=>i(K);default:return h.kind}},e[71]=s,e[72]=d,e[73]=r,e[74]=i,e[75]=o,e[76]=pe):pe=e[76];const be=pe,ie=v?(V.data??[]).filter(h=>Ae(h,l)&&!(h.volume===ye&&!h.path.includes("/"))):[],ve=he.length+ie.length>0&&t.jsxs(Jt,{sort:l.sort,onSort:l.onSort,locationLabel:v?b("library.entries.location"):void 0,plain:l.flat,children:[he.map(h=>{const K=xe(s,h.path),W=D?$.get(h.name):void 0,se=h.kind==="skill"||h.kind==="brand";return t.jsx(ct,{entry:W?.title?{...h,name:W.title}:h,selected:h.kind==="file"&&l.previewPath===K,publicState:we(h.entry),actions:{onOpen:be(h),onBrowse:se?()=>r(K):void 0,download:h.kind==="file"?{url:k(j,h.path),filename:h.name}:void 0,onShare:h.kind==="brand"?void 0:H(h.entry),onDelete:_(h.entry),draggable:!s.readOnly,...De(h.path,h.kind==="file"?"file":"dir",{onDragStart:p,onContextMenu:f,onDrop:h.kind==="folder"?m:void 0})}},h.path)}),ie.map(h=>{const K=Ee(h.volume,h.path),W=Te(h);return t.jsx(ct,{entry:W,secondary:yt(h.volume,h.path,N.slug),selected:l.previewPath===K,publicState:we(h),actions:{onOpen:()=>i(K),download:{url:k(h.volume,h.path),filename:W.name},onDelete:()=>u({volume:h.volume,path:h.path,kind:"file"})}},`${h.volume}/${h.path}`)})]});B=A,M=l.layout==="list"?ve:t.jsxs(t.Fragment,{children:[te.length+X.length+Q.length>0&&t.jsx(Ve,{label:b("library.libraryViews.folders"),count:te.length+X.length+Q.length,children:t.jsxs(xt,{children:[X.map(h=>{const K=we(h);return t.jsx(Fe,{name:le(h.path),meta:b("library.cards.skill"),icon:t.jsx(zt,{Glyph:mt}),badge:K&&t.jsx(Qe,{state:K,t:b}),onOpen:()=>o(xe(s,h.path)),onBrowse:()=>r(xe(s,h.path)),onShare:H(h),onDelete:_(h),draggable:!s.readOnly,...De(h.path,"dir",{onDragStart:p,onContextMenu:f})},h.path)}),Q.map(h=>t.jsx(Fe,{name:le(h.path),meta:b("library.cards.brand"),icon:t.jsx(zt,{Glyph:Me}),onOpen:()=>d(xe(s,h.path)),onBrowse:()=>r(xe(s,h.path)),onDelete:_(h),draggable:!s.readOnly,...De(h.path,"dir",{onDragStart:p,onContextMenu:f})},h.path)),te.map((h,K)=>{const W=le(h.path),se=D?$.get(W):void 0,fe=we(h);return t.jsx(Fe,{name:se?.title??W,meta:I(W),readOnly:s.readOnly,counts:{volume:j,path:h.path,enabled:K<Zt},overlay:se&&t.jsx(en,{icon:se.icon,name:se.title,size:"xs"}),badge:fe&&t.jsx(Qe,{state:fe,t:b}),onOpen:()=>r(xe(s,h.path)),onShare:H(h),onDelete:_(h),draggable:!s.readOnly,...De(h.path,"dir",{onDragStart:p,onContextMenu:f,onDrop:m})},h.path)})]})}),ae.length>0&&t.jsx(jt,{view:l,count:ae.length,children:ae.map(h=>t.jsx(wt,{entry:h,view:l,selected:l.previewPath===xe(s,h.path),publicState:we(h.entry),downloadUrl:k(j,h.path),actions:{onOpen:()=>i(xe(s,h.path)),download:{url:k(j,h.path),filename:h.name},onShare:H(h.entry),onDelete:_(h.entry),draggable:!s.readOnly,...De(h.path,"file",{onDragStart:p,onContextMenu:f})}},h.path))})]})}e[20]=I,e[21]=x,e[22]=k,e[23]=v,e[24]=D,e[25]=y,e[26]=w.data,e[27]=s,e[28]=f,e[29]=u,e[30]=p,e[31]=m,e[32]=d,e[33]=r,e[34]=i,e[35]=o,e[36]=c,e[37]=N,e[38]=$,e[39]=A,e[40]=V,e[41]=b,e[42]=l,e[43]=j,e[44]=F,e[45]=B,e[46]=M,e[47]=R}else F=e[44],B=e[45],M=e[46],R=e[47];if(R!==Symbol.for("react.early_return_sentinel"))return R;let C;e[77]!==F||e[78]!==b||e[79]!==l.fileView||e[80]!==l.modified?(C=(l.fileView!=="all"||l.modified!=="any")&&F.length===0&&t.jsx(vt,{children:b("library.library.noFilesInView")}),e[77]=F,e[78]=b,e[79]=l.fileView,e[80]=l.modified,e[81]=C):C=e[81];let U;return e[82]!==B||e[83]!==M||e[84]!==C?(U=t.jsxs(t.Fragment,{children:[B,M,C]}),e[82]=B,e[83]=M,e[84]=C,e[85]=U):U=e[85],U}function Dl(a){return a.kind==="dir"&&!a.hasSkill&&!a.hasBrand}function Ol(a){return a.kind==="dir"&&a.hasBrand&&!a.hasSkill}function $l(a){return a.kind==="dir"&&a.hasSkill}function Tl({root:a=ye,rootLabel:e,onOpenFile:s,onOpenSkill:n,onOpenBrand:r}={}){const l=de(),{org:i}=Le(),o=Mt(),d=Fs(),c=Bt({strict:!1}),u=c.fileView??"all",p=c.modified??"any",f=at(c.path||a),m=Et(f.volume)&&!f.dirPath?"updated":"name",x=Nn.find(g=>g===c.sort)??m,b=(g,G)=>o({to:".",search:ue=>({...ue,[g]:G||void 0})}),N=!s,j={layout:"list",sort:x,fileView:u,modified:p,previewPath:N?c.preview:void 0,flat:!0,onLayout:()=>{},onSort:g=>b("sort",g===m?null:g)},w=c.path||a,k=at(w),$=Ks(),y=k.volume!==null&&$.has(k.volume)?{...k,readOnly:!0}:k,D=g=>b("path",g),S=e??ft(i.slug),I=As(w,a),v=I.length===0,z=I.map(g=>({key:`folder:${g.path}`,label:g.label,onSelect:()=>D(g.path)})),V=(g,G)=>o({to:".",search:ue=>({...ue,preview:void 0,skill:void 0,brand:void 0,[g]:G})}),T=g=>{Is(),s?s(g):V("preview",g)},A=n??(g=>V("skill",g)),F=r??(g=>V("brand",g)),[B,M]=Y.useState(""),R=Vs(B.trim(),300),C=!v&&y.volume!==null?{volume:y.volume,prefix:y.dirPath}:void 0,U=C?l("library.library.searchInPlaceholder",{folder:Ye(y.segments.at(-1)??"")}):l("library.library.searchPlaceholder"),O=v?S:Ye(y.segments.at(-1)??""),[E,q]=Y.useState(null),[Z,_]=Y.useState(null),[ee,H]=Y.useState(!1),[X,Q]=Y.useState(""),[te,re]=Y.useState(!1),[ae,he]=Y.useState(null),[pe,be]=Y.useState(""),ie=Y.useRef(null),[ve,h]=Y.useState(!1),K=Y.useRef(0),W=y.readOnly?null:y.volume,{upload:se,mkdir:fe,move:me}=it(W??ye),{remove:et}=it(E?.volume??"uploads"),Re=y.isHomeRoot&&a===ye;async function P(g){if(!(!W||!g||g.length===0))try{await se.mutateAsync({dir:y.dirPath,files:[...g]}),oe.success(g.length===1?l("library.library.uploadedSingle",{filename:g[0]?.name??""}):l("library.library.uploadedMultiple",{count:g.length}))}catch(G){oe.error(G instanceof Error?G.message:l("library.library.uploadFailed"))}finally{ie.current&&(ie.current.value="")}}const J=W!==null;function je(g){return g.dataTransfer.types.includes("Files")}function Ue(g){!J||!je(g)||(g.preventDefault(),K.current+=1,h(!0))}function _e(g){!J||!je(g)||g.preventDefault()}function ss(){J&&(K.current=Math.max(0,K.current-1),K.current===0&&h(!1))}function ns(g){J&&(g.preventDefault(),g.stopPropagation(),K.current=0,h(!1),g.dataTransfer.files.length>0&&P(g.dataTransfer.files))}async function kt(){const g=X.trim();if(!(!W||!g)){if(Re&&dt.has(g.toLowerCase())){oe.error(l("library.library.folderNameReserved",{name:g}));return}try{const G=y.dirPath;await fe.mutateAsync(G?`${G}/${g}`:g),oe.success(l("library.library.folderCreated",{name:g})),H(!1),Q("")}catch(G){oe.error(G instanceof Error?G.message:l("library.library.folderCreateFailed"))}}}async function ls(){if(!E)return;const g=E;try{await et.mutateAsync(g.path),oe.success(l("library.library.deleted",{name:le(g.path)}))}catch(G){oe.error(G instanceof Error?G.message:l("library.library.deleteFailed"))}finally{q(null)}}async function Nt(){if(!ae)return;const g=pe.trim();if(!g||g.includes("/")||g.includes("..")||g===le(ae.path)){re(!1),he(null),be("");return}if(ae.kind==="dir"&&Re&&dt.has(g.toLowerCase())){oe.error(l("library.library.folderNameReserved",{name:g}));return}try{const G=ae.path.includes("/")?ae.path.slice(0,ae.path.lastIndexOf("/")):"",ue=G?`${G}/${g}`:g;await me.mutateAsync({from:ae.path,to:ue});const tt=g.replace(/[<>]/g,"");oe.success(l("library.library.renamed",{name:tt}))}catch(G){oe.error(G instanceof Error?G.message:l("library.library.renameFailed"))}finally{re(!1),he(null),be("")}}async function rs(g,G){try{const ue=le(g),tt=G?`${G}/${ue}`:ue;await me.mutateAsync({from:g,to:tt}),oe.success(l("library.library.moved",{name:ue,destination:G||l("library.library.theLibrary")}))}catch(ue){oe.error(ue instanceof Error?ue.message:l("library.library.moveFailed"))}}function as(g){g.defaultPrevented||!W||g.target.closest("input, textarea, button, a, [role='button']")||(g.preventDefault(),H(!0))}const is=y.readOnly?t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx($s,{size:12}),l("library.library.readOnly")]}):t.jsxs(ce,{size:"sm",disabled:se.isPending,onClick:()=>ie.current?.click(),"aria-label":se.isPending?l("library.library.uploading"):l("library.library.uploadFile"),children:[t.jsx(qe,{size:14}),t.jsx("span",{className:"hidden @lg/panel-header:inline",children:se.isPending?l("library.library.uploading"):l("library.library.uploadFile")})]}),St=t.jsxs(ce,{size:"sm",onClick:()=>ie.current?.click(),children:[t.jsx(qe,{size:14}),l("library.library.uploadFile")]}),os=t.jsxs("div",{className:"flex items-center gap-2",children:[St,t.jsxs(ce,{variant:"secondary",size:"sm",onClick:()=>H(!0),children:[t.jsx(Ts,{size:14}),l("library.library.newFolder")]})]}),cs=Et(y.volume)&&!y.dirPath,ds=wn(a).filter(g=>g.key!=="public"),us=Ls(y),fs=t.jsx(He.Tabs,{children:ds.map(g=>t.jsx(He.Tab,{active:us===g.key,onClick:()=>D(g.path),children:g.key==="all"?l("library.context.all"):g.label},g.key))});return t.jsxs("div",{className:"relative h-full",onDragEnter:Ue,onDragOver:_e,onDragLeave:ss,onDrop:ns,onContextMenu:as,children:[ve&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-background/80 p-6 backdrop-blur-sm",children:t.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl border-2 border-dashed border-primary px-10 py-8 text-center",children:[t.jsx(qe,{size:28,className:"text-primary"}),t.jsx("p",{className:"text-sm font-medium text-foreground",children:l("library.library.dropToUpload",{location:O})})]})}),t.jsx("input",{ref:ie,type:"file",multiple:!0,className:"hidden",onChange:g=>{P(g.target.files)}}),t.jsx(He.Breadcrumbs,{after:"page",parent:{onSelect:()=>D(a),...e?{label:e}:{}},items:z}),t.jsxs(He.Actions,{children:[W&&t.jsx(ce,{variant:"outline",size:"sm",onClick:()=>H(!0),children:l("library.library.newFolder")}),is]}),t.jsx(Ct.Toolbar.Left.Portal,{children:fs}),t.jsx(Ct.Toolbar.Right.Portal,{children:t.jsx(zs,{value:B,onChange:M,placeholder:U,className:"w-full min-w-48 md:w-56"})}),t.jsx("div",{className:"h-full overflow-y-auto",children:t.jsx("div",{className:ne("mx-auto flex w-full flex-col gap-8",ws,"pt-4 pb-8"),children:R?t.jsx(yl,{view:j,query:R,scope:C,stale:B.trim()!==R,onOpenFile:T,onShare:_,onDelete:q}):y.volume===null?t.jsx(Pl,{view:j,onOpenDir:D}):cs?t.jsx(jl,{volume:y.volume,view:j,onOpenDir:D,onOpenFile:T,onShare:_,onDelete:q,emptyActions:St},y.volume):t.jsx(Cl,{view:j,root:a,location:y,onOpenDir:D,onOpenFile:T,onOpenSkill:A,onOpenBrand:F,onShare:_,onDelete:q,onContextMenu:(g,G)=>{he({path:g,kind:G}),be(le(g)),re(!0)},onMove:rs,emptyActions:os},y.volume)})}),d&&(N&&c.preview?t.jsx(Rt,{previewPath:c.preview,onClose:()=>b("preview",null)}):c.skill?t.jsx(Ut,{skillPath:c.skill,onClose:()=>b("skill",null)},c.skill):c.brand?t.jsx(qt,{brandPath:c.brand,onClose:()=>b("brand",null)},c.brand):null),t.jsx(lt,{open:ee,onOpenChange:H,children:t.jsxs(nt,{children:[t.jsxs(Dt,{children:[t.jsx(rt,{children:l("library.library.newFolderTitle")}),t.jsx(Ot,{children:l("library.library.newFolderDescription",{path:O||l("library.library.theLibrary")})})]}),t.jsx(Ge,{autoFocus:!0,placeholder:l("library.library.folderNamePlaceholder"),value:X,onChange:g=>Q(g.target.value),onKeyDown:g=>{g.key==="Enter"&&kt()}}),t.jsxs($t,{children:[t.jsx(ce,{variant:"outline",onClick:()=>H(!1),children:l("library.library.cancel")}),t.jsx(ce,{disabled:!X.trim()||fe.isPending,onClick:()=>{kt()},children:l("library.library.create")})]})]})}),t.jsx(lt,{open:te,onOpenChange:g=>{re(g),g||(he(null),be(""))},children:t.jsxs(nt,{children:[t.jsxs(Dt,{children:[t.jsx(rt,{children:ae&&l("library.library.renameTitle",{name:le(ae.path)})}),t.jsx(Ot,{children:l("library.library.renameDescription")})]}),t.jsx(Ge,{autoFocus:!0,value:pe,onChange:g=>be(g.target.value),onKeyDown:g=>{g.key==="Enter"&&Nt()}}),t.jsxs($t,{children:[t.jsx(ce,{variant:"outline",onClick:()=>re(!1),children:l("library.library.cancel")}),t.jsx(ce,{disabled:!pe.trim()||me.isPending,onClick:()=>{Nt()},children:l("library.library.rename")})]})]})}),t.jsx(cn,{target:Z,onOpenChange:g=>{g||_(null)}}),t.jsx(js,{open:E!==null,onOpenChange:g=>{g||q(null)},children:t.jsxs(ks,{children:[t.jsxs(Ns,{children:[t.jsx(Ss,{children:l("library.library.deleteTitle",{name:E?le(E.path):""})}),t.jsx(Ps,{children:E?.kind==="dir"?l("library.library.deleteDirectoryDescription"):l("library.library.deleteFileDescription")})]}),t.jsxs(Cs,{children:[t.jsx(Ds,{children:l("library.library.cancel")}),t.jsx(Os,{onClick:()=>{ls()},children:l("library.library.delete")})]})]})})]})}function ir(a){const e=L.c(20),{root:s,rootLabel:n,filePreview:r}=a,l=Mt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const{preview:o}=Bt(i),[d,c]=Y.useState(null),[u,p]=Y.useState(null);let f;e[1]!==l?(f=$=>{l({to:".",search:y=>({...y,preview:$})})},e[1]=l,e[2]=f):f=e[2];const m=f,x=r==="dialog"?m:void 0;let b;e[3]!==s||e[4]!==n||e[5]!==x?(b=t.jsx(Tl,{root:s,rootLabel:n,onOpenFile:x,onOpenSkill:c,onOpenBrand:p}),e[3]=s,e[4]=n,e[5]=x,e[6]=b):b=e[6];let N;e[7]!==r||e[8]!==o||e[9]!==m?(N=r==="dialog"&&o&&t.jsx(Rt,{previewPath:o,onClose:()=>m(void 0)},o),e[7]=r,e[8]=o,e[9]=m,e[10]=N):N=e[10];let j;e[11]!==d?(j=d&&t.jsx(Ut,{skillPath:d,onClose:()=>c(null)},d),e[11]=d,e[12]=j):j=e[12];let w;e[13]!==u?(w=u&&t.jsx(qt,{brandPath:u,onClose:()=>p(null)},u),e[13]=u,e[14]=w):w=e[14];let k;return e[15]!==b||e[16]!==N||e[17]!==j||e[18]!==w?(k=t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[b,N,j,w]}),e[15]=b,e[16]=N,e[17]=j,e[18]=w,e[19]=k):k=e[19],k}export{ir as L};