diff --git a/crates/archivr-server/static/assets/index-AE6iQI2Q.js b/crates/archivr-server/static/assets/index-BZnJs_tc.js similarity index 92% rename from crates/archivr-server/static/assets/index-AE6iQI2Q.js rename to crates/archivr-server/static/assets/index-BZnJs_tc.js index 2743540..7fa76ea 100644 --- a/crates/archivr-server/static/assets/index-AE6iQI2Q.js +++ b/crates/archivr-server/static/assets/index-BZnJs_tc.js @@ -42,6 +42,6 @@ ${K.map(V=>` ${V}`).join(` `)}`),R.length>0&&Ae.push(`With warnings: ${R.map(V=>` ${V}`).join(` `)}`);const D=Ae.length>0?Ae.join(` -`):null;d.current(D,null,Ye,J)}async function te(N,C=null){if(!N.locator.trim())return;const F=t,M=N.locator.trim(),H=N.quality||"best";y(G=>G.map(Q=>Q.id===N.id?{...Q,status:"submitting",error:null}:Q));try{const Q=await ih(F,M,H,{ublock_enabled:E,reader_mode:S,cookie_ext_enabled:j});y(K=>K.map(R=>R.id===N.id?{...R,status:"running",jobUid:Q.job_uid,archiveId:F}:R)),b(N.id,Q.job_uid,M,F,C)}catch(G){const Q=G.message||"Submission failed.";y(K=>K.map(R=>R.id===N.id?{...R,status:"failed",error:Q}:R)),d.current(Q,M),W(C,"failed",M)}}function Z(){var F,M;const N=k.filter(H=>H.status==="idle"&&H.locator.trim());if(N.length===0)return;const C=N.length>1?((F=crypto.randomUUID)==null?void 0:F.call(crypto))??`batch-${Date.now()}`:null;C&&c.current.set(C,{total:N.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]}),N.forEach(H=>te(H,C)),(M=s.current)==null||M.close()}function ne(){y(N=>[...N,Wn()])}function Se(N){clearTimeout(u.current.get(N)),u.current.delete(N),y(C=>{const F=C.filter(M=>M.id!==N);return F.length===0?[Wn()]:F})}function Te(N){y(C=>C.map(F=>F.id===N?{...F,status:"idle",error:null}:F))}function xe(N,C){if(clearTimeout(u.current.get(N)),y(M=>M.map(H=>H.id===N?{...H,locator:C,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:H)),!Zc(C))return;const F=setTimeout(async()=>{u.current.delete(N),y(M=>M.map(H=>H.id===N?{...H,probeState:"probing"}:H));try{const M=await ah(g.current,C.trim());y(H=>H.map(G=>{if(G.id!==N||G.locator!==C)return G;const Q=M.qualities??[],K=M.has_audio??!1,R=Q.length===0&&K?"audio":"best";return{...G,probeState:"done",probeQualities:Q,probeHasAudio:K,quality:R}}))}catch{y(M=>M.map(H=>H.id===N?{...H,probeState:"idle",probeQualities:null}:H))}},600);u.current.set(N,F)}function z(N,C){y(F=>F.map(M=>M.id===N?{...M,quality:C}:M))}const _=k.filter(N=>N.status==="idle"&&N.locator.trim()).length,B=Ro(k);return i.jsx("dialog",{ref:s,className:"capture-dialog",children:i.jsxs("div",{className:"capture-dialog-inner",children:[i.jsxs("div",{className:"capture-dialog-header",children:[i.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),i.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var N;return(N=s.current)==null?void 0:N.close()},"aria-label":"Close",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),i.jsx("div",{className:"capture-rows",children:k.map((N,C)=>i.jsx(Wh,{item:N,autoFocus:C===k.length-1&&N.status==="idle",onLocatorChange:F=>xe(N.id,F),onQualityChange:F=>z(N.id,F),onRemove:()=>Se(N.id),onReset:()=>Te(N.id),onSubmit:Z},N.id))}),i.jsxs("button",{type:"button",className:"capture-add-row",onClick:ne,children:[i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),i.jsxs("div",{className:"capture-advanced",children:[i.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>L(N=>!N),"aria-expanded":w,children:[i.jsx("svg",{className:`capture-chevron${w?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),w&&i.jsxs("div",{className:"capture-advanced-panel",children:[i.jsxs("label",{className:"capture-ext-row",children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":E,className:`ext-toggle ext-toggle--sm${E?" ext-toggle--on":""}`,onClick:()=>f(N=>N===null?!E:!N),"aria-label":"Toggle uBlock for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),i.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(v!=null&&v.cookie_ext_available)&&i.jsxs("span",{className:"capture-ext-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":j,className:`ext-toggle ext-toggle--sm${j?" ext-toggle--on":""}`,onClick:()=>T(N=>!N),"aria-label":"Toggle cookie banner blocking for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),i.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":S,className:`ext-toggle ext-toggle--sm${S?" ext-toggle--on":""}`,onClick:()=>O(N=>!N),"aria-label":"Toggle reader mode for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),i.jsxs("div",{className:"capture-actions",children:[i.jsx("button",{type:"button",className:"capture-submit",onClick:Z,disabled:_===0,children:_>1?`Archive ${_}`:"Archive"}),i.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var N;return(N=s.current)==null?void 0:N.close()},children:B?"Close":"Cancel"})]})]})})}function Wh({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:s,onSubmit:a}){const o=p.useRef(null),u=e.status==="submitting"||e.status==="running";p.useEffect(()=>{var g;t&&e.status==="idle"&&((g=o.current)==null||g.focus())},[t]);const c=(()=>{if(e.status==="completed"||u||!Zc(e.locator))return null;if(e.probeState==="probing")return i.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const g=e.probeQualities??[],m=e.probeHasAudio??!1;return g.length===0&&!m?i.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):g.length===0&&m?i.jsx("select",{className:"capture-quality",value:"audio",onChange:d=>r(d.target.value),"aria-label":"Video quality",children:i.jsx("option",{value:"audio",children:"Audio only"})}):i.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:d=>r(d.target.value),"aria-label":"Video quality",children:[i.jsx("option",{value:"best",children:"Best quality"}),g.map(d=>i.jsx("option",{value:d,children:d},d)),m&&i.jsx("option",{value:"audio",children:"Audio only"})]})}return null})();return i.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[i.jsxs("div",{className:"capture-row-main",children:[i.jsx(Vh,{status:e.status}),i.jsx("input",{ref:o,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · ytm:ID · tweet:ID · x:ID",value:e.locator,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"&&a()},disabled:u||e.status==="completed",autoComplete:"off",spellCheck:!1}),c,e.status==="failed"&&i.jsx("button",{type:"button",className:"capture-row-action",onClick:s,title:"Retry",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),i.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!u&&e.status!=="completed"&&e.status!=="failed"&&i.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&i.jsx("p",{className:"capture-row-error",children:e.error})]})}function Vh({status:e}){return e==="submitting"||e==="running"?i.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:i.jsx("span",{className:"cap-spinner"})}):e==="completed"?i.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?i.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):i.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function wi(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function Kt(e){return Qh(e)??""}function ed(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const zo={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function ga(e){return zo[e]??zo.other}function td(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function Kh({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,s]=p.useState(!1),o=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?i.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>s(!0),style:{objectFit:"contain"}}):i.jsx("span",{dangerouslySetInnerHTML:{__html:ga(e.source_kind)}});return i.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:u=>{u.key==="Enter"&&r()},children:[i.jsx("div",{className:"col-added",children:ed(e.archived_at)}),i.jsxs("div",{className:"col-title",children:[i.jsx("span",{className:"source-icon",children:o}),i.jsx("span",{className:"entry-title",children:Kt(e.title)||Kt(e.entry_uid)})]}),i.jsx("div",{className:"col-type",children:i.jsx("span",{className:"type-pill",children:Kt(e.entity_kind)})}),i.jsxs("div",{className:"col-size",children:[i.jsx("span",{className:"size-total",children:wi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&i.jsxs("span",{className:"size-cached-pct",title:`${wi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),i.jsx("div",{className:"url-cell col-url",children:Kt(e.original_url)})]})}function Xh({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return i.jsx("section",{id:"archive-view",className:"view is-active",children:i.jsxs("div",{className:"entry-table",children:[i.jsxs("div",{className:"entry-header-row",children:[i.jsx("div",{className:"col-added",children:"Added"}),i.jsx("div",{className:"col-title",children:"Title"}),i.jsx("div",{className:"col-type",children:"Type"}),i.jsx("div",{className:"col-size",children:"Size"}),i.jsx("div",{className:"col-url",children:"Original URL"})]}),i.jsx("div",{id:"entries-body",children:e.map(l=>i.jsx(Kh,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function Jh(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function qh({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return i.jsx("span",{className:`run-status ${t}`,children:n})}function Gh({runs:e}){const[t,n]=p.useState(null);function r(l){n(s=>s===l?null:l)}return i.jsx("section",{id:"runs-view",className:"view is-active",children:i.jsxs("table",{className:"entry-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Started"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Requested"}),i.jsx("th",{children:"Completed"}),i.jsx("th",{children:"Failed"})]})}),i.jsx("tbody",{children:e.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const s=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[i.jsxs("tr",{className:s?"run-row run-row--failed":"run-row",onClick:s?()=>r(l.run_uid):void 0,title:s?a?"Click to hide error":"Click to view error":void 0,children:[i.jsx("td",{children:Jh(l.started_at)}),i.jsxs("td",{children:[i.jsx(qh,{status:l.status}),s&&i.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"▴":"▾"})]}),i.jsx("td",{children:l.requested_count??"—"}),i.jsx("td",{children:l.completed_count??"—"}),i.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),s&&a&&i.jsx("tr",{className:"run-error-row",children:i.jsx("td",{colSpan:5,children:i.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const Yh=4;function Zh({archives:e}){const{currentUser:t}=p.useContext(Ql)??{},n=t&&(t.role_bits&Yh)!==0,[r,l]=p.useState("users"),[s,a]=p.useState([]),[o,u]=p.useState([]),[c,g]=p.useState(!1),[m,d]=p.useState(null),[k,y]=p.useState(""),[w,L]=p.useState(""),[h,f]=p.useState(""),[v,x]=p.useState(null),[j,T]=p.useState(!1),[E,S]=p.useState(""),[O,b]=p.useState(""),[W,te]=p.useState(null),[Z,ne]=p.useState(!1),Se=p.useCallback(async()=>{if(n){g(!0),d(null);try{const[_,B]=await Promise.all([xh(),jh()]);a(_),u(B)}catch(_){d(_.message)}finally{g(!1)}}},[n]);p.useEffect(()=>{Se()},[Se]);async function Te(_){const B=_.status==="active"?"disabled":"active";try{await kh(_.user_uid,B),a(N=>N.map(C=>C.user_uid===_.user_uid?{...C,status:B}:C))}catch(N){d(N.message)}}async function xe(_){if(_.preventDefault(),!k.trim()||!w){x("Username and password required");return}T(!0),x(null);try{await wh(k.trim(),w,h.trim()||void 0),y(""),L(""),f(""),await Se()}catch(B){x(B.message)}finally{T(!1)}}async function z(_){if(_.preventDefault(),!E.trim()||!O.trim()){te("Slug and name required");return}ne(!0),te(null);try{await Sh(E.trim(),O.trim()),S(""),b(""),await Se()}catch(B){te(B.message)}finally{ne(!1)}}return n?i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsxs("div",{className:"view-tabs",children:[i.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),i.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),i.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),m&&i.jsx("div",{className:"form-msg form-msg--err",children:m}),r==="users"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Users"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Username"}),i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Roles"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Actions"})]})}),i.jsx("tbody",{children:s.map(_=>i.jsxs("tr",{className:_.status==="disabled"?"admin-row-disabled":"",children:[i.jsx("td",{children:_.username}),i.jsx("td",{className:"muted",children:_.email||"—"}),i.jsx("td",{children:_.role_slugs.join(", ")||"—"}),i.jsx("td",{children:i.jsx("span",{className:`status-badge status-${_.status}`,children:_.status})}),i.jsx("td",{children:i.jsx("button",{className:"admin-action-btn",onClick:()=>Te(_),children:_.status==="active"?"Ban":"Unban"})})]},_.user_uid))})]}),i.jsx("h3",{children:"Create User"}),i.jsxs("form",{className:"admin-form",onSubmit:xe,children:[i.jsx("input",{className:"admin-input",placeholder:"Username",value:k,onChange:_=>y(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:w,onChange:_=>L(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:h,onChange:_=>f(_.target.value)}),v&&i.jsx("div",{className:"form-msg form-msg--err",children:v}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:j,children:j?"Creating…":"Create User"})]})]}),r==="roles"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Roles"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Slug"}),i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Level"}),i.jsx("th",{children:"Bit"}),i.jsx("th",{children:"Built-in"})]})}),i.jsx("tbody",{children:o.map(_=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("code",{children:_.slug})}),i.jsx("td",{children:_.name}),i.jsx("td",{children:_.level}),i.jsx("td",{children:_.bit_position}),i.jsx("td",{children:_.is_builtin?"✓":""})]},_.role_uid))})]}),i.jsx("h3",{children:"Create Custom Role"}),i.jsxs("form",{className:"admin-form",onSubmit:z,children:[i.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:E,onChange:_=>S(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:O,onChange:_=>b(_.target.value),required:!0}),W&&i.jsx("div",{className:"form-msg form-msg--err",children:W}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:Z,children:Z?"Creating…":"Create Role"})]})]}),r==="archives"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})]}):i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})}function nd({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){var x;const c=n===e.tag.full_path,[g,m]=p.useState(!1),[d,k]=p.useState(""),y=p.useRef(!1);function w(){if(g)return;const j=c?null:e.tag.full_path;r(j),l("archive")}function L(j){j.stopPropagation(),k(e.tag.slug),m(!0)}async function h(){const j=d.trim();if(!j||j===e.tag.slug){m(!1);return}try{const T=await lh(t,e.tag.tag_uid,j);s(e.tag.full_path,T.full_path),o()}catch{}finally{m(!1)}}async function f(j){var E;j.stopPropagation();const T=((E=e.children)==null?void 0:E.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(T))try{await sh(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const v={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u};return i.jsxs("li",{children:[i.jsxs("div",{className:"tag-node-row",children:[g?i.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:d,onChange:j=>k(j.target.value),onKeyDown:j=>{j.key==="Enter"&&j.currentTarget.blur(),j.key==="Escape"&&(y.current=!0,j.currentTarget.blur())},onBlur:()=>{y.current?(y.current=!1,m(!1)):h()}}):i.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:w,onDoubleClick:L,children:[u?e.tag.name:e.tag.slug,i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",onClick:j=>{j.stopPropagation(),L(j)},children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),i.jsx("button",{className:"remove tag-node-delete",title:`Delete tag ${e.tag.full_path}`,onClick:f,"aria-label":`Delete tag ${e.tag.full_path}`,children:"×"})]}),((x=e.children)==null?void 0:x.length)>0&&i.jsx("div",{className:"tag-children",children:i.jsx("ul",{className:"tag-tree-list",children:e.children.map(j=>i.jsx(nd,{node:j,...v},j.tag.tag_uid))})})]})}function em({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){return i.jsx("section",{id:"tags-view",className:"view is-active",children:i.jsxs("div",{className:"tag-tree",children:[i.jsxs("div",{className:"tag-tree-header",children:[i.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&i.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?i.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):i.jsx("ul",{className:"tag-tree-list",children:t.map(c=>i.jsx(nd,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u},c.tag.tag_uid))})]})})}const qn=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],tm=e=>{var t;return((t=qn.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function nm({archiveId:e}){const[t,n]=p.useState([]),[r,l]=p.useState(!1),[s,a]=p.useState(null),[o,u]=p.useState(null),[c,g]=p.useState(null),[m,d]=p.useState(!1),[k,y]=p.useState(null),[w,L]=p.useState(""),[h,f]=p.useState(""),[v,x]=p.useState(2),[j,T]=p.useState(!1),[E,S]=p.useState(null),[O,b]=p.useState(""),[W,te]=p.useState(2),[Z,ne]=p.useState(!1),[Se,Te]=p.useState(null),[xe,z]=p.useState(!1),[_,B]=p.useState(""),N=p.useRef(null),C=t.find(D=>D.collection_uid===o)??null,F=(C==null?void 0:C.slug)==="_default_",M=p.useCallback(async()=>{if(e){l(!0),a(null);try{const D=await Nh(e);n(D)}catch(D){a(D.message)}finally{l(!1)}}},[e]),H=p.useCallback(async D=>{if(!D){g(null);return}d(!0),y(null);try{const V=await Ch(e,D);g(V)}catch(V){y(V.message)}finally{d(!1)}},[e]);p.useEffect(()=>{M()},[M]),p.useEffect(()=>{H(o)},[o,H]),p.useEffect(()=>{xe&&N.current&&N.current.focus()},[xe]);async function G(D){D.preventDefault();const V=w.trim(),Fe=h.trim();if(!(!V||!Fe)){T(!0),S(null);try{const dt=await _h(e,V,Fe,v);L(""),f(""),x(2),await M(),u(dt.collection_uid)}catch(dt){S(dt.message)}finally{T(!1)}}}async function Q(){const D=_.trim();if(!D||!C){z(!1);return}try{await Lo(e,C.collection_uid,{name:D}),await M(),g(V=>V&&{...V,name:D})}catch(V){a(V.message)}finally{z(!1)}}async function K(D){if(C)try{await Lo(e,C.collection_uid,{default_visibility_bits:D}),await M(),g(V=>V&&{...V,default_visibility_bits:D})}catch(V){a(V.message)}}async function R(){if(C&&window.confirm(`Delete collection "${C.name}"? Entries will not be deleted.`))try{await Rh(e,C.collection_uid),u(null),g(null),await M()}catch(D){a(D.message)}}async function J(D){D.preventDefault();const V=O.trim();if(!(!V||!C)){ne(!0),Te(null);try{await Eh(e,C.collection_uid,V,W),b(""),await H(C.collection_uid)}catch(Fe){Te(Fe.message)}finally{ne(!1)}}}async function Ye(D){if(C)try{await Th(e,C.collection_uid,D),await H(C.collection_uid)}catch(V){y(V.message)}}async function Ae(D,V){if(C)try{await Ph(e,C.collection_uid,D,V),g(Fe=>Fe&&{...Fe,entries:Fe.entries.map(dt=>dt.entry_uid===D?{...dt,collection_visibility_bits:V}:dt)})}catch(Fe){y(Fe.message)}}return e?i.jsxs("div",{className:"collections-view",children:[i.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&i.jsx("div",{className:"muted",children:"Loading…"}),s&&i.jsxs("div",{className:"collections-error",children:[s," ",i.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"×"})]}),i.jsxs("div",{className:"collections-layout",children:[i.jsxs("div",{className:"collections-sidebar",children:[t.map(D=>i.jsxs("button",{className:`coll-sidebar-row${o===D.collection_uid?" is-active":""}`,onClick:()=>u(D.collection_uid),children:[i.jsx("span",{className:"coll-row-name",children:D.name}),i.jsx("span",{className:"coll-row-meta",children:tm(D.default_visibility_bits)})]},D.collection_uid)),t.length===0&&!r&&i.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),C?i.jsxs("div",{className:"coll-detail",children:[i.jsxs("div",{className:"coll-detail-header",children:[xe?i.jsx("input",{ref:N,className:"coll-rename-input",value:_,onChange:D=>B(D.target.value),onBlur:Q,onKeyDown:D=>{D.key==="Enter"&&Q(),D.key==="Escape"&&z(!1)}}):i.jsxs("h3",{className:`coll-detail-name${F?"":" coll-detail-name--editable"}`,title:F?void 0:"Click to rename",onClick:()=>{F||(B(C.name),z(!0))},children:[(c==null?void 0:c.name)??C.name,!F&&i.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!F&&i.jsx("button",{className:"coll-delete-btn",onClick:R,title:"Delete collection",children:"Delete"})]}),i.jsxs("div",{className:"coll-detail-vis",children:[i.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),i.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??C.default_visibility_bits,onChange:D=>K(Number(D.target.value)),disabled:F,children:qn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))})]}),i.jsxs("div",{className:"coll-entries-section",children:[i.jsx("div",{className:"coll-section-heading",children:"Entries"}),m&&i.jsx("div",{className:"muted",children:"Loading…"}),k&&i.jsx("div",{className:"collections-error",children:k}),!m&&c&&(c.entries.length===0?i.jsx("div",{className:"muted",children:"No entries in this collection."}):i.jsx("ul",{className:"coll-entries-list",children:c.entries.map(D=>i.jsxs("li",{className:"coll-entry-row",children:[i.jsxs("div",{className:"coll-entry-info",children:[i.jsx("span",{className:"coll-entry-title",children:D.title||D.entry_uid}),i.jsx("span",{className:"coll-entry-kind muted",children:D.source_kind})]}),i.jsxs("div",{className:"coll-entry-actions",children:[i.jsx("select",{className:"coll-entry-vis-select",value:D.collection_visibility_bits,onChange:V=>Ae(D.entry_uid,Number(V.target.value)),children:qn.map(V=>i.jsx("option",{value:V.value,children:V.label},V.value))}),!F&&i.jsx("button",{className:"coll-entry-remove",onClick:()=>Ye(D.entry_uid),title:"Remove from collection",children:"×"})]})]},D.entry_uid))}))]}),!F&&i.jsxs("form",{className:"coll-add-entry-form",onSubmit:J,children:[i.jsx("div",{className:"coll-section-heading",children:"Add entry"}),i.jsxs("div",{className:"coll-add-entry-row",children:[i.jsx("input",{className:"coll-add-entry-input",type:"text",value:O,onChange:D=>b(D.target.value),placeholder:"entry_uid",required:!0}),i.jsx("select",{className:"coll-vis-select",value:W,onChange:D=>te(Number(D.target.value)),children:qn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))}),i.jsx("button",{className:"coll-add-btn",type:"submit",disabled:Z,children:Z?"…":"Add"})]}),Se&&i.jsx("div",{className:"collections-error",style:{marginTop:4},children:Se})]})]}):i.jsx("div",{className:"coll-detail coll-detail--empty",children:i.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),i.jsxs("details",{className:"coll-create-details",children:[i.jsx("summary",{children:"+ Create collection"}),i.jsxs("form",{className:"coll-create-form",onSubmit:G,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),i.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:w,onChange:D=>{L(D.target.value),h||f(D.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),i.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:h,onChange:D=>f(D.target.value),placeholder:"my-collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),i.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:v,onChange:D=>x(Number(D.target.value)),children:qn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))})]}),E&&i.jsx("div",{className:"collections-error",children:E}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:j,children:j?"Creating…":"Create collection"})]})]})]}):i.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const rm=4;function lm({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=p.useContext(Ql)??{},s=r&&(r.role_bits&rm)!==0,a=["profile","tokens",...s?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return i.jsxs("section",{className:"admin-view",children:[i.jsx("h1",{children:"Settings"}),i.jsx("div",{className:"view-tabs",children:a.map(u=>i.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&i.jsx(sm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&i.jsx(im,{}),e==="instance"&&s&&i.jsx(am,{}),e==="cookies"&&s&&i.jsx(um,{}),e==="extensions"&&s&&i.jsx(cm,{}),e==="storage"&&s&&i.jsx(om,{archiveId:n})]})}function sm({currentUser:e,setCurrentUser:t}){const[n,r]=p.useState((e==null?void 0:e.display_name)??""),[l,s]=p.useState(!1),[a,o]=p.useState(null),[u,c]=p.useState(""),[g,m]=p.useState(""),[d,k]=p.useState(""),[y,w]=p.useState(!1),[L,h]=p.useState(null);async function f(x){x.preventDefault(),s(!0),o(null);try{await ph(n),t(j=>({...j,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(j){o({ok:!1,text:j.message})}finally{s(!1)}}async function v(x){if(x.preventDefault(),g!==d){h({ok:!1,text:"Passwords do not match."});return}w(!0),h(null);try{await mh(u,g),c(""),m(""),k(""),h({ok:!0,text:"Password changed."})}catch(j){h({ok:!1,text:j.message})}finally{w(!1)}}return i.jsxs("div",{style:{maxWidth:440},children:[i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Name"}),i.jsxs("form",{onSubmit:f,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),i.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:x=>r(x.target.value)})]}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Preferences"}),i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async x=>{const j=x.target.checked;try{await hh({humanize_slugs:j}),t(T=>({...T,humanize_slugs:j}))}catch{}}}),i.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),i.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Change Password"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),i.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:x=>c(x.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),i.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:g,onChange:x=>m(x.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),i.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:d,onChange:x=>k(x.target.value),required:!0})]}),L&&i.jsx("div",{className:`form-msg form-msg--${L.ok?"ok":"err"}`,children:L.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Changing…":"Change Password"})]})]})]})}function im(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(""),[u,c]=p.useState(!1),[g,m]=p.useState(null),d=p.useCallback(async()=>{r(!0),s(null);try{t(await gh())}catch(w){s(w.message)}finally{r(!1)}},[]);p.useEffect(()=>{d()},[d]);async function k(w){if(w.preventDefault(),!!a.trim()){c(!0);try{const L=await vh(a.trim());m(L),o(""),d()}catch(L){s(L.message)}finally{c(!1)}}}async function y(w){try{await yh(w),t(L=>L.filter(h=>h.token_uid!==w))}catch(L){s(L.message)}}return i.jsx("div",{style:{maxWidth:600},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"API Tokens"}),g&&i.jsxs("div",{className:"token-banner",children:[i.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",i.jsx("code",{children:g.raw_token}),i.jsx("button",{className:"token-dismiss",onClick:()=>m(null),children:"Dismiss"})]}),i.jsxs("form",{className:"token-create-row",onSubmit:k,children:[i.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:w=>o(w.target.value),required:!0}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&i.jsx("div",{className:"form-msg form-msg--err",children:l}),n?i.jsx("div",{className:"muted",children:"Loading…"}):i.jsxs("div",{children:[e.length===0&&i.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(w=>i.jsxs("div",{className:"token-row",children:[i.jsxs("div",{className:"token-row-info",children:[i.jsx("strong",{children:w.name}),i.jsxs("div",{className:"muted",children:["Created ",w.created_at.slice(0,10),w.last_used_at&&` · Last used ${w.last_used_at.slice(0,10)}`]})]}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>y(w.token_uid),children:"Revoke"})]},w.token_uid))]})]})})}function am(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(!1),[u,c]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await ma())}catch(m){s(m.message)}finally{r(!1)}})()},[]);async function g(m){m.preventDefault(),o(!0),c(null);try{await yi(e),c({ok:!0,text:"Saved."})}catch(d){c({ok:!1,text:d.message})}finally{o(!1)}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):e?i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Instance Settings"}),i.jsxs("form",{onSubmit:g,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([m,d])=>i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:!!e[m],onChange:k=>t(y=>({...y,[m]:k.target.checked}))}),d]},m)),i.jsxs("div",{className:"form-field",style:{marginTop:4},children:[i.jsx("label",{className:"form-label",children:"Default entry visibility"}),i.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:m=>t(d=>({...d,default_entry_visibility:Number(m.target.value)})),children:[i.jsx("option",{value:0,children:"Private"}),i.jsx("option",{value:2,children:"Unlisted"}),i.jsx("option",{value:3,children:"Public"})]})]}),u&&i.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function Ss(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n===0?0:1)} ${t[n]}`}function om({archiveId:e}){const[t,n]=p.useState("idle"),[r,l]=p.useState(null),[s,a]=p.useState(null),[o,u]=p.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function g(){n("scanning"),u(null),l(null);try{const k=await zh(e);l(k),n("scanned")}catch(k){u(k.message),n("error")}}async function m(){n("deleting"),u(null);try{const k=await Dh(e);a(k),n("done")}catch(k){u(k.message),n("error")}}const d=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Orphan Cleanup"}),i.jsxs("p",{className:"muted",style:{marginBottom:16},children:["Scan for blob files and database records that are no longer referenced by any archive entry and safely delete them."," ",i.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&i.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&i.jsx("button",{className:"btn-ghost",onClick:g,children:"Scan for orphaned blobs"}),t==="scanning"&&i.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&d&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean — nothing to remove."}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!d&&i.jsxs("div",{children:[i.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",i.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",i.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","— ",i.jsx("strong",{children:Ss(r.total_bytes)})," recoverable."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsxs("button",{className:"btn-danger",onClick:m,children:["Delete (",Ss(r.total_bytes),")"]}),i.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&i.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&s&&i.jsxs("div",{children:[i.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",i.jsx("strong",{children:Ss(s.freed_bytes)})," ","— removed ",s.deleted_files," file",s.deleted_files!==1?"s":""," ","and ",s.deleted_blob_rows," DB record",s.deleted_blob_rows!==1?"s":"","."]}),s.errors&&s.errors.length>0&&i.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[s.errors.length," file",s.errors.length!==1?"s":""," could not be deleted."]}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&i.jsxs("div",{children:[i.jsx("div",{className:"form-msg form-msg--err",children:o}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function um(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState("global"),[u,c]=p.useState(""),[g,m]=p.useState("{}"),[d,k]=p.useState(null),[y,w]=p.useState(!1),[L,h]=p.useState({});p.useEffect(()=>{f()},[]);async function f(){r(!0),s(null);try{t(await bh())}catch(S){s(S.message)}finally{r(!1)}}async function v(S){S.preventDefault();try{JSON.parse(g)}catch{k({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}w(!0),k(null);try{await Oh(a==="global"?null:u.trim(),a,g),c(""),m("{}"),o("global"),k({ok:!0,text:"Rule added."}),await f()}catch(O){k({ok:!1,text:O.message})}finally{w(!1)}}async function x(S){try{await Ah(S),await f()}catch(O){s(O.message)}}function j(S){h(O=>({...O,[S.rule_uid]:{cookiesInput:S.cookies_json,saving:!1,msg:null}}))}function T(S){h(O=>{const b={...O};return delete b[S],b})}async function E(S){const O=L[S.rule_uid];try{JSON.parse(O.cookiesInput)}catch{h(b=>({...b,[S.rule_uid]:{...b[S.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}h(b=>({...b,[S.rule_uid]:{...b[S.rule_uid],saving:!0,msg:null}}));try{await $h(S.rule_uid,{cookies_json:O.cookiesInput}),T(S.rule_uid),await f()}catch(b){h(W=>({...W,[S.rule_uid]:{...W[S.rule_uid],saving:!1,msg:{ok:!1,text:b.message}}}))}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Cookie Rules"}),i.jsx("p",{className:"muted",style:{marginBottom:12},children:"Cookies are injected into every capture network request (yt-dlp, HTTP downloads, web-page snapshots). Global rules apply to all URLs; wildcard and regex rules apply only to matching URLs."}),e&&e.length>0?i.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Pattern"}),i.jsx("th",{children:"Cookies"}),i.jsx("th",{style:{width:100},children:"Actions"})]})}),i.jsx("tbody",{children:e.map(S=>{const O=L[S.rule_uid],b=S.url_pattern?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"muted",children:[S.pattern_kind,":"]})," ",i.jsx("code",{children:S.url_pattern})]}):i.jsx("span",{className:"muted",children:"global (all URLs)"});return i.jsxs("tr",{children:[i.jsx("td",{children:b}),i.jsx("td",{children:O?i.jsxs(i.Fragment,{children:[i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:O.cookiesInput,onChange:W=>h(te=>({...te,[S.rule_uid]:{...te[S.rule_uid],cookiesInput:W.target.value}}))}),O.msg&&i.jsx("div",{className:`form-msg form-msg--${O.msg.ok?"ok":"err"}`,children:O.msg.text}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[i.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:O.saving,onClick:()=>E(S),children:O.saving?"Saving…":"Save"}),i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>T(S.rule_uid),children:"Cancel"})]})]}):i.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:S.cookies_json})}),i.jsx("td",{children:!O&&i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>j(S),children:"Edit"}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>x(S.rule_uid),children:"Del"})]})})]},S.rule_uid)})})]}):i.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),i.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Pattern type"}),i.jsxs("select",{className:"field-input",value:a,onChange:S=>o(S.target.value),children:[i.jsx("option",{value:"global",children:"Global (all URLs)"}),i.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),i.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),i.jsx("input",{className:"field-input",type:"text",value:u,onChange:S=>c(S.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:g,onChange:S=>m(S.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),d&&i.jsx("div",{className:`form-msg form-msg--${d.ok?"ok":"err"}`,children:d.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Adding…":"Add Rule"})]})]})})}function cm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(!1),[a,o]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await ma())}catch(y){o({ok:!1,text:y.message})}finally{r(!1)}})()},[]);async function u(y){s(!0),o(null);try{await yi({ublock_enabled:y}),t(w=>({...w,ublock_enabled:y})),o({ok:!0,text:"Saved."})}catch(w){o({ok:!1,text:w.message})}finally{s(!1)}}async function c(y){s(!0),o(null);try{await yi({cookie_ext_enabled:y}),t(w=>({...w,cookie_ext_enabled:y})),o({ok:!0,text:"Saved."})}catch(w){o({ok:!1,text:w.message})}finally{s(!1)}}if(n)return i.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,m=(e==null?void 0:e.ublock_enabled)??!0,d=(e==null?void 0:e.cookie_ext_available)??!1,k=(e==null?void 0:e.cookie_ext_enabled)??!0;return i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Extensions"}),i.jsx("p",{className:"form-hint",style:{marginBottom:20},children:"Extensions run inside the browser during WebPage captures and can block ads, accept cookie banners, and more. Changes take effect on the next capture."}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!g&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":m,className:`ext-toggle${m?" ext-toggle--on":""}`,onClick:()=>u(!m),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),i.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!d&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":k,className:`ext-toggle${k?" ext-toggle--on":""}`,onClick:()=>c(!k),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const Do={0:"Private",1:"Public",2:"Users only",3:"Public"},dm=()=>i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function fm({archiveId:e,selectedEntry:t,detail:n,onTagFilterSet:r,tagNodes:l,onTagsRefresh:s,onEntryTitleChange:a,onEntryDeleted:o,humanizeTags:u,onDetailRefresh:c,onOpenPreview:g,onPlay:m}){const[d,k]=p.useState([]),[y,w]=p.useState(""),[L,h]=p.useState([]),[f,v]=p.useState(""),x=p.useRef(0),j=p.useRef(!1),[T,E]=p.useState(!1),[S,O]=p.useState(""),[b,W]=p.useState("idle"),[te,Z]=p.useState(""),ne=p.useRef(null);p.useEffect(()=>{const R=++x.current;if(ne.current&&(clearInterval(ne.current),ne.current=null),W("idle"),Z(""),!t||!e){k([]),h([]);return}E(!1),O(""),j.current=!1,k([]),Promise.all([Vr(e,t.entry_uid),Lh(e,t.entry_uid)]).then(([J,Ye])=>{R===x.current&&(k(J),h(Ye))}).catch(()=>{})},[t,e]),p.useEffect(()=>()=>{clearInterval(ne.current)},[]);async function Se(){const R=S.trim()||null;try{await eh(e,t.entry_uid,R),a==null||a(t.entry_uid,R)}catch{}finally{E(!1)}}async function Te(){const R=y.trim();if(!(!R||!t))try{await th(e,t.entry_uid,R),w(""),v("");const J=await Vr(e,t.entry_uid);k(J),s()}catch(J){v(J.message)}}async function xe(R){try{await nh(e,t.entry_uid,R);const J=await Vr(e,t.entry_uid);k(J),s()}catch{}}async function z(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await rh(e,t.entry_uid),o==null||o(t.entry_uid)}catch{}}async function _(){if(!t||!e||b==="running")return;const R=x.current,J=t.entry_uid;W("running"),Z("");try{const{job_uid:Ye}=await Ih(e,J);if(x.current!==R)return;ne.current=setInterval(async()=>{try{const Ae=await Yc(e,Ye);if(Ae.status==="completed"){if(clearInterval(ne.current),ne.current=null,x.current!==R)return;W("done");const D=await Vr(e,J);if(x.current!==R)return;k(D),c==null||c()}else if(Ae.status==="failed"){if(clearInterval(ne.current),ne.current=null,x.current!==R)return;W("error"),Z(Ae.error_text||"Re-archive failed.")}}catch{if(clearInterval(ne.current),ne.current=null,x.current!==R)return;W("error"),Z("Network error while polling.")}},500)}catch(Ye){if(x.current!==R)return;W("error"),Z(Ye.message||"Failed to start re-archive.")}}const B=n?[["Added",ed(n.summary.archived_at)],["Source",n.summary.source_kind],["Type",n.summary.entity_kind],["Visibility",Do[n.summary.visibility]??n.summary.visibility],["Root",n.structured_root_relpath]]:[],N=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),C=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),F=n?n.artifacts.findIndex(R=>R.artifact_role==="primary_media"):-1,M=F>=0?n.artifacts[F]:null,H=M?M.relpath.split(".").pop().toLowerCase():"",G=M&&N.has(H),Q=F>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${F}`:null,K=n&&!G&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread"||M&&C.has(H));return i.jsxs("aside",{className:"context-rail",children:[i.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?n?i.jsxs(i.Fragment,{children:[T?i.jsx("input",{className:"rail-title-input",autoFocus:!0,value:S,onChange:R=>O(R.target.value),onKeyDown:R=>{R.key==="Enter"&&R.currentTarget.blur(),R.key==="Escape"&&(j.current=!0,R.currentTarget.blur())},onBlur:()=>{j.current?E(!1):Se(),j.current=!1}}):i.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{O(n.summary.title??""),E(!0)},children:[Kt(n.summary.title)||Kt(n.summary.entry_uid),i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),n.summary.original_url&&i.jsxs("a",{className:"url-tile",href:n.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[i.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:ga(n.summary.source_kind)}}),i.jsx("span",{className:"u-text",children:n.summary.original_url}),i.jsx("span",{className:"ext",children:i.jsx(dm,{})})]}),G&&m&&i.jsx("button",{className:"rail-preview-btn",onClick:()=>m(Q,t),children:"▶ Play"}),K&&g&&i.jsx("button",{className:"rail-preview-btn",onClick:g,children:"Preview"}),i.jsx("div",{className:"meta-list",children:B.filter(([,R])=>R!=null&&R!=="").map(([R,J])=>i.jsxs("div",{className:"meta-item",children:[i.jsx("span",{className:"meta-k",children:R}),i.jsx("span",{className:`meta-v${R==="Root"?" mono":""}`,children:Kt(J)})]},R))}),n.artifacts.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",i.jsx("span",{className:"num",children:n.artifacts.length})]}),i.jsx("ul",{className:"artifact-list",children:n.artifacts.map((R,J)=>i.jsx("li",{children:i.jsxs("a",{href:`/api/archives/${e}/entries/${n.summary.entry_uid}/artifacts/${J}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[i.jsx("span",{className:"artifact-name",children:R.artifact_role.replace(/_/g," ")}),i.jsx("span",{className:"artifact-size",children:R.byte_size!=null?wi(R.byte_size):"—"})]})},J))})]})]}):i.jsx("p",{className:"tags-empty",children:"Loading…"}):i.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Tags"}),d.length===0?i.jsx("p",{className:"tags-empty",children:"No tags yet."}):i.jsx("div",{className:"tags-wrap",children:d.map(R=>i.jsxs("span",{className:"tag-pill",title:R.full_path,children:[u?td(R.full_path):R.full_path,i.jsx("button",{className:"remove",title:`Remove tag ${R.full_path}`,onClick:()=>xe(R.tag_uid),children:"×"})]},R.tag_uid))}),f&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:f}),i.jsxs("div",{className:"tag-input-wrap",children:[i.jsx("span",{className:"hash",children:"/"}),i.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:y,onChange:R=>w(R.target.value),onKeyDown:R=>{R.key==="Enter"&&Te()}}),i.jsx("button",{className:"tag-add-btn",onClick:Te,children:"Add"})]})]}),L.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Collections"}),L.map(R=>i.jsxs("div",{className:"coll-row",children:[i.jsx("span",{className:"coll-name",children:R.collection_uid}),i.jsx("span",{className:"vis-badge",children:Do[R.visibility_bits]??`bits:${R.visibility_bits}`})]},R.collection_uid))]}),n&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread")&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Actions"}),i.jsx("button",{className:"rail-rearchive-btn",onClick:_,disabled:b==="running",children:b==="running"?"Re-archiving…":"Re-archive"}),b==="done"&&i.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),b==="error"&&i.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:te})]}),i.jsx("div",{className:"rail-delete-zone",children:i.jsx("button",{className:"rail-delete-btn",onClick:z,children:"Delete entry"})})]})]})}function pm({src:e}){const t=p.useRef(null);return p.useEffect(()=>{t.current&&t.current.load()},[e]),i.jsx("div",{className:"preview-video-wrap",style:{background:"#111",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"240px"},children:e?i.jsxs("video",{ref:t,controls:!0,autoPlay:!1,style:{width:"100%",maxHeight:"100%",display:"block"},children:[i.jsx("source",{src:e}),"Your browser does not support the video element."]}):i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function Io({src:e,type:t,title:n,originalUrl:r}){const l=r||e,s=n||null;return i.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsxs("div",{className:"preview-iframe-toolbar",style:{display:"flex",flexDirection:"column",gap:"2px",padding:"6px 12px",borderBottom:"1px solid var(--line-soft)",background:"var(--paper-2)",flexShrink:0},children:[s&&i.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{fontSize:"0.78rem",color:"var(--accent)",textDecoration:"none",whiteSpace:"nowrap",fontFamily:"var(--sans)",flexShrink:0},children:t==="pdf"?"Open PDF ↗":"Open in new tab ↗"})]})]}),i.jsx("iframe",{src:e,sandbox:"allow-same-origin allow-popups",allow:"autoplay 'none'",referrerPolicy:"no-referrer",style:{flex:1,border:"none",width:"100%",minHeight:0},title:s||(t==="pdf"?"PDF preview":"Page preview")})]})}function hm({src:e,alt:t}){return i.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:i.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function rd(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function bo(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const $={card:{background:"var(--paper)",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},threadOuter:{border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},tweetRow:{display:"flex",gap:"10px",padding:"10px 12px"},tweetRowThread:{display:"flex",gap:"10px",padding:"10px 12px 0"},leftCol:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:"36px"},rightCol:{flex:1,minWidth:0,paddingBottom:"8px"},avatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},avatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},threadLine:{flex:1,width:"2px",background:"var(--line-soft, var(--line))",margin:"4px 0",minHeight:"12px",borderRadius:"1px"},authorRow:{display:"flex",alignItems:"baseline",gap:"4px",flexWrap:"wrap",marginBottom:"4px",lineHeight:"1.3"},authorName:{fontWeight:"700",fontSize:"14px",color:"var(--ink)"},authorHandle:{fontSize:"13px",color:"var(--muted)"},datePart:{fontSize:"13px",color:"var(--muted)"},tweetText:{fontSize:"14px",lineHeight:"1.5",color:"var(--ink)",whiteSpace:"pre-line",marginBottom:"8px",wordBreak:"break-word"},stats:{display:"flex",gap:"12px",fontSize:"13px",color:"var(--muted)"},link:{color:"var(--accent)",textDecoration:"none"},loading:{padding:"24px 16px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},error:{padding:"24px 16px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},mediaGrid:{marginBottom:"8px",borderRadius:"10px",overflow:"hidden",border:"1px solid var(--line)"},mediaImg:{display:"block",width:"100%",objectFit:"cover",maxHeight:"260px"},mediaVideo:{display:"block",width:"100%",maxHeight:"260px",background:"#000"},article:{maxWidth:"560px",margin:"0 auto",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"280px"},aMeta:{padding:"10px 14px 0"},aTweetTitle:{fontSize:"20px",fontWeight:"800",letterSpacing:"-0.3px",color:"var(--ink)",lineHeight:"1.3",marginBottom:"8px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},aAvatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},aAuthorName:{fontSize:"14px",fontWeight:"700",color:"var(--ink)",lineHeight:"1.3"},aAuthorSub:{fontSize:"13px",color:"var(--muted)",lineHeight:"1.3"},aDivider:{border:"none",borderTop:"1px solid var(--line)",margin:"0"},aBody:{padding:"4px 14px 16px"},bH1:{fontSize:"22px",fontWeight:"800",letterSpacing:"-0.4px",color:"var(--ink)",lineHeight:"1.25",margin:"16px 0 6px"},bH2:{fontSize:"18px",fontWeight:"700",letterSpacing:"-0.2px",color:"var(--ink)",lineHeight:"1.3",margin:"14px 0 4px"},bP:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.65",marginBottom:"12px",marginTop:"0"},bSpacer:{height:"4px",display:"block"},bQuote:{borderLeft:"3px solid var(--line)",padding:"2px 12px",margin:"12px 0",color:"var(--muted)",fontSize:"15px",lineHeight:"1.6"},bHr:{border:"none",borderTop:"1px solid var(--line)",margin:"14px 0"},bImg:{width:"100%",display:"block",borderRadius:"8px",margin:"12px 0"},bUl:{margin:"8px 0 12px",paddingLeft:"24px"},bOl:{margin:"8px 0 12px",paddingLeft:"24px"},bLi:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.6",marginBottom:"4px"},bTweet:{display:"flex",alignItems:"center",gap:"10px",border:"1px solid var(--line)",borderRadius:"10px",padding:"10px 14px",margin:"12px 0",color:"var(--muted)",fontSize:"14px",textDecoration:"none"},bMdPre:{borderRadius:"8px",margin:"10px 0",overflow:"auto",background:"var(--paper-3, var(--field))",padding:"12px 14px"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"12px",lineHeight:"1.6",color:"var(--ink)",background:"transparent",display:"block"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:"var(--paper-3, var(--field))",padding:"1px 5px",borderRadius:"4px",color:"var(--ink)"},qtBadge:{fontSize:"11px",color:"var(--muted)",display:"inline-flex",alignItems:"center",gap:"2px",marginLeft:"4px",letterSpacing:"0.03em",flexShrink:0},lightboxBackdrop:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.92)",display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},lightboxContent:{display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",maxWidth:"90vw",maxHeight:"90vh"},lightboxToolbar:{display:"flex",alignItems:"center",gap:"10px",alignSelf:"flex-end"},lightboxImg:{maxWidth:"88vw",maxHeight:"80vh",objectFit:"contain",borderRadius:"6px",display:"block"},lightboxNav:{display:"flex",gap:"12px",alignItems:"center"},lightboxNavBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"20px",cursor:"pointer",borderRadius:"50%",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"16px",cursor:"pointer",borderRadius:"50%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxLink:{color:"rgba(255,255,255,0.7)",textDecoration:"none",fontSize:"14px"},lightboxCounter:{color:"rgba(255,255,255,0.6)",fontSize:"13px"}};function mm(e,t,n){const r={};return n&&n.forEach((l,s)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${s}`)}),r}function Nn(e,t,n){return e&&n[e]?n[e]:t||null}function ld(){return i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:i.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z"})})}function va(e,t,...n){var r;if(e.fromIndex!=null&&e.toIndex!=null)return{s:e.fromIndex,e:e.toIndex};if(((r=e.indices)==null?void 0:r.length)===2)return{s:e.indices[0],e:e.indices[1]};if(t)for(const l of n){if(!l)continue;const s=t.indexOf(l);if(s!==-1)return{s,e:s+l.length}}return null}function sd(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=va(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function id(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=va(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const Oo=/https?:\/\/[^\s<>"'\])]+/g,gm=/[.,;:!?)()]+$/;function Pl(e,t){const n=[];let r=0,l;for(Oo.lastIndex=0;(l=Oo.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let s=l[0].replace(gm,"");n.push(i.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:t,children:s},l.index));const a=l[0].slice(s.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(rsd(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>id(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return Pl(bo(e),$.link);const l=new Set([0,e.length]);for(const o of r)o.s>=0&&o.s<=e.length&&l.add(o.s),o.e>=0&&o.e<=e.length&&l.add(o.e);for(const[o,u]of n)o>=0&&o<=e.length&&l.add(o),u>=0&&u<=e.length&&l.add(u);const s=(o,u)=>n.some(([c,g])=>c<=o&&g>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1];if(s(o,c))return null;const g=e.slice(o,c),m=r.filter(y=>y.s<=o&&y.e>=c),d=m.find(y=>y.kind==="url");if(d)return i.jsx("a",{href:d.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:d.display||g},u);const k=m.find(y=>y.kind==="mention");return k?i.jsx("a",{href:`https://x.com/${k.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:g},u):i.jsx("span",{children:Pl(bo(g),$.link)},u)}).filter(o=>o!==null)}function ym(e,t,n,r){if(!e)return null;t=t||[],n=n||[],r=r||[];const l=[];for(const o of t)o.length>0&&l.push({s:o.offset,e:o.offset+o.length,kind:"style",style:o.style});for(const o of n){const u=sd(o,e);u&&l.push(u)}for(const o of r){const u=id(o,e);u&&l.push(u)}if(l.length===0)return Pl(e,$.link);const s=new Set([0,e.length]);for(const o of l)o.s>=0&&o.s<=e.length&&s.add(o.s),o.e>=0&&o.e<=e.length&&s.add(o.e);const a=[...s].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1],g=l.filter(w=>w.s<=o&&w.e>=c),m=e.slice(o,c);let d;if(m.includes(` +`):null;d.current(D,null,Ye,J)}async function te(N,C=null){if(!N.locator.trim())return;const F=t,M=N.locator.trim(),H=N.quality||"best";y(G=>G.map(Q=>Q.id===N.id?{...Q,status:"submitting",error:null}:Q));try{const Q=await ih(F,M,H,{ublock_enabled:E,reader_mode:S,cookie_ext_enabled:j});y(K=>K.map(R=>R.id===N.id?{...R,status:"running",jobUid:Q.job_uid,archiveId:F}:R)),b(N.id,Q.job_uid,M,F,C)}catch(G){const Q=G.message||"Submission failed.";y(K=>K.map(R=>R.id===N.id?{...R,status:"failed",error:Q}:R)),d.current(Q,M),W(C,"failed",M)}}function Z(){var F,M;const N=k.filter(H=>H.status==="idle"&&H.locator.trim());if(N.length===0)return;const C=N.length>1?((F=crypto.randomUUID)==null?void 0:F.call(crypto))??`batch-${Date.now()}`:null;C&&c.current.set(C,{total:N.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]}),N.forEach(H=>te(H,C)),(M=s.current)==null||M.close()}function ne(){y(N=>[...N,Wn()])}function Se(N){clearTimeout(u.current.get(N)),u.current.delete(N),y(C=>{const F=C.filter(M=>M.id!==N);return F.length===0?[Wn()]:F})}function Te(N){y(C=>C.map(F=>F.id===N?{...F,status:"idle",error:null}:F))}function xe(N,C){if(clearTimeout(u.current.get(N)),y(M=>M.map(H=>H.id===N?{...H,locator:C,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:H)),!Zc(C))return;const F=setTimeout(async()=>{u.current.delete(N),y(M=>M.map(H=>H.id===N?{...H,probeState:"probing"}:H));try{const M=await ah(g.current,C.trim());y(H=>H.map(G=>{if(G.id!==N||G.locator!==C)return G;const Q=M.qualities??[],K=M.has_audio??!1,R=Q.length===0&&K?"audio":"best";return{...G,probeState:"done",probeQualities:Q,probeHasAudio:K,quality:R}}))}catch{y(M=>M.map(H=>H.id===N?{...H,probeState:"idle",probeQualities:null}:H))}},600);u.current.set(N,F)}function z(N,C){y(F=>F.map(M=>M.id===N?{...M,quality:C}:M))}const _=k.filter(N=>N.status==="idle"&&N.locator.trim()).length,B=Ro(k);return i.jsx("dialog",{ref:s,className:"capture-dialog",children:i.jsxs("div",{className:"capture-dialog-inner",children:[i.jsxs("div",{className:"capture-dialog-header",children:[i.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),i.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var N;return(N=s.current)==null?void 0:N.close()},"aria-label":"Close",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),i.jsx("div",{className:"capture-rows",children:k.map((N,C)=>i.jsx(Wh,{item:N,autoFocus:C===k.length-1&&N.status==="idle",onLocatorChange:F=>xe(N.id,F),onQualityChange:F=>z(N.id,F),onRemove:()=>Se(N.id),onReset:()=>Te(N.id),onSubmit:Z},N.id))}),i.jsxs("button",{type:"button",className:"capture-add-row",onClick:ne,children:[i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),i.jsxs("div",{className:"capture-advanced",children:[i.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>L(N=>!N),"aria-expanded":w,children:[i.jsx("svg",{className:`capture-chevron${w?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),w&&i.jsxs("div",{className:"capture-advanced-panel",children:[i.jsxs("label",{className:"capture-ext-row",children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":E,className:`ext-toggle ext-toggle--sm${E?" ext-toggle--on":""}`,onClick:()=>f(N=>N===null?!E:!N),"aria-label":"Toggle uBlock for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),i.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(v!=null&&v.cookie_ext_available)&&i.jsxs("span",{className:"capture-ext-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":j,className:`ext-toggle ext-toggle--sm${j?" ext-toggle--on":""}`,onClick:()=>T(N=>!N),"aria-label":"Toggle cookie banner blocking for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),i.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":S,className:`ext-toggle ext-toggle--sm${S?" ext-toggle--on":""}`,onClick:()=>O(N=>!N),"aria-label":"Toggle reader mode for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),i.jsxs("div",{className:"capture-actions",children:[i.jsx("button",{type:"button",className:"capture-submit",onClick:Z,disabled:_===0,children:_>1?`Archive ${_}`:"Archive"}),i.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var N;return(N=s.current)==null?void 0:N.close()},children:B?"Close":"Cancel"})]})]})})}function Wh({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:s,onSubmit:a}){const o=p.useRef(null),u=e.status==="submitting"||e.status==="running";p.useEffect(()=>{var g;t&&e.status==="idle"&&((g=o.current)==null||g.focus())},[t]);const c=(()=>{if(e.status==="completed"||u||!Zc(e.locator))return null;if(e.probeState==="probing")return i.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const g=e.probeQualities??[],m=e.probeHasAudio??!1;return g.length===0&&!m?i.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):g.length===0&&m?i.jsx("select",{className:"capture-quality",value:"audio",onChange:d=>r(d.target.value),"aria-label":"Video quality",children:i.jsx("option",{value:"audio",children:"Audio only"})}):i.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:d=>r(d.target.value),"aria-label":"Video quality",children:[i.jsx("option",{value:"best",children:"Best quality"}),g.map(d=>i.jsx("option",{value:d,children:d},d)),m&&i.jsx("option",{value:"audio",children:"Audio only"})]})}return null})();return i.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[i.jsxs("div",{className:"capture-row-main",children:[i.jsx(Vh,{status:e.status}),i.jsx("input",{ref:o,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · ytm:ID · tweet:ID · x:ID",value:e.locator,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"&&a()},disabled:u||e.status==="completed",autoComplete:"off",spellCheck:!1}),c,e.status==="failed"&&i.jsx("button",{type:"button",className:"capture-row-action",onClick:s,title:"Retry",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),i.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!u&&e.status!=="completed"&&e.status!=="failed"&&i.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&i.jsx("p",{className:"capture-row-error",children:e.error})]})}function Vh({status:e}){return e==="submitting"||e==="running"?i.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:i.jsx("span",{className:"cap-spinner"})}):e==="completed"?i.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?i.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):i.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function wi(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function Kt(e){return Qh(e)??""}function ed(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const zo={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function ga(e){return zo[e]??zo.other}function td(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function Kh({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,s]=p.useState(!1),o=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?i.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>s(!0),style:{objectFit:"contain"}}):i.jsx("span",{dangerouslySetInnerHTML:{__html:ga(e.source_kind)}});return i.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:u=>{u.key==="Enter"&&r()},children:[i.jsx("div",{className:"col-added",children:ed(e.archived_at)}),i.jsxs("div",{className:"col-title",children:[i.jsx("span",{className:"source-icon",children:o}),i.jsx("span",{className:"entry-title",children:Kt(e.title)||Kt(e.entry_uid)})]}),i.jsx("div",{className:"col-type",children:i.jsx("span",{className:"type-pill",children:Kt(e.entity_kind)})}),i.jsxs("div",{className:"col-size",children:[i.jsx("span",{className:"size-total",children:wi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&i.jsxs("span",{className:"size-cached-pct",title:`${wi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),i.jsx("div",{className:"url-cell col-url",children:Kt(e.original_url)})]})}function Xh({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return i.jsx("section",{id:"archive-view",className:"view is-active",children:i.jsxs("div",{className:"entry-table",children:[i.jsxs("div",{className:"entry-header-row",children:[i.jsx("div",{className:"col-added",children:"Added"}),i.jsx("div",{className:"col-title",children:"Title"}),i.jsx("div",{className:"col-type",children:"Type"}),i.jsx("div",{className:"col-size",children:"Size"}),i.jsx("div",{className:"col-url",children:"Original URL"})]}),i.jsx("div",{id:"entries-body",children:e.map(l=>i.jsx(Kh,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function Jh(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function qh({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return i.jsx("span",{className:`run-status ${t}`,children:n})}function Gh({runs:e}){const[t,n]=p.useState(null);function r(l){n(s=>s===l?null:l)}return i.jsx("section",{id:"runs-view",className:"view is-active",children:i.jsxs("table",{className:"entry-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Started"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Requested"}),i.jsx("th",{children:"Completed"}),i.jsx("th",{children:"Failed"})]})}),i.jsx("tbody",{children:e.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const s=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[i.jsxs("tr",{className:s?"run-row run-row--failed":"run-row",onClick:s?()=>r(l.run_uid):void 0,title:s?a?"Click to hide error":"Click to view error":void 0,children:[i.jsx("td",{children:Jh(l.started_at)}),i.jsxs("td",{children:[i.jsx(qh,{status:l.status}),s&&i.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"▴":"▾"})]}),i.jsx("td",{children:l.requested_count??"—"}),i.jsx("td",{children:l.completed_count??"—"}),i.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),s&&a&&i.jsx("tr",{className:"run-error-row",children:i.jsx("td",{colSpan:5,children:i.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const Yh=4;function Zh({archives:e}){const{currentUser:t}=p.useContext(Ql)??{},n=t&&(t.role_bits&Yh)!==0,[r,l]=p.useState("users"),[s,a]=p.useState([]),[o,u]=p.useState([]),[c,g]=p.useState(!1),[m,d]=p.useState(null),[k,y]=p.useState(""),[w,L]=p.useState(""),[h,f]=p.useState(""),[v,x]=p.useState(null),[j,T]=p.useState(!1),[E,S]=p.useState(""),[O,b]=p.useState(""),[W,te]=p.useState(null),[Z,ne]=p.useState(!1),Se=p.useCallback(async()=>{if(n){g(!0),d(null);try{const[_,B]=await Promise.all([xh(),jh()]);a(_),u(B)}catch(_){d(_.message)}finally{g(!1)}}},[n]);p.useEffect(()=>{Se()},[Se]);async function Te(_){const B=_.status==="active"?"disabled":"active";try{await kh(_.user_uid,B),a(N=>N.map(C=>C.user_uid===_.user_uid?{...C,status:B}:C))}catch(N){d(N.message)}}async function xe(_){if(_.preventDefault(),!k.trim()||!w){x("Username and password required");return}T(!0),x(null);try{await wh(k.trim(),w,h.trim()||void 0),y(""),L(""),f(""),await Se()}catch(B){x(B.message)}finally{T(!1)}}async function z(_){if(_.preventDefault(),!E.trim()||!O.trim()){te("Slug and name required");return}ne(!0),te(null);try{await Sh(E.trim(),O.trim()),S(""),b(""),await Se()}catch(B){te(B.message)}finally{ne(!1)}}return n?i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsxs("div",{className:"view-tabs",children:[i.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),i.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),i.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),m&&i.jsx("div",{className:"form-msg form-msg--err",children:m}),r==="users"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Users"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Username"}),i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Roles"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Actions"})]})}),i.jsx("tbody",{children:s.map(_=>i.jsxs("tr",{className:_.status==="disabled"?"admin-row-disabled":"",children:[i.jsx("td",{children:_.username}),i.jsx("td",{className:"muted",children:_.email||"—"}),i.jsx("td",{children:_.role_slugs.join(", ")||"—"}),i.jsx("td",{children:i.jsx("span",{className:`status-badge status-${_.status}`,children:_.status})}),i.jsx("td",{children:i.jsx("button",{className:"admin-action-btn",onClick:()=>Te(_),children:_.status==="active"?"Ban":"Unban"})})]},_.user_uid))})]}),i.jsx("h3",{children:"Create User"}),i.jsxs("form",{className:"admin-form",onSubmit:xe,children:[i.jsx("input",{className:"admin-input",placeholder:"Username",value:k,onChange:_=>y(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:w,onChange:_=>L(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:h,onChange:_=>f(_.target.value)}),v&&i.jsx("div",{className:"form-msg form-msg--err",children:v}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:j,children:j?"Creating…":"Create User"})]})]}),r==="roles"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Roles"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Slug"}),i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Level"}),i.jsx("th",{children:"Bit"}),i.jsx("th",{children:"Built-in"})]})}),i.jsx("tbody",{children:o.map(_=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("code",{children:_.slug})}),i.jsx("td",{children:_.name}),i.jsx("td",{children:_.level}),i.jsx("td",{children:_.bit_position}),i.jsx("td",{children:_.is_builtin?"✓":""})]},_.role_uid))})]}),i.jsx("h3",{children:"Create Custom Role"}),i.jsxs("form",{className:"admin-form",onSubmit:z,children:[i.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:E,onChange:_=>S(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:O,onChange:_=>b(_.target.value),required:!0}),W&&i.jsx("div",{className:"form-msg form-msg--err",children:W}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:Z,children:Z?"Creating…":"Create Role"})]})]}),r==="archives"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})]}):i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})}function nd({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){var x;const c=n===e.tag.full_path,[g,m]=p.useState(!1),[d,k]=p.useState(""),y=p.useRef(!1);function w(){if(g)return;const j=c?null:e.tag.full_path;r(j),l("archive")}function L(j){j.stopPropagation(),k(e.tag.slug),m(!0)}async function h(){const j=d.trim();if(!j||j===e.tag.slug){m(!1);return}try{const T=await lh(t,e.tag.tag_uid,j);s(e.tag.full_path,T.full_path),o()}catch{}finally{m(!1)}}async function f(j){var E;j.stopPropagation();const T=((E=e.children)==null?void 0:E.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(T))try{await sh(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const v={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u};return i.jsxs("li",{children:[i.jsxs("div",{className:"tag-node-row",children:[g?i.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:d,onChange:j=>k(j.target.value),onKeyDown:j=>{j.key==="Enter"&&j.currentTarget.blur(),j.key==="Escape"&&(y.current=!0,j.currentTarget.blur())},onBlur:()=>{y.current?(y.current=!1,m(!1)):h()}}):i.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:w,onDoubleClick:L,children:[u?e.tag.name:e.tag.slug,i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",onClick:j=>{j.stopPropagation(),L(j)},children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),i.jsx("button",{className:"remove tag-node-delete",title:`Delete tag ${e.tag.full_path}`,onClick:f,"aria-label":`Delete tag ${e.tag.full_path}`,children:"×"})]}),((x=e.children)==null?void 0:x.length)>0&&i.jsx("div",{className:"tag-children",children:i.jsx("ul",{className:"tag-tree-list",children:e.children.map(j=>i.jsx(nd,{node:j,...v},j.tag.tag_uid))})})]})}function em({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){return i.jsx("section",{id:"tags-view",className:"view is-active",children:i.jsxs("div",{className:"tag-tree",children:[i.jsxs("div",{className:"tag-tree-header",children:[i.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&i.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?i.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):i.jsx("ul",{className:"tag-tree-list",children:t.map(c=>i.jsx(nd,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u},c.tag.tag_uid))})]})})}const qn=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],tm=e=>{var t;return((t=qn.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function nm({archiveId:e}){const[t,n]=p.useState([]),[r,l]=p.useState(!1),[s,a]=p.useState(null),[o,u]=p.useState(null),[c,g]=p.useState(null),[m,d]=p.useState(!1),[k,y]=p.useState(null),[w,L]=p.useState(""),[h,f]=p.useState(""),[v,x]=p.useState(2),[j,T]=p.useState(!1),[E,S]=p.useState(null),[O,b]=p.useState(""),[W,te]=p.useState(2),[Z,ne]=p.useState(!1),[Se,Te]=p.useState(null),[xe,z]=p.useState(!1),[_,B]=p.useState(""),N=p.useRef(null),C=t.find(D=>D.collection_uid===o)??null,F=(C==null?void 0:C.slug)==="_default_",M=p.useCallback(async()=>{if(e){l(!0),a(null);try{const D=await Nh(e);n(D)}catch(D){a(D.message)}finally{l(!1)}}},[e]),H=p.useCallback(async D=>{if(!D){g(null);return}d(!0),y(null);try{const V=await Ch(e,D);g(V)}catch(V){y(V.message)}finally{d(!1)}},[e]);p.useEffect(()=>{M()},[M]),p.useEffect(()=>{H(o)},[o,H]),p.useEffect(()=>{xe&&N.current&&N.current.focus()},[xe]);async function G(D){D.preventDefault();const V=w.trim(),Fe=h.trim();if(!(!V||!Fe)){T(!0),S(null);try{const dt=await _h(e,V,Fe,v);L(""),f(""),x(2),await M(),u(dt.collection_uid)}catch(dt){S(dt.message)}finally{T(!1)}}}async function Q(){const D=_.trim();if(!D||!C){z(!1);return}try{await Lo(e,C.collection_uid,{name:D}),await M(),g(V=>V&&{...V,name:D})}catch(V){a(V.message)}finally{z(!1)}}async function K(D){if(C)try{await Lo(e,C.collection_uid,{default_visibility_bits:D}),await M(),g(V=>V&&{...V,default_visibility_bits:D})}catch(V){a(V.message)}}async function R(){if(C&&window.confirm(`Delete collection "${C.name}"? Entries will not be deleted.`))try{await Rh(e,C.collection_uid),u(null),g(null),await M()}catch(D){a(D.message)}}async function J(D){D.preventDefault();const V=O.trim();if(!(!V||!C)){ne(!0),Te(null);try{await Eh(e,C.collection_uid,V,W),b(""),await H(C.collection_uid)}catch(Fe){Te(Fe.message)}finally{ne(!1)}}}async function Ye(D){if(C)try{await Th(e,C.collection_uid,D),await H(C.collection_uid)}catch(V){y(V.message)}}async function Ae(D,V){if(C)try{await Ph(e,C.collection_uid,D,V),g(Fe=>Fe&&{...Fe,entries:Fe.entries.map(dt=>dt.entry_uid===D?{...dt,collection_visibility_bits:V}:dt)})}catch(Fe){y(Fe.message)}}return e?i.jsxs("div",{className:"collections-view",children:[i.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&i.jsx("div",{className:"muted",children:"Loading…"}),s&&i.jsxs("div",{className:"collections-error",children:[s," ",i.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"×"})]}),i.jsxs("div",{className:"collections-layout",children:[i.jsxs("div",{className:"collections-sidebar",children:[t.map(D=>i.jsxs("button",{className:`coll-sidebar-row${o===D.collection_uid?" is-active":""}`,onClick:()=>u(D.collection_uid),children:[i.jsx("span",{className:"coll-row-name",children:D.name}),i.jsx("span",{className:"coll-row-meta",children:tm(D.default_visibility_bits)})]},D.collection_uid)),t.length===0&&!r&&i.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),C?i.jsxs("div",{className:"coll-detail",children:[i.jsxs("div",{className:"coll-detail-header",children:[xe?i.jsx("input",{ref:N,className:"coll-rename-input",value:_,onChange:D=>B(D.target.value),onBlur:Q,onKeyDown:D=>{D.key==="Enter"&&Q(),D.key==="Escape"&&z(!1)}}):i.jsxs("h3",{className:`coll-detail-name${F?"":" coll-detail-name--editable"}`,title:F?void 0:"Click to rename",onClick:()=>{F||(B(C.name),z(!0))},children:[(c==null?void 0:c.name)??C.name,!F&&i.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!F&&i.jsx("button",{className:"coll-delete-btn",onClick:R,title:"Delete collection",children:"Delete"})]}),i.jsxs("div",{className:"coll-detail-vis",children:[i.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),i.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??C.default_visibility_bits,onChange:D=>K(Number(D.target.value)),disabled:F,children:qn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))})]}),i.jsxs("div",{className:"coll-entries-section",children:[i.jsx("div",{className:"coll-section-heading",children:"Entries"}),m&&i.jsx("div",{className:"muted",children:"Loading…"}),k&&i.jsx("div",{className:"collections-error",children:k}),!m&&c&&(c.entries.length===0?i.jsx("div",{className:"muted",children:"No entries in this collection."}):i.jsx("ul",{className:"coll-entries-list",children:c.entries.map(D=>i.jsxs("li",{className:"coll-entry-row",children:[i.jsxs("div",{className:"coll-entry-info",children:[i.jsx("span",{className:"coll-entry-title",children:D.title||D.entry_uid}),i.jsx("span",{className:"coll-entry-kind muted",children:D.source_kind})]}),i.jsxs("div",{className:"coll-entry-actions",children:[i.jsx("select",{className:"coll-entry-vis-select",value:D.collection_visibility_bits,onChange:V=>Ae(D.entry_uid,Number(V.target.value)),children:qn.map(V=>i.jsx("option",{value:V.value,children:V.label},V.value))}),!F&&i.jsx("button",{className:"coll-entry-remove",onClick:()=>Ye(D.entry_uid),title:"Remove from collection",children:"×"})]})]},D.entry_uid))}))]}),!F&&i.jsxs("form",{className:"coll-add-entry-form",onSubmit:J,children:[i.jsx("div",{className:"coll-section-heading",children:"Add entry"}),i.jsxs("div",{className:"coll-add-entry-row",children:[i.jsx("input",{className:"coll-add-entry-input",type:"text",value:O,onChange:D=>b(D.target.value),placeholder:"entry_uid",required:!0}),i.jsx("select",{className:"coll-vis-select",value:W,onChange:D=>te(Number(D.target.value)),children:qn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))}),i.jsx("button",{className:"coll-add-btn",type:"submit",disabled:Z,children:Z?"…":"Add"})]}),Se&&i.jsx("div",{className:"collections-error",style:{marginTop:4},children:Se})]})]}):i.jsx("div",{className:"coll-detail coll-detail--empty",children:i.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),i.jsxs("details",{className:"coll-create-details",children:[i.jsx("summary",{children:"+ Create collection"}),i.jsxs("form",{className:"coll-create-form",onSubmit:G,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),i.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:w,onChange:D=>{L(D.target.value),h||f(D.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),i.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:h,onChange:D=>f(D.target.value),placeholder:"my-collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),i.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:v,onChange:D=>x(Number(D.target.value)),children:qn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))})]}),E&&i.jsx("div",{className:"collections-error",children:E}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:j,children:j?"Creating…":"Create collection"})]})]})]}):i.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const rm=4;function lm({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=p.useContext(Ql)??{},s=r&&(r.role_bits&rm)!==0,a=["profile","tokens",...s?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return i.jsxs("section",{className:"admin-view",children:[i.jsx("h1",{children:"Settings"}),i.jsx("div",{className:"view-tabs",children:a.map(u=>i.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&i.jsx(sm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&i.jsx(im,{}),e==="instance"&&s&&i.jsx(am,{}),e==="cookies"&&s&&i.jsx(um,{}),e==="extensions"&&s&&i.jsx(cm,{}),e==="storage"&&s&&i.jsx(om,{archiveId:n})]})}function sm({currentUser:e,setCurrentUser:t}){const[n,r]=p.useState((e==null?void 0:e.display_name)??""),[l,s]=p.useState(!1),[a,o]=p.useState(null),[u,c]=p.useState(""),[g,m]=p.useState(""),[d,k]=p.useState(""),[y,w]=p.useState(!1),[L,h]=p.useState(null);async function f(x){x.preventDefault(),s(!0),o(null);try{await ph(n),t(j=>({...j,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(j){o({ok:!1,text:j.message})}finally{s(!1)}}async function v(x){if(x.preventDefault(),g!==d){h({ok:!1,text:"Passwords do not match."});return}w(!0),h(null);try{await mh(u,g),c(""),m(""),k(""),h({ok:!0,text:"Password changed."})}catch(j){h({ok:!1,text:j.message})}finally{w(!1)}}return i.jsxs("div",{style:{maxWidth:440},children:[i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Name"}),i.jsxs("form",{onSubmit:f,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),i.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:x=>r(x.target.value)})]}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Preferences"}),i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async x=>{const j=x.target.checked;try{await hh({humanize_slugs:j}),t(T=>({...T,humanize_slugs:j}))}catch{}}}),i.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),i.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Change Password"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),i.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:x=>c(x.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),i.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:g,onChange:x=>m(x.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),i.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:d,onChange:x=>k(x.target.value),required:!0})]}),L&&i.jsx("div",{className:`form-msg form-msg--${L.ok?"ok":"err"}`,children:L.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Changing…":"Change Password"})]})]})]})}function im(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(""),[u,c]=p.useState(!1),[g,m]=p.useState(null),d=p.useCallback(async()=>{r(!0),s(null);try{t(await gh())}catch(w){s(w.message)}finally{r(!1)}},[]);p.useEffect(()=>{d()},[d]);async function k(w){if(w.preventDefault(),!!a.trim()){c(!0);try{const L=await vh(a.trim());m(L),o(""),d()}catch(L){s(L.message)}finally{c(!1)}}}async function y(w){try{await yh(w),t(L=>L.filter(h=>h.token_uid!==w))}catch(L){s(L.message)}}return i.jsx("div",{style:{maxWidth:600},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"API Tokens"}),g&&i.jsxs("div",{className:"token-banner",children:[i.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",i.jsx("code",{children:g.raw_token}),i.jsx("button",{className:"token-dismiss",onClick:()=>m(null),children:"Dismiss"})]}),i.jsxs("form",{className:"token-create-row",onSubmit:k,children:[i.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:w=>o(w.target.value),required:!0}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&i.jsx("div",{className:"form-msg form-msg--err",children:l}),n?i.jsx("div",{className:"muted",children:"Loading…"}):i.jsxs("div",{children:[e.length===0&&i.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(w=>i.jsxs("div",{className:"token-row",children:[i.jsxs("div",{className:"token-row-info",children:[i.jsx("strong",{children:w.name}),i.jsxs("div",{className:"muted",children:["Created ",w.created_at.slice(0,10),w.last_used_at&&` · Last used ${w.last_used_at.slice(0,10)}`]})]}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>y(w.token_uid),children:"Revoke"})]},w.token_uid))]})]})})}function am(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(!1),[u,c]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await ma())}catch(m){s(m.message)}finally{r(!1)}})()},[]);async function g(m){m.preventDefault(),o(!0),c(null);try{await yi(e),c({ok:!0,text:"Saved."})}catch(d){c({ok:!1,text:d.message})}finally{o(!1)}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):e?i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Instance Settings"}),i.jsxs("form",{onSubmit:g,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([m,d])=>i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:!!e[m],onChange:k=>t(y=>({...y,[m]:k.target.checked}))}),d]},m)),i.jsxs("div",{className:"form-field",style:{marginTop:4},children:[i.jsx("label",{className:"form-label",children:"Default entry visibility"}),i.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:m=>t(d=>({...d,default_entry_visibility:Number(m.target.value)})),children:[i.jsx("option",{value:0,children:"Private"}),i.jsx("option",{value:2,children:"Unlisted"}),i.jsx("option",{value:3,children:"Public"})]})]}),u&&i.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function Ss(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n===0?0:1)} ${t[n]}`}function om({archiveId:e}){const[t,n]=p.useState("idle"),[r,l]=p.useState(null),[s,a]=p.useState(null),[o,u]=p.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function g(){n("scanning"),u(null),l(null);try{const k=await zh(e);l(k),n("scanned")}catch(k){u(k.message),n("error")}}async function m(){n("deleting"),u(null);try{const k=await Dh(e);a(k),n("done")}catch(k){u(k.message),n("error")}}const d=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Orphan Cleanup"}),i.jsxs("p",{className:"muted",style:{marginBottom:16},children:["Scan for blob files and database records that are no longer referenced by any archive entry and safely delete them."," ",i.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&i.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&i.jsx("button",{className:"btn-ghost",onClick:g,children:"Scan for orphaned blobs"}),t==="scanning"&&i.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&d&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean — nothing to remove."}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!d&&i.jsxs("div",{children:[i.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",i.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",i.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","— ",i.jsx("strong",{children:Ss(r.total_bytes)})," recoverable."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsxs("button",{className:"btn-danger",onClick:m,children:["Delete (",Ss(r.total_bytes),")"]}),i.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&i.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&s&&i.jsxs("div",{children:[i.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",i.jsx("strong",{children:Ss(s.freed_bytes)})," ","— removed ",s.deleted_files," file",s.deleted_files!==1?"s":""," ","and ",s.deleted_blob_rows," DB record",s.deleted_blob_rows!==1?"s":"","."]}),s.errors&&s.errors.length>0&&i.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[s.errors.length," file",s.errors.length!==1?"s":""," could not be deleted."]}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&i.jsxs("div",{children:[i.jsx("div",{className:"form-msg form-msg--err",children:o}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function um(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState("global"),[u,c]=p.useState(""),[g,m]=p.useState("{}"),[d,k]=p.useState(null),[y,w]=p.useState(!1),[L,h]=p.useState({});p.useEffect(()=>{f()},[]);async function f(){r(!0),s(null);try{t(await bh())}catch(S){s(S.message)}finally{r(!1)}}async function v(S){S.preventDefault();try{JSON.parse(g)}catch{k({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}w(!0),k(null);try{await Oh(a==="global"?null:u.trim(),a,g),c(""),m("{}"),o("global"),k({ok:!0,text:"Rule added."}),await f()}catch(O){k({ok:!1,text:O.message})}finally{w(!1)}}async function x(S){try{await Ah(S),await f()}catch(O){s(O.message)}}function j(S){h(O=>({...O,[S.rule_uid]:{cookiesInput:S.cookies_json,saving:!1,msg:null}}))}function T(S){h(O=>{const b={...O};return delete b[S],b})}async function E(S){const O=L[S.rule_uid];try{JSON.parse(O.cookiesInput)}catch{h(b=>({...b,[S.rule_uid]:{...b[S.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}h(b=>({...b,[S.rule_uid]:{...b[S.rule_uid],saving:!0,msg:null}}));try{await $h(S.rule_uid,{cookies_json:O.cookiesInput}),T(S.rule_uid),await f()}catch(b){h(W=>({...W,[S.rule_uid]:{...W[S.rule_uid],saving:!1,msg:{ok:!1,text:b.message}}}))}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Cookie Rules"}),i.jsx("p",{className:"muted",style:{marginBottom:12},children:"Cookies are injected into every capture network request (yt-dlp, HTTP downloads, web-page snapshots). Global rules apply to all URLs; wildcard and regex rules apply only to matching URLs."}),e&&e.length>0?i.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Pattern"}),i.jsx("th",{children:"Cookies"}),i.jsx("th",{style:{width:100},children:"Actions"})]})}),i.jsx("tbody",{children:e.map(S=>{const O=L[S.rule_uid],b=S.url_pattern?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"muted",children:[S.pattern_kind,":"]})," ",i.jsx("code",{children:S.url_pattern})]}):i.jsx("span",{className:"muted",children:"global (all URLs)"});return i.jsxs("tr",{children:[i.jsx("td",{children:b}),i.jsx("td",{children:O?i.jsxs(i.Fragment,{children:[i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:O.cookiesInput,onChange:W=>h(te=>({...te,[S.rule_uid]:{...te[S.rule_uid],cookiesInput:W.target.value}}))}),O.msg&&i.jsx("div",{className:`form-msg form-msg--${O.msg.ok?"ok":"err"}`,children:O.msg.text}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[i.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:O.saving,onClick:()=>E(S),children:O.saving?"Saving…":"Save"}),i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>T(S.rule_uid),children:"Cancel"})]})]}):i.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:S.cookies_json})}),i.jsx("td",{children:!O&&i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>j(S),children:"Edit"}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>x(S.rule_uid),children:"Del"})]})})]},S.rule_uid)})})]}):i.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),i.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Pattern type"}),i.jsxs("select",{className:"field-input",value:a,onChange:S=>o(S.target.value),children:[i.jsx("option",{value:"global",children:"Global (all URLs)"}),i.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),i.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),i.jsx("input",{className:"field-input",type:"text",value:u,onChange:S=>c(S.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:g,onChange:S=>m(S.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),d&&i.jsx("div",{className:`form-msg form-msg--${d.ok?"ok":"err"}`,children:d.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Adding…":"Add Rule"})]})]})})}function cm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(!1),[a,o]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await ma())}catch(y){o({ok:!1,text:y.message})}finally{r(!1)}})()},[]);async function u(y){s(!0),o(null);try{await yi({ublock_enabled:y}),t(w=>({...w,ublock_enabled:y})),o({ok:!0,text:"Saved."})}catch(w){o({ok:!1,text:w.message})}finally{s(!1)}}async function c(y){s(!0),o(null);try{await yi({cookie_ext_enabled:y}),t(w=>({...w,cookie_ext_enabled:y})),o({ok:!0,text:"Saved."})}catch(w){o({ok:!1,text:w.message})}finally{s(!1)}}if(n)return i.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,m=(e==null?void 0:e.ublock_enabled)??!0,d=(e==null?void 0:e.cookie_ext_available)??!1,k=(e==null?void 0:e.cookie_ext_enabled)??!0;return i.jsx("div",{children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Extensions"}),i.jsx("p",{className:"form-hint",style:{marginBottom:20},children:"Extensions run inside the browser during WebPage captures and can block ads, accept cookie banners, and more. Changes take effect on the next capture."}),i.jsxs("div",{className:"ext-grid",children:[i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!g&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":m,className:`ext-toggle${m?" ext-toggle--on":""}`,onClick:()=>u(!m),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),i.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!d&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":k,className:`ext-toggle${k?" ext-toggle--on":""}`,onClick:()=>c(!k),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",children:i.jsx("span",{className:"ext-toggle-knob"})})]})})]}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const Do={0:"Private",1:"Public",2:"Users only",3:"Public"},dm=()=>i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function fm({archiveId:e,selectedEntry:t,detail:n,onTagFilterSet:r,tagNodes:l,onTagsRefresh:s,onEntryTitleChange:a,onEntryDeleted:o,humanizeTags:u,onDetailRefresh:c,onOpenPreview:g,onPlay:m}){const[d,k]=p.useState([]),[y,w]=p.useState(""),[L,h]=p.useState([]),[f,v]=p.useState(""),x=p.useRef(0),j=p.useRef(!1),[T,E]=p.useState(!1),[S,O]=p.useState(""),[b,W]=p.useState("idle"),[te,Z]=p.useState(""),ne=p.useRef(null);p.useEffect(()=>{const R=++x.current;if(ne.current&&(clearInterval(ne.current),ne.current=null),W("idle"),Z(""),!t||!e){k([]),h([]);return}E(!1),O(""),j.current=!1,k([]),Promise.all([Vr(e,t.entry_uid),Lh(e,t.entry_uid)]).then(([J,Ye])=>{R===x.current&&(k(J),h(Ye))}).catch(()=>{})},[t,e]),p.useEffect(()=>()=>{clearInterval(ne.current)},[]);async function Se(){const R=S.trim()||null;try{await eh(e,t.entry_uid,R),a==null||a(t.entry_uid,R)}catch{}finally{E(!1)}}async function Te(){const R=y.trim();if(!(!R||!t))try{await th(e,t.entry_uid,R),w(""),v("");const J=await Vr(e,t.entry_uid);k(J),s()}catch(J){v(J.message)}}async function xe(R){try{await nh(e,t.entry_uid,R);const J=await Vr(e,t.entry_uid);k(J),s()}catch{}}async function z(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await rh(e,t.entry_uid),o==null||o(t.entry_uid)}catch{}}async function _(){if(!t||!e||b==="running")return;const R=x.current,J=t.entry_uid;W("running"),Z("");try{const{job_uid:Ye}=await Ih(e,J);if(x.current!==R)return;ne.current=setInterval(async()=>{try{const Ae=await Yc(e,Ye);if(Ae.status==="completed"){if(clearInterval(ne.current),ne.current=null,x.current!==R)return;W("done");const D=await Vr(e,J);if(x.current!==R)return;k(D),c==null||c()}else if(Ae.status==="failed"){if(clearInterval(ne.current),ne.current=null,x.current!==R)return;W("error"),Z(Ae.error_text||"Re-archive failed.")}}catch{if(clearInterval(ne.current),ne.current=null,x.current!==R)return;W("error"),Z("Network error while polling.")}},500)}catch(Ye){if(x.current!==R)return;W("error"),Z(Ye.message||"Failed to start re-archive.")}}const B=n?[["Added",ed(n.summary.archived_at)],["Source",n.summary.source_kind],["Type",n.summary.entity_kind],["Visibility",Do[n.summary.visibility]??n.summary.visibility],["Root",n.structured_root_relpath]]:[],N=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),C=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),F=n?n.artifacts.findIndex(R=>R.artifact_role==="primary_media"):-1,M=F>=0?n.artifacts[F]:null,H=M?M.relpath.split(".").pop().toLowerCase():"",G=M&&N.has(H),Q=F>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${F}`:null,K=n&&!G&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread"||M&&C.has(H));return i.jsxs("aside",{className:"context-rail",children:[i.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?n?i.jsxs(i.Fragment,{children:[T?i.jsx("input",{className:"rail-title-input",autoFocus:!0,value:S,onChange:R=>O(R.target.value),onKeyDown:R=>{R.key==="Enter"&&R.currentTarget.blur(),R.key==="Escape"&&(j.current=!0,R.currentTarget.blur())},onBlur:()=>{j.current?E(!1):Se(),j.current=!1}}):i.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{O(n.summary.title??""),E(!0)},children:[Kt(n.summary.title)||Kt(n.summary.entry_uid),i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),n.summary.original_url&&i.jsxs("a",{className:"url-tile",href:n.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[i.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:ga(n.summary.source_kind)}}),i.jsx("span",{className:"u-text",children:n.summary.original_url}),i.jsx("span",{className:"ext",children:i.jsx(dm,{})})]}),G&&m&&i.jsx("button",{className:"rail-preview-btn",onClick:()=>m(Q,t),children:"▶ Play"}),K&&g&&i.jsx("button",{className:"rail-preview-btn",onClick:g,children:"Preview"}),i.jsx("div",{className:"meta-list",children:B.filter(([,R])=>R!=null&&R!=="").map(([R,J])=>i.jsxs("div",{className:"meta-item",children:[i.jsx("span",{className:"meta-k",children:R}),i.jsx("span",{className:`meta-v${R==="Root"?" mono":""}`,children:Kt(J)})]},R))}),n.artifacts.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",i.jsx("span",{className:"num",children:n.artifacts.length})]}),i.jsx("ul",{className:"artifact-list",children:n.artifacts.map((R,J)=>i.jsx("li",{children:i.jsxs("a",{href:`/api/archives/${e}/entries/${n.summary.entry_uid}/artifacts/${J}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[i.jsx("span",{className:"artifact-name",children:R.artifact_role.replace(/_/g," ")}),i.jsx("span",{className:"artifact-size",children:R.byte_size!=null?wi(R.byte_size):"—"})]})},J))})]})]}):i.jsx("p",{className:"tags-empty",children:"Loading…"}):i.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Tags"}),d.length===0?i.jsx("p",{className:"tags-empty",children:"No tags yet."}):i.jsx("div",{className:"tags-wrap",children:d.map(R=>i.jsxs("span",{className:"tag-pill",title:R.full_path,children:[u?td(R.full_path):R.full_path,i.jsx("button",{className:"remove",title:`Remove tag ${R.full_path}`,onClick:()=>xe(R.tag_uid),children:"×"})]},R.tag_uid))}),f&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:f}),i.jsxs("div",{className:"tag-input-wrap",children:[i.jsx("span",{className:"hash",children:"/"}),i.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:y,onChange:R=>w(R.target.value),onKeyDown:R=>{R.key==="Enter"&&Te()}}),i.jsx("button",{className:"tag-add-btn",onClick:Te,children:"Add"})]})]}),L.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Collections"}),L.map(R=>i.jsxs("div",{className:"coll-row",children:[i.jsx("span",{className:"coll-name",children:R.collection_uid}),i.jsx("span",{className:"vis-badge",children:Do[R.visibility_bits]??`bits:${R.visibility_bits}`})]},R.collection_uid))]}),n&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread")&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Actions"}),i.jsx("button",{className:"rail-rearchive-btn",onClick:_,disabled:b==="running",children:b==="running"?"Re-archiving…":"Re-archive"}),b==="done"&&i.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),b==="error"&&i.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:te})]}),i.jsx("div",{className:"rail-delete-zone",children:i.jsx("button",{className:"rail-delete-btn",onClick:z,children:"Delete entry"})})]})]})}function pm({src:e}){const t=p.useRef(null);return p.useEffect(()=>{t.current&&t.current.load()},[e]),i.jsx("div",{className:"preview-video-wrap",style:{background:"#111",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"240px"},children:e?i.jsxs("video",{ref:t,controls:!0,autoPlay:!1,style:{width:"100%",maxHeight:"100%",display:"block"},children:[i.jsx("source",{src:e}),"Your browser does not support the video element."]}):i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function Io({src:e,type:t,title:n,originalUrl:r}){const l=r||e,s=n||null;return i.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsxs("div",{className:"preview-iframe-toolbar",style:{display:"flex",flexDirection:"column",gap:"2px",padding:"6px 12px",borderBottom:"1px solid var(--line-soft)",background:"var(--paper-2)",flexShrink:0},children:[s&&i.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{fontSize:"0.78rem",color:"var(--accent)",textDecoration:"none",whiteSpace:"nowrap",fontFamily:"var(--sans)",flexShrink:0},children:t==="pdf"?"Open PDF ↗":"Open in new tab ↗"})]})]}),i.jsx("iframe",{src:e,sandbox:"allow-same-origin allow-popups",allow:"autoplay 'none'",referrerPolicy:"no-referrer",style:{flex:1,border:"none",width:"100%",minHeight:0},title:s||(t==="pdf"?"PDF preview":"Page preview")})]})}function hm({src:e,alt:t}){return i.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:i.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function rd(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function bo(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const $={card:{background:"var(--paper)",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},threadOuter:{border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},tweetRow:{display:"flex",gap:"10px",padding:"10px 12px"},tweetRowThread:{display:"flex",gap:"10px",padding:"10px 12px 0"},leftCol:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:"36px"},rightCol:{flex:1,minWidth:0,paddingBottom:"8px"},avatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},avatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},threadLine:{flex:1,width:"2px",background:"var(--line-soft, var(--line))",margin:"4px 0",minHeight:"12px",borderRadius:"1px"},authorRow:{display:"flex",alignItems:"baseline",gap:"4px",flexWrap:"wrap",marginBottom:"4px",lineHeight:"1.3"},authorName:{fontWeight:"700",fontSize:"14px",color:"var(--ink)"},authorHandle:{fontSize:"13px",color:"var(--muted)"},datePart:{fontSize:"13px",color:"var(--muted)"},tweetText:{fontSize:"14px",lineHeight:"1.5",color:"var(--ink)",whiteSpace:"pre-line",marginBottom:"8px",wordBreak:"break-word"},stats:{display:"flex",gap:"12px",fontSize:"13px",color:"var(--muted)"},link:{color:"var(--accent)",textDecoration:"none"},loading:{padding:"24px 16px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},error:{padding:"24px 16px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},mediaGrid:{marginBottom:"8px",borderRadius:"10px",overflow:"hidden",border:"1px solid var(--line)"},mediaImg:{display:"block",width:"100%",objectFit:"cover",maxHeight:"260px"},mediaVideo:{display:"block",width:"100%",maxHeight:"260px",background:"#000"},article:{maxWidth:"560px",margin:"0 auto",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"280px"},aMeta:{padding:"10px 14px 0"},aTweetTitle:{fontSize:"20px",fontWeight:"800",letterSpacing:"-0.3px",color:"var(--ink)",lineHeight:"1.3",marginBottom:"8px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},aAvatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},aAuthorName:{fontSize:"14px",fontWeight:"700",color:"var(--ink)",lineHeight:"1.3"},aAuthorSub:{fontSize:"13px",color:"var(--muted)",lineHeight:"1.3"},aDivider:{border:"none",borderTop:"1px solid var(--line)",margin:"0"},aBody:{padding:"4px 14px 16px"},bH1:{fontSize:"22px",fontWeight:"800",letterSpacing:"-0.4px",color:"var(--ink)",lineHeight:"1.25",margin:"16px 0 6px"},bH2:{fontSize:"18px",fontWeight:"700",letterSpacing:"-0.2px",color:"var(--ink)",lineHeight:"1.3",margin:"14px 0 4px"},bP:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.65",marginBottom:"12px",marginTop:"0"},bSpacer:{height:"4px",display:"block"},bQuote:{borderLeft:"3px solid var(--line)",padding:"2px 12px",margin:"12px 0",color:"var(--muted)",fontSize:"15px",lineHeight:"1.6"},bHr:{border:"none",borderTop:"1px solid var(--line)",margin:"14px 0"},bImg:{width:"100%",display:"block",borderRadius:"8px",margin:"12px 0"},bUl:{margin:"8px 0 12px",paddingLeft:"24px"},bOl:{margin:"8px 0 12px",paddingLeft:"24px"},bLi:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.6",marginBottom:"4px"},bTweet:{display:"flex",alignItems:"center",gap:"10px",border:"1px solid var(--line)",borderRadius:"10px",padding:"10px 14px",margin:"12px 0",color:"var(--muted)",fontSize:"14px",textDecoration:"none"},bMdPre:{borderRadius:"8px",margin:"10px 0",overflow:"auto",background:"var(--paper-3, var(--field))",padding:"12px 14px"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"12px",lineHeight:"1.6",color:"var(--ink)",background:"transparent",display:"block"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:"var(--paper-3, var(--field))",padding:"1px 5px",borderRadius:"4px",color:"var(--ink)"},qtBadge:{fontSize:"11px",color:"var(--muted)",display:"inline-flex",alignItems:"center",gap:"2px",marginLeft:"4px",letterSpacing:"0.03em",flexShrink:0},lightboxBackdrop:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.92)",display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},lightboxContent:{display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",maxWidth:"90vw",maxHeight:"90vh"},lightboxToolbar:{display:"flex",alignItems:"center",gap:"10px",alignSelf:"flex-end"},lightboxImg:{maxWidth:"88vw",maxHeight:"80vh",objectFit:"contain",borderRadius:"6px",display:"block"},lightboxNav:{display:"flex",gap:"12px",alignItems:"center"},lightboxNavBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"20px",cursor:"pointer",borderRadius:"50%",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"16px",cursor:"pointer",borderRadius:"50%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxLink:{color:"rgba(255,255,255,0.7)",textDecoration:"none",fontSize:"14px"},lightboxCounter:{color:"rgba(255,255,255,0.6)",fontSize:"13px"}};function mm(e,t,n){const r={};return n&&n.forEach((l,s)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${s}`)}),r}function Nn(e,t,n){return e&&n[e]?n[e]:t||null}function ld(){return i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:i.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z"})})}function va(e,t,...n){var r;if(e.fromIndex!=null&&e.toIndex!=null)return{s:e.fromIndex,e:e.toIndex};if(((r=e.indices)==null?void 0:r.length)===2)return{s:e.indices[0],e:e.indices[1]};if(t)for(const l of n){if(!l)continue;const s=t.indexOf(l);if(s!==-1)return{s,e:s+l.length}}return null}function sd(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=va(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function id(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=va(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const Oo=/https?:\/\/[^\s<>"'\])]+/g,gm=/[.,;:!?)()]+$/;function Pl(e,t){const n=[];let r=0,l;for(Oo.lastIndex=0;(l=Oo.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let s=l[0].replace(gm,"");n.push(i.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:t,children:s},l.index));const a=l[0].slice(s.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(rsd(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>id(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return Pl(bo(e),$.link);const l=new Set([0,e.length]);for(const o of r)o.s>=0&&o.s<=e.length&&l.add(o.s),o.e>=0&&o.e<=e.length&&l.add(o.e);for(const[o,u]of n)o>=0&&o<=e.length&&l.add(o),u>=0&&u<=e.length&&l.add(u);const s=(o,u)=>n.some(([c,g])=>c<=o&&g>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1];if(s(o,c))return null;const g=e.slice(o,c),m=r.filter(y=>y.s<=o&&y.e>=c),d=m.find(y=>y.kind==="url");if(d)return i.jsx("a",{href:d.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:d.display||g},u);const k=m.find(y=>y.kind==="mention");return k?i.jsx("a",{href:`https://x.com/${k.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:g},u):i.jsx("span",{children:Pl(bo(g),$.link)},u)}).filter(o=>o!==null)}function ym(e,t,n,r){if(!e)return null;t=t||[],n=n||[],r=r||[];const l=[];for(const o of t)o.length>0&&l.push({s:o.offset,e:o.offset+o.length,kind:"style",style:o.style});for(const o of n){const u=sd(o,e);u&&l.push(u)}for(const o of r){const u=id(o,e);u&&l.push(u)}if(l.length===0)return Pl(e,$.link);const s=new Set([0,e.length]);for(const o of l)o.s>=0&&o.s<=e.length&&s.add(o.s),o.e>=0&&o.e<=e.length&&s.add(o.e);const a=[...s].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1],g=l.filter(w=>w.s<=o&&w.e>=c),m=e.slice(o,c);let d;if(m.includes(` `)){const w=m.split(` `);d=w.flatMap((L,h)=>hw.kind==="style"&&w.style==="Code")&&(d=i.jsx("code",{style:$.iCode,children:d})),g.some(w=>w.kind==="style"&&w.style==="Bold")&&(d=i.jsx("strong",{children:d})),g.some(w=>w.kind==="style"&&w.style==="Italic")&&(d=i.jsx("em",{children:d})),g.some(w=>w.kind==="style"&&w.style==="Underline")&&(d=i.jsx("u",{children:d})),g.some(w=>w.kind==="style"&&w.style==="Strikethrough")&&(d=i.jsx("s",{children:d}));const k=g.find(w=>w.kind==="url");if(k){const w=/^https?:\/\/t\.co\//i.test(d);d=i.jsx("a",{href:k.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:w?k.display:d})}const y=g.find(w=>w.kind==="mention");return y&&(d=i.jsx("a",{href:`https://x.com/${y.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:d})),i.jsx("span",{children:typeof d=="string"?Pl(d,$.link):d},u)})}function xm(e,t,n){const r=e.resolved_entities||[];return r.length===0?null:r.map((l,s)=>{var a;switch(l.type){case"divider":return i.jsx("hr",{style:$.bHr},s);case"media":{const o=Nn(l.local_path,l.url,t);return o?i.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:u=>{var c;!u.metaKey&&!u.ctrlKey&&(u.preventDefault(),(c=n==null?void 0:n.onImgClick)==null||c.call(n,o))},children:i.jsx("img",{src:o,style:$.bImg,loading:"lazy",alt:""})},s):null}case"tweet":return l.tweet_id?i.jsxs("a",{href:`https://x.com/i/status/${l.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:$.bTweet,children:[i.jsx(ld,{}),"View post on X"]},s):null;case"link":return l.url?i.jsx("p",{style:$.bP,children:i.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",style:$.link,children:l.url})},s):null;case"markdown":{const o=l.markdown??((a=l.data)==null?void 0:a.markdown)??"";return i.jsx("pre",{style:$.bMdPre,children:i.jsx("code",{style:$.bMdCode,children:o})},s)}case"emoji":return l.url?i.jsx("img",{src:l.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},s):null;default:return null}})}function Ns(e,t,n,r){const l=e.type||"",s=e.text||"",a=e.inline_style_ranges||[],o=e.data||{},u=ym(s,a,o.urls||[],o.mentions||[]);switch(l){case"header-one":return i.jsx("h1",{style:$.bH1,children:u},t);case"header-two":{const c=s.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return c?i.jsxs("a",{href:`https://x.com/i/status/${c[1]}`,target:"_blank",rel:"noopener noreferrer",style:$.bTweet,children:[i.jsx(ld,{}),"View post on X"]},t):i.jsx("h2",{style:$.bH2,children:u},t)}case"unstyled":return s.trim()?i.jsx("p",{style:$.bP,children:u},t):i.jsx("span",{style:$.bSpacer},t);case"blockquote":return i.jsx("blockquote",{style:$.bQuote,children:u},t);case"unordered-list-item":case"ordered-list-item":return i.jsx("li",{style:$.bLi,children:u},t);case"atomic":return i.jsx("span",{children:xm(e,n,r)},t);default:return s?i.jsx("p",{style:$.bP,children:u},t):null}}function wm(e,t,n){const r=[];let l=0;for(;ll(null)}),g&&i.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:d=>{!d.metaKey&&!d.ctrlKey&&(d.preventDefault(),l(g))},children:i.jsx("img",{src:g,style:$.aCover,alt:"Article cover"})}),i.jsxs("div",{style:$.aMeta,children:[e.title&&i.jsx("div",{style:$.aTweetTitle,children:e.title}),i.jsxs("div",{style:$.aAuthorRow,children:[m?i.jsx("img",{src:m,style:$.aAvatar,alt:a.name||""}):i.jsx("div",{style:$.aAvatarPh}),i.jsxs("div",{children:[i.jsx("div",{style:$.aAuthorName,children:a.name||a.screen_name||"Unknown"}),c&&i.jsx("div",{style:$.aAuthorSub,children:c})]})]})]}),i.jsx("hr",{style:$.aDivider}),i.jsx("div",{style:$.aBody,children:wm(e.blocks||[],n,{onImgClick:l})})]})}function jm({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return i.jsx("a",{href:e[0].src,target:"_blank",rel:"noopener noreferrer",style:{display:"block"},onClick:l=>{!l.metaKey&&!l.ctrlKey&&(l.preventDefault(),t(0))},children:i.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:$.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return i.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,s)=>i.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&s===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(s))},children:i.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},s))})}function ad({items:e,startIndex:t,onClose:n}){const[r,l]=p.useState(t);p.useEffect(()=>{const a=o=>{(o.key==="Escape"||o.key==="ArrowLeft"||o.key==="ArrowRight")&&(o.stopPropagation(),o.preventDefault()),o.key==="Escape"&&n(),o.key==="ArrowRight"&&l(u=>Math.min(u+1,e.length-1)),o.key==="ArrowLeft"&&l(u=>Math.max(u-1,0))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n,e.length]);const s=e[r];return i.jsx("div",{style:$.lightboxBackdrop,onClick:n,children:i.jsxs("div",{style:$.lightboxContent,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{style:$.lightboxToolbar,children:[e.length>1&&i.jsxs("span",{style:$.lightboxCounter,children:[r+1," / ",e.length]}),i.jsx("a",{href:s.src,target:"_blank",rel:"noopener noreferrer",style:$.lightboxLink,title:"Open in new tab",children:"↗"}),i.jsx("button",{style:$.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),i.jsx("img",{src:s.src,alt:s.alt||"",style:$.lightboxImg}),e.length>1&&i.jsxs("div",{style:$.lightboxNav,children:[i.jsx("button",{style:$.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),i.jsx("button",{style:$.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function $o({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var f,v;const[l,s]=p.useState(null),a=e.author||{},o=e.created_at_secs?rd(e.created_at_secs):"",u=e.entities||{},c=Nn(a.avatar_local_path,a.avatar_url,r),g=t&&!n,m=e.is_quote_status===!0,d=t?$.tweetRowThread:$.tweetRow,k=e.full_text||"",y=((v=(f=e.extended_entities)==null?void 0:f.media)!=null&&v.length?e.extended_entities.media:u.media)||[],w=[],L=[];for(const x of y)if(x.type==="photo"){const j=Nn(x.local_path,x.media_url_https,r);j&&w.push({kind:"photo",src:j,alt:x.alt_text||""})}else if(x.type==="video"||x.type==="animated_gif"){const j=x.local_path&&r[x.local_path]||(()=>{var E,S;return(S=(((E=x.video_info)==null?void 0:E.variants)||[]).filter(O=>O.content_type==="video/mp4").sort((O,b)=>(b.bitrate||0)-(O.bitrate||0))[0])==null?void 0:S.url})();j&&L.push({kind:x.type==="animated_gif"?"gif":"video",src:j})}const h=[];for(const x of y){if(!x.url||!(x.type==="photo"?w.some(E=>E.src===Nn(x.local_path,x.media_url_https,r)):L.length>0))continue;const T=va(x,k,x.url);T&&h.push([T.s,T.e])}return i.jsxs(i.Fragment,{children:[l!==null&&i.jsx(ad,{items:w,startIndex:l,onClose:()=>s(null)}),i.jsxs("div",{style:d,children:[i.jsxs("div",{style:$.leftCol,children:[c?i.jsx("img",{src:c,style:$.avatar,alt:a.name||""}):i.jsx("div",{style:$.avatarPh}),g&&i.jsx("div",{style:$.threadLine})]}),i.jsxs("div",{style:$.rightCol,children:[i.jsxs("div",{style:$.authorRow,children:[i.jsx("span",{style:$.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&i.jsxs("span",{style:$.authorHandle,children:["@",a.screen_name]}),o&&i.jsxs("span",{style:$.datePart,children:["· ",o]}),m&&i.jsx("span",{style:$.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),i.jsx("div",{style:$.tweetText,children:vm(k,u,h)}),w.length>0&&i.jsx("div",{style:$.mediaGrid,children:i.jsx(jm,{photos:w,onOpen:x=>s(x)})}),L.map((x,j)=>i.jsx("div",{style:$.mediaGrid,children:i.jsx("video",{src:x.src,style:$.mediaVideo,controls:!0,loop:x.kind==="gif",muted:x.kind==="gif",autoPlay:x.kind==="gif"})},j)),(e.retweet_count>0||e.favorite_count>0)&&i.jsxs("div",{style:$.stats,children:[e.favorite_count>0&&i.jsxs("span",{children:["❤️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&i.jsxs("span",{children:["🔁 ",e.retweet_count.toLocaleString()]})]})]})]})]})}function Sm({archiveId:e,entryUid:t,artifacts:n,entityKind:r}){const[l,s]=p.useState(!0),[a,o]=p.useState(null),[u,c]=p.useState([]);if(p.useEffect(()=>{if(s(!0),o(null),c([]),!n||!e||!t){s(!1);return}const d=n.map((y,w)=>({...y,index:w})).filter(y=>y.artifact_role==="raw_tweet_json");if(d.length===0){o("No tweet data found."),s(!1);return}let k=!1;return Yp(e,t,d.map(y=>y.index)).then(async y=>{if(k)return;const w=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,L=j=>{var E;const T=j.full_text||"";return(((E=j.entities)==null?void 0:E.urls)||[]).map(S=>{var O;if(S.fromIndex!=null&&S.toIndex!=null)return[S.fromIndex,S.toIndex];if(((O=S.indices)==null?void 0:O.length)===2)return[S.indices[0],S.indices[1]];if(S.url){const b=T.indexOf(S.url);if(b!==-1)return[b,b+S.url.length]}return null}).filter(Boolean)},h=(j,T,E)=>j.some(([S,O])=>S<=T&&O>=E),f=new Set;for(const j of y){const T=j.full_text||"",E=L(j);let S;for(w.lastIndex=0;(S=w.exec(T))!==null;)h(E,S.index,S.index+S[0].length)||f.add(S[0])}const v=f.size>0?await Zp([...f]).catch(()=>({})):{},x=y.map(j=>{var b;const T=j.full_text||"",E=L(j),S=[];let O;for(w.lastIndex=0;(O=w.exec(T))!==null;){const W=O[0],te=v[W];te&&te!==W&&!h(E,O.index,O.index+W.length)&&S.push({url:W,expanded_url:te,display_url:(()=>{try{const Z=new URL(te);return Z.hostname+(Z.pathname.length>1?"/…":"")}catch{return te}})(),fromIndex:O.index,toIndex:O.index+W.length})}return S.length===0?j:{...j,entities:{...j.entities||{},urls:[...((b=j.entities)==null?void 0:b.urls)||[],...S]}}});k||c(x)}).catch(y=>{k||o(y.message||"Failed to load tweet.")}).finally(()=>{k||s(!1)}),()=>{k=!0}},[e,t,n]),l)return i.jsx("div",{style:$.loading,children:"Loading…"});if(a)return i.jsxs("div",{style:$.error,children:["Error: ",a]});if(u.length===0)return null;const g=mm(e,t,n);if(r==="tweet_thread")return i.jsx("div",{style:$.threadOuter,children:u.map((d,k)=>i.jsx($o,{tweet:d,isInThread:!0,isLast:k===u.length-1,artifactMap:g},d.id||k))});const m=u[0];return m.is_article&&m.article?i.jsx(km,{article:m.article,tweetAuthor:m.author,artifactMap:g}):i.jsx("div",{style:$.card,children:i.jsx($o,{tweet:m,isInThread:!1,isLast:!0,artifactMap:g})})}const Nm=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),_m=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),Cm=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]);function od({archiveId:e,entry:t,detail:n}){if(!t)return i.jsx("div",{className:"preview-panel preview-panel--empty",children:i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return i.jsx("div",{className:"preview-panel preview-panel--loading",children:i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:r,artifacts:l}=n,s=r.entry_uid,a=r.entity_kind;if(a==="tweet"||a==="tweet_thread")return i.jsx("div",{className:"preview-tweet-wrap",children:i.jsx(Sm,{archiveId:e,entryUid:s,artifacts:l,entityKind:a})});const o=l.findIndex(m=>m.artifact_role==="primary_media");if(o===-1)return i.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),l.length>0&&i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((m,d)=>i.jsxs("li",{children:[m.artifact_role,": ",m.relpath]},d))})]});const u=l[o],c=`/api/archives/${e}/entries/${s}/artifacts/${o}`,g=u.relpath.split(".").pop().toLowerCase();return Nm.has(g)?i.jsx("div",{className:"preview-panel",children:i.jsx(pm,{src:c})}):_m.has(g)?i.jsxs("div",{className:"preview-panel preview-panel--audio",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",fontFamily:"var(--sans)"},children:[i.jsx("span",{style:{fontSize:"2rem"},children:"🎵"}),i.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:r.title||s}),i.jsx("audio",{src:c,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):g==="pdf"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(Io,{src:c,type:"pdf",title:r.title,originalUrl:r.original_url})}):g==="html"||g==="htm"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(Io,{src:c,type:"page",title:r.title,originalUrl:r.original_url})}):Cm.has(g)?i.jsx("div",{className:"preview-panel",style:{height:"100%"},children:i.jsx(hm,{src:c,alt:r.title||"Image"})}):i.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((m,d)=>i.jsxs("li",{children:[m.artifact_role,": ",m.relpath]},d))})]})}function Em({archiveId:e,entry:t,detail:n,onClose:r}){var l,s;return p.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),i.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:i.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((s=n==null?void 0:n.summary)==null?void 0:s.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{className:"preview-modal-header",children:[i.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),i.jsx("a",{className:"preview-modal-newtab",href:`/preview/${e}/${t==null?void 0:t.entry_uid}`,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",children:"↗"}),i.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"×"})]}),i.jsx("div",{className:"preview-modal-body",children:i.jsx(od,{archiveId:e,entry:t,detail:n})})]})})}function Ao(e){if(!isFinite(e)||isNaN(e))return"--:--";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,"0")}`}function Tm({entry:e,src:t,archiveId:n,onClose:r}){const l=p.useRef(null),[s,a]=p.useState(!1),[o,u]=p.useState(0),[c,g]=p.useState(NaN),[m,d]=p.useState(1);p.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),g(NaN),a(!1))},[t]),p.useEffect(()=>{l.current&&(l.current.volume=m)},[m]);function k(){const f=l.current;f&&(s?f.pause():f.play().catch(()=>{}))}function y(f){const v=l.current;if(!v||!isFinite(c))return;const x=Number(f.target.value);v.currentTime=x,u(x)}function w(f){d(Number(f.target.value))}const L=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",h=(e==null?void 0:e.source_kind)||"other";return i.jsxs(i.Fragment,{children:[i.jsx("audio",{ref:l,src:t||void 0,preload:"auto",onPlay:()=>a(!0),onPause:()=>a(!1),onEnded:()=>a(!1),onTimeUpdate:()=>{var f;return u(((f=l.current)==null?void 0:f.currentTime)??0)},onLoadedMetadata:()=>{var f;return g(((f=l.current)==null?void 0:f.duration)??NaN)},onDurationChange:()=>{var f;return g(((f=l.current)==null?void 0:f.duration)??NaN)},style:{display:"none"}}),i.jsxs("div",{className:"audio-bar",style:{position:"fixed",bottom:0,left:0,right:0,zIndex:100,background:"var(--paper-3)",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",gap:"16px",padding:"0 16px",height:"56px",fontFamily:"var(--sans)"},children:[i.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[i.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:ga(h)}}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:L,children:L})]}),i.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[i.jsx("button",{onClick:k,"aria-label":s?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:s?"⏸":"▶"}),i.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:Ao(o)}),i.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:y,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),i.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:Ao(c)})]}),i.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[i.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"🔊"}),i.jsx("input",{type:"range",min:0,max:1,step:.01,value:m,onChange:w,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),i.jsx("button",{onClick:r,"aria-label":"Close audio player",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--muted)",fontSize:"1rem",lineHeight:1,marginLeft:"4px"},children:"✕"})]})]})]})}function Pm({archiveId:e,entryUid:t}){var g,m;const[n,r]=p.useState(null),[l,s]=p.useState(!0),[a,o]=p.useState(null);p.useEffect(()=>{vi(e,t).then(d=>{r(d),s(!1)}).catch(d=>{o((d==null?void 0:d.message)||"Failed to load entry"),s(!1)})},[e,t]);const u=((g=n==null?void 0:n.summary)==null?void 0:g.title)||t,c=(m=n==null?void 0:n.summary)==null?void 0:m.original_url;return i.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:"var(--paper)",fontFamily:"var(--sans)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 16px",borderBottom:"1px solid var(--line)",flexShrink:0,background:"var(--paper-2)"},children:[i.jsx("a",{href:"/",style:{color:"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),i.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),c&&i.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),i.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&i.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&i.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&i.jsx(od,{archiveId:e,entry:n.summary,detail:n})]})]})}const Lm=7e3;function Rm({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?i.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>i.jsx(Dm,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function zm(e){if(!e)return null;if(e.length<=52)return e;try{const{hostname:t,pathname:n,search:r}=new URL(e),l=n.split("/").filter(Boolean),s=(l[l.length-1]??"")+r,a=s?`${t}/…/${s}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function Dm({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=p.useState(!1),s=e.type==="warning",a=e.type==="success";p.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Lm);return()=>clearTimeout(u)},[r,e.id,t]);const o=zm(e.locator);return a?i.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✓"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsx("div",{className:"toast-btns",children:i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})})]})}):s?i.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsxs("div",{className:"toast-btns",children:[e.text&&i.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&i.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&i.jsx("p",{className:"toast-warning-detail",children:e.text||"The page was captured but one or more browser extensions were unavailable (ad-blocking or cookie-consent). Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config."})]}):i.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsxs("div",{className:"toast-btns",children:[e.text&&i.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&e.text&&i.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const Ql=p.createContext(null),Vn=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})(),Im=["archive","tags","collections","runs","admin","settings"],bm=["profile","tokens","instance","cookies","extensions","storage"];function ln(){const e=window.location.pathname.split("/").filter(Boolean),t=Im.includes(e[0])?e[0]:"archive",n=t==="settings"&&bm.includes(e[1])?e[1]:"profile",r=new URLSearchParams(window.location.search),l=r.get("q")??"",s=r.get("tag")??null,a=r.get("entry")??null;return{view:t,settingsTab:n,q:l,tag:s,entry:a}}function Om(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function $m(){const[e,t]=p.useState("loading"),[n,r]=p.useState(null);p.useEffect(()=>{(async()=>{if(await oh()){t("setup");return}const U=await fh();if(!U){t("login");return}r(U),t("authenticated")})()},[]),p.useEffect(()=>{const I=()=>{r(null),t("login")};return window.addEventListener("auth:expired",I),()=>window.removeEventListener("auth:expired",I)},[]),p.useEffect(()=>{const I=()=>{const{view:U,settingsTab:Y,q:ge,tag:Xl,entry:Jl}=ln();h(U),v(Y),j(ge),w(Xl),m(Jl),k(null)};return window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)},[]);const[l,s]=p.useState([]),[a,o]=p.useState(null),[u,c]=p.useState([]),[g,m]=p.useState(()=>ln().entry),[d,k]=p.useState(null),[y,w]=p.useState(()=>ln().tag),[L,h]=p.useState(()=>ln().view),[f,v]=p.useState(()=>ln().settingsTab),[x,j]=p.useState(()=>ln().q),[T,E]=p.useState(""),[S,O]=p.useState(!1),[b,W]=p.useState([]),[te,Z]=p.useState([]),[ne,Se]=p.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[Te,xe]=p.useState([]),z=p.useRef(0),[_,B]=p.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[N,C]=p.useState(null),F=p.useRef(0),M=p.useRef(null),H=p.useRef(!1),G=p.useRef(!0),Q=(n==null?void 0:n.humanize_slugs)??!1;p.useEffect(()=>{const I=++F.current;C(null),!(!d||!a)&&vi(a,d.entry_uid).then(U=>{I===F.current&&C(U)}).catch(()=>{})},[d,a]),p.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",ne)},[ne]);const K=p.useCallback(async(I,U,Y)=>{if(I){O(!0);try{let ge;U||Y?ge=await Gp(I,U,Y):ge=await qp(I),c(ge),E(ge.length===0?"No results":`${ge.length} result${ge.length===1?"":"s"}`)}catch{c([]),E("Search failed. Try again.")}finally{O(!1)}}},[]);p.useEffect(()=>{e==="authenticated"&&Jp().then(I=>{if(s(I),I.length>0){const U=I[0].id;o(U)}})},[e]),p.useEffect(()=>{if(a){if(G.current){G.current=!1,Promise.all([js(a).then(W),Qr(a).then(Z)]);return}w(null),k(null),m(null),Promise.all([K(a,"",null),js(a).then(W),Qr(a).then(Z)])}},[a]),p.useEffect(()=>{if(a===null)return;const I=setTimeout(()=>{K(a,x,y)},300);return()=>clearTimeout(I)},[x,a]),p.useEffect(()=>{a!==null&&(y!==null&&h("archive"),K(a,x,y))},[y,a]);const R=p.useCallback(I=>{o(I)},[]),J=p.useCallback(I=>{h(I),I==="tags"&&a&&Qr(a).then(Z)},[a]);p.useEffect(()=>{if(Vn)return;const I=Om(L,f);window.location.pathname!==I&&history.pushState(null,"",I+window.location.search)},[L,f]);const Ye=p.useCallback(I=>{m(I?I.entry_uid:null),k(I)},[]),Ae=p.useCallback(I=>{w(I)},[]),D=p.useCallback(()=>{w(null)},[]),V=p.useCallback(()=>{a&&Qr(a).then(Z)},[a]),Fe=p.useCallback((I,U)=>{y===I?w(U):y!=null&&y.startsWith(I+"/")&&w(U+y.slice(I.length))},[y]),dt=p.useCallback(I=>{(y===I||y!=null&&y.startsWith(I+"/"))&&w(null)},[y]),ud=p.useCallback((I,U)=>{c(Y=>Y.map(ge=>ge.entry_uid===I?{...ge,title:U}:ge)),k(Y=>Y&&Y.entry_uid===I?{...Y,title:U}:Y),C(Y=>Y&&Y.summary.entry_uid===I?{...Y,summary:{...Y.summary,title:U}}:Y)},[]),cd=p.useCallback(()=>{if(!a||!d)return;const I=++F.current;vi(a,d.entry_uid).then(U=>{I===F.current&&C(U)}).catch(()=>{})},[a,d]),dd=p.useCallback(I=>{c(U=>U.filter(Y=>Y.entry_uid!==I)),k(U=>(U==null?void 0:U.entry_uid)===I?null:U),m(U=>U===I?null:U)},[]);p.useEffect(()=>{if(!g||d)return;const I=u.find(U=>U.entry_uid===g);I&&k(I)},[u,g]),p.useEffect(()=>{if(Vn)return;const I=new URLSearchParams;x&&I.set("q",x),y&&I.set("tag",y),g&&I.set("entry",g);const U=I.toString(),Y=window.location.pathname+(U?"?"+U:"");window.location.pathname+window.location.search!==Y&&history.replaceState(null,"",Y)},[x,y,g]),p.useEffect(()=>{const I=U=>{var Y,ge;(U.metaKey||U.ctrlKey)&&U.key==="k"&&(U.preventDefault(),L==="archive"?((Y=M.current)==null||Y.focus(),(ge=M.current)==null||ge.select()):(H.current=!0,h("archive")))};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[L]),p.useEffect(()=>{L==="archive"&&H.current&&(H.current=!1,requestAnimationFrame(()=>{var I,U;(I=M.current)==null||I.focus(),(U=M.current)==null||U.select()}))},[L]);const fd=p.useCallback(()=>{Se(!0)},[]),pd=p.useCallback(()=>{Se(!1)},[]),hd=p.useCallback(()=>{a&&Promise.all([K(a,x,y),js(a).then(W)])},[a,x,y,K]),md=p.useCallback((I,U,Y="error",ge=null)=>{if(Y==="warning"&&_&&U)return;const Xl=++z.current;xe(Jl=>[...Jl,{id:Xl,text:I,locator:U,type:Y,headline:ge}])},[_]),gd=p.useCallback(I=>{xe(U=>U.filter(Y=>Y.id!==I))},[]),vd=p.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),B(!0),xe(I=>I.filter(U=>!(U.type==="warning"&&U.locator)))},[]),[ya,Kl]=p.useState(null),[bn,xa]=p.useState(null),yd=p.useCallback(()=>{d&&Kl(d.entry_uid)},[d]),xd=p.useCallback(()=>Kl(null),[]),wd=p.useCallback((I,U)=>{xa({src:I,entry:U})},[]),kd=p.useCallback(()=>xa(null),[]);return p.useEffect(()=>{Kl(null)},[d]),p.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!bn),()=>document.body.classList.remove("has-audio-bar")),[bn]),e==="loading"?i.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?i.jsx(Bh,{onComplete:()=>t("login")}):e==="login"?i.jsx(Mh,{onLogin:I=>{r(I),t("authenticated")}}):Vn?i.jsx(Pm,{archiveId:Vn.archiveId,entryUid:Vn.entryUid}):i.jsx(Ql.Provider,{value:{currentUser:n,setCurrentUser:r},children:i.jsxs(i.Fragment,{children:[i.jsx(Uh,{archives:l,archiveId:a,onArchiveChange:R,view:L,onViewChange:J,onCaptureClick:fd}),i.jsxs("main",{className:"app-shell",children:[i.jsxs("div",{className:"workspace",children:[L==="archive"&&i.jsxs("div",{className:"toolbar",children:[i.jsxs("div",{className:"search-field",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("circle",{cx:"11",cy:"11",r:"7"}),i.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),i.jsx("input",{ref:M,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":S,placeholder:"Search titles, URLs, types, tags…",value:x,onChange:I=>j(I.target.value)}),i.jsx("span",{className:"kbd",children:"⌘K"})]}),i.jsxs("span",{className:"result-count",children:[T&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:T.split(" ")[0]})," ",T.split(" ").slice(1).join(" ")]}),y&&i.jsxs("button",{className:"tag-filter-badge",onClick:D,children:["× ",Q?td(y):y]})]})]}),L==="archive"&&i.jsx(Xh,{entries:u,selectedEntryUid:g,onSelectEntry:Ye,archiveId:a,tagFilter:y,onClearTagFilter:D,searchQuery:x,onSearchChange:j,resultCount:T,searchBusy:S}),L==="runs"&&i.jsx(Gh,{runs:b}),L==="admin"&&i.jsx(Zh,{archives:l}),L==="tags"&&i.jsx(em,{archiveId:a,tagNodes:te,tagFilter:y,onTagFilterSet:Ae,onViewChange:J,onTagRenamed:Fe,onTagDeleted:dt,onTagsRefresh:V,humanizeTags:Q}),L==="collections"&&i.jsx(nm,{archiveId:a}),L==="settings"&&i.jsx(lm,{tab:f,onTabChange:v,archiveId:a})]}),i.jsx(fm,{archiveId:a,selectedEntry:d,detail:N,onTagFilterSet:Ae,tagNodes:te,onTagsRefresh:V,onEntryTitleChange:ud,onEntryDeleted:dd,humanizeTags:Q,onDetailRefresh:cd,onOpenPreview:yd,onPlay:wd})]}),ya&&d&&d.entry_uid===ya&&i.jsx(Em,{archiveId:a,entry:d,detail:N,onClose:xd}),bn&&i.jsx(Tm,{entry:bn.entry,src:bn.src,archiveId:a,onClose:kd}),i.jsx(Hh,{open:ne,archiveId:a,onClose:pd,onCaptured:hd,onToast:md}),i.jsx(Rm,{toasts:Te,onDismiss:gd,onIgnoreUblock:vd})]})})}Gc(document.getElementById("root")).render(i.jsx(p.StrictMode,{children:i.jsx($m,{})})); diff --git a/crates/archivr-server/static/assets/index-C89vW3ol.css b/crates/archivr-server/static/assets/index-C89vW3ol.css deleted file mode 100644 index ef6fc85..0000000 --- a/crates/archivr-server/static/assets/index-C89vW3ol.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Spectral:wght@500;600&display=swap";:root{color-scheme:light;--ink: #20251f;--muted: #6b6f66;--muted-2: #8a8d83;--paper: #f5f0e7;--paper-2: #e9e1d2;--paper-3: #fffaf0;--line: #d2c6b5;--line-soft: #e5dccd;--accent: #8d3f30;--accent-2: #b78342;--link: #245f72;--top: #141d18;--field: #fffdf7;--r: 3px;--r2: 6px;--r3: 10px;--sans: "Helvetica Neue", Helvetica, Arial, sans-serif;--serif: "Spectral", Georgia, "Times New Roman", serif;--display: "Cormorant Garamond", Georgia, serif}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:var(--paper);color:var(--ink);font-family:var(--sans);font-size:14px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select{font:inherit}.workspace,.context-rail{scrollbar-width:thin;scrollbar-color:var(--line) transparent}.workspace::-webkit-scrollbar,.context-rail::-webkit-scrollbar{width:11px;height:11px}.workspace::-webkit-scrollbar-track,.context-rail::-webkit-scrollbar-track{background:transparent}.workspace::-webkit-scrollbar-thumb,.context-rail::-webkit-scrollbar-thumb{background:var(--line);border-radius:999px;border:3px solid transparent;background-clip:padding-box}.workspace::-webkit-scrollbar-thumb:hover,.context-rail::-webkit-scrollbar-thumb:hover{background:var(--muted-2);background-clip:padding-box;border:3px solid transparent}.topbar{height:58px;display:grid;grid-template-columns:auto auto 1fr auto auto;align-items:center;gap:26px;padding:0 22px;background:var(--top);color:#efe6d6;border-bottom:3px solid var(--accent)}.brand{font-family:var(--display);font-weight:600;font-size:30px;line-height:1;letter-spacing:.01em;color:#f4ead8}.switcher{position:relative;display:inline-flex;align-items:center}.switcher select{-moz-appearance:none;appearance:none;-webkit-appearance:none;border:1px solid rgba(247,238,223,.2);background:#f7eedf0f;color:#f1e8d8;font-family:var(--sans);font-weight:550;font-size:13.5px;letter-spacing:.04em;padding:8px 32px 8px 15px;cursor:pointer;border-radius:6px;transition:background .15s ease,border-color .15s ease}.switcher select:hover{background:#f7eedf1c;border-color:#f7eedf57}.switcher:after{content:"";position:absolute;right:15px;top:50%;width:6px;height:6px;margin-top:-5px;border-right:1.2px solid #b6ab98;border-bottom:1.2px solid #b6ab98;transform:rotate(45deg);pointer-events:none}.nav{display:flex;gap:22px;justify-content:flex-end;min-width:0}.nav-link{border:0;background:transparent;color:#cdc1ad;cursor:pointer;padding:6px 0;font-size:12.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;position:relative}.nav-link:hover,.nav-link.is-active{color:#f4ead8}.nav-link.is-active:after{content:"";position:absolute;left:0;right:0;bottom:-2px;height:1px;background:var(--accent-2)}.capture-button{display:inline-flex;align-items:center;gap:8px;position:relative;overflow:hidden;border:0;background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 88%,#fff) 0%,var(--accent) 55%);color:#f7eddd;padding:10px 18px;cursor:pointer;font-size:12px;font-weight:600;letter-spacing:.15em;text-transform:uppercase;border-radius:var(--r);box-shadow:inset 0 1px #fff5e629,0 1px 2px #141d184d;transition:filter .18s ease,box-shadow .18s ease}.capture-button:hover{filter:brightness(.93);box-shadow:inset 0 1px #fff5e61f,0 2px 6px #141d1857}.capture-button:before{content:"";position:absolute;top:0;bottom:0;left:0;width:45%;background:linear-gradient(100deg,transparent 0%,rgba(255,246,232,.45) 50%,transparent 100%);transform:translate(-180%) skew(-18deg);pointer-events:none}@media (prefers-reduced-motion: no-preference){.capture-button:hover:before{animation:cap-sheen .7s ease}}@keyframes cap-sheen{0%{transform:translate(-180%) skew(-18deg)}to{transform:translate(340%) skew(-18deg)}}.app-shell{height:calc(100vh - 58px);display:grid;grid-template-columns:minmax(0,1fr) 340px}.workspace{min-width:0;overflow:auto;display:flex;flex-direction:column}.view{display:none}.view.is-active{display:block}.toolbar{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:16px;padding:12px 22px;background:color-mix(in srgb,var(--paper) 88%,white);border-bottom:1px solid var(--line-soft)}.search-field{position:relative;flex:1 1 auto;min-width:0;display:flex;align-items:center;height:42px;background:var(--field);border:1px solid var(--line);border-radius:20px;transition:border-color .15s ease,box-shadow .15s ease}.search-field:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.search-field .ico{display:grid;place-items:center;width:46px;height:100%;color:var(--muted-2);flex-shrink:0}.search-field .ico svg{width:16px;height:16px}.search-input{flex:1;min-width:0;height:100%;border:0;background:transparent;color:var(--ink);padding:0 6px 0 0;font-size:14px;letter-spacing:.01em;outline:none}.search-input::placeholder{color:var(--muted-2)}.search-field .kbd{margin-right:12px;display:inline-flex;align-items:center;padding:3px 7px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:var(--r);flex-shrink:0}.result-count{flex-shrink:0;font-size:13px;color:var(--muted);letter-spacing:.02em;white-space:nowrap}.result-count b{color:var(--ink);font-weight:600;font-variant-numeric:tabular-nums}.tag-filter-badge{display:inline-flex;align-items:center;gap:4px;background:var(--accent);color:#fff;border:0;border-radius:var(--r);font-size:12px;padding:2px 8px;cursor:pointer;margin-left:8px}.tag-filter-badge:hover{opacity:.85}.entry-table{width:100%;font-size:12.5px}.entry-header-row{display:flex;align-items:stretch;position:sticky;top:67px;z-index:2;background:color-mix(in srgb,var(--paper) 92%,white);border-bottom:1px solid var(--line-soft);color:var(--muted);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600;display:flex;align-items:center}#entries-body>div{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft)}#entries-body>div>div{padding:7px 10px;flex-shrink:0;overflow:hidden}#entries-body>div:nth-child(2n){background:#f2ede5}#entries-body>div:nth-child(odd){background:var(--paper-3)}#entries-body>div.is-selected{background:#eee2d2;outline:2px solid var(--accent);outline-offset:-2px}.col-added{width:162px;color:var(--muted)}.col-title{flex:1 1 0;min-width:0;overflow:hidden;display:flex;align-items:center;gap:.42em}.col-type{width:116px}.col-size{width:100px;display:flex;flex-direction:column;justify-content:center;gap:1px}.size-total{font-variant-numeric:tabular-nums}.size-cached-pct{font-size:10px;color:var(--muted);opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.col-url{flex:0 0 30%;min-width:0;overflow:hidden}.entry-header-row>div:first-child,#entries-body>div>div:first-child{padding-left:22px}.entry-header-row>div:last-child,#entries-body>div>div:last-child{padding-right:22px}.entry-title{color:var(--link);font-weight:700;min-width:0}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600}.source-icon{display:flex;align-items:center;justify-content:center;width:1.05em;height:1.05em;flex-shrink:0}.source-icon>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.source-icon svg{width:100%;height:100%}.url-cell{color:#555b55;white-space:nowrap;text-overflow:ellipsis;word-break:break-all}#entries-body .url-cell:hover,#entries-body .is-selected .url-cell{overflow:visible;white-space:normal}.type-pill{display:inline-block;padding:2px 6px;background:#d8e3df;color:#275a5f;border:1px solid #bfd0ca;border-radius:var(--r)}#runs-view .entry-table{border-collapse:collapse;table-layout:auto}#runs-view .entry-table th{position:sticky;top:0;z-index:1;text-align:left;padding:10px;background:color-mix(in srgb,var(--paper) 92%,white);color:var(--muted);border-bottom:1px solid var(--line-soft);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}#runs-view .entry-table td{padding:10px;border-bottom:1px solid var(--line-soft);vertical-align:top}#runs-view .entry-table tr:nth-child(2n) td{background:#f2ede5}#runs-view .entry-table tr:nth-child(odd) td{background:var(--paper-3)}.context-rail{border-left:1px solid var(--line);background:var(--paper);padding:20px 20px 32px;overflow:auto}.rail-eyebrow{font-size:10.5px;font-weight:600;letter-spacing:.16em;text-transform:uppercase;color:var(--muted-2);margin-bottom:16px}.rail-title{display:block;font-family:var(--sans);font-weight:700;font-size:15.5px;line-height:1.4;color:var(--ink);margin:0 0 16px;word-break:break-word}.url-tile{display:flex;align-items:center;gap:9px;padding:10px 12px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);margin-bottom:20px;text-decoration:none}.url-tile:hover{background:var(--field);border-color:var(--accent)}.url-tile .ico{color:var(--ink);flex-shrink:0;display:grid;place-items:center}.url-tile .ico svg{width:15px;height:15px}.url-tile .u-text{min-width:0;flex:1;font-size:12.5px;color:var(--link);font-family:ui-monospace,SF Mono,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.url-tile .ext{color:var(--muted-2);flex-shrink:0}.url-tile .ext svg{width:13px;height:13px;display:block}.meta-list{margin-bottom:24px;border-top:1px solid var(--line-soft)}.meta-item{display:grid;grid-template-columns:92px 1fr;gap:14px;align-items:baseline;padding:9px 0;border-bottom:1px solid var(--line-soft)}.meta-k{font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted-2)}.meta-v{font-size:13.5px;color:var(--ink);word-break:break-word;line-height:1.4}.meta-v.mono{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:12px;color:var(--muted)}.rail-section{margin-bottom:24px}.rail-section-heading{display:flex;align-items:baseline;gap:8px;font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;color:var(--muted-2);margin-bottom:9px;padding-bottom:8px;border-bottom:1px solid var(--line)}.rail-section-heading .num{color:var(--muted-2);font-weight:600}.artifact-list{list-style:none;margin:0;padding:0}.artifact-link{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:7px 2px;border-bottom:1px solid var(--line-soft);text-decoration:none}.artifact-link:last-child{border-bottom:0}.artifact-name{font-size:13px;color:var(--link);min-width:0;word-break:break-word}.artifact-link:hover .artifact-name{text-decoration:underline}.artifact-size{font-size:11.5px;color:var(--muted-2);flex-shrink:0;font-variant-numeric:tabular-nums}.tags-wrap{display:flex;flex-wrap:wrap;gap:7px;margin:0 0 12px}.tag-pill{display:inline-flex;align-items:center;gap:7px;background:var(--paper-2);border:1px solid var(--line);border-radius:var(--r);font-size:12px;padding:4px 7px 4px 10px;color:var(--ink)}.tag-pill .remove{border:0;background:transparent;cursor:pointer;color:var(--muted-2);width:15px;height:15px;display:grid;place-items:center;font-size:13px;line-height:1}.tag-pill .remove:hover{color:var(--accent)}.tags-empty{font-size:13px;color:var(--muted);margin:0 0 11px}.tag-input-wrap{display:flex;align-items:center;gap:8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);padding:2px 2px 2px 11px;transition:border-color .15s ease,box-shadow .15s ease}.tag-input-wrap:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 12%,transparent)}.tag-input-wrap .hash{color:var(--muted-2);font-size:13px}.tag-input{flex:1;min-width:0;border:0;background:transparent;color:var(--ink);font-size:13px;padding:6px 0;outline:none;font-family:ui-monospace,SF Mono,Menlo,monospace}.tag-add-btn{border:0;background:var(--ink);color:var(--paper-3);padding:6px 13px;font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;border-radius:var(--r);cursor:pointer;white-space:nowrap}.tag-add-btn:hover{background:#2c332b}.coll-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 13px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);margin-bottom:6px;transition:border-color .15s ease}.coll-row:hover{border-color:var(--accent)}.coll-name{font-size:13px;color:var(--ink);font-weight:500}.vis-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:999px;padding:3px 10px}.vis-badge:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent-2)}.rail-delete-zone{margin-top:24px;padding-top:20px;border-top:1px solid var(--line-soft)}.rail-delete-btn{width:100%;padding:8px 14px;background:none;border:1px solid color-mix(in srgb,var(--accent) 45%,transparent);color:var(--accent);border-radius:var(--r);cursor:pointer;font-size:12.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;transition:background .15s ease,border-color .15s ease}.rail-delete-btn:hover{background:color-mix(in srgb,var(--accent) 8%,transparent);border-color:var(--accent)}.rail-rearchive-btn{width:100%;padding:6px 12px;background:var(--surface-2, #2a2a2a);color:var(--text, #e0e0e0);border:1px solid var(--border, #444);border-radius:4px;cursor:pointer;font-size:13px}.rail-rearchive-btn:hover:not(:disabled){background:var(--surface-3, #333)}.rail-rearchive-btn:disabled{opacity:.6;cursor:not-allowed}.capture-dialog{border:1px solid var(--line);background:var(--paper);padding:0;width:min(540px,calc(100vw - 32px));border-radius:var(--r3);box-shadow:0 20px 60px #141d1847}.capture-dialog::backdrop{background:#141d1873}.capture-dialog-inner{padding:28px}.capture-dialog-title{margin:0;font-size:22px;font-family:var(--display);font-weight:600}.capture-label{display:block;font-size:11px;font-weight:600;margin-bottom:6px;color:var(--muted-2);text-transform:uppercase;letter-spacing:.06em}.capture-input{width:100%;height:44px;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:0 14px;font-size:15px;margin-bottom:10px;border-radius:var(--r2);outline:none;transition:border-color .15s ease,box-shadow .15s ease}.capture-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.form-field .capture-input{margin-bottom:0}.capture-error{color:var(--accent);font-size:13px;margin-bottom:10px;min-height:18px}.capture-actions{display:flex;flex-direction:column;gap:8px;margin-top:18px}.capture-submit{border:0;background:var(--ink);color:var(--paper);padding:13px 20px;border-radius:var(--r2);cursor:pointer;font-weight:600;font-size:15px;width:100%;min-width:220px;letter-spacing:.01em}.capture-submit:hover{opacity:.85}.capture-submit:disabled{opacity:.45;cursor:default}.capture-cancel{border:0;background:none;color:var(--muted);padding:7px 18px;border-radius:var(--r);cursor:pointer;font-size:13px;text-align:center;width:100%}.capture-cancel:hover{color:var(--ink);background:var(--paper-2)}.capture-advanced{margin-top:12px}.capture-advanced-toggle{display:flex;align-items:center;gap:5px;background:none;border:0;cursor:pointer;color:var(--muted);font-size:12.5px;padding:4px 0;border-radius:var(--r)}.capture-advanced-toggle:hover{color:var(--ink)}.capture-chevron{width:14px;height:14px;flex-shrink:0;transition:transform .18s ease}.capture-chevron--open{transform:rotate(180deg)}.capture-advanced-panel{margin-top:8px;padding:10px 12px;border:1px solid var(--line);border-radius:var(--r2);background:var(--paper-2)}.capture-ext-row{display:flex;align-items:center;justify-content:space-between;gap:12px;cursor:default}.capture-ext-label{flex:1;min-width:0}.capture-ext-name{display:block;font-size:13px;font-weight:600;color:var(--ink)}.capture-ext-desc{display:block;font-size:11.5px;color:var(--muted);margin-top:1px}.capture-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.capture-dialog-close{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-dialog-close svg{width:14px;height:14px}.capture-dialog-close:hover{background:var(--paper-2);color:var(--ink)}.capture-rows{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}.capture-row{display:flex;flex-direction:column;gap:3px}.capture-row-main{display:flex;align-items:center;gap:8px}.capture-row-main .capture-input{margin-bottom:0}.capture-quality{flex-shrink:0;height:32px;padding:0 6px;border:1px solid var(--line);border-radius:var(--r);background:var(--paper);color:var(--ink);font-size:12px;cursor:pointer;outline:none;transition:border-color .15s}.capture-quality:hover{border-color:var(--accent-2)}.capture-quality:focus{border-color:var(--accent)}.capture-quality:disabled{opacity:.5;cursor:default}.capture-quality-probing{flex-shrink:0;font-size:12px;color:var(--muted);padding:0 4px;letter-spacing:.05em}.capture-quality-hint{flex-shrink:0;font-size:12px;color:var(--muted);font-style:italic}.cap-dot{flex-shrink:0;width:20px;height:20px;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:700;line-height:1}.cap-dot--idle{background:var(--paper-2)}.cap-dot--running{background:#fdefd8;color:#8a4f10}.cap-dot--ok{background:#d8eddf;color:#235c35}.cap-dot--err{background:#f5ddd8;color:#8d3f30}.cap-spinner{display:block;width:10px;height:10px;border:2px solid currentColor;border-top-color:transparent;border-radius:50%;animation:cap-spin .7s linear infinite}@keyframes cap-spin{to{transform:rotate(360deg)}}.capture-row-action{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-row-action svg{width:12px;height:12px}.capture-row-action:hover{color:var(--accent);background:var(--paper-2)}.capture-row-remove:hover{color:var(--accent)}.capture-row-error{margin:0;padding-left:28px;font-size:12px;color:var(--accent);line-height:1.45}.capture-add-row{display:flex;align-items:center;gap:7px;width:100%;background:none;border:1px dashed var(--line);border-radius:var(--r);color:var(--muted);font-size:13px;cursor:pointer;padding:7px 12px;margin-top:4px;margin-bottom:18px;transition:border-color .15s,color .15s,background .15s}.capture-add-row svg{width:13px;height:13px;flex-shrink:0}.capture-add-row:hover{border-color:var(--accent-2);color:var(--ink);background:var(--paper-2)}.toast-stack{position:fixed;bottom:24px;right:24px;z-index:9000;display:flex;flex-direction:column;gap:10px;width:340px;max-width:calc(100vw - 32px);pointer-events:none}.toast{pointer-events:auto;background:var(--paper);border:1px solid var(--line);border-radius:var(--r2);box-shadow:0 6px 24px #141d182e,0 1px 4px #141d181a;overflow:hidden;animation:toast-slide-in .22s cubic-bezier(.22,.68,0,1.2)}@keyframes toast-slide-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.toast--error{border-left:3px solid var(--accent)}.toast--warning{border-left:3px solid #e8a000}.toast--success{border-left:3px solid #22a855}.toast-top{display:flex;align-items:flex-start;gap:10px;padding:12px 12px 12px 14px}.toast-icon{flex-shrink:0;font-size:13px;font-weight:700;color:var(--accent);margin-top:2px}.toast--success .toast-icon{color:#22a855}.toast--warning .toast-icon{color:#e8a000}.toast-body{flex:1;min-width:0}.toast-headline{display:block;font-size:13.5px;font-weight:600;color:var(--ink);line-height:1.3}.toast-locator{display:block;font-size:12px;color:var(--muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-btns{display:flex;align-items:center;gap:6px;flex-shrink:0}.toast-view-btn{background:none;border:1px solid var(--line);color:var(--link);font-size:12px;cursor:pointer;padding:3px 9px;border-radius:var(--r);white-space:nowrap}.toast-view-btn:hover{background:var(--paper-2);border-color:var(--link)}.toast-dismiss{background:none;border:0;cursor:pointer;color:var(--muted);font-size:20px;line-height:1;width:24px;height:24px;display:grid;place-items:center;border-radius:var(--r);padding:0}.toast-dismiss:hover{color:var(--ink);background:var(--paper-2)}.toast-error-detail{margin:0;padding:10px 14px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);background:var(--paper-2);border-top:1px solid var(--line);white-space:pre-wrap;word-break:break-word;max-height:200px;overflow-y:auto}.toast-warning-detail{margin:0;padding:10px 14px 12px;font-size:12px;line-height:1.55;color:var(--muted);background:var(--paper-2);border-top:1px solid var(--line);white-space:pre-wrap;word-break:break-word}.toast-ignore-btn{color:var(--muted)}.ext-toggle{flex-shrink:0;position:relative;width:44px;height:24px;border-radius:12px;background:var(--line);border:0;cursor:pointer;transition:background .18s ease;padding:0}.ext-toggle--sm{width:36px;height:20px;border-radius:10px}.ext-toggle--on{background:var(--ink)}.ext-toggle:disabled{opacity:.4;cursor:default}.ext-toggle-knob{position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:var(--paper);transition:transform .18s ease;display:block;box-shadow:0 1px 3px #0003}.ext-toggle--sm .ext-toggle-knob{width:14px;height:14px;top:3px;left:3px}.ext-toggle--on .ext-toggle-knob{transform:translate(20px)}.ext-toggle--sm.ext-toggle--on .ext-toggle-knob{transform:translate(16px)}.ext-card{border:1px solid var(--line);border-radius:var(--r2);padding:16px 18px;background:var(--paper)}.ext-card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.ext-card-info{flex:1;min-width:0}.ext-card-name{display:block;font-weight:600;font-size:14px;margin-bottom:4px}.ext-card-desc{display:block;font-size:13px;color:var(--muted);line-height:1.5}.ext-card-hint{display:block;font-size:12px;color:#e8a000;margin-top:6px}.ext-card-hint code{font-size:11.5px}.form-hint{font-size:13px;color:var(--muted);line-height:1.55;margin:0}.muted{color:var(--muted)}.admin-view{padding:22px}.admin-list{display:grid;gap:10px;max-width:780px}.admin-archive{border:1px solid var(--line);background:var(--paper-3);padding:12px;border-radius:var(--r2)}.tag-tree{padding:20px 22px;max-width:320px}.tag-tree-header{display:flex;align-items:baseline;gap:10px;margin-bottom:14px;border-bottom:1px solid var(--line-soft);padding-bottom:10px}.tag-tree-title{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}.tag-tree-active{font-size:12px;color:var(--muted-2);font-style:italic}.tag-tree-list{list-style:none;margin:0;padding:0}.tag-children{padding-left:16px}.tag-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 0;text-align:left;font-size:13px;display:block;width:100%}.tag-node-btn:hover{text-decoration:underline}.tag-node-btn.is-active{font-weight:600;color:var(--ink)}.tag-node-row{display:flex;align-items:center;gap:4px}.tag-node-row .tag-node-btn{flex:1 1 0;min-width:0;display:flex;align-items:center;gap:4px;width:auto}.tag-node-btn .edit-icon{width:.75em;height:.75em;flex-shrink:0;vertical-align:-.1em;opacity:.35}.tag-node-btn:hover .edit-icon{opacity:.65}.tag-node-delete{flex-shrink:0;border:0;background:transparent;color:var(--muted-2);cursor:pointer;padding:0 3px;font-size:14px;line-height:1;opacity:0}.tag-node-row:hover .tag-node-delete{opacity:1}.tag-node-delete:hover{color:var(--accent)}.tag-rename-input{font-size:13px;flex:1 1 0;min-width:0;padding:2px 5px;border:1px solid var(--accent);border-radius:var(--r);background:var(--field);color:var(--ink);outline:none}.collections-view{padding:24px}.collections-heading{margin:0 0 16px;font-size:22px;font-family:var(--display);font-weight:600}.collections-error{color:var(--accent);font-size:13px;margin-bottom:8px}.coll-dismiss{background:none;border:none;cursor:pointer;color:var(--accent);font-size:16px;line-height:1;padding:0 4px}.collections-layout{display:grid;grid-template-columns:220px 1fr;gap:0;border:1px solid var(--line);border-radius:var(--r2);min-height:340px}.collections-sidebar{border-right:1px solid var(--line);overflow-y:auto}.coll-sidebar-row{display:flex;flex-direction:column;width:100%;padding:10px 14px;border:none;border-bottom:1px solid var(--line-soft);background:none;cursor:pointer;text-align:left;gap:2px}.coll-sidebar-row:hover{background:var(--paper-2)}.coll-sidebar-row.is-active{background:var(--paper-2);border-left:3px solid var(--accent)}.coll-row-name{font-size:14px;font-weight:600;color:var(--ink)}.coll-row-meta{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.coll-detail{padding:20px 24px;display:flex;flex-direction:column;gap:16px}.coll-detail--empty{justify-content:center;align-items:center}.coll-detail-header{display:flex;align-items:center;gap:12px}.coll-detail-name{margin:0;font-size:18px;font-family:var(--display);font-weight:600;flex:1}.coll-detail-name--editable{cursor:pointer}.coll-detail-name--editable:hover{color:var(--link)}.coll-edit-hint{font-size:14px;opacity:.5;margin-left:4px}.coll-rename-input{flex:1;font-size:16px;font-family:var(--display);border:1px solid var(--line);padding:4px 8px;background:var(--field);color:var(--ink);border-radius:var(--r)}.coll-delete-btn{border:1px solid var(--accent);background:none;color:var(--accent);padding:5px 12px;font-size:13px;cursor:pointer;border-radius:var(--r)}.coll-delete-btn:hover{background:var(--accent);color:var(--paper)}.coll-detail-vis{display:flex;align-items:center;gap:10px}.coll-vis-label{font-size:13px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;white-space:nowrap}.coll-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:4px 8px;font-size:13px;border-radius:var(--r)}.coll-section-heading{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px}.coll-entries-section{flex:1}.coll-entries-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}.coll-entry-row{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid var(--line-soft)}.coll-entry-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.coll-entry-title{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.coll-entry-kind{font-size:11px;text-transform:uppercase;letter-spacing:.04em}.coll-entry-actions{display:flex;align-items:center;gap:6px;flex-shrink:0}.coll-entry-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:3px 6px;font-size:12px;border-radius:var(--r)}.coll-entry-remove{border:none;background:none;cursor:pointer;color:var(--muted);font-size:18px;line-height:1;padding:0 4px}.coll-entry-remove:hover{color:var(--accent)}.coll-add-entry-form{border-top:1px solid var(--line-soft);padding-top:12px}.coll-add-entry-row{display:flex;gap:8px;align-items:center}.coll-add-entry-input{flex:1;border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:6px 10px;font-size:13px;min-width:0;border-radius:var(--r)}.coll-add-btn{border:none;background:var(--ink);color:var(--paper);padding:6px 14px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;border-radius:var(--r)}.coll-add-btn:hover{opacity:.85}.coll-add-btn:disabled{opacity:.45;cursor:default}.auth-loading{min-height:100vh;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:15px;background:var(--paper)}.user-menu{display:flex;align-items:center;gap:14px;padding-left:6px;flex-shrink:0}.user-name{font-size:12.5px;color:var(--muted-2);letter-spacing:.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:140px}.logout-btn{border:1px solid rgba(255,255,255,.18);background:transparent;color:#c8bfb0;font-size:12px;padding:4px 11px;border-radius:var(--r);cursor:pointer;white-space:nowrap;transition:background .15s,color .15s}.logout-btn:hover{background:#ffffff1a;color:var(--paper)}.logout-btn:disabled{opacity:.5;cursor:default}.login-page,.setup-page{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--paper)}.login-card,.setup-card{width:100%;max-width:360px;padding:40px 36px 44px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);box-shadow:0 2px 20px #141d1812}.login-brand,.setup-brand{font-family:var(--display);font-size:32px;font-weight:600;color:var(--ink);letter-spacing:-.01em;margin:0 0 6px}.login-tagline,.setup-tagline{font-size:13px;color:var(--muted);margin:0 0 28px}.login-field,.setup-field{display:flex;flex-direction:column;gap:5px;margin-bottom:14px}.login-label,.setup-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.login-input,.setup-input{width:100%;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:9px 11px;font-size:14px;border-radius:var(--r2);outline:none;transition:border-color .15s}.login-input:focus,.setup-input:focus{border-color:var(--accent)}.login-error,.setup-error{font-size:13px;color:var(--accent);margin:4px 0 8px}.login-submit,.setup-submit{width:100%;margin-top:8px;border:none;background:var(--top);color:var(--paper);font-size:14px;font-weight:600;padding:11px 16px;border-radius:var(--r2);cursor:pointer;letter-spacing:.02em;transition:opacity .15s}.login-submit:hover,.setup-submit:hover{opacity:.85}.login-submit:disabled,.setup-submit:disabled{opacity:.45;cursor:default}.view-tabs{display:flex;gap:2px;margin-bottom:22px;border-bottom:1px solid var(--line-soft);padding-bottom:0}.view-tab{border:none;background:none;color:var(--muted);font-size:13px;font-weight:600;padding:7px 14px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;letter-spacing:.02em;transition:color .12s;text-transform:uppercase;letter-spacing:.06em;font-size:11.5px}.view-tab:hover{color:var(--ink)}.view-tab.is-active{color:var(--ink);border-bottom-color:var(--accent)}.form-section{margin-bottom:32px}.form-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.form-row{display:flex;gap:8px;margin-bottom:10px}.form-field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px}.form-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}.field-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s;min-width:0}.field-input:focus{border-color:var(--accent)}.field-input--flex{flex:1}.form-msg{font-size:13px;margin:6px 0}.form-msg--ok{color:var(--link)}.form-msg--err{color:var(--accent)}.btn-primary{border:none;background:var(--top);color:var(--paper);font-size:13px;font-weight:600;padding:8px 16px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.btn-primary:hover{opacity:.85}.btn-primary:disabled{opacity:.45;cursor:default}.btn-ghost{border:1px solid var(--line);background:none;color:var(--ink);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-ghost:hover{background:var(--paper-2)}.btn-danger{border:1px solid var(--accent);background:none;color:var(--accent);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-danger:hover{background:var(--accent);color:var(--paper)}.admin-view h1{font-family:var(--display);font-weight:600;font-size:26px;margin:0 0 20px}.admin-table{width:100%;border-collapse:collapse;font-size:13px;margin-bottom:28px}.admin-table th{text-align:left;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);padding:8px 10px;border-bottom:1px solid var(--line);background:var(--paper-2)}.admin-table th:first-child{padding-left:16px}.admin-table td{padding:9px 10px;border-bottom:1px solid var(--line-soft);color:var(--ink);vertical-align:middle}.admin-table td:first-child{padding-left:16px}.admin-table tr:hover td{background:var(--paper-2)}.admin-row-disabled td{opacity:.45}.admin-section{margin-bottom:36px;max-width:860px}.admin-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.admin-section h3{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin:22px 0 10px}.admin-form{display:flex;flex-direction:column;gap:8px;max-width:480px}.admin-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s}.admin-input:focus{border-color:var(--accent)}.admin-action-btn{border:1px solid var(--line);background:none;color:var(--ink);font-size:12px;padding:4px 10px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.admin-action-btn:hover{border-color:var(--accent);color:var(--accent)}.status-badge{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.status-active{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.status-disabled{background:#ede8e0;color:var(--muted);border:1px solid var(--line)}.run-status{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.run-status--completed{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.run-status--failed{background:#f5ddd8;color:#8d3f30;border:1px solid #e0b8b0}.run-status--in-progress{background:#fdefd8;color:#8a4f10;border:1px solid #f0cfa0}.run-row--failed{cursor:pointer}.run-row--failed:hover td{background:#fdf0ed!important}.run-expand-hint{margin-left:6px;font-size:10px;color:var(--accent);vertical-align:middle}.run-error-row td{padding:0!important;background:var(--paper-2)!important}.run-error-detail{margin:0;padding:10px 16px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);white-space:pre-wrap;word-break:break-word;max-height:220px;overflow-y:auto}.token-banner{background:#d8eddf;border:1px solid #b4d9be;padding:12px 14px;margin-bottom:16px;font-size:13px;border-radius:var(--r2)}.token-banner code{word-break:break-all;display:block;margin-top:6px;padding:6px 8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r);font-size:12px;font-family:ui-monospace,SF Mono,Menlo,monospace}.token-dismiss{margin-top:8px;font-size:12px;border:1px solid var(--line);background:none;cursor:pointer;padding:3px 8px;border-radius:var(--r);color:var(--muted)}.token-dismiss:hover{background:var(--paper-2)}.token-row{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--line);background:var(--paper-3);padding:10px 12px;border-radius:var(--r);margin-bottom:6px}.token-row-info strong{font-size:14px;display:block}.token-row-info .muted{font-size:12px;margin-top:2px}.token-create-row{display:flex;gap:8px;margin-bottom:16px}.checkbox-row{display:flex;align-items:center;gap:10px;margin-bottom:12px;cursor:pointer;font-size:14px}.checkbox-row input[type=checkbox]{width:15px;height:15px;accent-color:var(--accent)}.coll-create-details{margin-top:16px}.coll-create-details summary{font-weight:600;cursor:pointer;font-size:13px;color:var(--link);list-style:none;display:flex;align-items:center;gap:6px;padding:8px 12px;border:1px solid var(--line-soft);border-radius:var(--r2);background:var(--paper-3);width:fit-content}.coll-create-details summary:hover{background:var(--paper-2)}.coll-create-details[open] summary{border-bottom-left-radius:0;border-bottom-right-radius:0}.coll-create-form{border:1px solid var(--line-soft);border-top:none;padding:14px;border-radius:0 0 var(--r2) var(--r2);background:var(--paper-3);display:flex;flex-direction:column;gap:10px;max-width:440px}@media (max-width: 900px){.topbar{grid-template-columns:1fr auto;height:auto;min-height:58px;padding:12px}.switcher,.nav{grid-column:1 / -1}.nav{justify-content:flex-start;overflow-x:auto}.app-shell{height:auto;grid-template-columns:1fr}.context-rail{border-left:0;border-top:1px solid var(--line)}.entry-table{min-width:860px}}.rail-title--editable{cursor:pointer}.rail-title--editable:hover{opacity:.75}.rail-title--editable .edit-icon{display:inline-block;width:.75em;height:.75em;margin-left:.35em;vertical-align:middle;opacity:0;transition:opacity .1s;flex-shrink:0}.rail-title--editable:hover .edit-icon{opacity:.5}.rail-title-input{width:100%;font:inherit;font-size:inherit;font-weight:600;background:transparent;border:none;border-bottom:1px solid currentColor;color:inherit;padding:0;margin:0 0 8px;outline:none}.preview-panel{flex:1;display:flex;flex-direction:column;min-height:0}.preview-panel-loading,.preview-panel-empty{flex:1;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:8px;color:var(--muted-2);font-size:14px;text-align:center;padding:24px}.preview-video-wrap{flex:1;display:flex;align-items:center;justify-content:center;background:#0d0d0b;min-height:200px}.preview-video-wrap video{max-width:100%;max-height:100%;width:100%;display:block}.preview-iframe-wrap{flex:1;display:flex;flex-direction:column;min-height:0}.preview-iframe-toolbar{display:flex;flex-direction:column;gap:2px;padding:6px 12px;background:var(--paper-2);border-bottom:1px solid var(--line);flex-shrink:0;text-transform:none;letter-spacing:normal}.preview-iframe-toolbar span{font-size:11px;color:var(--muted-2)}.preview-iframe-toolbar a{margin-left:auto;color:var(--link);font-size:12px;text-decoration:none;padding:3px 8px;border:1px solid var(--line);border-radius:var(--r2);background:var(--field);transition:border-color .12s}.preview-iframe-toolbar a:hover{border-color:var(--accent);text-decoration:none}.preview-iframe-wrap iframe{flex:1;width:100%;border:none;background:#fff;min-height:0}.preview-image-wrap{flex:1;display:flex;align-items:center;justify-content:center;padding:20px;background:var(--paper-2)}.preview-image-wrap img{max-width:100%;max-height:100%;object-fit:contain;border-radius:var(--r3);cursor:zoom-in;display:block;box-shadow:0 4px 24px #0000001a}.preview-tweet-wrap{flex:1;min-height:0;overflow-y:auto;padding:12px 16px;background:var(--paper-2);scrollbar-width:thin;scrollbar-color:var(--line) transparent}.preview-tweet-wrap::-webkit-scrollbar{width:8px}.preview-tweet-wrap::-webkit-scrollbar-track{background:transparent}.preview-tweet-wrap::-webkit-scrollbar-thumb{background:var(--line);border-radius:999px;border:2px solid transparent;background-clip:padding-box}.preview-tweet-wrap::-webkit-scrollbar-thumb:hover{background:var(--muted-2);background-clip:padding-box;border:2px solid transparent}.tw-card{border:1px solid var(--line);border-radius:12px;padding:16px;background:var(--paper);max-width:560px;margin:0 auto 12px}.tw-thread{max-width:560px;margin:0 auto}.tw-thread-item{display:flex;gap:0;margin-bottom:0}.tw-thread-connector{display:flex;flex-direction:column;align-items:center;flex-shrink:0;width:52px;padding-top:2px}.tw-thread-avatar-col{display:flex;flex-direction:column;align-items:center;flex-shrink:0}.tw-thread-line{width:2px;background:var(--line);flex:1;min-height:16px;margin:4px 0}.tw-thread-body{flex:1;min-width:0;padding:0 0 16px 12px}.tw-thread-body:last-child{padding-bottom:0}.tw-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;display:block}.tw-avatar-ph{width:40px;height:40px;border-radius:50%;background:var(--paper-2);border:1px solid var(--line);flex-shrink:0}.tw-header{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;margin-bottom:6px}.tw-author-name{font-size:14.5px;font-weight:700;color:var(--ink)}.tw-author-handle{font-size:13px;color:var(--muted-2)}.tw-dot{color:var(--muted-2);font-size:13px}.tw-date{font-size:13px;color:var(--muted-2)}.tw-text{font-size:15px;line-height:1.65;color:var(--ink);white-space:pre-line;word-break:break-word;margin-bottom:10px}.tw-text a{color:var(--link);text-decoration:none}.tw-text a:hover{text-decoration:underline}.tw-stats{display:flex;gap:20px;color:var(--muted-2);font-size:13px;margin-top:10px;padding-top:10px;border-top:1px solid var(--line-soft)}.tw-stats span{display:flex;align-items:center;gap:4px}.tw-article{max-width:598px;margin:0 auto}.tw-article-cover{width:100%;display:block;object-fit:cover;max-height:380px}.tw-article-meta{padding:20px 16px 0}.tw-article-title{font-size:22px;font-weight:800;letter-spacing:-.3px;color:var(--ink);line-height:1.3;margin-bottom:14px}.tw-article-author-row{display:flex;align-items:center;gap:12px;margin-bottom:14px}.tw-article-author-name{font-size:14px;font-weight:700;color:var(--ink)}.tw-article-author-sub{font-size:13px;color:var(--muted-2)}.tw-article-divider{border:none;border-top:1px solid var(--line);margin:0}.tw-article-body{padding:8px 16px 60px}.tw-b-h1{font-size:24px;font-weight:800;letter-spacing:-.3px;color:var(--ink);line-height:1.25;margin:22px 0 10px}.tw-b-h2{font-size:19px;font-weight:700;letter-spacing:-.15px;color:var(--ink);line-height:1.3;margin:20px 0 8px}.tw-b-p{font-size:16px;color:var(--ink);line-height:1.72;margin-bottom:14px}.tw-b-p:empty{display:none}.tw-b-spacer{height:6px;display:block}.tw-b-blockquote{border-left:3px solid var(--line);padding:2px 14px;margin:14px 0;color:var(--muted);font-size:16px;line-height:1.65}.tw-b-hr{border:none;border-top:1px solid var(--line);margin:24px 0}.tw-b-img{width:100%;display:block;border-radius:10px;margin:14px 0}.tw-b-ul,.tw-b-ol{margin:10px 0 14px;padding-left:26px}.tw-b-li{font-size:16px;color:var(--ink);line-height:1.65;margin-bottom:6px}.tw-b-code{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:.875em;background:var(--paper-2);padding:2px 5px;border-radius:4px;color:var(--ink)}.tw-b-pre{background:var(--paper-2);border:1px solid var(--line);border-radius:8px;padding:14px 16px;overflow-x:auto;margin:12px 0}.tw-b-pre code{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:13px;line-height:1.6}.tw-b-tweet-link{display:flex;align-items:center;gap:10px;border:1px solid var(--line);border-radius:10px;padding:12px 14px;margin:12px 0;color:var(--muted);font-size:14px;text-decoration:none;background:var(--paper-3);transition:background .12s}.tw-b-tweet-link:hover{background:var(--field)}.tw-b-tweet-link svg{flex-shrink:0;color:var(--ink)}.audio-bar{position:fixed;bottom:0;left:0;right:0;height:72px;background:var(--paper);border-top:1px solid var(--line);display:flex;align-items:center;gap:20px;padding:0 24px;z-index:100;box-shadow:0 -2px 16px #00000014}.audio-bar-info{display:flex;align-items:center;gap:10px;min-width:0;flex:0 0 200px}.audio-bar-icon{flex-shrink:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center}.audio-bar-icon svg{width:20px;height:20px}.audio-bar-title{font-size:13px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;font-weight:500}.audio-bar-controls{flex:1;display:flex;align-items:center;gap:12px;min-width:0}.audio-bar-play-btn{width:38px;height:38px;border-radius:50%;background:var(--accent);color:var(--paper);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .12s,transform .1s}.audio-bar-play-btn:hover{background:var(--accent-2)}.audio-bar-play-btn:active{transform:scale(.93)}.audio-bar-play-btn svg{width:15px;height:15px}.audio-bar-seek{flex:1;min-width:0;display:flex;align-items:center;gap:8px}.audio-bar-seek input[type=range]{flex:1;accent-color:var(--accent);height:4px;cursor:pointer;min-width:0}.audio-bar-time{font-size:11.5px;color:var(--muted-2);white-space:nowrap;min-width:80px;text-align:right;font-variant-numeric:tabular-nums}.audio-bar-right{flex:0 0 auto;display:flex;align-items:center;gap:10px}.audio-bar-volume{display:flex;align-items:center;gap:6px}.audio-bar-volume svg{width:14px;height:14px;color:var(--muted-2);flex-shrink:0}.audio-bar-volume input[type=range]{width:72px;accent-color:var(--accent);cursor:pointer}.audio-bar-close{width:28px;height:28px;border-radius:50%;border:none;background:transparent;color:var(--muted-2);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:18px;padding:0;line-height:1;transition:background .12s,color .12s}.audio-bar-close:hover{background:var(--field);color:var(--ink)}.preview-modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:200;background:#0000008c;display:flex;align-items:center;justify-content:center;padding:20px}.preview-modal{background:var(--paper);border-radius:12px;box-shadow:0 24px 80px #00000047;width:90vw;max-width:1100px;max-height:88vh;display:flex;flex-direction:column;overflow:hidden}.preview-modal--full{height:88vh}.preview-modal--full .preview-modal-body{max-height:none}.preview-modal-header{display:flex;align-items:center;padding:14px 18px;border-bottom:1px solid var(--line);flex-shrink:0;gap:12px}.preview-modal-title{flex:1;min-width:0;font-size:14px;font-weight:600;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.preview-modal-close{width:30px;height:30px;border-radius:50%;border:none;background:transparent;color:var(--muted-2);font-size:20px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .12s,color .12s}.preview-modal-close:hover{background:var(--field);color:var(--ink)}.preview-modal-body{flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column;max-height:calc(88vh - 52px)}.rail-preview-btn{display:block;width:100%;padding:8px 12px;margin-bottom:16px;background:var(--accent);color:var(--paper);border:none;border-radius:var(--r3);font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .12s}.rail-preview-btn:hover{background:var(--accent-2)}.preview-modal-newtab{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:var(--r2);color:var(--muted-2);text-decoration:none;font-size:16px;flex-shrink:0;transition:background .12s,color .12s}.preview-modal-newtab:hover{background:var(--field);color:var(--ink)}body.has-audio-bar{padding-bottom:56px} diff --git a/crates/archivr-server/static/assets/index-p2mzAHzf.css b/crates/archivr-server/static/assets/index-p2mzAHzf.css new file mode 100644 index 0000000..8df0ef5 --- /dev/null +++ b/crates/archivr-server/static/assets/index-p2mzAHzf.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Spectral:wght@500;600&display=swap";:root{color-scheme:light;--ink: #20251f;--muted: #6b6f66;--muted-2: #8a8d83;--paper: #f5f0e7;--paper-2: #e9e1d2;--paper-3: #fffaf0;--line: #d2c6b5;--line-soft: #e5dccd;--accent: #8d3f30;--accent-2: #b78342;--link: #245f72;--top: #141d18;--field: #fffdf7;--r: 3px;--r2: 6px;--r3: 10px;--sans: "Helvetica Neue", Helvetica, Arial, sans-serif;--serif: "Spectral", Georgia, "Times New Roman", serif;--display: "Cormorant Garamond", Georgia, serif}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:var(--paper);color:var(--ink);font-family:var(--sans);font-size:14px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select{font:inherit}.workspace,.context-rail{scrollbar-width:thin;scrollbar-color:var(--line) transparent}.workspace::-webkit-scrollbar,.context-rail::-webkit-scrollbar{width:11px;height:11px}.workspace::-webkit-scrollbar-track,.context-rail::-webkit-scrollbar-track{background:transparent}.workspace::-webkit-scrollbar-thumb,.context-rail::-webkit-scrollbar-thumb{background:var(--line);border-radius:999px;border:3px solid transparent;background-clip:padding-box}.workspace::-webkit-scrollbar-thumb:hover,.context-rail::-webkit-scrollbar-thumb:hover{background:var(--muted-2);background-clip:padding-box;border:3px solid transparent}.topbar{height:58px;display:grid;grid-template-columns:auto auto 1fr auto auto;align-items:center;gap:26px;padding:0 22px;background:var(--top);color:#efe6d6;border-bottom:3px solid var(--accent)}.brand{font-family:var(--display);font-weight:600;font-size:30px;line-height:1;letter-spacing:.01em;color:#f4ead8}.switcher{position:relative;display:inline-flex;align-items:center}.switcher select{-moz-appearance:none;appearance:none;-webkit-appearance:none;border:1px solid rgba(247,238,223,.2);background:#f7eedf0f;color:#f1e8d8;font-family:var(--sans);font-weight:550;font-size:13.5px;letter-spacing:.04em;padding:8px 32px 8px 15px;cursor:pointer;border-radius:6px;transition:background .15s ease,border-color .15s ease}.switcher select:hover{background:#f7eedf1c;border-color:#f7eedf57}.switcher:after{content:"";position:absolute;right:15px;top:50%;width:6px;height:6px;margin-top:-5px;border-right:1.2px solid #b6ab98;border-bottom:1.2px solid #b6ab98;transform:rotate(45deg);pointer-events:none}.nav{display:flex;gap:22px;justify-content:flex-end;min-width:0}.nav-link{border:0;background:transparent;color:#cdc1ad;cursor:pointer;padding:6px 0;font-size:12.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;position:relative}.nav-link:hover,.nav-link.is-active{color:#f4ead8}.nav-link.is-active:after{content:"";position:absolute;left:0;right:0;bottom:-2px;height:1px;background:var(--accent-2)}.capture-button{display:inline-flex;align-items:center;gap:8px;position:relative;overflow:hidden;border:0;background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 88%,#fff) 0%,var(--accent) 55%);color:#f7eddd;padding:10px 18px;cursor:pointer;font-size:12px;font-weight:600;letter-spacing:.15em;text-transform:uppercase;border-radius:var(--r);box-shadow:inset 0 1px #fff5e629,0 1px 2px #141d184d;transition:filter .18s ease,box-shadow .18s ease}.capture-button:hover{filter:brightness(.93);box-shadow:inset 0 1px #fff5e61f,0 2px 6px #141d1857}.capture-button:before{content:"";position:absolute;top:0;bottom:0;left:0;width:45%;background:linear-gradient(100deg,transparent 0%,rgba(255,246,232,.45) 50%,transparent 100%);transform:translate(-180%) skew(-18deg);pointer-events:none}@media (prefers-reduced-motion: no-preference){.capture-button:hover:before{animation:cap-sheen .7s ease}}@keyframes cap-sheen{0%{transform:translate(-180%) skew(-18deg)}to{transform:translate(340%) skew(-18deg)}}.app-shell{height:calc(100vh - 58px);display:grid;grid-template-columns:minmax(0,1fr) 340px}.workspace{min-width:0;overflow:auto;display:flex;flex-direction:column}.view{display:none}.view.is-active{display:block}.toolbar{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:16px;padding:12px 22px;background:color-mix(in srgb,var(--paper) 88%,white);border-bottom:1px solid var(--line-soft)}.search-field{position:relative;flex:1 1 auto;min-width:0;display:flex;align-items:center;height:42px;background:var(--field);border:1px solid var(--line);border-radius:20px;transition:border-color .15s ease,box-shadow .15s ease}.search-field:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.search-field .ico{display:grid;place-items:center;width:46px;height:100%;color:var(--muted-2);flex-shrink:0}.search-field .ico svg{width:16px;height:16px}.search-input{flex:1;min-width:0;height:100%;border:0;background:transparent;color:var(--ink);padding:0 6px 0 0;font-size:14px;letter-spacing:.01em;outline:none}.search-input::placeholder{color:var(--muted-2)}.search-field .kbd{margin-right:12px;display:inline-flex;align-items:center;padding:3px 7px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:var(--r);flex-shrink:0}.result-count{flex-shrink:0;font-size:13px;color:var(--muted);letter-spacing:.02em;white-space:nowrap}.result-count b{color:var(--ink);font-weight:600;font-variant-numeric:tabular-nums}.tag-filter-badge{display:inline-flex;align-items:center;gap:4px;background:var(--accent);color:#fff;border:0;border-radius:var(--r);font-size:12px;padding:2px 8px;cursor:pointer;margin-left:8px}.tag-filter-badge:hover{opacity:.85}.entry-table{width:100%;font-size:12.5px}.entry-header-row{display:flex;align-items:stretch;position:sticky;top:67px;z-index:2;background:color-mix(in srgb,var(--paper) 92%,white);border-bottom:1px solid var(--line-soft);color:var(--muted);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600;display:flex;align-items:center}#entries-body>div{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft)}#entries-body>div>div{padding:7px 10px;flex-shrink:0;overflow:hidden}#entries-body>div:nth-child(2n){background:#f2ede5}#entries-body>div:nth-child(odd){background:var(--paper-3)}#entries-body>div.is-selected{background:#eee2d2;outline:2px solid var(--accent);outline-offset:-2px}.col-added{width:162px;color:var(--muted)}.col-title{flex:1 1 0;min-width:0;overflow:hidden;display:flex;align-items:center;gap:.42em}.col-type{width:116px}.col-size{width:100px;display:flex;flex-direction:column;justify-content:center;gap:1px}.size-total{font-variant-numeric:tabular-nums}.size-cached-pct{font-size:10px;color:var(--muted);opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.col-url{flex:0 0 30%;min-width:0;overflow:hidden}.entry-header-row>div:first-child,#entries-body>div>div:first-child{padding-left:22px}.entry-header-row>div:last-child,#entries-body>div>div:last-child{padding-right:22px}.entry-title{color:var(--link);font-weight:700;min-width:0}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600}.source-icon{display:flex;align-items:center;justify-content:center;width:1.05em;height:1.05em;flex-shrink:0}.source-icon>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.source-icon svg{width:100%;height:100%}.url-cell{color:#555b55;white-space:nowrap;text-overflow:ellipsis;word-break:break-all}#entries-body .url-cell:hover,#entries-body .is-selected .url-cell{overflow:visible;white-space:normal}.type-pill{display:inline-block;padding:2px 6px;background:#d8e3df;color:#275a5f;border:1px solid #bfd0ca;border-radius:var(--r)}#runs-view .entry-table{border-collapse:collapse;table-layout:auto}#runs-view .entry-table th{position:sticky;top:0;z-index:1;text-align:left;padding:10px;background:color-mix(in srgb,var(--paper) 92%,white);color:var(--muted);border-bottom:1px solid var(--line-soft);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}#runs-view .entry-table td{padding:10px;border-bottom:1px solid var(--line-soft);vertical-align:top}#runs-view .entry-table tr:nth-child(2n) td{background:#f2ede5}#runs-view .entry-table tr:nth-child(odd) td{background:var(--paper-3)}.context-rail{border-left:1px solid var(--line);background:var(--paper);padding:20px 20px 32px;overflow:auto}.rail-eyebrow{font-size:10.5px;font-weight:600;letter-spacing:.16em;text-transform:uppercase;color:var(--muted-2);margin-bottom:16px}.rail-title{display:block;font-family:var(--sans);font-weight:700;font-size:15.5px;line-height:1.4;color:var(--ink);margin:0 0 16px;word-break:break-word}.url-tile{display:flex;align-items:center;gap:9px;padding:10px 12px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);margin-bottom:20px;text-decoration:none}.url-tile:hover{background:var(--field);border-color:var(--accent)}.url-tile .ico{color:var(--ink);flex-shrink:0;display:grid;place-items:center}.url-tile .ico svg{width:15px;height:15px}.url-tile .u-text{min-width:0;flex:1;font-size:12.5px;color:var(--link);font-family:ui-monospace,SF Mono,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.url-tile .ext{color:var(--muted-2);flex-shrink:0}.url-tile .ext svg{width:13px;height:13px;display:block}.meta-list{margin-bottom:24px;border-top:1px solid var(--line-soft)}.meta-item{display:grid;grid-template-columns:92px 1fr;gap:14px;align-items:baseline;padding:9px 0;border-bottom:1px solid var(--line-soft)}.meta-k{font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted-2)}.meta-v{font-size:13.5px;color:var(--ink);word-break:break-word;line-height:1.4}.meta-v.mono{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:12px;color:var(--muted)}.rail-section{margin-bottom:24px}.rail-section-heading{display:flex;align-items:baseline;gap:8px;font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;color:var(--muted-2);margin-bottom:9px;padding-bottom:8px;border-bottom:1px solid var(--line)}.rail-section-heading .num{color:var(--muted-2);font-weight:600}.artifact-list{list-style:none;margin:0;padding:0}.artifact-link{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:7px 2px;border-bottom:1px solid var(--line-soft);text-decoration:none}.artifact-link:last-child{border-bottom:0}.artifact-name{font-size:13px;color:var(--link);min-width:0;word-break:break-word}.artifact-link:hover .artifact-name{text-decoration:underline}.artifact-size{font-size:11.5px;color:var(--muted-2);flex-shrink:0;font-variant-numeric:tabular-nums}.tags-wrap{display:flex;flex-wrap:wrap;gap:7px;margin:0 0 12px}.tag-pill{display:inline-flex;align-items:center;gap:7px;background:var(--paper-2);border:1px solid var(--line);border-radius:var(--r);font-size:12px;padding:4px 7px 4px 10px;color:var(--ink)}.tag-pill .remove{border:0;background:transparent;cursor:pointer;color:var(--muted-2);width:15px;height:15px;display:grid;place-items:center;font-size:13px;line-height:1}.tag-pill .remove:hover{color:var(--accent)}.tags-empty{font-size:13px;color:var(--muted);margin:0 0 11px}.tag-input-wrap{display:flex;align-items:center;gap:8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);padding:2px 2px 2px 11px;transition:border-color .15s ease,box-shadow .15s ease}.tag-input-wrap:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 12%,transparent)}.tag-input-wrap .hash{color:var(--muted-2);font-size:13px}.tag-input{flex:1;min-width:0;border:0;background:transparent;color:var(--ink);font-size:13px;padding:6px 0;outline:none;font-family:ui-monospace,SF Mono,Menlo,monospace}.tag-add-btn{border:0;background:var(--ink);color:var(--paper-3);padding:6px 13px;font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;border-radius:var(--r);cursor:pointer;white-space:nowrap}.tag-add-btn:hover{background:#2c332b}.coll-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 13px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);margin-bottom:6px;transition:border-color .15s ease}.coll-row:hover{border-color:var(--accent)}.coll-name{font-size:13px;color:var(--ink);font-weight:500}.vis-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:999px;padding:3px 10px}.vis-badge:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent-2)}.rail-delete-zone{margin-top:24px;padding-top:20px;border-top:1px solid var(--line-soft)}.rail-delete-btn{width:100%;padding:8px 14px;background:none;border:1px solid color-mix(in srgb,var(--accent) 45%,transparent);color:var(--accent);border-radius:var(--r);cursor:pointer;font-size:12.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;transition:background .15s ease,border-color .15s ease}.rail-delete-btn:hover{background:color-mix(in srgb,var(--accent) 8%,transparent);border-color:var(--accent)}.rail-rearchive-btn{width:100%;padding:6px 12px;background:var(--surface-2, #2a2a2a);color:var(--text, #e0e0e0);border:1px solid var(--border, #444);border-radius:4px;cursor:pointer;font-size:13px}.rail-rearchive-btn:hover:not(:disabled){background:var(--surface-3, #333)}.rail-rearchive-btn:disabled{opacity:.6;cursor:not-allowed}.capture-dialog{border:1px solid var(--line);background:var(--paper);padding:0;width:min(540px,calc(100vw - 32px));border-radius:var(--r3);box-shadow:0 20px 60px #141d1847}.capture-dialog::backdrop{background:#141d1873}.capture-dialog-inner{padding:28px}.capture-dialog-title{margin:0;font-size:22px;font-family:var(--display);font-weight:600}.capture-label{display:block;font-size:11px;font-weight:600;margin-bottom:6px;color:var(--muted-2);text-transform:uppercase;letter-spacing:.06em}.capture-input{width:100%;height:44px;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:0 14px;font-size:15px;margin-bottom:10px;border-radius:var(--r2);outline:none;transition:border-color .15s ease,box-shadow .15s ease}.capture-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.form-field .capture-input{margin-bottom:0}.capture-error{color:var(--accent);font-size:13px;margin-bottom:10px;min-height:18px}.capture-actions{display:flex;flex-direction:column;gap:8px;margin-top:18px}.capture-submit{border:0;background:var(--ink);color:var(--paper);padding:13px 20px;border-radius:var(--r2);cursor:pointer;font-weight:600;font-size:15px;width:100%;min-width:220px;letter-spacing:.01em}.capture-submit:hover{opacity:.85}.capture-submit:disabled{opacity:.45;cursor:default}.capture-cancel{border:0;background:none;color:var(--muted);padding:7px 18px;border-radius:var(--r);cursor:pointer;font-size:13px;text-align:center;width:100%}.capture-cancel:hover{color:var(--ink);background:var(--paper-2)}.capture-advanced{margin-top:12px}.capture-advanced-toggle{display:flex;align-items:center;gap:5px;background:none;border:0;cursor:pointer;color:var(--muted);font-size:12.5px;padding:4px 0;border-radius:var(--r)}.capture-advanced-toggle:hover{color:var(--ink)}.capture-chevron{width:14px;height:14px;flex-shrink:0;transition:transform .18s ease}.capture-chevron--open{transform:rotate(180deg)}.capture-advanced-panel{margin-top:8px;padding:10px 12px;border:1px solid var(--line);border-radius:var(--r2);background:var(--paper-2)}.capture-ext-row{display:flex;align-items:center;justify-content:space-between;gap:12px;cursor:default}.capture-ext-label{flex:1;min-width:0}.capture-ext-name{display:block;font-size:13px;font-weight:600;color:var(--ink)}.capture-ext-desc{display:block;font-size:11.5px;color:var(--muted);margin-top:1px}.capture-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.capture-dialog-close{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-dialog-close svg{width:14px;height:14px}.capture-dialog-close:hover{background:var(--paper-2);color:var(--ink)}.capture-rows{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}.capture-row{display:flex;flex-direction:column;gap:3px}.capture-row-main{display:flex;align-items:center;gap:8px}.capture-row-main .capture-input{margin-bottom:0}.capture-quality{flex-shrink:0;height:32px;padding:0 6px;border:1px solid var(--line);border-radius:var(--r);background:var(--paper);color:var(--ink);font-size:12px;cursor:pointer;outline:none;transition:border-color .15s}.capture-quality:hover{border-color:var(--accent-2)}.capture-quality:focus{border-color:var(--accent)}.capture-quality:disabled{opacity:.5;cursor:default}.capture-quality-probing{flex-shrink:0;font-size:12px;color:var(--muted);padding:0 4px;letter-spacing:.05em}.capture-quality-hint{flex-shrink:0;font-size:12px;color:var(--muted);font-style:italic}.cap-dot{flex-shrink:0;width:20px;height:20px;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:700;line-height:1}.cap-dot--idle{background:var(--paper-2)}.cap-dot--running{background:#fdefd8;color:#8a4f10}.cap-dot--ok{background:#d8eddf;color:#235c35}.cap-dot--err{background:#f5ddd8;color:#8d3f30}.cap-spinner{display:block;width:10px;height:10px;border:2px solid currentColor;border-top-color:transparent;border-radius:50%;animation:cap-spin .7s linear infinite}@keyframes cap-spin{to{transform:rotate(360deg)}}.capture-row-action{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-row-action svg{width:12px;height:12px}.capture-row-action:hover{color:var(--accent);background:var(--paper-2)}.capture-row-remove:hover{color:var(--accent)}.capture-row-error{margin:0;padding-left:28px;font-size:12px;color:var(--accent);line-height:1.45}.capture-add-row{display:flex;align-items:center;gap:7px;width:100%;background:none;border:1px dashed var(--line);border-radius:var(--r);color:var(--muted);font-size:13px;cursor:pointer;padding:7px 12px;margin-top:4px;margin-bottom:18px;transition:border-color .15s,color .15s,background .15s}.capture-add-row svg{width:13px;height:13px;flex-shrink:0}.capture-add-row:hover{border-color:var(--accent-2);color:var(--ink);background:var(--paper-2)}.toast-stack{position:fixed;bottom:24px;right:24px;z-index:9000;display:flex;flex-direction:column;gap:10px;width:340px;max-width:calc(100vw - 32px);pointer-events:none}.toast{pointer-events:auto;background:var(--paper);border:1px solid var(--line);border-radius:var(--r2);box-shadow:0 6px 24px #141d182e,0 1px 4px #141d181a;overflow:hidden;animation:toast-slide-in .22s cubic-bezier(.22,.68,0,1.2)}@keyframes toast-slide-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.toast--error{border-left:3px solid var(--accent)}.toast--warning{border-left:3px solid #e8a000}.toast--success{border-left:3px solid #22a855}.toast-top{display:flex;align-items:flex-start;gap:10px;padding:12px 12px 12px 14px}.toast-icon{flex-shrink:0;font-size:13px;font-weight:700;color:var(--accent);margin-top:2px}.toast--success .toast-icon{color:#22a855}.toast--warning .toast-icon{color:#e8a000}.toast-body{flex:1;min-width:0}.toast-headline{display:block;font-size:13.5px;font-weight:600;color:var(--ink);line-height:1.3}.toast-locator{display:block;font-size:12px;color:var(--muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-btns{display:flex;align-items:center;gap:6px;flex-shrink:0}.toast-view-btn{background:none;border:1px solid var(--line);color:var(--link);font-size:12px;cursor:pointer;padding:3px 9px;border-radius:var(--r);white-space:nowrap}.toast-view-btn:hover{background:var(--paper-2);border-color:var(--link)}.toast-dismiss{background:none;border:0;cursor:pointer;color:var(--muted);font-size:20px;line-height:1;width:24px;height:24px;display:grid;place-items:center;border-radius:var(--r);padding:0}.toast-dismiss:hover{color:var(--ink);background:var(--paper-2)}.toast-error-detail{margin:0;padding:10px 14px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);background:var(--paper-2);border-top:1px solid var(--line);white-space:pre-wrap;word-break:break-word;max-height:200px;overflow-y:auto}.toast-warning-detail{margin:0;padding:10px 14px 12px;font-size:12px;line-height:1.55;color:var(--muted);background:var(--paper-2);border-top:1px solid var(--line);white-space:pre-wrap;word-break:break-word}.toast-ignore-btn{color:var(--muted)}.ext-toggle{flex-shrink:0;position:relative;width:44px;height:24px;border-radius:12px;background:var(--line);border:0;cursor:pointer;transition:background .18s ease;padding:0}.ext-toggle--sm{width:36px;height:20px;border-radius:10px}.ext-toggle--on{background:var(--ink)}.ext-toggle:disabled{opacity:.4;cursor:default}.ext-toggle-knob{position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:var(--paper);transition:transform .18s ease;display:block;box-shadow:0 1px 3px #0003}.ext-toggle--sm .ext-toggle-knob{width:14px;height:14px;top:3px;left:3px}.ext-toggle--on .ext-toggle-knob{transform:translate(20px)}.ext-toggle--sm.ext-toggle--on .ext-toggle-knob{transform:translate(16px)}.ext-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px}.ext-card{border:1px solid var(--line);border-radius:var(--r2);padding:16px 18px;background:var(--paper)}.ext-card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.ext-card-info{flex:1;min-width:0}.ext-card-name{display:block;font-weight:600;font-size:14px;margin-bottom:4px}.ext-card-desc{display:block;font-size:13px;color:var(--muted);line-height:1.5}.ext-card-hint{display:block;font-size:12px;color:#e8a000;margin-top:6px}.ext-card-hint code{font-size:11.5px}.form-hint{font-size:13px;color:var(--muted);line-height:1.55;margin:0}.muted{color:var(--muted)}.admin-view{padding:22px}.admin-list{display:grid;gap:10px;max-width:780px}.admin-archive{border:1px solid var(--line);background:var(--paper-3);padding:12px;border-radius:var(--r2)}.tag-tree{padding:20px 22px;max-width:320px}.tag-tree-header{display:flex;align-items:baseline;gap:10px;margin-bottom:14px;border-bottom:1px solid var(--line-soft);padding-bottom:10px}.tag-tree-title{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}.tag-tree-active{font-size:12px;color:var(--muted-2);font-style:italic}.tag-tree-list{list-style:none;margin:0;padding:0}.tag-children{padding-left:16px}.tag-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 0;text-align:left;font-size:13px;display:block;width:100%}.tag-node-btn:hover{text-decoration:underline}.tag-node-btn.is-active{font-weight:600;color:var(--ink)}.tag-node-row{display:flex;align-items:center;gap:4px}.tag-node-row .tag-node-btn{flex:1 1 0;min-width:0;display:flex;align-items:center;gap:4px;width:auto}.tag-node-btn .edit-icon{width:.75em;height:.75em;flex-shrink:0;vertical-align:-.1em;opacity:.35}.tag-node-btn:hover .edit-icon{opacity:.65}.tag-node-delete{flex-shrink:0;border:0;background:transparent;color:var(--muted-2);cursor:pointer;padding:0 3px;font-size:14px;line-height:1;opacity:0}.tag-node-row:hover .tag-node-delete{opacity:1}.tag-node-delete:hover{color:var(--accent)}.tag-rename-input{font-size:13px;flex:1 1 0;min-width:0;padding:2px 5px;border:1px solid var(--accent);border-radius:var(--r);background:var(--field);color:var(--ink);outline:none}.collections-view{padding:24px}.collections-heading{margin:0 0 16px;font-size:22px;font-family:var(--display);font-weight:600}.collections-error{color:var(--accent);font-size:13px;margin-bottom:8px}.coll-dismiss{background:none;border:none;cursor:pointer;color:var(--accent);font-size:16px;line-height:1;padding:0 4px}.collections-layout{display:grid;grid-template-columns:220px 1fr;gap:0;border:1px solid var(--line);border-radius:var(--r2);min-height:340px}.collections-sidebar{border-right:1px solid var(--line);overflow-y:auto}.coll-sidebar-row{display:flex;flex-direction:column;width:100%;padding:10px 14px;border:none;border-bottom:1px solid var(--line-soft);background:none;cursor:pointer;text-align:left;gap:2px}.coll-sidebar-row:hover{background:var(--paper-2)}.coll-sidebar-row.is-active{background:var(--paper-2);border-left:3px solid var(--accent)}.coll-row-name{font-size:14px;font-weight:600;color:var(--ink)}.coll-row-meta{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.coll-detail{padding:20px 24px;display:flex;flex-direction:column;gap:16px}.coll-detail--empty{justify-content:center;align-items:center}.coll-detail-header{display:flex;align-items:center;gap:12px}.coll-detail-name{margin:0;font-size:18px;font-family:var(--display);font-weight:600;flex:1}.coll-detail-name--editable{cursor:pointer}.coll-detail-name--editable:hover{color:var(--link)}.coll-edit-hint{font-size:14px;opacity:.5;margin-left:4px}.coll-rename-input{flex:1;font-size:16px;font-family:var(--display);border:1px solid var(--line);padding:4px 8px;background:var(--field);color:var(--ink);border-radius:var(--r)}.coll-delete-btn{border:1px solid var(--accent);background:none;color:var(--accent);padding:5px 12px;font-size:13px;cursor:pointer;border-radius:var(--r)}.coll-delete-btn:hover{background:var(--accent);color:var(--paper)}.coll-detail-vis{display:flex;align-items:center;gap:10px}.coll-vis-label{font-size:13px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;white-space:nowrap}.coll-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:4px 8px;font-size:13px;border-radius:var(--r)}.coll-section-heading{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px}.coll-entries-section{flex:1}.coll-entries-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}.coll-entry-row{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid var(--line-soft)}.coll-entry-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.coll-entry-title{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.coll-entry-kind{font-size:11px;text-transform:uppercase;letter-spacing:.04em}.coll-entry-actions{display:flex;align-items:center;gap:6px;flex-shrink:0}.coll-entry-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:3px 6px;font-size:12px;border-radius:var(--r)}.coll-entry-remove{border:none;background:none;cursor:pointer;color:var(--muted);font-size:18px;line-height:1;padding:0 4px}.coll-entry-remove:hover{color:var(--accent)}.coll-add-entry-form{border-top:1px solid var(--line-soft);padding-top:12px}.coll-add-entry-row{display:flex;gap:8px;align-items:center}.coll-add-entry-input{flex:1;border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:6px 10px;font-size:13px;min-width:0;border-radius:var(--r)}.coll-add-btn{border:none;background:var(--ink);color:var(--paper);padding:6px 14px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;border-radius:var(--r)}.coll-add-btn:hover{opacity:.85}.coll-add-btn:disabled{opacity:.45;cursor:default}.auth-loading{min-height:100vh;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:15px;background:var(--paper)}.user-menu{display:flex;align-items:center;gap:14px;padding-left:6px;flex-shrink:0}.user-name{font-size:12.5px;color:var(--muted-2);letter-spacing:.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:140px}.logout-btn{border:1px solid rgba(255,255,255,.18);background:transparent;color:#c8bfb0;font-size:12px;padding:4px 11px;border-radius:var(--r);cursor:pointer;white-space:nowrap;transition:background .15s,color .15s}.logout-btn:hover{background:#ffffff1a;color:var(--paper)}.logout-btn:disabled{opacity:.5;cursor:default}.login-page,.setup-page{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--paper)}.login-card,.setup-card{width:100%;max-width:360px;padding:40px 36px 44px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);box-shadow:0 2px 20px #141d1812}.login-brand,.setup-brand{font-family:var(--display);font-size:32px;font-weight:600;color:var(--ink);letter-spacing:-.01em;margin:0 0 6px}.login-tagline,.setup-tagline{font-size:13px;color:var(--muted);margin:0 0 28px}.login-field,.setup-field{display:flex;flex-direction:column;gap:5px;margin-bottom:14px}.login-label,.setup-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.login-input,.setup-input{width:100%;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:9px 11px;font-size:14px;border-radius:var(--r2);outline:none;transition:border-color .15s}.login-input:focus,.setup-input:focus{border-color:var(--accent)}.login-error,.setup-error{font-size:13px;color:var(--accent);margin:4px 0 8px}.login-submit,.setup-submit{width:100%;margin-top:8px;border:none;background:var(--top);color:var(--paper);font-size:14px;font-weight:600;padding:11px 16px;border-radius:var(--r2);cursor:pointer;letter-spacing:.02em;transition:opacity .15s}.login-submit:hover,.setup-submit:hover{opacity:.85}.login-submit:disabled,.setup-submit:disabled{opacity:.45;cursor:default}.view-tabs{display:flex;gap:2px;margin-bottom:22px;border-bottom:1px solid var(--line-soft);padding-bottom:0}.view-tab{border:none;background:none;color:var(--muted);font-size:13px;font-weight:600;padding:7px 14px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;letter-spacing:.02em;transition:color .12s;text-transform:uppercase;letter-spacing:.06em;font-size:11.5px}.view-tab:hover{color:var(--ink)}.view-tab.is-active{color:var(--ink);border-bottom-color:var(--accent)}.form-section{margin-bottom:32px}.form-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.form-row{display:flex;gap:8px;margin-bottom:10px}.form-field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px}.form-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}.field-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s;min-width:0}.field-input:focus{border-color:var(--accent)}.field-input--flex{flex:1}.form-msg{font-size:13px;margin:6px 0}.form-msg--ok{color:var(--link)}.form-msg--err{color:var(--accent)}.btn-primary{border:none;background:var(--top);color:var(--paper);font-size:13px;font-weight:600;padding:8px 16px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.btn-primary:hover{opacity:.85}.btn-primary:disabled{opacity:.45;cursor:default}.btn-ghost{border:1px solid var(--line);background:none;color:var(--ink);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-ghost:hover{background:var(--paper-2)}.btn-danger{border:1px solid var(--accent);background:none;color:var(--accent);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-danger:hover{background:var(--accent);color:var(--paper)}.admin-view h1{font-family:var(--display);font-weight:600;font-size:26px;margin:0 0 20px}.admin-table{width:100%;border-collapse:collapse;font-size:13px;margin-bottom:28px}.admin-table th{text-align:left;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);padding:8px 10px;border-bottom:1px solid var(--line);background:var(--paper-2)}.admin-table th:first-child{padding-left:16px}.admin-table td{padding:9px 10px;border-bottom:1px solid var(--line-soft);color:var(--ink);vertical-align:middle}.admin-table td:first-child{padding-left:16px}.admin-table tr:hover td{background:var(--paper-2)}.admin-row-disabled td{opacity:.45}.admin-section{margin-bottom:36px;max-width:860px}.admin-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.admin-section h3{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin:22px 0 10px}.admin-form{display:flex;flex-direction:column;gap:8px;max-width:480px}.admin-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s}.admin-input:focus{border-color:var(--accent)}.admin-action-btn{border:1px solid var(--line);background:none;color:var(--ink);font-size:12px;padding:4px 10px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.admin-action-btn:hover{border-color:var(--accent);color:var(--accent)}.status-badge{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.status-active{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.status-disabled{background:#ede8e0;color:var(--muted);border:1px solid var(--line)}.run-status{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.run-status--completed{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.run-status--failed{background:#f5ddd8;color:#8d3f30;border:1px solid #e0b8b0}.run-status--in-progress{background:#fdefd8;color:#8a4f10;border:1px solid #f0cfa0}.run-row--failed{cursor:pointer}.run-row--failed:hover td{background:#fdf0ed!important}.run-expand-hint{margin-left:6px;font-size:10px;color:var(--accent);vertical-align:middle}.run-error-row td{padding:0!important;background:var(--paper-2)!important}.run-error-detail{margin:0;padding:10px 16px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);white-space:pre-wrap;word-break:break-word;max-height:220px;overflow-y:auto}.token-banner{background:#d8eddf;border:1px solid #b4d9be;padding:12px 14px;margin-bottom:16px;font-size:13px;border-radius:var(--r2)}.token-banner code{word-break:break-all;display:block;margin-top:6px;padding:6px 8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r);font-size:12px;font-family:ui-monospace,SF Mono,Menlo,monospace}.token-dismiss{margin-top:8px;font-size:12px;border:1px solid var(--line);background:none;cursor:pointer;padding:3px 8px;border-radius:var(--r);color:var(--muted)}.token-dismiss:hover{background:var(--paper-2)}.token-row{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--line);background:var(--paper-3);padding:10px 12px;border-radius:var(--r);margin-bottom:6px}.token-row-info strong{font-size:14px;display:block}.token-row-info .muted{font-size:12px;margin-top:2px}.token-create-row{display:flex;gap:8px;margin-bottom:16px}.checkbox-row{display:flex;align-items:center;gap:10px;margin-bottom:12px;cursor:pointer;font-size:14px}.checkbox-row input[type=checkbox]{width:15px;height:15px;accent-color:var(--accent)}.coll-create-details{margin-top:16px}.coll-create-details summary{font-weight:600;cursor:pointer;font-size:13px;color:var(--link);list-style:none;display:flex;align-items:center;gap:6px;padding:8px 12px;border:1px solid var(--line-soft);border-radius:var(--r2);background:var(--paper-3);width:fit-content}.coll-create-details summary:hover{background:var(--paper-2)}.coll-create-details[open] summary{border-bottom-left-radius:0;border-bottom-right-radius:0}.coll-create-form{border:1px solid var(--line-soft);border-top:none;padding:14px;border-radius:0 0 var(--r2) var(--r2);background:var(--paper-3);display:flex;flex-direction:column;gap:10px;max-width:440px}@media (max-width: 900px){.topbar{grid-template-columns:1fr auto;height:auto;min-height:58px;padding:12px}.switcher,.nav{grid-column:1 / -1}.nav{justify-content:flex-start;overflow-x:auto}.app-shell{height:auto;grid-template-columns:1fr}.context-rail{border-left:0;border-top:1px solid var(--line)}.entry-table{min-width:860px}}.rail-title--editable{cursor:pointer}.rail-title--editable:hover{opacity:.75}.rail-title--editable .edit-icon{display:inline-block;width:.75em;height:.75em;margin-left:.35em;vertical-align:middle;opacity:0;transition:opacity .1s;flex-shrink:0}.rail-title--editable:hover .edit-icon{opacity:.5}.rail-title-input{width:100%;font:inherit;font-size:inherit;font-weight:600;background:transparent;border:none;border-bottom:1px solid currentColor;color:inherit;padding:0;margin:0 0 8px;outline:none}.preview-panel{flex:1;display:flex;flex-direction:column;min-height:0}.preview-panel-loading,.preview-panel-empty{flex:1;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:8px;color:var(--muted-2);font-size:14px;text-align:center;padding:24px}.preview-video-wrap{flex:1;display:flex;align-items:center;justify-content:center;background:#0d0d0b;min-height:200px}.preview-video-wrap video{max-width:100%;max-height:100%;width:100%;display:block}.preview-iframe-wrap{flex:1;display:flex;flex-direction:column;min-height:0}.preview-iframe-toolbar{display:flex;flex-direction:column;gap:2px;padding:6px 12px;background:var(--paper-2);border-bottom:1px solid var(--line);flex-shrink:0;text-transform:none;letter-spacing:normal}.preview-iframe-toolbar span{font-size:11px;color:var(--muted-2)}.preview-iframe-toolbar a{margin-left:auto;color:var(--link);font-size:12px;text-decoration:none;padding:3px 8px;border:1px solid var(--line);border-radius:var(--r2);background:var(--field);transition:border-color .12s}.preview-iframe-toolbar a:hover{border-color:var(--accent);text-decoration:none}.preview-iframe-wrap iframe{flex:1;width:100%;border:none;background:#fff;min-height:0}.preview-image-wrap{flex:1;display:flex;align-items:center;justify-content:center;padding:20px;background:var(--paper-2)}.preview-image-wrap img{max-width:100%;max-height:100%;object-fit:contain;border-radius:var(--r3);cursor:zoom-in;display:block;box-shadow:0 4px 24px #0000001a}.preview-tweet-wrap{flex:1;min-height:0;overflow-y:auto;padding:12px 16px;background:var(--paper-2);scrollbar-width:thin;scrollbar-color:var(--line) transparent}.preview-tweet-wrap::-webkit-scrollbar{width:8px}.preview-tweet-wrap::-webkit-scrollbar-track{background:transparent}.preview-tweet-wrap::-webkit-scrollbar-thumb{background:var(--line);border-radius:999px;border:2px solid transparent;background-clip:padding-box}.preview-tweet-wrap::-webkit-scrollbar-thumb:hover{background:var(--muted-2);background-clip:padding-box;border:2px solid transparent}.tw-card{border:1px solid var(--line);border-radius:12px;padding:16px;background:var(--paper);max-width:560px;margin:0 auto 12px}.tw-thread{max-width:560px;margin:0 auto}.tw-thread-item{display:flex;gap:0;margin-bottom:0}.tw-thread-connector{display:flex;flex-direction:column;align-items:center;flex-shrink:0;width:52px;padding-top:2px}.tw-thread-avatar-col{display:flex;flex-direction:column;align-items:center;flex-shrink:0}.tw-thread-line{width:2px;background:var(--line);flex:1;min-height:16px;margin:4px 0}.tw-thread-body{flex:1;min-width:0;padding:0 0 16px 12px}.tw-thread-body:last-child{padding-bottom:0}.tw-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;flex-shrink:0;display:block}.tw-avatar-ph{width:40px;height:40px;border-radius:50%;background:var(--paper-2);border:1px solid var(--line);flex-shrink:0}.tw-header{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;margin-bottom:6px}.tw-author-name{font-size:14.5px;font-weight:700;color:var(--ink)}.tw-author-handle{font-size:13px;color:var(--muted-2)}.tw-dot{color:var(--muted-2);font-size:13px}.tw-date{font-size:13px;color:var(--muted-2)}.tw-text{font-size:15px;line-height:1.65;color:var(--ink);white-space:pre-line;word-break:break-word;margin-bottom:10px}.tw-text a{color:var(--link);text-decoration:none}.tw-text a:hover{text-decoration:underline}.tw-stats{display:flex;gap:20px;color:var(--muted-2);font-size:13px;margin-top:10px;padding-top:10px;border-top:1px solid var(--line-soft)}.tw-stats span{display:flex;align-items:center;gap:4px}.tw-article{max-width:598px;margin:0 auto}.tw-article-cover{width:100%;display:block;object-fit:cover;max-height:380px}.tw-article-meta{padding:20px 16px 0}.tw-article-title{font-size:22px;font-weight:800;letter-spacing:-.3px;color:var(--ink);line-height:1.3;margin-bottom:14px}.tw-article-author-row{display:flex;align-items:center;gap:12px;margin-bottom:14px}.tw-article-author-name{font-size:14px;font-weight:700;color:var(--ink)}.tw-article-author-sub{font-size:13px;color:var(--muted-2)}.tw-article-divider{border:none;border-top:1px solid var(--line);margin:0}.tw-article-body{padding:8px 16px 60px}.tw-b-h1{font-size:24px;font-weight:800;letter-spacing:-.3px;color:var(--ink);line-height:1.25;margin:22px 0 10px}.tw-b-h2{font-size:19px;font-weight:700;letter-spacing:-.15px;color:var(--ink);line-height:1.3;margin:20px 0 8px}.tw-b-p{font-size:16px;color:var(--ink);line-height:1.72;margin-bottom:14px}.tw-b-p:empty{display:none}.tw-b-spacer{height:6px;display:block}.tw-b-blockquote{border-left:3px solid var(--line);padding:2px 14px;margin:14px 0;color:var(--muted);font-size:16px;line-height:1.65}.tw-b-hr{border:none;border-top:1px solid var(--line);margin:24px 0}.tw-b-img{width:100%;display:block;border-radius:10px;margin:14px 0}.tw-b-ul,.tw-b-ol{margin:10px 0 14px;padding-left:26px}.tw-b-li{font-size:16px;color:var(--ink);line-height:1.65;margin-bottom:6px}.tw-b-code{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:.875em;background:var(--paper-2);padding:2px 5px;border-radius:4px;color:var(--ink)}.tw-b-pre{background:var(--paper-2);border:1px solid var(--line);border-radius:8px;padding:14px 16px;overflow-x:auto;margin:12px 0}.tw-b-pre code{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:13px;line-height:1.6}.tw-b-tweet-link{display:flex;align-items:center;gap:10px;border:1px solid var(--line);border-radius:10px;padding:12px 14px;margin:12px 0;color:var(--muted);font-size:14px;text-decoration:none;background:var(--paper-3);transition:background .12s}.tw-b-tweet-link:hover{background:var(--field)}.tw-b-tweet-link svg{flex-shrink:0;color:var(--ink)}.audio-bar{position:fixed;bottom:0;left:0;right:0;height:72px;background:var(--paper);border-top:1px solid var(--line);display:flex;align-items:center;gap:20px;padding:0 24px;z-index:100;box-shadow:0 -2px 16px #00000014}.audio-bar-info{display:flex;align-items:center;gap:10px;min-width:0;flex:0 0 200px}.audio-bar-icon{flex-shrink:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center}.audio-bar-icon svg{width:20px;height:20px}.audio-bar-title{font-size:13px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;font-weight:500}.audio-bar-controls{flex:1;display:flex;align-items:center;gap:12px;min-width:0}.audio-bar-play-btn{width:38px;height:38px;border-radius:50%;background:var(--accent);color:var(--paper);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .12s,transform .1s}.audio-bar-play-btn:hover{background:var(--accent-2)}.audio-bar-play-btn:active{transform:scale(.93)}.audio-bar-play-btn svg{width:15px;height:15px}.audio-bar-seek{flex:1;min-width:0;display:flex;align-items:center;gap:8px}.audio-bar-seek input[type=range]{flex:1;accent-color:var(--accent);height:4px;cursor:pointer;min-width:0}.audio-bar-time{font-size:11.5px;color:var(--muted-2);white-space:nowrap;min-width:80px;text-align:right;font-variant-numeric:tabular-nums}.audio-bar-right{flex:0 0 auto;display:flex;align-items:center;gap:10px}.audio-bar-volume{display:flex;align-items:center;gap:6px}.audio-bar-volume svg{width:14px;height:14px;color:var(--muted-2);flex-shrink:0}.audio-bar-volume input[type=range]{width:72px;accent-color:var(--accent);cursor:pointer}.audio-bar-close{width:28px;height:28px;border-radius:50%;border:none;background:transparent;color:var(--muted-2);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:18px;padding:0;line-height:1;transition:background .12s,color .12s}.audio-bar-close:hover{background:var(--field);color:var(--ink)}.preview-modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:200;background:#0000008c;display:flex;align-items:center;justify-content:center;padding:20px}.preview-modal{background:var(--paper);border-radius:12px;box-shadow:0 24px 80px #00000047;width:90vw;max-width:1100px;max-height:88vh;display:flex;flex-direction:column;overflow:hidden}.preview-modal--full{height:88vh}.preview-modal--full .preview-modal-body{max-height:none}.preview-modal-header{display:flex;align-items:center;padding:14px 18px;border-bottom:1px solid var(--line);flex-shrink:0;gap:12px}.preview-modal-title{flex:1;min-width:0;font-size:14px;font-weight:600;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.preview-modal-close{width:30px;height:30px;border-radius:50%;border:none;background:transparent;color:var(--muted-2);font-size:20px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .12s,color .12s}.preview-modal-close:hover{background:var(--field);color:var(--ink)}.preview-modal-body{flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column;max-height:calc(88vh - 52px)}.rail-preview-btn{display:block;width:100%;padding:8px 12px;margin-bottom:16px;background:var(--accent);color:var(--paper);border:none;border-radius:var(--r3);font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .12s}.rail-preview-btn:hover{background:var(--accent-2)}.preview-modal-newtab{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:var(--r2);color:var(--muted-2);text-decoration:none;font-size:16px;flex-shrink:0;transition:background .12s,color .12s}.preview-modal-newtab:hover{background:var(--field);color:var(--ink)}body.has-audio-bar{padding-bottom:56px} diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 60596ca..1644f61 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -4,8 +4,8 @@ Archivr - - + +
diff --git a/frontend/src/components/SettingsView.jsx b/frontend/src/components/SettingsView.jsx index ddf361a..38ce545 100644 --- a/frontend/src/components/SettingsView.jsx +++ b/frontend/src/components/SettingsView.jsx @@ -691,7 +691,7 @@ function ExtensionsTab() { const cookieExtEnabled = settings?.cookie_ext_enabled ?? true return ( -
+

Extensions

@@ -699,60 +699,62 @@ function ExtensionsTab() { accept cookie banners, and more. Changes take effect on the next capture.

-
-
-
- uBlock Origin Lite - - Blocks ads, trackers, and other page clutter during archiving - via Chrome’s declarativeNetRequest API (Manifest V3). - - {!extAvailable && ( - - Not configured — set ARCHIVR_UBLOCK_EXT to the - unpacked extension directory to enable. +
+
+
+
+ uBlock Origin Lite + + Blocks ads, trackers, and other page clutter during archiving + via Chrome’s declarativeNetRequest API (Manifest V3). - )} + {!extAvailable && ( + + Not configured — set ARCHIVR_UBLOCK_EXT to the + unpacked extension directory to enable. + + )} +
+
-
-
-
-
-
- I Still Don’t Care About Cookies - - Dismiss cookie consent banners during archiving. - - {!cookieExtAvailable && ( - - Not configured — set ARCHIVR_COOKIE_EXT to the - unpacked extension directory to enable. +
+
+
+ I Still Don’t Care About Cookies + + Dismiss cookie consent banners during archiving. - )} + {!cookieExtAvailable && ( + + Not configured — set ARCHIVR_COOKIE_EXT to the + unpacked extension directory to enable. + + )} +
+
-
diff --git a/frontend/src/styles.css b/frontend/src/styles.css index de51b4b..715c6a8 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -1014,6 +1014,12 @@ select { .ext-toggle--sm.ext-toggle--on .ext-toggle-knob { transform: translateX(16px); } /* ── Extension card (Settings / Extensions tab) ──────────────────────────── */ +.ext-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); + gap: 12px; +} + .ext-card { border: 1px solid var(--line); border-radius: var(--r2);