diff --git a/crates/archivr-server/static/assets/index-BLxoi9rt.css b/crates/archivr-server/static/assets/index-BV7QPxEc.css similarity index 98% rename from crates/archivr-server/static/assets/index-BLxoi9rt.css rename to crates/archivr-server/static/assets/index-BV7QPxEc.css index 143d2eb..dd141f8 100644 --- a/crates/archivr-server/static/assets/index-BLxoi9rt.css +++ b/crates/archivr-server/static/assets/index-BV7QPxEc.css @@ -1 +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}.switchers{display:flex;gap:8px;align-items:center;min-width:0}.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:not(.entry-row-outer):nth-child(2n){background:#f2ede5}#entries-body>div:not(.entry-row-outer):nth-child(odd){background:var(--paper-3)}#entries-body>.entry-row-outer--light{background:var(--paper-3)}#entries-body>.entry-row-outer--dark{background:#f2ede5}#entries-body>div.is-selected{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}#entries-body>div.is-multi-selected{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}.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 .col-added,#entries-body>div .col-added{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{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)}.col-check{display:none;width:40px;flex-shrink:0;align-items:center;justify-content:center;padding:0!important;cursor:pointer}.row-checkbox{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;border:1.5px solid var(--line);cursor:pointer;display:block;width:17px;height:17px;border-radius:4px;background:var(--paper-3);transition:border-color .15s ease,background .15s ease;position:relative;flex-shrink:0}.row-checkbox.is-checked{background:var(--accent);border-color:var(--accent)}.row-checkbox.is-checked:after{content:"";position:absolute;left:4px;top:2px;width:5px;height:8px;border:2px solid #fff;border-top:none;border-left:none;transform:rotate(45deg)}@media (pointer: coarse){.col-check{display:flex}.entry-header-row .col-added,#entries-body>div .col-added{padding-left:10px}}#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}.artifact-group{list-style:none}.artifact-group-header{width:100%;background:none;border:none;border-bottom:1px solid var(--line-soft);cursor:pointer;text-align:left;color:inherit;font:inherit}.artifact-group-header:hover .artifact-name{text-decoration:underline}.artifact-group-chevron{display:inline-block;font-style:normal;transition:transform .15s ease;transform:rotate(0);transform-origin:45% 50%;margin-right:3px}.artifact-group-chevron.open{transform:rotate(90deg)}.artifact-group-body{padding-left:14px}.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;overflow:hidden;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;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.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)}.bulk-panel{padding-top:2px}.bulk-count{font-size:13px;color:var(--muted);margin-bottom:22px}.bulk-count-num{font-size:22px;font-weight:700;color:var(--ink);line-height:1;margin-right:4px}.bulk-coll-row{display:flex;align-items:center;gap:8px}.bulk-coll-select{flex:1;min-width:0;height:32px;padding:0 8px;border:1px solid var(--line);border-radius:var(--r);background:var(--field);color:var(--ink);font-size:13px;cursor:pointer;outline:none;transition:border-color .15s ease}.bulk-coll-select:focus{border-color:var(--accent)}.tag-add-btn:disabled{opacity:.45;cursor:default}.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}.capture-quality-hint--error{color:#c05000;font-style:normal}.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-text-row>.capture-row-main{align-items:flex-start}.capture-text-icon{flex-shrink:0;width:20px;height:44px;display:grid;place-items:center;color:var(--muted)}.capture-text-inputs{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:8px}.capture-text-input{width:100%;border:1px solid var(--line);background:var(--field);color:var(--ink);border-radius:var(--r2);outline:none;transition:border-color .15s ease,box-shadow .15s ease;font-family:inherit}.capture-text-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.capture-text-title{height:44px;padding:0 14px;font-size:15px}.capture-text-body{min-height:140px;padding:10px 14px;font-size:14px;line-height:1.55;resize:vertical}.capture-text-body::placeholder,.capture-text-title::placeholder{color:var(--muted)}.capture-text-footer{display:flex;align-items:center;gap:8px;justify-content:flex-end}.capture-text-mime{flex-shrink:0;height:28px;padding:0 26px 0 10px;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;-moz-appearance:none;appearance:none;-webkit-appearance:none;background-image:url("data:image/svg+xml;utf8,");background-repeat:no-repeat;background-position:right 8px center}.capture-text-mime:hover{border-color:var(--accent-2)}.capture-text-mime:focus{border-color:var(--accent)}.capture-text-row .capture-row-action{margin-top:8px}.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)}.capture-add-row-group{display:flex;gap:8px;margin-top:4px;margin-bottom:18px}.capture-add-row-group .capture-add-row{margin-top:0;margin-bottom:0;flex:1}.capture-dialog--dragover .capture-dialog-inner{outline:2px dashed var(--accent);outline-offset:-6px;border-radius:var(--r3)}.capture-file-icon{flex-shrink:0;color:var(--muted);display:flex;align-items:center}.capture-file-name{flex:1;min-width:0;font-size:13.5px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.capture-file-name--error{color:var(--accent)}.capture-file-progress-wrap{flex-shrink:0;display:flex;align-items:center;gap:6px}.capture-file-progress-bar{width:80px;height:4px;border-radius:2px;background:var(--paper-2);overflow:hidden;border:1px solid var(--line)}.capture-file-progress-fill{display:block;height:100%;background:var(--ink);border-radius:2px;transition:width .1s ease}.capture-file-progress-pct{font-size:11px;color:var(--muted);min-width:28px;text-align:right}.capture-file-badge{flex-shrink:0;width:18px;height:18px;border-radius:50%;display:grid;place-items:center;font-size:11px;font-weight:700;line-height:1}.capture-file-badge--done{background:#d8eddf;color:#235c35}.capture-file-badge--error{background:#f5ddd8;color:#8d3f30}.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}.tag-node-label{flex-shrink:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tag-node-count{font-size:11px;color:var(--muted-2);font-weight:400;flex-shrink:0;margin-left:3px}.tag-tree-header{align-items:center}.tag-tree-actions{margin-left:auto;display:flex;gap:4px}.tag-tree-action-btn{font-size:11px;padding:2px 7px;border:1px solid var(--line);border-radius:var(--r);background:transparent;color:var(--muted);cursor:pointer;line-height:1.5;white-space:nowrap;transition:background .1s,color .1s}.tag-tree-action-btn:hover:not(:disabled){background:var(--paper-2);color:var(--ink)}.tag-tree-action-btn:disabled{opacity:.4;cursor:default}.tag-tree-action-btn--cancel{border-color:var(--accent);color:var(--accent)}.tag-tree-action-btn--cancel:hover{background:color-mix(in srgb,var(--accent) 8%,transparent)}.tag-tree-title--move{font-style:italic;color:var(--accent-2)}.tag-node-row--move-select .tag-node-btn{cursor:crosshair;color:var(--ink)}.tag-node-row--move-select .tag-node-btn:hover{background:color-mix(in srgb,var(--link) 10%,transparent);text-decoration:none;border-radius:var(--r)}.tag-picker-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:200;background:#00000073;display:flex;align-items:center;justify-content:center;padding:20px}.tag-picker-modal{background:var(--paper);border-radius:var(--r3);box-shadow:0 16px 56px #0000003d;width:300px;max-width:100%;display:flex;flex-direction:column;max-height:60vh}.tag-picker-header{display:flex;align-items:center;padding:12px 14px;border-bottom:1px solid var(--line);flex-shrink:0;gap:8px}.tag-picker-title{flex:1;font-size:13px;font-weight:600;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tag-picker-close{width:26px;height:26px;border-radius:50%;border:none;background:transparent;color:var(--muted-2);font-size:18px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0}.tag-picker-close:hover{background:var(--paper-2);color:var(--ink)}.tag-picker-body{flex:1;min-height:0;overflow-y:auto;padding:8px 12px 12px}.tag-picker-root-btn{display:block;width:100%;text-align:left;padding:5px 8px;margin-bottom:6px;border:1px dashed var(--line);border-radius:var(--r);background:transparent;color:var(--muted);font-size:12px;cursor:pointer}.tag-picker-root-btn:hover{background:var(--paper-2);color:var(--ink);border-color:var(--muted-2)}.tag-picker-tree{border-top:1px solid var(--line-soft);padding-top:6px;margin-top:2px}.tag-picker-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 6px;text-align:left;font-size:13px;display:block;width:100%;border-radius:var(--r)}.tag-picker-node-btn:hover{background:var(--paper-2);text-decoration:none}.tag-picker-empty{font-size:13px;color:var(--muted-2);margin:6px 0 0}.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}.rail-public-summary{padding:4px 0}.rail-public-summary .rail-title{margin:0 0 10px}.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}.video-tv-controls{position:absolute;top:10px;right:10px;display:flex;gap:6px;z-index:10}.video-tv-btn{display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border:none;border-radius:6px;background:#00000080;color:#ffffffd1;cursor:pointer;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);transition:background .15s,color .15s}.video-tv-btn:hover{background:#000000b8;color:#fff}google-cast-launcher.video-tv-btn{color:#ffffffd1}.video-tv-loading{width:100%;min-height:200px;background:#0d0d0b}.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}.in-progress-entry-row{box-sizing:border-box;min-width:0;padding:7px 22px;gap:9px;color:var(--muted);white-space:nowrap}.in-progress-entry-row__spinner{width:16px;height:16px;border-width:2px;color:var(--accent);flex-shrink:0}.in-progress-entry-row__locator{min-width:0;overflow:hidden;text-overflow:ellipsis;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px}.in-progress-entry-row__status{display:inline-flex;align-items:center;gap:5px;flex-shrink:0;color:var(--muted-2);font-size:11.5px}.in-progress-entry-row__kind{font-size:10.5px;opacity:.85}@media (pointer: coarse){.in-progress-entry-row{padding-inline:10px}}#entries-body>.entry-row-outer{display:block;border-bottom:none}#entries-body>.entry-row-outer>.entry-row-main{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft);padding:0;flex-shrink:unset;overflow:visible}#entries-body>.entry-row-outer>.entry-row-main>div{padding:7px 10px;flex-shrink:0;overflow:hidden}#entries-body>.entry-row-outer>.entry-row-main>div:last-child{padding-right:22px}#entries-body>.entry-row-outer>.entry-row-main .col-added{padding-left:22px}#entries-body>.entry-row-outer.is-selected{background:unset;outline:none;box-shadow:none}#entries-body>.entry-row-outer.is-multi-selected{background:unset;outline:none;box-shadow:none}#entries-body>.entry-row-outer.is-selected>.entry-row-main{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}#entries-body>.entry-row-outer.is-multi-selected>.entry-row-main{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}#entries-body>.entry-row-outer .url-cell:hover{overflow:visible;white-space:normal}#entries-body>.entry-row-outer>.child-entries{display:block;padding:0;flex-shrink:unset;overflow:visible;border-left:2px solid var(--line-soft);margin-left:32px}.child-entry-row{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft);opacity:.88}.child-entry-row:hover{opacity:1}.child-entry-row:last-child{border-bottom:none}.child-entry-row--light{background:#fafaf8}.child-entry-row--dark{background:#f2f0ec}.child-entry-row.is-selected,.child-entry-row.is-multi-selected{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent);opacity:1}.child-entry-row>div{padding:6px 10px;flex-shrink:0;overflow:hidden}.child-entry-row .col-added{padding-left:22px}.child-entry-row>div:last-child{padding-right:22px}.entry-expand-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;flex-shrink:0;padding:0;margin-right:2px;background:none;border:none;cursor:pointer;opacity:.45;color:inherit;transition:opacity .15s}.entry-expand-btn:focus{outline:none}.entry-expand-btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}.entry-expand-btn:before{content:"";display:block;width:0;height:0;border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:6px solid currentColor;transition:transform .15s}.entry-expand-btn:hover{opacity:1}.entry-expand-btn.is-expanded:before{transform:rotate(90deg)}.child-count-badge{display:inline-block;margin-left:5px;padding:0 5px;font-size:.72em;font-weight:600;background:color-mix(in srgb,var(--line-soft) 60%,transparent);border-radius:10px;opacity:.75;vertical-align:middle;line-height:1.6}.child-entries-loading{padding:8px 12px;font-size:.85em;opacity:.55}.capture-playlist-toggle{display:inline-flex;align-items:center;gap:4px;font-size:.75rem;color:var(--muted);background:none;border:none;cursor:pointer;padding:2px 6px}.capture-playlist-toggle:hover{color:var(--text)}.capture-playlist-toggle--left{flex-shrink:0;padding:2px 4px;font-size:.7rem}.capture-conflict-badge{font-size:.7rem;color:#c07000;background:#fff3cd;border:1px solid #e0a000;border-radius:4px;padding:1px 6px;margin-left:6px}.capture-playlist-items{border-top:1px solid var(--line-soft);max-height:320px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}.capture-playlist-item{display:flex;align-items:center;gap:8px;padding:5px 10px 5px 14px;font-size:.8rem;border-bottom:1px solid var(--line-soft);border-left:3px solid transparent}.capture-playlist-item:last-of-type{border-bottom:none}.capture-playlist-item--conflict{border-left-color:#c07000;background:color-mix(in srgb,#c07000 6%,transparent)}.capture-playlist-item-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text);opacity:.9}.capture-item-quality{font-size:.73rem;padding:2px 4px;border:1px solid var(--line);border-radius:3px;background:var(--paper-3);color:var(--text);flex-shrink:0}.capture-playlist-conflict-badge{font-size:.68rem;font-weight:600;color:#c07000;white-space:nowrap;flex-shrink:0}.capture-playlist-item-remove{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:none;background:none;color:var(--muted);cursor:pointer;border-radius:3px;opacity:.3;transition:opacity .1s,color .1s}.capture-playlist-item:hover .capture-playlist-item-remove,.capture-playlist-item-remove:focus-visible{opacity:1}.capture-playlist-item-remove:hover{color:#c04000;opacity:1}@media (pointer: coarse){.capture-playlist-item-remove{opacity:1}}.capture-playlist-item-remove{font-size:.75rem;line-height:1}.capture-sync-row{display:flex;align-items:center;gap:6px;padding:6px 12px;font-size:.78rem;color:var(--muted);border-top:1px solid var(--line-soft);cursor:pointer}.capture-sync-row input[type=checkbox]{cursor:pointer}.rail-summary-body{margin-bottom:10px}.rail-summary-tldr{margin:0 0 8px;font-size:13.5px;font-weight:600;color:var(--ink);line-height:1.45}.rail-summary-text{margin:0 0 8px;font-size:13px;color:var(--ink);line-height:1.55}.rail-summary-tags{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:8px}.rail-summary-tag{font-size:11px;padding:2px 7px;border:1px solid var(--line);border-radius:999px;color:var(--muted)}.rail-summary-provider{margin:0;font-size:11px;color:var(--muted-2);letter-spacing:.02em}.rail-summary-status{display:flex;align-items:center;gap:7px;margin:0 0 8px;font-size:12.5px;color:var(--muted)}.rail-summary-spinner{width:11px;height:11px;border:1.5px solid var(--line);border-top-color:var(--muted);border-radius:50%;animation:rail-summary-spin .7s linear infinite;flex-shrink:0}@keyframes rail-summary-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.rail-summary-spinner{animation:none}}.rail-summary-controls{display:flex;flex-direction:column;gap:6px}.rail-summary-select{width:100%;padding:5px 8px;font-size:12.5px;color:var(--ink);background:var(--paper);border:1px solid var(--line);border-radius:4px} +@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}.switchers{display:flex;gap:8px;align-items:center;min-width:0}.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:not(.entry-row-outer):nth-child(2n){background:#f2ede5}#entries-body>div:not(.entry-row-outer):nth-child(odd){background:var(--paper-3)}#entries-body>.entry-row-outer--light{background:var(--paper-3)}#entries-body>.entry-row-outer--dark{background:#f2ede5}#entries-body>div.is-selected{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}#entries-body>div.is-multi-selected{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}.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 .col-added,#entries-body>div .col-added{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{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)}.col-check{display:none;width:40px;flex-shrink:0;align-items:center;justify-content:center;padding:0!important;cursor:pointer}.row-checkbox{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;border:1.5px solid var(--line);cursor:pointer;display:block;width:17px;height:17px;border-radius:4px;background:var(--paper-3);transition:border-color .15s ease,background .15s ease;position:relative;flex-shrink:0}.row-checkbox.is-checked{background:var(--accent);border-color:var(--accent)}.row-checkbox.is-checked:after{content:"";position:absolute;left:4px;top:2px;width:5px;height:8px;border:2px solid #fff;border-top:none;border-left:none;transform:rotate(45deg)}@media (pointer: coarse){.col-check{display:flex}.entry-header-row .col-added,#entries-body>div .col-added{padding-left:10px}}#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}.artifact-group{list-style:none}.artifact-group-header{width:100%;background:none;border:none;border-bottom:1px solid var(--line-soft);cursor:pointer;text-align:left;color:inherit;font:inherit}.artifact-group-header:hover .artifact-name{text-decoration:underline}.artifact-group-chevron{display:inline-block;font-style:normal;transition:transform .15s ease;transform:rotate(0);transform-origin:45% 50%;margin-right:3px}.artifact-group-chevron.open{transform:rotate(90deg)}.artifact-group-body{padding-left:14px}.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;overflow:hidden;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;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.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)}.bulk-panel{padding-top:2px}.bulk-count{font-size:13px;color:var(--muted);margin-bottom:22px}.bulk-count-num{font-size:22px;font-weight:700;color:var(--ink);line-height:1;margin-right:4px}.bulk-coll-row{display:flex;align-items:center;gap:8px}.bulk-coll-select{flex:1;min-width:0;height:32px;padding:0 8px;border:1px solid var(--line);border-radius:var(--r);background:var(--field);color:var(--ink);font-size:13px;cursor:pointer;outline:none;transition:border-color .15s ease}.bulk-coll-select:focus{border-color:var(--accent)}.tag-add-btn:disabled{opacity:.45;cursor:default}.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}.capture-quality-hint--error{color:#c05000;font-style:normal}.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-text-row>.capture-row-main{align-items:flex-start}.capture-text-icon{flex-shrink:0;width:20px;height:44px;display:grid;place-items:center;color:var(--muted)}.capture-text-inputs{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:8px}.capture-text-input{width:100%;border:1px solid var(--line);background:var(--field);color:var(--ink);border-radius:var(--r2);outline:none;transition:border-color .15s ease,box-shadow .15s ease;font-family:inherit}.capture-text-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.capture-text-title{height:44px;padding:0 14px;font-size:15px}.capture-text-body{min-height:140px;padding:10px 14px;font-size:14px;line-height:1.55;resize:vertical}.capture-text-body::placeholder,.capture-text-title::placeholder{color:var(--muted)}.capture-text-footer{display:flex;align-items:center;gap:8px;justify-content:flex-end}.capture-text-mime{flex-shrink:0;height:28px;padding:0 26px 0 10px;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;-moz-appearance:none;appearance:none;-webkit-appearance:none;background-image:url("data:image/svg+xml;utf8,");background-repeat:no-repeat;background-position:right 8px center}.capture-text-mime:hover{border-color:var(--accent-2)}.capture-text-mime:focus{border-color:var(--accent)}.capture-text-row .capture-row-action{margin-top:8px}.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)}.capture-add-row-group{display:flex;gap:8px;margin-top:4px;margin-bottom:18px}.capture-add-row-group .capture-add-row{margin-top:0;margin-bottom:0;flex:1}.capture-dialog--dragover .capture-dialog-inner{outline:2px dashed var(--accent);outline-offset:-6px;border-radius:var(--r3)}.capture-file-icon{flex-shrink:0;color:var(--muted);display:flex;align-items:center}.capture-file-name{flex:1;min-width:0;font-size:13.5px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.capture-file-name--error{color:var(--accent)}.capture-file-progress-wrap{flex-shrink:0;display:flex;align-items:center;gap:6px}.capture-file-progress-bar{width:80px;height:4px;border-radius:2px;background:var(--paper-2);overflow:hidden;border:1px solid var(--line)}.capture-file-progress-fill{display:block;height:100%;background:var(--ink);border-radius:2px;transition:width .1s ease}.capture-file-progress-pct{font-size:11px;color:var(--muted);min-width:28px;text-align:right}.capture-file-badge{flex-shrink:0;width:18px;height:18px;border-radius:50%;display:grid;place-items:center;font-size:11px;font-weight:700;line-height:1}.capture-file-badge--done{background:#d8eddf;color:#235c35}.capture-file-badge--error{background:#f5ddd8;color:#8d3f30}.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}.tag-node-label{flex-shrink:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tag-node-count{font-size:11px;color:var(--muted-2);font-weight:400;flex-shrink:0;margin-left:3px}.tag-tree-header{align-items:center}.tag-tree-actions{margin-left:auto;display:flex;gap:4px}.tag-tree-action-btn{font-size:11px;padding:2px 7px;border:1px solid var(--line);border-radius:var(--r);background:transparent;color:var(--muted);cursor:pointer;line-height:1.5;white-space:nowrap;transition:background .1s,color .1s}.tag-tree-action-btn:hover:not(:disabled){background:var(--paper-2);color:var(--ink)}.tag-tree-action-btn:disabled{opacity:.4;cursor:default}.tag-tree-action-btn--cancel{border-color:var(--accent);color:var(--accent)}.tag-tree-action-btn--cancel:hover{background:color-mix(in srgb,var(--accent) 8%,transparent)}.tag-tree-title--move{font-style:italic;color:var(--accent-2)}.tag-node-row--move-select .tag-node-btn{cursor:crosshair;color:var(--ink)}.tag-node-row--move-select .tag-node-btn:hover{background:color-mix(in srgb,var(--link) 10%,transparent);text-decoration:none;border-radius:var(--r)}.tag-picker-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:200;background:#00000073;display:flex;align-items:center;justify-content:center;padding:20px}.tag-picker-modal{background:var(--paper);border-radius:var(--r3);box-shadow:0 16px 56px #0000003d;width:300px;max-width:100%;display:flex;flex-direction:column;max-height:60vh}.tag-picker-header{display:flex;align-items:center;padding:12px 14px;border-bottom:1px solid var(--line);flex-shrink:0;gap:8px}.tag-picker-title{flex:1;font-size:13px;font-weight:600;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tag-picker-close{width:26px;height:26px;border-radius:50%;border:none;background:transparent;color:var(--muted-2);font-size:18px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0}.tag-picker-close:hover{background:var(--paper-2);color:var(--ink)}.tag-picker-body{flex:1;min-height:0;overflow-y:auto;padding:8px 12px 12px}.tag-picker-root-btn{display:block;width:100%;text-align:left;padding:5px 8px;margin-bottom:6px;border:1px dashed var(--line);border-radius:var(--r);background:transparent;color:var(--muted);font-size:12px;cursor:pointer}.tag-picker-root-btn:hover{background:var(--paper-2);color:var(--ink);border-color:var(--muted-2)}.tag-picker-tree{border-top:1px solid var(--line-soft);padding-top:6px;margin-top:2px}.tag-picker-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 6px;text-align:left;font-size:13px;display:block;width:100%;border-radius:var(--r)}.tag-picker-node-btn:hover{background:var(--paper-2);text-decoration:none}.tag-picker-empty{font-size:13px;color:var(--muted-2);margin:6px 0 0}.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}.rail-public-summary{padding:4px 0}.rail-public-summary .rail-title{margin:0 0 10px}.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}.video-tv-controls{position:absolute;top:10px;right:10px;display:flex;gap:6px;z-index:10}.video-tv-btn{display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border:none;border-radius:6px;background:#00000080;color:#ffffffd1;cursor:pointer;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);transition:background .15s,color .15s}.video-tv-btn:hover{background:#000000b8;color:#fff}google-cast-launcher.video-tv-btn{color:#ffffffd1}.video-tv-loading{width:100%;min-height:200px;background:#0d0d0b}.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}.in-progress-entry-row{box-sizing:border-box;min-width:0;padding:7px 22px;gap:9px;color:var(--muted);white-space:nowrap}.in-progress-entry-row__spinner{width:16px;height:16px;border-width:2px;color:var(--accent);flex-shrink:0}.in-progress-entry-row__locator{min-width:0;overflow:hidden;text-overflow:ellipsis;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px}.in-progress-entry-row__status{display:inline-flex;align-items:center;gap:5px;flex-shrink:0;color:var(--muted-2);font-size:11.5px}.in-progress-entry-row__kind{font-size:10.5px;opacity:.85}@media (pointer: coarse){.in-progress-entry-row{padding-inline:10px}}#entries-body>.entry-row-outer{display:block;border-bottom:none}#entries-body>.entry-row-outer>.entry-row-main{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft);padding:0;flex-shrink:unset;overflow:visible}#entries-body>.entry-row-outer>.entry-row-main>div{padding:7px 10px;flex-shrink:0;overflow:hidden}#entries-body>.entry-row-outer>.entry-row-main>div:last-child{padding-right:22px}#entries-body>.entry-row-outer>.entry-row-main .col-added{padding-left:22px}#entries-body>.entry-row-outer.is-selected{background:unset;outline:none;box-shadow:none}#entries-body>.entry-row-outer.is-multi-selected{background:unset;outline:none;box-shadow:none}#entries-body>.entry-row-outer.is-selected>.entry-row-main{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}#entries-body>.entry-row-outer.is-multi-selected>.entry-row-main{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent)}#entries-body>.entry-row-outer .url-cell:hover{overflow:visible;white-space:normal}#entries-body>.entry-row-outer>.child-entries{display:block;padding:0;flex-shrink:unset;overflow:visible;border-left:2px solid var(--line-soft);margin-left:32px}.child-entry-row{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft);opacity:.88}.child-entry-row:hover{opacity:1}.child-entry-row:last-child{border-bottom:none}.child-entry-row--light{background:#fafaf8}.child-entry-row--dark{background:#f2f0ec}.child-entry-row.is-selected,.child-entry-row.is-multi-selected{background:#eee2d2;box-shadow:inset 0 0 0 2px var(--accent);opacity:1}.child-entry-row>div{padding:6px 10px;flex-shrink:0;overflow:hidden}.child-entry-row .col-added{padding-left:22px}.child-entry-row>div:last-child{padding-right:22px}.entry-expand-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;flex-shrink:0;padding:0;margin-right:2px;background:none;border:none;cursor:pointer;opacity:.45;color:inherit;transition:opacity .15s}.entry-expand-btn:focus{outline:none}.entry-expand-btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}.entry-expand-btn:before{content:"";display:block;width:0;height:0;border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:6px solid currentColor;transition:transform .15s}.entry-expand-btn:hover{opacity:1}.entry-expand-btn.is-expanded:before{transform:rotate(90deg)}.child-count-badge{display:inline-block;margin-left:5px;padding:0 5px;font-size:.72em;font-weight:600;background:color-mix(in srgb,var(--line-soft) 60%,transparent);border-radius:10px;opacity:.75;vertical-align:middle;line-height:1.6}.child-entries-loading{padding:8px 12px;font-size:.85em;opacity:.55}.capture-playlist-toggle{display:inline-flex;align-items:center;gap:4px;font-size:.75rem;color:var(--muted);background:none;border:none;cursor:pointer;padding:2px 6px}.capture-playlist-toggle:hover{color:var(--text)}.capture-playlist-toggle--left{flex-shrink:0;padding:2px 4px;font-size:.7rem}.capture-conflict-badge{font-size:.7rem;color:#c07000;background:#fff3cd;border:1px solid #e0a000;border-radius:4px;padding:1px 6px;margin-left:6px}.capture-playlist-items{border-top:1px solid var(--line-soft);max-height:320px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}.capture-playlist-item{display:flex;align-items:center;gap:8px;padding:5px 10px 5px 14px;font-size:.8rem;border-bottom:1px solid var(--line-soft);border-left:3px solid transparent}.capture-playlist-item:last-of-type{border-bottom:none}.capture-playlist-item--conflict{border-left-color:#c07000;background:color-mix(in srgb,#c07000 6%,transparent)}.capture-playlist-item-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text);opacity:.9}.capture-item-quality{font-size:.73rem;padding:2px 4px;border:1px solid var(--line);border-radius:3px;background:var(--paper-3);color:var(--text);flex-shrink:0}.capture-playlist-conflict-badge{font-size:.68rem;font-weight:600;color:#c07000;white-space:nowrap;flex-shrink:0}.capture-playlist-item-remove{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:none;background:none;color:var(--muted);cursor:pointer;border-radius:3px;opacity:.3;transition:opacity .1s,color .1s}.capture-playlist-item:hover .capture-playlist-item-remove,.capture-playlist-item-remove:focus-visible{opacity:1}.capture-playlist-item-remove:hover{color:#c04000;opacity:1}@media (pointer: coarse){.capture-playlist-item-remove{opacity:1}}.capture-playlist-item-remove{font-size:.75rem;line-height:1}.capture-sync-row{display:flex;align-items:center;gap:6px;padding:6px 12px;font-size:.78rem;color:var(--muted);border-top:1px solid var(--line-soft);cursor:pointer}.capture-sync-row input[type=checkbox]{cursor:pointer}.rail-summary-body{margin-bottom:10px}.rail-summary-tldr{margin:0 0 8px;font-size:13.5px;font-weight:600;color:var(--ink);line-height:1.45}.rail-summary-text{margin:0 0 8px;font-size:13px;color:var(--ink);line-height:1.55}.rail-summary-tags{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:8px}.rail-summary-tag{font-size:11px;padding:2px 7px;border:1px solid var(--line);border-radius:999px;color:var(--muted)}.rail-summary-provider{margin:0;font-size:11px;color:var(--muted-2);letter-spacing:.02em}.rail-summary-status{display:flex;align-items:center;gap:7px;margin:0 0 8px;font-size:12.5px;color:var(--muted)}.rail-summary-spinner{width:11px;height:11px;border:1.5px solid var(--line);border-top-color:var(--muted);border-radius:50%;animation:rail-summary-spin .7s linear infinite;flex-shrink:0}@keyframes rail-summary-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.rail-summary-spinner{animation:none}}.rail-summary-controls{display:flex;flex-direction:column;gap:6px}.rail-summary-select{width:100%;padding:5px 8px;font-size:12.5px;color:var(--ink);background:var(--paper);border:1px solid var(--line);border-radius:4px}.text-preview{padding:32px 40px 48px;max-width:780px;margin:0 auto;font-family:var(--sans);color:var(--ink);overflow:auto;height:100%;box-sizing:border-box}.text-preview--loading,.text-preview--error{padding:24px;color:var(--muted);font-size:13px}.text-preview--error{color:var(--accent)}.text-preview__title{font-family:var(--serif, var(--sans));font-size:22px;font-weight:600;margin:0 0 20px;line-height:1.25;color:var(--ink)}.text-preview__body{white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13.5px;line-height:1.65;color:var(--ink);background:var(--paper);border:1px solid var(--line);border-radius:var(--r2);padding:16px 18px;margin:0}.text-preview__mime{margin-top:12px;font-size:11px;color:var(--muted);letter-spacing:.04em;text-align:right} diff --git a/crates/archivr-server/static/assets/index-CQcpPA_I.js b/crates/archivr-server/static/assets/index-C4rpqY7g.js similarity index 91% rename from crates/archivr-server/static/assets/index-CQcpPA_I.js rename to crates/archivr-server/static/assets/index-C4rpqY7g.js index 00add7e..819a72d 100644 --- a/crates/archivr-server/static/assets/index-CQcpPA_I.js +++ b/crates/archivr-server/static/assets/index-C4rpqY7g.js @@ -44,4 +44,4 @@ ${we.map(wt=>` ${wt}`).join(` `)}`);const dt=le.length>0?le.join(` `):null;_.current(dt,null,Ue,ce)}async function Ee(w,B){var we,ce,Ue;const M=v.current,I=((we=crypto.randomUUID)==null?void 0:we.call(crypto))??`job-${Date.now()}-${Math.random()}`;if(w.type==="text"){try{const le=await qh(M,{title:w.title,body:w.body,mime:w.mime}),dt=`text:${w.title}`;(ce=E.current)==null||ce.call(E,{id:I,jobUid:le.job_uid,locator:dt,archiveId:M}),he(I,le.job_uid,dt,M,B)}catch(le){const dt=le.message||"Submission failed.";_.current(dt,`text:${w.title}`),ue(B,"failed",`text:${w.title}`)}return}const F=w.locator,H=w.quality,xe=w.extraExtensions||{},fe={ublock_enabled:ee,reader_mode:Re,cookie_ext_enabled:Ae,modal_closer_enabled:D,via_freedium:V,...xe};try{const le=await Qh(M,F,H,fe);(Ue=E.current)==null||Ue.call(E,{id:I,jobUid:le.job_uid,locator:F,archiveId:M}),he(I,le.job_uid,F,M,B)}catch(le){const dt=le.message||"Submission failed.";_.current(dt,F),ue(B,"failed",F),F.startsWith("file://")&&le.status&&hi(M,F).catch(()=>{})}}function Qe(){var I,F;if(j.some(H=>H.kind==="file"&&H.uploadStatus==="uploading"))return;const w=j.filter(H=>H.kind==="file"?H.uploadStatus==="done"&&H.uploadLocator:H.kind==="text"?H.title.trim()&&H.body.trim():H.locator.trim());if(w.length===0||w.some(H=>H.kind!=="file"&&H.kind!=="text"&&Eu(H))||w.some(H=>H.kind!=="file"&&H.kind!=="text"&&(H.probeState==="probing"||Ln(H.locator)&&H.playlistProbeState!=="done"))||w.some(H=>H.kind!=="file"&&H.kind!=="text"&&Array.isArray(H.playlistItems)&&H.playlistItems.length===0))return;const B=w.length>1?((I=crypto.randomUUID)==null?void 0:I.call(crypto))??`batch-${Date.now()}`:null;B&&h.current.set(B,{total:w.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]});const M=w.map(H=>H.kind==="file"?{type:"file",locator:H.uploadLocator,quality:"best",extraExtensions:{}}:H.kind==="text"?{type:"text",title:H.title.trim(),body:H.body.trim(),mime:H.mime}:{type:"url",locator:H.locator.trim(),quality:H.playlistItems!==null?null:H.quality||"best",extraExtensions:H.playlistItems!==null?{per_item_quality:Object.fromEntries(H.playlistItems.map(xe=>[xe.id,xe.quality])),sync:H.syncEnabled}:{}});f.current=!0,T([Wn()]),(F=u.current)==null||F.close(),M.forEach(H=>Ee(H,B))}function Et(){T(w=>[...w,Wn()])}function ut(w){var M;clearTimeout(g.current.get(w)),g.current.delete(w);const B=p.current.find(I=>I.id===w);(B==null?void 0:B.kind)==="file"&&(B.uploadStatus==="uploading"?((M=m.current.get(w))==null||M(),m.current.delete(w)):B.uploadStatus==="done"&&B.uploadLocator&&hi(v.current,B.uploadLocator).catch(()=>{})),T(I=>{const F=I.filter(H=>H.id!==w);return F.length===0?[Wn()]:F})}function Wt(w,B){if(clearTimeout(g.current.get(w)),T(M=>M.map(I=>I.id===w?{...I,locator:B,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best",playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1}:I)),Jd(B)){const M=setTimeout(async()=>{g.current.delete(w),T(I=>I.map(F=>F.id===w?{...F,probeState:"probing"}:F));try{const I=await Kh(v.current,B.trim());T(F=>F.map(H=>{if(H.id!==w||H.locator!==B)return H;const xe=I.qualities??[],fe=I.has_audio??!1,we=xe.length===0&&fe?"audio":"best";return{...H,probeState:"done",probeQualities:xe,probeHasAudio:fe,quality:we}}))}catch{T(I=>I.map(F=>F.id===w?{...F,probeState:"idle",probeQualities:null}:F))}},600);g.current.set(w,M)}else if(Ln(B)){const M=setTimeout(async()=>{g.current.delete(w),T(I=>I.map(F=>F.id===w?{...F,playlistProbeState:"probing"}:F));try{const I=await Xh(v.current,B.trim());T(F=>F.map(H=>H.id!==w||H.locator!==B?H:{...H,playlistProbeState:"done",playlistInfo:I,playlistItems:I.items.map(xe=>({...xe,quality:null})),playlistQuality:null}))}catch{T(I=>I.map(F=>F.id===w?{...F,playlistProbeState:"error"}:F))}},800);g.current.set(w,M)}}function ct(w,B){T(M=>M.map(I=>I.id===w?{...I,quality:B}:I))}function rt(w,B){T(M=>M.map(I=>{if(I.id!==w)return I;const F=Rm(B,I.playlistItems);return{...I,playlistQuality:B,playlistItems:F}}))}function xt(w,B,M){T(I=>I.map(F=>F.id!==w?F:{...F,playlistItems:F.playlistItems.map(H=>H.id===B?{...H,quality:M}:H)}))}function bt(w){T(B=>B.map(M=>M.id===w?{...M,playlistExpanded:!M.playlistExpanded}:M))}function A(w,B){T(M=>M.map(I=>I.id===w?{...I,syncEnabled:B}:I))}function q(w,B){T(M=>M.map(I=>I.id!==w?I:{...I,playlistItems:I.playlistItems.filter(F=>F.id!==B)}))}function de(w){const B=Array.from(w);B.length!==0&&B.forEach(M=>{const I=Pm(M.name);T(fe=>fe.length===1&&fe[0].kind!=="file"&&!fe[0].locator.trim()?[I]:[...fe,I]);const F=v.current,{promise:H,abort:xe}=_m(F,M,fe=>{T(we=>we.map(ce=>ce.id===I.id?{...ce,uploadProgress:fe}:ce))});m.current.set(I.id,xe),H.then(fe=>{m.current.delete(I.id),T(we=>we.map(ce=>ce.id===I.id?{...ce,uploadStatus:"done",uploadLocator:fe.locator,uploadProgress:100}:ce))}).catch(fe=>{m.current.delete(I.id),fe.message!=="Upload cancelled"&&T(we=>we.map(ce=>ce.id===I.id?{...ce,uploadStatus:"error",uploadError:fe.message}:ce))})})}function Be(w){w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&N(!0)}function Dt(w){w.currentTarget.contains(w.relatedTarget)||N(!1)}function ze(w){w.preventDefault(),w.stopPropagation(),N(!1),de(w.dataTransfer.files)}function Bn(w){de(w.target.files),w.target.value=""}const _n=j.some(w=>w.kind==="file"&&w.uploadStatus==="uploading"),nn=j.filter(w=>w.kind==="file"?w.uploadStatus==="done"&&w.uploadLocator:w.kind==="text"?w.title.trim()&&w.body.trim():w.locator.trim()).length,qe=j.some(w=>w.kind!=="file"&&w.kind!=="text"&&Eu(w)),wr=j.some(w=>w.kind!=="file"&&w.kind!=="text"&&Array.isArray(w.playlistItems)&&w.playlistItems.length===0),Un=j.some(w=>w.kind!=="file"&&w.kind!=="text"&&(w.probeState==="probing"||Ln(w.locator)&&w.playlistProbeState!=="done"));return s.jsx("dialog",{ref:u,className:`capture-dialog${S?" capture-dialog--dragover":""}`,onDragOver:Be,onDragLeave:Dt,onDrop:ze,children:s.jsxs("div",{className:"capture-dialog-inner",children:[s.jsxs("div",{className:"capture-dialog-header",children:[s.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),s.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var w;return(w=u.current)==null?void 0:w.close()},"aria-label":"Close",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),s.jsx("div",{className:"capture-rows",children:j.map((w,B)=>w.kind==="file"?s.jsx($m,{item:w,onRemove:()=>ut(w.id)},w.id):w.kind==="text"?s.jsx(Dm,{item:w,autoFocus:B===j.length-1,onTitleChange:M=>T(I=>I.map(F=>F.id===w.id?{...F,title:M}:F)),onBodyChange:M=>T(I=>I.map(F=>F.id===w.id?{...F,body:M}:F)),onMimeChange:M=>T(I=>I.map(F=>F.id===w.id?{...F,mime:M}:F)),onRemove:()=>ut(w.id),onSubmit:Qe},w.id):s.jsx(Im,{item:w,autoFocus:B===j.length-1,onLocatorChange:M=>Wt(w.id,M),onQualityChange:M=>ct(w.id,M),onRemove:()=>ut(w.id),onSubmit:Qe,onPlaylistQualityChange:M=>rt(w.id,M),onPlaylistItemQualityChange:(M,I)=>xt(w.id,M,I),onPlaylistToggle:()=>bt(w.id),onSyncChange:M=>A(w.id,M),onPlaylistItemDelete:M=>q(w.id,M)},w.id))}),s.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:Bn,"aria-hidden":"true",tabIndex:-1}),s.jsxs("div",{className:"capture-add-row-group",children:[s.jsxs("button",{type:"button",className:"capture-add-row",onClick:Et,children:[s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),s.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add URL"]}),s.jsxs("button",{type:"button",className:"capture-add-row capture-add-file",onClick:()=>{var w;return(w=x.current)==null?void 0:w.click()},children:[s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1.5"}),s.jsx("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"5.5"}),s.jsx("line",{x1:"5.5",y1:"8",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"5.5",y1:"10.5",x2:"8.5",y2:"10.5"})]}),"Upload file"]}),s.jsxs("button",{type:"button",className:"capture-add-row capture-add-text",onClick:()=>T(w=>[...w,Lm()]),children:[s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M2 3h12M2 7h12M2 11h8"})}),"Add text"]})]}),s.jsxs("div",{className:"capture-advanced",children:[s.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>K(w=>!w),"aria-expanded":L,children:[s.jsx("svg",{className:`capture-chevron${L?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),L&&s.jsxs("div",{className:"capture-advanced-panel",children:[s.jsxs("label",{className:"capture-ext-row",children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),s.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":ee,className:`ext-toggle ext-toggle--sm${ee?" ext-toggle--on":""}`,onClick:()=>X(w=>w===null?!ee:!w),"aria-label":"Toggle uBlock for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),s.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(Z!=null&&Z.cookie_ext_available)&&s.jsxs("span",{className:"capture-ext-hint",children:["Not configured β€” set ",s.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":Ae,className:`ext-toggle ext-toggle--sm${Ae?" ext-toggle--on":""}`,onClick:()=>ye(w=>!w),"aria-label":"Toggle cookie banner blocking for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),s.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":Re,className:`ext-toggle ext-toggle--sm${Re?" ext-toggle--on":""}`,onClick:()=>Y(w=>!w),"aria-label":"Toggle reader mode for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Close modals and dialogs"}),s.jsx("span",{className:"capture-ext-desc",children:"Auto-dismiss cookie banners and overlays during this capture"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":D,className:`ext-toggle ext-toggle--sm${D?" ext-toggle--on":""}`,onClick:()=>P(w=>!w),"aria-label":"Toggle modal closer for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Freedium mirror"}),s.jsx("span",{className:"capture-ext-desc",children:"Route paywalled articles through a Freedium mirror (Medium, NYT, WaPo, etc.)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":V,className:`ext-toggle ext-toggle--sm${V?" ext-toggle--on":""}`,onClick:()=>te(w=>!w),"aria-label":"Toggle Freedium mirror for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),s.jsxs("div",{className:"capture-actions",children:[s.jsx("button",{type:"button",className:"capture-submit",onClick:Qe,disabled:nn===0||qe||Un||wr||_n,children:nn>1?`Archive ${nn}`:"Archive"}),s.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var w;return(w=u.current)==null?void 0:w.close()},children:"Cancel"})]})]})})}function Im({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onSubmit:i,onPlaylistQualityChange:a,onPlaylistItemQualityChange:o,onPlaylistToggle:u,onSyncChange:c,onPlaylistItemDelete:y}){const g=d.useRef(null);d.useEffect(()=>{var x;t&&((x=g.current)==null||x.focus())},[t]);const h=(()=>{if(Ln(e.locator)){if(e.playlistProbeState==="probing")return s.jsx("span",{className:"capture-quality-probing","aria-label":"Probing playlist…",children:"…"});if(e.playlistProbeState==="done"){const x=[...new Set(e.playlistItems.flatMap(p=>p.qualities.map(f=>parseInt(f))))].sort((p,f)=>f-p),S=e.playlistItems.every(p=>p.has_audio),N=e.playlistItems.filter(p=>p.quality===null).length;return s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"capture-quality",value:e.playlistQuality??"",onChange:p=>a(p.target.value),"aria-label":"Playlist quality",children:[!e.playlistQuality&&s.jsx("option",{value:"",disabled:!0,children:"Select quality…"}),s.jsx("option",{value:"best",children:"Best quality"}),x.map(p=>s.jsxs("option",{value:`${p}p`,children:[p,"p"]},p)),S&&s.jsx("option",{value:"audio",children:"Audio only"})]}),N>0&&s.jsxs("span",{className:"capture-conflict-badge",children:[N," need selection"]})]})}return e.playlistProbeState==="error"?s.jsx("span",{className:"capture-quality-hint capture-quality-hint--error",children:"Probe failed β€” edit URL to retry"}):null}if(!Jd(e.locator))return null;if(e.probeState==="probing")return s.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const x=e.probeQualities??[],S=e.probeHasAudio??!1;return x.length===0&&!S?s.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):x.length===0&&S?s.jsx("select",{className:"capture-quality",value:"audio",onChange:N=>r(N.target.value),"aria-label":"Video quality",children:s.jsx("option",{value:"audio",children:"Audio only"})}):s.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:N=>r(N.target.value),"aria-label":"Video quality",children:[s.jsx("option",{value:"best",children:"Best quality"}),x.map(N=>s.jsx("option",{value:N,children:N},N)),S&&s.jsx("option",{value:"audio",children:"Audio only"})]})}return null})(),v=Ln(e.locator)&&e.playlistProbeState==="done"?s.jsxs("label",{className:"capture-sync-row",children:[s.jsx("input",{type:"checkbox",checked:e.syncEnabled,onChange:x=>c(x.target.checked)}),s.jsx("span",{children:"Sync β€” skip already-archived videos"})]}):null;return s.jsxs("div",{className:"capture-row",children:[s.jsxs("div",{className:"capture-row-main",children:[Ln(e.locator)&&e.playlistProbeState==="done"?s.jsx("button",{type:"button",className:"capture-playlist-toggle capture-playlist-toggle--left",onClick:u,"aria-label":e.playlistExpanded?"Collapse video list":"Expand video list","aria-expanded":e.playlistExpanded,children:e.playlistExpanded?"β–²":"β–Ό"}):null,s.jsx("input",{ref:g,className:"capture-input",type:"text",placeholder:"https://… Β· yt:ID Β· ytm:ID Β· tweet:ID Β· x:ID",value:e.locator,onChange:x=>n(x.target.value),onKeyDown:x=>{x.key==="Enter"&&i()},autoComplete:"off",spellCheck:!1}),h,s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&s.jsx("p",{className:"capture-row-error",children:e.error}),Ln(e.locator)&&e.playlistProbeState==="done"&&e.playlistExpanded?s.jsxs("div",{className:"capture-playlist-items",children:[e.playlistItems.map(x=>s.jsxs("div",{className:`capture-playlist-item${x.quality===null?" capture-playlist-item--conflict":""}`,children:[s.jsx("span",{className:"capture-playlist-item-title",children:x.title||x.url}),s.jsxs("select",{className:"capture-item-quality",value:x.quality??"",onChange:S=>o(x.id,S.target.value),"aria-label":`Quality for ${x.title||x.url}`,children:[x.quality===null&&s.jsx("option",{value:"",disabled:!0,children:"Choose…"}),s.jsx("option",{value:"best",children:"Best quality"}),x.qualities.map(S=>s.jsx("option",{value:S,children:S},S)),x.has_audio&&s.jsx("option",{value:"audio",children:"Audio only"})]}),x.quality===null&&s.jsx("span",{className:"capture-playlist-conflict-badge",children:"Choose quality"}),s.jsx("button",{type:"button",className:"capture-playlist-item-remove","aria-label":`Remove ${x.title||x.url}`,onClick:()=>y(x.id),children:"Γ—"})]},x.id)),v]}):v]})}function $m({item:e,onRemove:t}){const n=e.uploadStatus==="uploading",r=e.uploadStatus==="done",l=e.uploadStatus==="error";return s.jsxs("div",{className:"capture-row",children:[s.jsxs("div",{className:"capture-row-main",children:[s.jsx("span",{className:"capture-file-icon","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{width:14,height:14},children:[s.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1.5"}),s.jsx("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"5.5"}),s.jsx("line",{x1:"5.5",y1:"8",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"5.5",y1:"10.5",x2:"8.5",y2:"10.5"})]})}),s.jsx("span",{className:`capture-file-name${l?" capture-file-name--error":""}`,children:e.filename}),n&&s.jsxs("span",{className:"capture-file-progress-wrap","aria-label":`Uploading ${e.uploadProgress}%`,children:[s.jsx("span",{className:"capture-file-progress-bar",children:s.jsx("span",{className:"capture-file-progress-fill",style:{width:`${e.uploadProgress}%`}})}),s.jsxs("span",{className:"capture-file-progress-pct",children:[e.uploadProgress,"%"]})]}),r&&s.jsx("span",{className:"capture-file-badge capture-file-badge--done","aria-label":"Upload complete",children:s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{width:11,height:11},children:s.jsx("polyline",{points:"3 8.5 6.5 12 13 5"})})}),l&&s.jsx("span",{className:"capture-file-badge capture-file-badge--error",children:"!"}),s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:t,"aria-label":"Remove",disabled:n,children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),l&&s.jsx("p",{className:"capture-row-error",children:e.uploadError||"Upload failed"})]})}function Dm({item:e,autoFocus:t,onTitleChange:n,onBodyChange:r,onMimeChange:l,onRemove:i,onSubmit:a}){const o=d.useRef(null);return d.useEffect(()=>{var u;t&&((u=o.current)==null||u.focus())},[t]),s.jsx("div",{className:"capture-row capture-text-row",children:s.jsxs("div",{className:"capture-row-main",children:[s.jsx("span",{className:"capture-text-icon","aria-hidden":"true",children:s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{width:14,height:14},children:s.jsx("path",{d:"M2 3h12M2 7h12M2 11h8"})})}),s.jsxs("div",{className:"capture-text-inputs",children:[s.jsx("input",{ref:o,className:"capture-text-input capture-text-title",type:"text",placeholder:"Title",value:e.title,onChange:u=>n(u.target.value),maxLength:500}),s.jsx("textarea",{className:"capture-text-input capture-text-body",placeholder:"Body (markdown or plain text)",value:e.body,onChange:u=>r(u.target.value),rows:6}),s.jsx("div",{className:"capture-text-footer",children:s.jsxs("select",{className:"capture-text-mime",value:e.mime,onChange:u=>l(u.target.value),children:[s.jsx("option",{value:"text/markdown",children:"Markdown"}),s.jsx("option",{value:"text/plain",children:"Plain text"})]})})]}),s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:i,"aria-label":"Remove",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]})})}function Om(){return s.jsxs("div",{className:"skeleton-row",children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:s.jsx("span",{className:"skeleton-cell",style:{width:108,height:13}})}),s.jsxs("div",{className:"col-title",style:{gap:"0.42em",display:"flex",alignItems:"center"},children:[s.jsx("span",{className:"skeleton-cell",style:{width:14,height:14,borderRadius:"50%",flexShrink:0}}),s.jsx("span",{className:"skeleton-cell",style:{width:"58%",height:13}})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"skeleton-cell",style:{width:58,height:20,borderRadius:99}})}),s.jsx("div",{className:"col-size",children:s.jsx("span",{className:"skeleton-cell",style:{width:44,height:12}})}),s.jsx("div",{className:"col-url",children:s.jsx("span",{className:"skeleton-cell",style:{width:"65%",height:12}})})]})}function dl(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 pt(e){return Am(e)??""}function ao(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 bu={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function Os(e){return bu[e]??bu.other}function Gd(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function Mm({entry:e,index:t,onRowClick:n,selectedUids:r}){const l=(r==null?void 0:r.size)===1&&r.has(e.entry_uid),i=(r==null?void 0:r.size)>=2&&r.has(e.entry_uid),a=["child-entry-row",t%2===0?"child-entry-row--light":"child-entry-row--dark",l&&"is-selected",i&&"is-multi-selected"].filter(Boolean).join(" ");return s.jsxs("div",{className:a,tabIndex:0,"data-entry-uid":e.entry_uid,onMouseDown:o=>{o.shiftKey&&o.preventDefault()},onClick:o=>n(e,o),onKeyDown:o=>{o.key==="Enter"&&n(e,o)},children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:ao(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[s.jsx("span",{className:"source-icon",children:s.jsx("span",{dangerouslySetInnerHTML:{__html:Os(e.source_kind)}})}),s.jsx("span",{className:"entry-title",children:pt(e.title)||pt(e.entry_uid)})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:pt(e.entity_kind)})}),s.jsx("div",{className:"col-size",children:s.jsx("span",{className:"size-total",children:dl(e.total_artifact_bytes)})}),s.jsx("div",{className:"url-cell col-url",children:pt(e.original_url)})]})}function Fm({entry:e,archiveId:t,rowIndex:n,isSelected:r,isMultiSelected:l,onRowClick:i,selectedUids:a,deletedUids:o,isPublicSession:u}){const[c,y]=d.useState(!1),[g,h]=d.useState(!1),[v,x]=d.useState(null),[S,N]=d.useState(!1),f=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!c?s.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>y(!0),style:{objectFit:"contain"}}):s.jsx("span",{dangerouslySetInnerHTML:{__html:Os(e.source_kind)}}),m=r||l,k=e.child_count>0&&!u;function _(j){j.stopPropagation(),i(e,{ctrlKey:!0,metaKey:!1,shiftKey:!1,preventDefault(){}})}async function E(j){if(j.stopPropagation(),g){h(!1);return}if(h(!0),v===null&&!S){N(!0);try{const T=await Oh(t,e.entry_uid);x(T)}catch{x([])}finally{N(!1)}}}const b=["entry-row-outer",n%2===0?"entry-row-outer--light":"entry-row-outer--dark",r&&"is-selected",l&&"is-multi-selected"].filter(Boolean).join(" ");return s.jsxs("div",{className:b,"data-entry-uid":e.entry_uid,children:[s.jsxs("div",{className:"entry-row-main",tabIndex:0,onMouseDown:j=>{j.shiftKey&&j.preventDefault()},onClick:j=>i(e,j),onKeyDown:j=>{j.key==="Enter"&&i(e,j)},children:[s.jsx("div",{className:"col-check",children:s.jsx("button",{type:"button",className:`row-checkbox${m?" is-checked":""}`,"aria-pressed":m,"aria-label":m?"Deselect entry":"Select entry",onClick:_,onKeyDown:j=>j.stopPropagation()})}),s.jsx("div",{className:"col-added",children:ao(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[k&&s.jsx("button",{type:"button",className:`entry-expand-btn${g?" is-expanded":""}`,"aria-label":g?"Collapse children":`Expand ${e.child_count} items`,"aria-expanded":g,onClick:E,onKeyDown:j=>j.stopPropagation()}),s.jsx("span",{className:"source-icon",children:f}),s.jsx("span",{className:"entry-title",children:pt(e.title)||pt(e.entry_uid)}),k&&s.jsx("span",{className:"child-count-badge","aria-hidden":"true",children:e.child_count})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:pt(e.entity_kind)})}),s.jsxs("div",{className:"col-size",children:[s.jsx("span",{className:"size-total",children:dl(e.total_artifact_bytes)}),e.cached_bytes>0&&e.cacheable_bytes>0&&s.jsxs("span",{className:"size-cached-pct",title:`${dl(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.cacheable_bytes*100),"% cached"]})]}),s.jsx("div",{className:"url-cell col-url",children:pt(e.original_url)})]}),g&&s.jsxs(s.Fragment,{children:[S&&s.jsx("div",{className:"child-entries-loading",children:"Loading…"}),s.jsx("div",{className:"child-entries","aria-label":`${e.child_count} child entries`,children:v&&v.filter(j=>!(o!=null&&o.has(j.entry_uid))).map((j,T)=>s.jsx(Mm,{entry:j,index:T,onRowClick:i,selectedUids:a},j.entry_uid))})]})]})}function Bm({entries:e,selectedUids:t,onRowClick:n,archiveId:r,pendingCaptures:l=[],deletedUids:i,isPublicSession:a}){return s.jsx("section",{id:"archive-view",className:"view is-active",children:s.jsxs("div",{className:"entry-table",children:[s.jsxs("div",{className:"entry-header-row",children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:"Added"}),s.jsx("div",{className:"col-title",children:"Title"}),s.jsx("div",{className:"col-type",children:"Type"}),s.jsx("div",{className:"col-size",children:"Size"}),s.jsx("div",{className:"col-url",children:"Original URL"})]}),s.jsxs("div",{id:"entries-body",children:[l.filter(o=>o.archiveId===r).reverse().map(o=>s.jsx(Om,{},o.id)),e.map((o,u)=>s.jsx(Fm,{entry:o,rowIndex:u,archiveId:r,isSelected:t.size===1&&t.has(o.entry_uid),isMultiSelected:t.size>=2&&t.has(o.entry_uid),onRowClick:n,selectedUids:t,deletedUids:i,isPublicSession:a},o.entry_uid))]})]})})}function Um(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 Hm({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 s.jsx("span",{className:`run-status ${t}`,children:n})}function Wm({runs:e}){const[t,n]=d.useState(null);function r(l){n(i=>i===l?null:l)}return s.jsx("section",{id:"runs-view",className:"view is-active",children:s.jsxs("table",{className:"entry-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:"Requested"}),s.jsx("th",{children:"Completed"}),s.jsx("th",{children:"Failed"})]})}),s.jsx("tbody",{children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const i=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[s.jsxs("tr",{className:i?"run-row run-row--failed":"run-row",onClick:i?()=>r(l.run_uid):void 0,title:i?a?"Click to hide error":"Click to view error":void 0,children:[s.jsx("td",{children:Um(l.started_at)}),s.jsxs("td",{children:[s.jsx(Hm,{status:l.status}),i&&s.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"β–΄":"β–Ύ"})]}),s.jsx("td",{children:l.requested_count??"β€”"}),s.jsx("td",{children:l.completed_count??"β€”"}),s.jsx("td",{children:l.failed_count??"β€”"})]},l.run_uid),i&&a&&s.jsx("tr",{className:"run-error-row",children:s.jsx("td",{colSpan:5,children:s.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const Vm=4;function Qm({archives:e}){const{currentUser:t}=d.useContext(As)??{},n=t&&(t.role_bits&Vm)!==0,[r,l]=d.useState("users"),[i,a]=d.useState([]),[o,u]=d.useState([]),[c,y]=d.useState(!1),[g,h]=d.useState(null),[v,x]=d.useState(""),[S,N]=d.useState(""),[p,f]=d.useState(""),[m,k]=d.useState(null),[_,E]=d.useState(!1),[b,j]=d.useState(""),[T,L]=d.useState(""),[K,U]=d.useState(null),[X,Z]=d.useState(!1),oe=d.useCallback(async()=>{if(n){y(!0),h(null);try{const[P,V]=await Promise.all([am(),cm()]);a(P),u(V)}catch(P){h(P.message)}finally{y(!1)}}},[n]);d.useEffect(()=>{oe()},[oe]);async function Ae(P){const V=P.status==="active"?"disabled":"active";try{await um(P.user_uid,V),a(te=>te.map(ee=>ee.user_uid===P.user_uid?{...ee,status:V}:ee))}catch(te){h(te.message)}}async function ye(P){if(P.preventDefault(),!v.trim()||!S){k("Username and password required");return}E(!0),k(null);try{await om(v.trim(),S,p.trim()||void 0),x(""),N(""),f(""),await oe()}catch(V){k(V.message)}finally{E(!1)}}async function D(P){if(P.preventDefault(),!b.trim()||!T.trim()){U("Slug and name required");return}Z(!0),U(null);try{await dm(b.trim(),T.trim()),j(""),L(""),await oe()}catch(V){U(V.message)}finally{Z(!1)}}return n?s.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[s.jsx("h1",{children:"Admin"}),s.jsxs("div",{className:"view-tabs",children:[s.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),s.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),s.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),g&&s.jsx("div",{className:"form-msg form-msg--err",children:g}),r==="users"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Users"}),c?s.jsx("p",{className:"muted",children:"Loading…"}):s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Username"}),s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Roles"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:i.map(P=>s.jsxs("tr",{className:P.status==="disabled"?"admin-row-disabled":"",children:[s.jsx("td",{children:P.username}),s.jsx("td",{className:"muted",children:P.email||"β€”"}),s.jsx("td",{children:P.role_slugs.join(", ")||"β€”"}),s.jsx("td",{children:s.jsx("span",{className:`status-badge status-${P.status}`,children:P.status})}),s.jsx("td",{children:s.jsx("button",{className:"admin-action-btn",onClick:()=>Ae(P),children:P.status==="active"?"Ban":"Unban"})})]},P.user_uid))})]}),s.jsx("h3",{children:"Create User"}),s.jsxs("form",{className:"admin-form",onSubmit:ye,children:[s.jsx("input",{className:"admin-input",placeholder:"Username",value:v,onChange:P=>x(P.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:S,onChange:P=>N(P.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:p,onChange:P=>f(P.target.value)}),m&&s.jsx("div",{className:"form-msg form-msg--err",children:m}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:_,children:_?"Creating…":"Create User"})]})]}),r==="roles"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Roles"}),c?s.jsx("p",{className:"muted",children:"Loading…"}):s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Slug"}),s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Level"}),s.jsx("th",{children:"Bit"}),s.jsx("th",{children:"Built-in"})]})}),s.jsx("tbody",{children:o.map(P=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:P.slug})}),s.jsx("td",{children:P.name}),s.jsx("td",{children:P.level}),s.jsx("td",{children:P.bit_position}),s.jsx("td",{children:P.is_builtin?"βœ“":""})]},P.role_uid))})]}),s.jsx("h3",{children:"Create Custom Role"}),s.jsxs("form",{className:"admin-form",onSubmit:D,children:[s.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:b,onChange:P=>j(P.target.value),required:!0}),s.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:T,onChange:P=>L(P.target.value),required:!0}),K&&s.jsx("div",{className:"form-msg form-msg--err",children:K}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:X,children:X?"Creating…":"Create Role"})]})]}),r==="archives"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Mounted Archives"}),s.jsx("div",{className:"admin-list",children:e.map(P=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:P.label}),s.jsx("div",{className:"muted",children:P.archive_path})]},P.id))})]})]}):s.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[s.jsx("h1",{children:"Admin"}),s.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),s.jsx("h2",{children:"Mounted Archives"}),s.jsx("div",{className:"admin-list",children:e.map(P=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:P.label}),s.jsx("div",{className:"muted",children:P.archive_path})]},P.id))})]})}function Yd({node:e,onPick:t}){var n;return s.jsxs("li",{children:[s.jsx("button",{className:"tag-picker-node-btn",title:e.tag.full_path,onClick:()=>t(e.tag),children:e.tag.slug}),((n=e.children)==null?void 0:n.length)>0&&s.jsx("div",{className:"tag-children",children:s.jsx("ul",{className:"tag-tree-list",children:e.children.map(r=>s.jsx(Yd,{node:r,onPick:t},r.tag.tag_uid))})})]})}function Tu({title:e,tagNodes:t,excludeUid:n,onPick:r,onCancel:l}){d.useEffect(()=>{function o(u){u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),l())}return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[l]);function i(o){return o.filter(u=>u.tag.tag_uid!==n).map(u=>({...u,children:i(u.children)}))}const a=n?i(t):t;return s.jsx("div",{className:"tag-picker-backdrop",onClick:o=>{o.target===o.currentTarget&&l()},children:s.jsxs("div",{className:"tag-picker-modal",role:"dialog","aria-modal":"true",children:[s.jsxs("div",{className:"tag-picker-header",children:[s.jsx("span",{className:"tag-picker-title",children:e}),s.jsx("button",{className:"tag-picker-close",onClick:l,title:"Cancel","aria-label":"Cancel",children:"Γ—"})]}),s.jsxs("div",{className:"tag-picker-body",children:[s.jsx("button",{className:"tag-picker-root-btn",onClick:()=>r(null),title:"Place at root level (no parent)",children:"↑ Root tag (no parent)"}),a.length>0?s.jsx("ul",{className:"tag-tree-list tag-picker-tree",children:a.map(o=>s.jsx(Yd,{node:o,onPick:r},o.tag.tag_uid))}):s.jsx("p",{className:"tag-picker-empty",children:"No other tags available."})]})]})})}function Zd({parentPath:e,archiveId:t,onDone:n,onCancel:r}){const[l,i]=d.useState(""),a=d.useRef(!1);async function o(){const u=l.trim();if(!u){r();return}const c=e?`${e}/${u}`:`/${u}`;try{await Wh(t,c),n()}catch(y){alert(y.message||"Create failed"),r()}}return s.jsx("input",{className:"tag-rename-input",autoFocus:!0,placeholder:"tag name",value:l,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&u.currentTarget.blur(),u.key==="Escape"&&(a.current=!0,u.currentTarget.blur())},onBlur:()=>{a.current?(a.current=!1,r()):o()}})}function ef({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:c,onMoveSourceSelect:y,pendingCreateParentUid:g,onCreateDone:h,onCreateCancel:v}){var K;const x=n===e.tag.full_path,[S,N]=d.useState(!1),[p,f]=d.useState(""),m=d.useRef(!1);function k(){if(S)return;if(c){y(e);return}const U=x?null:e.tag.full_path;r(U),l("archive")}function _(U){U.stopPropagation(),!c&&(f(e.tag.slug),N(!0))}async function E(){const U=p.trim();if(!U||U===e.tag.slug){N(!1);return}try{const X=await Uh(t,e.tag.tag_uid,U);i(e.tag.full_path,X.full_path),o()}catch{}finally{N(!1)}}async function b(U){var Z;U.stopPropagation();const X=((Z=e.children)==null?void 0:Z.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(X))try{await Hh(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const j={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:c,onMoveSourceSelect:y,pendingCreateParentUid:g,onCreateDone:h,onCreateCancel:v},T=g===e.tag.tag_uid,L=((K=e.children)==null?void 0:K.length)>0;return s.jsxs("li",{children:[s.jsxs("div",{className:`tag-node-row${c?" tag-node-row--move-select":""}`,children:[S?s.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:p,onChange:U=>f(U.target.value),onKeyDown:U=>{U.key==="Enter"&&U.currentTarget.blur(),U.key==="Escape"&&(m.current=!0,U.currentTarget.blur())},onBlur:()=>{m.current?(m.current=!1,N(!1)):E()}}):s.jsxs("button",{className:`tag-node-btn${x?" is-active":""}${c?" tag-node-btn--move-select":""}`,title:c?`Select "${e.tag.full_path}" to move`:e.tag.full_path,onClick:k,onDoubleClick:c?void 0:_,children:[s.jsx("span",{className:"tag-node-label",children:u?e.tag.name:e.tag.slug}),s.jsx("span",{className:"tag-node-count",children:e.children.length===0?`(${e.entry_count})`:`(${e.entry_count}) (${e.subtree_count} Total)`}),!c&&s.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",title:"Rename tag",onClick:U=>{U.stopPropagation(),_(U)},children:s.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),!S&&!c&&s.jsx("button",{className:"remove tag-node-delete",title:`Delete "${e.tag.full_path}"`,onClick:b,"aria-label":`Delete "${e.tag.full_path}"`,children:"Γ—"})]}),(L||T)&&s.jsx("div",{className:"tag-children",children:s.jsxs("ul",{className:"tag-tree-list",children:[e.children.map(U=>s.jsx(ef,{node:U,...j},U.tag.tag_uid)),T&&s.jsx("li",{children:s.jsx(Zd,{parentPath:e.tag.full_path,archiveId:t,onDone:h,onCancel:v})})]})})]})}function qm({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){const[c,y]=d.useState(null),[g,h]=d.useState(null);function v(){y("select-source"),h(null)}function x(){y(null),h(null)}d.useEffect(()=>{if(c!=="select-source")return;function X(Z){Z.key==="Escape"&&(Z.preventDefault(),Z.stopPropagation(),x())}return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[c]);function S(X){h(X),y("select-dest")}async function N(X){const Z=g.tag.full_path,oe=g.tag.tag_uid,Ae=(X==null?void 0:X.tag_uid)??null;x();try{const ye=await Vh(e,oe,Ae);i(Z,ye.full_path),o()}catch(ye){alert(ye.message||"Move failed")}}const[p,f]=d.useState(null),[m,k]=d.useState(void 0);function _(){f("select-parent"),k(void 0)}function E(){f(null),k(void 0)}function b(X){k(X??null),f("input")}function j(){f(null),k(void 0),o()}const T=c==="select-source",L=p==="input"?m?m.tag_uid:"__root__":void 0,K={archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:T,onMoveSourceSelect:S,pendingCreateParentUid:L,onCreateDone:j,onCreateCancel:E},U=L==="__root__";return s.jsxs("section",{id:"tags-view",className:"view is-active",children:[s.jsxs("div",{className:"tag-tree",children:[s.jsx("div",{className:"tag-tree-header",children:T?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag-tree-title tag-tree-title--move",children:"Select a tag to move"}),s.jsx("button",{className:"tag-tree-action-btn tag-tree-action-btn--cancel",onClick:x,children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&s.jsxs("span",{className:"tag-tree-active",title:n,children:["Filtering: ",n]}),s.jsxs("div",{className:"tag-tree-actions",children:[s.jsx("button",{className:"tag-tree-action-btn",onClick:_,title:"Create a new tag",disabled:!!p||!!c,children:"+ New"}),s.jsx("button",{className:"tag-tree-action-btn",onClick:v,title:"Move a tag to a different parent",disabled:!!p||!!c||t.length===0,children:"Move"})]})]})}),t.length===0&&!U?s.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):s.jsxs("ul",{className:"tag-tree-list",children:[t.map(X=>s.jsx(ef,{node:X,...K},X.tag.tag_uid)),U&&s.jsx("li",{children:s.jsx(Zd,{parentPath:null,archiveId:e,onDone:j,onCancel:E})})]})]}),p==="select-parent"&&s.jsx(Tu,{title:"Create tag under…",tagNodes:t,excludeUid:null,onPick:b,onCancel:E}),c==="select-dest"&&g&&s.jsx(Tu,{title:`Move "${g.tag.slug}" under…`,tagNodes:t,excludeUid:g.tag.tag_uid,onPick:N,onCancel:x})]})}const Or=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],Km=e=>{var t;return((t=Or.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function Xm({archiveId:e}){const[t,n]=d.useState([]),[r,l]=d.useState(!1),[i,a]=d.useState(null),[o,u]=d.useState(null),[c,y]=d.useState(null),[g,h]=d.useState(!1),[v,x]=d.useState(null),[S,N]=d.useState(""),[p,f]=d.useState(""),[m,k]=d.useState(2),[_,E]=d.useState(!1),[b,j]=d.useState(!0),[T,L]=d.useState(null),[K,U]=d.useState(""),[X,Z]=d.useState(2),[oe,Ae]=d.useState(!1),[ye,D]=d.useState(null),[P,V]=d.useState(!1),[te,ee]=d.useState(""),Re=d.useRef(null),Y=t.find(A=>A.collection_uid===o)??null,he=(Y==null?void 0:Y.slug)==="_default_",ue=d.useCallback(async()=>{if(e){l(!0),a(null);try{const A=await io(e);n(A)}catch(A){a(A.message)}finally{l(!1)}}},[e]),Ee=d.useCallback(async A=>{if(!A){y(null);return}h(!0),x(null);try{const q=await pm(e,A);y(q)}catch(q){x(q.message)}finally{h(!1)}},[e]);d.useEffect(()=>{ue()},[ue]),d.useEffect(()=>{Ee(o)},[o,Ee]),d.useEffect(()=>{P&&Re.current&&Re.current.focus()},[P]),d.useEffect(()=>{c!=null&&Z(c.default_visibility_bits)},[c]);async function Qe(A){A.preventDefault();const q=S.trim(),de=p.trim();if(!(!q||!de)){E(!0),L(null);try{const Be=await fm(e,q,de,m,b);N(""),f(""),k(2),j(!0),await ue(),u(Be.collection_uid)}catch(Be){L(Be.message)}finally{E(!1)}}}async function Et(){const A=te.trim();if(!A||!Y){V(!1);return}try{await pi(e,Y.collection_uid,{name:A}),await ue(),y(q=>q&&{...q,name:A})}catch(q){a(q.message)}finally{V(!1)}}async function ut(A){if(Y)try{await pi(e,Y.collection_uid,{default_visibility_bits:A}),await ue(),y(q=>q&&{...q,default_visibility_bits:A})}catch(q){a(q.message)}}async function Wt(A){if(Y)try{await pi(e,Y.collection_uid,{requires_auth:A}),await ue(),y(q=>q&&{...q,requires_auth:A})}catch(q){a(q.message)}}async function ct(){if(Y&&window.confirm(`Delete collection "${Y.name}"? Entries will not be deleted.`))try{await gm(e,Y.collection_uid),u(null),y(null),await ue()}catch(A){a(A.message)}}async function rt(A){A.preventDefault();const q=K.trim();if(!(!q||!Y)){Ae(!0),D(null);try{await ca(e,Y.collection_uid,q,X),U(""),await Ee(Y.collection_uid)}catch(de){D(de.message)}finally{Ae(!1)}}}async function xt(A){if(Y)try{await hm(e,Y.collection_uid,A),await Ee(Y.collection_uid)}catch(q){x(q.message)}}async function bt(A,q){if(Y)try{await mm(e,Y.collection_uid,A,q),y(de=>de&&{...de,entries:de.entries.map(Be=>Be.entry_uid===A?{...Be,collection_visibility_bits:q}:Be)})}catch(de){x(de.message)}}return e?s.jsxs("div",{className:"collections-view",children:[s.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&s.jsx("div",{className:"muted",children:"Loading…"}),i&&s.jsxs("div",{className:"collections-error",children:[i," ",s.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"Γ—"})]}),s.jsxs("div",{className:"collections-layout",children:[s.jsxs("div",{className:"collections-sidebar",children:[t.map(A=>s.jsxs("button",{className:`coll-sidebar-row${o===A.collection_uid?" is-active":""}`,onClick:()=>u(A.collection_uid),children:[s.jsx("span",{className:"coll-row-name",children:A.name}),s.jsx("span",{className:"coll-row-meta",children:Km(A.default_visibility_bits)})]},A.collection_uid)),t.length===0&&!r&&s.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),Y?s.jsxs("div",{className:"coll-detail",children:[s.jsxs("div",{className:"coll-detail-header",children:[P?s.jsx("input",{ref:Re,className:"coll-rename-input",value:te,onChange:A=>ee(A.target.value),onBlur:Et,onKeyDown:A=>{A.key==="Enter"&&Et(),A.key==="Escape"&&V(!1)}}):s.jsxs("h3",{className:`coll-detail-name${he?"":" coll-detail-name--editable"}`,title:he?void 0:"Click to rename",onClick:()=>{he||(ee(Y.name),V(!0))},children:[(c==null?void 0:c.name)??Y.name,!he&&s.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!he&&s.jsx("button",{className:"coll-delete-btn",onClick:ct,title:"Delete collection",children:"Delete"})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Entries' default visibility"}),s.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??Y.default_visibility_bits,onChange:A=>ut(Number(A.target.value)),children:Or.map(A=>s.jsx("option",{value:A.value,children:A.label},A.value))})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Collection access"}),s.jsxs("label",{className:"coll-auth-label",children:[s.jsx("input",{type:"checkbox",checked:!!((c==null?void 0:c.requires_auth)??Y.requires_auth),onChange:A=>Wt(A.target.checked)})," Require authentication to view"]})]}),s.jsxs("div",{className:"coll-entries-section",children:[s.jsx("div",{className:"coll-section-heading",children:"Entries"}),g&&s.jsx("div",{className:"muted",children:"Loading…"}),v&&s.jsx("div",{className:"collections-error",children:v}),!g&&c&&(c.entries.length===0?s.jsx("div",{className:"muted",children:"No entries in this collection."}):s.jsx("ul",{className:"coll-entries-list",children:c.entries.map(A=>s.jsxs("li",{className:"coll-entry-row",children:[s.jsxs("div",{className:"coll-entry-info",children:[s.jsx("span",{className:"coll-entry-title",children:A.title||A.entry_uid}),s.jsx("span",{className:"coll-entry-kind muted",children:A.source_kind})]}),s.jsxs("div",{className:"coll-entry-actions",children:[s.jsx("select",{className:"coll-entry-vis-select",value:A.collection_visibility_bits,onChange:q=>bt(A.entry_uid,Number(q.target.value)),children:Or.map(q=>s.jsx("option",{value:q.value,children:q.label},q.value))}),!he&&s.jsx("button",{className:"coll-entry-remove",onClick:()=>xt(A.entry_uid),title:"Remove from collection",children:"Γ—"})]})]},A.entry_uid))}))]}),!he&&s.jsxs("form",{className:"coll-add-entry-form",onSubmit:rt,children:[s.jsx("div",{className:"coll-section-heading",children:"Add entry"}),s.jsxs("div",{className:"coll-add-entry-row",children:[s.jsx("input",{className:"coll-add-entry-input",type:"text",value:K,onChange:A=>U(A.target.value),placeholder:"entry_uid",required:!0}),s.jsx("select",{className:"coll-vis-select",value:X,onChange:A=>Z(Number(A.target.value)),children:Or.map(A=>s.jsx("option",{value:A.value,children:A.label},A.value))}),s.jsx("button",{className:"coll-add-btn",type:"submit",disabled:oe,children:oe?"…":"Add"})]}),ye&&s.jsx("div",{className:"collections-error",style:{marginTop:4},children:ye})]})]}):s.jsx("div",{className:"coll-detail coll-detail--empty",children:s.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),s.jsxs("details",{className:"coll-create-details",children:[s.jsx("summary",{children:"+ Create collection"}),s.jsxs("form",{className:"coll-create-form",onSubmit:Qe,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),s.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:S,onChange:A=>{N(A.target.value),p||f(A.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),s.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:p,onChange:A=>f(A.target.value),placeholder:"my-collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Entries' default visibility"}),s.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:m,onChange:A=>k(Number(A.target.value)),children:Or.map(A=>s.jsx("option",{value:A.value,children:A.label},A.value))})]}),s.jsx("div",{className:"form-field",children:s.jsxs("label",{className:"form-label",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:A=>j(A.target.checked)})," Require authentication to view"]})}),T&&s.jsx("div",{className:"collections-error",children:T}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:_,children:_?"Creating…":"Create collection"})]})]})]}):s.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const Jm=4;function Gm({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=d.useContext(As)??{},i=r&&(r.role_bits&Jm)!==0,a=["profile","tokens",...i?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return s.jsxs("section",{className:"admin-view",children:[s.jsx("h1",{children:"Settings"}),s.jsx("div",{className:"view-tabs",children:a.map(u=>s.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&s.jsx(Ym,{currentUser:r,setCurrentUser:l}),e==="tokens"&&s.jsx(Zm,{}),e==="instance"&&i&&s.jsx(eg,{}),e==="cookies"&&i&&s.jsx(ng,{}),e==="extensions"&&i&&s.jsx(rg,{}),e==="storage"&&i&&s.jsx(tg,{archiveId:n})]})}function Ym({currentUser:e,setCurrentUser:t}){const[n,r]=d.useState((e==null?void 0:e.display_name)??""),[l,i]=d.useState(!1),[a,o]=d.useState(null),[u,c]=d.useState(""),[y,g]=d.useState(""),[h,v]=d.useState(""),[x,S]=d.useState(!1),[N,p]=d.useState(null);async function f(k){k.preventDefault(),i(!0),o(null);try{await tm(n),t(_=>({..._,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(_){o({ok:!1,text:_.message})}finally{i(!1)}}async function m(k){if(k.preventDefault(),y!==h){p({ok:!1,text:"Passwords do not match."});return}S(!0),p(null);try{await rm(u,y),c(""),g(""),v(""),p({ok:!0,text:"Password changed."})}catch(_){p({ok:!1,text:_.message})}finally{S(!1)}}return s.jsxs("div",{style:{maxWidth:440},children:[s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Display Name"}),s.jsxs("form",{onSubmit:f,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),s.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:k=>r(k.target.value)})]}),a&&s.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Display Preferences"}),s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async k=>{const _=k.target.checked;try{await nm({humanize_slugs:_}),t(E=>({...E,humanize_slugs:_}))}catch{}}}),s.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),s.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Change Password"}),s.jsxs("form",{onSubmit:m,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),s.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:k=>c(k.target.value),required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),s.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:y,onChange:k=>g(k.target.value),required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),s.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:h,onChange:k=>v(k.target.value),required:!0})]}),N&&s.jsx("div",{className:`form-msg form-msg--${N.ok?"ok":"err"}`,children:N.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Changing…":"Change Password"})]})]})]})}function Zm(){const[e,t]=d.useState([]),[n,r]=d.useState(!0),[l,i]=d.useState(null),[a,o]=d.useState(""),[u,c]=d.useState(!1),[y,g]=d.useState(null),h=d.useCallback(async()=>{r(!0),i(null);try{t(await lm())}catch(S){i(S.message)}finally{r(!1)}},[]);d.useEffect(()=>{h()},[h]);async function v(S){if(S.preventDefault(),!!a.trim()){c(!0);try{const N=await sm(a.trim());g(N),o(""),h()}catch(N){i(N.message)}finally{c(!1)}}}async function x(S){try{await im(S),t(N=>N.filter(p=>p.token_uid!==S))}catch(N){i(N.message)}}return s.jsx("div",{style:{maxWidth:600},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"API Tokens"}),y&&s.jsxs("div",{className:"token-banner",children:[s.jsx("strong",{children:"Token created."})," Copy it now β€” it won't be shown again.",s.jsx("code",{children:y.raw_token}),s.jsx("button",{className:"token-dismiss",onClick:()=>g(null),children:"Dismiss"})]}),s.jsxs("form",{className:"token-create-row",onSubmit:v,children:[s.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:S=>o(S.target.value),required:!0}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&s.jsx("div",{className:"form-msg form-msg--err",children:l}),n?s.jsx("div",{className:"muted",children:"Loading…"}):s.jsxs("div",{children:[e.length===0&&s.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(S=>s.jsxs("div",{className:"token-row",children:[s.jsxs("div",{className:"token-row-info",children:[s.jsx("strong",{children:S.name}),s.jsxs("div",{className:"muted",children:["Created ",S.created_at.slice(0,10),S.last_used_at&&` Β· Last used ${S.last_used_at.slice(0,10)}`]})]}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>x(S.token_uid),children:"Revoke"})]},S.token_uid))]})]})})}function eg(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[l,i]=d.useState(null),[a,o]=d.useState(!1),[u,c]=d.useState(null);d.useEffect(()=>{(async()=>{try{t(await so())}catch(g){i(g.message)}finally{r(!1)}})()},[]);async function y(g){g.preventDefault(),o(!0),c(null);try{await Xl(e),c({ok:!0,text:"Saved."})}catch(h){c({ok:!1,text:h.message})}finally{o(!1)}}return n?s.jsx("div",{className:"muted",children:"Loading…"}):l?s.jsx("div",{className:"form-msg form-msg--err",children:l}):e?s.jsx("div",{style:{maxWidth:440},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Instance Settings"}),s.jsxs("form",{onSubmit:y,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([g,h])=>s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:!!e[g],onChange:v=>t(x=>({...x,[g]:v.target.checked}))}),h]},g)),s.jsxs("div",{className:"form-field",style:{marginTop:4},children:[s.jsx("label",{className:"form-label",children:"Default entry visibility"}),s.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:g=>t(h=>({...h,default_entry_visibility:Number(g.target.value)})),children:[s.jsx("option",{value:0,children:"Private"}),s.jsx("option",{value:2,children:"Unlisted"}),s.jsx("option",{value:3,children:"Public"})]})]}),u&&s.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function mi(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 tg({archiveId:e}){const[t,n]=d.useState("idle"),[r,l]=d.useState(null),[i,a]=d.useState(null),[o,u]=d.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function y(){n("scanning"),u(null),l(null);try{const v=await ym(e);l(v),n("scanned")}catch(v){u(v.message),n("error")}}async function g(){n("deleting"),u(null);try{const v=await vm(e);a(v),n("done")}catch(v){u(v.message),n("error")}}const h=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return s.jsx("div",{style:{maxWidth:440},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Orphan Cleanup"}),s.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."," ",s.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&s.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&s.jsx("button",{className:"btn-ghost",onClick:y,children:"Scan for orphaned blobs"}),t==="scanning"&&s.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean β€” nothing to remove."}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!h&&s.jsxs("div",{children:[s.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",s.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",s.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","β€” ",s.jsx("strong",{children:mi(r.total_bytes)})," recoverable."]}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsxs("button",{className:"btn-danger",onClick:g,children:["Delete (",mi(r.total_bytes),")"]}),s.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&s.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&i&&s.jsxs("div",{children:[s.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",s.jsx("strong",{children:mi(i.freed_bytes)})," ","β€” removed ",i.deleted_files," file",i.deleted_files!==1?"s":""," ","and ",i.deleted_blob_rows," DB record",i.deleted_blob_rows!==1?"s":"","."]}),i.errors&&i.errors.length>0&&s.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[i.errors.length," file",i.errors.length!==1?"s":""," could not be deleted."]}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&s.jsxs("div",{children:[s.jsx("div",{className:"form-msg form-msg--err",children:o}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function ng(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[l,i]=d.useState(null),[a,o]=d.useState("global"),[u,c]=d.useState(""),[y,g]=d.useState("{}"),[h,v]=d.useState(null),[x,S]=d.useState(!1),[N,p]=d.useState({});d.useEffect(()=>{f()},[]);async function f(){r(!0),i(null);try{t(await km())}catch(j){i(j.message)}finally{r(!1)}}async function m(j){j.preventDefault();try{JSON.parse(y)}catch{v({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}S(!0),v(null);try{await jm(a==="global"?null:u.trim(),a,y),c(""),g("{}"),o("global"),v({ok:!0,text:"Rule added."}),await f()}catch(T){v({ok:!1,text:T.message})}finally{S(!1)}}async function k(j){try{await Nm(j),await f()}catch(T){i(T.message)}}function _(j){p(T=>({...T,[j.rule_uid]:{cookiesInput:j.cookies_json,saving:!1,msg:null}}))}function E(j){p(T=>{const L={...T};return delete L[j],L})}async function b(j){const T=N[j.rule_uid];try{JSON.parse(T.cookiesInput)}catch{p(L=>({...L,[j.rule_uid]:{...L[j.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}p(L=>({...L,[j.rule_uid]:{...L[j.rule_uid],saving:!0,msg:null}}));try{await Sm(j.rule_uid,{cookies_json:T.cookiesInput}),E(j.rule_uid),await f()}catch(L){p(K=>({...K,[j.rule_uid]:{...K[j.rule_uid],saving:!1,msg:{ok:!1,text:L.message}}}))}}return n?s.jsx("div",{className:"muted",children:"Loading…"}):l?s.jsx("div",{className:"form-msg form-msg--err",children:l}):s.jsx("div",{style:{maxWidth:560},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Cookie Rules"}),s.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?s.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Pattern"}),s.jsx("th",{children:"Cookies"}),s.jsx("th",{style:{width:100},children:"Actions"})]})}),s.jsx("tbody",{children:e.map(j=>{const T=N[j.rule_uid],L=j.url_pattern?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted",children:[j.pattern_kind,":"]})," ",s.jsx("code",{children:j.url_pattern})]}):s.jsx("span",{className:"muted",children:"global (all URLs)"});return s.jsxs("tr",{children:[s.jsx("td",{children:L}),s.jsx("td",{children:T?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:T.cookiesInput,onChange:K=>p(U=>({...U,[j.rule_uid]:{...U[j.rule_uid],cookiesInput:K.target.value}}))}),T.msg&&s.jsx("div",{className:`form-msg form-msg--${T.msg.ok?"ok":"err"}`,children:T.msg.text}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[s.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:T.saving,onClick:()=>b(j),children:T.saving?"Saving…":"Save"}),s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>E(j.rule_uid),children:"Cancel"})]})]}):s.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:j.cookies_json})}),s.jsx("td",{children:!T&&s.jsxs("div",{style:{display:"flex",gap:6},children:[s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>_(j),children:"Edit"}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>k(j.rule_uid),children:"Del"})]})})]},j.rule_uid)})})]}):s.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),s.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),s.jsxs("form",{onSubmit:m,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:"Pattern type"}),s.jsxs("select",{className:"field-input",value:a,onChange:j=>o(j.target.value),children:[s.jsx("option",{value:"global",children:"Global (all URLs)"}),s.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),s.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),s.jsx("input",{className:"field-input",type:"text",value:u,onChange:j=>c(j.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:y,onChange:j=>g(j.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),h&&s.jsx("div",{className:`form-msg form-msg--${h.ok?"ok":"err"}`,children:h.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Adding…":"Add Rule"})]})]})})}function rg(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[l,i]=d.useState(!1),[a,o]=d.useState(null);d.useEffect(()=>{(async()=>{try{t(await so())}catch(N){o({ok:!1,text:N.message})}finally{r(!1)}})()},[]);async function u(N){i(!0),o(null);try{await Xl({ublock_enabled:N}),t(p=>({...p,ublock_enabled:N})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}async function c(N){i(!0),o(null);try{await Xl({cookie_ext_enabled:N}),t(p=>({...p,cookie_ext_enabled:N})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}async function y(N){i(!0),o(null);try{await Xl({modal_closer_enabled:N}),t(p=>({...p,modal_closer_enabled:N})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}if(n)return s.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,h=(e==null?void 0:e.ublock_enabled)??!0,v=(e==null?void 0:e.cookie_ext_available)??!1,x=(e==null?void 0:e.cookie_ext_enabled)??!0,S=(e==null?void 0:e.modal_closer_enabled)??!0;return s.jsx("div",{children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Extensions"}),s.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."}),s.jsxs("div",{className:"ext-grid",children:[s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),s.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!g&&s.jsxs("span",{className:"ext-card-hint",children:["Not configured β€” set ",s.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":h,className:`ext-toggle${h?" ext-toggle--on":""}`,onClick:()=>u(!h),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:s.jsx("span",{className:"ext-toggle-knob"})})]})}),s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),s.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!v&&s.jsxs("span",{className:"ext-card-hint",children:["Not configured β€” set ",s.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":x,className:`ext-toggle${x?" ext-toggle--on":""}`,onClick:()=>c(!x),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",children:s.jsx("span",{className:"ext-toggle-knob"})})]})}),s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"Modal & Dialog Closer"}),s.jsx("span",{className:"ext-card-desc",children:"Auto-dismiss cookie banners, consent overlays, and other modal dialogs before a WebPage capture is taken. Implemented as an injected browser script; no external extension required."})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":S,className:`ext-toggle${S?" ext-toggle--on":""}`,onClick:()=>y(!S),disabled:l,"aria-label":"Toggle Modal and Dialog Closer",children:s.jsx("span",{className:"ext-toggle-knob"})})]})})]}),a&&s.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const Pu={0:"Private",1:"Public",2:"Users only",3:"Public"},lg=()=>s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function sg({archiveId:e,selectedEntry:t,selectedUids:n,selectedEntries:r,detail:l,onTagFilterSet:i,tagNodes:a,onTagsRefresh:o,onEntryTitleChange:u,onEntryDeleted:c,onBulkDeleted:y,humanizeTags:g,onDetailRefresh:h,onOpenPreview:v,onPlay:x,isPublicSession:S}){var yl;const[N,p]=d.useState([]),[f,m]=d.useState(""),[k,_]=d.useState([]),[E,b]=d.useState(""),j=d.useRef(0),T=d.useRef(!1),[L,K]=d.useState(!1),[U,X]=d.useState(""),[Z,oe]=d.useState("idle"),[Ae,ye]=d.useState(""),D=d.useRef(null),[P,V]=d.useState(!1);d.useEffect(()=>{V(!1)},[(yl=l==null?void 0:l.summary)==null?void 0:yl.entry_uid]);const te=(n==null?void 0:n.size)>=2,[ee,Re]=d.useState(""),[Y,he]=d.useState("idle"),[ue,Ee]=d.useState(""),[Qe,Et]=d.useState([]),[ut,Wt]=d.useState(""),[ct,rt]=d.useState("idle"),[xt,bt]=d.useState(""),[A,q]=d.useState("idle"),[de,Be]=d.useState(""),[Dt,ze]=d.useState("idle"),[Bn,_n]=d.useState("");d.useEffect(()=>{const z=++j.current;if(D.current&&(clearInterval(D.current),D.current=null),oe("idle"),ye(""),!t||!e){p([]),_([]);return}if(S){p([]),_([]);return}K(!1),X(""),T.current=!1,p([]),Promise.all([$l(e,t.entry_uid),Cu(e,t.entry_uid)]).then(([re,be])=>{z===j.current&&(p(re),_(be))}).catch(()=>{})},[t,e,S]),d.useEffect(()=>()=>{clearInterval(D.current)},[]),d.useEffect(()=>{if(!e){Et([]);return}io(e).then(Et).catch(()=>Et([]))},[e]),d.useEffect(()=>{Re(""),he("idle"),Ee(""),Wt(""),rt("idle"),bt(""),q("idle"),Be(""),ze("idle"),_n("")},[n]);async function nn(){const z=n.size;if(!window.confirm(`Delete ${z} entr${z===1?"y":"ies"}? This cannot be undone.`))return;q("running");const re=new Set;for(const be of n)try{await _u(e,be),re.add(be)}catch{}q("idle"),y==null||y(re)}async function qe(){const z=ee.trim();if(z){he("running"),Ee("");try{for(const re of n)await Nu(e,re,z);Re(""),he("done"),o==null||o(),setTimeout(()=>he("idle"),1800)}catch(re){Ee(re.message),he("error")}}}async function wr(){if(!ut)return;rt("running"),bt("");const z=[],re=Qe.find(be=>be.collection_uid===ut);for(const be of n)try{await ca(e,ut,be,(re==null?void 0:re.default_visibility_bits)??2)}catch{z.push(be)}z.length>0?(bt(`Failed for ${z.length} entr${z.length===1?"y":"ies"}.`),rt("error")):(rt("done"),setTimeout(()=>rt("idle"),1800))}async function Un(){if(!de||!t)return;ze("running"),_n("");const z=Qe.find(re=>re.collection_uid===de);try{await ca(e,de,t.entry_uid,(z==null?void 0:z.default_visibility_bits)??2),ze("done"),Be("");const re=await Cu(e,t.entry_uid);_(re),setTimeout(()=>ze("idle"),1800)}catch(re){_n(re.message),ze("error")}}async function w(){const z=U.trim()||null;try{await Fh(e,t.entry_uid,z),u==null||u(t.entry_uid,z)}catch{}finally{K(!1)}}async function B(){const z=f.trim();if(!(!z||!t))try{await Nu(e,t.entry_uid,z),m(""),b("");const re=await $l(e,t.entry_uid);p(re),o()}catch(re){b(re.message)}}async function M(z){try{await Bh(e,t.entry_uid,z);const re=await $l(e,t.entry_uid);p(re),o()}catch{}}async function I(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await _u(e,t.entry_uid),c==null||c(t.entry_uid)}catch{}}async function F(){if(!t||!e||Z==="running")return;const z=j.current,re=t.entry_uid;oe("running"),ye("");try{const{job_uid:be}=await xm(e,re);if(j.current!==z)return;D.current=setInterval(async()=>{try{const Ot=await Xd(e,be);if(Ot.status==="completed"){if(clearInterval(D.current),D.current=null,j.current!==z)return;oe("done");const Vt=await $l(e,re);if(j.current!==z)return;p(Vt),h==null||h()}else if(Ot.status==="failed"){if(clearInterval(D.current),D.current=null,j.current!==z)return;oe("error"),ye(Ot.error_text||"Re-archive failed.")}}catch{if(clearInterval(D.current),D.current=null,j.current!==z)return;oe("error"),ye("Network error while polling.")}},500)}catch(be){if(j.current!==z)return;oe("error"),ye(be.message||"Failed to start re-archive.")}}const H=l?[["Added",ao(l.summary.archived_at)],["Source",l.summary.source_kind],["Type",l.summary.entity_kind],["Visibility",Pu[l.summary.visibility]??l.summary.visibility],["Root",l.structured_root_relpath]]:[],xe=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),fe=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),we=l?l.artifacts.findIndex(z=>z.artifact_role==="primary_media"):-1,ce=we>=0?l.artifacts[we]:null,Ue=ce?ce.relpath.split(".").pop().toLowerCase():"",le=ce&&xe.has(Ue),dt=we>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${we}`:null,wt=l&&!le&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread"||ce&&fe.has(Ue));return s.jsxs("aside",{className:"context-rail",children:[s.jsx("div",{className:"rail-eyebrow",children:"Context"}),te?S?s.jsxs("p",{className:"bulk-count",children:[s.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}):s.jsxs("div",{className:"bulk-panel",children:[s.jsxs("p",{className:"bulk-count",children:[s.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}),s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Assign tag"}),ue&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:ue}),s.jsxs("div",{className:"tag-input-wrap",children:[s.jsx("span",{className:"hash",children:"/"}),s.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:ee,onChange:z=>Re(z.target.value),onKeyDown:z=>{z.key==="Enter"&&qe()}}),s.jsx("button",{className:"tag-add-btn",onClick:qe,disabled:Y==="running"||!ee.trim(),children:Y==="running"?"…":Y==="done"?"βœ“":"Add"})]})]}),Qe.length>0&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Add to collection"}),s.jsxs("div",{className:"bulk-coll-row",children:[s.jsxs("select",{className:"bulk-coll-select",value:ut,onChange:z=>Wt(z.target.value),children:[s.jsx("option",{value:"",children:"Pick a collection…"}),Qe.filter(z=>z.slug!=="_default_").map(z=>s.jsx("option",{value:z.collection_uid,children:z.name},z.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:wr,disabled:!ut||ct==="running",children:ct==="running"?"…":ct==="done"?"βœ“":ct==="error"?"!":"Add"})]}),xt&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"6px 0 0"},children:xt})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:nn,disabled:A==="running",children:A==="running"?"Deleting…":`Delete ${n.size} entr${n.size===1?"y":"ies"}`})})]}):t?l?s.jsxs(s.Fragment,{children:[S?s.jsx("h2",{className:"rail-title",children:pt(l.summary.title)||pt(l.summary.entry_uid)}):L?s.jsx("input",{className:"rail-title-input",autoFocus:!0,value:U,onChange:z=>X(z.target.value),onKeyDown:z=>{z.key==="Enter"&&z.currentTarget.blur(),z.key==="Escape"&&(T.current=!0,z.currentTarget.blur())},onBlur:()=>{T.current?K(!1):w(),T.current=!1}}):s.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{X(l.summary.title??""),K(!0)},children:[pt(l.summary.title)||pt(l.summary.entry_uid),s.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:s.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),l.summary.original_url&&s.jsxs("a",{className:"url-tile",href:l.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[s.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:Os(l.summary.source_kind)}}),s.jsx("span",{className:"u-text",children:l.summary.original_url}),s.jsx("span",{className:"ext",children:s.jsx(lg,{})})]}),le&&x&&s.jsx("button",{className:"rail-preview-btn",onClick:()=>x(dt,t),children:"β–Ά Play"}),wt&&v&&s.jsx("button",{className:"rail-preview-btn",onClick:v,children:"Preview"}),s.jsx("div",{className:"meta-list",children:H.filter(([,z])=>z!=null&&z!=="").map(([z,re])=>s.jsxs("div",{className:"meta-item",children:[s.jsx("span",{className:"meta-k",children:z}),s.jsx("span",{className:`meta-v${z==="Root"?" mono":""}`,children:pt(re)})]},z))}),l.artifacts.length>0&&(()=>{const z=l.artifacts.map((Ie,jr)=>({...Ie,_idx:jr})),re=z.filter(Ie=>Ie.artifact_role==="font"),be=z.filter(Ie=>Ie.artifact_role!=="font"),Ot=re.reduce((Ie,jr)=>Ie+(jr.byte_size||0),0),Vt=l.summary.entry_uid,kr=Ie=>s.jsx("li",{children:s.jsxs("a",{href:`/api/archives/${e}/entries/${Vt}/artifacts/${Ie._idx}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[s.jsx("span",{className:"artifact-name",children:Ie.artifact_role==="font"?Ie.relpath.split("/").pop():Ie.artifact_role.replace(/_/g," ")}),s.jsx("span",{className:"artifact-size",children:Ie.byte_size!=null?dl(Ie.byte_size):"β€”"})]})},Ie._idx);return s.jsxs("div",{className:"rail-section",children:[s.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",s.jsx("span",{className:"num",children:l.artifacts.length})]}),s.jsxs("ul",{className:"artifact-list",children:[be.map(kr),re.length>0&&s.jsxs("li",{className:"artifact-group",children:[s.jsxs("button",{type:"button",className:"artifact-group-header artifact-link","aria-expanded":P,onClick:()=>V(Ie=>!Ie),children:[s.jsxs("span",{className:"artifact-name",children:[s.jsx("span",{"aria-hidden":"true",className:`artifact-group-chevron${P?" open":""}`,children:"β€Ί"}),` fonts (${re.length})`]}),s.jsx("span",{className:"artifact-size",children:dl(Ot)})]}),P&&s.jsx("ul",{className:"artifact-list artifact-group-body",children:re.map(kr)})]})]})]})})()]}):s.jsx("p",{className:"tags-empty",children:"Loading\\u2026"}):s.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&!te&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Tags"}),N.length===0?s.jsx("p",{className:"tags-empty",children:"No tags yet."}):s.jsx("div",{className:"tags-wrap",children:N.map(z=>s.jsxs("span",{className:"tag-pill",title:z.full_path,children:[g?Gd(z.full_path):z.full_path,s.jsx("button",{className:"remove",title:`Remove tag ${z.full_path}`,onClick:()=>M(z.tag_uid),children:"Γ—"})]},z.tag_uid))}),E&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:E}),s.jsxs("div",{className:"tag-input-wrap",children:[s.jsx("span",{className:"hash",children:"/"}),s.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:f,onChange:z=>m(z.target.value),onKeyDown:z=>{z.key==="Enter"&&B()}}),s.jsx("button",{className:"tag-add-btn",onClick:B,children:"Add"})]})]}),(k.length>0||Qe.filter(z=>z.slug!=="_default_").length>0)&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Collections"}),k.map(z=>s.jsxs("div",{className:"coll-row",children:[s.jsx("span",{className:"coll-name",children:z.name}),s.jsx("span",{className:"vis-badge",children:Pu[z.visibility_bits]??`bits:${z.visibility_bits}`})]},z.collection_uid)),Qe.filter(z=>z.slug!=="_default_").length>0&&s.jsxs("div",{className:"bulk-coll-row",style:{marginTop:8},children:[s.jsxs("select",{className:"bulk-coll-select",value:de,onChange:z=>Be(z.target.value),children:[s.jsx("option",{value:"",children:"Add to collection…"}),Qe.filter(z=>z.slug!=="_default_").map(z=>s.jsx("option",{value:z.collection_uid,children:z.name},z.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:Un,disabled:!de||Dt==="running",children:Dt==="running"?"…":Dt==="done"?"βœ“":Dt==="error"?"!":"Add"})]}),Bn&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"4px 0 0"},children:Bn})]}),l&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread")&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Actions"}),s.jsx("button",{className:"rail-rearchive-btn",onClick:F,disabled:Z==="running",children:Z==="running"?"Re-archiving…":"Re-archive"}),Z==="done"&&s.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),Z==="error"&&s.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:Ae})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:I,children:"Delete entry"})})]})]})}const ig=/\/api\/archives\/([^/]+)\/entries\/([^/]+)\/artifacts\/(\d+)/;function ag(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M5 17H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h18a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2"}),s.jsx("polygon",{points:"12 15 17 21 7 21 12 15"})]})}function og({src:e,contentType:t="video/mp4"}){const n=d.useRef(null),[r,l]=d.useState(null),[i,a]=d.useState(!1),[o,u]=d.useState(!1);d.useEffect(()=>{if(!e){l(null);return}const g=e.match(ig);if(!g){l(e);return}let h=!1;return l(null),wm(g[1],g[2],parseInt(g[3],10)).then(({url:v})=>{h||l(v)}).catch(()=>{h||l(e)}),()=>{h=!0}},[e]),d.useEffect(()=>{n.current&&n.current.load()},[r]),d.useEffect(()=>{u(typeof HTMLVideoElement<"u"&&"webkitShowPlaybackTargetPicker"in HTMLVideoElement.prototype)},[]),d.useEffect(()=>{var h;const g=v=>{if(v)try{cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a(!0)}catch{}};if((h=window.cast)!=null&&h.framework)g(!0);else if(window.__onGCastApiAvailable=g,!document.querySelector('script[src*="cast_sender"]')){const v=document.createElement("script");v.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(v)}},[]),d.useEffect(()=>{if(!i||!r)return;const g=cast.framework.CastContext.getInstance(),{CastContextEventType:h,SessionState:v}=cast.framework,x=N=>{if(!N)return;const p=new chrome.cast.media.MediaInfo(window.location.origin+r,t);N.loadMedia(new chrome.cast.media.LoadRequest(p)).catch(()=>{})};x(g.getCurrentSession());const S=N=>{(N.sessionState===v.SESSION_STARTED||N.sessionState===v.SESSION_RESUMED)&&x(g.getCurrentSession())};return g.addEventListener(h.SESSION_STATE_CHANGED,S),()=>g.removeEventListener(h.SESSION_STATE_CHANGED,S)},[i,r,t]);const c=()=>{var g,h;(h=(g=n.current)==null?void 0:g.webkitShowPlaybackTargetPicker)==null||h.call(g)},y=i||o;return s.jsx("div",{className:"preview-video-wrap",style:{position:"relative"},children:e?s.jsxs(s.Fragment,{children:[r?s.jsxs("video",{ref:n,controls:!0,autoPlay:!1,playsInline:!0,"x-webkit-airplay":"allow",style:{width:"100%",maxHeight:"100%",display:"block"},children:[s.jsx("source",{src:r}),"Your browser does not support the video element."]}):s.jsx("div",{className:"video-tv-loading","aria-label":"Loading video…"}),y&&r&&s.jsxs("div",{className:"video-tv-controls",children:[o&&s.jsx("button",{className:"video-tv-btn",title:"AirPlay to device","aria-label":"AirPlay to device",onClick:c,children:s.jsx(ag,{})}),i&&s.jsx("google-cast-launcher",{className:"video-tv-btn",title:"Cast to TV"})]})]}):s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function Lu({src:e,type:t,title:n,originalUrl:r}){const l=r||e,i=n||null;return s.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[s.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:[i&&s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),s.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 β†—"})]})]}),s.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:i||(t==="pdf"?"PDF preview":"Page preview")})]})}function ug({src:e,alt:t}){return s.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:s.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:s.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function tf(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function Ru(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const G={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"}},$e={bg:"#000000",border:"#2f3336",text:"#e7e9ea",dim:"#71767b",accent:"#1d9bf0",codeBg:"#16181c"},gi={article:{background:$e.bg,color:$e.text,minHeight:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'},articleInner:{maxWidth:"598px",margin:"0 auto",paddingBottom:"80px"},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"420px"},aMeta:{padding:"20px 16px 0"},aTweetTitle:{fontSize:"34px",fontWeight:"800",letterSpacing:"-0.5px",color:$e.text,lineHeight:"44px",marginBottom:"16px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},aAvatar:{width:"40px",height:"40px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"40px",height:"40px",borderRadius:"50%",background:$e.border,flexShrink:0},aAuthorName:{fontSize:"15px",fontWeight:"700",color:$e.text,lineHeight:"1.3"},aAuthorSub:{fontSize:"15px",color:$e.dim,lineHeight:"1.3"},aDivider:{border:"none",borderTop:`1px solid ${$e.border}`,margin:"0"},aBody:{padding:"4px 16px 0"},bH1:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:$e.text,lineHeight:"36px",margin:"24px 0 10px"},bH2:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:$e.text,lineHeight:"36px",margin:"24px 0 10px"},bP:{fontSize:"17px",color:$e.text,lineHeight:"1.5",marginBottom:"16px",marginTop:"0"},bSpacer:{height:"6px",display:"block"},bQuote:{borderLeft:`3px solid ${$e.border}`,padding:"2px 14px",margin:"14px 0",color:$e.dim,fontSize:"17px",lineHeight:"1.5"},bHr:{border:"none",borderTop:`1px solid ${$e.border}`,margin:"28px 0"},bImg:{width:"100%",display:"block",borderRadius:"12px",margin:"16px 0"},bUl:{margin:"10px 0 16px",paddingLeft:"28px"},bOl:{margin:"10px 0 16px",paddingLeft:"28px"},bLi:{fontSize:"17px",color:$e.text,lineHeight:"1.5",marginBottom:"6px"},bTweet:{display:"flex",alignItems:"center",gap:"12px",border:`1px solid ${$e.border}`,borderRadius:"12px",padding:"14px 16px",margin:"14px 0",color:$e.dim,fontSize:"15px",textDecoration:"none"},bMdPre:{borderRadius:"12px",margin:"12px 0",overflow:"auto",background:"#1e2029"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"13px",lineHeight:"1.65",padding:"18px 20px",display:"block",color:$e.text,background:"transparent"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:$e.codeBg,padding:"2px 6px",borderRadius:"4px",color:"#e6edf3"},link:{color:$e.accent,textDecoration:"none"}};function cg(e,t,n){const r={};return n&&n.forEach((l,i)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${i}`)}),r}function ur(e,t,n){return e&&n[e]?n[e]:t||null}function nf(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:s.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 oo(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 i=t.indexOf(l);if(i!==-1)return{s:i,e:i+l.length}}return null}function rf(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=oo(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function lf(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=oo(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const zu=/https?:\/\/[^\s<>"'\]οΌ‰]+/g,dg=/[.,;:!?)οΌˆοΌ‰]+$/;function ws(e,t){const n=[];let r=0,l;for(zu.lastIndex=0;(l=zu.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let i=l[0].replace(dg,"");n.push(s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:t,children:i},l.index));const a=l[0].slice(i.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(rrf(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>lf(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return ws(Ru(e),G.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 i=(o,u)=>n.some(([c,y])=>c<=o&&y>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1];if(i(o,c))return null;const y=e.slice(o,c),g=r.filter(x=>x.s<=o&&x.e>=c),h=g.find(x=>x.kind==="url");if(h)return s.jsx("a",{href:h.href,target:"_blank",rel:"noopener noreferrer",style:G.link,children:h.display||y},u);const v=g.find(x=>x.kind==="mention");return v?s.jsx("a",{href:`https://x.com/${v.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:G.link,children:y},u):s.jsx("span",{children:ws(Ru(y),G.link)},u)}).filter(o=>o!==null)}function pg(e,t,n,r,l=G){if(!e)return null;t=t||[],n=n||[],r=r||[];const i=[];for(const u of t)u.length>0&&i.push({s:u.offset,e:u.offset+u.length,kind:"style",style:u.style});for(const u of n){const c=rf(u,e);c&&i.push(c)}for(const u of r){const c=lf(u,e);c&&i.push(c)}if(i.length===0)return ws(e,l.link);const a=new Set([0,e.length]);for(const u of i)u.s>=0&&u.s<=e.length&&a.add(u.s),u.e>=0&&u.e<=e.length&&a.add(u.e);const o=[...a].sort((u,c)=>u-c);return o.slice(0,-1).map((u,c)=>{const y=o[c+1],g=i.filter(N=>N.s<=u&&N.e>=y),h=e.slice(u,y);let v;if(h.includes(` `)){const N=h.split(` -`);v=N.flatMap((p,f)=>fN.kind==="style"&&N.style==="Code")&&(v=s.jsx("code",{style:l.iCode,children:v})),g.some(N=>N.kind==="style"&&N.style==="Bold")&&(v=s.jsx("strong",{children:v})),g.some(N=>N.kind==="style"&&N.style==="Italic")&&(v=s.jsx("em",{children:v})),g.some(N=>N.kind==="style"&&N.style==="Underline")&&(v=s.jsx("u",{children:v})),g.some(N=>N.kind==="style"&&N.style==="Strikethrough")&&(v=s.jsx("s",{children:v}));const x=g.find(N=>N.kind==="url");if(x){const N=/^https?:\/\/t\.co\//i.test(v);v=s.jsx("a",{href:x.href,target:"_blank",rel:"noopener noreferrer",style:l.link,children:N?x.display:v})}const S=g.find(N=>N.kind==="mention");return S&&(v=s.jsx("a",{href:`https://x.com/${S.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:l.link,children:v})),s.jsx("span",{children:typeof v=="string"?ws(v,l.link):v},c)})}function hg(e,t,n){const r=(n==null?void 0:n.st)||G,l=e.resolved_entities||[];return l.length===0?null:l.map((i,a)=>{var o;switch(i.type){case"divider":return s.jsx("hr",{style:r.bHr},a);case"media":{const u=ur(i.local_path,i.url,t);return u?s.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:c=>{var y;!c.metaKey&&!c.ctrlKey&&(c.preventDefault(),(y=n==null?void 0:n.onImgClick)==null||y.call(n,u))},children:s.jsx("img",{src:u,style:r.bImg,loading:"lazy",alt:""})},a):null}case"tweet":return i.tweet_id?s.jsxs("a",{href:`https://x.com/i/status/${i.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:r.bTweet,children:[s.jsx(nf,{}),"View post on X"]},a):null;case"link":return i.url?s.jsx("p",{style:r.bP,children:s.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",style:r.link,children:i.url})},a):null;case"markdown":{const u=i.markdown??((o=i.data)==null?void 0:o.markdown)??"";return s.jsx("pre",{style:r.bMdPre,children:s.jsx("code",{style:r.bMdCode,children:u})},a)}case"emoji":return i.url?s.jsx("img",{src:i.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},a):null;default:return null}})}function yi(e,t,n,r){const l=(r==null?void 0:r.st)||G,i=e.type||"",a=e.text||"",o=e.inline_style_ranges||[],u=e.data||{},c=pg(a,o,u.urls||[],u.mentions||[],l);switch(i){case"header-one":return s.jsx("h1",{style:l.bH1,children:c},t);case"header-two":{const y=a.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return y?s.jsxs("a",{href:`https://x.com/i/status/${y[1]}`,target:"_blank",rel:"noopener noreferrer",style:l.bTweet,children:[s.jsx(nf,{}),"View post on X"]},t):s.jsx("h2",{style:l.bH2,children:c},t)}case"unstyled":return a.trim()?s.jsx("p",{style:l.bP,children:c},t):s.jsx("span",{style:l.bSpacer},t);case"blockquote":return s.jsx("blockquote",{style:l.bQuote,children:c},t);case"unordered-list-item":case"ordered-list-item":return s.jsx("li",{style:l.bLi,children:c},t);case"atomic":return s.jsx("span",{children:hg(e,n,r)},t);default:return a?s.jsx("p",{style:l.bP,children:c},t):null}}function mg(e,t,n){const r=(n==null?void 0:n.st)||G,l=[];let i=0;for(;i{r&&(l==null||l(!0))},[r,l]);const o=r?gi:G,u=e.cover_media||{},c=e.author||t||{},y=e.first_published_at_secs?tf(e.first_published_at_secs):"",h=[c.screen_name?`@${c.screen_name}`:"",y].filter(Boolean).join(" Β· "),v=ur(u.local_path,u.url,n),x=ur(c.avatar_local_path,c.avatar_url,n),S=s.jsxs(s.Fragment,{children:[i&&s.jsx(sf,{items:[{src:i,alt:""}],startIndex:0,onClose:()=>a(null)}),v&&s.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:N=>{!N.metaKey&&!N.ctrlKey&&(N.preventDefault(),a(v))},children:s.jsx("img",{src:v,style:o.aCover,alt:"Article cover"})}),s.jsxs("div",{style:o.aMeta,children:[e.title&&s.jsx("div",{style:o.aTweetTitle,children:e.title}),s.jsxs("div",{style:o.aAuthorRow,children:[x?s.jsx("img",{src:x,style:o.aAvatar,alt:c.name||""}):s.jsx("div",{style:o.aAvatarPh}),s.jsxs("div",{children:[s.jsx("div",{style:o.aAuthorName,children:c.name||c.screen_name||"Unknown"}),h&&s.jsx("div",{style:o.aAuthorSub,children:h})]})]})]}),s.jsx("hr",{style:o.aDivider}),s.jsx("div",{style:o.aBody,children:mg(e.blocks||[],n,{onImgClick:a,st:o})})]});return r?s.jsx("div",{style:gi.article,children:s.jsx("div",{style:gi.articleInner,children:S})}):s.jsx("div",{style:G.article,children:S})}function yg({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return s.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:s.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:G.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,i)=>s.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&i===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(i))},children:s.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},i))})}function sf({items:e,startIndex:t,onClose:n}){const[r,l]=d.useState(t);d.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 i=e[r];return s.jsx("div",{style:G.lightboxBackdrop,onClick:n,children:s.jsxs("div",{style:G.lightboxContent,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{style:G.lightboxToolbar,children:[e.length>1&&s.jsxs("span",{style:G.lightboxCounter,children:[r+1," / ",e.length]}),s.jsx("a",{href:i.src,target:"_blank",rel:"noopener noreferrer",style:G.lightboxLink,title:"Open in new tab",children:"β†—"}),s.jsx("button",{style:G.lightboxBtn,onClick:n,"aria-label":"Close",children:"Γ—"})]}),s.jsx("img",{src:i.src,alt:i.alt||"",style:G.lightboxImg}),e.length>1&&s.jsxs("div",{style:G.lightboxNav,children:[s.jsx("button",{style:G.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"β€Ή"}),s.jsx("button",{style:G.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"β€Ί"})]})]})})}function Iu({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var f,m;const[l,i]=d.useState(null),a=e.author||{},o=e.created_at_secs?tf(e.created_at_secs):"",u=e.entities||{},c=ur(a.avatar_local_path,a.avatar_url,r),y=t&&!n,g=e.is_quote_status===!0,h=t?G.tweetRowThread:G.tweetRow,v=e.full_text||"",x=((m=(f=e.extended_entities)==null?void 0:f.media)!=null&&m.length?e.extended_entities.media:u.media)||[],S=[],N=[];for(const k of x)if(k.type==="photo"){const _=ur(k.local_path,k.media_url_https,r);_&&S.push({kind:"photo",src:_,alt:k.alt_text||""})}else if(k.type==="video"||k.type==="animated_gif"){const _=k.local_path&&r[k.local_path]||(()=>{var b,j;return(j=(((b=k.video_info)==null?void 0:b.variants)||[]).filter(T=>T.content_type==="video/mp4").sort((T,L)=>(L.bitrate||0)-(T.bitrate||0))[0])==null?void 0:j.url})();_&&N.push({kind:k.type==="animated_gif"?"gif":"video",src:_})}const p=[];for(const k of x){if(!k.url||!(k.type==="photo"?S.some(b=>b.src===ur(k.local_path,k.media_url_https,r)):N.length>0))continue;const E=oo(k,v,k.url);E&&p.push([E.s,E.e])}return s.jsxs(s.Fragment,{children:[l!==null&&s.jsx(sf,{items:S,startIndex:l,onClose:()=>i(null)}),s.jsxs("div",{style:h,children:[s.jsxs("div",{style:G.leftCol,children:[c?s.jsx("img",{src:c,style:G.avatar,alt:a.name||""}):s.jsx("div",{style:G.avatarPh}),y&&s.jsx("div",{style:G.threadLine})]}),s.jsxs("div",{style:G.rightCol,children:[s.jsxs("div",{style:G.authorRow,children:[s.jsx("span",{style:G.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&s.jsxs("span",{style:G.authorHandle,children:["@",a.screen_name]}),o&&s.jsxs("span",{style:G.datePart,children:["Β· ",o]}),g&&s.jsx("span",{style:G.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),s.jsx("div",{style:G.tweetText,children:fg(v,u,p)}),S.length>0&&s.jsx("div",{style:G.mediaGrid,children:s.jsx(yg,{photos:S,onOpen:k=>i(k)})}),N.map((k,_)=>s.jsx("div",{style:G.mediaGrid,children:s.jsx("video",{src:k.src,style:G.mediaVideo,controls:!0,loop:k.kind==="gif",muted:k.kind==="gif",autoPlay:k.kind==="gif"})},_)),(e.retweet_count>0||e.favorite_count>0)&&s.jsxs("div",{style:G.stats,children:[e.favorite_count>0&&s.jsxs("span",{children:["❀️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&s.jsxs("span",{children:["πŸ” ",e.retweet_count.toLocaleString()]})]})]})]})]})}function vg({archiveId:e,entryUid:t,artifacts:n,entityKind:r,fullPage:l,onXArticle:i}){const[a,o]=d.useState(!0),[u,c]=d.useState(null),[y,g]=d.useState([]);if(d.useEffect(()=>{if(o(!0),c(null),g([]),!n||!e||!t){o(!1);return}const x=n.map((N,p)=>({...N,index:p})).filter(N=>N.artifact_role==="raw_tweet_json");if(x.length===0){c("No tweet data found."),o(!1);return}let S=!1;return Ah(e,t,x.map(N=>N.index)).then(async N=>{if(S)return;const p=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,f=b=>{var T;const j=b.full_text||"";return(((T=b.entities)==null?void 0:T.urls)||[]).map(L=>{var K;if(L.fromIndex!=null&&L.toIndex!=null)return[L.fromIndex,L.toIndex];if(((K=L.indices)==null?void 0:K.length)===2)return[L.indices[0],L.indices[1]];if(L.url){const U=j.indexOf(L.url);if(U!==-1)return[U,U+L.url.length]}return null}).filter(Boolean)},m=(b,j,T)=>b.some(([L,K])=>L<=j&&K>=T),k=new Set;for(const b of N){const j=b.full_text||"",T=f(b);let L;for(p.lastIndex=0;(L=p.exec(j))!==null;)m(T,L.index,L.index+L[0].length)||k.add(L[0])}const _=k.size>0?await Mh([...k]).catch(()=>({})):{},E=N.map(b=>{var U;const j=b.full_text||"",T=f(b),L=[];let K;for(p.lastIndex=0;(K=p.exec(j))!==null;){const X=K[0],Z=_[X];Z&&Z!==X&&!m(T,K.index,K.index+X.length)&&L.push({url:X,expanded_url:Z,display_url:(()=>{try{const oe=new URL(Z);return oe.hostname+(oe.pathname.length>1?"/…":"")}catch{return Z}})(),fromIndex:K.index,toIndex:K.index+X.length})}return L.length===0?b:{...b,entities:{...b.entities||{},urls:[...((U=b.entities)==null?void 0:U.urls)||[],...L]}}});S||g(E)}).catch(N=>{S||c(N.message||"Failed to load tweet.")}).finally(()=>{S||o(!1)}),()=>{S=!0}},[e,t,n]),a)return s.jsx("div",{style:G.loading,children:"Loading…"});if(u)return s.jsxs("div",{style:G.error,children:["Error: ",u]});if(y.length===0)return null;const h=cg(e,t,n);if(r==="tweet_thread")return s.jsx("div",{style:G.threadOuter,children:y.map((x,S)=>s.jsx(Iu,{tweet:x,isInThread:!0,isLast:S===y.length-1,artifactMap:h},x.id||S))});const v=y[0];return v.is_article&&v.article?s.jsx(gg,{article:v.article,tweetAuthor:v.author,artifactMap:h,fullPage:l,onXArticle:i}):s.jsx("div",{style:G.card,children:s.jsx(Iu,{tweet:v,isInThread:!1,isLast:!0,artifactMap:h})})}const xg=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),wg=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),kg=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]),jg={mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",mkv:"video/x-matroska",avi:"video/x-msvideo",m4v:"video/mp4",ogv:"video/ogg"};function af({archiveId:e,entry:t,detail:n,fullPage:r,onXArticle:l}){if(!t)return s.jsx("div",{className:"preview-panel preview-panel--empty",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return s.jsx("div",{className:"preview-panel preview-panel--loading",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:i,artifacts:a}=n,o=i.entry_uid,u=i.entity_kind;if(u==="tweet"||u==="tweet_thread"){const v=s.jsx(vg,{archiveId:e,entryUid:o,artifacts:a,entityKind:u,fullPage:r,onXArticle:l});return r?v:s.jsx("div",{className:"preview-tweet-wrap",children:v})}const c=a.findIndex(v=>v.artifact_role==="primary_media");if(c===-1)return s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),a.length>0&&s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((v,x)=>s.jsxs("li",{children:[v.artifact_role,": ",v.relpath]},x))})]});const y=a[c],g=`/api/archives/${e}/entries/${o}/artifacts/${c}`,h=y.relpath.split(".").pop().toLowerCase();return xg.has(h)?s.jsx("div",{className:"preview-panel",children:s.jsx(og,{src:g,contentType:jg[h]||"video/mp4"})}):wg.has(h)?s.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:[s.jsx("span",{style:{fontSize:"2rem"},children:"🎡"}),s.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:i.title||o}),s.jsx("audio",{src:g,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):h==="pdf"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(Lu,{src:g,type:"pdf",title:i.title,originalUrl:i.original_url})}):h==="html"||h==="htm"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(Lu,{src:g,type:"page",title:i.title,originalUrl:i.original_url})}):kg.has(h)?s.jsx("div",{className:"preview-panel",style:{height:"100%"},children:s.jsx(ug,{src:g,alt:i.title||"Image"})}):s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((v,x)=>s.jsxs("li",{children:[v.artifact_role,": ",v.relpath]},x))})]})}function Sg({archiveId:e,entry:t,detail:n,onClose:r}){var l,i;return d.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:s.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((i=n==null?void 0:n.summary)==null?void 0:i.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"preview-modal-header",children:[s.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),s.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:"β†—"}),s.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"Γ—"})]}),s.jsx("div",{className:"preview-modal-body",children:s.jsx(af,{archiveId:e,entry:t,detail:n})})]})})}function $u(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 Ng({entry:e,src:t,archiveId:n,onClose:r}){const l=d.useRef(null),[i,a]=d.useState(!1),[o,u]=d.useState(0),[c,y]=d.useState(NaN),[g,h]=d.useState(1);d.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),y(NaN),a(!1))},[t]),d.useEffect(()=>{l.current&&(l.current.volume=g)},[g]);function v(){const f=l.current;f&&(i?f.pause():f.play().catch(()=>{}))}function x(f){const m=l.current;if(!m||!isFinite(c))return;const k=Number(f.target.value);m.currentTime=k,u(k)}function S(f){h(Number(f.target.value))}const N=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",p=(e==null?void 0:e.source_kind)||"other";return s.jsxs(s.Fragment,{children:[s.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 y(((f=l.current)==null?void 0:f.duration)??NaN)},onDurationChange:()=>{var f;return y(((f=l.current)==null?void 0:f.duration)??NaN)},style:{display:"none"}}),s.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:[s.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[s.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:Os(p)}}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:N,children:N})]}),s.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[s.jsx("button",{onClick:v,"aria-label":i?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:i?"⏸":"β–Ά"}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:$u(o)}),s.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:x,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:$u(c)})]}),s.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[s.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"πŸ”Š"}),s.jsx("input",{type:"range",min:0,max:1,step:.01,value:g,onChange:S,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),s.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 _g({archiveId:e,entryUid:t}){var h,v;const[n,r]=d.useState(null),[l,i]=d.useState(!0),[a,o]=d.useState(null),[u,c]=d.useState(!1);d.useEffect(()=>{if(!u)return;const x=document.documentElement,S=document.body,N=x.style.colorScheme,p=S.style.background;return x.style.colorScheme="dark",S.style.background="#000",()=>{x.style.colorScheme=N,S.style.background=p}},[u]),d.useEffect(()=>{c(!1),Dr(e,t).then(x=>{r(x),i(!1)}).catch(x=>{o((x==null?void 0:x.message)||"Failed to load entry"),i(!1)})},[e,t]);const y=((h=n==null?void 0:n.summary)==null?void 0:h.title)||t,g=(v=n==null?void 0:n.summary)==null?void 0:v.original_url;return s.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:u?"#000":"var(--paper)",fontFamily:"var(--sans)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:u?"8px 12px":"10px 16px",borderBottom:u?"none":"1px solid var(--line)",flexShrink:0,position:u?"sticky":"relative",top:0,zIndex:20,background:u?"rgba(0,0,0,0.82)":"var(--paper-2)",backdropFilter:u?"blur(12px)":"none",WebkitBackdropFilter:u?"blur(12px)":"none"},children:[s.jsx("a",{href:"/",style:{color:u?"#1d9bf0":"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),s.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:u?"#e7e9ea":"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),g&&s.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:u?"#71767b":"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original β†—"})]}),s.jsxs("div",{style:u?{flex:1}:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&s.jsx(af,{archiveId:e,entry:n.summary,detail:n,fullPage:!0,onXArticle:c})]})]})}const Cg=7e3;function Eg({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?s.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>s.jsx(Tg,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function bg(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),i=(l[l.length-1]??"")+r,a=i?`${t}/…/${i}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function Tg({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=d.useState(!1),i=e.type==="warning",a=e.type==="success";d.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Cg);return()=>clearTimeout(u)},[r,e.id,t]);const o=bg(e.locator);return a?s.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"βœ“"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsx("div",{className:"toast-btns",children:s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"Γ—"})})]})}):i?s.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&s.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"Γ—"})]})]}),r&&s.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."})]}):s.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"βœ•"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"Γ—"})]})]}),r&&e.text&&s.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const As=d.createContext(null),Pg=["archive","tags","collections","runs","admin","settings"],Lg=["profile","tokens","instance","cookies","extensions","storage"],Lr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})();function Mt(){const e=window.location.pathname.split("/").filter(Boolean),t=Pg.includes(e[0])?e[0]:"archive",n=t==="settings"&&Lg.includes(e[1])?e[1]:"profile",r=new URLSearchParams(window.location.search),l=r.get("q")??"",i=t==="archive"?r.get("tag")??null:null,a=t==="archive"?r.get("entry")??null:null,o=t==="archive"?r.get("collection")??null:null,u=o==="main"?null:o,c=r.get("archive")??null;return{view:t,settingsTab:n,q:l,tag:i,entry:a,collection:u,archive:c}}function Rg(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function zg(){const[e,t]=d.useState("loading"),[n,r]=d.useState(null);d.useEffect(()=>{(async()=>{var O,Q,J;if(await Jh()){t("setup");return}const $=await em();if(!$){const{collection:se,archive:Te}=Mt();try{const Ke=await ju(),Ne=Te?((O=Ke.find(Ms=>Ms.id===Te))==null?void 0:O.id)??((Q=Ke[0])==null?void 0:Q.id):(J=Ke[0])==null?void 0:J.id;if(Ne){await Su(Ne,se),i(Ke),o(Ne),c(se),t("authenticated");return}}catch{}t("login");return}r($),t("authenticated")})()},[]),d.useEffect(()=>{const C=()=>{n&&(r(null),t("login"))};return window.addEventListener("auth:expired",C),()=>window.removeEventListener("auth:expired",C)},[n]),d.useEffect(()=>{const C=()=>{const{view:$,settingsTab:O,q:Q,tag:J,entry:se,collection:Te}=Mt();T($),K(O),X(Q),b(J),p(se),m(null),_(se?new Set([se]):new Set),c(Te)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[]);const[l,i]=d.useState([]),[a,o]=d.useState(null),[u,c]=d.useState(()=>Mt().collection),[y,g]=d.useState([]),[h,v]=d.useState([]),[x,S]=d.useState(()=>new Set),[N,p]=d.useState(()=>Mt().entry),[f,m]=d.useState(null),[k,_]=d.useState(()=>{const C=Mt().entry;return C?new Set([C]):new Set}),[E,b]=d.useState(()=>Mt().tag),[j,T]=d.useState(()=>Mt().view),[L,K]=d.useState(()=>Mt().settingsTab),[U,X]=d.useState(()=>Mt().q),[Z,oe]=d.useState(""),[Ae,ye]=d.useState(!1),[D,P]=d.useState([]),[V,te]=d.useState([]),[ee,Re]=d.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[Y,he]=d.useState([]),ue=d.useRef(0),[Ee,Qe]=d.useState(()=>{try{const C=JSON.parse(sessionStorage.getItem("pendingCaptures")||"[]");if(Array.isArray(C))return C}catch{}return[]});d.useEffect(()=>{sessionStorage.setItem("pendingCaptures",JSON.stringify(Ee))},[Ee]);const[Et,ut]=d.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[Wt,ct]=d.useState(null),rt=d.useRef(0),xt=d.useRef(null),bt=d.useRef(!1),A=d.useRef(!0),q=d.useRef(null),de=d.useRef(0),Be=d.useRef(new Map),Dt=(n==null?void 0:n.humanize_slugs)??!1;d.useEffect(()=>{const C=++rt.current;ct(null),!(!f||!a)&&Dr(a,f.entry_uid).then($=>{C===rt.current&&ct($)}).catch(()=>{})},[f,a]),d.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",ee)},[ee]);const ze=d.useCallback(async(C,$,O,Q)=>{if(C){ye(!0);try{let J;$||O?J=await Dh(C,$,O,Q):J=await Su(C,Q),v(J),_(se=>{if(se.size<2)return se;const Te=new Set(J.map(Ne=>Ne.entry_uid)),Ke=new Set([...se].filter(Ne=>Te.has(Ne)));return Ke.size===se.size?se:Ke}),oe(J.length===0?"No results":`${J.length} result${J.length===1?"":"s"}`)}catch{v([]),oe("Search failed. Try again.")}finally{ye(!1)}}},[]);d.useEffect(()=>{e==="authenticated"&&(a||ju().then(C=>{if(i(C),C.length>0){const{archive:$}=Mt(),O=$?C.find(Q=>Q.id===$):null;o((O==null?void 0:O.id)??C[0].id)}}))},[e,a]),d.useEffect(()=>{if(!a)return;const C=!n;if(A.current){A.current=!1;const O=[];C||(O.push(fi(a).then(P)),O.push(Dl(a).then(te))),O.length&&Promise.all(O);return}b(null),m(null),p(null),_(new Set),c(null);const $=[ze(a,"",null,null)];C||($.push(fi(a).then(P)),$.push(Dl(a).then(te))),Promise.all($)},[a,n]),d.useEffect(()=>{if(a===null)return;const C=setTimeout(()=>{ze(a,U,E,u)},300);return()=>clearTimeout(C)},[U,a,u]),d.useEffect(()=>{a!==null&&(E!==null&&T("archive"),ze(a,U,E,u))},[E,a,u]);const Bn=d.useCallback(C=>{o(C),c(null);const $=new URLSearchParams(window.location.search);$.set("archive",C),$.delete("collection");const O=$.toString();history.replaceState(null,"",window.location.pathname+(O?"?"+O:""))},[]);d.useEffect(()=>{if(!a){g([]);return}io(a).then(g).catch(()=>g([]))},[a]);const _n=d.useCallback(C=>{if(!n){const Q=C?y.find(J=>J.collection_uid===C):y.find(J=>J.slug==="_default_");if(Q!=null&&Q.requires_auth){t("login");return}}c(C),m(null),p(null),_(new Set),ze(a,U,E,C);const $=new URLSearchParams(window.location.search);C?($.set("collection",C),$.set("archive",a)):($.delete("collection"),a&&$.set("archive",a));const O=$.toString();history.replaceState(null,"",window.location.pathname+(O?"?"+O:""))},[a,U,E,n,y,ze]),nn=d.useCallback(C=>{T(C),C==="tags"&&a&&Dl(a).then(te)},[a]);d.useEffect(()=>{if(Lr)return;const C=Rg(j,L);window.location.pathname!==C&&history.pushState(null,"",C+window.location.search)},[j,L]);const qe=d.useCallback(C=>{p(C?C.entry_uid:null),m(C)},[]),wr=d.useCallback((C,$)=>{if(Be.current.set(C.entry_uid,C),++de.current,$.shiftKey&&q.current!==null){$.preventDefault();const O=[...document.querySelectorAll("#entries-body [data-entry-uid]")],Q=O.findIndex(Ne=>Ne.dataset.entryUid===q.current),J=O.findIndex(Ne=>Ne.dataset.entryUid===C.entry_uid);if(Q===-1||J===-1){q.current=C.entry_uid,_(new Set([C.entry_uid])),qe(C);return}const se=Math.min(Q,J),Te=Math.max(Q,J),Ke=new Set(O.slice(se,Te+1).map(Ne=>Ne.dataset.entryUid));_(Ke),Ke.size===1&&qe(C)}else if($.ctrlKey||$.metaKey){q.current=C.entry_uid;const O=new Set(k);if(O.has(C.entry_uid)?O.delete(C.entry_uid):O.add(C.entry_uid),_(O),O.size===0)qe(null);else if(O.size===1){const[Q]=O,J=Be.current.get(Q)??h.find(se=>se.entry_uid===Q)??null;if(J)qe(J);else{const se=++de.current;Dr(a,Q).then(Te=>{se===de.current&&(Te!=null&&Te.summary)&&qe(Te.summary)}).catch(()=>{})}}else qe(null)}else q.current=C.entry_uid,_(new Set([C.entry_uid])),qe(C)},[h,k,qe,a]),Un=d.useCallback(C=>{b(C)},[]),w=d.useCallback(()=>{b(null)},[]),B=d.useCallback(()=>{a&&Dl(a).then(te)},[a]),M=d.useCallback((C,$)=>{E===C?b($):E!=null&&E.startsWith(C+"/")&&b($+E.slice(C.length))},[E]),I=d.useCallback(C=>{(E===C||E!=null&&E.startsWith(C+"/"))&&b(null)},[E]),F=d.useCallback((C,$)=>{v(O=>O.map(Q=>Q.entry_uid===C?{...Q,title:$}:Q)),m(O=>O&&O.entry_uid===C?{...O,title:$}:O),ct(O=>O&&O.summary.entry_uid===C?{...O,summary:{...O.summary,title:$}}:O)},[]),H=d.useCallback(()=>{if(!a||!f)return;const C=++rt.current;Dr(a,f.entry_uid).then($=>{C===rt.current&&ct($)}).catch(()=>{})},[a,f]),xe=d.useCallback(C=>{const $=h.some(O=>O.entry_uid===C);S(O=>{const Q=new Set(O);return Q.add(C),Q}),v(O=>O.filter(Q=>Q.entry_uid!==C)),m(O=>(O==null?void 0:O.entry_uid)===C?null:O),p(O=>O===C?null:O),_(O=>{const Q=new Set(O);return Q.delete(C),Q}),$||ze(a,U,E,u)},[h,a,U,E,u,ze]),fe=d.useCallback(C=>{const $=new Set(h.map(Q=>Q.entry_uid)),O=[...C].some(Q=>!$.has(Q));S(Q=>{const J=new Set(Q);return C.forEach(se=>J.add(se)),J}),v(Q=>Q.filter(J=>!C.has(J.entry_uid))),_(new Set),m(null),p(null),O&&ze(a,U,E,u)},[h,a,U,E,u,ze]);d.useEffect(()=>{if(k.size>=2)p(null),m(null);else if(k.size===1){const[C]=k;p(C)}else p(null),m(null)},[k]);const we=d.useMemo(()=>h.filter(C=>k.has(C.entry_uid)),[h,k]);d.useEffect(()=>{if(!N||f)return;const C=h.find($=>$.entry_uid===N);C&&m(C)},[h,N,f]),d.useEffect(()=>{if(Lr)return;const C=new URLSearchParams(window.location.search).get("archive"),$=new URLSearchParams;U&&$.set("q",U),j==="archive"&&E&&$.set("tag",E),j==="archive"&&N&&$.set("entry",N),j==="archive"&&u?($.set("collection",u),a&&$.set("archive",a)):C&&a&&$.set("archive",a);const O=$.toString(),Q=window.location.pathname+(O?"?"+O:"");window.location.pathname+window.location.search!==Q&&history.replaceState(null,"",Q)},[U,E,N,u,a,j]),d.useEffect(()=>{const C=$=>{var se,Te,Ke,Ne;const O=$.key==="/"&&!$.metaKey&&!$.ctrlKey&&!$.altKey,Q=($.metaKey||$.ctrlKey)&&$.key==="k";if(!O&&!Q)return;const J=(se=document.activeElement)==null?void 0:se.tagName;O&&(J==="INPUT"||J==="TEXTAREA"||J==="SELECT")||O&&((Te=document.activeElement)!=null&&Te.isContentEditable)||($.preventDefault(),j==="archive"?((Ke=xt.current)==null||Ke.focus(),(Ne=xt.current)==null||Ne.select()):(bt.current=!0,T("archive")))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[j]),d.useEffect(()=>{const C=$=>{var co,fo;if($.metaKey||$.ctrlKey||$.altKey||$.key!=="j"&&$.key!=="k")return;const O=(co=document.activeElement)==null?void 0:co.tagName;if(O==="INPUT"||O==="TEXTAREA"||O==="SELECT"||(fo=document.activeElement)!=null&&fo.isContentEditable)return;const Q=[...document.querySelectorAll("#entries-body [data-entry-uid]")];if(Q.length===0)return;const[J]=k.size===1?k:[null],se=J?Q.findIndex(rn=>rn.dataset.entryUid===J):-1,Te=$.key==="j"?Math.min(se+1,Q.length-1):Math.max(se-1,0);if(Te===se&&se!==-1)return;const Ke=Q[Te<0?0:Te],Ne=Ke.dataset.entryUid;q.current=Ne;const Ms=++de.current;_(new Set([Ne]));const uo=Be.current.get(Ne)??h.find(rn=>rn.entry_uid===Ne)??null;uo?qe(uo):Dr(a,Ne).then(rn=>{Ms===de.current&&(rn!=null&&rn.summary)&&qe(rn.summary)}).catch(()=>{}),Ke.scrollIntoView({block:"nearest"}),$.preventDefault()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[k,h,qe,a]),d.useEffect(()=>{j==="archive"&&bt.current&&(bt.current=!1,requestAnimationFrame(()=>{var C,$;(C=xt.current)==null||C.focus(),($=xt.current)==null||$.select()}))},[j]);const ce=d.useCallback(()=>{Re(!0)},[]),Ue=d.useCallback(()=>{Re(!1)},[]),le=d.useCallback(()=>{if(a)return Promise.allSettled([ze(a,U,E,u),fi(a).then(P)])},[a,U,E,u,ze]),dt=d.useCallback((C,$,O="error",Q=null)=>{if(O==="warning"&&Et&&$)return;const J=++ue.current;he(se=>[...se,{id:J,text:C,locator:$,type:O,headline:Q}])},[Et]),wt=d.useCallback(C=>{he($=>$.filter(O=>O.id!==C))},[]),yl=d.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),ut(!0),he(C=>C.filter($=>!($.type==="warning"&&$.locator)))},[]),z=d.useCallback(C=>{Qe($=>[...$,C])},[]),re=d.useCallback(C=>{Qe($=>$.filter(O=>O.id!==C))},[]),[be,Ot]=d.useState(null),[Vt,kr]=d.useState(null),Ie=d.useCallback(()=>{f&&Ot(f.entry_uid)},[f]),jr=d.useCallback(()=>Ot(null),[]),of=d.useCallback((C,$)=>{kr({src:C,entry:$})},[]),uf=d.useCallback(()=>kr(null),[]);return d.useEffect(()=>{Ot(null)},[f]),d.useEffect(()=>{const C=$=>{var Q,J,se;if($.key!=="Escape"||ee||be)return;const O=(Q=document.activeElement)==null?void 0:Q.tagName;O==="INPUT"||O==="TEXTAREA"||O==="SELECT"||k.size>0&&($.preventDefault(),_(new Set),(se=(J=document.activeElement)==null?void 0:J.blur)==null||se.call(J))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[ee,be,k]),d.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!Vt),()=>document.body.classList.remove("has-audio-bar")),[Vt]),Lr?s.jsx(_g,{archiveId:Lr.archiveId,entryUid:Lr.entryUid}):e==="loading"?s.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?s.jsx(bm,{onComplete:()=>t("login")}):e==="login"?s.jsx(Em,{onLogin:C=>{r(C),t("authenticated")}}):s.jsx(As.Provider,{value:{currentUser:n,setCurrentUser:r},children:s.jsxs(s.Fragment,{children:[s.jsx(Tm,{archives:l,archiveId:a,onArchiveChange:Bn,view:j,onViewChange:nn,onCaptureClick:ce,collections:y,selectedCollectionUid:u,onCollectionChange:_n,isPublicSession:!n,onSignInClick:()=>t("login")}),s.jsxs("main",{className:"app-shell",children:[s.jsxs("div",{className:"workspace",children:[j==="archive"&&s.jsxs("div",{className:"toolbar",children:[s.jsxs("div",{className:"search-field",children:[s.jsx("span",{className:"ico","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),s.jsx("input",{ref:xt,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":Ae,placeholder:"Search titles, URLs, types, tags…",value:U,onChange:C=>X(C.target.value)}),s.jsx("span",{className:"kbd",children:"⌘K"})]}),s.jsxs("span",{className:"result-count",children:[Z&&s.jsxs(s.Fragment,{children:[s.jsx("b",{children:Z.split(" ")[0]})," ",Z.split(" ").slice(1).join(" ")]}),E&&s.jsxs("button",{className:"tag-filter-badge",onClick:w,children:["Γ— ",Dt?Gd(E):E]})]})]}),j==="archive"&&s.jsx(Bm,{entries:h,selectedUids:k,onRowClick:wr,archiveId:a,pendingCaptures:Ee,deletedUids:x,isPublicSession:!n}),j==="runs"&&s.jsx(Wm,{runs:D}),j==="admin"&&s.jsx(Qm,{archives:l}),j==="tags"&&s.jsx(qm,{archiveId:a,tagNodes:V,tagFilter:E,onTagFilterSet:Un,onViewChange:nn,onTagRenamed:M,onTagDeleted:I,onTagsRefresh:B,humanizeTags:Dt}),j==="collections"&&s.jsx(Xm,{archiveId:a}),j==="settings"&&s.jsx(Gm,{tab:L,onTabChange:K,archiveId:a})]}),s.jsx(sg,{archiveId:a,selectedEntry:f,selectedUids:k,selectedEntries:we,detail:Wt,onTagFilterSet:Un,tagNodes:V,onTagsRefresh:B,onEntryTitleChange:F,onEntryDeleted:xe,onBulkDeleted:fe,humanizeTags:Dt,onDetailRefresh:H,onOpenPreview:Ie,onPlay:of,isPublicSession:!n})]}),be&&f&&f.entry_uid===be&&s.jsx(Sg,{archiveId:a,entry:f,detail:Wt,onClose:jr}),Vt&&s.jsx(Ng,{entry:Vt.entry,src:Vt.src,archiveId:a,onClose:uf}),s.jsx(zm,{open:ee,archiveId:a,onClose:Ue,onCaptured:le,onToast:dt,activeJobs:Ee,onJobStarted:z,onJobSettled:re}),s.jsx(Eg,{toasts:Y,onDismiss:wt,onIgnoreUblock:yl})]})})}Kd(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx(zg,{})})); +`);v=N.flatMap((p,f)=>fN.kind==="style"&&N.style==="Code")&&(v=s.jsx("code",{style:l.iCode,children:v})),g.some(N=>N.kind==="style"&&N.style==="Bold")&&(v=s.jsx("strong",{children:v})),g.some(N=>N.kind==="style"&&N.style==="Italic")&&(v=s.jsx("em",{children:v})),g.some(N=>N.kind==="style"&&N.style==="Underline")&&(v=s.jsx("u",{children:v})),g.some(N=>N.kind==="style"&&N.style==="Strikethrough")&&(v=s.jsx("s",{children:v}));const x=g.find(N=>N.kind==="url");if(x){const N=/^https?:\/\/t\.co\//i.test(v);v=s.jsx("a",{href:x.href,target:"_blank",rel:"noopener noreferrer",style:l.link,children:N?x.display:v})}const S=g.find(N=>N.kind==="mention");return S&&(v=s.jsx("a",{href:`https://x.com/${S.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:l.link,children:v})),s.jsx("span",{children:typeof v=="string"?ws(v,l.link):v},c)})}function hg(e,t,n){const r=(n==null?void 0:n.st)||G,l=e.resolved_entities||[];return l.length===0?null:l.map((i,a)=>{var o;switch(i.type){case"divider":return s.jsx("hr",{style:r.bHr},a);case"media":{const u=ur(i.local_path,i.url,t);return u?s.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:c=>{var y;!c.metaKey&&!c.ctrlKey&&(c.preventDefault(),(y=n==null?void 0:n.onImgClick)==null||y.call(n,u))},children:s.jsx("img",{src:u,style:r.bImg,loading:"lazy",alt:""})},a):null}case"tweet":return i.tweet_id?s.jsxs("a",{href:`https://x.com/i/status/${i.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:r.bTweet,children:[s.jsx(nf,{}),"View post on X"]},a):null;case"link":return i.url?s.jsx("p",{style:r.bP,children:s.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",style:r.link,children:i.url})},a):null;case"markdown":{const u=i.markdown??((o=i.data)==null?void 0:o.markdown)??"";return s.jsx("pre",{style:r.bMdPre,children:s.jsx("code",{style:r.bMdCode,children:u})},a)}case"emoji":return i.url?s.jsx("img",{src:i.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},a):null;default:return null}})}function yi(e,t,n,r){const l=(r==null?void 0:r.st)||G,i=e.type||"",a=e.text||"",o=e.inline_style_ranges||[],u=e.data||{},c=pg(a,o,u.urls||[],u.mentions||[],l);switch(i){case"header-one":return s.jsx("h1",{style:l.bH1,children:c},t);case"header-two":{const y=a.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return y?s.jsxs("a",{href:`https://x.com/i/status/${y[1]}`,target:"_blank",rel:"noopener noreferrer",style:l.bTweet,children:[s.jsx(nf,{}),"View post on X"]},t):s.jsx("h2",{style:l.bH2,children:c},t)}case"unstyled":return a.trim()?s.jsx("p",{style:l.bP,children:c},t):s.jsx("span",{style:l.bSpacer},t);case"blockquote":return s.jsx("blockquote",{style:l.bQuote,children:c},t);case"unordered-list-item":case"ordered-list-item":return s.jsx("li",{style:l.bLi,children:c},t);case"atomic":return s.jsx("span",{children:hg(e,n,r)},t);default:return a?s.jsx("p",{style:l.bP,children:c},t):null}}function mg(e,t,n){const r=(n==null?void 0:n.st)||G,l=[];let i=0;for(;i{r&&(l==null||l(!0))},[r,l]);const o=r?gi:G,u=e.cover_media||{},c=e.author||t||{},y=e.first_published_at_secs?tf(e.first_published_at_secs):"",h=[c.screen_name?`@${c.screen_name}`:"",y].filter(Boolean).join(" Β· "),v=ur(u.local_path,u.url,n),x=ur(c.avatar_local_path,c.avatar_url,n),S=s.jsxs(s.Fragment,{children:[i&&s.jsx(sf,{items:[{src:i,alt:""}],startIndex:0,onClose:()=>a(null)}),v&&s.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:N=>{!N.metaKey&&!N.ctrlKey&&(N.preventDefault(),a(v))},children:s.jsx("img",{src:v,style:o.aCover,alt:"Article cover"})}),s.jsxs("div",{style:o.aMeta,children:[e.title&&s.jsx("div",{style:o.aTweetTitle,children:e.title}),s.jsxs("div",{style:o.aAuthorRow,children:[x?s.jsx("img",{src:x,style:o.aAvatar,alt:c.name||""}):s.jsx("div",{style:o.aAvatarPh}),s.jsxs("div",{children:[s.jsx("div",{style:o.aAuthorName,children:c.name||c.screen_name||"Unknown"}),h&&s.jsx("div",{style:o.aAuthorSub,children:h})]})]})]}),s.jsx("hr",{style:o.aDivider}),s.jsx("div",{style:o.aBody,children:mg(e.blocks||[],n,{onImgClick:a,st:o})})]});return r?s.jsx("div",{style:gi.article,children:s.jsx("div",{style:gi.articleInner,children:S})}):s.jsx("div",{style:G.article,children:S})}function yg({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return s.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:s.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:G.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,i)=>s.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&i===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(i))},children:s.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},i))})}function sf({items:e,startIndex:t,onClose:n}){const[r,l]=d.useState(t);d.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 i=e[r];return s.jsx("div",{style:G.lightboxBackdrop,onClick:n,children:s.jsxs("div",{style:G.lightboxContent,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{style:G.lightboxToolbar,children:[e.length>1&&s.jsxs("span",{style:G.lightboxCounter,children:[r+1," / ",e.length]}),s.jsx("a",{href:i.src,target:"_blank",rel:"noopener noreferrer",style:G.lightboxLink,title:"Open in new tab",children:"β†—"}),s.jsx("button",{style:G.lightboxBtn,onClick:n,"aria-label":"Close",children:"Γ—"})]}),s.jsx("img",{src:i.src,alt:i.alt||"",style:G.lightboxImg}),e.length>1&&s.jsxs("div",{style:G.lightboxNav,children:[s.jsx("button",{style:G.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"β€Ή"}),s.jsx("button",{style:G.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"β€Ί"})]})]})})}function Iu({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var f,m;const[l,i]=d.useState(null),a=e.author||{},o=e.created_at_secs?tf(e.created_at_secs):"",u=e.entities||{},c=ur(a.avatar_local_path,a.avatar_url,r),y=t&&!n,g=e.is_quote_status===!0,h=t?G.tweetRowThread:G.tweetRow,v=e.full_text||"",x=((m=(f=e.extended_entities)==null?void 0:f.media)!=null&&m.length?e.extended_entities.media:u.media)||[],S=[],N=[];for(const k of x)if(k.type==="photo"){const _=ur(k.local_path,k.media_url_https,r);_&&S.push({kind:"photo",src:_,alt:k.alt_text||""})}else if(k.type==="video"||k.type==="animated_gif"){const _=k.local_path&&r[k.local_path]||(()=>{var b,j;return(j=(((b=k.video_info)==null?void 0:b.variants)||[]).filter(T=>T.content_type==="video/mp4").sort((T,L)=>(L.bitrate||0)-(T.bitrate||0))[0])==null?void 0:j.url})();_&&N.push({kind:k.type==="animated_gif"?"gif":"video",src:_})}const p=[];for(const k of x){if(!k.url||!(k.type==="photo"?S.some(b=>b.src===ur(k.local_path,k.media_url_https,r)):N.length>0))continue;const E=oo(k,v,k.url);E&&p.push([E.s,E.e])}return s.jsxs(s.Fragment,{children:[l!==null&&s.jsx(sf,{items:S,startIndex:l,onClose:()=>i(null)}),s.jsxs("div",{style:h,children:[s.jsxs("div",{style:G.leftCol,children:[c?s.jsx("img",{src:c,style:G.avatar,alt:a.name||""}):s.jsx("div",{style:G.avatarPh}),y&&s.jsx("div",{style:G.threadLine})]}),s.jsxs("div",{style:G.rightCol,children:[s.jsxs("div",{style:G.authorRow,children:[s.jsx("span",{style:G.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&s.jsxs("span",{style:G.authorHandle,children:["@",a.screen_name]}),o&&s.jsxs("span",{style:G.datePart,children:["Β· ",o]}),g&&s.jsx("span",{style:G.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),s.jsx("div",{style:G.tweetText,children:fg(v,u,p)}),S.length>0&&s.jsx("div",{style:G.mediaGrid,children:s.jsx(yg,{photos:S,onOpen:k=>i(k)})}),N.map((k,_)=>s.jsx("div",{style:G.mediaGrid,children:s.jsx("video",{src:k.src,style:G.mediaVideo,controls:!0,loop:k.kind==="gif",muted:k.kind==="gif",autoPlay:k.kind==="gif"})},_)),(e.retweet_count>0||e.favorite_count>0)&&s.jsxs("div",{style:G.stats,children:[e.favorite_count>0&&s.jsxs("span",{children:["❀️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&s.jsxs("span",{children:["πŸ” ",e.retweet_count.toLocaleString()]})]})]})]})]})}function vg({archiveId:e,entryUid:t,artifacts:n,entityKind:r,fullPage:l,onXArticle:i}){const[a,o]=d.useState(!0),[u,c]=d.useState(null),[y,g]=d.useState([]);if(d.useEffect(()=>{if(o(!0),c(null),g([]),!n||!e||!t){o(!1);return}const x=n.map((N,p)=>({...N,index:p})).filter(N=>N.artifact_role==="raw_tweet_json");if(x.length===0){c("No tweet data found."),o(!1);return}let S=!1;return Ah(e,t,x.map(N=>N.index)).then(async N=>{if(S)return;const p=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,f=b=>{var T;const j=b.full_text||"";return(((T=b.entities)==null?void 0:T.urls)||[]).map(L=>{var K;if(L.fromIndex!=null&&L.toIndex!=null)return[L.fromIndex,L.toIndex];if(((K=L.indices)==null?void 0:K.length)===2)return[L.indices[0],L.indices[1]];if(L.url){const U=j.indexOf(L.url);if(U!==-1)return[U,U+L.url.length]}return null}).filter(Boolean)},m=(b,j,T)=>b.some(([L,K])=>L<=j&&K>=T),k=new Set;for(const b of N){const j=b.full_text||"",T=f(b);let L;for(p.lastIndex=0;(L=p.exec(j))!==null;)m(T,L.index,L.index+L[0].length)||k.add(L[0])}const _=k.size>0?await Mh([...k]).catch(()=>({})):{},E=N.map(b=>{var U;const j=b.full_text||"",T=f(b),L=[];let K;for(p.lastIndex=0;(K=p.exec(j))!==null;){const X=K[0],Z=_[X];Z&&Z!==X&&!m(T,K.index,K.index+X.length)&&L.push({url:X,expanded_url:Z,display_url:(()=>{try{const oe=new URL(Z);return oe.hostname+(oe.pathname.length>1?"/…":"")}catch{return Z}})(),fromIndex:K.index,toIndex:K.index+X.length})}return L.length===0?b:{...b,entities:{...b.entities||{},urls:[...((U=b.entities)==null?void 0:U.urls)||[],...L]}}});S||g(E)}).catch(N=>{S||c(N.message||"Failed to load tweet.")}).finally(()=>{S||o(!1)}),()=>{S=!0}},[e,t,n]),a)return s.jsx("div",{style:G.loading,children:"Loading…"});if(u)return s.jsxs("div",{style:G.error,children:["Error: ",u]});if(y.length===0)return null;const h=cg(e,t,n);if(r==="tweet_thread")return s.jsx("div",{style:G.threadOuter,children:y.map((x,S)=>s.jsx(Iu,{tweet:x,isInThread:!0,isLast:S===y.length-1,artifactMap:h},x.id||S))});const v=y[0];return v.is_article&&v.article?s.jsx(gg,{article:v.article,tweetAuthor:v.author,artifactMap:h,fullPage:l,onXArticle:i}):s.jsx("div",{style:G.card,children:s.jsx(Iu,{tweet:v,isInThread:!1,isLast:!0,artifactMap:h})})}function xg({src:e,mime:t,title:n}){const[r,l]=d.useState(null),[i,a]=d.useState(null);return d.useEffect(()=>{let o=!1;return l(null),a(null),fetch(e,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);return u.text()}).then(u=>{o||l(u)}).catch(u=>{o||a(u.message||String(u))}),()=>{o=!0}},[e]),i?s.jsxs("div",{className:"text-preview text-preview--error",children:["Failed to load text: ",i]}):r===null?s.jsx("div",{className:"text-preview text-preview--loading",children:"Loading…"}):s.jsxs("div",{className:"text-preview",children:[n&&s.jsx("h1",{className:"text-preview__title",children:n}),s.jsx("pre",{className:"text-preview__body",children:r}),t&&s.jsx("div",{className:"text-preview__mime",children:t})]})}const wg=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),kg=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),jg=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]),Sg=new Set(["md","markdown","txt"]),Ng={mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",mkv:"video/x-matroska",avi:"video/x-msvideo",m4v:"video/mp4",ogv:"video/ogg"};function af({archiveId:e,entry:t,detail:n,fullPage:r,onXArticle:l}){if(!t)return s.jsx("div",{className:"preview-panel preview-panel--empty",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return s.jsx("div",{className:"preview-panel preview-panel--loading",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:i,artifacts:a}=n,o=i.entry_uid,u=i.entity_kind;if(u==="tweet"||u==="tweet_thread"){const v=s.jsx(vg,{archiveId:e,entryUid:o,artifacts:a,entityKind:u,fullPage:r,onXArticle:l});return r?v:s.jsx("div",{className:"preview-tweet-wrap",children:v})}const c=a.findIndex(v=>v.artifact_role==="primary_media");if(c===-1)return s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),a.length>0&&s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((v,x)=>s.jsxs("li",{children:[v.artifact_role,": ",v.relpath]},x))})]});const y=a[c],g=`/api/archives/${e}/entries/${o}/artifacts/${c}`,h=y.relpath.split(".").pop().toLowerCase();return wg.has(h)?s.jsx("div",{className:"preview-panel",children:s.jsx(og,{src:g,contentType:Ng[h]||"video/mp4"})}):kg.has(h)?s.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:[s.jsx("span",{style:{fontSize:"2rem"},children:"🎡"}),s.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:i.title||o}),s.jsx("audio",{src:g,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):h==="pdf"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(Lu,{src:g,type:"pdf",title:i.title,originalUrl:i.original_url})}):h==="html"||h==="htm"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(Lu,{src:g,type:"page",title:i.title,originalUrl:i.original_url})}):Sg.has(h)?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0,overflow:"auto"},children:s.jsx(xg,{src:g,mime:y.mime_type,title:i.title})}):jg.has(h)?s.jsx("div",{className:"preview-panel",style:{height:"100%"},children:s.jsx(ug,{src:g,alt:i.title||"Image"})}):s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((v,x)=>s.jsxs("li",{children:[v.artifact_role,": ",v.relpath]},x))})]})}function _g({archiveId:e,entry:t,detail:n,onClose:r}){var l,i;return d.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:s.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((i=n==null?void 0:n.summary)==null?void 0:i.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"preview-modal-header",children:[s.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),s.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:"β†—"}),s.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"Γ—"})]}),s.jsx("div",{className:"preview-modal-body",children:s.jsx(af,{archiveId:e,entry:t,detail:n})})]})})}function $u(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 Cg({entry:e,src:t,archiveId:n,onClose:r}){const l=d.useRef(null),[i,a]=d.useState(!1),[o,u]=d.useState(0),[c,y]=d.useState(NaN),[g,h]=d.useState(1);d.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),y(NaN),a(!1))},[t]),d.useEffect(()=>{l.current&&(l.current.volume=g)},[g]);function v(){const f=l.current;f&&(i?f.pause():f.play().catch(()=>{}))}function x(f){const m=l.current;if(!m||!isFinite(c))return;const k=Number(f.target.value);m.currentTime=k,u(k)}function S(f){h(Number(f.target.value))}const N=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",p=(e==null?void 0:e.source_kind)||"other";return s.jsxs(s.Fragment,{children:[s.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 y(((f=l.current)==null?void 0:f.duration)??NaN)},onDurationChange:()=>{var f;return y(((f=l.current)==null?void 0:f.duration)??NaN)},style:{display:"none"}}),s.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:[s.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[s.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:Os(p)}}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:N,children:N})]}),s.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[s.jsx("button",{onClick:v,"aria-label":i?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:i?"⏸":"β–Ά"}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:$u(o)}),s.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:x,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:$u(c)})]}),s.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[s.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"πŸ”Š"}),s.jsx("input",{type:"range",min:0,max:1,step:.01,value:g,onChange:S,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),s.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 Eg({archiveId:e,entryUid:t}){var h,v;const[n,r]=d.useState(null),[l,i]=d.useState(!0),[a,o]=d.useState(null),[u,c]=d.useState(!1);d.useEffect(()=>{if(!u)return;const x=document.documentElement,S=document.body,N=x.style.colorScheme,p=S.style.background;return x.style.colorScheme="dark",S.style.background="#000",()=>{x.style.colorScheme=N,S.style.background=p}},[u]),d.useEffect(()=>{c(!1),Dr(e,t).then(x=>{r(x),i(!1)}).catch(x=>{o((x==null?void 0:x.message)||"Failed to load entry"),i(!1)})},[e,t]);const y=((h=n==null?void 0:n.summary)==null?void 0:h.title)||t,g=(v=n==null?void 0:n.summary)==null?void 0:v.original_url;return s.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:u?"#000":"var(--paper)",fontFamily:"var(--sans)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:u?"8px 12px":"10px 16px",borderBottom:u?"none":"1px solid var(--line)",flexShrink:0,position:u?"sticky":"relative",top:0,zIndex:20,background:u?"rgba(0,0,0,0.82)":"var(--paper-2)",backdropFilter:u?"blur(12px)":"none",WebkitBackdropFilter:u?"blur(12px)":"none"},children:[s.jsx("a",{href:"/",style:{color:u?"#1d9bf0":"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),s.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:u?"#e7e9ea":"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),g&&s.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:u?"#71767b":"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original β†—"})]}),s.jsxs("div",{style:u?{flex:1}:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&s.jsx(af,{archiveId:e,entry:n.summary,detail:n,fullPage:!0,onXArticle:c})]})]})}const bg=7e3;function Tg({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?s.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>s.jsx(Lg,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Pg(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),i=(l[l.length-1]??"")+r,a=i?`${t}/…/${i}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function Lg({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=d.useState(!1),i=e.type==="warning",a=e.type==="success";d.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),bg);return()=>clearTimeout(u)},[r,e.id,t]);const o=Pg(e.locator);return a?s.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"βœ“"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsx("div",{className:"toast-btns",children:s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"Γ—"})})]})}):i?s.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&s.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"Γ—"})]})]}),r&&s.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."})]}):s.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"βœ•"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"Γ—"})]})]}),r&&e.text&&s.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const As=d.createContext(null),Rg=["archive","tags","collections","runs","admin","settings"],zg=["profile","tokens","instance","cookies","extensions","storage"],Lr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})();function Mt(){const e=window.location.pathname.split("/").filter(Boolean),t=Rg.includes(e[0])?e[0]:"archive",n=t==="settings"&&zg.includes(e[1])?e[1]:"profile",r=new URLSearchParams(window.location.search),l=r.get("q")??"",i=t==="archive"?r.get("tag")??null:null,a=t==="archive"?r.get("entry")??null:null,o=t==="archive"?r.get("collection")??null:null,u=o==="main"?null:o,c=r.get("archive")??null;return{view:t,settingsTab:n,q:l,tag:i,entry:a,collection:u,archive:c}}function Ig(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function $g(){const[e,t]=d.useState("loading"),[n,r]=d.useState(null);d.useEffect(()=>{(async()=>{var O,Q,J;if(await Jh()){t("setup");return}const $=await em();if(!$){const{collection:se,archive:Te}=Mt();try{const Ke=await ju(),Ne=Te?((O=Ke.find(Ms=>Ms.id===Te))==null?void 0:O.id)??((Q=Ke[0])==null?void 0:Q.id):(J=Ke[0])==null?void 0:J.id;if(Ne){await Su(Ne,se),i(Ke),o(Ne),c(se),t("authenticated");return}}catch{}t("login");return}r($),t("authenticated")})()},[]),d.useEffect(()=>{const C=()=>{n&&(r(null),t("login"))};return window.addEventListener("auth:expired",C),()=>window.removeEventListener("auth:expired",C)},[n]),d.useEffect(()=>{const C=()=>{const{view:$,settingsTab:O,q:Q,tag:J,entry:se,collection:Te}=Mt();T($),K(O),X(Q),b(J),p(se),m(null),_(se?new Set([se]):new Set),c(Te)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[]);const[l,i]=d.useState([]),[a,o]=d.useState(null),[u,c]=d.useState(()=>Mt().collection),[y,g]=d.useState([]),[h,v]=d.useState([]),[x,S]=d.useState(()=>new Set),[N,p]=d.useState(()=>Mt().entry),[f,m]=d.useState(null),[k,_]=d.useState(()=>{const C=Mt().entry;return C?new Set([C]):new Set}),[E,b]=d.useState(()=>Mt().tag),[j,T]=d.useState(()=>Mt().view),[L,K]=d.useState(()=>Mt().settingsTab),[U,X]=d.useState(()=>Mt().q),[Z,oe]=d.useState(""),[Ae,ye]=d.useState(!1),[D,P]=d.useState([]),[V,te]=d.useState([]),[ee,Re]=d.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[Y,he]=d.useState([]),ue=d.useRef(0),[Ee,Qe]=d.useState(()=>{try{const C=JSON.parse(sessionStorage.getItem("pendingCaptures")||"[]");if(Array.isArray(C))return C}catch{}return[]});d.useEffect(()=>{sessionStorage.setItem("pendingCaptures",JSON.stringify(Ee))},[Ee]);const[Et,ut]=d.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[Wt,ct]=d.useState(null),rt=d.useRef(0),xt=d.useRef(null),bt=d.useRef(!1),A=d.useRef(!0),q=d.useRef(null),de=d.useRef(0),Be=d.useRef(new Map),Dt=(n==null?void 0:n.humanize_slugs)??!1;d.useEffect(()=>{const C=++rt.current;ct(null),!(!f||!a)&&Dr(a,f.entry_uid).then($=>{C===rt.current&&ct($)}).catch(()=>{})},[f,a]),d.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",ee)},[ee]);const ze=d.useCallback(async(C,$,O,Q)=>{if(C){ye(!0);try{let J;$||O?J=await Dh(C,$,O,Q):J=await Su(C,Q),v(J),_(se=>{if(se.size<2)return se;const Te=new Set(J.map(Ne=>Ne.entry_uid)),Ke=new Set([...se].filter(Ne=>Te.has(Ne)));return Ke.size===se.size?se:Ke}),oe(J.length===0?"No results":`${J.length} result${J.length===1?"":"s"}`)}catch{v([]),oe("Search failed. Try again.")}finally{ye(!1)}}},[]);d.useEffect(()=>{e==="authenticated"&&(a||ju().then(C=>{if(i(C),C.length>0){const{archive:$}=Mt(),O=$?C.find(Q=>Q.id===$):null;o((O==null?void 0:O.id)??C[0].id)}}))},[e,a]),d.useEffect(()=>{if(!a)return;const C=!n;if(A.current){A.current=!1;const O=[];C||(O.push(fi(a).then(P)),O.push(Dl(a).then(te))),O.length&&Promise.all(O);return}b(null),m(null),p(null),_(new Set),c(null);const $=[ze(a,"",null,null)];C||($.push(fi(a).then(P)),$.push(Dl(a).then(te))),Promise.all($)},[a,n]),d.useEffect(()=>{if(a===null)return;const C=setTimeout(()=>{ze(a,U,E,u)},300);return()=>clearTimeout(C)},[U,a,u]),d.useEffect(()=>{a!==null&&(E!==null&&T("archive"),ze(a,U,E,u))},[E,a,u]);const Bn=d.useCallback(C=>{o(C),c(null);const $=new URLSearchParams(window.location.search);$.set("archive",C),$.delete("collection");const O=$.toString();history.replaceState(null,"",window.location.pathname+(O?"?"+O:""))},[]);d.useEffect(()=>{if(!a){g([]);return}io(a).then(g).catch(()=>g([]))},[a]);const _n=d.useCallback(C=>{if(!n){const Q=C?y.find(J=>J.collection_uid===C):y.find(J=>J.slug==="_default_");if(Q!=null&&Q.requires_auth){t("login");return}}c(C),m(null),p(null),_(new Set),ze(a,U,E,C);const $=new URLSearchParams(window.location.search);C?($.set("collection",C),$.set("archive",a)):($.delete("collection"),a&&$.set("archive",a));const O=$.toString();history.replaceState(null,"",window.location.pathname+(O?"?"+O:""))},[a,U,E,n,y,ze]),nn=d.useCallback(C=>{T(C),C==="tags"&&a&&Dl(a).then(te)},[a]);d.useEffect(()=>{if(Lr)return;const C=Ig(j,L);window.location.pathname!==C&&history.pushState(null,"",C+window.location.search)},[j,L]);const qe=d.useCallback(C=>{p(C?C.entry_uid:null),m(C)},[]),wr=d.useCallback((C,$)=>{if(Be.current.set(C.entry_uid,C),++de.current,$.shiftKey&&q.current!==null){$.preventDefault();const O=[...document.querySelectorAll("#entries-body [data-entry-uid]")],Q=O.findIndex(Ne=>Ne.dataset.entryUid===q.current),J=O.findIndex(Ne=>Ne.dataset.entryUid===C.entry_uid);if(Q===-1||J===-1){q.current=C.entry_uid,_(new Set([C.entry_uid])),qe(C);return}const se=Math.min(Q,J),Te=Math.max(Q,J),Ke=new Set(O.slice(se,Te+1).map(Ne=>Ne.dataset.entryUid));_(Ke),Ke.size===1&&qe(C)}else if($.ctrlKey||$.metaKey){q.current=C.entry_uid;const O=new Set(k);if(O.has(C.entry_uid)?O.delete(C.entry_uid):O.add(C.entry_uid),_(O),O.size===0)qe(null);else if(O.size===1){const[Q]=O,J=Be.current.get(Q)??h.find(se=>se.entry_uid===Q)??null;if(J)qe(J);else{const se=++de.current;Dr(a,Q).then(Te=>{se===de.current&&(Te!=null&&Te.summary)&&qe(Te.summary)}).catch(()=>{})}}else qe(null)}else q.current=C.entry_uid,_(new Set([C.entry_uid])),qe(C)},[h,k,qe,a]),Un=d.useCallback(C=>{b(C)},[]),w=d.useCallback(()=>{b(null)},[]),B=d.useCallback(()=>{a&&Dl(a).then(te)},[a]),M=d.useCallback((C,$)=>{E===C?b($):E!=null&&E.startsWith(C+"/")&&b($+E.slice(C.length))},[E]),I=d.useCallback(C=>{(E===C||E!=null&&E.startsWith(C+"/"))&&b(null)},[E]),F=d.useCallback((C,$)=>{v(O=>O.map(Q=>Q.entry_uid===C?{...Q,title:$}:Q)),m(O=>O&&O.entry_uid===C?{...O,title:$}:O),ct(O=>O&&O.summary.entry_uid===C?{...O,summary:{...O.summary,title:$}}:O)},[]),H=d.useCallback(()=>{if(!a||!f)return;const C=++rt.current;Dr(a,f.entry_uid).then($=>{C===rt.current&&ct($)}).catch(()=>{})},[a,f]),xe=d.useCallback(C=>{const $=h.some(O=>O.entry_uid===C);S(O=>{const Q=new Set(O);return Q.add(C),Q}),v(O=>O.filter(Q=>Q.entry_uid!==C)),m(O=>(O==null?void 0:O.entry_uid)===C?null:O),p(O=>O===C?null:O),_(O=>{const Q=new Set(O);return Q.delete(C),Q}),$||ze(a,U,E,u)},[h,a,U,E,u,ze]),fe=d.useCallback(C=>{const $=new Set(h.map(Q=>Q.entry_uid)),O=[...C].some(Q=>!$.has(Q));S(Q=>{const J=new Set(Q);return C.forEach(se=>J.add(se)),J}),v(Q=>Q.filter(J=>!C.has(J.entry_uid))),_(new Set),m(null),p(null),O&&ze(a,U,E,u)},[h,a,U,E,u,ze]);d.useEffect(()=>{if(k.size>=2)p(null),m(null);else if(k.size===1){const[C]=k;p(C)}else p(null),m(null)},[k]);const we=d.useMemo(()=>h.filter(C=>k.has(C.entry_uid)),[h,k]);d.useEffect(()=>{if(!N||f)return;const C=h.find($=>$.entry_uid===N);C&&m(C)},[h,N,f]),d.useEffect(()=>{if(Lr)return;const C=new URLSearchParams(window.location.search).get("archive"),$=new URLSearchParams;U&&$.set("q",U),j==="archive"&&E&&$.set("tag",E),j==="archive"&&N&&$.set("entry",N),j==="archive"&&u?($.set("collection",u),a&&$.set("archive",a)):C&&a&&$.set("archive",a);const O=$.toString(),Q=window.location.pathname+(O?"?"+O:"");window.location.pathname+window.location.search!==Q&&history.replaceState(null,"",Q)},[U,E,N,u,a,j]),d.useEffect(()=>{const C=$=>{var se,Te,Ke,Ne;const O=$.key==="/"&&!$.metaKey&&!$.ctrlKey&&!$.altKey,Q=($.metaKey||$.ctrlKey)&&$.key==="k";if(!O&&!Q)return;const J=(se=document.activeElement)==null?void 0:se.tagName;O&&(J==="INPUT"||J==="TEXTAREA"||J==="SELECT")||O&&((Te=document.activeElement)!=null&&Te.isContentEditable)||($.preventDefault(),j==="archive"?((Ke=xt.current)==null||Ke.focus(),(Ne=xt.current)==null||Ne.select()):(bt.current=!0,T("archive")))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[j]),d.useEffect(()=>{const C=$=>{var co,fo;if($.metaKey||$.ctrlKey||$.altKey||$.key!=="j"&&$.key!=="k")return;const O=(co=document.activeElement)==null?void 0:co.tagName;if(O==="INPUT"||O==="TEXTAREA"||O==="SELECT"||(fo=document.activeElement)!=null&&fo.isContentEditable)return;const Q=[...document.querySelectorAll("#entries-body [data-entry-uid]")];if(Q.length===0)return;const[J]=k.size===1?k:[null],se=J?Q.findIndex(rn=>rn.dataset.entryUid===J):-1,Te=$.key==="j"?Math.min(se+1,Q.length-1):Math.max(se-1,0);if(Te===se&&se!==-1)return;const Ke=Q[Te<0?0:Te],Ne=Ke.dataset.entryUid;q.current=Ne;const Ms=++de.current;_(new Set([Ne]));const uo=Be.current.get(Ne)??h.find(rn=>rn.entry_uid===Ne)??null;uo?qe(uo):Dr(a,Ne).then(rn=>{Ms===de.current&&(rn!=null&&rn.summary)&&qe(rn.summary)}).catch(()=>{}),Ke.scrollIntoView({block:"nearest"}),$.preventDefault()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[k,h,qe,a]),d.useEffect(()=>{j==="archive"&&bt.current&&(bt.current=!1,requestAnimationFrame(()=>{var C,$;(C=xt.current)==null||C.focus(),($=xt.current)==null||$.select()}))},[j]);const ce=d.useCallback(()=>{Re(!0)},[]),Ue=d.useCallback(()=>{Re(!1)},[]),le=d.useCallback(()=>{if(a)return Promise.allSettled([ze(a,U,E,u),fi(a).then(P)])},[a,U,E,u,ze]),dt=d.useCallback((C,$,O="error",Q=null)=>{if(O==="warning"&&Et&&$)return;const J=++ue.current;he(se=>[...se,{id:J,text:C,locator:$,type:O,headline:Q}])},[Et]),wt=d.useCallback(C=>{he($=>$.filter(O=>O.id!==C))},[]),yl=d.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),ut(!0),he(C=>C.filter($=>!($.type==="warning"&&$.locator)))},[]),z=d.useCallback(C=>{Qe($=>[...$,C])},[]),re=d.useCallback(C=>{Qe($=>$.filter(O=>O.id!==C))},[]),[be,Ot]=d.useState(null),[Vt,kr]=d.useState(null),Ie=d.useCallback(()=>{f&&Ot(f.entry_uid)},[f]),jr=d.useCallback(()=>Ot(null),[]),of=d.useCallback((C,$)=>{kr({src:C,entry:$})},[]),uf=d.useCallback(()=>kr(null),[]);return d.useEffect(()=>{Ot(null)},[f]),d.useEffect(()=>{const C=$=>{var Q,J,se;if($.key!=="Escape"||ee||be)return;const O=(Q=document.activeElement)==null?void 0:Q.tagName;O==="INPUT"||O==="TEXTAREA"||O==="SELECT"||k.size>0&&($.preventDefault(),_(new Set),(se=(J=document.activeElement)==null?void 0:J.blur)==null||se.call(J))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[ee,be,k]),d.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!Vt),()=>document.body.classList.remove("has-audio-bar")),[Vt]),Lr?s.jsx(Eg,{archiveId:Lr.archiveId,entryUid:Lr.entryUid}):e==="loading"?s.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?s.jsx(bm,{onComplete:()=>t("login")}):e==="login"?s.jsx(Em,{onLogin:C=>{r(C),t("authenticated")}}):s.jsx(As.Provider,{value:{currentUser:n,setCurrentUser:r},children:s.jsxs(s.Fragment,{children:[s.jsx(Tm,{archives:l,archiveId:a,onArchiveChange:Bn,view:j,onViewChange:nn,onCaptureClick:ce,collections:y,selectedCollectionUid:u,onCollectionChange:_n,isPublicSession:!n,onSignInClick:()=>t("login")}),s.jsxs("main",{className:"app-shell",children:[s.jsxs("div",{className:"workspace",children:[j==="archive"&&s.jsxs("div",{className:"toolbar",children:[s.jsxs("div",{className:"search-field",children:[s.jsx("span",{className:"ico","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),s.jsx("input",{ref:xt,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":Ae,placeholder:"Search titles, URLs, types, tags…",value:U,onChange:C=>X(C.target.value)}),s.jsx("span",{className:"kbd",children:"⌘K"})]}),s.jsxs("span",{className:"result-count",children:[Z&&s.jsxs(s.Fragment,{children:[s.jsx("b",{children:Z.split(" ")[0]})," ",Z.split(" ").slice(1).join(" ")]}),E&&s.jsxs("button",{className:"tag-filter-badge",onClick:w,children:["Γ— ",Dt?Gd(E):E]})]})]}),j==="archive"&&s.jsx(Bm,{entries:h,selectedUids:k,onRowClick:wr,archiveId:a,pendingCaptures:Ee,deletedUids:x,isPublicSession:!n}),j==="runs"&&s.jsx(Wm,{runs:D}),j==="admin"&&s.jsx(Qm,{archives:l}),j==="tags"&&s.jsx(qm,{archiveId:a,tagNodes:V,tagFilter:E,onTagFilterSet:Un,onViewChange:nn,onTagRenamed:M,onTagDeleted:I,onTagsRefresh:B,humanizeTags:Dt}),j==="collections"&&s.jsx(Xm,{archiveId:a}),j==="settings"&&s.jsx(Gm,{tab:L,onTabChange:K,archiveId:a})]}),s.jsx(sg,{archiveId:a,selectedEntry:f,selectedUids:k,selectedEntries:we,detail:Wt,onTagFilterSet:Un,tagNodes:V,onTagsRefresh:B,onEntryTitleChange:F,onEntryDeleted:xe,onBulkDeleted:fe,humanizeTags:Dt,onDetailRefresh:H,onOpenPreview:Ie,onPlay:of,isPublicSession:!n})]}),be&&f&&f.entry_uid===be&&s.jsx(_g,{archiveId:a,entry:f,detail:Wt,onClose:jr}),Vt&&s.jsx(Cg,{entry:Vt.entry,src:Vt.src,archiveId:a,onClose:uf}),s.jsx(zm,{open:ee,archiveId:a,onClose:Ue,onCaptured:le,onToast:dt,activeJobs:Ee,onJobStarted:z,onJobSettled:re}),s.jsx(Tg,{toasts:Y,onDismiss:wt,onIgnoreUblock:yl})]})})}Kd(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx($g,{})})); diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 9589243..d9951f9 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -6,8 +6,8 @@ Archivr - - + +
diff --git a/frontend/src/components/PreviewPanel.jsx b/frontend/src/components/PreviewPanel.jsx index f0b45f1..196005d 100644 --- a/frontend/src/components/PreviewPanel.jsx +++ b/frontend/src/components/PreviewPanel.jsx @@ -2,10 +2,12 @@ import VideoPreview from './VideoPreview'; import IframePreview from './IframePreview'; import ImagePreview from './ImagePreview'; import TweetPreview from './TweetPreview'; +import TextPreview from './TextPreview'; const VIDEO_EXTS = new Set(['mp4', 'webm', 'mov', 'mkv', 'avi', 'm4v', 'ogv']); const AUDIO_EXTS = new Set(['mp3', 'ogg', 'm4a', 'opus', 'wav', 'flac', 'aac']); const IMAGE_EXTS = new Set(['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'svg', 'bmp']); +const TEXT_EXTS = new Set(['md', 'markdown', 'txt']); const CONTENT_TYPES = { mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime', mkv: 'video/x-matroska', avi: 'video/x-msvideo', m4v: 'video/mp4', ogv: 'video/ogg', @@ -131,7 +133,20 @@ export default function PreviewPanel({ archiveId, entry, detail, fullPage, onXAr ); } - // 7. Image + // 6b. Plain text / Markdown + if (TEXT_EXTS.has(ext)) { + return ( +
+ +
+ ); + } + + // 7. Image if (IMAGE_EXTS.has(ext)) { return (
diff --git a/frontend/src/components/TextPreview.jsx b/frontend/src/components/TextPreview.jsx new file mode 100644 index 0000000..6befaab --- /dev/null +++ b/frontend/src/components/TextPreview.jsx @@ -0,0 +1,46 @@ +import { useEffect, useState } from 'react' + +/** + * Renders the primary_media artifact of a text/document entry as plain text. + * + * v1 intentionally does NOT render Markdown β€” we don't want a Markdown parser + * dep just to unblock the "no preview available" fallback, and monospace text + * with visible fences reads fine for the note-length content this feature + * captures. Bump to a real renderer if/when Markdown-authored entries grow. + */ +export default function TextPreview({ src, mime, title }) { + const [text, setText] = useState(null) + const [error, setError] = useState(null) + + useEffect(() => { + let cancelled = false + setText(null) + setError(null) + fetch(src, { credentials: 'same-origin' }) + .then(r => { + if (!r.ok) throw new Error(`HTTP ${r.status}`) + return r.text() + }) + .then(t => { if (!cancelled) setText(t) }) + .catch(e => { if (!cancelled) setError(e.message || String(e)) }) + return () => { cancelled = true } + }, [src]) + + if (error) { + return ( +
+ Failed to load text: {error} +
+ ) + } + if (text === null) { + return
Loading…
+ } + return ( +
+ {title &&

{title}

} +
{text}
+ {mime &&
{mime}
} +
+ ) +} diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 150c50f..1503e8e 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -3285,3 +3285,51 @@ body.has-audio-bar { padding-bottom: 56px; } border: 1px solid var(--line); border-radius: 4px; } + +/* ── Text / Markdown preview ────────────────────────────────────────────── */ +.text-preview { + padding: 32px 40px 48px; + max-width: 780px; + margin: 0 auto; + font-family: var(--sans); + color: var(--ink); + overflow: auto; + height: 100%; + box-sizing: border-box; +} +.text-preview--loading, +.text-preview--error { + padding: 24px; + color: var(--muted); + font-size: 13px; +} +.text-preview--error { color: var(--accent); } +.text-preview__title { + font-family: var(--serif, var(--sans)); + font-size: 22px; + font-weight: 600; + margin: 0 0 20px; + line-height: 1.25; + color: var(--ink); +} +.text-preview__body { + white-space: pre-wrap; + overflow-wrap: anywhere; + word-break: break-word; + font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; + font-size: 13.5px; + line-height: 1.65; + color: var(--ink); + background: var(--paper); + border: 1px solid var(--line); + border-radius: var(--r2); + padding: 16px 18px; + margin: 0; +} +.text-preview__mime { + margin-top: 12px; + font-size: 11px; + color: var(--muted); + letter-spacing: .04em; + text-align: right; +}